Example #1
0
  protected synchronized void startFlusher(final Address new_coord) {
    if (flusher == null || !flusher.isAlive()) {
      if (log.isTraceEnabled()) log.trace(local_addr + ": flushing started");
      // causes subsequent message sends (broadcasts and forwards) to block
      // (https://issues.jboss.org/browse/JGRP-1495)
      flushing = true;

      flusher = new Flusher(new_coord);
      flusher.setName("Flusher");
      flusher.start();
    }
  }
Example #2
0
  public void enqueue(Frame frame, WriteCallback callback, BatchMode batchMode) {
    if (closed.get()) {
      notifyCallbackFailure(callback, new EOFException("Connection has been closed locally"));
      return;
    }
    if (flusher.isFailed()) {
      notifyCallbackFailure(callback, failure);
      return;
    }

    FrameEntry entry = new FrameEntry(frame, callback, batchMode);

    synchronized (lock) {
      switch (frame.getOpCode()) {
        case OpCode.PING:
          {
            // Prepend PINGs so they are processed first.
            queue.add(0, entry);
            break;
          }
        case OpCode.CLOSE:
          {
            // There may be a chance that other frames are
            // added after this close frame, but we will
            // fail them later to keep it simple here.
            closed.set(true);
            queue.add(entry);
            break;
          }
        default:
          {
            queue.add(entry);
            break;
          }
      }
    }

    if (LOG.isDebugEnabled()) {
      LOG.debug("{} queued {}", this, entry);
    }

    flusher.iterate();
  }
Example #3
0
  public void close() {
    if (closed.compareAndSet(false, true)) {
      LOG.debug("{} closing {}", this);
      EOFException eof = new EOFException("Connection has been closed locally");
      flusher.failed(eof);

      // Fail also queued entries.
      List<FrameEntry> entries = new ArrayList<>();
      synchronized (lock) {
        entries.addAll(queue);
        queue.clear();
      }
      // Notify outside sync block.
      for (FrameEntry entry : entries) {
        notifyCallbackFailure(entry.callback, eof);
      }
    }
  }
Example #4
0
 /** Flushes resources associated with this TextureData by calling Flusher.flush(). */
 public void flush() {
   if (flusher != null) {
     flusher.flush();
     flusher = null;
   }
 }