コード例 #1
0
  @Test
  public void testInsertRetrieveAndUpdate() throws Exception {
    EntityState entityState = getEntityState(EntityType.PROCESS, "process");
    stateStore.putEntity(entityState);
    EntityID entityID = new EntityID(entityState.getEntity());
    EntityState actualEntityState = stateStore.getEntity(entityID);
    Assert.assertEquals(actualEntityState.getEntity(), entityState.getEntity());
    Assert.assertEquals(actualEntityState.getCurrentState(), entityState.getCurrentState());
    try {
      stateStore.putEntity(entityState);
      Assert.fail("Exception must have been thrown");
    } catch (StateStoreException e) {
      // no op
    }

    entityState.setCurrentState(EntityState.STATE.SCHEDULED);
    stateStore.updateEntity(entityState);
    actualEntityState = stateStore.getEntity(entityID);
    Assert.assertEquals(actualEntityState.getEntity(), entityState.getEntity());
    Assert.assertEquals(actualEntityState.getCurrentState(), entityState.getCurrentState());

    stateStore.deleteEntity(entityID);
    boolean entityExists = stateStore.entityExists(entityID);
    Assert.assertEquals(entityExists, false);

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

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

    try {
      stateStore.deleteEntity(entityID);
      Assert.fail("Exception must have been thrown");
    } catch (StateStoreException e) {
      // no op
    }
  }
コード例 #2
0
  @Test
  public void testCascadingDelete() throws Exception {
    storeEntity(EntityType.CLUSTER, "testCluster");
    storeEntity(EntityType.FEED, "clicksFeed");
    storeEntity(EntityType.FEED, "clicksSummary");
    EntityState entityState = getEntityState(EntityType.PROCESS, "process1");
    stateStore.putEntity(entityState);
    ExecutionInstance processExecutionInstance1 =
        BeanMapperUtil.getExecutionInstance(
            entityState.getEntity().getEntityType(),
            entityState.getEntity(),
            System.currentTimeMillis() - 60000,
            "cluster1",
            System.currentTimeMillis() - 60000);
    InstanceState instanceState1 = new InstanceState(processExecutionInstance1);
    instanceState1.setCurrentState(InstanceState.STATE.READY);

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

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

    Collection<InstanceState> instances =
        stateStore.getAllExecutionInstances(entityState.getEntity(), "cluster1");
    Assert.assertEquals(instances.size(), 2);

    stateStore.deleteEntity(new EntityID(entityState.getEntity()));
    deleteEntity(EntityType.PROCESS, "process1");

    instances = stateStore.getAllExecutionInstances(entityState.getEntity(), "cluster1");
    Assert.assertEquals(instances.size(), 0);
  }