Search in sources :

Example 6 with PartitionTrigger

use of co.cask.cdap.internal.app.runtime.schedule.trigger.PartitionTrigger in project cdap by caskdata.

the class JobQueueDataset method isTriggerSatisfied.

private boolean isTriggerSatisfied(Trigger trigger, List<Notification> notifications) {
    if (trigger instanceof TimeTrigger || trigger instanceof StreamSizeTrigger) {
        // is initially created
        return true;
    }
    if (trigger instanceof PartitionTrigger) {
        PartitionTrigger partitionTrigger = (PartitionTrigger) trigger;
        int numPartitions = 0;
        for (Notification notification : notifications) {
            String numPartitionsString = notification.getProperties().get("numPartitions");
            numPartitions += Integer.parseInt(numPartitionsString);
        }
        return numPartitions >= partitionTrigger.getNumPartitions();
    }
    throw new IllegalArgumentException("Unknown trigger class: " + trigger.getClass());
}
Also used : TimeTrigger(co.cask.cdap.internal.app.runtime.schedule.trigger.TimeTrigger) StreamSizeTrigger(co.cask.cdap.internal.app.runtime.schedule.trigger.StreamSizeTrigger) Constraint(co.cask.cdap.internal.schedule.constraint.Constraint) Notification(co.cask.cdap.proto.Notification) PartitionTrigger(co.cask.cdap.internal.app.runtime.schedule.trigger.PartitionTrigger)

Aggregations

PartitionTrigger (co.cask.cdap.internal.app.runtime.schedule.trigger.PartitionTrigger)6 ProgramSchedule (co.cask.cdap.internal.app.runtime.schedule.ProgramSchedule)5 Test (org.junit.Test)5 SimpleJob (co.cask.cdap.internal.app.runtime.schedule.queue.SimpleJob)3 TimeTrigger (co.cask.cdap.internal.app.runtime.schedule.trigger.TimeTrigger)3 Store (co.cask.cdap.app.store.Store)2 StreamSizeTrigger (co.cask.cdap.internal.app.runtime.schedule.trigger.StreamSizeTrigger)2 DatasetManagementException (co.cask.cdap.api.dataset.DatasetManagementException)1 TopicNotFoundException (co.cask.cdap.api.messaging.TopicNotFoundException)1 AlreadyExistsException (co.cask.cdap.common.AlreadyExistsException)1 NotFoundException (co.cask.cdap.common.NotFoundException)1 DynamicTransactionExecutorFactory (co.cask.cdap.data.runtime.DynamicTransactionExecutorFactory)1 DatasetFramework (co.cask.cdap.data2.dataset2.DatasetFramework)1 TransactionExecutorFactory (co.cask.cdap.data2.transaction.TransactionExecutorFactory)1 Constraint (co.cask.cdap.internal.schedule.constraint.Constraint)1 Notification (co.cask.cdap.proto.Notification)1 TransactionAware (org.apache.tephra.TransactionAware)1 TransactionExecutor (org.apache.tephra.TransactionExecutor)1 TransactionSystemClient (org.apache.tephra.TransactionSystemClient)1