Search in sources :

Example 1 with InstanceControlMsg

use of org.apache.heron.instance.InstanceControlMsg in project heron by twitter.

the class StreamManagerClient method handleCheckpointSaved.

private void handleCheckpointSaved(CheckpointManager.StatefulConsistentCheckpointSaved message) {
    LOG.info("Received a StatefulCheckpointSaved message with checkpoint id: " + message.getConsistentCheckpoint().getCheckpointId());
    InstanceControlMsg instanceControlMsg = InstanceControlMsg.newBuilder().setStatefulCheckpointSaved(message).build();
    inControlQueue.offer(instanceControlMsg);
}
Also used : InstanceControlMsg(org.apache.heron.instance.InstanceControlMsg)

Example 2 with InstanceControlMsg

use of org.apache.heron.instance.InstanceControlMsg in project heron by twitter.

the class AbstractTupleRoutingTest method testRoundRobinRouting.

/**
 * Test that tuple routing occurs using round robin
 */
@Test
public void testRoundRobinRouting() throws Exception {
    PhysicalPlanHelper physicalPlanHelper = new PhysicalPlanHelper(constructPhysicalPlan(), getComponentToVerify().getInstanceId());
    InstanceControlMsg instanceControlMsg = InstanceControlMsg.newBuilder().setNewPhysicalPlanHelper(physicalPlanHelper).build();
    executorTester.getInControlQueue().offer(instanceControlMsg);
    SingletonRegistry.INSTANCE.registerSingleton(getInitInfoKey(getComponentToVerify().getName()), groupingInitInfo);
    final int expectedTuplesValidated = 10;
    Runnable task = new Runnable() {

        @Override
        public void run() {
            HeronServerTester.await(outStreamQueueOfferLatch);
            assertNotEquals(0, executorTester.getOutStreamQueue().size());
            while (tupleReceived < expectedTuplesValidated) {
                if (executorTester.getOutStreamQueue().isEmpty()) {
                    continue;
                }
                Message msg = executorTester.getOutStreamQueue().poll();
                assertTrue(msg instanceof HeronTuples.HeronTupleSet);
                HeronTuples.HeronTupleSet set = (HeronTuples.HeronTupleSet) msg;
                assertTrue(set.isInitialized());
                assertFalse(set.hasControl());
                assertTrue(set.hasData());
                HeronTuples.HeronDataTupleSet dataTupleSet = set.getData();
                assertEquals(dataTupleSet.getStream().getId(), "default");
                assertEquals(dataTupleSet.getStream().getComponentName(), getComponentToVerify().getName());
                for (HeronTuples.HeronDataTuple dataTuple : dataTupleSet.getTuplesList()) {
                    List<Integer> destTaskIds = dataTuple.getDestTaskIdsList();
                    assertEquals(1, destTaskIds.size());
                    assertEquals((Integer) tupleReceived, destTaskIds.get(0));
                    tupleReceived++;
                }
            }
            assertEquals(expectedTuplesValidated, tupleReceived);
            assertEquals(getExpectedComponentInitInfo(), groupingInitInfo.toString());
            executorTester.getTestLooper().exitLoop();
        }
    };
    executorTester.getTestLooper().addTasksOnWakeup(task);
    executorTester.getTestLooper().loop();
    assertEquals(expectedTuplesValidated, tupleReceived);
}
Also used : PhysicalPlanHelper(org.apache.heron.common.utils.misc.PhysicalPlanHelper) InstanceControlMsg(org.apache.heron.instance.InstanceControlMsg) Message(com.google.protobuf.Message) HeronTuples(org.apache.heron.proto.system.HeronTuples) Test(org.junit.Test)

Example 3 with InstanceControlMsg

use of org.apache.heron.instance.InstanceControlMsg in project heron by twitter.

the class StreamManagerClient method handleRestoreInstanceStateRequest.

private void handleRestoreInstanceStateRequest(CheckpointManager.RestoreInstanceStateRequest request) {
    LOG.info("Received a RestoreInstanceState request with checkpoint id: " + request.getState().getCheckpointId());
    InstanceControlMsg instanceControlMsg = InstanceControlMsg.newBuilder().setRestoreInstanceStateRequest(request).build();
    inControlQueue.offer(instanceControlMsg);
}
Also used : InstanceControlMsg(org.apache.heron.instance.InstanceControlMsg)

Example 4 with InstanceControlMsg

use of org.apache.heron.instance.InstanceControlMsg in project heron by twitter.

the class StreamManagerClient method handleAssignmentMessage.

private void handleAssignmentMessage(PhysicalPlans.PhysicalPlan pplan) {
    LOG.fine("Physical Plan: " + pplan);
    PhysicalPlanHelper newHelper = new PhysicalPlanHelper(pplan, instance.getInstanceId());
    if (helper != null && (!helper.getMyComponent().equals(newHelper.getMyComponent()) || helper.getMyTaskId() != newHelper.getMyTaskId())) {
        // we will get the new assignment
        throw new RuntimeException("Our Assignment has changed. We will die to pick it");
    }
    if (helper == null) {
        LOG.info("We received a new Physical Plan.");
    } else {
        LOG.info("We received a new Physical Plan with same assignment. Should be state changes.");
        LOG.info(String.format("Old state: %s; new sate: %s.", helper.getTopologyState(), newHelper.getTopologyState()));
    }
    helper = newHelper;
    LOG.info("Push to Executor");
    InstanceControlMsg instanceControlMsg = InstanceControlMsg.newBuilder().setNewPhysicalPlanHelper(helper).build();
    inControlQueue.offer(instanceControlMsg);
}
Also used : PhysicalPlanHelper(org.apache.heron.common.utils.misc.PhysicalPlanHelper) InstanceControlMsg(org.apache.heron.instance.InstanceControlMsg)

Example 5 with InstanceControlMsg

use of org.apache.heron.instance.InstanceControlMsg in project heron by twitter.

the class StreamManagerClient method handleStartStatefulRequest.

private void handleStartStatefulRequest(CheckpointManager.StartInstanceStatefulProcessing request) {
    LOG.info("Received a StartInstanceStatefulProcessing request: " + request);
    InstanceControlMsg instanceControlMsg = InstanceControlMsg.newBuilder().setStartInstanceStatefulProcessing(request).build();
    inControlQueue.offer(instanceControlMsg);
}
Also used : InstanceControlMsg(org.apache.heron.instance.InstanceControlMsg)

Aggregations

InstanceControlMsg (org.apache.heron.instance.InstanceControlMsg)7 PhysicalPlanHelper (org.apache.heron.common.utils.misc.PhysicalPlanHelper)4 Test (org.junit.Test)3 ByteString (com.google.protobuf.ByteString)1 Message (com.google.protobuf.Message)1 InetSocketAddress (java.net.InetSocketAddress)1 ClosedChannelException (java.nio.channels.ClosedChannelException)1 ServerSocketChannel (java.nio.channels.ServerSocketChannel)1 SocketChannel (java.nio.channels.SocketChannel)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 OutgoingPacket (org.apache.heron.common.network.OutgoingPacket)1 REQID (org.apache.heron.common.network.REQID)1 HeronTuples (org.apache.heron.proto.system.HeronTuples)1 PhysicalPlans (org.apache.heron.proto.system.PhysicalPlans)1