Package com.google.protobuf

Examples of com.google.protobuf.ByteString


     * Server side throttling does't work when current client connects to old version
     * server.
     */
    @Test(timeout=60000)
    public void testServerSideThrottleCompat410() throws Exception {
        ByteString topic = ByteString.copyFromUtf8("TestServerSideThrottleCompat410");
        ByteString subid = ByteString.copyFromUtf8("mysub");

        // start bookkeeper
        BookKeeperCluster410 bkc410 = new BookKeeperCluster410(3);
        bkc410.start();

View Full Code Here


            new ThrottleDeliveryClientConfiguration();
        HedwigClient client = new HedwigClient(conf);
        Publisher pub = client.getPublisher();
        Subscriber sub = client.getSubscriber();

        ByteString topic = ByteString.copyFromUtf8("testServerSideThrottle");
        ByteString subid = ByteString.copyFromUtf8("serverThrottleSub");
        sub.subscribe(topic, subid, CreateOrAttach.CREATE);
        sub.closeSubscription(topic, subid);

        // throttle with hub server's setting
        throttleX(pub, sub, topic, subid, DEFAULT_MESSAGE_WINDOW_SIZE);
View Full Code Here

        ThrottleDeliveryClientConfiguration conf = new ThrottleDeliveryClientConfiguration();
        HedwigClient client = new HedwigClient(conf);
        Publisher pub = client.getPublisher();
        Subscriber sub = client.getSubscriber();

        ByteString topic = ByteString.copyFromUtf8("testThrottleWithServerSideFilter");
        ByteString subid = ByteString.copyFromUtf8("mysub");
        SubscriptionOptions opts = SubscriptionOptions.newBuilder().setCreateOrAttach(CreateOrAttach.CREATE).build();
        sub.subscribe(topic, subid, opts);
        sub.closeSubscription(topic, subid);

        // message gap: half of the throttle threshold
View Full Code Here

    public void testScanMessagesOnUnclosedLedgerAfterDeleteLedger() throws Exception {
        scanMessagesAfterDeleteLedgerTest(1);
    }

    private void scanMessagesAfterDeleteLedgerTest(int numLedgers) throws Exception {
        ByteString topic = ByteString.copyFromUtf8("TestScanMessagesAfterDeleteLedger");

        List<Message> msgs = new ArrayList<Message>();

        acquireTopic(topic);
        msgs.addAll(publishMessages(topic, 2));
View Full Code Here

        assertTrue("Should succeed to scan messages after deleted consumed ledger.", b);
    }

    @Test(timeout=60000)
    public void testScanMessagesOnEmptyLedgerAfterDeleteLedger() throws Exception {
        ByteString topic = ByteString.copyFromUtf8("TestScanMessagesOnEmptyLedgerAfterDeleteLedger");

        List<Message> msgs = new ArrayList<Message>();

        acquireTopic(topic);
        msgs.addAll(publishMessages(topic, 2));
View Full Code Here

        // succeed to delete second ledger
        failedToDeleteLedgersTest(2);
    }

    private void failedToDeleteLedgersTest(int numLedgers) throws Exception {
        final ByteString topic = ByteString.copyFromUtf8("TestFailedToDeleteLedger");
        final int serviceDownCount = 1;

        List<Message> msgs = new ArrayList<Message>();

        for (int i=0; i<numLedgers; i++) {
            acquireTopic(topic);
            msgs.addAll(publishMessages(topic, 2));
            releaseTopic(topic);
        }

        // acquire topic again to force a new ledger
        acquireTopic(topic);
        logger.info("Consumed messages.");
        metadataManagerFactory.setServiceDownCount(serviceDownCount);
        // failed consumed
        consumedUntil(topic, 2L * numLedgers);
        // Wait until ledger ranges is updated.
        Thread.sleep(2000L);
        logger.info("Released topic with an empty ledger.");
        // release topic to force an empty ledger
        releaseTopic(topic);

        // publish 2 more messages, these message expected to be id 3 and 4
        acquireTopic(topic);
        logger.info("Published more messages.");
        msgs.addAll(publishMessages(topic, 2));
        releaseTopic(topic);

        // acquire topic again
        acquireTopic(topic);
        LinkedBlockingQueue<Boolean> statusQueue =
            new LinkedBlockingQueue<Boolean>();
        manager.scanMessages(new RangeScanRequest(topic, numLedgers * 2 + 1, 2, Long.MAX_VALUE,
                             new RangeScanVerifier(subMessages(msgs, numLedgers * 2, numLedgers * 2 + 1), null), statusQueue));
        Boolean b = statusQueue.poll(10 * readDelay, TimeUnit.MILLISECONDS);
        assertTrue("Should succeed to scan messages after deleted consumed ledger.", b);

        // consumed
        consumedUntil(topic, (numLedgers + 1) * 2L);
        // Wait until ledger ranges is updated.
        Thread.sleep(2000L);

        Semaphore latch = new Semaphore(1);
        latch.acquire();
        tpManager.readTopicPersistenceInfo(topic, new Callback<Versioned<LedgerRanges>>() {
            @Override
            public void operationFinished(Object ctx, Versioned<LedgerRanges> ranges) {
                if (null == ranges || ranges.getValue().getRangesList().size() > 1) {
                    failureException = new PubSubException.NoTopicPersistenceInfoException("Invalid persistence info found for topic " + topic.toStringUtf8());
                    ((Semaphore)ctx).release();
                    return;
                }
                failureException = null;
                ((Semaphore)ctx).release();
View Full Code Here

    @Test(timeout=60000)
    public void testScanMessagesOnTwoLedgers() throws Exception {
        stopCluster();
        startCluster(readDelay);

        ByteString topic = ByteString.copyFromUtf8("TestScanMessagesOnTwoLedgers");

        List<Message> msgs = new ArrayList<Message>();

        acquireTopic(topic);
        msgs.addAll(publishMessages(topic, 1));
View Full Code Here

     *      and L1 is delete
     * (4). If Hub restarts at this time, old subscription state is read and
     *      Hub will try to deliver message from 1
     */
    public void inconsistentSubscriptionStateAndLedgerRanges(int failedCount) throws Exception {
        final ByteString topic = ByteString.copyFromUtf8("inconsistentSubscriptionStateAndLedgerRanges");
        final ByteString subscriberId = ByteString.copyFromUtf8("subId");
        LinkedList<Message> msgs = new LinkedList<Message>();

        // make ledger L1 [1 ~ 2]
        acquireTopic(topic);
        msgs.addAll(publishMessages(topic, 2));
View Full Code Here

    }

    @Test(timeout=60000)
    // Add this test case for BOOKKEEPER-458
    public void testReadWhenTopicChangeLedger() throws Exception {
        final ByteString topic = ByteString.copyFromUtf8("testReadWhenTopicChangeLedger");
        LinkedList<Message> msgs = new LinkedList<Message>();

        // Write maxEntriesPerLedger entries to make topic change ledger
        acquireTopic(topic);
        msgs.addAll(publishMessages(topic, maxEntriesPerLedger));
View Full Code Here

        @Override
        public MessageFilterBase setSubscriptionPreferences(ByteString topic, ByteString subscriberId,
                SubscriptionPreferences preferences) {
            Map<String, ByteString> userOptions = SubscriptionStateUtils.buildUserOptions(preferences);
            ByteString modValue = userOptions.get(OPT_MOD);
            if (null == modValue) {
                mod = 0;
            } else {
                mod = Integer.valueOf(modValue.toStringUtf8());
            }
            return this;
        }
View Full Code Here

TOP

Related Classes of com.google.protobuf.ByteString

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.