kfaraz commented on code in PR #16602:
URL: https://github.com/apache/druid/pull/16602#discussion_r1644493943


##########
server/src/test/java/org/apache/druid/segment/realtime/appenderator/AppenderatorsTest.java:
##########
@@ -0,0 +1,245 @@
+/*
+ * 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.segment.realtime.appenderator;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.druid.data.input.impl.DimensionsSpec;
+import org.apache.druid.data.input.impl.JSONParseSpec;
+import org.apache.druid.data.input.impl.MapInputRowParser;
+import org.apache.druid.data.input.impl.TimestampSpec;
+import org.apache.druid.jackson.DefaultObjectMapper;
+import org.apache.druid.java.util.common.FileUtils;
+import org.apache.druid.java.util.common.granularity.Granularities;
+import org.apache.druid.java.util.emitter.EmittingLogger;
+import org.apache.druid.java.util.emitter.core.NoopEmitter;
+import org.apache.druid.java.util.emitter.service.ServiceEmitter;
+import org.apache.druid.query.aggregation.AggregatorFactory;
+import org.apache.druid.query.aggregation.CountAggregatorFactory;
+import org.apache.druid.query.aggregation.LongSumAggregatorFactory;
+import org.apache.druid.segment.IndexIO;
+import org.apache.druid.segment.IndexMerger;
+import org.apache.druid.segment.IndexMergerV9;
+import org.apache.druid.segment.IndexSpec;
+import org.apache.druid.segment.column.ColumnConfig;
+import org.apache.druid.segment.incremental.ParseExceptionHandler;
+import org.apache.druid.segment.incremental.RowIngestionMeters;
+import org.apache.druid.segment.incremental.SimpleRowIngestionMeters;
+import org.apache.druid.segment.indexing.DataSchema;
+import org.apache.druid.segment.indexing.TuningConfig;
+import org.apache.druid.segment.indexing.granularity.UniformGranularitySpec;
+import org.apache.druid.segment.loading.NoopDataSegmentPusher;
+import org.apache.druid.segment.metadata.CentralizedDatasourceSchemaConfig;
+import org.apache.druid.segment.realtime.SegmentGenerationMetrics;
+import 
org.apache.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory;
+import org.apache.druid.timeline.partition.LinearShardSpec;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.annotation.Nullable;
+import java.io.File;
+import java.util.Map;
+
+
+public class AppenderatorsTest
+{
+  @Test
+  public void testOpenSegmentsOfflineAppenderator() throws Exception
+  {
+    try (final AppenderatorTester tester = new 
AppenderatorTester("OPEN_SEGMENTS")) {
+      Assert.assertTrue(tester.appenderator instanceof AppenderatorImpl);
+      AppenderatorImpl appenderator = (AppenderatorImpl) tester.appenderator;
+      Assert.assertTrue(appenderator.isOpenSegments());
+    }
+  }
+
+  @Test
+  public void testClosedSegmentsOfflineAppenderator() throws Exception
+  {
+    try (final AppenderatorTester tester = new 
AppenderatorTester("CLOSED_SEGMENTS")) {
+      Assert.assertTrue(tester.appenderator instanceof AppenderatorImpl);
+      AppenderatorImpl appenderator = (AppenderatorImpl) tester.appenderator;
+      Assert.assertFalse(appenderator.isOpenSegments());
+    }
+  }
+
+  @Test
+  public void testClosedSegmentsSinksOfflineAppenderator() throws Exception
+  {
+    try (final AppenderatorTester tester = new 
AppenderatorTester("CLOSED_SEGMENTS_SINKS")) {
+      Assert.assertTrue(tester.appenderator instanceof BatchAppenderator);
+    }
+  }
+
+  private static class AppenderatorTester implements AutoCloseable
+  {
+    public static final String DATASOURCE = "foo";
+
+    private final AppenderatorConfig tuningConfig;
+    private final Appenderator appenderator;
+    private final ServiceEmitter emitter;
+
+    public AppenderatorTester(final String batchMode)
+    {
+      this(100, 100, null, new SimpleRowIngestionMeters(), false, batchMode);
+    }
+
+    public AppenderatorTester(
+        final int maxRowsInMemory,
+        final long maxSizeInBytes,
+        @Nullable final File basePersistDirectory,
+        final RowIngestionMeters rowIngestionMeters,
+        final boolean skipBytesInMemoryOverheadCheck,
+        String batchMode
+    )
+    {
+      ObjectMapper objectMapper = new DefaultObjectMapper();
+      objectMapper.registerSubtypes(LinearShardSpec.class);
+
+      final Map<String, Object> parserMap = objectMapper.convertValue(
+          new MapInputRowParser(
+              new JSONParseSpec(
+                  new TimestampSpec("ts", "auto", null),
+                  DimensionsSpec.EMPTY,
+                  null,
+                  null,
+                  null
+              )
+          ),
+          Map.class
+      );
+
+      DataSchema schema = new DataSchema(
+          DATASOURCE,
+          null,
+          null,
+          new AggregatorFactory[]{
+              new CountAggregatorFactory("count"),
+              new LongSumAggregatorFactory("met", "met")
+          },
+          new UniformGranularitySpec(Granularities.MINUTE, Granularities.NONE, 
null),
+          null,
+          parserMap,
+          objectMapper
+      );
+
+      tuningConfig = new TestAppenderatorConfig(
+          TuningConfig.DEFAULT_APPENDABLE_INDEX,
+          maxRowsInMemory,
+          maxSizeInBytes == 0L ? getDefaultMaxBytesInMemory() : maxSizeInBytes,
+          skipBytesInMemoryOverheadCheck,
+          IndexSpec.DEFAULT,
+          0,
+          false,
+          0L,
+          OffHeapMemorySegmentWriteOutMediumFactory.instance(),
+          IndexMerger.UNLIMITED_MAX_COLUMNS_TO_MERGE,
+          basePersistDirectory == null ? createNewBasePersistDirectory() : 
basePersistDirectory
+      );
+      SegmentGenerationMetrics metrics = new SegmentGenerationMetrics();
+
+      IndexIO indexIO = new IndexIO(objectMapper, ColumnConfig.DEFAULT);
+      IndexMergerV9 indexMerger = new IndexMergerV9(
+          objectMapper,
+          indexIO,
+          OffHeapMemorySegmentWriteOutMediumFactory.instance()
+      );
+
+      emitter = new ServiceEmitter(
+          "test",
+          "test",
+          new NoopEmitter()
+      );

Review Comment:
   Nit:
   ```suggestion
         emitter = new StubServiceEmitter();
   ```



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/SinglePhaseSubTask.java:
##########
@@ -461,8 +453,6 @@ private DataSegmentsWithSchemas generateAndPushSegments(
         } else {
           throw new ISE("Failed to add a row with timestamp[%s]", 
inputRow.getTimestamp());
         }
-
-        fireDepartmentMetrics.incrementProcessed();

Review Comment:
   Is this `incrementProcessed()` redundant now?



##########
integration-tests-ex/cases/cluster/Common/dependencies.yaml:
##########
@@ -46,28 +46,27 @@ services:
   kafka:
     image: bitnami/kafka:${KAFKA_VERSION}
     container_name: kafka
+    # platform: linux/x86_64
     labels:
       druid-int-test: "true"
     ports:
       - 9092:9092
-      - 9093:9093
+      - 9094:9094

Review Comment:
   why the port change?



##########
indexing-service/src/main/java/org/apache/druid/indexing/common/task/batch/parallel/SinglePhaseSubTask.java:
##########
@@ -461,8 +453,6 @@ private DataSegmentsWithSchemas generateAndPushSegments(
         } else {
           throw new ISE("Failed to add a row with timestamp[%s]", 
inputRow.getTimestamp());
         }
-
-        fireDepartmentMetrics.incrementProcessed();

Review Comment:
   Is this `incrementProcessed()` redundant now?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to