You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by fj...@apache.org on 2019/04/16 00:41:59 UTC

[incubator-druid] branch master updated: Fix ParallelIndexTuningConfig constructor (#7479)

This is an automated email from the ASF dual-hosted git repository.

fjy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git


The following commit(s) were added to refs/heads/master by this push:
     new 625c030  Fix ParallelIndexTuningConfig constructor (#7479)
625c030 is described below

commit 625c03074400aac0329d5a85a8c6e597e404504d
Author: Jihoon Son <ji...@apache.org>
AuthorDate: Mon Apr 15 17:41:53 2019 -0700

    Fix ParallelIndexTuningConfig constructor (#7479)
    
    * Fix ParallelIndexTuningConfig constructor
    
    * unused import
---
 .../batch/parallel/ParallelIndexTuningConfig.java  |  6 +-
 .../parallel/ParallelIndexTuningConfigTest.java    | 92 ++++++++++++++++++++++
 2 files changed, 96 insertions(+), 2 deletions(-)

diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexTuningConfig.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexTuningConfig.java
index 2038bf0..2c41549 100644
--- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexTuningConfig.java
+++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexTuningConfig.java
@@ -127,8 +127,10 @@ public class ParallelIndexTuningConfig extends IndexTuningConfig
                                    DEFAULT_TASK_STATUS_CHECK_PERIOD_MS :
                                    taskStatusCheckPeriodMs;
 
-    this.chatHandlerTimeout = DEFAULT_CHAT_HANDLER_TIMEOUT;
-    this.chatHandlerNumRetries = DEFAULT_CHAT_HANDLER_NUM_RETRIES;
+    this.chatHandlerTimeout = chatHandlerTimeout == null ? DEFAULT_CHAT_HANDLER_TIMEOUT : chatHandlerTimeout;
+    this.chatHandlerNumRetries = chatHandlerNumRetries == null
+                                 ? DEFAULT_CHAT_HANDLER_NUM_RETRIES
+                                 : chatHandlerNumRetries;
 
     Preconditions.checkArgument(this.maxNumSubTasks > 0, "maxNumSubTasks must be positive");
   }
diff --git a/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexTuningConfigTest.java b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexTuningConfigTest.java
new file mode 100644
index 0000000..d587c6c
--- /dev/null
+++ b/indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexTuningConfigTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.druid.indexing.common.task.batch.parallel;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.jsontype.NamedType;
+import org.apache.druid.jackson.DefaultObjectMapper;
+import org.apache.druid.segment.IndexSpec;
+import org.apache.druid.segment.data.CompressionFactory.LongEncodingStrategy;
+import org.apache.druid.segment.data.CompressionStrategy;
+import org.apache.druid.segment.data.RoaringBitmapSerdeFactory;
+import org.apache.druid.segment.indexing.TuningConfig;
+import org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory;
+import org.joda.time.Duration;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+
+public class ParallelIndexTuningConfigTest
+{
+  private final ObjectMapper mapper = new DefaultObjectMapper();
+
+  @Before
+  public void setup()
+  {
+    mapper.registerSubtypes(new NamedType(ParallelIndexTuningConfig.class, "index_parallel"));
+  }
+
+  @Test
+  public void testSerdeDefault() throws IOException
+  {
+    final ParallelIndexTuningConfig tuningConfig = ParallelIndexTuningConfig.defaultConfig();
+    final byte[] json = mapper.writeValueAsBytes(tuningConfig);
+    final ParallelIndexTuningConfig fromJson = (ParallelIndexTuningConfig) mapper.readValue(json, TuningConfig.class);
+    Assert.assertEquals(fromJson, tuningConfig);
+  }
+
+  @Test
+  public void testSerdeWithMaxRowsPerSegment()
+      throws IOException
+  {
+    final ParallelIndexTuningConfig tuningConfig = new ParallelIndexTuningConfig(
+        null,
+        100,
+        10,
+        1000L,
+        100L,
+        null,
+        new IndexSpec(
+            new RoaringBitmapSerdeFactory(true),
+            CompressionStrategy.UNCOMPRESSED,
+            CompressionStrategy.LZF,
+            LongEncodingStrategy.LONGS
+        ),
+        1,
+        false,
+        true,
+        10000L,
+        OffHeapMemorySegmentWriteOutMediumFactory.instance(),
+        250,
+        100,
+        20,
+        new Duration(3600),
+        128,
+        false,
+        null,
+        null
+    );
+    final byte[] json = mapper.writeValueAsBytes(tuningConfig);
+    final ParallelIndexTuningConfig fromJson = (ParallelIndexTuningConfig) mapper.readValue(json, TuningConfig.class);
+    Assert.assertEquals(fromJson, tuningConfig);
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org