Merge "Add task termination traces"
[openflowplugin.git] / applications / forwardingrules-manager / src / main / java / org / opendaylight / openflowplugin / applications / frm / nodeconfigurator / JobEntry.java
1 /*
2  * Copyright (c) 2018 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowplugin.applications.frm.nodeconfigurator;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import com.google.common.util.concurrent.SettableFuture;
12 import java.util.concurrent.Callable;
13 import javax.annotation.Nullable;
14
15 /**
16  * JobEntry is the entity built per job submitted by the application and
17  * enqueued to the book-keeping data structure.
18  */
19 class JobEntry<T> {
20
21     private final String key;
22     private volatile @Nullable Callable<ListenableFuture<T>> mainWorker;
23     private volatile SettableFuture<T> resultFuture;
24
25     JobEntry(String key, Callable<ListenableFuture<T>> mainWorker) {
26         this.key = key;
27         this.mainWorker = mainWorker;
28         resultFuture = SettableFuture.create();
29     }
30
31     public String getKey() {
32         return key;
33     }
34
35     @Nullable public Callable<ListenableFuture<T>> getMainWorker() {
36         return mainWorker;
37     }
38
39     public void setMainWorker(@Nullable Callable<ListenableFuture<T>> mainWorker) {
40         this.mainWorker = mainWorker;
41     }
42
43     public ListenableFuture<T> getResultFuture() {
44         return resultFuture;
45     }
46
47     public void setResultFuture(@Nullable T result) {
48         this.resultFuture.set(result);
49     }
50
51 }