// DryadJobManager organizes running Jobs on allocated Dryad.
type DryadJobManager interface {
// Create starts execution of Job definition on allocated Dryad.
+ // Job's config is passed in order to avoid need to fetch it from Job Manager.
+ //
+ // JobID is used only to reference currently executing Jobs.
//
// Slow read from a channel may miss some events.
- Create(JobID, Dryad, chan<- DryadJobStatusChange) error
+ Create(JobID, Dryad, Config, chan<- DryadJobStatusChange) error
// Cancel stops DryadJob associated with Job.
//
// newDryadJob creates an instance of dryadJob and starts a goroutine
// executing phases of given job implemented by provider of DryadJobRunner interface.
-func newDryadJob(job JobID, rusalka Dryad, changes chan<- DryadJobStatusChange) *dryadJob {
+func newDryadJob(job JobID, rusalka Dryad, conf Config, changes chan<- DryadJobStatusChange) *dryadJob {
session := dryad.NewSessionProvider(rusalka)
device := dryad.NewDeviceCommunicationProvider(session)
ctx, cancel := context.WithCancel(context.Background())
- runner := newDryadJobRunner(ctx, session, device)
+ runner := newDryadJobRunner(ctx, session, device, conf)
dJob := newDryadJobWithCancel(job, changes, runner, cancel)
}
// Create is part of DryadJobManager interface.
-func (d *DryadJobs) Create(job JobID, rusalka Dryad, changes chan<- DryadJobStatusChange) error {
+func (d *DryadJobs) Create(job JobID, rusalka Dryad, conf Config, changes chan<- DryadJobStatusChange) error {
_, ok := d.jobs[job]
if ok {
return ErrDuplicated
d.jobsMutex.Lock()
defer d.jobsMutex.Unlock()
// FIXME(amistewicz): dryadJobs should not be stored indefinitely.
- d.jobs[job] = newDryadJob(job, rusalka, changes)
+ d.jobs[job] = newDryadJob(job, rusalka, conf, changes)
return nil
}
})
create := func() {
- err := djm.Create(jobID, Dryad{}, nil)
+ err := djm.Create(jobID, Dryad{}, Config{}, nil)
Expect(err).ToNot(HaveOccurred())
}
It("should fail to duplicate jobs", func() {
create()
- err := djm.Create(jobID, Dryad{}, nil)
+ err := djm.Create(jobID, Dryad{}, Config{}, nil)
Expect(err).To(Equal(ErrDuplicated))
})
import (
"context"
+ "git.tizen.org/tools/weles"
"git.tizen.org/tools/weles/manager/dryad"
)
ctx context.Context
rusalka dryad.SessionProvider
device dryad.DeviceCommunicationProvider
+ conf weles.Config
}
// newDryadJobRunner prepares a new instance of dryadJobRunner
// and returns DryadJobRunner interface to it.
-func newDryadJobRunner(ctx context.Context, rusalka dryad.SessionProvider, device dryad.DeviceCommunicationProvider) DryadJobRunner {
+func newDryadJobRunner(ctx context.Context, rusalka dryad.SessionProvider,
+ device dryad.DeviceCommunicationProvider, conf weles.Config) DryadJobRunner {
return &dryadJobRunner{
ctx: ctx,
rusalka: rusalka,
device: device,
+ conf: conf,
}
}
"context"
"errors"
+ "git.tizen.org/tools/weles"
+
"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
ctrl = gomock.NewController(GinkgoT())
mockSession = NewMockSessionProvider(ctrl)
mockDevice = NewMockDeviceCommunicationProvider(ctrl)
- djr = newDryadJobRunner(context.Background(), mockSession, mockDevice)
+ djr = newDryadJobRunner(context.Background(), mockSession, mockDevice, weles.Config{})
})
AfterEach(func() {