Пример #1
0
    public void run() {

      for (int i = 1; i <= number_of_msgs; i++) {
        try {
          Message msg = new Message(null, buf);
          if (oob) msg.setFlag(Message.Flag.OOB);
          if (dont_bundle) msg.setFlag(Message.Flag.DONT_BUNDLE);
          if (i > 0 && do_print > 0 && i % do_print == 0) System.out.println("-- sent " + i);

          Buffer buffer = writeMessage(msg);

          output_lock.lock(); // need to sync if we have more than 1 sender
          try {
            // msg.writeTo(output);
            output.writeInt(buffer.getLength());
            output.write(buffer.getBuf(), buffer.getOffset(), buffer.getLength());
            // output.flush();
          } finally {
            output_lock.unlock();
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
Пример #2
0
  public void startFlush(boolean automatic_resume) throws Exception {
    if (!flushSupported())
      throw new IllegalStateException(
          "Flush is not supported, add pbcast.FLUSH protocol to your configuration");

    try {
      down(new Event(Event.SUSPEND));
    } catch (Exception e) {
      throw new Exception("Flush failed", e.getCause());
    } finally {
      if (automatic_resume) stopFlush();
    }
  }
Пример #3
0
 public void startFlush(List<Address> flushParticipants, boolean automatic_resume)
     throws Exception {
   if (!flushSupported())
     throw new IllegalStateException(
         "Flush is not supported, add pbcast.FLUSH protocol to your configuration");
   View v = getView();
   boolean validParticipants = v != null && v.getMembers().containsAll(flushParticipants);
   if (!validParticipants)
     throw new IllegalArgumentException(
         "Current view " + v + " does not contain all flush participants " + flushParticipants);
   try {
     down(new Event(Event.SUSPEND, flushParticipants));
   } catch (Exception e) {
     throw new Exception("Flush failed", e.getCause());
   } finally {
     if (automatic_resume) stopFlush(flushParticipants);
   }
 }