NIFI-413: Formatted code to fix checkstyle failures

This commit is contained in:
Mark Payne 2015-06-22 12:05:02 -04:00
parent f5226ad3c6
commit f2f9056055
2 changed files with 203 additions and 195 deletions

View File

@ -103,6 +103,7 @@ public class PutKafka extends AbstractProcessor {
*/ */
public static final AllowableValue COMPRESSION_CODEC_SNAPPY = new AllowableValue("snappy", "Snappy", "Compress messages using Snappy"); public static final AllowableValue COMPRESSION_CODEC_SNAPPY = new AllowableValue("snappy", "Snappy", "Compress messages using Snappy");
public static final PropertyDescriptor SEED_BROKERS = new PropertyDescriptor.Builder() public static final PropertyDescriptor SEED_BROKERS = new PropertyDescriptor.Builder()
.name("Known Brokers") .name("Known Brokers")
.description("A comma-separated list of known Kafka Brokers in the format <host>:<port>") .description("A comma-separated list of known Kafka Brokers in the format <host>:<port>")
@ -182,7 +183,8 @@ public class PutKafka extends AbstractProcessor {
+ " to send or \"Queue Buffering Max Time\" is reached.") + " to send or \"Queue Buffering Max Time\" is reached.")
.required(true) .required(true)
.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR)
.defaultValue("200").build(); .defaultValue("200")
.build();
public static final PropertyDescriptor QUEUE_BUFFERING_MAX = new PropertyDescriptor.Builder() public static final PropertyDescriptor QUEUE_BUFFERING_MAX = new PropertyDescriptor.Builder()
.name("Queue Buffering Max Time") .name("Queue Buffering Max Time")
.description("Used only if Producer Type is set to \"" + PRODUCTER_TYPE_ASYNCHRONOUS.getDisplayName() + "\"." .description("Used only if Producer Type is set to \"" + PRODUCTER_TYPE_ASYNCHRONOUS.getDisplayName() + "\"."
@ -191,7 +193,8 @@ public class PutKafka extends AbstractProcessor {
+ " throughput but adds message delivery latency due to the buffering.") + " throughput but adds message delivery latency due to the buffering.")
.required(true) .required(true)
.addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
.defaultValue("5 secs").build(); .defaultValue("5 secs")
.build();
public static final PropertyDescriptor QUEUE_BUFFERING_MAX_MESSAGES = new PropertyDescriptor.Builder() public static final PropertyDescriptor QUEUE_BUFFERING_MAX_MESSAGES = new PropertyDescriptor.Builder()
.name("Queue Buffer Max Count") .name("Queue Buffer Max Count")
.description("Used only if Producer Type is set to \"" + PRODUCTER_TYPE_ASYNCHRONOUS.getDisplayName() + "\"." .description("Used only if Producer Type is set to \"" + PRODUCTER_TYPE_ASYNCHRONOUS.getDisplayName() + "\"."
@ -199,7 +202,8 @@ public class PutKafka extends AbstractProcessor {
+ " using " + PRODUCTER_TYPE_ASYNCHRONOUS.getDisplayName() + " mode before either the producer must be blocked or data must be dropped.") + " using " + PRODUCTER_TYPE_ASYNCHRONOUS.getDisplayName() + " mode before either the producer must be blocked or data must be dropped.")
.required(true) .required(true)
.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR)
.defaultValue("10000").build(); .defaultValue("10000")
.build();
public static final PropertyDescriptor QUEUE_ENQUEUE_TIMEOUT = new PropertyDescriptor.Builder() public static final PropertyDescriptor QUEUE_ENQUEUE_TIMEOUT = new PropertyDescriptor.Builder()
.name("Queue Enqueue Timeout") .name("Queue Enqueue Timeout")
.description("Used only if Producer Type is set to \"" + PRODUCTER_TYPE_ASYNCHRONOUS.getDisplayName() + "\"." .description("Used only if Producer Type is set to \"" + PRODUCTER_TYPE_ASYNCHRONOUS.getDisplayName() + "\"."
@ -219,7 +223,8 @@ public class PutKafka extends AbstractProcessor {
.required(true) .required(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.allowableValues(COMPRESSION_CODEC_NONE, COMPRESSION_CODEC_GZIP, COMPRESSION_CODEC_SNAPPY) .allowableValues(COMPRESSION_CODEC_NONE, COMPRESSION_CODEC_GZIP, COMPRESSION_CODEC_SNAPPY)
.defaultValue(COMPRESSION_CODEC_NONE.getValue()).build(); .defaultValue(COMPRESSION_CODEC_NONE.getValue())
.build();
public static final PropertyDescriptor COMPRESSED_TOPICS = new PropertyDescriptor.Builder() public static final PropertyDescriptor COMPRESSED_TOPICS = new PropertyDescriptor.Builder()
.name("Compressed Topics") .name("Compressed Topics")
.description("This parameter allows you to set whether compression should be turned on" .description("This parameter allows you to set whether compression should be turned on"
@ -228,7 +233,8 @@ public class PutKafka extends AbstractProcessor {
+ " If the list of compressed topics is empty, then enable the specified" + " If the list of compressed topics is empty, then enable the specified"
+ " compression codec for all topics. If the compression codec is " + COMPRESSION_CODEC_NONE.getDisplayName() + "," + " compression codec for all topics. If the compression codec is " + COMPRESSION_CODEC_NONE.getDisplayName() + ","
+ " compression is disabled for all topics") + " compression is disabled for all topics")
.required(false).build(); .required(false)
.build();
public static final Relationship REL_SUCCESS = new Relationship.Builder() public static final Relationship REL_SUCCESS = new Relationship.Builder()
.name("success") .name("success")
@ -275,7 +281,8 @@ public class PutKafka extends AbstractProcessor {
final Integer bufferMaxMessages = context.getProperty(QUEUE_BUFFERING_MAX_MESSAGES).asInteger(); final Integer bufferMaxMessages = context.getProperty(QUEUE_BUFFERING_MAX_MESSAGES).asInteger();
if (batchMessages > bufferMaxMessages) { if (batchMessages > bufferMaxMessages) {
errors.add(new ValidationResult.Builder().subject("Batch Size, Queue Buffer").valid(false).explanation("Batch Size (" + batchMessages + ") must be equal to or less than the Queue Buffer Max Count (" + bufferMaxMessages + ")").build()); errors.add(new ValidationResult.Builder().subject("Batch Size, Queue Buffer").valid(false)
.explanation("Batch Size (" + batchMessages + ") must be equal to or less than the Queue Buffer Max Count (" + bufferMaxMessages + ")").build());
} }
return errors; return errors;
@ -311,21 +318,21 @@ public class PutKafka extends AbstractProcessor {
properties.setProperty("producer.type", context.getProperty(PRODUCER_TYPE).getValue()); properties.setProperty("producer.type", context.getProperty(PRODUCER_TYPE).getValue());
properties.setProperty("batch.num.messages", context.getProperty(BATCH_NUM_MESSAGES).getValue()); properties.setProperty("batch.num.messages", context.getProperty(BATCH_NUM_MESSAGES).getValue());
Long queueBufferingMillis = context.getProperty(QUEUE_BUFFERING_MAX).asTimePeriod(TimeUnit.MILLISECONDS); final Long queueBufferingMillis = context.getProperty(QUEUE_BUFFERING_MAX).asTimePeriod(TimeUnit.MILLISECONDS);
if (queueBufferingMillis != null) { if (queueBufferingMillis != null) {
properties.setProperty("queue.buffering.max.ms", String.valueOf(queueBufferingMillis)); properties.setProperty("queue.buffering.max.ms", String.valueOf(queueBufferingMillis));
} }
properties.setProperty("queue.buffering.max.messages", context.getProperty(QUEUE_BUFFERING_MAX_MESSAGES).getValue()); properties.setProperty("queue.buffering.max.messages", context.getProperty(QUEUE_BUFFERING_MAX_MESSAGES).getValue());
Long queueEnqueueTimeoutMillis = context.getProperty(QUEUE_ENQUEUE_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS); final Long queueEnqueueTimeoutMillis = context.getProperty(QUEUE_ENQUEUE_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS);
if (queueEnqueueTimeoutMillis != null) { if (queueEnqueueTimeoutMillis != null) {
properties.setProperty("queue.enqueue.timeout.ms", String.valueOf(queueEnqueueTimeoutMillis)); properties.setProperty("queue.enqueue.timeout.ms", String.valueOf(queueEnqueueTimeoutMillis));
} }
String compressionCodec = context.getProperty(COMPRESSION_CODEC).getValue(); final String compressionCodec = context.getProperty(COMPRESSION_CODEC).getValue();
properties.setProperty("compression.codec", compressionCodec); properties.setProperty("compression.codec", compressionCodec);
String compressedTopics = context.getProperty(COMPRESSED_TOPICS).getValue(); final String compressedTopics = context.getProperty(COMPRESSED_TOPICS).getValue();
if (compressedTopics != null) { if (compressedTopics != null) {
properties.setProperty("compressed.topics", compressedTopics); properties.setProperty("compressed.topics", compressedTopics);
} }
@ -338,7 +345,7 @@ public class PutKafka extends AbstractProcessor {
} }
private Producer<byte[], byte[]> borrowProducer(final ProcessContext context) { private Producer<byte[], byte[]> borrowProducer(final ProcessContext context) {
Producer<byte[], byte[]> producer = producers.poll(); final Producer<byte[], byte[]> producer = producers.poll();
return producer == null ? createProducer(context) : producer; return producer == null ? createProducer(context) : producer;
} }
@ -348,7 +355,7 @@ public class PutKafka extends AbstractProcessor {
@Override @Override
public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException { public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
FlowFile flowFile = session.get(); final FlowFile flowFile = session.get();
if (flowFile == null) { if (flowFile == null) {
return; return;
} }
@ -356,7 +363,7 @@ public class PutKafka extends AbstractProcessor {
final long start = System.nanoTime(); final long start = System.nanoTime();
final String topic = context.getProperty(TOPIC).evaluateAttributeExpressions(flowFile).getValue(); final String topic = context.getProperty(TOPIC).evaluateAttributeExpressions(flowFile).getValue();
final String key = context.getProperty(KEY).evaluateAttributeExpressions(flowFile).getValue(); final String key = context.getProperty(KEY).evaluateAttributeExpressions(flowFile).getValue();
final byte[] keyBytes = (key == null) ? null : key.getBytes(StandardCharsets.UTF_8); final byte[] keyBytes = key == null ? null : key.getBytes(StandardCharsets.UTF_8);
String delimiter = context.getProperty(MESSAGE_DELIMITER).evaluateAttributeExpressions(flowFile).getValue(); String delimiter = context.getProperty(MESSAGE_DELIMITER).evaluateAttributeExpressions(flowFile).getValue();
if (delimiter != null) { if (delimiter != null) {
delimiter = delimiter.replace("\\n", "\n").replace("\\r", "\r").replace("\\t", "\t"); delimiter = delimiter.replace("\\n", "\n").replace("\\r", "\r").replace("\\t", "\t");

View File

@ -235,26 +235,26 @@ public class TestPutKafka {
public void testProducerConfigDefault() { public void testProducerConfigDefault() {
final TestableProcessor processor = new TestableProcessor(); final TestableProcessor processor = new TestableProcessor();
TestRunner runner = TestRunners.newTestRunner(processor); final TestRunner runner = TestRunners.newTestRunner(processor);
runner.setProperty(PutKafka.TOPIC, "topic1"); runner.setProperty(PutKafka.TOPIC, "topic1");
runner.setProperty(PutKafka.KEY, "key1"); runner.setProperty(PutKafka.KEY, "key1");
runner.setProperty(PutKafka.SEED_BROKERS, "localhost:1234"); runner.setProperty(PutKafka.SEED_BROKERS, "localhost:1234");
runner.setProperty(PutKafka.MESSAGE_DELIMITER, "\\n"); runner.setProperty(PutKafka.MESSAGE_DELIMITER, "\\n");
ProcessContext context = runner.getProcessContext(); final ProcessContext context = runner.getProcessContext();
ProducerConfig config = processor.createConfig(context); final ProducerConfig config = processor.createConfig(context);
// Check the codec // Check the codec
CompressionCodec codec = config.compressionCodec(); final CompressionCodec codec = config.compressionCodec();
assertTrue(codec instanceof kafka.message.NoCompressionCodec$); assertTrue(codec instanceof kafka.message.NoCompressionCodec$);
// Check compressed topics // Check compressed topics
Seq<String> compressedTopics = config.compressedTopics(); final Seq<String> compressedTopics = config.compressedTopics();
assertEquals(0, compressedTopics.size()); assertEquals(0, compressedTopics.size());
// Check the producer type // Check the producer type
String actualProducerType = config.producerType(); final String actualProducerType = config.producerType();
assertEquals(PutKafka.PRODUCER_TYPE.getDefaultValue(), actualProducerType); assertEquals(PutKafka.PRODUCER_TYPE.getDefaultValue(), actualProducerType);
} }
@ -263,7 +263,7 @@ public class TestPutKafka {
public void testProducerConfigAsyncWithCompression() { public void testProducerConfigAsyncWithCompression() {
final TestableProcessor processor = new TestableProcessor(); final TestableProcessor processor = new TestableProcessor();
TestRunner runner = TestRunners.newTestRunner(processor); final TestRunner runner = TestRunners.newTestRunner(processor);
runner.setProperty(PutKafka.TOPIC, "topic1"); runner.setProperty(PutKafka.TOPIC, "topic1");
runner.setProperty(PutKafka.KEY, "key1"); runner.setProperty(PutKafka.KEY, "key1");
@ -273,22 +273,22 @@ public class TestPutKafka {
runner.setProperty(PutKafka.COMPRESSION_CODEC, PutKafka.COMPRESSION_CODEC_SNAPPY.getValue()); runner.setProperty(PutKafka.COMPRESSION_CODEC, PutKafka.COMPRESSION_CODEC_SNAPPY.getValue());
runner.setProperty(PutKafka.COMPRESSED_TOPICS, "topic01,topic02,topic03"); runner.setProperty(PutKafka.COMPRESSED_TOPICS, "topic01,topic02,topic03");
ProcessContext context = runner.getProcessContext(); final ProcessContext context = runner.getProcessContext();
ProducerConfig config = processor.createConfig(context); final ProducerConfig config = processor.createConfig(context);
// Check that the codec is snappy // Check that the codec is snappy
CompressionCodec codec = config.compressionCodec(); final CompressionCodec codec = config.compressionCodec();
assertTrue(codec instanceof kafka.message.SnappyCompressionCodec$); assertTrue(codec instanceof kafka.message.SnappyCompressionCodec$);
// Check compressed topics // Check compressed topics
Seq<String> compressedTopics = config.compressedTopics(); final Seq<String> compressedTopics = config.compressedTopics();
assertEquals(3, compressedTopics.size()); assertEquals(3, compressedTopics.size());
assertTrue(compressedTopics.contains("topic01")); assertTrue(compressedTopics.contains("topic01"));
assertTrue(compressedTopics.contains("topic02")); assertTrue(compressedTopics.contains("topic02"));
assertTrue(compressedTopics.contains("topic03")); assertTrue(compressedTopics.contains("topic03"));
// Check the producer type // Check the producer type
String actualProducerType = config.producerType(); final String actualProducerType = config.producerType();
assertEquals("async", actualProducerType); assertEquals("async", actualProducerType);
} }
@ -297,7 +297,7 @@ public class TestPutKafka {
public void testProducerConfigAsyncQueueThresholds() { public void testProducerConfigAsyncQueueThresholds() {
final TestableProcessor processor = new TestableProcessor(); final TestableProcessor processor = new TestableProcessor();
TestRunner runner = TestRunners.newTestRunner(processor); final TestRunner runner = TestRunners.newTestRunner(processor);
runner.setProperty(PutKafka.TOPIC, "topic1"); runner.setProperty(PutKafka.TOPIC, "topic1");
runner.setProperty(PutKafka.KEY, "key1"); runner.setProperty(PutKafka.KEY, "key1");
@ -308,8 +308,8 @@ public class TestPutKafka {
runner.setProperty(PutKafka.QUEUE_BUFFERING_MAX_MESSAGES, "535"); runner.setProperty(PutKafka.QUEUE_BUFFERING_MAX_MESSAGES, "535");
runner.setProperty(PutKafka.QUEUE_ENQUEUE_TIMEOUT, "200 ms"); runner.setProperty(PutKafka.QUEUE_ENQUEUE_TIMEOUT, "200 ms");
ProcessContext context = runner.getProcessContext(); final ProcessContext context = runner.getProcessContext();
ProducerConfig config = processor.createConfig(context); final ProducerConfig config = processor.createConfig(context);
// Check that the queue thresholds were properly translated // Check that the queue thresholds were properly translated
assertEquals(7000, config.queueBufferingMaxMs()); assertEquals(7000, config.queueBufferingMaxMs());
@ -317,7 +317,7 @@ public class TestPutKafka {
assertEquals(200, config.queueEnqueueTimeoutMs()); assertEquals(200, config.queueEnqueueTimeoutMs());
// Check the producer type // Check the producer type
String actualProducerType = config.producerType(); final String actualProducerType = config.producerType();
assertEquals("async", actualProducerType); assertEquals("async", actualProducerType);
} }
@ -326,7 +326,7 @@ public class TestPutKafka {
public void testProducerConfigInvalidBatchSize() { public void testProducerConfigInvalidBatchSize() {
final TestableProcessor processor = new TestableProcessor(); final TestableProcessor processor = new TestableProcessor();
TestRunner runner = TestRunners.newTestRunner(processor); final TestRunner runner = TestRunners.newTestRunner(processor);
runner.setProperty(PutKafka.TOPIC, "topic1"); runner.setProperty(PutKafka.TOPIC, "topic1");
runner.setProperty(PutKafka.KEY, "key1"); runner.setProperty(PutKafka.KEY, "key1");
@ -344,7 +344,7 @@ public class TestPutKafka {
public void testProducerConfigAsyncDefaultEnqueueTimeout() { public void testProducerConfigAsyncDefaultEnqueueTimeout() {
final TestableProcessor processor = new TestableProcessor(); final TestableProcessor processor = new TestableProcessor();
TestRunner runner = TestRunners.newTestRunner(processor); final TestRunner runner = TestRunners.newTestRunner(processor);
runner.setProperty(PutKafka.TOPIC, "topic1"); runner.setProperty(PutKafka.TOPIC, "topic1");
runner.setProperty(PutKafka.KEY, "key1"); runner.setProperty(PutKafka.KEY, "key1");
@ -353,14 +353,14 @@ public class TestPutKafka {
runner.setProperty(PutKafka.PRODUCER_TYPE, PutKafka.PRODUCTER_TYPE_ASYNCHRONOUS.getValue()); runner.setProperty(PutKafka.PRODUCER_TYPE, PutKafka.PRODUCTER_TYPE_ASYNCHRONOUS.getValue());
// Do not set QUEUE_ENQUEUE_TIMEOUT // Do not set QUEUE_ENQUEUE_TIMEOUT
ProcessContext context = runner.getProcessContext(); final ProcessContext context = runner.getProcessContext();
ProducerConfig config = processor.createConfig(context); final ProducerConfig config = processor.createConfig(context);
// Check that the enqueue timeout defaults to -1 // Check that the enqueue timeout defaults to -1
assertEquals(-1, config.queueEnqueueTimeoutMs()); assertEquals(-1, config.queueEnqueueTimeoutMs());
// Check the producer type // Check the producer type
String actualProducerType = config.producerType(); final String actualProducerType = config.producerType();
assertEquals("async", actualProducerType); assertEquals("async", actualProducerType);
} }
@ -395,6 +395,7 @@ public class TestPutKafka {
/** /**
* Exposed for test verification * Exposed for test verification
*/ */
@Override
public ProducerConfig createConfig(final ProcessContext context) { public ProducerConfig createConfig(final ProcessContext context) {
return super.createConfig(context); return super.createConfig(context);
} }