@Override public void init() throws Throwable { cluster = protocolServer.newClient(Cluster.class); cluster.addClusterListener(clusterListener); builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); transformer = TransformerFactory.newInstance().newTransformer(); }
public ClusterMemberContext(ProtocolServer server) { server.addBindingListener( new BindingListener() { @Override public void listeningAt(URI me) { myId = me; } }); }
private void acquireServerId() throws RuntimeException { final Semaphore semaphore = new Semaphore(0); protocolServer.addBindingListener( new BindingListener() { @Override public void listeningAt(URI me) { serverId = me; semaphore.release(); protocolServer.removeBindingListener(this); } }); try { if (!semaphore.tryAcquire(1, TimeUnit.MINUTES)) { throw new RuntimeException("Unable to acquire server id, timed out"); } } catch (InterruptedException e) { Thread.interrupted(); throw new RuntimeException("Unable to acquire server id, interrupted", e); } }