Package eu.stratosphere.runtime.io.channels

Examples of eu.stratosphere.runtime.io.channels.ChannelID


   *
   * @return the corresponding channelID.
   */
  public ChannelID toChannelID() {

    final ChannelID channelID = new ChannelID();
    channelID.setID(this);

    return channelID;
  }
View Full Code Here


              "number in current envelope header.");
        }

        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;
        this.currentBufferRequestSize = bufferSize > 0 ? bufferSize : 0;

        this.headerBuffer.clear();
      }
    }

    // --------------------------------------------------------------------
    // (2) events (var length)
    // --------------------------------------------------------------------
    if (this.currentEventsBuffer != null) {
      copy(in, this.currentEventsBuffer);

      if (this.currentEventsBuffer.hasRemaining()) {
        return DecoderState.PENDING;
      }
      else {
        this.currentEventsBuffer.flip();
        this.currentEnvelope.setEventsSerialized(this.currentEventsBuffer);
        this.currentEventsBuffer = null;
      }
    }

    // --------------------------------------------------------------------
    // (3) buffer (var length)
    // --------------------------------------------------------------------
    // (a) request a buffer from OUR pool
    if (this.currentBufferRequestSize > 0) {
      JobID jobId = this.currentEnvelope.getJobID();
      ChannelID sourceId = this.currentEnvelope.getSource();
      Buffer buffer = requestBufferForTarget(jobId, sourceId, this.currentBufferRequestSize);

      if (buffer == null) {
        return DecoderState.NO_BUFFER_AVAILABLE;
      }
View Full Code Here

   * Tests the setID method of an abstract ID.
   */
  @Test
  public void testSetID() {

    final ChannelID id1 = new ChannelID();
    final ChannelID id2 = new ChannelID();
    id1.setID(id2);

    assertEquals(id1.hashCode(), id2.hashCode());
    assertEquals(id1, id2);
  }
View Full Code Here

   * Tests the serialization/deserialization of an abstract ID.
   */
  @Test
  public void testSerialization() {

    final ChannelID origID = new ChannelID();
    try {
      final ChannelID copyID = (ChannelID) CommonTestUtils.createCopy(origID);

      assertEquals(origID.hashCode(), copyID.hashCode());
      assertEquals(origID, copyID);

    } catch (IOException e) {
      e.printStackTrace();
    }
View Full Code Here

   * Tests the constructor of the {@link ChannelDeploymentDescriptor} class with valid arguments.
   */
  @Test
  public void testConstructorWithValidArguments() {

    final ChannelID outputChannelID = new ChannelID();
    final ChannelID inputChannelID = new ChannelID();

    final ChannelDeploymentDescriptor cdd = new ChannelDeploymentDescriptor(outputChannelID, inputChannelID);

    assertEquals(outputChannelID, cdd.getOutputChannelID());
    assertEquals(inputChannelID, cdd.getInputChannelID());
View Full Code Here

   * Tests the constructor of the {@link ChannelDeploymentDescriptor} class with invalid arguments.
   */
  @Test
  public void testConstructorWithInvalidArguments() {

    final ChannelID channelID = new ChannelID();

    boolean firstExceptionCaught = false;
    boolean secondExceptionCaught = false;

    try {
View Full Code Here

   * Tests the serialization/deserialization of the {@link ChannelDeploymentDescriptor} class.
   */
  @Test
  public void testSerialization() {

    final ChannelID outputChannelID = new ChannelID();
    final ChannelID inputChannelID = new ChannelID();

    final ChannelDeploymentDescriptor orig = new ChannelDeploymentDescriptor(outputChannelID, inputChannelID);

    ChannelDeploymentDescriptor copy = null;

View Full Code Here

  public void testSerialization() {

    final GateID gateID = new GateID();
    final ChannelType channelType = ChannelType.IN_MEMORY;
    final List<ChannelDeploymentDescriptor> channels = new ArrayList<ChannelDeploymentDescriptor>(0);
    final ChannelDeploymentDescriptor cdd = new ChannelDeploymentDescriptor(new ChannelID(), new ChannelID());
    channels.add(cdd);

    final GateDeploymentDescriptor orig = new GateDeploymentDescriptor(gateID, channelType,
      channels);
View Full Code Here

    final EmbeddedChannel channel = new EmbeddedChannel(new OutboundEnvelopeEncoder());

    int numBuffers = 0;
    for (int i = 0; i < NUM_RANDOM_ENVELOPES; i++) {
      Envelope env = new Envelope(i, new JobID(), new ChannelID());
      int expectedEncodedMsgSize = OutboundEnvelopeEncoder.HEADER_SIZE;

      if (random.nextBoolean()) {
        int eventsSize = random.nextInt(MAX_EVENTS_SIZE + 1);
        expectedEncodedMsgSize += eventsSize;
View Full Code Here

  private Envelope nextEnvelope(boolean withBuffer) {
    return nextEnvelope(withBuffer, false);
  }

  private Envelope nextEnvelope(int bufferSize, AbstractEvent... events) {
    Envelope env = new Envelope(random.nextInt(), new JobID(), new ChannelID());
    if (bufferSize > 0) {
      byte[] data = new byte[bufferSize];
      random.nextBytes(data);

      env.setBuffer(spy(new Buffer(new MemorySegment(data), bufferSize, RECYCLER)));
View Full Code Here

TOP

Related Classes of eu.stratosphere.runtime.io.channels.ChannelID

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.