use of com.continuuity.weave.common.Cancellable in project weave by continuuity.
the class SocketServer method initialize.
@Override
public void initialize(WeaveContext context) {
super.initialize(context);
running = true;
try {
serverSocket = new ServerSocket(0);
LOG.info("Server started: " + serverSocket.getLocalSocketAddress() + ", id: " + context.getInstanceId() + ", count: " + context.getInstanceCount());
final List<Cancellable> cancellables = ImmutableList.of(context.announce(context.getApplicationArguments()[0], serverSocket.getLocalPort()), context.announce(context.getArguments()[0], serverSocket.getLocalPort()));
canceller = new Cancellable() {
@Override
public void cancel() {
for (Cancellable c : cancellables) {
c.cancel();
}
}
};
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
Aggregations