Package com.google.protobuf

Examples of com.google.protobuf.ByteString$Output


     * 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

    for (Iterator i = list.iterator(); i.hasNext();) {
      source.setBookmark(bookmark);

      ElementOutputList.ElementOutput elementOutput = (ElementOutputList.ElementOutput)i.next();
      Element element = elementOutput.getElement();
      Output output = elementOutput.getOutput();
     
      boolean elementNot = elementOutput.isNot();

      if (this.caseSensitive != null) {
        caseSensitive = this.caseSensitive.booleanValue();
      }
      if (elementOutput.isCaseSensitive() != null) {
        caseSensitive = elementOutput.isCaseSensitive().booleanValue();
      }

      boolean match = false;
      if (output.receive()) {
        if (receive) {
          match = recorder.playMatch(element, source.getBookmark());
          source.setBookmark(recorder.playBookmark());
        } else {
          output.init(source);
          int mindex = recorder.reserveMatchIndex(level, element, source.getBookmark(), parentNot, elementNot);
          int bindex = recorder.reserveBookmarkIndex();
          match = element.parse(level, source, not|parentNot|elementNot, caseSensitive, false);
          match = match != elementNot;
          recorder.set(level, source, element, bookmark, source.getBookmark(), source.getBestIndex(), mindex, bindex, match, parentNot, elementNot);
          output.set(source, bookmark);
        }
      } else {
        if (receive) {
          match = recorder.playMatch(element, source.getBookmark());
        } else {
          int index = recorder.reserveMatchIndex(level, element, source.getBookmark(), parentNot, elementNot);
          match = element.parse(level, source, not|parentNot|elementNot, caseSensitive, false);
          match = (match != elementNot);
          recorder.set(level, source, element, bookmark, source.getBookmark(), source.getBestIndex(), index, match, parentNot, elementNot);
        }
      }

      if (match) {
        if (receive && !elementNot && !not) {
          source.setBookmark(bookmark);
          output.init(source);
          element.parse(level, source, not|parentNot|elementNot, caseSensitive, receive);
          output.set(source, bookmark);
        }
                output = list.getOutput();
                if (output != null && receive) {
                    output.init(source);
                    output.set(source, bookmark);
                }
               
                return !not;
      }
    }
    if (not) {
      source.setBookmark(bookmark);
      source.skipCharacter();

      Output output = list.getOutput();
      if (output != null && receive) {
        output.init(source);
        output.set(source, bookmark);
      }
    } else {
      recorder.setIndex(recIndex);
    }
View Full Code Here

    int startIndex = recorder.getIndex();
   
    for (Iterator i = list.iterator(); i.hasNext();) {
      ElementOutput elementOutput = (ElementOutput)i.next();
      Element element = elementOutput.getElement();
      Output output = elementOutput.getOutput();
      boolean elementNot = elementOutput.isNot();

      if (this.caseSensitive != null) {
        caseSensitive = this.caseSensitive.booleanValue();
      }
      if (elementOutput.isCaseSensitive() != null) {
        caseSensitive = elementOutput.isCaseSensitive().booleanValue();
      }

      int bookmark = source.getBookmark();

      boolean match = false;
      if (output.receive()) {
        if (receive) {
          match = recorder.playMatch(element, source.getBookmark());
          source.setBookmark(recorder.playBookmark());
        } else {
          output.init(source);
          int mindex = recorder.reserveMatchIndex(level, element, source.getBookmark(), parentNot, elementNot);
          int bindex = recorder.reserveBookmarkIndex();
          match = element.parse(level, source, not|parentNot|elementNot, caseSensitive, false);
          match = match != elementNot;
          recorder.set(level, source, element, bookmark, source.getBookmark(), source.getBestIndex(), mindex, bindex, match, parentNot, elementNot);
          output.set(source, bookmark);
        }
      } else {
        if (receive) {
          match = recorder.playMatch(element, source.getBookmark());
        } else {
          int mindex = recorder.reserveMatchIndex(level, element, source.getBookmark(), parentNot, elementNot);
          match = element.parse(level, source, not|parentNot|elementNot, caseSensitive, false);
          match = match != elementNot;
          recorder.set(level, source, element, bookmark, source.getBookmark(), source.getBestIndex(), mindex, match, parentNot, elementNot);
        }
      }
     
      if (match == not) {
        if (!receive) {
          recorder.setIndex(startIndex);
        }
        return false;
      }
     
      if (not) {
        break;
      }

      if (elementNot) {
        source.setBookmark(bookmark);
        source.skipCharacter();
        if (source.getBookmark() > bestMatchIdx) {
          source.setBestIndex(source.getBookmark());
        }
      }

      if (receive) {
        if (elementNot) {
          output.init(source);
          output.set(source, bookmark);
        } else {
          source.setBookmark(bookmark);
          output.init(source);
          element.parse(level, source, not|parentNot|elementNot, caseSensitive, receive);
          output.set(source, bookmark);
        }
      }
    }

    if (not) {
View Full Code Here

TOP

Related Classes of com.google.protobuf.ByteString$Output

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.