kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsiva...@apache.org
Subject [kafka] branch trunk updated: MINOR: Add NullPayloadGenerator to Trogdor (#4844)
Date Tue, 10 Apr 2018 19:48:42 GMT
This is an automated email from the ASF dual-hosted git repository.

rsivaram pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 4223ef6  MINOR: Add NullPayloadGenerator to Trogdor (#4844)
4223ef6 is described below

commit 4223ef61060673e95077abfe6aca27bc0f71fffa
Author: Colin Patrick McCabe <colin@cmccabe.xyz>
AuthorDate: Tue Apr 10 12:48:38 2018 -0700

    MINOR: Add NullPayloadGenerator to Trogdor (#4844)
---
 .../trogdor/workload/NullPayloadGenerator.java     | 33 ++++++++++++++++++++++
 .../kafka/trogdor/workload/PayloadGenerator.java   |  3 +-
 .../trogdor/workload/PayloadGeneratorTest.java     |  8 ++++++
 3 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/tools/src/main/java/org/apache/kafka/trogdor/workload/NullPayloadGenerator.java
b/tools/src/main/java/org/apache/kafka/trogdor/workload/NullPayloadGenerator.java
new file mode 100644
index 0000000..e9799c0
--- /dev/null
+++ b/tools/src/main/java/org/apache/kafka/trogdor/workload/NullPayloadGenerator.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.trogdor.workload;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+
+/**
+ * A PayloadGenerator which always generates a null payload.
+ */
+public class NullPayloadGenerator implements PayloadGenerator {
+    @JsonCreator
+    public NullPayloadGenerator() {
+    }
+
+    @Override
+    public byte[] generate(long position) {
+        return null;
+    }
+}
diff --git a/tools/src/main/java/org/apache/kafka/trogdor/workload/PayloadGenerator.java b/tools/src/main/java/org/apache/kafka/trogdor/workload/PayloadGenerator.java
index 4895f21..3c574ba 100644
--- a/tools/src/main/java/org/apache/kafka/trogdor/workload/PayloadGenerator.java
+++ b/tools/src/main/java/org/apache/kafka/trogdor/workload/PayloadGenerator.java
@@ -33,7 +33,8 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
 @JsonSubTypes(value = {
     @JsonSubTypes.Type(value = ConstantPayloadGenerator.class, name = "constant"),
     @JsonSubTypes.Type(value = SequentialPayloadGenerator.class, name = "sequential"),
-    @JsonSubTypes.Type(value = UniformRandomPayloadGenerator.class, name = "uniformRandom")
+    @JsonSubTypes.Type(value = UniformRandomPayloadGenerator.class, name = "uniformRandom"),
+    @JsonSubTypes.Type(value = NullPayloadGenerator.class, name = "null")
     })
 public interface PayloadGenerator {
     /**
diff --git a/tools/src/test/java/org/apache/kafka/trogdor/workload/PayloadGeneratorTest.java
b/tools/src/test/java/org/apache/kafka/trogdor/workload/PayloadGeneratorTest.java
index 25ef2e3..0909dc0 100644
--- a/tools/src/test/java/org/apache/kafka/trogdor/workload/PayloadGeneratorTest.java
+++ b/tools/src/test/java/org/apache/kafka/trogdor/workload/PayloadGeneratorTest.java
@@ -139,4 +139,12 @@ public class PayloadGeneratorTest {
         iter.seek(0);
         assertEquals(0, iter.position());
     }
+
+    @Test
+    public void testNullPayloadGenerator() {
+        NullPayloadGenerator generator = new NullPayloadGenerator();
+        assertEquals(null, generator.generate(0));
+        assertEquals(null, generator.generate(1));
+        assertEquals(null, generator.generate(100));
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
rsivaram@apache.org.

Mime
View raw message