本文整理汇总了Java中rice.p2p.scribe.Topic类的典型用法代码示例。如果您正苦于以下问题:Java Topic类的具体用法?Java Topic怎么用?Java Topic使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Topic类属于rice.p2p.scribe包,在下文中一共展示了Topic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: before
import rice.p2p.scribe.Topic; //导入依赖的package包/类
@Before
public void before() throws Exception {
scribeClient = mock(ScribeMultiClient.class);
topic = mock(Topic.class);
id = mock(Id.class);
topicId = mock(Id.class);
endpoint = mock(Endpoint.class);
scribeContent = mock(KoalaScribeContent.class);
applicationContext = mock(ApplicationContext.class);
wrappedScribeContentMessage = new WrappedScribeContentMessage(mock(NodeHandle.class), topic, WrappedScribeContentMessageType.ANYCAST, EntityMethod.UPDATE, "json", "transaction-id");
koalaIdFactory = mock(KoalaIdFactory.class);
when(koalaIdFactory.buildIdFromToString(TOPIC_ID)).thenReturn(topicId);
scribe = spy(new KoalaScribeImpl(setupPastryNode(), applicationContext));
scribe.setKoalaIdFactory(koalaIdFactory);
messageDeserializer = scribe.getEndpoint().getDeserializer();
}
示例2: deliver
import rice.p2p.scribe.Topic; //导入依赖的package包/类
/**
* Internal Pi method that converts pastry Scribe messages to PubSubMessageContext messages.
*/
@Override
@Deprecated
public final void deliver(Topic topic, ScribeContent content) {
LOG.debug(String.format("deliver(Topic - %s, ScribeContent - %s)", topic, content));
if (content instanceof KoalaScribeContent) {
KoalaScribeContent koalaScribeContent = (KoalaScribeContent) content;
String transactionUID = koalaScribeContent.getTransactionUID();
EntityMethod entityMethod = koalaScribeContent.getEntityMethod();
MDCHelper.putTransactionUID(transactionUID);
long startTime = ContinuationUtils.logStartOfContinuation(ContinuationUtils.SCRIBE_DELIVER, transactionUID);
try {
PiEntity scribeData = getPiEntityFromJson(koalaScribeContent.getJsonData());
PubSubMessageContext pubSubMessageContext = newPubSubMessageContext(topic, koalaScribeContent.getSourceNodeHandle(), transactionUID);
deliver(pubSubMessageContext, entityMethod, scribeData);
} catch (Throwable t) {
LOG.error(t.getMessage(), t);
throw new RuntimeException(t);
} finally {
MDCHelper.clearTransactionUID();
ContinuationUtils.logEndOfContinuation(ContinuationUtils.SCRIBE_DELIVER, transactionUID, startTime);
}
}
}
示例3: testOnApplicationStarting
import rice.p2p.scribe.Topic; //导入依赖的package包/类
@Test
public void testOnApplicationStarting() {
// setup
setupTopics();
Topic topic = mock(Topic.class);
when(aScribe.subscribeToTopic(isA(String.class), isA(ScribeMultiClient.class))).thenReturn(topic);
when(koalaIdUtils.isIdClosestToMe(eq(nodeIdFull), eq(leafNodeHandles), isA(Id.class), eq(NodeScope.AVAILABILITY_ZONE))).thenReturn(false).thenReturn(true);
// act
volumeManagerApplication.onApplicationStarting();
// assert
assertTrue(this.volumeManagerApplication.getSubscribedTopics().contains(createVolumeTopic));
assertTrue(this.volumeManagerApplication.getSubscribedTopics().contains(deleteVolumeTopic));
assertTrue(this.volumeManagerApplication.getSubscribedTopics().contains(detachVolumeTopic));
assertTrue(this.volumeManagerApplication.getSubscribedTopics().contains(attachVolumeTopic));
assertTrue(this.volumeManagerApplication.getSubscribedTopics().contains(createSnapshotTopic));
assertTrue(this.volumeManagerApplication.getSubscribedTopics().contains(deleteSnapshotTopic));
verify(volumeManagerQueueManager).createVolumeApplicationWatchers(nodeIdFull);
}
示例4: deliver
import rice.p2p.scribe.Topic; //导入依赖的package包/类
/**
* Called when a message is received for a topic this node has subscribed.
* <p>
* This application only uses one topic to broadcast reset notifications.
* When receiving a reset notification, reset the current value to the
* original value and set the weight to 1.
*/
@Override
public void deliver(Topic topic, ScribeContent content)
{
if (trace)
{
log("deliver (" + topic + "," + content + ")");
}
if (content instanceof ResetNotification)
{
this.value = trueValue;
this.valueBuffer = trueValue;
this.weight = 1.;
this.weightBuffer = 1.;
}
}
示例5: shouldAllowConstructionWithTopicEntityAndTransactionUID
import rice.p2p.scribe.Topic; //导入依赖的package包/类
@Test
public void shouldAllowConstructionWithTopicEntityAndTransactionUID() {
// act
pubSubMessageContext = new PubSubMessageContext(handlingApplication, topicEntity, "aa");
// assert
assertEquals(new Topic(tId), pubSubMessageContext.getTopic());
assertEquals("aa", pubSubMessageContext.getTransactionUID());
}
示例6: childAdded
import rice.p2p.scribe.Topic; //导入依赖的package包/类
@Override
public final void childAdded(Topic topic, NodeHandle child) {
long startTime = ContinuationUtils.logStartOfContinuation(ContinuationUtils.SCRIBE_CHILD_ADDED, null);
try {
LOG.debug(String.format("childAdded(%s, %s)", topic, child));
} finally {
ContinuationUtils.logEndOfContinuation(ContinuationUtils.SCRIBE_CHILD_ADDED, null, startTime);
}
}
示例7: testFailedTopic
import rice.p2p.scribe.Topic; //导入依赖的package包/类
@Test
public void testFailedTopic() {
// setup
ArrayList<Topic> topics = new ArrayList<Topic>();
koalaPastryScribeApplication.subscribe(idFactory.convertToPId(topic.getId()), koalaPastryScribeApplication);
topics.add(topic);
// act
koalaPastryScribeApplication.subscribeFailed(topics);
// assert
assertEquals(0, koalaPastryScribeApplication.getSubscribedTopics().size());
}
示例8: subscribeFailed
import rice.p2p.scribe.Topic; //导入依赖的package包/类
@Override
public final void subscribeFailed(Topic topic) {
long startTime = ContinuationUtils.logStartOfContinuation(ContinuationUtils.SCRIBE_SUBSCRIBE_FAILED, null);
try {
LOG.debug(String.format(SUBSCRIBE_FAILED_S, topic));
if (topic != null) {
subscribedTopics.remove(topic);
}
} finally {
ContinuationUtils.logEndOfContinuation(ContinuationUtils.SCRIBE_SUBSCRIBE_FAILED, null, startTime);
}
}
示例9: WrappedScribeContentMessage
import rice.p2p.scribe.Topic; //导入依赖的package包/类
public WrappedScribeContentMessage(NodeHandle sourceHandle, Topic aTopic, WrappedScribeContentMessageType aWrappedScribeContentMessageType, EntityMethod anEntityMethod, String aJsonData, String aTransactionUID) {
super(sourceHandle, aTopic);
wrappedScribeContentMessageType = aWrappedScribeContentMessageType;
entityMethod = anEntityMethod;
jsonData = aJsonData;
transactionUID = aTransactionUID;
}
示例10: constructorsShouldBeEquivalent
import rice.p2p.scribe.Topic; //导入依赖的package包/类
@Test
public void constructorsShouldBeEquivalent() {
// act
PubSubMessageContext scopedEntityContext = new PubSubMessageContext(handlingApplication, topicEntity, TRANSACTION_ID);
PubSubMessageContext topicContext = new PubSubMessageContext(handlingApplication, new Topic(tId), handlingApplication.getNodeHandle(), TRANSACTION_ID);
// assert
assertEquals(scopedEntityContext, topicContext);
}
示例11: MyScribeClient
import rice.p2p.scribe.Topic; //导入依赖的package包/类
/**
* The constructor for this scribe client. It will construct the ScribeApplication.
*
* @param node the PastryNode
*/
public MyScribeClient(Node node) {
// you should recognize this from lesson 3
this.endpoint = node.buildEndpoint(this, "myinstance");
// construct Scribe
myScribe = new ScribeImpl(node,"myScribeInstance");
// construct the topic
myTopic = new Topic(new PastryIdFactory(node.getEnvironment()), "example topic");
System.out.println("myTopic = "+myTopic);
// now we can receive messages
endpoint.register();
}
示例12: deliver
import rice.p2p.scribe.Topic; //导入依赖的package包/类
/**
* Called whenever we receive a published message.
*/
public void deliver(Topic topic, ScribeContent content) {
System.out.println("MyScribeClient.deliver("+topic+","+content+")");
if (((MyScribeContent)content).from == null) {
new Exception("Stack Trace").printStackTrace();
}
}
示例13: testCreateTopic
import rice.p2p.scribe.Topic; //导入依赖的package包/类
@Test
public void testCreateTopic() {
// setup
PId topicPId = mock(PId.class);
when(topicPId.forLocalScope(eq(NodeScope.REGION))).thenReturn(topicPId);
when(koalaIdFactory.buildPId(DUMMY_NETWORK)).thenReturn(topicPId);
when(koalaIdFactory.buildId(topicPId)).thenReturn(id);
// act
Topic result = scribe.createTopic(DUMMY_NETWORK);
// assert
assertThat(result.getId(), equalTo(id));
}
示例14: subscribeSuccess
import rice.p2p.scribe.Topic; //导入依赖的package包/类
@Override
public final void subscribeSuccess(Collection<Topic> topics) {
long startTime = ContinuationUtils.logStartOfContinuation(ContinuationUtils.SCRIBE_SUBSCRIBE_SUCCESS, null);
try {
LOG.debug(String.format("subscribeSuccess(%s)", topics));
handleSubscribeSuccess(topics);
} finally {
ContinuationUtils.logEndOfContinuation(ContinuationUtils.SCRIBE_SUBSCRIBE_SUCCESS, null, startTime);
}
}
示例15: subscribeToTopic
import rice.p2p.scribe.Topic; //导入依赖的package包/类
public Topic subscribeToTopic(String topicName, ScribeMultiClient scribeClient) {
LOG.debug(String.format("subscribeToTopic(%s, %s)", topicName, scribeClient));
Topic topic = createTopic(topicName);
subscribe(topic, scribeClient);
return topic;
}