Package eu.stratosphere.runtime.io.network

Examples of eu.stratosphere.runtime.io.network.Envelope


    // discard empty buffers
    if (buffer.size() == 0) {
      return;
    }

    Envelope envelope = createNextEnvelope();
    envelope.setBuffer(buffer);
    this.envelopeDispatcher.dispatchFromOutputChannel(envelope);
  }
View Full Code Here


  }

  public void sendEvent(AbstractEvent event) throws IOException, InterruptedException {
    checkStatus();

    Envelope envelope = createNextEnvelope();
    envelope.serializeEventList(Arrays.asList(event));
    this.envelopeDispatcher.dispatchFromOutputChannel(envelope);
  }
View Full Code Here

  }

  public void sendBufferAndEvent(Buffer buffer, AbstractEvent event) throws IOException, InterruptedException {
    checkStatus();

    Envelope envelope = createNextEnvelope();
    envelope.setBuffer(buffer);
    envelope.serializeEventList(Arrays.asList(event));
    this.envelopeDispatcher.dispatchFromOutputChannel(envelope);
  }
View Full Code Here

      return;
    }

    this.senderCloseRequested = true;

    Envelope envelope = createNextEnvelope();
    envelope.serializeEventList(Arrays.asList(new ChannelCloseEvent()));
    this.envelopeDispatcher.dispatchFromOutputChannel(envelope);
  }
View Full Code Here

      throw new ReceiverAlreadyClosedException();
    }
  }

  private Envelope createNextEnvelope() {
    return new Envelope(this.currentSeqNum++, getJobID(), getID());
  }
View Full Code Here

    synchronized (this.queuedEnvelopes) {
      this.destroyCalled = true;

      while (!this.queuedEnvelopes.isEmpty()) {
        final Envelope envelope = this.queuedEnvelopes.poll();
        if (envelope.getBuffer() != null) {
          buffersToRecycle.add(envelope.getBuffer());
        }
      }
    }

    while (!buffersToRecycle.isEmpty()) {
View Full Code Here

    synchronized (this.queuedEnvelopes) {

      final Iterator<Envelope> it = this.queuedEnvelopes.iterator();
      while (it.hasNext()) {

        final Envelope envelope = it.next();
        ++numberOfQueuedEnvelopes;
        final Buffer buffer = envelope.getBuffer();
        if (buffer == null) {
          continue;
        }

        ++numberOfQueuedEnvelopesWithMemoryBuffers;
View Full Code Here

      }
      return next;
    }

    // if no events are pending, get the next buffer
    Envelope nextEnvelope;
    synchronized (this.queuedEnvelopes) {
      if (this.queuedEnvelopes.isEmpty()) {
        return null;
      }
      nextEnvelope = this.queuedEnvelopes.poll();
    }

    // schedule events as pending, because events come always after the buffer!
    List<AbstractEvent> events = (List<AbstractEvent>) nextEnvelope.deserializeEvents();
    Iterator<AbstractEvent> eventsIt = events.iterator();
    if (eventsIt.hasNext()) {
      this.pendingEvents = eventsIt;
    }

    // get the buffer, if there is one
    if (nextEnvelope.getBuffer() != null) {
      return new BufferOrEvent(nextEnvelope.getBuffer());
    }
    else if (this.pendingEvents != null) {
      // if the field is not null, it must always have a next value!
      BufferOrEvent next = new BufferOrEvent(this.pendingEvents.next());
      if (!this.pendingEvents.hasNext()) {
View Full Code Here

      throw new IOException("Received an envelope with neither data nor events.");
    }
  }

  public void transferEventToOutputChannel(AbstractEvent event) throws IOException, InterruptedException {
    Envelope ephemeralEnvelope = new Envelope(0, getJobID(), getID());
    ephemeralEnvelope.serializeEventList(Arrays.asList(event));

    this.envelopeDispatcher.dispatchFromInputChannel(ephemeralEnvelope);
  }
View Full Code Here

        int seqNum = this.headerBuffer.getInt();
        JobID jobId = JobID.fromByteBuffer(this.headerBuffer);
        ChannelID sourceId = ChannelID.fromByteBuffer(this.headerBuffer);

        this.currentEnvelope = new Envelope(seqNum, jobId, sourceId);

        int eventsSize = this.headerBuffer.getInt();
        int bufferSize = this.headerBuffer.getInt();

        this.currentEventsBuffer = eventsSize > 0 ? ByteBuffer.allocate(eventsSize) : null;
View Full Code Here

TOP

Related Classes of eu.stratosphere.runtime.io.network.Envelope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.