@Override public void deleteTopic(String topic) throws TopicNotFoundException, IOException { messagingService.deleteTopic(namespace.topic(topic)); } }
@Inject TimeScheduler(Supplier<org.quartz.Scheduler> schedulerSupplier, MessagingService messagingService, CConfiguration cConf) { this.schedulerSupplier = schedulerSupplier; this.messagingService = messagingService; this.scheduler = null; this.schedulerStarted = false; this.topicId = NamespaceId.SYSTEM.topic(cConf.get(Constants.Scheduler.TIME_EVENT_TOPIC)); }
@Inject MessagingWorkflowStateWriter(CConfiguration cConf, MessagingService messagingService) { this.topic = NamespaceId.SYSTEM.topic(cConf.get(Constants.Metadata.MESSAGING_TOPIC)); this.messagingService = messagingService; this.retryStrategy = RetryStrategies.fromConfiguration(cConf, "system.metadata."); }
@Inject MessagingMetadataPublisher(CConfiguration cConf, MessagingService messagingService) { this.topic = NamespaceId.SYSTEM.topic(cConf.get(Constants.Metadata.MESSAGING_TOPIC)); this.messagingService = messagingService; this.retryStrategy = RetryStrategies.fromConfiguration(cConf, "system.metadata."); }
@Inject MessagingUsageWriter(CConfiguration cConf, MessagingService messagingService) { this.topic = NamespaceId.SYSTEM.topic(cConf.get(Constants.Metadata.MESSAGING_TOPIC)); this.messagingService = messagingService; this.retryStrategy = RetryStrategies.fromConfiguration(cConf, "system.metadata."); }
@Inject MessagingLineageWriter(CConfiguration cConf, MessagingService messagingService) { this.topic = NamespaceId.SYSTEM.topic(cConf.get(Constants.Metadata.MESSAGING_TOPIC)); this.messagingService = messagingService; this.retryStrategy = RetryStrategies.fromConfiguration(cConf, "system.metadata."); }
@Inject ProvisionerNotifier(CConfiguration cConf, MessagingService messagingService) { this.topic = NamespaceId.SYSTEM.topic(cConf.get(Constants.AppFabric.PROGRAM_STATUS_EVENT_TOPIC)); this.retryStrategy = RetryStrategies.fromConfiguration(cConf, "system.program.state."); this.messagingService = messagingService; }
@GET @Path("/topics/{topic}") public void getTopic(HttpRequest request, HttpResponder responder, @PathParam("namespace") String namespace, @PathParam("topic") String topic) throws Exception { TopicId topicId = new NamespaceId(namespace).topic(topic); TopicMetadata metadata = messagingService.getTopic(topicId); responder.sendJson(HttpResponseStatus.OK, GSON.toJson(metadata.getProperties(), TOPIC_PROPERTY_TYPE)); }
@Inject public MessagingProgramStateWriter(CConfiguration cConf, MessagingService messagingService) { this.programStatePublisher = new MessagingProgramStatePublisher(messagingService, NamespaceId.SYSTEM.topic(cConf.get( Constants.AppFabric.PROGRAM_STATUS_EVENT_TOPIC)), RetryStrategies.fromConfiguration(cConf, "system.program.state.")); }
@POST @Path("/rollback") public void rollback(FullHttpRequest request, HttpResponder responder, @PathParam("namespace") String namespace, @PathParam("topic") String topic) throws Exception { TopicId topicId = new NamespaceId(namespace).topic(topic); Decoder decoder = DecoderFactory.get().directBinaryDecoder(new ByteBufInputStream(request.content()), null); DatumReader<GenericRecord> datumReader = new GenericDatumReader<>(Schemas.V1.PublishResponse.SCHEMA); messagingService.rollback(topicId, new GenericRecordRollbackDetail(datumReader.read(null, decoder))); responder.sendStatus(HttpResponseStatus.OK); }
@Override public List<TopicId> listTopics(NamespaceId namespaceId) throws IOException { HttpRequest request = remoteClient.requestBuilder(HttpMethod.GET, namespaceId.getNamespace() + "/topics").build(); HttpResponse response = remoteClient.execute(request); handleError(response, "Failed to list topics in namespace " + namespaceId); List<String> topics = GSON.fromJson(response.getResponseBodyAsString(), TOPIC_LIST_TYPE); List<TopicId> result = new ArrayList<>(topics.size()); for (String topic : topics) { result.add(namespaceId.topic(topic)); } return Collections.unmodifiableList(result); }
@PUT @Path("/topics/{topic}") public void createTopic(FullHttpRequest request, HttpResponder responder, @PathParam("namespace") String namespace, @PathParam("topic") String topic) throws Exception { TopicId topicId = new NamespaceId(namespace).topic(topic); messagingService.createTopic(new TopicMetadata(topicId, decodeTopicProperties(request.content()))); responder.sendStatus(HttpResponseStatus.OK); }
@Inject DefaultAuditPublisher(CConfiguration cConf, MessagingService messagingService) { this.messagingService = messagingService; this.auditTopic = NamespaceId.SYSTEM.topic(cConf.get(Constants.Audit.TOPIC)); this.retryStrategy = RetryStrategies.timeLimit( cConf.getLong(Constants.Audit.PUBLISH_TIMEOUT_MS), TimeUnit.MILLISECONDS, RetryStrategies.exponentialDelay(10, 200, TimeUnit.MILLISECONDS)); }
@Inject DefaultAuditPublisher(CConfiguration cConf, MessagingService messagingService) { this.messagingService = messagingService; this.auditTopic = NamespaceId.SYSTEM.topic(cConf.get(Constants.Audit.TOPIC)); this.retryStrategy = RetryStrategies.timeLimit( cConf.getLong(Constants.Audit.PUBLISH_TIMEOUT_MS), TimeUnit.MILLISECONDS, RetryStrategies.exponentialDelay(10, 200, TimeUnit.MILLISECONDS)); }
public AdminEventPublisher(CConfiguration cConf, MessagingContext messagingContext) { this.topic = NamespaceId.SYSTEM.topic(cConf.get(Constants.Metadata.MESSAGING_TOPIC)); this.retryStrategy = RetryStrategies.timeLimit( 20, TimeUnit.SECONDS, RetryStrategies.exponentialDelay(10, 200, TimeUnit.MILLISECONDS)); this.messagingContext = messagingContext; }
public ProgramStateWriterWithHeartBeat(ProgramRunId programRunId, ProgramStateWriter programStateWriter, MessagingService messagingService, CConfiguration cConf) { this(programRunId, programStateWriter, cConf.getLong(Constants.ProgramHeartbeat.HEARTBEAT_INTERVAL_SECONDS), new MessagingProgramStatePublisher(messagingService, NamespaceId.SYSTEM.topic(cConf.get( Constants.AppFabric.PROGRAM_STATUS_EVENT_TOPIC)), RetryStrategies.fromConfiguration(cConf, "system.program.state."))); }
public ProgramStateWriterWithHeartBeat(ProgramRunId programRunId, ProgramStateWriter programStateWriter, MessagingService messagingService, CConfiguration cConf) { this(programRunId, programStateWriter, cConf.getLong(Constants.ProgramHeartbeat.HEARTBEAT_INTERVAL_SECONDS), new MessagingProgramStatePublisher(messagingService, NamespaceId.SYSTEM.topic(cConf.get( Constants.AppFabric.PROGRAM_STATUS_EVENT_TOPIC)), RetryStrategies.fromConfiguration(cConf, "system.program.state."))); }
@Override public CloseableIterator<Message> fetch(String namespace, String topic, int limit, long timestamp) throws IOException, TopicNotFoundException { co.cask.cdap.messaging.MessageFetcher fetcher = messagingService .prepareFetch(new NamespaceId(namespace).topic(topic)) .setLimit(limit) .setStartTime(timestamp); if (transaction != null) { fetcher.setTransaction(transaction); } return new MessageIterator(fetcher.fetch()); }
@BeforeClass public static void init() throws Exception { cConf = CConfiguration.create(); cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath()); Injector injector = AppFabricTestHelper.getInjector(cConf, new AuditModule().getDistributedModules()); messagingService = injector.getInstance(MessagingService.class); if (messagingService instanceof Service) { ((Service) messagingService).startAndWait(); } auditTopic = NamespaceId.SYSTEM.topic(cConf.get(Constants.Audit.TOPIC)); }
@Test public void testGeMetadata() throws Exception { TopicId topicId = new NamespaceId("ns2").topic("d"); TopicMetadata metadata = new TopicMetadata(topicId, "ttl", "100"); for (int i = 1; i <= 5; i++) { client.createTopic(metadata); TopicMetadata topicMetadata = client.getTopic(topicId); Assert.assertEquals(100, topicMetadata.getTTL()); Assert.assertEquals(i, topicMetadata.getGeneration()); client.deleteTopic(topicId); } }