doleyzi commented on a change in pull request #2036:
URL: https://github.com/apache/incubator-inlong/pull/2036#discussion_r772283112



##########
File path: 
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/SourceContext.java
##########
@@ -0,0 +1,85 @@
+/**
+ * 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.inlong.sort.standalone.source;
+
+import org.apache.flume.Context;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * Base source context <b>WITHOUT</b> metric reporter.
+ * The derived classes of SourceContext may implement {@link 
org.apache.inlong.commons.config.metrics.MetricItem} and
+ * realize methods to report customized metrics.
+ */
+public class SourceContext {
+
+    /** The reload interval of source.*/
+    private static final String KEY_RELOAD_INTERVAL = "reloadInterval";
+
+    /** The configured source context.*/
+    private final Context sourceContext;
+
+    /** Name of source. Usually the class name of source.*/
+    private final String sourceName;
+
+    /** Cluster Id of source.*/
+    @NotNull
+    private final String clusterId;
+
+    /**
+     * Constructor of {@link SourceContext}.
+     *
+     * @param sourceName Name of source. Usually the class name of source.
+     * @param context The configured source context.
+     */
+    public SourceContext(
+            @NotBlank(message = "sourceName should not be empty or null") 
final String sourceName,
+            @NotNull(message = "context should not be null") final Context 
context) {
+
+        this.sourceName = sourceName;
+        this.sourceContext = context;
+        this.clusterId = 
context.getString(CommonPropertiesHolder.KEY_CLUSTER_ID);
+    }
+
+    /**
+     * Obtain the reload interval of source.
+     * @return Reload interval of source.
+     */
+    public final long getReloadInterval() {
+        return sourceContext.getLong(SourceContext.KEY_RELOAD_INTERVAL, 
60000L);

Review comment:
       magic number  60000L

##########
File path: inlong-sort-standalone/sort-standalone-source/pom.xml
##########
@@ -42,5 +42,39 @@
             <artifactId>sort-standalone-common</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.inlong</groupId>
+            <artifactId>sort-sdk</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>jakarta.validation</groupId>
+            <artifactId>jakarta.validation-api</artifactId>
+            <version>2.0.2</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <artifactId>powermock-module-junit4</artifactId>
+            <groupId>org.powermock</groupId>
+            <scope>test</scope>
+            <version>2.0.2</version>

Review comment:
       ditto

##########
File path: inlong-sort-standalone/sort-standalone-source/pom.xml
##########
@@ -42,5 +42,39 @@
             <artifactId>sort-standalone-common</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.inlong</groupId>
+            <artifactId>sort-sdk</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>jakarta.validation</groupId>
+            <artifactId>jakarta.validation-api</artifactId>
+            <version>2.0.2</version>

Review comment:
       abstract version to properties




-- 
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]


Reply via email to