public ClientCnx(PulsarClientImpl pulsarClient) { super(30, TimeUnit.SECONDS); this.pendingLookupRequestSemaphore = new Semaphore(pulsarClient.getConfiguration().getConcurrentLookupRequest(), true); this.authentication = pulsarClient.getConfiguration().getAuthentication(); this.eventLoopGroup = pulsarClient.eventLoopGroup(); this.maxNumberOfRejectedRequestPerConnection = pulsarClient.getConfiguration() .getMaxNumberOfRejectedRequestPerConnection(); this.state = State.None; }
public ConnectionPool(final PulsarClientImpl client, EventLoopGroup eventLoopGroup) { this.eventLoopGroup = eventLoopGroup; this.maxConnectionsPerHosts = client.getConfiguration().getConnectionsPerBroker(); bootstrap.option(ChannelOption.TCP_NODELAY, client.getConfiguration().isUseTcpNoDelay()); bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); bootstrap.handler(new ChannelInitializer<SocketChannel>() {
PartitionedConsumerImpl(PulsarClientImpl client, String topic, String subscription, ConsumerConfiguration conf, int numPartitions, ExecutorService listenerExecutor, CompletableFuture<Consumer> subscribeFuture) { super(client, topic, subscription, conf, Math.max(numPartitions, conf.getReceiverQueueSize()), listenerExecutor, subscribeFuture); this.consumers = Lists.newArrayListWithCapacity(numPartitions); this.pausedConsumers = new ConcurrentLinkedQueue<>(); this.sharedQueueResumeThreshold = maxReceiverQueueSize / 2; this.numPartitions = numPartitions; stats = client.getConfiguration().getStatsIntervalSeconds() > 0 ? new ConsumerStats() : null; checkArgument(conf.getReceiverQueueSize() > 0, "Receiver queue size needs to be greater than 0 for Partitioned Topics"); start(); }
public PartitionedProducerImpl(PulsarClientImpl client, String topic, ProducerConfiguration conf, int numPartitions, CompletableFuture<Producer> producerCreatedFuture) { super(client, topic, conf, producerCreatedFuture); this.producers = Lists.newArrayListWithCapacity(numPartitions); this.numPartitions = numPartitions; this.routerPolicy = conf.getMessageRouter(numPartitions); stats = client.getConfiguration().getStatsIntervalSeconds() > 0 ? new ProducerStats() : null; start(); }
log.info("Pulsar client config: {}", w.writeValueAsString(pulsarClient.getConfiguration())); } catch (IOException e) { log.error("Failed to dump config info: {}", e);
log.info("Pulsar client config: {}", w.writeValueAsString(pulsarClient.getConfiguration())); } catch (IOException e) { log.error("Failed to dump config info: {}", e);
public void initChannel(SocketChannel ch) throws Exception { ClientConfiguration clientConfig = client.getConfiguration(); if (clientConfig.isUseTls()) { SslContextBuilder builder = SslContextBuilder.forClient(); if (clientConfig.isTlsAllowInsecureConnection()) { builder.trustManager(InsecureTrustManagerFactory.INSTANCE); } else { if (clientConfig.getTlsTrustCertsFilePath().isEmpty()) { // Use system default builder.trustManager((File) null); } else { File trustCertCollection = new File(clientConfig.getTlsTrustCertsFilePath()); builder.trustManager(trustCertCollection); } } // Set client certificate if available AuthenticationDataProvider authData = clientConfig.getAuthentication().getAuthData(); if (authData.hasDataForTls()) { builder.keyManager(authData.getTlsPrivateKey(), (X509Certificate[]) authData.getTlsCertificates()); } SslContext sslCtx = builder.build(); ch.pipeline().addLast(TLS_HANDLER, sslCtx.newHandler(ch.alloc())); } ch.pipeline().addLast("frameDecoder", new PulsarLengthFieldFrameDecoder(MaxMessageSize, 0, 4, 0, 4)); ch.pipeline().addLast("handler", new ClientCnx(client)); } });
this.startMessageId = startMessageId; AVAILABLE_PERMITS_UPDATER.set(this, 0); this.subscribeTimeout = System.currentTimeMillis() + client.getConfiguration().getOperationTimeoutMs(); this.partitionIndex = partitionIndex; this.receiverQueueRefillThreshold = conf.getReceiverQueueSize() / 2; this.priorityLevel = conf.getPriorityLevel(); this.batchMessageAckTracker = new ConcurrentSkipListMap<>(); if (client.getConfiguration().getStatsIntervalSeconds() > 0) { stats = new ConsumerStats(client, conf, this); } else {
public ProducerStats(PulsarClientImpl pulsarClient, ProducerConfiguration conf, ProducerImpl producer) { this.pulsarClient = pulsarClient; this.statsIntervalSeconds = pulsarClient.getConfiguration().getStatsIntervalSeconds(); this.producer = producer; numMsgsSent = new LongAdder(); numBytesSent = new LongAdder(); numSendFailed = new LongAdder(); numAcksReceived = new LongAdder(); totalMsgsSent = new LongAdder(); totalBytesSent = new LongAdder(); totalSendFailed = new LongAdder(); totalAcksReceived = new LongAdder(); ds = DoublesSketch.builder().build(256); dec = new DecimalFormat("0.000"); throughputFormat = new DecimalFormat("0.00"); init(conf); }
public ConsumerStats(PulsarClientImpl pulsarClient, ConsumerConfiguration conf, ConsumerImpl consumer) { this.pulsarClient = pulsarClient; this.consumer = consumer; this.statsIntervalSeconds = pulsarClient.getConfiguration().getStatsIntervalSeconds(); numMsgsReceived = new LongAdder(); numBytesReceived = new LongAdder(); numReceiveFailed = new LongAdder(); numAcksSent = new LongAdder(); numAcksFailed = new LongAdder(); totalMsgsReceived = new LongAdder(); totalBytesReceived = new LongAdder(); totalReceiveFailed = new LongAdder(); totalAcksSent = new LongAdder(); totalAcksFailed = new LongAdder(); throughputFormat = new DecimalFormat("0.00"); init(conf); }
public ProducerImpl(PulsarClientImpl client, String topic, String producerName, ProducerConfiguration conf, CompletableFuture<Producer> producerCreatedFuture, int partitionIndex) { super(client, topic, conf, producerCreatedFuture); this.producerId = client.newProducerId(); this.producerName = producerName; this.partitionIndex = partitionIndex; this.pendingMessages = Queues.newArrayBlockingQueue(conf.getMaxPendingMessages()); this.pendingCallbacks = Queues.newArrayBlockingQueue(conf.getMaxPendingMessages()); this.semaphore = new Semaphore(conf.getMaxPendingMessages(), true); this.compressor = CompressionCodecProvider .getCompressionCodec(convertCompressionType(conf.getCompressionType())); if (conf.getSendTimeoutMs() > 0) { sendTimeout = client.timer().newTimeout(this, conf.getSendTimeoutMs(), TimeUnit.MILLISECONDS); } this.createProducerTimeout = System.currentTimeMillis() + client.getConfiguration().getOperationTimeoutMs(); if (conf.getBatchingEnabled()) { this.maxNumMessagesInBatch = conf.getBatchingMaxMessages(); this.batchMessageContainer = new BatchMessageContainer(maxNumMessagesInBatch, convertCompressionType(conf.getCompressionType()), topic, producerName); } else { this.maxNumMessagesInBatch = 1; this.batchMessageContainer = null; } if (client.getConfiguration().getStatsIntervalSeconds() > 0) { stats = new ProducerStats(client, conf, this); } else { stats = ProducerStats.PRODUCER_STATS_DISABLED; } grabCnx(); }