当前位置: 首页>>代码示例>>Java>>正文


Java Topic类代码示例

本文整理汇总了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();
}
 
开发者ID:barnyard,项目名称:p2p-core,代码行数:20,代码来源:KoalaScribeImplTest.java

示例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);
        }
    }
}
 
开发者ID:barnyard,项目名称:pi,代码行数:29,代码来源:KoalaPastryScribeApplicationBase.java

示例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);
}
 
开发者ID:barnyard,项目名称:pi,代码行数:23,代码来源:VolumeManagerApplicationTest.java

示例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.;
	}
}
 
开发者ID:darioseidl,项目名称:pastry-push-sum,代码行数:24,代码来源:PastryPushSum.java

示例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());
}
 
开发者ID:barnyard,项目名称:p2p-core,代码行数:10,代码来源:PubSubMessageContextTest.java

示例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);
    }
}
 
开发者ID:barnyard,项目名称:p2p-core,代码行数:11,代码来源:KoalaPastryScribeApplicationBase.java

示例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());
}
 
开发者ID:barnyard,项目名称:p2p-core,代码行数:14,代码来源:KoalaPastryScribeApplicationTest.java

示例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);
    }
}
 
开发者ID:barnyard,项目名称:p2p-core,代码行数:14,代码来源:KoalaPastryScribeApplicationBase.java

示例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;
}
 
开发者ID:barnyard,项目名称:p2p-core,代码行数:8,代码来源:WrappedScribeContentMessage.java

示例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);
}
 
开发者ID:barnyard,项目名称:p2p-core,代码行数:10,代码来源:PubSubMessageContextTest.java

示例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();
}
 
开发者ID:barnyard,项目名称:pi,代码行数:20,代码来源:MyScribeClient.java

示例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();
  }
}
 
开发者ID:barnyard,项目名称:pi,代码行数:10,代码来源:MyScribeClient.java

示例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));
}
 
开发者ID:barnyard,项目名称:p2p-core,代码行数:15,代码来源:KoalaScribeImplTest.java

示例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);
    }
}
 
开发者ID:barnyard,项目名称:p2p-core,代码行数:12,代码来源:KoalaPastryScribeApplicationBase.java

示例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;
}
 
开发者ID:barnyard,项目名称:p2p-core,代码行数:8,代码来源:KoalaScribeImpl.java


注:本文中的rice.p2p.scribe.Topic类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。