public class LeaderElectionMessagingService extends com.google.common.util.concurrent.AbstractIdleService implements MessagingService
MessagingService that performs lead-election and only operates if it is currently a leader.| Modifier and Type | Method and Description |
|---|---|
void |
createTopic(TopicMetadata topicMetadata)
Creates a topic with the given metadata.
|
void |
deleteTopic(co.cask.cdap.proto.id.TopicId topicId)
Deletes a topic
|
TopicMetadata |
getTopic(co.cask.cdap.proto.id.TopicId topicId)
Returns the metadata of the given topic.
|
List<co.cask.cdap.proto.id.TopicId> |
listTopics(co.cask.cdap.proto.id.NamespaceId namespaceId)
Returns the list of topics available under the given namespace.
|
MessageFetcher |
prepareFetch(co.cask.cdap.proto.id.TopicId topicId)
Prepares to fetch messages from the given topic.
|
RollbackDetail |
publish(StoreRequest request)
Publishes a list of messages to the messaging system.
|
void |
rollback(co.cask.cdap.proto.id.TopicId topicId,
RollbackDetail rollbackDetail)
Rollbacks messages published to the given topic with the given transaction.
|
protected void |
shutDown() |
protected void |
startUp() |
void |
storePayload(StoreRequest request)
Stores a list of messages to the messaging system.
|
void |
updateTopic(TopicMetadata topicMetadata)
Updates the metadata of a topic.
|
protected void startUp()
throws Exception
startUp in class com.google.common.util.concurrent.AbstractIdleServiceExceptionprotected void shutDown()
throws Exception
shutDown in class com.google.common.util.concurrent.AbstractIdleServiceExceptionpublic void createTopic(TopicMetadata topicMetadata) throws co.cask.cdap.api.messaging.TopicAlreadyExistsException, IOException
MessagingServicecreateTopic in interface MessagingServicetopicMetadata - topic to be createdco.cask.cdap.api.messaging.TopicAlreadyExistsException - if the topic to be created already existIOException - if failed to create the topicpublic void updateTopic(TopicMetadata topicMetadata) throws co.cask.cdap.api.messaging.TopicNotFoundException, IOException
MessagingServiceupdateTopic in interface MessagingServicetopicMetadata - the topic metadata to be updatedco.cask.cdap.api.messaging.TopicNotFoundException - if the topic doesn't existIOException - if failed to update the topic metadatapublic void deleteTopic(co.cask.cdap.proto.id.TopicId topicId)
throws co.cask.cdap.api.messaging.TopicNotFoundException,
IOException
MessagingServicedeleteTopic in interface MessagingServicetopicId - the topic to be deletedco.cask.cdap.api.messaging.TopicNotFoundException - if the topic doesn't existIOException - if failed to delete the topicpublic TopicMetadata getTopic(co.cask.cdap.proto.id.TopicId topicId) throws co.cask.cdap.api.messaging.TopicNotFoundException, IOException
MessagingServicegetTopic in interface MessagingServicetopicId - message topicTopicMetadata of the given topic.co.cask.cdap.api.messaging.TopicNotFoundException - if the topic doesn't existIOException - if failed to retrieve topic metadata.public List<co.cask.cdap.proto.id.TopicId> listTopics(co.cask.cdap.proto.id.NamespaceId namespaceId) throws IOException
MessagingServicelistTopics in interface MessagingServicenamespaceId - the namespace to list topics under itList of TopicId.IOException - if failed to retrieve topics.public MessageFetcher prepareFetch(co.cask.cdap.proto.id.TopicId topicId) throws co.cask.cdap.api.messaging.TopicNotFoundException, IOException
MessagingServiceprepareFetch in interface MessagingServicetopicId - the topic to fetch message fromMessageFetcher for setting up parameters for fetching messages from the messaging systemco.cask.cdap.api.messaging.TopicNotFoundException - if the topic doesn't existIOException - if failed to fetch messages@Nullable public RollbackDetail publish(StoreRequest request) throws co.cask.cdap.api.messaging.TopicNotFoundException, IOException
MessagingServicepublish in interface MessagingServicerequest - the StoreRequest containing messages to be publishedRollbackDetail containing
information for rollback; otherwise null will be returned.co.cask.cdap.api.messaging.TopicNotFoundException - if the topic doesn't existIOException - if failed to publish messagespublic void storePayload(StoreRequest request) throws co.cask.cdap.api.messaging.TopicNotFoundException, IOException
MessagingServicestorePayload in interface MessagingServicerequest - the StoreRequest containing messages to be storedco.cask.cdap.api.messaging.TopicNotFoundException - if the topic doesn't existIOException - if failed to store messagespublic void rollback(co.cask.cdap.proto.id.TopicId topicId,
RollbackDetail rollbackDetail)
throws co.cask.cdap.api.messaging.TopicNotFoundException,
IOException
MessagingServicerollback in interface MessagingServicetopicId - the topic where the messages were published underrollbackDetail - the RollbackDetail as returned by the
MessagingService.publish(StoreRequest) call,
which contains information needed for the rollbackco.cask.cdap.api.messaging.TopicNotFoundException - if the topic doesn't existIOException - if failed to rollback changesCopyright © 2017 Cask Data, Inc. Licensed under the Apache License, Version 2.0.