use of org.apache.pulsar.common.api.proto.BaseCommand in project pulsar by apache.
the class Commands method newLookup.
public static ByteBuf newLookup(String topic, String listenerName, boolean authoritative, long requestId) {
BaseCommand cmd = localCmd(Type.LOOKUP);
CommandLookupTopic lookup = cmd.setLookupTopic().setTopic(topic).setRequestId(requestId).setAuthoritative(authoritative);
if (StringUtils.isNotBlank(listenerName)) {
lookup.setAdvertisedListenerName(listenerName);
}
return serializeWithSize(cmd);
}
use of org.apache.pulsar.common.api.proto.BaseCommand in project pulsar by apache.
the class Commands method newGetSchemaResponse.
public static ByteBuf newGetSchemaResponse(long requestId, CommandGetSchemaResponse response) {
BaseCommand cmd = localCmd(Type.GET_SCHEMA_RESPONSE);
cmd.setGetSchemaResponse().copyFrom(response).setRequestId(requestId);
return serializeWithSize(cmd);
}
use of org.apache.pulsar.common.api.proto.BaseCommand in project pulsar by apache.
the class Commands method newGetOrCreateSchemaResponseError.
public static ByteBuf newGetOrCreateSchemaResponseError(long requestId, ServerError error, String errorMessage) {
BaseCommand cmd = localCmd(Type.GET_OR_CREATE_SCHEMA_RESPONSE);
cmd.setGetOrCreateSchemaResponse().setRequestId(requestId).setErrorCode(error).setErrorMessage(errorMessage);
return serializeWithSize(cmd);
}
use of org.apache.pulsar.common.api.proto.BaseCommand in project pulsar by apache.
the class Commands method newGetSchemaResponseErrorCommand.
public static BaseCommand newGetSchemaResponseErrorCommand(long requestId, ServerError error, String errorMessage) {
BaseCommand cmd = localCmd(Type.GET_SCHEMA_RESPONSE);
cmd.setGetSchemaResponse().setRequestId(requestId).setErrorCode(error).setErrorMessage(errorMessage);
return cmd;
}
use of org.apache.pulsar.common.api.proto.BaseCommand in project pulsar by apache.
the class Commands method newAuthChallenge.
public static ByteBuf newAuthChallenge(String authMethod, AuthData brokerData, int clientProtocolVersion) {
BaseCommand cmd = localCmd(Type.AUTH_CHALLENGE);
CommandAuthChallenge challenge = cmd.setAuthChallenge();
// If the broker supports a newer version of the protocol, it will anyway advertise the max version that the
// client supports, to avoid confusing the client.
int currentProtocolVersion = getCurrentProtocolVersion();
int versionToAdvertise = Math.min(currentProtocolVersion, clientProtocolVersion);
challenge.setProtocolVersion(versionToAdvertise).setChallenge().setAuthData(brokerData != null ? brokerData.getBytes() : new byte[0]).setAuthMethodName(authMethod);
return serializeWithSize(cmd);
}
Aggregations