blob: 2f4cd4f273c441a1e3f40d0d69bcffe1b95887b1 (
plain)
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
|
package com.orbekk.stats;
import com.orbekk.protobuf.SimpleProtobufServer;
public class Server {
private final Experiment1Impl exp1 = new Experiment1Impl();
private final Experiment2Impl exp2 = new Experiment2Impl();
public static void main(String[] args) {
new Server().run();
}
public void run() {
addShutdownHook();
SimpleProtobufServer server = SimpleProtobufServer.create(
Common.PORT);
server.registerService(exp1);
server.registerService(exp2);
System.out.println("Waiting for samples...");
server.start();
}
public void addShutdownHook() {
class ShutdownTask implements Runnable {
@Override public void run() {
exp1.writeSamples("experiment1.data");
exp2.writeSamples("experiment2.data");
}
}
Runtime.getRuntime().addShutdownHook(new Thread(new ShutdownTask()));
}
}
|