felix-thinkingdata commented on a change in pull request #3264:
URL: 
https://github.com/apache/incubator-dolphinscheduler/pull/3264#discussion_r461321654



##########
File path: pom.xml
##########
@@ -807,9 +808,9 @@
                         
<!--<include>**/server/master/register/MasterRegistryTest.java</include>-->
                         
<include>**/server/master/AlertManagerTest.java</include>
                         
<include>**/server/master/MasterCommandTest.java</include>
-                        
<include>**/server/master/DependentTaskTest.java</include>
+                        
<!--<include>**/server/master/DependentTaskTest.java</include>-->

Review comment:
       > I have fixed the github action oom, please revert these changes.
   
   Ok, let me modify it

##########
File path: 
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HttpUtils.java
##########
@@ -33,66 +33,86 @@
  * http utils
  */
 public class HttpUtils {
-       
-       
-       public static final Logger logger = 
LoggerFactory.getLogger(HttpUtils.class);
 
-       /**
-        * get http request content
-        * @param url url
-        * @return http get request response content
-        */
-       public static String get(String url){
-               CloseableHttpClient httpclient = HttpClients.createDefault();
+    public static final Logger logger = 
LoggerFactory.getLogger(HttpUtils.class);
 
-               HttpGet httpget = new HttpGet(url);
-               /** set timeout、request time、socket timeout */
-               RequestConfig requestConfig = 
RequestConfig.custom().setConnectTimeout(Constants.HTTP_CONNECT_TIMEOUT)
-                               
.setConnectionRequestTimeout(Constants.HTTP_CONNECTION_REQUEST_TIMEOUT)
-                               .setSocketTimeout(Constants.SOCKET_TIMEOUT)
-                               .setRedirectsEnabled(true)
-                               .build();
-               httpget.setConfig(requestConfig);
-               String responseContent = null;
-               CloseableHttpResponse response = null;
+    /**
+     * get http request content
+     *
+     * @param url url
+     * @return http get request response content
+     */
+    public static String get(String url) {
+       boolean kerberState = 
PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE,
 false);

Review comment:
       It has been modified.

##########
File path: 
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/KerberosHttpClient.java
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.dolphinscheduler.common.utils;
+
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.http.auth.AuthSchemeProvider;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.Credentials;
+import org.apache.http.client.config.AuthSchemes;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.config.Lookup;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.impl.auth.SPNegoSchemeFactory;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.security.auth.Subject;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * kerberos http client
+ */
+public class KerberosHttpClient {
+
+    public static final Logger logger = 
LoggerFactory.getLogger(KerberosHttpClient.class);
+
+    private String principal;
+    private String keyTabLocation;
+
+    public KerberosHttpClient(String principal, String keyTabLocation) {
+       super();
+       this.principal = principal;
+       this.keyTabLocation = keyTabLocation;
+    }
+
+    public KerberosHttpClient(String principal, String keyTabLocation, boolean 
isDebug) {
+       this(principal, keyTabLocation);
+       if (isDebug) {
+           System.setProperty("sun.security.spnego.debug", "true");
+           System.setProperty("sun.security.krb5.debug", "true");
+       }
+    }
+
+    public KerberosHttpClient(String principal, String keyTabLocation, String 
krb5Location, boolean isDebug) {
+       this(principal, keyTabLocation, isDebug);
+       System.setProperty("java.security.krb5.conf", krb5Location);
+    }

Review comment:
       Can I continue to optimize my patch
   
   > Hi,
   > Good job,
   > I create an improvement issue #3332 about HttpClient and 
KerberosHttpClient can further optimize singleton mode.
   
   Continue optimizing in my Patch?




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to