Package org.apache.hedwig.protocol.PubSubProtocol

Examples of org.apache.hedwig.protocol.PubSubProtocol.Message


    // subscribed to.
    public void handleSubscribeMessage(PubSubResponse response) {
        if (logger.isDebugEnabled())
            logger.debug("Handling a Subscribe message in response: " + response + ", topic: "
                         + origSubData.topic.toStringUtf8() + ", subscriberId: " + origSubData.subscriberId.toStringUtf8());
        Message message = response.getMessage();

        synchronized (this) {
            // Consume the message asynchronously that the client is subscribed
            // to. Do this only if delivery for the subscription has started and
            // a MessageHandler has been registered for the TopicSubscriber.
View Full Code Here


            }
        });

        // picking constants arbitarily for warmup phase
        ThroughputLatencyAggregator agg = new ThroughputLatencyAggregator("acked pubs", nWarmup, 100);
        Message msg = getMsg(1024);
        for (int i = 0; i < nWarmup; i++) {
            publisher.asyncPublish(topic, msg, new BenchmarkCallback(agg), null);
        }

        if (agg.tpAgg.queue.take() > 0) {
View Full Code Here

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < size; i++) {
            sb.append('a');
        }
        final ByteString body = ByteString.copyFromUtf8(sb.toString());
        Message msg = Message.newBuilder().setBody(body).build();
        return msg;
    }
View Full Code Here

        Message msg = Message.newBuilder().setBody(body).build();
        return msg;
    }

    public Void call() throws Exception {
        Message msg = getMsg(msgSize);

        // Single warmup for every topic
        int myPublishCount = 0;
        for (int i = 0; i < numTopics; i++) {
            if (!HedwigBenchmark.amIResponsibleForTopic(startTopicLabel + i, partitionIndex, numPartitions)) {
View Full Code Here

            UmbrellaHandler.sendErrorResponseToMalformedRequest(channel, request.getTxnId(),
                    "Missing publish request data");
            return;
        }

        Message msgToSerialize = Message.newBuilder(request.getPublishRequest().getMsg()).setSrcRegion(
                                     cfg.getMyRegionByteString()).build();

        PersistRequest persistRequest = new PersistRequest(request.getTopic(), msgToSerialize,
        new Callback<Long>() {
            @Override
View Full Code Here

            // hear success
            originalRequest.getCallback().operationFinished(originalRequest.getCtx(), resultOfOperation);

            // Original message that was persisted didn't have the local seq-id.
            // Lets add that in
            Message messageWithLocalSeqId = MessageIdUtils.mergeLocalSeqId(originalRequest.getMessage(),
                                            resultOfOperation.getLocalComponent());

            // Now enqueue a request to add this newly persisted message to our
            // cache
            CacheKey cacheKey = new CacheKey(originalRequest.getTopic(), resultOfOperation.getLocalComponent());
View Full Code Here

        for (int i = 1; i <= num; i++) {
            PubSubProtocol.Map.Builder propsBuilder = PubSubProtocol.Map.newBuilder().addEntries(
                    PubSubProtocol.Map.Entry.newBuilder().setKey(OPT_MOD)
                            .setValue(ByteString.copyFromUtf8(String.valueOf((start + i) % M))));
            MessageHeader.Builder headerBuilder = MessageHeader.newBuilder().setProperties(propsBuilder);
            Message msg = Message.newBuilder().setBody(ByteString.copyFromUtf8(String.valueOf(start + i)))
                    .setHeader(headerBuilder).build();
            pub.publish(topic, msg);
        }
    }
View Full Code Here

            if (pubMsgs.size() == 0) {
                return;
            }

            Message pubMsg = pubMsgs.removeFirst();
            if (!HelperMethods.areEqual(recvMessage, pubMsg)) {
                fail("Scanned message not equal to expected");
            }
        }
View Full Code Here

        if (logger.isDebugEnabled()) {
            logger.debug("Handling a Subscribe message in response: {}, topic: {}, subscriberId: {}",
                    new Object[] { response, getOrigSubData().topic.toStringUtf8(),
                                   getOrigSubData().subscriberId.toStringUtf8() });
        }
        Message message = response.getMessage();

        synchronized (this) {
            // Consume the message asynchronously that the client is subscribed
            // to. Do this only if delivery for the subscription has started and
            // a MessageHandler has been registered for the TopicSubscriber.
View Full Code Here

                                        ArrayListMessageFactory.instance);
            if (startSeqId + i > messageList.size()) {
                request.getCallback().scanFinished(request.getCtx(), ReasonForFinish.NO_MORE_MESSAGES);
                return;
            }
            Message msg = messageList.get((int) startSeqId + i - 1);
            Message toDeliver = MessageIdUtils.mergeLocalSeqId(msg, startSeqId + i);
            request.getCallback().messageScanned(request.getCtx(), toDeliver);

            totalSize += toDeliver.getBody().size();

            if (totalSize > request.getSizeLimit()) {
                request.getCallback().scanFinished(request.getCtx(), ReasonForFinish.SIZE_LIMIT_EXCEEDED);
                return;
            }
View Full Code Here

TOP

Related Classes of org.apache.hedwig.protocol.PubSubProtocol.Message

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.