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;
}
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();
}
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;
}
Aggregations