Ejemplo n.º 1
0
 @Override
 public void init() throws Throwable {
   cluster = protocolServer.newClient(Cluster.class);
   cluster.addClusterListener(clusterListener);
   builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
   transformer = TransformerFactory.newInstance().newTransformer();
 }
Ejemplo n.º 2
0
 public ClusterMemberContext(ProtocolServer server) {
   server.addBindingListener(
       new BindingListener() {
         @Override
         public void listeningAt(URI me) {
           myId = me;
         }
       });
 }
Ejemplo n.º 3
0
  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);
    }
  }