shangeyao commented on code in PR #4419:
URL: https://github.com/apache/streampark/pull/4419#discussion_r3540608690


##########
streampark-common/src/main/java/org/apache/streampark/common/util/ZooKeeperUtils.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * 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.common.util;
+
+import org.apache.curator.RetryPolicy;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.RetryNTimes;
+import org.apache.zookeeper.CreateMode;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public final class ZooKeeperUtils {
+
+    private static final String CONNECT = "localhost:2181";
+    private static final Map<String, CuratorFramework> CLIENT_MAP = new 
ConcurrentHashMap<>();
+
+    private ZooKeeperUtils() {}
+
+    public static CuratorFramework getClient() {
+        return getClient(CONNECT);
+    }
+
+    public static CuratorFramework getClient(String url) {
+        CuratorFramework existing = CLIENT_MAP.get(url);
+        if (existing != null) {
+            return existing;
+        }
+        try {
+            RetryPolicy retryPolicy = new RetryNTimes(5, 2000);
+            CuratorFramework client =
+                    CuratorFrameworkFactory.builder()
+                            .connectString(url)
+                            .retryPolicy(retryPolicy)
+                            .connectionTimeoutMs(2000)
+                            .build();
+            client.start();
+            CLIENT_MAP.put(url, client);
+            return client;
+        } catch (Exception e) {
+            throw new IllegalStateException(e.getMessage(), e);
+        }
+    }
+
+    public static void close(String url) {
+        CuratorFramework client = getClient(url);
+        if (client != null) {
+            client.close();
+            CLIENT_MAP.remove(url);
+        }
+    }
+
+    public static List<String> listChildren(String path) throws Exception {
+        return listChildren(path, CONNECT);
+    }
+
+    public static List<String> listChildren(String path, String url) throws 
Exception {
+        CuratorFramework client = getClient(url);
+        if (client.checkExists().forPath(path) == null) {
+            return new ArrayList<>();
+        }
+        return client.getChildren().forPath(path);
+    }
+
+    public static boolean create(String path) throws Exception {
+        return create(path, null, CONNECT, false);
+    }
+
+    public static boolean create(String path, String value, String url, 
boolean persistent)
+            throws Exception {
+        try {
+            CuratorFramework client = getClient(url);
+            if (client.checkExists().forPath(path) == null) {
+                byte[] data =
+                        value == null || value.isEmpty()
+                                ? new byte[0]
+                                : value.getBytes(StandardCharsets.UTF_8);
+                CreateMode mode = persistent ? CreateMode.PERSISTENT : 
CreateMode.EPHEMERAL;
+                String opResult =
+                        
client.create().creatingParentsIfNeeded().withMode(mode).forPath(path, data);
+                return path.equals(opResult);
+            }
+            return false;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    public static boolean update(String path, String value, String url, 
boolean persistent)
+            throws Exception {
+        try {
+            CuratorFramework client = getClient(url);
+            if (client.checkExists().forPath(path) == null) {
+                CreateMode mode = persistent ? CreateMode.PERSISTENT : 
CreateMode.EPHEMERAL;
+                String opResult =
+                        client.create()
+                                .creatingParentsIfNeeded()
+                                .withMode(mode)
+                                .forPath(path, 
value.getBytes(StandardCharsets.UTF_8));
+                return path.equals(opResult);
+            }
+            client.setData().forPath(path, 
value.getBytes(StandardCharsets.UTF_8));
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    public static void delete(String path) throws Exception {
+        delete(path, CONNECT);
+    }
+
+    public static void delete(String path, String url) throws Exception {
+        try {
+            CuratorFramework client = getClient(url);
+            if (client.checkExists().forPath(path) != null) {
+                client.delete().deletingChildrenIfNeeded().forPath(path);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();

Review Comment:
   Fixed in `752fa8a68`: replaced `printStackTrace()` with `LOG.warn(...)`.



##########
streampark-common/src/main/java/org/apache/streampark/common/util/ZooKeeperUtils.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * 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.common.util;
+
+import org.apache.curator.RetryPolicy;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.RetryNTimes;
+import org.apache.zookeeper.CreateMode;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public final class ZooKeeperUtils {
+
+    private static final String CONNECT = "localhost:2181";
+    private static final Map<String, CuratorFramework> CLIENT_MAP = new 
ConcurrentHashMap<>();
+
+    private ZooKeeperUtils() {}
+
+    public static CuratorFramework getClient() {
+        return getClient(CONNECT);
+    }
+
+    public static CuratorFramework getClient(String url) {
+        CuratorFramework existing = CLIENT_MAP.get(url);
+        if (existing != null) {
+            return existing;
+        }
+        try {
+            RetryPolicy retryPolicy = new RetryNTimes(5, 2000);
+            CuratorFramework client =
+                    CuratorFrameworkFactory.builder()
+                            .connectString(url)
+                            .retryPolicy(retryPolicy)
+                            .connectionTimeoutMs(2000)
+                            .build();
+            client.start();
+            CLIENT_MAP.put(url, client);
+            return client;
+        } catch (Exception e) {
+            throw new IllegalStateException(e.getMessage(), e);
+        }
+    }
+
+    public static void close(String url) {
+        CuratorFramework client = getClient(url);
+        if (client != null) {
+            client.close();
+            CLIENT_MAP.remove(url);
+        }
+    }
+
+    public static List<String> listChildren(String path) throws Exception {
+        return listChildren(path, CONNECT);
+    }
+
+    public static List<String> listChildren(String path, String url) throws 
Exception {
+        CuratorFramework client = getClient(url);
+        if (client.checkExists().forPath(path) == null) {
+            return new ArrayList<>();
+        }
+        return client.getChildren().forPath(path);
+    }
+
+    public static boolean create(String path) throws Exception {
+        return create(path, null, CONNECT, false);
+    }
+
+    public static boolean create(String path, String value, String url, 
boolean persistent)
+            throws Exception {
+        try {
+            CuratorFramework client = getClient(url);
+            if (client.checkExists().forPath(path) == null) {
+                byte[] data =
+                        value == null || value.isEmpty()
+                                ? new byte[0]
+                                : value.getBytes(StandardCharsets.UTF_8);
+                CreateMode mode = persistent ? CreateMode.PERSISTENT : 
CreateMode.EPHEMERAL;
+                String opResult =
+                        
client.create().creatingParentsIfNeeded().withMode(mode).forPath(path, data);
+                return path.equals(opResult);
+            }
+            return false;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    public static boolean update(String path, String value, String url, 
boolean persistent)
+            throws Exception {
+        try {
+            CuratorFramework client = getClient(url);
+            if (client.checkExists().forPath(path) == null) {
+                CreateMode mode = persistent ? CreateMode.PERSISTENT : 
CreateMode.EPHEMERAL;
+                String opResult =
+                        client.create()
+                                .creatingParentsIfNeeded()
+                                .withMode(mode)
+                                .forPath(path, 
value.getBytes(StandardCharsets.UTF_8));
+                return path.equals(opResult);
+            }
+            client.setData().forPath(path, 
value.getBytes(StandardCharsets.UTF_8));
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();

Review Comment:
   Fixed in `752fa8a68`: replaced `printStackTrace()` with `LOG.warn(...)`.



##########
streampark-common/src/main/java/org/apache/streampark/common/util/ZooKeeperUtils.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * 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.common.util;
+
+import org.apache.curator.RetryPolicy;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.RetryNTimes;
+import org.apache.zookeeper.CreateMode;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public final class ZooKeeperUtils {
+
+    private static final String CONNECT = "localhost:2181";
+    private static final Map<String, CuratorFramework> CLIENT_MAP = new 
ConcurrentHashMap<>();
+
+    private ZooKeeperUtils() {}
+
+    public static CuratorFramework getClient() {
+        return getClient(CONNECT);
+    }
+
+    public static CuratorFramework getClient(String url) {
+        CuratorFramework existing = CLIENT_MAP.get(url);
+        if (existing != null) {
+            return existing;
+        }
+        try {
+            RetryPolicy retryPolicy = new RetryNTimes(5, 2000);
+            CuratorFramework client =
+                    CuratorFrameworkFactory.builder()
+                            .connectString(url)
+                            .retryPolicy(retryPolicy)
+                            .connectionTimeoutMs(2000)
+                            .build();
+            client.start();
+            CLIENT_MAP.put(url, client);
+            return client;
+        } catch (Exception e) {
+            throw new IllegalStateException(e.getMessage(), e);
+        }
+    }
+
+    public static void close(String url) {
+        CuratorFramework client = getClient(url);
+        if (client != null) {
+            client.close();
+            CLIENT_MAP.remove(url);
+        }
+    }
+
+    public static List<String> listChildren(String path) throws Exception {
+        return listChildren(path, CONNECT);
+    }
+
+    public static List<String> listChildren(String path, String url) throws 
Exception {
+        CuratorFramework client = getClient(url);
+        if (client.checkExists().forPath(path) == null) {
+            return new ArrayList<>();
+        }
+        return client.getChildren().forPath(path);
+    }
+
+    public static boolean create(String path) throws Exception {
+        return create(path, null, CONNECT, false);
+    }
+
+    public static boolean create(String path, String value, String url, 
boolean persistent)
+            throws Exception {
+        try {
+            CuratorFramework client = getClient(url);
+            if (client.checkExists().forPath(path) == null) {
+                byte[] data =
+                        value == null || value.isEmpty()
+                                ? new byte[0]
+                                : value.getBytes(StandardCharsets.UTF_8);
+                CreateMode mode = persistent ? CreateMode.PERSISTENT : 
CreateMode.EPHEMERAL;
+                String opResult =
+                        
client.create().creatingParentsIfNeeded().withMode(mode).forPath(path, data);
+                return path.equals(opResult);
+            }
+            return false;
+        } catch (Exception e) {
+            e.printStackTrace();

Review Comment:
   Fixed in `752fa8a68`: replaced `printStackTrace()` with `LOG.warn(...)`.



##########
streampark-common/src/main/java/org/apache/streampark/common/util/YarnUtils.java:
##########
@@ -0,0 +1,299 @@
+/*
+ * 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.common.util;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.CommonConfigurationKeys;
+import org.apache.hadoop.net.NetUtils;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationReport;
+import org.apache.hadoop.yarn.api.records.YarnApplicationState;
+import org.apache.hadoop.yarn.conf.HAUtil;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.util.RMHAUtils;
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.core5.util.Timeout;
+import org.apache.streampark.common.conf.CommonConfig;
+import org.apache.streampark.common.conf.InternalConfigHolder;
+import org.apache.streampark.common.constants.Constants;
+import org.apache.streampark.shaded.org.slf4j.Logger;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.security.PrivilegedExceptionAction;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.TimeUnit;
+
+/** YARN cluster utilities. */
+public final class YarnUtils {
+
+    private static final Logger LOG =
+            
StreamParkLoggerFactory.loggerFactory().getLogger(YarnUtils.class.getName());
+
+    private static String rmHttpURL;
+
+    public static final String PROXY_YARN_URL =
+            InternalConfigHolder.get(CommonConfig.STREAMPARK_PROXY_YARN_URL());
+
+    public static final boolean HAS_YARN_HTTP_KERBEROS_AUTH =
+            "kerberos"
+                    
.equalsIgnoreCase(InternalConfigHolder.get(CommonConfig.STREAMPARK_YARN_AUTH()));
+
+    public static final boolean HAS_YARN_HTTP_SIMPLE_AUTH =
+            
"simple".equalsIgnoreCase(InternalConfigHolder.get(CommonConfig.STREAMPARK_YARN_AUTH()));
+
+    private YarnUtils() {}
+
+    public static boolean hasYarnHttpKerberosAuth() {
+        return HAS_YARN_HTTP_KERBEROS_AUTH;
+    }
+
+    public static boolean hasYarnHttpSimpleAuth() {
+        return HAS_YARN_HTTP_SIMPLE_AUTH;
+    }
+
+    public static List<ApplicationId> getAppId(String appName) {
+        EnumSet<YarnApplicationState> appStates =
+                EnumSet.of(
+                        YarnApplicationState.RUNNING,
+                        YarnApplicationState.ACCEPTED,
+                        YarnApplicationState.SUBMITTED);
+        try {
+            List<ApplicationId> appIds = new ArrayList<>();
+            for (ApplicationReport report : 
HadoopUtils.yarnClient().getApplications(appStates)) {
+                if (appName.equals(report.getName())) {
+                    appIds.add(report.getApplicationId());
+                }
+            }
+            return appIds;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return new ArrayList<>();
+        }
+    }
+
+    public static YarnApplicationState getState(String appId) {
+        ApplicationId applicationId = ApplicationId.fromString(appId);
+        try {
+            ApplicationReport applicationReport =
+                    
HadoopUtils.yarnClient().getApplicationReport(applicationId);
+            return applicationReport.getYarnApplicationState();
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    public static boolean isContains(String appName) {
+        try {
+            List<ApplicationReport> runningApps =
+                    
HadoopUtils.yarnClient().getApplications(EnumSet.of(YarnApplicationState.RUNNING));
+            if (runningApps != null) {
+                for (ApplicationReport app : runningApps) {
+                    if (appName.equals(app.getName())) {
+                        return true;
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();

Review Comment:
   Fixed in `752fa8a68`: replaced `printStackTrace()` with `LOG.warn(...)`.



##########
streampark-common/src/main/java/org/apache/streampark/common/util/YarnUtils.java:
##########
@@ -0,0 +1,299 @@
+/*
+ * 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.common.util;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.CommonConfigurationKeys;
+import org.apache.hadoop.net.NetUtils;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationReport;
+import org.apache.hadoop.yarn.api.records.YarnApplicationState;
+import org.apache.hadoop.yarn.conf.HAUtil;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.util.RMHAUtils;
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.core5.util.Timeout;
+import org.apache.streampark.common.conf.CommonConfig;
+import org.apache.streampark.common.conf.InternalConfigHolder;
+import org.apache.streampark.common.constants.Constants;
+import org.apache.streampark.shaded.org.slf4j.Logger;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.security.PrivilegedExceptionAction;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.TimeUnit;
+
+/** YARN cluster utilities. */
+public final class YarnUtils {
+
+    private static final Logger LOG =
+            
StreamParkLoggerFactory.loggerFactory().getLogger(YarnUtils.class.getName());
+
+    private static String rmHttpURL;
+
+    public static final String PROXY_YARN_URL =
+            InternalConfigHolder.get(CommonConfig.STREAMPARK_PROXY_YARN_URL());
+
+    public static final boolean HAS_YARN_HTTP_KERBEROS_AUTH =
+            "kerberos"
+                    
.equalsIgnoreCase(InternalConfigHolder.get(CommonConfig.STREAMPARK_YARN_AUTH()));
+
+    public static final boolean HAS_YARN_HTTP_SIMPLE_AUTH =
+            
"simple".equalsIgnoreCase(InternalConfigHolder.get(CommonConfig.STREAMPARK_YARN_AUTH()));
+
+    private YarnUtils() {}
+
+    public static boolean hasYarnHttpKerberosAuth() {
+        return HAS_YARN_HTTP_KERBEROS_AUTH;
+    }
+
+    public static boolean hasYarnHttpSimpleAuth() {
+        return HAS_YARN_HTTP_SIMPLE_AUTH;
+    }
+
+    public static List<ApplicationId> getAppId(String appName) {
+        EnumSet<YarnApplicationState> appStates =
+                EnumSet.of(
+                        YarnApplicationState.RUNNING,
+                        YarnApplicationState.ACCEPTED,
+                        YarnApplicationState.SUBMITTED);
+        try {
+            List<ApplicationId> appIds = new ArrayList<>();
+            for (ApplicationReport report : 
HadoopUtils.yarnClient().getApplications(appStates)) {
+                if (appName.equals(report.getName())) {
+                    appIds.add(report.getApplicationId());
+                }
+            }
+            return appIds;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return new ArrayList<>();
+        }
+    }
+
+    public static YarnApplicationState getState(String appId) {
+        ApplicationId applicationId = ApplicationId.fromString(appId);
+        try {
+            ApplicationReport applicationReport =
+                    
HadoopUtils.yarnClient().getApplicationReport(applicationId);
+            return applicationReport.getYarnApplicationState();
+        } catch (Exception e) {
+            e.printStackTrace();

Review Comment:
   Fixed in `752fa8a68`: replaced `printStackTrace()` with `LOG.warn(...)`.



##########
streampark-common/src/main/java/org/apache/streampark/common/util/YarnUtils.java:
##########
@@ -0,0 +1,299 @@
+/*
+ * 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.common.util;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.CommonConfigurationKeys;
+import org.apache.hadoop.net.NetUtils;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationReport;
+import org.apache.hadoop.yarn.api.records.YarnApplicationState;
+import org.apache.hadoop.yarn.conf.HAUtil;
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import org.apache.hadoop.yarn.util.RMHAUtils;
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.core5.util.Timeout;
+import org.apache.streampark.common.conf.CommonConfig;
+import org.apache.streampark.common.conf.InternalConfigHolder;
+import org.apache.streampark.common.constants.Constants;
+import org.apache.streampark.shaded.org.slf4j.Logger;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.security.PrivilegedExceptionAction;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.TimeUnit;
+
+/** YARN cluster utilities. */
+public final class YarnUtils {
+
+    private static final Logger LOG =
+            
StreamParkLoggerFactory.loggerFactory().getLogger(YarnUtils.class.getName());
+
+    private static String rmHttpURL;
+
+    public static final String PROXY_YARN_URL =
+            InternalConfigHolder.get(CommonConfig.STREAMPARK_PROXY_YARN_URL());
+
+    public static final boolean HAS_YARN_HTTP_KERBEROS_AUTH =
+            "kerberos"
+                    
.equalsIgnoreCase(InternalConfigHolder.get(CommonConfig.STREAMPARK_YARN_AUTH()));
+
+    public static final boolean HAS_YARN_HTTP_SIMPLE_AUTH =
+            
"simple".equalsIgnoreCase(InternalConfigHolder.get(CommonConfig.STREAMPARK_YARN_AUTH()));
+
+    private YarnUtils() {}
+
+    public static boolean hasYarnHttpKerberosAuth() {
+        return HAS_YARN_HTTP_KERBEROS_AUTH;
+    }
+
+    public static boolean hasYarnHttpSimpleAuth() {
+        return HAS_YARN_HTTP_SIMPLE_AUTH;
+    }
+
+    public static List<ApplicationId> getAppId(String appName) {
+        EnumSet<YarnApplicationState> appStates =
+                EnumSet.of(
+                        YarnApplicationState.RUNNING,
+                        YarnApplicationState.ACCEPTED,
+                        YarnApplicationState.SUBMITTED);
+        try {
+            List<ApplicationId> appIds = new ArrayList<>();
+            for (ApplicationReport report : 
HadoopUtils.yarnClient().getApplications(appStates)) {
+                if (appName.equals(report.getName())) {
+                    appIds.add(report.getApplicationId());
+                }
+            }
+            return appIds;
+        } catch (Exception e) {
+            e.printStackTrace();

Review Comment:
   Fixed in `752fa8a68`: replaced `printStackTrace()` with `LOG.warn(...)`.



##########
streampark-common/src/main/java/org/apache/streampark/common/util/StreamParkLoggerFactory.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * 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.common.util;
+
+import org.apache.streampark.shaded.ch.qos.logback.classic.LoggerContext;
+import 
org.apache.streampark.shaded.ch.qos.logback.classic.joran.JoranConfigurator;
+import 
org.apache.streampark.shaded.ch.qos.logback.classic.util.ContextInitializer;
+import 
org.apache.streampark.shaded.ch.qos.logback.classic.util.ContextSelectorStaticBinder;
+import org.apache.streampark.shaded.ch.qos.logback.core.CoreConstants;
+import org.apache.streampark.shaded.ch.qos.logback.core.LogbackException;
+import org.apache.streampark.shaded.ch.qos.logback.core.status.StatusUtil;
+import org.apache.streampark.shaded.ch.qos.logback.core.util.StatusPrinter;
+import org.apache.streampark.shaded.org.slf4j.ILoggerFactory;
+import org.apache.streampark.shaded.org.slf4j.spi.LoggerFactoryBinder;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+
+/** Shaded logback SLF4J logger factory binder. */
+public final class StreamParkLoggerFactory implements LoggerFactoryBinder {
+
+    private static final StreamParkLoggerFactory INSTANCE = new 
StreamParkLoggerFactory();
+
+    private static final ContextSelectorStaticBinder CONTEXT_SELECTOR_BINDER;
+
+    static {
+        LoggerContext defaultLoggerContext = new LoggerContext();
+        try {
+            new ShadedContextInitializer(defaultLoggerContext).autoConfig();
+        } catch (Exception e) {
+            System.err.println("Failed to auto configure default logger 
context");
+            System.err.println("Reported exception:");
+            e.printStackTrace();

Review Comment:
   Fixed in `752fa8a68`: replaced `printStackTrace()` with `LOG.warn(...)`.



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