コード例 #1
0
 @Override
 public String touch(Entity entity, String cluster, Boolean skipDryRun) throws FalconException {
   EntityID id = new EntityID(entity);
   // Ideally state store should have all entities, but, check anyway.
   if (STATE_STORE.entityExists(id)) {
     Date endTime = EntityUtil.getEndTime(entity, cluster);
     if (endTime.before(DateUtil.now())) {
       throw new FalconException(
           "Entity's end time "
               + SchemaHelper.formatDateUTC(endTime)
               + " is before current time. Entity can't be touch-ed as it has completed.");
     }
     Collection<InstanceState> instances =
         STATE_STORE.getExecutionInstances(entity, cluster, InstanceState.getRunningStates());
     // touch should happen irrespective of the state the entity is in.
     DAGEngineFactory.getDAGEngine(cluster)
         .touch(entity, (skipDryRun == null) ? Boolean.FALSE : skipDryRun);
     StringBuilder builder = new StringBuilder();
     builder
         .append(entity.toShortString())
         .append("/Effective Time: ")
         .append(getEffectiveTime(entity, cluster, instances));
     return builder.toString();
   }
   throw new FalconException("Could not find entity " + id + " in state store.");
 }
コード例 #2
0
 @Override
 public boolean isActive(Entity entity) throws FalconException {
   EntityID id = new EntityID(entity);
   // Ideally state store should have all entities, but, check anyway.
   if (STATE_STORE.entityExists(id)) {
     return STATE_STORE.getEntity(id).getCurrentState() != EntityState.STATE.SUBMITTED;
   }
   return false;
 }
コード例 #3
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
    }
  }