[ 
https://issues.apache.org/jira/browse/GOBBLIN-1868?focusedWorklogId=874725&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-874725
 ]

ASF GitHub Bot logged work on GOBBLIN-1868:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Aug/23 19:52
            Start Date: 04/Aug/23 19:52
    Worklog Time Spent: 10m 
      Work Description: phet commented on code in PR #3731:
URL: https://github.com/apache/gobblin/pull/3731#discussion_r1284729295


##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/utils/SharedFlowMetricsContainer.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.gobblin.service.modules.utils;
+
+import com.codahale.metrics.Meter;
+import com.codahale.metrics.MetricRegistry;
+import com.google.common.base.Optional;
+import com.google.common.collect.Maps;
+import com.typesafe.config.Config;
+import java.util.Map;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import lombok.Data;
+import lombok.Setter;
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.instrumented.Instrumented;
+import org.apache.gobblin.metrics.ContextAwareGauge;
+import org.apache.gobblin.metrics.MetricContext;
+import org.apache.gobblin.metrics.RootMetricContext;
+import org.apache.gobblin.metrics.ServiceMetricNames;
+import org.apache.gobblin.runtime.api.Spec;
+import org.apache.gobblin.service.modules.orchestration.Orchestrator;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * Class to store flow related metrics shared between the {@link Orchestrator} 
and {@link DagManager} so we can easily
+ * track all flow compilations and skipped flows handled between the two in a 
common place.
+ */
+@Singleton
+@Data
+public class SharedFlowMetricsContainer {
+  protected final MetricContext metricContext;
+  private Map<String, FlowCompiledState> flowGauges = Maps.newHashMap();
+  private Optional<Meter> skippedFlowsMeter;
+
+  @Inject
+  public SharedFlowMetricsContainer(Config config) {
+    this.metricContext = 
Instrumented.getMetricContext(ConfigUtils.configToState(config), 
SharedFlowMetricsContainer.class);
+    this.skippedFlowsMeter = 
Optional.of(metricContext.contextAwareMeter(ServiceMetricNames.SKIPPED_FLOWS));
+  }
+
+  /**
+   * Adds a new FlowGauge to the metric context if one does not already exist 
for this flow spec
+   */
+  public void addFlowGauge(Spec spec, Config flowConfig, String flowName, 
String flowGroup) {

Review Comment:
   I find widely-employed, non-semantic types like `String` error-prone, 
because particular instances are readily confused w/ one another and may lead 
to param/arg mis-ordering.  since `flowGroup` is less-specific than `flowName`, 
my habit is to put it first, which appears to be how `MetricRegistry.name` 
wants them as well... and yet they're swapped in this method's params.
   
   let's seek uniform consistency, so a misordering easily jumps out at 
maintainers.  nonetheless, even better, would be to replace the two `String` 
params w/ a single `FlowId`





Issue Time Tracking
-------------------

    Worklog Id:     (was: 874725)
    Time Spent: 40m  (was: 0.5h)

> Refactor Common Utils between Orchestrator & DagManager
> -------------------------------------------------------
>
>                 Key: GOBBLIN-1868
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1868
>             Project: Apache Gobblin
>          Issue Type: Bug
>          Components: gobblin-service
>            Reporter: Urmi Mustafi
>            Assignee: Abhishek Tiwari
>            Priority: Major
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Create a Util class to contain functionality re-used between the DagManager 
> and Orchestrator when launching executions of a flow spec. In the common 
> case, the Orchestrator receives a flow to orchestrate, performs necessary 
> validations, and forwards the execution responsibility to the DagManager. The 
> DagManager's responsibility is to carry out any flow action requests. 
> However, with launch executions now being stored in the DagActionStateStore, 
> on restart or leadership change the DagManager has to perform validations 
> before executing any launch actions the previous leader was unable to 
> complete. Rather than duplicating the code or introducing a circular 
> dependency between the DagManager and Orchestrator, this class is utilized to 
> store the common functionality. It is stateless and requires all stateful 
> pieces to be passed as input from the caller.
> * Note: We expect further refactoring to be done to the DagManager in later 
> stage of multi-active development so we do not attempt *major* reorganization 
> as abstractions may change. 
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to