Search in sources :

Example 1 with Subscriber

use of com.yahoo.bullet.pubsub.Subscriber in project bullet-core by yahoo.

the class RESTPubSubTest method testGetSubscribers.

@Test
public void testGetSubscribers() throws PubSubException {
    BulletConfig config = new BulletConfig("src/test/resources/test_config.yaml");
    config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "QUERY_SUBMISSION");
    RESTPubSub pubSub = new RESTPubSub(config);
    List<Subscriber> subscribers = pubSub.getSubscribers(8);
    Assert.assertNotNull(subscribers);
    Assert.assertTrue(subscribers.get(0) instanceof RESTSubscriber);
    Assert.assertTrue(subscribers.get(7) instanceof RESTSubscriber);
    config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "QUERY_PROCESSING");
    pubSub = new RESTPubSub(config);
    subscribers = pubSub.getSubscribers(8);
    Assert.assertNotNull(subscribers);
    Assert.assertTrue(subscribers.get(0) instanceof RESTSubscriber);
    Assert.assertTrue(subscribers.get(7) instanceof RESTSubscriber);
}
Also used : Subscriber(com.yahoo.bullet.pubsub.Subscriber) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 2 with Subscriber

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

the class DRPCPubSubTest method testQuerySubmissionSingleInstanceTypes.

@Test
public void testQuerySubmissionSingleInstanceTypes() 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 instanceof DRPCQueryResultPubscriber);
    Assert.assertTrue(subscriber instanceof DRPCQueryResultPubscriber);
}
Also used : Subscriber(com.yahoo.bullet.pubsub.Subscriber) Publisher(com.yahoo.bullet.pubsub.Publisher) Test(org.testng.annotations.Test)

Example 3 with Subscriber

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

the class DRPCPubSubTest method testQuerySubmissionMultipleInstancesAreTheSameInstances.

@Test
public void testQuerySubmissionMultipleInstancesAreTheSameInstances() throws Exception {
    config.set(DRPCConfig.PUBSUB_CONTEXT_NAME, PubSub.Context.QUERY_SUBMISSION.name());
    DRPCPubSub pubSub = new DRPCPubSub(config);
    List<Publisher> publishers = pubSub.getPublishers(10);
    List<Subscriber> subscribers = pubSub.getSubscribers(20);
    Assert.assertEquals(publishers.size(), 10);
    // If we ask for more, the size is the same as the first call
    Assert.assertEquals(subscribers.size(), 10);
    // If we ask for less, the size is the same as the first call
    Assert.assertEquals(pubSub.getSubscribers(1).size(), 10);
    // If we ask for the same, the size is the same as the first call
    Assert.assertEquals(pubSub.getSubscribers(10).size(), 10);
    // The corresponding items are the same
    IntStream.range(0, 9).forEach(i -> Assert.assertTrue(publishers.get(i) == subscribers.get(i)));
    Publisher publisher = pubSub.getPublisher();
    Subscriber subscriber = pubSub.getSubscriber();
    // If you ask for one, it's the first one in the list
    Assert.assertTrue(publisher == subscriber);
    Assert.assertTrue(publishers.get(0) == publisher);
}
Also used : Subscriber(com.yahoo.bullet.pubsub.Subscriber) Publisher(com.yahoo.bullet.pubsub.Publisher) Test(org.testng.annotations.Test)

Example 4 with Subscriber

use of com.yahoo.bullet.pubsub.Subscriber in project bullet-core by yahoo.

the class RESTPubSubTest method testGetSubscriber.

@Test
public void testGetSubscriber() throws PubSubException {
    BulletConfig config = new BulletConfig("src/test/resources/test_config.yaml");
    config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "QUERY_SUBMISSION");
    RESTPubSub pubSub = new RESTPubSub(config);
    Subscriber subscriber = pubSub.getSubscriber();
    Assert.assertNotNull(subscriber);
    Assert.assertTrue(subscriber instanceof RESTSubscriber);
    config.set(BulletConfig.PUBSUB_CONTEXT_NAME, "QUERY_PROCESSING");
    pubSub = new RESTPubSub(config);
    subscriber = pubSub.getSubscriber();
    Assert.assertNotNull(subscriber);
    Assert.assertTrue(subscriber instanceof RESTSubscriber);
}
Also used : Subscriber(com.yahoo.bullet.pubsub.Subscriber) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 5 with Subscriber

use of com.yahoo.bullet.pubsub.Subscriber 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)

Aggregations

Subscriber (com.yahoo.bullet.pubsub.Subscriber)6 Test (org.testng.annotations.Test)6 Publisher (com.yahoo.bullet.pubsub.Publisher)4 BulletConfig (com.yahoo.bullet.common.BulletConfig)2