Ejemplo n.º 1
0
 void subscribe(ByteString topic, ByteString subscriberId) throws Exception {
   org.apache.hw_v4_1_0.hedwig.protocol.PubSubProtocol.SubscriptionOptions options =
       org.apache.hw_v4_1_0.hedwig.protocol.PubSubProtocol.SubscriptionOptions.newBuilder()
           .setCreateOrAttach(
               org.apache.hw_v4_1_0.hedwig.protocol.PubSubProtocol.SubscribeRequest
                   .CreateOrAttach.CREATE_OR_ATTACH)
           .build();
   subscribe(topic, subscriberId, options);
 }
Ejemplo n.º 2
0
  /**
   * Test compatability between version 4.1.0 and the current version.
   *
   * <p>A 4.1.0 client could not update message bound, while current could do it.
   */
  @Test(timeout = 60000)
  public void testUpdateMessageBoundCompat410() throws Exception {
    ByteString topic = ByteString.copyFromUtf8("TestUpdateMessageBoundCompat410");
    ByteString subid = ByteString.copyFromUtf8("mysub");

    // start bookkeeper
    BookKeeperCluster420 bkc420 = new BookKeeperCluster420(3);
    bkc420.start();

    int port = PortManager.nextFreePort();
    int sslPort = PortManager.nextFreePort();

    // start hub server
    Server420 s420 = new Server420(zkUtil.getZooKeeperConnectString(), port, sslPort);
    s420.start();

    org.apache.hedwig.protocol.PubSubProtocol.SubscriptionOptions options5cur =
        org.apache.hedwig.protocol.PubSubProtocol.SubscriptionOptions.newBuilder()
            .setCreateOrAttach(
                org.apache.hedwig.protocol.PubSubProtocol.SubscribeRequest.CreateOrAttach
                    .CREATE_OR_ATTACH)
            .setMessageBound(5)
            .build();
    org.apache.hw_v4_1_0.hedwig.protocol.PubSubProtocol.SubscriptionOptions options5v410 =
        org.apache.hw_v4_1_0.hedwig.protocol.PubSubProtocol.SubscriptionOptions.newBuilder()
            .setCreateOrAttach(
                org.apache.hw_v4_1_0.hedwig.protocol.PubSubProtocol.SubscribeRequest.CreateOrAttach
                    .CREATE_OR_ATTACH)
            .setMessageBound(5)
            .build();
    org.apache.hw_v4_1_0.hedwig.protocol.PubSubProtocol.SubscriptionOptions options20v410 =
        org.apache.hw_v4_1_0.hedwig.protocol.PubSubProtocol.SubscriptionOptions.newBuilder()
            .setCreateOrAttach(
                org.apache.hw_v4_1_0.hedwig.protocol.PubSubProtocol.SubscribeRequest.CreateOrAttach
                    .CREATE_OR_ATTACH)
            .setMessageBound(20)
            .build();

    Client410 c410 = new Client410("localhost:" + port + ":" + sslPort);
    c410.subscribe(topic, subid, options20v410);
    c410.closeSubscription(topic, subid);
    Thread.sleep(1000); // give server time to run disconnect logic (BOOKKEEPER-513)

    c410.sendXExpectLastY(topic, subid, 50, 20);

    c410.subscribe(topic, subid, options5v410);
    c410.closeSubscription(topic, subid);
    Thread.sleep(1000); // give server time to run disconnect logic (BOOKKEEPER-513)

    // the message bound isn't updated.
    c410.sendXExpectLastY(topic, subid, 50, 20);

    ClientCurrent ccur = new ClientCurrent("localhost:" + port + ":" + sslPort);
    ccur.subscribe(topic, subid, options5cur);
    ccur.closeSubscription(topic, subid);
    Thread.sleep(1000); // give server time to run disconnect logic (BOOKKEEPER-513)

    // the message bound should be updated.
    c410.sendXExpectLastY(topic, subid, 50, 5);

    // stop 420 server
    s420.stop();

    c410.close();
    ccur.close();

    // stop bookkeeper cluster
    bkc420.stop();
  }