blob: a395da7fe2d9b52fa886c0ecb5eab427c840f852 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
package org.eclipse.osee.ote.master.rest.client.internal;
import java.net.URI;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServer;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServerAvailableNodes;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServerResult;
import org.eclipse.osee.ote.master.rest.model.OTEServer;
public class OTEMasterServerImpl implements OTEMasterServer {
static final String CONTEXT_NAME = "otemaster";
static final String CONTEXT_SERVERS = "servers";
private JaxRsClient client;
private ExecutorService executor;
public void setJaxRsClient(JaxRsClient client) {
this.client = client;
}
public void start() {
executor = Executors.newCachedThreadPool(new ThreadFactory() {
@Override
public Thread newThread(Runnable arg0) {
Thread th = new Thread(arg0);
th.setName("OTE Master Client " + th.getId());
th.setDaemon(true);
return th;
}
});
}
public void stop() {
if (executor != null) {
executor.shutdown();
}
}
@Override
public Future<OTEMasterServerAvailableNodes> getAvailableServers(URI uri) {
return executor.submit(new GetAvailableServers(client, uri));
}
@Override
public Future<OTEMasterServerResult> addServer(URI uri, OTEServer server) {
return executor.submit(new AddServer(client, uri, server));
}
@Override
public Future<OTEMasterServerResult> removeServer(URI uri, OTEServer server) {
return executor.submit(new RemoveServer(client, uri, server));
}
}
|