Package org.apache.hedwig.server.netty

Examples of org.apache.hedwig.server.netty.WriteRecordingChannel


        TopicManager tm = new TrivialOwnAllTopicManager(conf, executor);
        dm = new StubDeliveryManager();
        PersistenceManager pm = LocalDBPersistenceManager.instance();
        sm = new StubSubscriptionManager(tm, pm, conf, executor);
        sh = new SubscribeHandler(tm, dm, pm, sm, conf);
        channel = new WriteRecordingChannel();

        subscriberId = ByteString.copyFromUtf8("subId");

        subRequestPrototype = SubscribeRequest.newBuilder().setSubscriberId(subscriberId).build();
        pubSubRequestPrototype = PubSubRequest.newBuilder().setProtocolVersion(ProtocolVersion.VERSION_ONE).setType(
View Full Code Here


        assertEquals(PubSubException.ClientAlreadySubscribedException.class, ConcurrencyUtils.take(callback1.queue)
                     .right().getClass());

        // trying to subscribe again should throw an error
        WriteRecordingChannel dupChannel = new WriteRecordingChannel();
        sh.handleRequestAtOwner(pubSubRequestPrototype, dupChannel);
        assertEquals(StatusCode.TOPIC_BUSY, ((PubSubResponse) dupChannel.getMessagesWritten().get(0)).getStatusCode());

        // after disconnecting the channel, subscribe should work again
        sh.channelDisconnected(channel);

        dupChannel = new WriteRecordingChannel();
        sh.handleRequestAtOwner(pubSubRequestPrototype, dupChannel);
        assertEquals(StatusCode.SUCCESS, ((PubSubResponse) dupChannel.getMessagesWritten().get(0)).getStatusCode());

        // test unsubscribe
        channel = new WriteRecordingChannel();
        ush.handleRequestAtOwner(pubSubRequestPrototype, channel);
        assertEquals(StatusCode.MALFORMED_REQUEST, ((PubSubResponse) channel.getMessagesWritten().get(0))
                     .getStatusCode());

        PubSubRequest unsubRequest = PubSubRequest.newBuilder(pubSubRequestPrototype).setUnsubscribeRequest(
                                         UnsubscribeRequest.newBuilder().setSubscriberId(subscriberId)).build();
        channel = new WriteRecordingChannel();
        dm.lastRequest.clear();

        ush.handleRequestAtOwner(unsubRequest, channel);
        assertEquals(StatusCode.SUCCESS, ((PubSubResponse) channel.getMessagesWritten().get(0)).getStatusCode());
View Full Code Here

    protected void startDelivery(Subscriber subscriber, ByteString topic, ByteString subscriberId,
                                 MessageHandler handler) throws Exception {
        subscriber.startDelivery(topic, subscriberId, handler);
        if (mode == Mode.PROXY) {
            WriteRecordingChannel channel = new WriteRecordingChannel();
            PubSubRequest request = PubSubRequest.newBuilder().setProtocolVersion(ProtocolVersion.VERSION_ONE)
                                    .setTopic(topic).setTxnId(0).setType(OperationType.START_DELIVERY).setStartDeliveryRequest(
                                        StartDeliveryRequest.newBuilder().setSubscriberId(subscriberId)).build();
            proxy.getStartDeliveryHandler().handleRequest(request, channel);
            assertEquals(StatusCode.SUCCESS, ((PubSubResponse) channel.getMessagesWritten().get(0)).getStatusCode());
        }
    }
View Full Code Here

    public void setUp() throws Exception {
        ServerConfiguration conf = new ServerConfiguration();
        tm = new StubTopicManager(conf);
        handler = new MyBaseHandler(tm, conf);
        request = PubSubRequest.getDefaultInstance();
        channel = new WriteRecordingChannel();
    }
View Full Code Here

    protected void startDelivery(Subscriber subscriber, ByteString topic, ByteString subscriberId,
                                 MessageHandler handler) throws Exception {
        subscriber.startDelivery(topic, subscriberId, handler);
        if (mode == Mode.PROXY) {
            WriteRecordingChannel channel = new WriteRecordingChannel();
            PubSubRequest request = PubSubRequest.newBuilder().setProtocolVersion(ProtocolVersion.VERSION_ONE)
                                    .setTopic(topic).setTxnId(0).setType(OperationType.START_DELIVERY).setStartDeliveryRequest(
                                        StartDeliveryRequest.newBuilder().setSubscriberId(subscriberId)).build();
            proxy.getStartDeliveryHandler().handleRequest(request, channel);
            assertEquals(StatusCode.SUCCESS, ((PubSubResponse) channel.getMessagesWritten().get(0)).getStatusCode());
        }
    }
View Full Code Here

    public void setUp() throws Exception {
        ServerConfiguration conf = new ServerConfiguration();
        tm = new StubTopicManager(conf);
        handler = new MyBaseHandler(tm, conf);
        request = PubSubRequest.getDefaultInstance();
        channel = new WriteRecordingChannel();
    }
View Full Code Here

        dm = new StubDeliveryManager();
        PersistenceManager pm = LocalDBPersistenceManager.instance();
        sm = new StubSubscriptionManager(tm, pm, dm, conf, executor);
        subChannelMgr = new SubscriptionChannelManager();
        sh = new SubscribeHandler(conf, tm, dm, pm, sm, subChannelMgr);
        channel = new WriteRecordingChannel();

        subscriberId = ByteString.copyFromUtf8("subId");

        subRequestPrototype = SubscribeRequest.newBuilder().setSubscriberId(subscriberId).build();
        pubSubRequestPrototype = PubSubRequest.newBuilder().setProtocolVersion(ProtocolVersion.VERSION_ONE).setType(
View Full Code Here

        assertEquals(PubSubException.ClientAlreadySubscribedException.class, ConcurrencyUtils.take(callback1.queue)
                     .right().getClass());

        // trying to subscribe again should throw an error
        WriteRecordingChannel dupChannel = new WriteRecordingChannel();
        sh.handleRequestAtOwner(pubSubRequestPrototype, dupChannel);
        assertEquals(StatusCode.TOPIC_BUSY, ((PubSubResponse) dupChannel.getMessagesWritten().get(0)).getStatusCode());

        // after disconnecting the channel, subscribe should work again
        subChannelMgr.channelDisconnected(channel);

        dupChannel = new WriteRecordingChannel();
        sh.handleRequestAtOwner(pubSubRequestPrototype, dupChannel);
        assertEquals(StatusCode.SUCCESS, ((PubSubResponse) dupChannel.getMessagesWritten().get(0)).getStatusCode());

        // test unsubscribe
        channel = new WriteRecordingChannel();
        ush.handleRequestAtOwner(pubSubRequestPrototype, channel);
        assertEquals(StatusCode.MALFORMED_REQUEST, ((PubSubResponse) channel.getMessagesWritten().get(0))
                     .getStatusCode());

        PubSubRequest unsubRequest = PubSubRequest.newBuilder(pubSubRequestPrototype).setUnsubscribeRequest(
                                         UnsubscribeRequest.newBuilder().setSubscriberId(subscriberId)).build();
        channel = new WriteRecordingChannel();
        dm.lastRequest.clear();

        ush.handleRequestAtOwner(unsubRequest, channel);
        assertEquals(StatusCode.SUCCESS, ((PubSubResponse) channel.getMessagesWritten().get(0)).getStatusCode());
View Full Code Here

    protected void startDelivery(Subscriber subscriber, ByteString topic, ByteString subscriberId,
                                 MessageHandler handler) throws Exception {
        subscriber.startDelivery(topic, subscriberId, handler);
        if (mode == Mode.PROXY) {
            WriteRecordingChannel channel = new WriteRecordingChannel();
            PubSubRequest request = PubSubRequest.newBuilder().setProtocolVersion(ProtocolVersion.VERSION_ONE)
                                    .setTopic(topic).setTxnId(0).setType(OperationType.START_DELIVERY).setStartDeliveryRequest(
                                        StartDeliveryRequest.newBuilder().setSubscriberId(subscriberId)).build();
            proxy.getStartDeliveryHandler().handleRequest(request, channel);
            assertEquals(StatusCode.SUCCESS, ((PubSubResponse) channel.getMessagesWritten().get(0)).getStatusCode());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.hedwig.server.netty.WriteRecordingChannel

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.