Search in sources :

Example 1 with CommandLookupTopicResponse

use of org.apache.pulsar.common.api.proto.PulsarApi.CommandLookupTopicResponse in project incubator-pulsar by apache.

the class Commands method newLookupResponse.

public static ByteBuf newLookupResponse(String brokerServiceUrl, String brokerServiceUrlTls, boolean authoritative, LookupType response, long requestId, boolean proxyThroughServiceUrl) {
    CommandLookupTopicResponse.Builder commandLookupTopicResponseBuilder = CommandLookupTopicResponse.newBuilder();
    commandLookupTopicResponseBuilder.setBrokerServiceUrl(brokerServiceUrl);
    if (brokerServiceUrlTls != null) {
        commandLookupTopicResponseBuilder.setBrokerServiceUrlTls(brokerServiceUrlTls);
    }
    commandLookupTopicResponseBuilder.setResponse(response);
    commandLookupTopicResponseBuilder.setRequestId(requestId);
    commandLookupTopicResponseBuilder.setAuthoritative(authoritative);
    commandLookupTopicResponseBuilder.setProxyThroughServiceUrl(proxyThroughServiceUrl);
    CommandLookupTopicResponse commandLookupTopicResponse = commandLookupTopicResponseBuilder.build();
    ByteBuf res = serializeWithSize(BaseCommand.newBuilder().setType(Type.LOOKUP_RESPONSE).setLookupTopicResponse(commandLookupTopicResponse));
    commandLookupTopicResponseBuilder.recycle();
    commandLookupTopicResponse.recycle();
    return res;
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) CommandLookupTopicResponse(org.apache.pulsar.common.api.proto.PulsarApi.CommandLookupTopicResponse)

Example 2 with CommandLookupTopicResponse

use of org.apache.pulsar.common.api.proto.PulsarApi.CommandLookupTopicResponse in project incubator-pulsar by apache.

the class ServerCnxTest method testInvalidTopicOnLookup.

@Test(timeOut = 30000)
public void testInvalidTopicOnLookup() throws Exception {
    resetChannel();
    setChannelConnected();
    String invalidTopicName = "xx/ass/aa/aaa";
    resetChannel();
    setChannelConnected();
    channel.writeInbound(Commands.newLookup(invalidTopicName, true, 1));
    Object obj = getResponse();
    assertEquals(obj.getClass(), CommandLookupTopicResponse.class);
    CommandLookupTopicResponse res = (CommandLookupTopicResponse) obj;
    assertEquals(res.getError(), ServerError.InvalidTopicName);
    channel.finish();
}
Also used : Matchers.anyObject(org.mockito.Matchers.anyObject) ByteString(com.google.protobuf.ByteString) CommandLookupTopicResponse(org.apache.pulsar.common.api.proto.PulsarApi.CommandLookupTopicResponse) Test(org.testng.annotations.Test)

Example 3 with CommandLookupTopicResponse

use of org.apache.pulsar.common.api.proto.PulsarApi.CommandLookupTopicResponse in project incubator-pulsar by apache.

the class Commands method newLookupErrorResponse.

public static ByteBuf newLookupErrorResponse(ServerError error, String errorMsg, long requestId) {
    CommandLookupTopicResponse.Builder connectionBuilder = CommandLookupTopicResponse.newBuilder();
    connectionBuilder.setRequestId(requestId);
    connectionBuilder.setError(error);
    if (errorMsg != null) {
        connectionBuilder.setMessage(errorMsg);
    }
    connectionBuilder.setResponse(LookupType.Failed);
    CommandLookupTopicResponse connectionBroker = connectionBuilder.build();
    ByteBuf res = serializeWithSize(BaseCommand.newBuilder().setType(Type.LOOKUP_RESPONSE).setLookupTopicResponse(connectionBroker));
    connectionBuilder.recycle();
    connectionBroker.recycle();
    return res;
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) CommandLookupTopicResponse(org.apache.pulsar.common.api.proto.PulsarApi.CommandLookupTopicResponse)

Aggregations

CommandLookupTopicResponse (org.apache.pulsar.common.api.proto.PulsarApi.CommandLookupTopicResponse)3 ByteBuf (io.netty.buffer.ByteBuf)2 ByteString (com.google.protobuf.ByteString)1 Matchers.anyObject (org.mockito.Matchers.anyObject)1 Test (org.testng.annotations.Test)1