示例#1
0
  @Test
  public void testInstanceInsertionAndUpdate() throws Exception {
    storeEntity(EntityType.CLUSTER, "testCluster");
    storeEntity(EntityType.FEED, "clicksFeed");
    storeEntity(EntityType.FEED, "clicksSummary");
    EntityState entityState = getEntityState(EntityType.PROCESS, "process");
    ExecutionInstance executionInstance =
        BeanMapperUtil.getExecutionInstance(
            entityState.getEntity().getEntityType(),
            entityState.getEntity(),
            System.currentTimeMillis(),
            "cluster",
            System.currentTimeMillis());
    InstanceState instanceState = new InstanceState(executionInstance);
    initInstanceState(instanceState);
    stateStore.putExecutionInstance(instanceState);
    InstanceID instanceID = new InstanceID(instanceState.getInstance());
    InstanceState actualInstanceState = stateStore.getExecutionInstance(instanceID);
    Assert.assertEquals(actualInstanceState, instanceState);

    instanceState.setCurrentState(InstanceState.STATE.RUNNING);
    Predicate predicate = new Predicate(Predicate.TYPE.DATA);
    instanceState.getInstance().getAwaitingPredicates().add(predicate);

    stateStore.updateExecutionInstance(instanceState);
    actualInstanceState = stateStore.getExecutionInstance(instanceID);
    Assert.assertEquals(actualInstanceState, instanceState);

    try {
      stateStore.putExecutionInstance(instanceState);
      Assert.fail("Exception must have been thrown");
    } catch (StateStoreException e) {
      // no op
    }

    stateStore.deleteExecutionInstance(instanceID);

    try {
      stateStore.getExecutionInstance(instanceID);
      Assert.fail("Exception must have been thrown");
    } catch (StateStoreException e) {
      // no op
    }

    try {
      stateStore.deleteExecutionInstance(instanceID);
      Assert.fail("Exception must have been thrown");
    } catch (StateStoreException e) {
      // no op
    }

    try {
      stateStore.updateExecutionInstance(instanceState);
      Assert.fail("Exception must have been thrown");
    } catch (StateStoreException e) {
      // no op
    }
  }
 // Populates the InstancesResult.Instance instance using ExecutionInstance
 private void populateInstanceInfo(
     InstancesResult.Instance instanceInfo, ExecutionInstance instance)
     throws StateStoreException {
   instanceInfo.cluster = instance.getCluster();
   InstanceState.STATE state =
       STATE_STORE.getExecutionInstance(instance.getId()).getCurrentState();
   switch (state) {
     case SUCCEEDED:
       instanceInfo.status = InstancesResult.WorkflowStatus.SUCCEEDED;
       break;
     case FAILED:
       instanceInfo.status = InstancesResult.WorkflowStatus.FAILED;
       break;
     case KILLED:
       instanceInfo.status = InstancesResult.WorkflowStatus.KILLED;
       break;
     case READY:
       instanceInfo.status = InstancesResult.WorkflowStatus.READY;
       break;
     case WAITING:
       instanceInfo.status = InstancesResult.WorkflowStatus.WAITING;
       break;
     case SUSPENDED:
       instanceInfo.status = InstancesResult.WorkflowStatus.SUSPENDED;
       break;
     case RUNNING:
       instanceInfo.status = InstancesResult.WorkflowStatus.RUNNING;
       break;
     default:
       instanceInfo.status = InstancesResult.WorkflowStatus.UNDEFINED;
       break;
   }
   // Mask wfParams by default
   instanceInfo.wfParams = null;
 }
 @Override
 public void reRun(String cluster, String jobId, Properties props, boolean isForced)
     throws FalconException {
   InstanceState instanceState = STATE_STORE.getExecutionInstance(jobId);
   ExecutionInstance instance = instanceState.getInstance();
   EntityExecutor executor = EXECUTION_SERVICE.getEntityExecutor(instance.getEntity(), cluster);
   executor.rerun(instance, props, isForced);
 }
示例#4
0
  @Test
  public void testGetInstanceFromExternalID() throws Exception {
    storeEntity(EntityType.CLUSTER, "testCluster");
    storeEntity(EntityType.FEED, "clicksFeed");
    storeEntity(EntityType.FEED, "clicksSummary");

    long instance1Time = System.currentTimeMillis() - 180000;
    long instance2Time = System.currentTimeMillis();
    EntityState entityState = getEntityState(EntityType.PROCESS, "processext");
    ExecutionInstance processExecutionInstance1 =
        BeanMapperUtil.getExecutionInstance(
            entityState.getEntity().getEntityType(),
            entityState.getEntity(),
            instance1Time,
            "cluster1",
            instance1Time);
    processExecutionInstance1.setExternalID("external_id_1");
    InstanceState instanceState1 = new InstanceState(processExecutionInstance1);
    instanceState1.setCurrentState(InstanceState.STATE.RUNNING);

    ExecutionInstance processExecutionInstance2 =
        BeanMapperUtil.getExecutionInstance(
            entityState.getEntity().getEntityType(),
            entityState.getEntity(),
            instance2Time,
            "cluster1",
            instance2Time);
    processExecutionInstance2.setExternalID("external_id_2");
    InstanceState instanceState2 = new InstanceState(processExecutionInstance2);
    instanceState2.setCurrentState(InstanceState.STATE.RUNNING);

    stateStore.putExecutionInstance(instanceState1);
    stateStore.putExecutionInstance(instanceState2);

    InstanceState actualInstanceState = stateStore.getExecutionInstance("external_id_1");
    Assert.assertEquals(actualInstanceState.getInstance(), processExecutionInstance1);

    actualInstanceState = stateStore.getExecutionInstance("external_id_2");
    Assert.assertEquals(actualInstanceState.getInstance(), processExecutionInstance2);
  }