コード例 #1
0
  /** Sends leave message to everyone ARRG knows :) */
  public void broadcastLeave() {
    VirtualSocketAddress[] addresses = arrg.getRandomMembers(nrOfLeavesSend);

    Broadcaster broadcaster = new Broadcaster(this, addresses);

    // wait for all the broadcasts to be finished
    broadcaster.waitUntilDone();
  }
コード例 #2
0
  // ARRG gossip send and handled in ARRG class
  private void handleArrgGossip(Connection connection) throws IOException {
    String poolName = connection.in().readUTF();

    if (!poolName.equals(registry.getPoolName())) {
      connection.closeWithError("wrong pool name");
      return;
    }

    arrg.handleGossip(connection);
  }
コード例 #3
0
  public void gossip() {
    VirtualSocketAddress address = arrg.getRandomMember();

    if (address == null || address.equals(serverSocket.getLocalSocketAddress())) {
      logger.debug("noone to gossip with, or (not) gossiping with self");
      return;
    }

    try {
      long start = System.currentTimeMillis();
      Connection connection = new Connection(address, CONNECTION_TIMEOUT, true, socketFactory);

      connection.out().writeByte(Protocol.MAGIC_BYTE);
      connection.out().writeByte(Protocol.OPCODE_GOSSIP);
      registry.getIbisIdentifier().writeTo(connection.out());

      pool.writeGossipData(connection.out(), gossipSize);
      elections.writeGossipData(connection.out());

      connection.getAndCheckReply();

      pool.readGossipData(connection.in());
      elections.readGossipData(connection.in());

      connection.close();
      if (statistics != null) {
        statistics.add(
            Protocol.OPCODE_GOSSIP,
            System.currentTimeMillis() - start,
            connection.read(),
            connection.written(),
            false);
      }
    } catch (IOException e) {
      logger.debug("could not gossip with " + address, e);
    }
  }
コード例 #4
0
 public void start() {
   arrg.start();
   createThread();
 }