use of co.cask.cdap.proto.Notification 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());
}
use of co.cask.cdap.proto.Notification in project cdap by caskdata.
the class CoreSchedulerServiceTest method publishNotification.
private void publishNotification(TopicId topicId, ProgramId programId, String dataset) throws TopicNotFoundException, IOException, TransactionFailureException, AlreadyExistsException, BadRequestException {
DatasetId datasetId = programId.getNamespaceId().dataset(dataset);
PartitionKey partitionKey = PartitionKey.builder().addIntField("part1", 1).build();
Notification notification = Notification.forPartitions(datasetId, ImmutableList.of(partitionKey));
messagingService.publish(StoreRequestBuilder.of(topicId).addPayloads(GSON.toJson(notification)).build());
}
use of co.cask.cdap.proto.Notification in project cdap by caskdata.
the class ScheduleTaskPublisher method publishNotification.
/**
* Publish notification for the triggered schedule
* @param notificationType type of the notification
* @param scheduleId {@link ScheduleId} of the triggered schedule
* @param systemOverrides Arguments that would be supplied as system runtime arguments for the program.
* @param userOverrides Arguments to add to the user runtime arguments for the program.
*/
public void publishNotification(Notification.Type notificationType, ScheduleId scheduleId, Map<String, String> systemOverrides, Map<String, String> userOverrides) throws Exception {
Map<String, String> properties = new HashMap<>();
properties.put(ProgramOptionConstants.SCHEDULE_ID, scheduleId.toString());
properties.put(ProgramOptionConstants.SYSTEM_OVERRIDES, GSON.toJson(systemOverrides));
properties.put(ProgramOptionConstants.USER_OVERRIDES, GSON.toJson(userOverrides));
Notification notification = new Notification(notificationType, properties);
messagingService.publish(StoreRequestBuilder.of(topicId).addPayloads(GSON.toJson(notification)).build());
}
Aggregations