Loading dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java +11 −15 Original line number Diff line number Diff line Loading @@ -32,7 +32,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; import java.nio.file.Files; import java.security.PrivilegedExceptionAction; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; Loading @@ -46,16 +48,14 @@ public class HadoopUtils implements Closeable { private static final Logger logger = LoggerFactory.getLogger(HadoopUtils.class); private static String hdfsUser = PropertyUtils.getString(Constants.HDFS_ROOT_USER); private static volatile HadoopUtils instance = new HadoopUtils(); private static volatile Configuration configuration; private static HadoopUtils instance = new HadoopUtils(); private static Configuration configuration; private static FileSystem fs; private String hdfsUser; private HadoopUtils(){ if(StringUtils.isEmpty(hdfsUser)){ hdfsUser = PropertyUtils.getString(Constants.HDFS_ROOT_USER); } init(); initHdfsPath(); } Loading Loading @@ -129,7 +129,6 @@ public class HadoopUtils implements Closeable { if (fs == null) { if(StringUtils.isNotEmpty(hdfsUser)){ //UserGroupInformation ugi = UserGroupInformation.createProxyUser(hdfsUser,UserGroupInformation.getLoginUser()); UserGroupInformation ugi = UserGroupInformation.createRemoteUser(hdfsUser); ugi.doAs(new PrivilegedExceptionAction<Boolean>() { @Override Loading Loading @@ -196,7 +195,7 @@ public class HadoopUtils implements Closeable { if(StringUtils.isBlank(hdfsFilePath)){ logger.error("hdfs file path:{} is blank",hdfsFilePath); return null; return new byte[0]; } FSDataInputStream fsDataInputStream = fs.open(new Path(hdfsFilePath)); Loading @@ -218,7 +217,7 @@ public class HadoopUtils implements Closeable { if (StringUtils.isBlank(hdfsFilePath)){ logger.error("hdfs file path:{} is blank",hdfsFilePath); return null; return Collections.emptyList(); } try (FSDataInputStream in = fs.open(new Path(hdfsFilePath))){ Loading Loading @@ -293,7 +292,7 @@ public class HadoopUtils implements Closeable { if (dstPath.exists()) { if (dstPath.isFile()) { if (overwrite) { dstPath.delete(); Files.delete(dstPath.toPath()); } } else { logger.error("destination file must be a file"); Loading Loading @@ -378,7 +377,7 @@ public class HadoopUtils implements Closeable { String responseContent = HttpUtils.get(applicationUrl); JSONObject jsonObject = JSONObject.parseObject(responseContent); JSONObject jsonObject = JSON.parseObject(responseContent); String result = jsonObject.getJSONObject("app").getString("finalStatus"); switch (result) { Loading Loading @@ -525,8 +524,6 @@ public class HadoopUtils implements Closeable { */ private static final class YarnHAAdminUtils extends RMAdminCLI { private static final Logger logger = LoggerFactory.getLogger(YarnHAAdminUtils.class); /** * get active resourcemanager * Loading Loading @@ -585,8 +582,7 @@ public class HadoopUtils implements Closeable { JSONObject jsonObject = JSON.parseObject(retStr); //get ResourceManager state String state = jsonObject.getJSONObject("clusterInfo").getString("haState"); return state; return jsonObject.getJSONObject("clusterInfo").getString("haState"); } } Loading dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HttpUtils.java +5 −7 Original line number Diff line number Diff line Loading @@ -81,19 +81,17 @@ public class HttpUtils { logger.error(e.getMessage(),e); } if (httpget != null && !httpget.isAborted()) { if (!httpget.isAborted()) { httpget.releaseConnection(); httpget.abort(); } if (httpclient != null) { try { httpclient.close(); } catch (IOException e) { logger.error(e.getMessage(),e); } } } return responseContent; } Loading dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/PropertyUtils.java +1 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ public class PropertyUtils { * @param key property name * @return property value */ public static Boolean getBoolean(String key) { public static boolean getBoolean(String key) { String value = properties.getProperty(key.trim()); if(null != value){ return Boolean.parseBoolean(value); Loading dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/HttpUtilsTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ public class HttpUtilsTest { String result = HttpUtils.get("https://github.com/manifest.json"); Assert.assertNotNull(result); JSONObject jsonObject = JSON.parseObject(result); Assert.assertEquals(jsonObject.getString("name"), "GitHub"); Assert.assertEquals("GitHub", jsonObject.getString("name")); result = HttpUtils.get("https://123.333.111.33/ccc"); Assert.assertNull(result); Loading dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/HiveDataSource.java +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public class HiveDataSource extends BaseDataSource { @Override public String getJdbcUrl() { String jdbcUrl = getAddress(); if (jdbcUrl.lastIndexOf("/") != (jdbcUrl.length() - 1)) { if (jdbcUrl.lastIndexOf('/') != (jdbcUrl.length() - 1)) { jdbcUrl += "/"; } Loading Loading
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java +11 −15 Original line number Diff line number Diff line Loading @@ -32,7 +32,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; import java.nio.file.Files; import java.security.PrivilegedExceptionAction; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; Loading @@ -46,16 +48,14 @@ public class HadoopUtils implements Closeable { private static final Logger logger = LoggerFactory.getLogger(HadoopUtils.class); private static String hdfsUser = PropertyUtils.getString(Constants.HDFS_ROOT_USER); private static volatile HadoopUtils instance = new HadoopUtils(); private static volatile Configuration configuration; private static HadoopUtils instance = new HadoopUtils(); private static Configuration configuration; private static FileSystem fs; private String hdfsUser; private HadoopUtils(){ if(StringUtils.isEmpty(hdfsUser)){ hdfsUser = PropertyUtils.getString(Constants.HDFS_ROOT_USER); } init(); initHdfsPath(); } Loading Loading @@ -129,7 +129,6 @@ public class HadoopUtils implements Closeable { if (fs == null) { if(StringUtils.isNotEmpty(hdfsUser)){ //UserGroupInformation ugi = UserGroupInformation.createProxyUser(hdfsUser,UserGroupInformation.getLoginUser()); UserGroupInformation ugi = UserGroupInformation.createRemoteUser(hdfsUser); ugi.doAs(new PrivilegedExceptionAction<Boolean>() { @Override Loading Loading @@ -196,7 +195,7 @@ public class HadoopUtils implements Closeable { if(StringUtils.isBlank(hdfsFilePath)){ logger.error("hdfs file path:{} is blank",hdfsFilePath); return null; return new byte[0]; } FSDataInputStream fsDataInputStream = fs.open(new Path(hdfsFilePath)); Loading @@ -218,7 +217,7 @@ public class HadoopUtils implements Closeable { if (StringUtils.isBlank(hdfsFilePath)){ logger.error("hdfs file path:{} is blank",hdfsFilePath); return null; return Collections.emptyList(); } try (FSDataInputStream in = fs.open(new Path(hdfsFilePath))){ Loading Loading @@ -293,7 +292,7 @@ public class HadoopUtils implements Closeable { if (dstPath.exists()) { if (dstPath.isFile()) { if (overwrite) { dstPath.delete(); Files.delete(dstPath.toPath()); } } else { logger.error("destination file must be a file"); Loading Loading @@ -378,7 +377,7 @@ public class HadoopUtils implements Closeable { String responseContent = HttpUtils.get(applicationUrl); JSONObject jsonObject = JSONObject.parseObject(responseContent); JSONObject jsonObject = JSON.parseObject(responseContent); String result = jsonObject.getJSONObject("app").getString("finalStatus"); switch (result) { Loading Loading @@ -525,8 +524,6 @@ public class HadoopUtils implements Closeable { */ private static final class YarnHAAdminUtils extends RMAdminCLI { private static final Logger logger = LoggerFactory.getLogger(YarnHAAdminUtils.class); /** * get active resourcemanager * Loading Loading @@ -585,8 +582,7 @@ public class HadoopUtils implements Closeable { JSONObject jsonObject = JSON.parseObject(retStr); //get ResourceManager state String state = jsonObject.getJSONObject("clusterInfo").getString("haState"); return state; return jsonObject.getJSONObject("clusterInfo").getString("haState"); } } Loading
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HttpUtils.java +5 −7 Original line number Diff line number Diff line Loading @@ -81,19 +81,17 @@ public class HttpUtils { logger.error(e.getMessage(),e); } if (httpget != null && !httpget.isAborted()) { if (!httpget.isAborted()) { httpget.releaseConnection(); httpget.abort(); } if (httpclient != null) { try { httpclient.close(); } catch (IOException e) { logger.error(e.getMessage(),e); } } } return responseContent; } Loading
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/PropertyUtils.java +1 −1 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ public class PropertyUtils { * @param key property name * @return property value */ public static Boolean getBoolean(String key) { public static boolean getBoolean(String key) { String value = properties.getProperty(key.trim()); if(null != value){ return Boolean.parseBoolean(value); Loading
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/HttpUtilsTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,7 @@ public class HttpUtilsTest { String result = HttpUtils.get("https://github.com/manifest.json"); Assert.assertNotNull(result); JSONObject jsonObject = JSON.parseObject(result); Assert.assertEquals(jsonObject.getString("name"), "GitHub"); Assert.assertEquals("GitHub", jsonObject.getString("name")); result = HttpUtils.get("https://123.333.111.33/ccc"); Assert.assertNull(result); Loading
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/HiveDataSource.java +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public class HiveDataSource extends BaseDataSource { @Override public String getJdbcUrl() { String jdbcUrl = getAddress(); if (jdbcUrl.lastIndexOf("/") != (jdbcUrl.length() - 1)) { if (jdbcUrl.lastIndexOf('/') != (jdbcUrl.length() - 1)) { jdbcUrl += "/"; } Loading