diff options
author | Lukasz Wojciechowski <l.wojciechow@partner.samsung.com> | 2017-10-24 11:59:52 +0200 |
---|---|---|
committer | Lukasz Wojciechowski <l.wojciechow@partner.samsung.com> | 2018-04-27 17:43:52 +0200 |
commit | e4627e555a80f8ae05f9d854e548bdc866915f52 (patch) | |
tree | e4a8b27370a34ff43520cbf5f7d729902f0b1e23 | |
parent | 1e273354e2f6f35ff9514df8f2cc14d0094d301b (diff) | |
download | boruta-e4627e555a80f8ae05f9d854e548bdc866915f52.tar.gz boruta-e4627e555a80f8ae05f9d854e548bdc866915f52.tar.bz2 boruta-e4627e555a80f8ae05f9d854e548bdc866915f52.zip |
Set ReqsCollection as WorkerChange listener
WorkerChange listener is notified about changes of worker state:
* when worker becomes IDLE;
* when worker's work has been broken by entering FAIL
or MAINTENANCE state.
The ReqsCollection implementing WorkerChange interface reacts by:
* matching new pending request to IDLE worker;
* finishing request execution with FAILED state if worker's job has
been broken.
Change-Id: Icff6a91e3173712243bf6d8ee382d1f1222b4735
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
-rw-r--r-- | requests/requests.go | 4 | ||||
-rw-r--r-- | requests/requests_requestsmanager_test.go | 1 | ||||
-rw-r--r-- | requests/requests_test.go | 1 | ||||
-rw-r--r-- | requests/requests_workerchange_test.go | 1 |
4 files changed, 7 insertions, 0 deletions
diff --git a/requests/requests.go b/requests/requests.go index ec4c596..c343f22 100644 --- a/requests/requests.go +++ b/requests/requests.go @@ -63,6 +63,10 @@ func NewRequestQueue(w matcher.WorkersManager, j matcher.JobsManager) *ReqsColle r.deadlineTimes.setMatcher(r.deadlineMatcher) r.timeoutTimes.setMatcher(r.timeoutMatcher) + if w != nil { + w.SetChangeListener(r) + } + return r } diff --git a/requests/requests_requestsmanager_test.go b/requests/requests_requestsmanager_test.go index 42e44fd..305bd5f 100644 --- a/requests/requests_requestsmanager_test.go +++ b/requests/requests_requestsmanager_test.go @@ -39,6 +39,7 @@ var _ = Describe("Requests as RequestsManager", func() { ctrl = gomock.NewController(GinkgoT()) wm = NewMockWorkersManager(ctrl) jm = NewMockJobsManager(ctrl) + wm.EXPECT().SetChangeListener(gomock.Any()) R = NewRequestQueue(wm, jm) }) AfterEach(func() { diff --git a/requests/requests_test.go b/requests/requests_test.go index 6c414f6..2226ffb 100644 --- a/requests/requests_test.go +++ b/requests/requests_test.go @@ -71,6 +71,7 @@ func initTest(t *testing.T) (*assert.Assertions, *ReqsCollection, *gomock.Contro jm := NewMockJobsManager(ctrl) testErr := errors.New("Test Error") wm.EXPECT().TakeBestMatchingWorker(gomock.Any(), gomock.Any()).Return(WorkerUUID(""), testErr).AnyTimes() + wm.EXPECT().SetChangeListener(gomock.Any()) return assert.New(t), NewRequestQueue(wm, jm), ctrl, jm } diff --git a/requests/requests_workerchange_test.go b/requests/requests_workerchange_test.go index 9090e15..1ce2eb8 100644 --- a/requests/requests_workerchange_test.go +++ b/requests/requests_workerchange_test.go @@ -62,6 +62,7 @@ var _ = Describe("Requests as WorkerChange", func() { ctrl = gomock.NewController(GinkgoT()) wm = NewMockWorkersManager(ctrl) jm = NewMockJobsManager(ctrl) + wm.EXPECT().SetChangeListener(gomock.Any()) R = NewRequestQueue(wm, jm) }) AfterEach(func() { |