m-trieu commented on code in PR #30764:
URL: https://github.com/apache/beam/pull/30764#discussion_r1582573447


##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/harness/ApplianceWorkerHarness.java:
##########
@@ -0,0 +1,572 @@
+/*
+ * 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.beam.runners.dataflow.worker.streaming.harness;
+
+import com.google.api.services.dataflow.model.MapTask;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import javax.annotation.concurrent.ThreadSafe;
+import org.apache.beam.runners.dataflow.options.DataflowWorkerHarnessOptions;
+import org.apache.beam.runners.dataflow.worker.DataflowExecutionStateSampler;
+import org.apache.beam.runners.dataflow.worker.DataflowMapTaskExecutorFactory;
+import org.apache.beam.runners.dataflow.worker.DataflowWorkUnitClient;
+import org.apache.beam.runners.dataflow.worker.HotKeyLogger;
+import org.apache.beam.runners.dataflow.worker.IntrinsicMapTaskExecutorFactory;
+import 
org.apache.beam.runners.dataflow.worker.MetricTrackingWindmillServerStub;
+import org.apache.beam.runners.dataflow.worker.ReaderCache;
+import org.apache.beam.runners.dataflow.worker.WindmillComputationKey;
+import org.apache.beam.runners.dataflow.worker.WindmillTimeUtils;
+import org.apache.beam.runners.dataflow.worker.WorkUnitClient;
+import org.apache.beam.runners.dataflow.worker.streaming.ComputationState;
+import org.apache.beam.runners.dataflow.worker.streaming.ComputationStateCache;
+import org.apache.beam.runners.dataflow.worker.streaming.StageInfo;
+import 
org.apache.beam.runners.dataflow.worker.streaming.StreamingApplianceComputationStateCacheLoader;
+import 
org.apache.beam.runners.dataflow.worker.streaming.config.StreamingApplianceConfigLoader;
+import 
org.apache.beam.runners.dataflow.worker.streaming.processing.ExecutionStateFactory;
+import 
org.apache.beam.runners.dataflow.worker.streaming.processing.StreamingCommitFinalizer;
+import 
org.apache.beam.runners.dataflow.worker.streaming.processing.StreamingWorkScheduler;
+import 
org.apache.beam.runners.dataflow.worker.streaming.sideinput.SideInputStateFetcher;
+import org.apache.beam.runners.dataflow.worker.util.BoundedQueueExecutor;
+import org.apache.beam.runners.dataflow.worker.util.MemoryMonitor;
+import org.apache.beam.runners.dataflow.worker.windmill.Windmill;
+import 
org.apache.beam.runners.dataflow.worker.windmill.Windmill.ComputationWorkItems;
+import 
org.apache.beam.runners.dataflow.worker.windmill.Windmill.GetWorkResponse;
+import org.apache.beam.runners.dataflow.worker.windmill.WindmillServerStub;
+import 
org.apache.beam.runners.dataflow.worker.windmill.appliance.JniWindmillApplianceServer;
+import 
org.apache.beam.runners.dataflow.worker.windmill.client.commits.CompleteCommit;
+import 
org.apache.beam.runners.dataflow.worker.windmill.client.commits.StreamingApplianceWorkCommitter;
+import 
org.apache.beam.runners.dataflow.worker.windmill.client.commits.WorkCommitter;
+import 
org.apache.beam.runners.dataflow.worker.windmill.state.WindmillStateCache;
+import 
org.apache.beam.runners.dataflow.worker.windmill.work.WorkProcessingContext;
+import 
org.apache.beam.runners.dataflow.worker.windmill.work.processing.failures.FailureTracker;
+import 
org.apache.beam.runners.dataflow.worker.windmill.work.processing.failures.StreamingApplianceFailureTracker;
+import 
org.apache.beam.runners.dataflow.worker.windmill.work.processing.failures.WorkFailureProcessor;
+import 
org.apache.beam.runners.dataflow.worker.windmill.work.refresh.ActiveWorkRefresher;
+import 
org.apache.beam.runners.dataflow.worker.windmill.work.refresh.DispatchedActiveWorkRefresher;
+import org.apache.beam.sdk.annotations.Internal;
+import org.apache.beam.sdk.io.FileSystems;
+import 
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.annotations.VisibleForTesting;
+import 
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions;
+import 
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.cache.CacheLoader;
+import 
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableList;
+import 
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.util.concurrent.ThreadFactoryBuilder;
+import 
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.util.concurrent.Uninterruptibles;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Streaming Appliance worker harness implementation. */
+@Internal
+@ThreadSafe
+public final class ApplianceWorkerHarness implements StreamingWorkerHarness {
+  private static final Logger LOG = 
LoggerFactory.getLogger(ApplianceWorkerHarness.class);
+  private static final String MEMORY_MONITOR_EXECUTOR = "MemoryMonitor";
+  private static final String GET_WORK_EXECUTOR = "GetWorkDispatcher";
+  private static final String REFRESH_WORK_EXECUTOR = "RefreshWork";
+
+  private final DataflowWorkerHarnessOptions options;
+  private final long clientId;
+  private final WindmillServerStub windmillServer;
+  private final MetricTrackingWindmillServerStub getDataClient;
+  private final MemoryMonitor memoryMonitor;
+  private final ComputationStateCache computationCache;
+  private final StreamingWorkScheduler streamingWorkScheduler;
+  private final WorkCommitter workCommitter;
+  private final StreamingWorkerStatusReporter workerStatusReporter;
+  private final StreamingStatusPages statusPages;
+  private final DataflowExecutionStateSampler sampler;
+  private final ActiveWorkRefresher activeWorkRefresher;
+  private final BoundedQueueExecutor workExecutor;
+  private final ExecutorService memoryMonitoryExecutor;
+  private final ExecutorService getWorkExecutor;
+  private final AtomicBoolean isRunning;
+
+  private ApplianceWorkerHarness(
+      DataflowWorkerHarnessOptions options,
+      long clientId,
+      WindmillServerStub windmillServer,
+      MetricTrackingWindmillServerStub getDataClient,
+      MemoryMonitor memoryMonitor,
+      ComputationStateCache computationCache,
+      StreamingWorkScheduler streamingWorkScheduler,
+      WorkCommitter workCommitter,
+      StreamingWorkerStatusReporter workerStatusReporter,
+      StreamingStatusPages statusPages,
+      DataflowExecutionStateSampler sampler,
+      ActiveWorkRefresher activeWorkRefresher,
+      ExecutorService memoryMonitoryExecutor,
+      ExecutorService getWorkExecutor,
+      AtomicBoolean isRunning,
+      BoundedQueueExecutor workExecutor) {
+    this.options = options;
+    this.clientId = clientId;
+    this.windmillServer = windmillServer;
+    this.getDataClient = getDataClient;
+    this.memoryMonitor = memoryMonitor;
+    this.computationCache = computationCache;
+    this.streamingWorkScheduler = streamingWorkScheduler;
+    this.workCommitter = workCommitter;
+    this.workerStatusReporter = workerStatusReporter;
+    this.statusPages = statusPages;
+    this.sampler = sampler;
+    this.activeWorkRefresher = activeWorkRefresher;
+    this.memoryMonitoryExecutor = memoryMonitoryExecutor;
+    this.getWorkExecutor = getWorkExecutor;
+    this.isRunning = isRunning;
+    this.workExecutor = workExecutor;
+    // Register standard file systems.
+    FileSystems.setDefaultPipelineOptions(options);
+  }
+
+  public static ApplianceWorkerHarness 
fromOptions(DataflowWorkerHarnessOptions options) {

Review Comment:
   sgtm!



-- 
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: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to