public static ByteBuf newConnect(String authMethodName, String authData, String libVersion, String targetBroker, String originalPrincipal, String clientAuthData, String clientAuthMethod) { return newConnect(authMethodName, authData, getCurrentProtocolVersion(), libVersion, targetBroker, originalPrincipal, clientAuthData, clientAuthMethod); }
public static void skipChecksumIfPresent(ByteBuf buffer) { if (hasChecksum(buffer)) { readChecksum(buffer); } }
@Override protected ByteBufPair newObject(Recycler.Handle<ByteBufPair> handle) { return new ByteBufPair(handle); } };
public static ByteBuf newProducer(String topic, long producerId, long requestId, String producerName, boolean encrypted, Map<String, String> metadata, SchemaInfo schemaInfo) { CommandProducer.Builder producerBuilder = CommandProducer.newBuilder(); producerBuilder.setTopic(topic); producerBuilder.setProducerId(producerId); producerBuilder.setRequestId(requestId); if (producerName != null) { producerBuilder.setProducerName(producerName); } producerBuilder.setEncrypted(encrypted); producerBuilder.addAllMetadata(CommandUtils.toKeyValueList(metadata)); if (null != schemaInfo) { producerBuilder.setSchema(getSchema(schemaInfo)); } CommandProducer producer = producerBuilder.build(); ByteBuf res = serializeWithSize(BaseCommand.newBuilder().setType(Type.PRODUCER).setProducer(producer)); producerBuilder.recycle(); producer.recycle(); return res; }
public ClientCnx(ClientConfigurationData conf, EventLoopGroup eventLoopGroup) { this(conf, eventLoopGroup, Commands.getCurrentProtocolVersion()); }
protected ByteBuf newConnectCommand() throws PulsarClientException { String authData = ""; if (authentication.getAuthData().hasDataFromCommand()) { authData = authentication.getAuthData().getCommandData(); } return Commands.newConnect(authentication.getAuthMethodName(), authData, this.protocolVersion, getPulsarClientVersion(), proxyToTargetBrokerAddress, null, null, null); }
public static ByteBuf newProducer(String topic, long producerId, long requestId, String producerName, boolean encrypted, Map<String, String> metadata) { return newProducer(topic, producerId, requestId, producerName, encrypted, metadata, null); }
public static ByteBuf newProducerSuccess(long requestId, String producerName, SchemaVersion schemaVersion) { return newProducerSuccess(requestId, producerName, -1, schemaVersion); }
public static Map<String, String> metadataFromCommand(PulsarApi.CommandSubscribe commandSubscribe) { return toMap(commandSubscribe.getMetadataList()); }
public static Map<String, String> metadataFromCommand(PulsarApi.CommandProducer commandProducer) { return toMap(commandProducer.getMetadataList()); }
public static ByteBuf newSubscribe(String topic, String subscription, long consumerId, long requestId, SubType subType, int priorityLevel, String consumerName) { return newSubscribe(topic, subscription, consumerId, requestId, subType, priorityLevel, consumerName, true /* isDurable */, null /* startMessageId */, Collections.emptyMap(), false, InitialPosition.Earliest, null); }
/** * @return a single buffer with the content of both individual buffers */ @VisibleForTesting public static ByteBuf coalesce(ByteBufPair pair) { ByteBuf b = Unpooled.buffer(pair.readableBytes()); b.writeBytes(pair.b1, pair.b1.readerIndex(), pair.b1.readableBytes()); b.writeBytes(pair.b2, pair.b2.readerIndex(), pair.b2.readableBytes()); return b; }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { cancelKeepAliveTask(); }
@Override final protected void handlePing(CommandPing ping) { // Immediately reply success to ping requests if (log.isDebugEnabled()) { log.debug("[{}] Replying back to ping message", ctx.channel()); } ctx.writeAndFlush(Commands.newPong()); }
/** * Get a new {@link ByteBufPair} from the pool and assign 2 buffers to it. * <p> * The buffers b1 and b2 lifecycles are now managed by the ByteBufPair: when the {@link ByteBufPair} is deallocated, * b1 and b2 will be released as well. * * @param b1 * @param b2 * @return */ public static ByteBufPair get(ByteBuf b1, ByteBuf b2) { ByteBufPair buf = RECYCLER.get(); buf.setRefCnt(1); buf.b1 = b1; buf.b2 = b2; return buf; }
/** * send the flow command to have the broker start pushing messages */ void sendFlowPermitsToBroker(ClientCnx cnx, int numMessages) { if (cnx != null) { if (log.isDebugEnabled()) { log.debug("[{}] [{}] Adding {} additional permits", topic, subscription, numMessages); } cnx.ctx().writeAndFlush(Commands.newFlow(consumerId, numMessages), cnx.ctx().voidPromise()); } }
private ByteBufPair sendMessage(long producerId, long sequenceId, int numMessages, MessageMetadata msgMetadata, ByteBuf compressedPayload) throws IOException { ChecksumType checksumType; if (connectionHandler.getClientCnx() == null || connectionHandler.getClientCnx().getRemoteEndpointProtocolVersion() >= brokerChecksumSupportedVersion()) { checksumType = ChecksumType.Crc32c; } else { checksumType = ChecksumType.None; } return Commands.newSend(producerId, sequenceId, numMessages, checksumType, msgMetadata, compressedPayload); }
public static ByteBuf newConnect(String authMethodName, String authData, String libVersion) { return newConnect(authMethodName, authData, getCurrentProtocolVersion(), libVersion, null /* target broker */, null /* originalPrincipal */, null /* Client Auth Data */, null /* Client Auth Method */); }
@VisibleForTesting public static ByteBuf newProducer(String topic, long producerId, long requestId, String producerName, Map<String, String> metadata) { return newProducer(topic, producerId, requestId, producerName, false, metadata); }
public static ByteBuf newConnect(String authMethodName, String authData, String libVersion, String targetBroker) { return newConnect(authMethodName, authData, getCurrentProtocolVersion(), libVersion, targetBroker, null, null, null); }