Java Code Examples for org.apache.pulsar.client.api.CompressionType#NONE
The following examples show how to use
org.apache.pulsar.client.api.CompressionType#NONE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompressionCodecProvider.java From pulsar with Apache License 2.0 | 6 votes |
public static CompressionType convertFromWireProtocol(PulsarApi.CompressionType compressionType) { switch (compressionType) { case NONE: return CompressionType.NONE; case LZ4: return CompressionType.LZ4; case ZLIB: return CompressionType.ZLIB; case ZSTD: return CompressionType.ZSTD; case SNAPPY: return CompressionType.SNAPPY; default: throw new RuntimeException("Invalid compression type"); } }
Example 2
Source File: BatchMessageTest.java From pulsar with Apache License 2.0 | 5 votes |
@DataProvider(name = "codecAndContainerBuilder") public Object[][] codecAndContainerBuilderProvider() { return new Object[][] { { CompressionType.NONE, BatcherBuilder.DEFAULT }, { CompressionType.LZ4, BatcherBuilder.DEFAULT }, { CompressionType.ZLIB, BatcherBuilder.DEFAULT }, { CompressionType.NONE, BatcherBuilder.KEY_BASED }, { CompressionType.LZ4, BatcherBuilder.KEY_BASED }, { CompressionType.ZLIB, BatcherBuilder.KEY_BASED } }; }
Example 3
Source File: PulsarKafkaProducer.java From pulsar with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) public PulsarKafkaProducer(ProducerConfig config) { super((kafka.producer.Producer) null); partitioner = config.partitionerClass() != null ? newInstance(config.partitionerClass(), Partitioner.class, config.props()) : new DefaultPartitioner(config.props()); // kafka-config returns default serializer if client doesn't configure it checkNotNull(config.keySerializerClass(), "key-serializer class can't be null"); checkNotNull(config.serializerClass(), "value-serializer class can't be null"); keySerializer = newInstance(config.keySerializerClass(), Encoder.class, config.props()); valueSerializer = newInstance(config.serializerClass(), Encoder.class, config.props()); Properties properties = config.props() != null && config.props().props() != null ? config.props().props() : new Properties(); String serviceUrl = config.brokerList(); try { client = PulsarClientKafkaConfig.getClientBuilder(properties).serviceUrl(serviceUrl).build(); } catch (PulsarClientException e) { throw new IllegalArgumentException( "Failed to create pulsar-client using url = " + serviceUrl + ", properties = " + properties, e); } pulsarProducerBuilder = client.newProducer(); // doc: https://kafka.apache.org/08/documentation.html#producerapi // api-doc: // https://github.com/apache/kafka/blob/0.8.2.2/clients/src/main/java/org/apache/kafka/clients/producer/ProducerConfig.java // queue.enqueue.timeout.ms: The amount of time to block before dropping messages when running in async mode and // the buffer has reached queue.buffering.max.messages. If set to 0 events will be enqueued immediately or // dropped if the queue is full (the producer send call will never block). If set to -1 the producer will block // indefinitely and never willingly drop a send. boolean blockIfQueueFull = config.queueEnqueueTimeoutMs() == -1 ? true : false; // This parameter specifies whether the messages are sent asynchronously in a background thread. Valid values // are (1) async for asynchronous send and (2) sync for synchronous send. By setting the producer to async we // allow batching together of requests (which is great for throughput) but open the possibility of a failure of // the client machine dropping unsent data. isSendAsync = "async".equalsIgnoreCase(config.producerType()); CompressionType compressionType = CompressionType.NONE; // Valid values are "none", "gzip" and "snappy". if ("gzip".equals(config.compressionCodec().name())) { compressionType = CompressionType.ZLIB; } else if ("snappy".equals(config.compressionCodec().name())) { compressionType = CompressionType.SNAPPY; } long batchDelayMs = config.queueBufferingMaxMs(); if (properties.containsKey(KAFKA_KEY_MAX_QUEUE_BUFFERING_MESSAGES)) { pulsarProducerBuilder.maxPendingMessages(config.queueBufferingMaxMessages()); } if (properties.containsKey(KAFKA_KEY_MAX_BATCH_MESSAGES)) { pulsarProducerBuilder.batchingMaxMessages(config.batchNumMessages()); } if (properties.containsKey(KAFKA_KEY_MAX_QUEUE_BUFFERING_TIME_MS)) { pulsarProducerBuilder.batchingMaxPublishDelay(batchDelayMs, TimeUnit.MILLISECONDS); } if (properties.containsKey(KAFKA_KEY_REQUEST_TIMEOUT_MS)) { pulsarProducerBuilder.sendTimeout(config.requestTimeoutMs(), TimeUnit.MILLISECONDS); } pulsarProducerBuilder.blockIfQueueFull(blockIfQueueFull).compressionType(compressionType); }
Example 4
Source File: PersistentTopicE2ETest.java From pulsar with Apache License 2.0 | 4 votes |
@DataProvider(name = "codec") public Object[][] codecProvider() { return new Object[][] { { CompressionType.NONE }, { CompressionType.LZ4 }, { CompressionType.ZLIB }, }; }