Search in sources :

Example 16 with BaseCommand

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);
}
Also used : CommandLookupTopic(org.apache.pulsar.common.api.proto.CommandLookupTopic) BaseCommand(org.apache.pulsar.common.api.proto.BaseCommand)

Example 17 with BaseCommand

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);
}
Also used : BaseCommand(org.apache.pulsar.common.api.proto.BaseCommand)

Example 18 with BaseCommand

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);
}
Also used : BaseCommand(org.apache.pulsar.common.api.proto.BaseCommand)

Example 19 with BaseCommand

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;
}
Also used : BaseCommand(org.apache.pulsar.common.api.proto.BaseCommand)

Example 20 with BaseCommand

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);
}
Also used : CommandAuthChallenge(org.apache.pulsar.common.api.proto.CommandAuthChallenge) BaseCommand(org.apache.pulsar.common.api.proto.BaseCommand)

Aggregations

BaseCommand (org.apache.pulsar.common.api.proto.BaseCommand)284 ByteBuf (io.netty.buffer.ByteBuf)68 MessageIdData (org.apache.pulsar.common.api.proto.MessageIdData)12 CommandAck (org.apache.pulsar.common.api.proto.CommandAck)9 CommandGetSchema (org.apache.pulsar.common.api.proto.CommandGetSchema)9 PulsarService (org.apache.pulsar.broker.PulsarService)6 CommandConnect (org.apache.pulsar.common.api.proto.CommandConnect)6 CommandLookupTopicResponse (org.apache.pulsar.common.api.proto.CommandLookupTopicResponse)6 Schema (org.apache.pulsar.common.api.proto.Schema)6 BeforeMethod (org.testng.annotations.BeforeMethod)4 NoSuchElementException (java.util.NoSuchElementException)3 AuthenticationException (javax.naming.AuthenticationException)3 lombok.val (lombok.val)3 ManagedLedgerException (org.apache.bookkeeper.mledger.ManagedLedgerException)3 ConsumerBusyException (org.apache.pulsar.broker.service.BrokerServiceException.ConsumerBusyException)3 ServerMetadataException (org.apache.pulsar.broker.service.BrokerServiceException.ServerMetadataException)3 ServiceUnitNotReadyException (org.apache.pulsar.broker.service.BrokerServiceException.ServiceUnitNotReadyException)3 SubscriptionNotFoundException (org.apache.pulsar.broker.service.BrokerServiceException.SubscriptionNotFoundException)3 TopicNotFoundException (org.apache.pulsar.broker.service.BrokerServiceException.TopicNotFoundException)3 IncompatibleSchemaException (org.apache.pulsar.broker.service.schema.exceptions.IncompatibleSchemaException)3