Search in sources :

Example 1 with CommandConnect

use of com.yahoo.pulsar.common.api.proto.PulsarApi.CommandConnect in project pulsar by yahoo.

the class Commands method newConnect.

public static ByteBuf newConnect(String authMethodName, String authData, int protocolVersion) {
    CommandConnect.Builder connectBuilder = CommandConnect.newBuilder();
    connectBuilder.setClientVersion("Pulsar Client");
    connectBuilder.setAuthMethodName(authMethodName);
    if ("ycav1".equals(authMethodName)) {
        // Handle the case of a client that gets updated before the broker and starts sending the string auth method
        // name. An example would be in broker-to-broker replication. We need to make sure the clients are still
        // passing both the enum and the string until all brokers are upgraded.
        connectBuilder.setAuthMethod(AuthMethod.AuthMethodYcaV1);
    }
    connectBuilder.setAuthData(ByteString.copyFromUtf8(authData));
    connectBuilder.setProtocolVersion(protocolVersion);
    CommandConnect connect = connectBuilder.build();
    ByteBuf res = serializeWithSize(BaseCommand.newBuilder().setType(Type.CONNECT).setConnect(connect));
    connect.recycle();
    connectBuilder.recycle();
    return res;
}
Also used : CommandConnect(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandConnect) UnpooledHeapByteBuf(io.netty.buffer.UnpooledHeapByteBuf) RecyclableDuplicateByteBuf(io.netty.buffer.RecyclableDuplicateByteBuf) ByteBuf(io.netty.buffer.ByteBuf)

Example 2 with CommandConnect

use of com.yahoo.pulsar.common.api.proto.PulsarApi.CommandConnect in project pulsar by yahoo.

the class Commands method newConnect.

/**
     * @deprecated AuthMethod has been deprecated. Use
     *             {@link #newConnect(String authMethodName, String authData, int protocolVersion)} instead.
     */
@Deprecated
public static ByteBuf newConnect(AuthMethod authMethod, String authData, int protocolVersion) {
    CommandConnect.Builder connectBuilder = CommandConnect.newBuilder();
    connectBuilder.setClientVersion("Pulsar Client");
    connectBuilder.setAuthMethod(authMethod);
    connectBuilder.setAuthData(ByteString.copyFromUtf8(authData));
    connectBuilder.setProtocolVersion(protocolVersion);
    CommandConnect connect = connectBuilder.build();
    ByteBuf res = serializeWithSize(BaseCommand.newBuilder().setType(Type.CONNECT).setConnect(connect));
    connect.recycle();
    connectBuilder.recycle();
    return res;
}
Also used : CommandConnect(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandConnect) UnpooledHeapByteBuf(io.netty.buffer.UnpooledHeapByteBuf) RecyclableDuplicateByteBuf(io.netty.buffer.RecyclableDuplicateByteBuf) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

CommandConnect (com.yahoo.pulsar.common.api.proto.PulsarApi.CommandConnect)2 ByteBuf (io.netty.buffer.ByteBuf)2 RecyclableDuplicateByteBuf (io.netty.buffer.RecyclableDuplicateByteBuf)2 UnpooledHeapByteBuf (io.netty.buffer.UnpooledHeapByteBuf)2