1996fanrui commented on code in PR #1910:
URL: 
https://github.com/apache/incubator-streampark/pull/1910#discussion_r1007076154


##########
streampark-flink/streampark-flink-kubernetes/src/main/java/org/apache/streampark/archives/RefreshLocation.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.streampark.archives;
+
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+
+/**
+ * Container for the {@link Path} and {@link FileSystem} of a refresh 
directory.
+ */
+class RefreshLocation {

Review Comment:
   This class can be deleted.



##########
streampark-flink/streampark-flink-kubernetes/src/main/java/org/apache/streampark/archives/FetchArchives.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.streampark.archives;
+
+import org.apache.flink.core.fs.FileStatus;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.runtime.history.FsJobArchivist;
+import org.apache.flink.runtime.webmonitor.history.ArchivedJson;
+import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Objects;
+
+public class FetchArchives {
+
+    public static String fetchArchives(String jobId, String archivePath) {
+        try {
+            Objects.requireNonNull(jobId, "JobId cannot be empty.");
+            Objects.requireNonNull(archivePath, "archivePath cannot be 
empty.");
+            Path refreshPath = new Path(archivePath);
+            FileSystem refreshFS = refreshPath.getFileSystem();
+            RefreshLocation refreshLocation = new RefreshLocation(refreshPath, 
refreshFS);
+            Path refreshDir = refreshLocation.getPath();
+            // contents of /:refreshDir
+            FileStatus[] jobArchives;
+            jobArchives = listArchives(refreshLocation.getFs(), refreshDir);
+            Path jobArchivePath = Arrays.stream(jobArchives)
+                .map(FileStatus::getPath)
+                .filter(path -> 
path.getName().equals(jobId)).findFirst().orElse(null);

Review Comment:
   You list all jobs from `archivePath`, then filter the jobId from all jobs.
   
   Why don't you list `archivePath/jobId` directly?



##########
streampark-flink/streampark-flink-kubernetes/src/main/scala/org/apache/streampark/flink/kubernetes/FlinkTrackController.scala:
##########
@@ -236,3 +240,19 @@ object MetricCache {
   def build(): MetricCache = new MetricCache()
 
 }
+
+class ArchivesCache {
+  def put(k: String, v: String): Unit = cache.put(k, v)
+
+  def get(k: String): String = cache.getIfPresent(k)
+
+  def asMap(): Map[String, String] = cache.asMap().toMap
+
+  def cleanUp(): Unit = cache.cleanUp()
+
+  val cache: Cache[String, String] = Caffeine.newBuilder.build()

Review Comment:
   I mean the cache size or expire policy are not set, why don't you use Map 
directly?



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