Search in sources :

Example 6 with Publisher

use of com.yahoo.bullet.pubsub.Publisher in project bullet-storm by yahoo.

the class DRPCPubSubTest method testQueryProcessingSingleInstanceTypes.

@Test
public void testQueryProcessingSingleInstanceTypes() throws Exception {
    config.set(DRPCConfig.PUBSUB_CONTEXT_NAME, PubSub.Context.QUERY_PROCESSING.name());
    DRPCPubSub pubSub = new DRPCPubSub(config);
    Publisher publisher = pubSub.getPublisher();
    Subscriber subscriber = pubSub.getSubscriber();
    Assert.assertTrue(publisher instanceof DRPCResultPublisher);
    Assert.assertTrue(subscriber instanceof DRPCQuerySubscriber);
}
Also used : Subscriber(com.yahoo.bullet.pubsub.Subscriber) Publisher(com.yahoo.bullet.pubsub.Publisher) Test(org.testng.annotations.Test)

Example 7 with Publisher

use of com.yahoo.bullet.pubsub.Publisher in project bullet-storm by yahoo.

the class DRPCPubSubTest method testQuerySubmissionOneInstanceIsTheSameInstance.

@Test
public void testQuerySubmissionOneInstanceIsTheSameInstance() throws Exception {
    config.set(DRPCConfig.PUBSUB_CONTEXT_NAME, PubSub.Context.QUERY_SUBMISSION.name());
    DRPCPubSub pubSub = new DRPCPubSub(config);
    Publisher publisher = pubSub.getPublisher();
    Subscriber subscriber = pubSub.getSubscriber();
    Assert.assertTrue(publisher == subscriber);
    // All future calls just return the same instance
    Assert.assertTrue(publisher == pubSub.getPublisher());
    Assert.assertTrue(subscriber == pubSub.getSubscriber());
    Assert.assertTrue(pubSub.getPublisher() == pubSub.getSubscriber());
    // So do calls to get multiples after
    List<Publisher> publishers = pubSub.getPublishers(42);
    List<Subscriber> subscribers = pubSub.getSubscribers(20);
    Assert.assertEquals(publishers.size(), 1);
    Assert.assertEquals(subscribers.size(), 1);
    Assert.assertEquals(publishers.get(0), publisher);
    Assert.assertEquals(subscribers.get(0), subscriber);
}
Also used : Subscriber(com.yahoo.bullet.pubsub.Subscriber) Publisher(com.yahoo.bullet.pubsub.Publisher) Test(org.testng.annotations.Test)

Example 8 with Publisher

use of com.yahoo.bullet.pubsub.Publisher in project bullet-storm by yahoo.

the class ResultBolt method createPublisher.

@Override
protected Publisher createPublisher() throws PubSubException {
    PubSub pubSub = PubSub.from(config);
    Publisher publisher = pubSub.getPublisher();
    log.info("Setup PubSub: {} with Publisher: {}", pubSub, publisher);
    return publisher;
}
Also used : PubSub(com.yahoo.bullet.pubsub.PubSub) Publisher(com.yahoo.bullet.pubsub.Publisher)

Aggregations

Publisher (com.yahoo.bullet.pubsub.Publisher)8 Test (org.testng.annotations.Test)6 Subscriber (com.yahoo.bullet.pubsub.Subscriber)4 BulletConfig (com.yahoo.bullet.common.BulletConfig)2 PubSub (com.yahoo.bullet.pubsub.PubSub)2 Map (java.util.Map)1