diff --git a/streamx-common/pom.xml b/streamx-common/pom.xml index d349039f8f..b92b76040f 100644 --- a/streamx-common/pom.xml +++ b/streamx-common/pom.xml @@ -69,13 +69,13 @@ mysql mysql-connector-java - provided + true redis.clients jedis - provided + true @@ -134,36 +134,51 @@ commons-cli + + + org.apache.flink + flink-core + ${flink.version} + true + + + + org.apache.flink + flink-clients_${scala.binary.version} + ${flink.version} + true + + org.apache.hadoop hadoop-client - provided + true org.apache.hbase hbase-client - provided + true org.apache.hadoop hadoop-yarn-api - provided + true org.apache.hadoop hadoop-yarn-client - provided + true org.mongodb mongo-java-driver 3.12.2 - provided + true @@ -175,14 +190,14 @@ org.apache.curator curator-framework 2.6.0 - provided + true org.apache.ivy ivy 2.4.0 - provided + true diff --git a/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/AssertUtil.scala b/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/AssertUtils.scala similarity index 99% rename from streamx-common/src/main/scala/com/streamxhub/streamx/common/util/AssertUtil.scala rename to streamx-common/src/main/scala/com/streamxhub/streamx/common/util/AssertUtils.scala index 5ff6a7e565..852e47ef2e 100644 --- a/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/AssertUtil.scala +++ b/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/AssertUtils.scala @@ -24,7 +24,7 @@ package com.streamxhub.streamx.common.util import java.util; -object AssertUtil { +object AssertUtils { /** * Assert a boolean expression, throwing IllegalArgumentException if the test result diff --git a/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/DateUtils.scala b/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/DateUtils.scala index 140e424180..c1e5b02828 100644 --- a/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/DateUtils.scala +++ b/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/DateUtils.scala @@ -20,7 +20,9 @@ */ package com.streamxhub.streamx.common.util -import java.text.SimpleDateFormat +import java.text.{ParseException, SimpleDateFormat} +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter import java.util.concurrent.TimeUnit import java.util.{Calendar, TimeZone, _} import scala.util._ @@ -181,6 +183,24 @@ object DateUtils { } } + def formatFullTime(localDateTime: LocalDateTime): String = formatFullTime(localDateTime, fullFormat) + + def formatFullTime(localDateTime: LocalDateTime, pattern: String): String = { + val dateTimeFormatter = DateTimeFormatter.ofPattern(pattern) + localDateTime.format(dateTimeFormatter) + } + + private def getDateFormat(date: Date, dateFormatType: String) = { + val simformat = new SimpleDateFormat(dateFormatType) + simformat.format(date) + } + + @throws[ParseException] def formatCSTTime(date: String, format: String): String = { + val sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US) + val d = sdf.parse(date) + DateUtils.getDateFormat(d, format) + } + def main(args: Array[String]): Unit = { println(DateUtils.+-(-1)) } diff --git a/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/FlinkClientUtils.scala b/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/FlinkClientUtils.scala new file mode 100644 index 0000000000..4150ebcdba --- /dev/null +++ b/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/FlinkClientUtils.scala @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019 The StreamX Project + *

+ * 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 com.streamxhub.streamx.common.util + +import org.apache.flink.api.common.Plan +import org.apache.flink.client.program.{PackagedProgram, PackagedProgramUtils, ProgramInvocationException} +import org.apache.flink.configuration.{Configuration, JobManagerOptions} +import org.apache.flink.optimizer.costs.DefaultCostEstimator +import org.apache.flink.optimizer.plan.OptimizedPlan +import org.apache.flink.optimizer.plandump.PlanJSONDumpGenerator +import org.apache.flink.optimizer.{DataStatistics, Optimizer} + +import java.net.{InetAddress, InetSocketAddress, ServerSocket} + +object FlinkClientUtils { + + + /** + * getExecutionPlan + * + * @param packagedProgram + * @throws + * @return + */ + @throws[ProgramInvocationException] def getExecutionPlan(packagedProgram: PackagedProgram): String = { + require(packagedProgram != null) + val address: InetAddress = InetAddress.getLocalHost + val jmAddress = new InetSocketAddress(address, new ServerSocket(0).getLocalPort) + + val config = new Configuration + config.setString(JobManagerOptions.ADDRESS, jmAddress.getHostName) + config.setInteger(JobManagerOptions.PORT, jmAddress.getPort) + + val optimizer = new Optimizer(new DataStatistics, new DefaultCostEstimator, config) + val plan: Plan = PackagedProgramUtils.getPipelineFromProgram(packagedProgram, config, -1, true).asInstanceOf[Plan] + val optimizedPlan: OptimizedPlan = optimizer.compile(plan) + require(optimizedPlan != null) + + val dumper = new PlanJSONDumpGenerator + dumper.setEncodeForHTML(true) + dumper.getOptimizerPlanAsJSON(optimizedPlan) + } + +} diff --git a/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/util/FlinkUtils.scala b/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/FlinkUtils.scala similarity index 96% rename from streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/util/FlinkUtils.scala rename to streamx-common/src/main/scala/com/streamxhub/streamx/common/util/FlinkUtils.scala index 09f5e16ffa..ed01f8bcf7 100644 --- a/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/util/FlinkUtils.scala +++ b/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/FlinkUtils.scala @@ -18,7 +18,8 @@ * specific language governing permissions and limitations * under the License. */ -package com.streamxhub.streamx.flink.core.scala.util +package com.streamxhub.streamx.common.util + import org.apache.flink.api.common.state.{ListState, ListStateDescriptor} import org.apache.flink.api.common.typeinfo.TypeInformation @@ -30,5 +31,4 @@ object FlinkUtils { context.getOperatorStateStore.getUnionListState(new ListStateDescriptor(descriptorName, implicitly[TypeInformation[R]].getTypeClass)) } - } diff --git a/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/HadoopUtils.scala b/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/HadoopUtils.scala index 13f49ab103..ac1d0dcdd8 100644 --- a/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/HadoopUtils.scala +++ b/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/HadoopUtils.scala @@ -106,7 +106,7 @@ object HadoopUtils extends Logger { if (!configurationCache.containsKey(confDir)) { FileUtils.exists(confDir) val hadoopConfDir = new File(confDir) - val confName = List("core-site.xml", "hdfs-site.xml", "yarn-site.xml") + val confName = List("core-site.xml", "hdfs-site.xml", "yarn-site.xml","mapred-site.xml") val files = hadoopConfDir.listFiles().filter(x => x.isFile && confName.contains(x.getName)).toList val conf = new Configuration() if (CollectionUtils.isNotEmpty(files)) { @@ -175,7 +175,7 @@ object HadoopUtils extends Logger { logInfo("kerberos authentication successful") } catch { case e: IOException => - logInfo(s"kerberos login failed,${e.getLocalizedMessage}") + logError(s"kerberos login failed,${e.getLocalizedMessage}") throw e } } diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/config/P6spySqlFormatConfig.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/config/P6spySqlFormatConfig.java index 3ee8aa9768..1c09ac061a 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/config/P6spySqlFormatConfig.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/config/P6spySqlFormatConfig.java @@ -21,7 +21,7 @@ package com.streamxhub.streamx.console.base.config; import com.p6spy.engine.spy.appender.MessageFormattingStrategy; -import com.streamxhub.streamx.console.base.utils.DateUtil; +import com.streamxhub.streamx.common.util.DateUtils; import org.apache.commons.lang3.StringUtils; import java.time.LocalDateTime; @@ -49,7 +49,7 @@ public String formatMessage( return StringUtils.isBlank(sql) ? "" : String.format( "%s | 耗时 %d ms | SQL 语句:\n %s;", - DateUtil.formatFullTime(LocalDateTime.now()), + DateUtils.formatFullTime(LocalDateTime.now()), elapsed, sql.replaceAll("[\\s]+", StringUtils.SPACE) ); diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/CommonUtil.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/CommonUtils.java similarity index 94% rename from streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/CommonUtil.java rename to streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/CommonUtils.java index 47f59dbcd3..141bdb6695 100755 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/CommonUtil.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/CommonUtils.java @@ -18,9 +18,9 @@ * specific language governing permissions and limitations * under the License. */ -package com.streamxhub.streamx.console.base.utils; +package com.streamxhub.streamx.console.base.util; -import com.streamxhub.streamx.common.util.AssertUtil; +import com.streamxhub.streamx.common.util.AssertUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.cglib.beans.BeanMap; @@ -30,7 +30,7 @@ import java.util.*; @Slf4j -public class CommonUtil implements Serializable { +public class CommonUtils implements Serializable { private static final long serialVersionUID = 6458428317155311192L; @@ -41,7 +41,6 @@ public class CommonUtil implements Serializable { * * @param objs 要判断,处理的对象 * @return Boolean - * @author Ben * @see 对象为Null返回true,集合的大小为0也返回true,迭代器没有下一个也返回true.. * @since 1.0 */ @@ -110,7 +109,6 @@ public static Boolean isEmpty(Object... objs) { * * @param obj 要判断,处理的对象 * @return Boolean - * @author Ben * @see 与非空相反 * @since 1.0 */ @@ -179,14 +177,14 @@ public static Float toFloat(Object val) { } public static List arrayToList(Object source) { - return Arrays.asList(ObjectUtil.toObjectArray(source)); + return Arrays.asList(ObjectUtils.toObjectArray(source)); } public static boolean contains(Iterator iterator, Object element) { if (iterator != null) { while (iterator.hasNext()) { Object candidate = iterator.next(); - if (ObjectUtil.safeEquals(candidate, element)) { + if (ObjectUtils.safeEquals(candidate, element)) { return true; } } @@ -205,7 +203,7 @@ public static boolean contains(Enumeration enumeration, Object element) { if (enumeration != null) { while (enumeration.hasMoreElements()) { Object candidate = enumeration.nextElement(); - if (ObjectUtil.safeEquals(candidate, element)) { + if (ObjectUtils.safeEquals(candidate, element)) { return true; } } @@ -420,10 +418,10 @@ public static boolean isUnix() { */ public static int getPlatform() { int platform = 0; - if (CommonUtil.isUnix()) { + if (CommonUtils.isUnix()) { platform = 1; } - if (CommonUtil.isWindows()) { + if (CommonUtils.isWindows()) { platform = 2; } return platform; @@ -440,7 +438,7 @@ public static > Map sortMapByValue(Map< } public static T[] arrayRemoveElements(T[] array, T... elem) { - AssertUtil.notNull(array); + AssertUtils.notNull(array); List arrayList = new ArrayList<>(0); Collections.addAll(arrayList, array); if (isEmpty(elem)) { @@ -453,7 +451,7 @@ public static T[] arrayRemoveElements(T[] array, T... elem) { } public static T[] arrayRemoveIndex(T[] array, int... index) { - AssertUtil.notNull(array); + AssertUtils.notNull(array); for (int j : index) { if (j < 0 || j > array.length - 1) { throw new IndexOutOfBoundsException("index error.@" + j); @@ -470,7 +468,7 @@ public static T[] arrayRemoveIndex(T[] array, int... index) { } public static T[] arrayInsertIndex(T[] array, int index, T t) { - AssertUtil.notNull(array); + AssertUtils.notNull(array); List arrayList = new ArrayList(array.length + 1); if (index == 0) { arrayList.add(t); @@ -579,8 +577,8 @@ public static List> objectsToMaps(List objList) { if (objList != null && objList.size() > 0) { Map map = null; T bean = null; - for (int i = 0, size = objList.size(); i < size; i++) { - bean = objList.get(i); + for (T t : objList) { + bean = t; map = beanToMap(bean); list.add(map); } @@ -601,10 +599,10 @@ public static List mapsToObjects(List> maps, Class throws InstantiationException, IllegalAccessException { List list = new ArrayList<>(); if (maps != null && maps.size() > 0) { - Map map = null; - T bean = null; - for (int i = 0, size = maps.size(); i < size; i++) { - map = maps.get(i); + Map map; + T bean; + for (Map stringObjectMap : maps) { + map = stringObjectMap; bean = clazz.newInstance(); mapToBean(map, bean); list.add(bean); diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/EncryptUtil.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/EncryptUtils.java similarity index 94% rename from streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/EncryptUtil.java rename to streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/EncryptUtils.java index ed21b1f4b1..2f62a4eb64 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/EncryptUtil.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/EncryptUtils.java @@ -18,12 +18,12 @@ * specific language governing permissions and limitations * under the License. */ -package com.streamxhub.streamx.console.base.utils; +package com.streamxhub.streamx.console.base.util; import javax.crypto.Cipher; import java.security.Key; -public class EncryptUtil { +public class EncryptUtils { // 设置默认密匙 private static String strDefaultKey = "defaultKey"; @@ -60,11 +60,11 @@ private static byte[] hexStr2ByteArr(String strIn) { return arrOut; } - public EncryptUtil() throws Exception { + public EncryptUtils() throws Exception { this(strDefaultKey); } - EncryptUtil(String strKey) throws Exception { + EncryptUtils(String strKey) throws Exception { /* * Security.addProvider(new com.sun.crypto.provider.SunJCE()); */ diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/GZipUtil.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/GZipUtils.java similarity index 98% rename from streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/GZipUtil.java rename to streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/GZipUtils.java index 55f01343e4..5d2e20f066 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/GZipUtil.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/GZipUtils.java @@ -18,7 +18,7 @@ * specific language governing permissions and limitations * under the License. */ -package com.streamxhub.streamx.console.base.utils; +package com.streamxhub.streamx.console.base.util; import org.apache.commons.compress.archivers.ArchiveInputStream; import org.apache.commons.compress.archivers.ArchiveStreamFactory; @@ -30,7 +30,7 @@ /** * @author benjobs */ -public class GZipUtil { +public class GZipUtils { /** * @param tarZipSource 源文件 * @param targetDir 目标目录 diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/JsonUtils.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/JsonUtils.java similarity index 97% rename from streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/JsonUtils.java rename to streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/JsonUtils.java index c3f4d37230..cbb326bfdd 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/JsonUtils.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/JsonUtils.java @@ -18,7 +18,7 @@ * specific language governing permissions and limitations * under the License. */ -package com.streamxhub.streamx.console.base.utils; +package com.streamxhub.streamx.console.base.util; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/ObjectUtil.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/ObjectUtils.java similarity index 99% rename from streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/ObjectUtil.java rename to streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/ObjectUtils.java index c039e6256a..9d13276f0d 100755 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/ObjectUtil.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/ObjectUtils.java @@ -19,11 +19,9 @@ * under the License. */ -package com.streamxhub.streamx.console.base.utils; +package com.streamxhub.streamx.console.base.util; /** - * @Package: cn.damai.usercenter.common.util @Description: TODO - * @author: Wanghuajie * @date: 13-3-6 - 上午11:17 * @version: V1.0 * @company: damai @@ -32,7 +30,7 @@ import java.lang.reflect.Array; import java.util.Arrays; -public class ObjectUtil { +public class ObjectUtils { private static final int INITIAL_HASH = 7; private static final int MULTIPLIER = 31; diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/ShaHashUtil.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/ShaHashUtils.java similarity index 96% rename from streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/ShaHashUtil.java rename to streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/ShaHashUtils.java index b5703897a4..50f94568c0 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/ShaHashUtil.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/ShaHashUtils.java @@ -18,14 +18,14 @@ * specific language governing permissions and limitations * under the License. */ -package com.streamxhub.streamx.console.base.utils; +package com.streamxhub.streamx.console.base.util; import org.apache.shiro.crypto.hash.Sha256Hash; import org.apache.shiro.util.ByteSource; import java.util.Random; -public class ShaHashUtil { +public class ShaHashUtils { /** * 用户密码加密 diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/SortUtil.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/SortUtils.java similarity index 93% rename from streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/SortUtil.java rename to streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/SortUtils.java index 3f41ac34c7..ea2c18f875 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/SortUtil.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/SortUtils.java @@ -18,7 +18,7 @@ * specific language governing permissions and limitations * under the License. */ -package com.streamxhub.streamx.console.base.utils; +package com.streamxhub.streamx.console.base.util; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -30,7 +30,7 @@ * 处理排序工具类 */ @SuppressWarnings("unchecked") -public class SortUtil { +public class SortUtils { /** * 处理排序(分页情况下) for mybatis-plus * @@ -48,10 +48,10 @@ public static void handlePageSort( boolean camelToUnderscore) { page.setCurrent(request.getPageNum()); page.setSize(request.getPageSize()); - String sortField = WebUtil.camelToUnderscore(request.getSortField()); + String sortField = WebUtils.camelToUnderscore(request.getSortField()); if (camelToUnderscore) { - sortField = WebUtil.camelToUnderscore(sortField); - defaultSort = WebUtil.camelToUnderscore(defaultSort); + sortField = WebUtils.camelToUnderscore(sortField); + defaultSort = WebUtils.camelToUnderscore(defaultSort); } if (StringUtils.isNotBlank(request.getSortField()) && StringUtils.isNotBlank(request.getSortOrder()) @@ -111,8 +111,8 @@ public static void handleWrapperSort( boolean camelToUnderscore) { String sortField = request.getSortField(); if (camelToUnderscore) { - sortField = WebUtil.camelToUnderscore(sortField); - defaultSort = WebUtil.camelToUnderscore(defaultSort); + sortField = WebUtils.camelToUnderscore(sortField); + defaultSort = WebUtils.camelToUnderscore(defaultSort); } if (StringUtils.isNotBlank(request.getSortField()) && StringUtils.isNotBlank(request.getSortOrder()) diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/SpringContextUtil.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/SpringContextUtils.java similarity index 91% rename from streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/SpringContextUtil.java rename to streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/SpringContextUtils.java index 59b1ce92a9..c7c92ad980 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/SpringContextUtil.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/SpringContextUtils.java @@ -18,7 +18,7 @@ * specific language governing permissions and limitations * under the License. */ -package com.streamxhub.streamx.console.base.utils; +package com.streamxhub.streamx.console.base.util; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; @@ -31,12 +31,12 @@ * @author benjobs */ @Component -public class SpringContextUtil implements ApplicationContextAware { +public class SpringContextUtils implements ApplicationContextAware { private static ApplicationContext applicationContext; @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - SpringContextUtil.applicationContext = applicationContext; + SpringContextUtils.applicationContext = applicationContext; } public static Object getBean(String name) { diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/TreeUtil.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/TreeUtils.java similarity index 97% rename from streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/TreeUtil.java rename to streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/TreeUtils.java index 8e1a7d8b79..6470b5afb3 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/TreeUtil.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/TreeUtils.java @@ -18,7 +18,7 @@ * specific language governing permissions and limitations * under the License. */ -package com.streamxhub.streamx.console.base.utils; +package com.streamxhub.streamx.console.base.util; import com.streamxhub.streamx.console.base.domain.router.RouterTree; import com.streamxhub.streamx.console.base.domain.router.VueRouter; @@ -26,9 +26,9 @@ import java.util.ArrayList; import java.util.List; -public class TreeUtil { +public class TreeUtils { - protected TreeUtil() { + protected TreeUtils() { } private static final String TOP_NODE_ID = "0"; diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/WebUtil.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/WebUtils.java similarity index 88% rename from streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/WebUtil.java rename to streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/WebUtils.java index 702b281a67..0e85282ff8 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/WebUtil.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/util/WebUtils.java @@ -18,7 +18,7 @@ * specific language governing permissions and limitations * under the License. */ -package com.streamxhub.streamx.console.base.utils; +package com.streamxhub.streamx.console.base.util; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.streamxhub.streamx.console.base.domain.Constant; @@ -32,7 +32,7 @@ * 工具类 */ @Slf4j -public class WebUtil { +public class WebUtils { /** * token 加密 @@ -42,8 +42,8 @@ public class WebUtil { */ public static String encryptToken(String token) { try { - EncryptUtil encryptUtil = new EncryptUtil(Constant.TOKEN_CACHE_PREFIX); - return encryptUtil.encrypt(token); + EncryptUtils encryptUtils = new EncryptUtils(Constant.TOKEN_CACHE_PREFIX); + return encryptUtils.encrypt(token); } catch (Exception e) { log.info("token加密失败:", e); return null; @@ -58,8 +58,8 @@ public static String encryptToken(String token) { */ public static String decryptToken(String encryptToken) { try { - EncryptUtil encryptUtil = new EncryptUtil(Constant.TOKEN_CACHE_PREFIX); - return encryptUtil.decrypt(encryptToken); + EncryptUtils encryptUtils = new EncryptUtils(Constant.TOKEN_CACHE_PREFIX); + return encryptUtils.decrypt(encryptToken); } catch (Exception e) { log.info("token解密失败:", e); return null; diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/DateUtil.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/DateUtil.java deleted file mode 100644 index ce8dbf24ca..0000000000 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/DateUtil.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2019 The StreamX Project - *

- * 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 com.streamxhub.streamx.console.base.utils; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Date; -import java.util.Locale; - -/** - * 时间工具类 - */ -public class DateUtil { - - public static final String FULL_TIME_PATTERN = "yyyyMMddHHmmss"; - - public static final String FULL_TIME_SPLIT_PATTERN = "yyyy-MM-dd HH:mm:ss"; - - public static String formatFullTime(LocalDateTime localDateTime) { - return formatFullTime(localDateTime, FULL_TIME_PATTERN); - } - - public static String formatFullTime(LocalDateTime localDateTime, String pattern) { - DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern); - return localDateTime.format(dateTimeFormatter); - } - - private static String getDateFormat(Date date, String dateFormatType) { - SimpleDateFormat simformat = new SimpleDateFormat(dateFormatType); - return simformat.format(date); - } - - public static String formatCSTTime(String date, String format) throws ParseException { - SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US); - Date d = sdf.parse(date); - return DateUtil.getDateFormat(d, format); - } -} diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/IPUtil.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/IPUtil.java deleted file mode 100644 index 922e9ddaae..0000000000 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/base/utils/IPUtil.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2019 The StreamX Project - *

- * 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 com.streamxhub.streamx.console.base.utils; - -import javax.servlet.http.HttpServletRequest; - -/** - * @author benjobs - */ -public class IPUtil { - - private static final String UNKNOWN = "unknown"; - - protected IPUtil() { - } - - /** - * 获取 IP地址 使用 Nginx等反向代理软件, 则不能通过 request.getRemoteAddr()获取 IP地址 - * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址, X-Forwarded-For中第一个非 unknown的有效IP字符串,则为真实IP地址 - */ - public static String getIpAddr(HttpServletRequest request) { - String ip = request.getHeader("x-forwarded-for"); - if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("Proxy-Client-IP"); - } - if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getHeader("WL-Proxy-Client-IP"); - } - if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) { - ip = request.getRemoteAddr(); - } - return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip; - } -} diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/entity/Application.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/entity/Application.java index 182759798c..d98ffbc6e7 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/entity/Application.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/entity/Application.java @@ -31,8 +31,8 @@ import com.streamxhub.streamx.common.util.HadoopUtils; import com.streamxhub.streamx.common.util.HttpClientUtils; import com.streamxhub.streamx.common.util.Utils; -import com.streamxhub.streamx.console.base.utils.JsonUtils; -import com.streamxhub.streamx.console.base.utils.SpringContextUtil; +import com.streamxhub.streamx.console.base.util.JsonUtils; +import com.streamxhub.streamx.console.base.util.SpringContextUtils; import com.streamxhub.streamx.console.core.enums.ApplicationType; import com.streamxhub.streamx.console.core.enums.DeployState; import com.streamxhub.streamx.console.core.enums.FlinkAppState; @@ -236,13 +236,13 @@ public boolean eqFlinkJob(Application other) { @JsonIgnore public File getLocalAppBase() { - String localWorkspace = SpringContextUtil.getBean(SettingService.class).getStreamXWorkspace(); + String localWorkspace = SpringContextUtils.getBean(SettingService.class).getStreamXWorkspace(); return new File(localWorkspace.concat("/app/").concat(projectId.toString())); } @JsonIgnore public File getLocalFlinkSqlBase() { - String localWorkspace = SpringContextUtil.getBean(SettingService.class).getStreamXWorkspace(); + String localWorkspace = SpringContextUtils.getBean(SettingService.class).getStreamXWorkspace(); File flinkSql = new File(localWorkspace, "flinksql"); if (!flinkSql.exists()) { flinkSql.mkdirs(); diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/entity/Project.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/entity/Project.java index 724eee76b1..b568c67e40 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/entity/Project.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/entity/Project.java @@ -25,8 +25,8 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.streamxhub.streamx.console.base.utils.CommonUtil; -import com.streamxhub.streamx.console.base.utils.SpringContextUtil; +import com.streamxhub.streamx.console.base.util.CommonUtils; +import com.streamxhub.streamx.console.base.util.SpringContextUtils; import com.streamxhub.streamx.console.core.enums.GitAuthorizedError; import com.streamxhub.streamx.console.core.service.SettingService; import lombok.Data; @@ -103,7 +103,7 @@ public class Project implements Serializable { private String getStreamXWorkspace() { if (settingService == null) { - settingService = SpringContextUtil.getBean(SettingService.class); + settingService = SpringContextUtils.getBean(SettingService.class); } return settingService.getStreamXWorkspace(); } @@ -159,7 +159,7 @@ public void delete() throws IOException { public List getAllBranches() { try { Collection refList; - if (CommonUtil.notEmpty(username, password)) { + if (CommonUtils.notEmpty(username, password)) { UsernamePasswordCredentialsProvider pro = new UsernamePasswordCredentialsProvider(username, password); refList = Git.lsRemoteRepository().setRemote(url).setCredentialsProvider(pro).call(); } else { @@ -182,7 +182,7 @@ public List getAllBranches() { @JsonIgnore public GitAuthorizedError gitCheck() { try { - if (CommonUtil.notEmpty(username, password)) { + if (CommonUtils.notEmpty(username, password)) { UsernamePasswordCredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider(username, password); Git.lsRemoteRepository().setRemote(url).setCredentialsProvider(credentialsProvider).call(); } else { @@ -221,7 +221,7 @@ public void cleanCloned() throws IOException { @JsonIgnore public List getMavenBuildCmd() { String buildHome = this.getAppSource().getAbsolutePath(); - if (CommonUtil.notEmpty(this.getPom())) { + if (CommonUtils.notEmpty(this.getPom())) { buildHome = new File(buildHome.concat("/").concat(this.getPom())) .getParentFile() .getAbsolutePath(); diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/metrics/flink/JvmProfiler.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/metrics/flink/JvmProfiler.java index 25d7558c24..761e246f9e 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/metrics/flink/JvmProfiler.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/metrics/flink/JvmProfiler.java @@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.ObjectMapper; import com.streamxhub.streamx.common.util.DeflaterUtils; -import com.streamxhub.streamx.console.base.utils.CommonUtil; +import com.streamxhub.streamx.console.base.util.CommonUtils; import lombok.Data; import java.io.IOException; @@ -48,7 +48,7 @@ public class JvmProfiler implements Serializable { @JsonIgnore public Map getMetricsAsMap() throws IOException { - if (CommonUtil.notEmpty(metric)) { + if (CommonUtils.notEmpty(metric)) { String content = DeflaterUtils.unzipString(metric); return mapper.readValue(content, Map.class); } diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/runner/EnvInitializeRunner.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/runner/EnvInitializeRunner.java index 6008a841a3..6c7ccb448c 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/runner/EnvInitializeRunner.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/runner/EnvInitializeRunner.java @@ -22,7 +22,7 @@ import com.streamxhub.streamx.common.conf.ConfigConst; import com.streamxhub.streamx.common.util.HdfsUtils; -import com.streamxhub.streamx.console.base.utils.WebUtil; +import com.streamxhub.streamx.console.base.util.WebUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; @@ -102,7 +102,7 @@ public void run(ApplicationArguments args) throws Exception { String keepFile = ".gitkeep"; - File plugins = new File(WebUtil.getAppDir("plugins")); + File plugins = new File(WebUtils.getAppDir("plugins")); for (File file : Objects.requireNonNull(plugins.listFiles())) { String plugin = appPlugins.concat("/").concat(file.getName()); if (!HdfsUtils.exists(plugin) && !keepFile.equals(file.getName())) { @@ -117,7 +117,7 @@ public void run(ApplicationArguments args) throws Exception { } String regex = "^streamx-flink-shims_flink-(1.12|1.13)-(.*).jar$"; Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.DOTALL); - File[] shims = new File(WebUtil.getAppDir("lib")).listFiles(pathname -> pathname.getName().matches(regex)); + File[] shims = new File(WebUtils.getAppDir("lib")).listFiles(pathname -> pathname.getName().matches(regex)); for (File file : Objects.requireNonNull(shims)) { Matcher matcher = pattern.matcher(file.getName()); if (!keepFile.equals(file.getName()) && matcher.matches()) { diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationBackUpServiceImpl.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationBackUpServiceImpl.java index 28dc862ecc..43b457e168 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationBackUpServiceImpl.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationBackUpServiceImpl.java @@ -32,7 +32,7 @@ import com.streamxhub.streamx.console.base.domain.Constant; import com.streamxhub.streamx.console.base.domain.RestRequest; import com.streamxhub.streamx.console.base.exception.ServiceException; -import com.streamxhub.streamx.console.base.utils.SortUtil; +import com.streamxhub.streamx.console.base.util.SortUtils; import com.streamxhub.streamx.console.core.dao.ApplicationBackUpMapper; import com.streamxhub.streamx.console.core.entity.Application; import com.streamxhub.streamx.console.core.entity.ApplicationBackUp; @@ -90,7 +90,7 @@ public class ApplicationBackUpServiceImpl @Override public IPage page(ApplicationBackUp backUp, RestRequest request) { Page page = new Page<>(); - SortUtil.handlePageSort(request, page, "create_time", Constant.ORDER_DESC, false); + SortUtils.handlePageSort(request, page, "create_time", Constant.ORDER_DESC, false); return this.baseMapper.page(page, backUp.getAppId()); } diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationConfigServiceImpl.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationConfigServiceImpl.java index 93be50197b..9d27e02d3b 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationConfigServiceImpl.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationConfigServiceImpl.java @@ -31,8 +31,8 @@ import com.streamxhub.streamx.common.util.Utils; import com.streamxhub.streamx.console.base.domain.Constant; import com.streamxhub.streamx.console.base.domain.RestRequest; -import com.streamxhub.streamx.console.base.utils.SortUtil; -import com.streamxhub.streamx.console.base.utils.WebUtil; +import com.streamxhub.streamx.console.base.util.SortUtils; +import com.streamxhub.streamx.console.base.util.WebUtils; import com.streamxhub.streamx.console.core.dao.ApplicationConfigMapper; import com.streamxhub.streamx.console.core.entity.Application; import com.streamxhub.streamx.console.core.entity.ApplicationConfig; @@ -214,7 +214,7 @@ public ApplicationConfig get(Long id) { @Override public IPage page(ApplicationConfig config, RestRequest request) { Page page = new Page<>(); - SortUtil.handlePageSort(request, page, "version", Constant.ORDER_DESC, false); + SortUtils.handlePageSort(request, page, "version", Constant.ORDER_DESC, false); return this.baseMapper.page(page, config.getAppId()); } @@ -243,7 +243,7 @@ public synchronized String readTemplate() { String path; if (profiles.equals(PROD_ENV_NAME)) { //生产环境部署读取conf/flink-application.template - path = WebUtil.getAppDir("conf").concat("/flink-application.template"); + path = WebUtils.getAppDir("conf").concat("/flink-application.template"); } else { URL url = Thread.currentThread().getContextClassLoader().getResource("flink-application.template"); assert url != null; diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationLogServiceImpl.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationLogServiceImpl.java index e31f536b10..7dce7250a3 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationLogServiceImpl.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationLogServiceImpl.java @@ -25,7 +25,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.streamxhub.streamx.console.base.domain.Constant; import com.streamxhub.streamx.console.base.domain.RestRequest; -import com.streamxhub.streamx.console.base.utils.SortUtil; +import com.streamxhub.streamx.console.base.util.SortUtils; import com.streamxhub.streamx.console.core.dao.ApplicationLogMapper; import com.streamxhub.streamx.console.core.entity.Application; import com.streamxhub.streamx.console.core.entity.ApplicationLog; @@ -47,7 +47,7 @@ public class ApplicationLogServiceImpl extends ServiceImpl page(ApplicationLog applicationLog, RestRequest request) { Page page = new Page<>(); - SortUtil.handlePageSort(request, page, "start_time", Constant.ORDER_DESC, false); + SortUtils.handlePageSort(request, page, "start_time", Constant.ORDER_DESC, false); return this.baseMapper.page(page, applicationLog.getAppId()); } diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationServiceImpl.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationServiceImpl.java index 0e52c7c163..d80c9a53ba 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationServiceImpl.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ApplicationServiceImpl.java @@ -34,9 +34,9 @@ import com.streamxhub.streamx.console.base.domain.Constant; import com.streamxhub.streamx.console.base.domain.RestRequest; import com.streamxhub.streamx.console.base.exception.ServiceException; -import com.streamxhub.streamx.console.base.utils.CommonUtil; -import com.streamxhub.streamx.console.base.utils.SortUtil; -import com.streamxhub.streamx.console.base.utils.WebUtil; +import com.streamxhub.streamx.console.base.util.CommonUtils; +import com.streamxhub.streamx.console.base.util.SortUtils; +import com.streamxhub.streamx.console.base.util.WebUtils; import com.streamxhub.streamx.console.core.annotation.RefreshCache; import com.streamxhub.streamx.console.core.dao.ApplicationMapper; import com.streamxhub.streamx.console.core.entity.*; @@ -229,7 +229,7 @@ public boolean upload(MultipartFile file) throws IOException { } //2) 确定需要上传,先上传到本地零时目录 - String temp = WebUtil.getAppDir("temp"); + String temp = WebUtils.getAppDir("temp"); File saveFile = new File(temp, file.getOriginalFilename()); // delete when exsit if (saveFile.exists()) { @@ -354,7 +354,7 @@ private void removeApp(Long appId) { @Override public IPage page(Application appParam, RestRequest request) { Page page = new Page<>(); - SortUtil.handlePageSort(request, page, "create_time", Constant.ORDER_DESC, false); + SortUtils.handlePageSort(request, page, "create_time", Constant.ORDER_DESC, false); this.baseMapper.page(page, appParam); //瞒天过海,暗度陈仓,偷天换日,鱼目混珠. List records = page.getRecords(); @@ -660,7 +660,7 @@ private void downloadDependency(Application application) throws Exception { //1) init. File jobLocalHome = application.getLocalFlinkSqlBase(); if (jobLocalHome.exists()) { - if (!CommonUtil.deleteFile(jobLocalHome)) { + if (!CommonUtils.deleteFile(jobLocalHome)) { throw new RuntimeException(jobLocalHome + " delete failed."); } } @@ -961,7 +961,7 @@ public boolean start(Application appParam, boolean auto) throws Exception { this.flinkSqlService.cleanCandidate(flinkSql.getId()); //1) dist_userJar - File localPlugins = new File(WebUtil.getAppDir("plugins")); + File localPlugins = new File(WebUtils.getAppDir("plugins")); assert localPlugins.exists(); List jars = Arrays.stream(Objects.requireNonNull(localPlugins.list())).filter(x -> x.matches("streamx-flink-sqlclient-.*\\.jar")).collect(Collectors.toList()); if (jars.isEmpty()) { @@ -1004,7 +1004,7 @@ public boolean start(Application appParam, boolean auto) throws Exception { option.append(" -n "); } - String[] dynamicOption = CommonUtil.notEmpty(application.getDynamicOptions()) + String[] dynamicOption = CommonUtils.notEmpty(application.getDynamicOptions()) ? application.getDynamicOptions().split("\\s+") : new String[0]; diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/FlameGraphServiceImpl.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/FlameGraphServiceImpl.java index 2025e95708..2a88aa013d 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/FlameGraphServiceImpl.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/FlameGraphServiceImpl.java @@ -22,8 +22,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.streamxhub.streamx.common.util.CommandUtils; -import com.streamxhub.streamx.console.base.utils.CommonUtil; -import com.streamxhub.streamx.console.base.utils.WebUtil; +import com.streamxhub.streamx.console.base.util.CommonUtils; +import com.streamxhub.streamx.console.base.util.WebUtils; import com.streamxhub.streamx.console.core.dao.FlameGraphMapper; import com.streamxhub.streamx.console.core.entity.Application; import com.streamxhub.streamx.console.core.entity.FlameGraph; @@ -62,7 +62,7 @@ public String generateFlameGraph(FlameGraph flameGraph) throws IOException { flameGraph.getStart(), flameGraph.getEnd() ); - if (CommonUtil.notEmpty(flameGraphList)) { + if (CommonUtils.notEmpty(flameGraphList)) { StringBuffer jsonBuffer = new StringBuffer(); flameGraphList.forEach(x -> jsonBuffer.append(x.getUnzipContent()).append("\r\n")); @@ -73,10 +73,10 @@ public String generateFlameGraph(FlameGraph flameGraph) throws IOException { flameGraph.getStart().getTime(), flameGraph.getEnd().getTime() ); - String jsonPath = WebUtil.getAppDir("temp").concat(File.separator).concat(jsonName); + String jsonPath = WebUtils.getAppDir("temp").concat(File.separator).concat(jsonName); String foldedPath = jsonPath.replace(".json", ".folded"); String svgPath = jsonPath.replace(".json", ".svg"); - String flameGraphPath = WebUtil.getAppDir("bin/flame-graph"); + String flameGraphPath = WebUtils.getAppDir("bin/flame-graph"); // write json FileOutputStream fileOutputStream = new FileOutputStream(jsonPath); diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/FlinkSqlServiceImpl.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/FlinkSqlServiceImpl.java index 5c4937a4ba..f24c1216c6 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/FlinkSqlServiceImpl.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/FlinkSqlServiceImpl.java @@ -25,9 +25,8 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.streamxhub.streamx.common.util.ClassLoaderUtils; import com.streamxhub.streamx.common.util.DeflaterUtils; -import com.streamxhub.streamx.console.base.utils.WebUtil; +import com.streamxhub.streamx.console.base.util.WebUtils; import com.streamxhub.streamx.console.core.dao.FlinkSqlMapper; import com.streamxhub.streamx.console.core.entity.Application; import com.streamxhub.streamx.console.core.entity.FlinkSql; @@ -52,7 +51,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -200,7 +198,7 @@ private synchronized ClassLoader getFlinkShimsClassLoader() { String shimsRegex = "(^|.*)streamx-flink-shims_flink-(1.12|1.13)-(.*).jar$"; Pattern pattern = Pattern.compile(shimsRegex, Pattern.CASE_INSENSITIVE | Pattern.DOTALL); - File[] libJars = new File(WebUtil.getAppDir("lib")).listFiles(pathname -> !pathname.getName().matches(shimsRegex)); + File[] libJars = new File(WebUtils.getAppDir("lib")).listFiles(pathname -> !pathname.getName().matches(shimsRegex)); assert libJars != null; List libList = new ArrayList<>(0); for (File jar : libJars) { @@ -208,7 +206,7 @@ private synchronized ClassLoader getFlinkShimsClassLoader() { } List shimsList = new ArrayList<>(0); - File[] shimsJars = new File(WebUtil.getAppDir("lib")).listFiles(pathname -> pathname.getName().matches(shimsRegex)); + File[] shimsJars = new File(WebUtils.getAppDir("lib")).listFiles(pathname -> pathname.getName().matches(shimsRegex)); assert shimsJars != null; for (File jar : shimsJars) { shimsList.add(jar.toURI().toURL()); diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ProjectServiceImpl.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ProjectServiceImpl.java index b064b2e9a5..f4c3fa5026 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ProjectServiceImpl.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/ProjectServiceImpl.java @@ -31,9 +31,9 @@ import com.streamxhub.streamx.console.base.domain.Constant; import com.streamxhub.streamx.console.base.domain.RestRequest; import com.streamxhub.streamx.console.base.domain.RestResponse; -import com.streamxhub.streamx.console.base.utils.CommonUtil; -import com.streamxhub.streamx.console.base.utils.GZipUtil; -import com.streamxhub.streamx.console.base.utils.SortUtil; +import com.streamxhub.streamx.console.base.util.CommonUtils; +import com.streamxhub.streamx.console.base.util.GZipUtils; +import com.streamxhub.streamx.console.base.util.SortUtils; import com.streamxhub.streamx.console.core.dao.ApplicationMapper; import com.streamxhub.streamx.console.core.dao.ProjectMapper; import com.streamxhub.streamx.console.core.entity.Application; @@ -129,7 +129,7 @@ public boolean delete(Long id) { @Override public IPage page(Project project, RestRequest request) { Page page = new Page<>(); - SortUtil.handlePageSort(request, page, "date", Constant.ORDER_DESC, false); + SortUtils.handlePageSort(request, page, "date", Constant.ORDER_DESC, false); return this.baseMapper.findProject(page, project); } @@ -303,7 +303,7 @@ public List> listConf(Project project) { File file = new File(project.getAppBase(), project.getModule()); File unzipFile = new File(file.getAbsolutePath().replaceAll(".tar.gz", "")); if (!unzipFile.exists()) { - GZipUtil.decompress(file.getAbsolutePath(), file.getParentFile().getAbsolutePath()); + GZipUtils.decompress(file.getAbsolutePath(), file.getParentFile().getAbsolutePath()); } List> list = new ArrayList<>(); // 只过滤conf这个目录 @@ -329,7 +329,7 @@ private boolean cloneSourceCode(Project project) { .setDirectory(project.getAppSource()) .setBranch(project.getBranches()); - if (CommonUtil.notEmpty(project.getUsername(), project.getPassword())) { + if (CommonUtils.notEmpty(project.getUsername(), project.getPassword())) { cloneCommand.setCredentialsProvider(project.getCredentialsProvider()); } diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/SavePointServiceImpl.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/SavePointServiceImpl.java index 417e356a51..714ed2f592 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/SavePointServiceImpl.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/service/impl/SavePointServiceImpl.java @@ -30,8 +30,8 @@ import com.streamxhub.streamx.console.base.domain.Constant; import com.streamxhub.streamx.console.base.domain.RestRequest; import com.streamxhub.streamx.console.base.exception.ServiceException; -import com.streamxhub.streamx.console.base.utils.CommonUtil; -import com.streamxhub.streamx.console.base.utils.SortUtil; +import com.streamxhub.streamx.console.base.util.CommonUtils; +import com.streamxhub.streamx.console.base.util.SortUtils; import com.streamxhub.streamx.console.core.dao.SavePointMapper; import com.streamxhub.streamx.console.core.entity.SavePoint; import com.streamxhub.streamx.console.core.enums.CheckPointType; @@ -108,7 +108,7 @@ public SavePoint getLatest(Long id) { public Boolean delete(Long id) throws ServiceException { SavePoint savePoint = getById(id); try { - if (CommonUtil.notEmpty(savePoint.getPath())) { + if (CommonUtils.notEmpty(savePoint.getPath())) { HdfsUtils.delete(savePoint.getPath()); } removeById(id); @@ -121,7 +121,7 @@ public Boolean delete(Long id) throws ServiceException { @Override public IPage page(SavePoint savePoint, RestRequest request) { Page page = new Page<>(); - SortUtil.handlePageSort(request, page, "trigger_time", Constant.ORDER_DESC, false); + SortUtils.handlePageSort(request, page, "trigger_time", Constant.ORDER_DESC, false); return this.baseMapper.page(page, savePoint.getAppId()); } diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/task/MetricsTask.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/task/MetricsTask.java index 883d84c4bb..37cdab50b0 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/task/MetricsTask.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/core/task/MetricsTask.java @@ -20,7 +20,7 @@ */ package com.streamxhub.streamx.console.core.task; -import com.streamxhub.streamx.console.base.utils.WebUtil; +import com.streamxhub.streamx.console.base.util.WebUtils; import com.streamxhub.streamx.console.core.service.FlameGraphService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -48,7 +48,7 @@ public class MetricsTask { @Scheduled(cron = "0 0 * * * ?") public void cleanFlameGraph() { // 1) clean file - String tempPath = WebUtil.getAppDir("temp"); + String tempPath = WebUtils.getAppDir("temp"); File temp = new File(tempPath); Arrays.stream(Objects.requireNonNull(temp.listFiles())) .filter(x -> x.getName().matches(FLAMEGRAPH_FILE_REGEXP)) diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/authentication/JWTFilter.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/authentication/JWTFilter.java index 289c553ea8..d4335d6ad5 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/authentication/JWTFilter.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/authentication/JWTFilter.java @@ -22,8 +22,8 @@ import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.streamxhub.streamx.console.base.properties.ShiroProperties; -import com.streamxhub.streamx.console.base.utils.SpringContextUtil; -import com.streamxhub.streamx.console.base.utils.WebUtil; +import com.streamxhub.streamx.console.base.util.SpringContextUtils; +import com.streamxhub.streamx.console.base.util.WebUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authz.UnauthorizedException; @@ -52,7 +52,7 @@ protected boolean isAccessAllowed( ServletRequest request, ServletResponse response, Object mappedValue) throws UnauthorizedException { HttpServletRequest httpServletRequest = (HttpServletRequest) request; - ShiroProperties properties = SpringContextUtil.getBean(ShiroProperties.class); + ShiroProperties properties = SpringContextUtils.getBean(ShiroProperties.class); String[] anonUrl = StringUtils.splitByWholeSeparatorPreserveAllTokens( properties.getAnonUrl(), StringPool.COMMA @@ -81,7 +81,7 @@ protected boolean isLoginAttempt(ServletRequest request, ServletResponse respons protected boolean executeLogin(ServletRequest request, ServletResponse response) { HttpServletRequest httpServletRequest = (HttpServletRequest) request; String token = httpServletRequest.getHeader(TOKEN); - JWTToken jwtToken = new JWTToken(WebUtil.decryptToken(token)); + JWTToken jwtToken = new JWTToken(WebUtils.decryptToken(token)); try { getSubject(request, response).login(jwtToken); return true; diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/authentication/JWTUtil.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/authentication/JWTUtil.java index dfddb5a484..50df452582 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/authentication/JWTUtil.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/authentication/JWTUtil.java @@ -26,7 +26,7 @@ import com.auth0.jwt.exceptions.JWTDecodeException; import com.auth0.jwt.interfaces.DecodedJWT; import com.streamxhub.streamx.console.base.properties.ShiroProperties; -import com.streamxhub.streamx.console.base.utils.SpringContextUtil; +import com.streamxhub.streamx.console.base.util.SpringContextUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -38,7 +38,7 @@ @Slf4j public class JWTUtil { - private static final long EXPIRE_TIME = SpringContextUtil.getBean(ShiroProperties.class).getJwtTimeOut() * 1000; + private static final long EXPIRE_TIME = SpringContextUtils.getBean(ShiroProperties.class).getJwtTimeOut() * 1000; /** * 校验 token是否正确 diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/controller/PassportController.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/controller/PassportController.java index 8179baf88b..e285462ba5 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/controller/PassportController.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/controller/PassportController.java @@ -20,11 +20,11 @@ */ package com.streamxhub.streamx.console.system.controller; +import com.streamxhub.streamx.common.util.DateUtils; import com.streamxhub.streamx.console.base.domain.RestResponse; import com.streamxhub.streamx.console.base.properties.ShiroProperties; -import com.streamxhub.streamx.console.base.utils.DateUtil; -import com.streamxhub.streamx.console.base.utils.ShaHashUtil; -import com.streamxhub.streamx.console.base.utils.WebUtil; +import com.streamxhub.streamx.console.base.util.ShaHashUtils; +import com.streamxhub.streamx.console.base.util.WebUtils; import com.streamxhub.streamx.console.system.authentication.JWTToken; import com.streamxhub.streamx.console.system.authentication.JWTUtil; import com.streamxhub.streamx.console.system.entity.User; @@ -75,7 +75,7 @@ public RestResponse signin( } String salt = user.getSalt(); - password = ShaHashUtil.encrypt(salt, password); + password = ShaHashUtils.encrypt(salt, password); if (!StringUtils.equals(user.getPassword(), password)) { return RestResponse.create().put("code", 0); @@ -87,9 +87,9 @@ public RestResponse signin( // 更新用户登录时间 this.userService.updateLoginTime(username); - String token = WebUtil.encryptToken(JWTUtil.sign(username, password)); + String token = WebUtils.encryptToken(JWTUtil.sign(username, password)); LocalDateTime expireTime = LocalDateTime.now().plusSeconds(properties.getJwtTimeOut()); - String expireTimeStr = DateUtil.formatFullTime(expireTime); + String expireTimeStr = DateUtils.formatFullTime(expireTime); JWTToken jwtToken = new JWTToken(token, expireTimeStr); String userId = RandomStringUtils.randomAlphanumeric(20); user.setId(userId); diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/controller/UserController.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/controller/UserController.java index b1cb4af36e..15c72ae499 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/controller/UserController.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/controller/UserController.java @@ -25,7 +25,7 @@ import com.streamxhub.streamx.console.base.domain.RestRequest; import com.streamxhub.streamx.console.base.domain.RestResponse; import com.streamxhub.streamx.console.base.exception.ServiceException; -import com.streamxhub.streamx.console.base.utils.ShaHashUtil; +import com.streamxhub.streamx.console.base.util.ShaHashUtils; import com.streamxhub.streamx.console.system.entity.User; import com.streamxhub.streamx.console.system.service.UserService; import lombok.extern.slf4j.Slf4j; @@ -111,7 +111,7 @@ public RestResponse checkPassword( User user = userService.findByName(username); String salt = user.getSalt(); - String encryptPassword = ShaHashUtil.encrypt(salt, password); + String encryptPassword = ShaHashUtils.encrypt(salt, password); boolean result = StringUtils.equals(user.getPassword(), encryptPassword); return RestResponse.create().data(result); } diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/service/impl/MenuServiceImpl.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/service/impl/MenuServiceImpl.java index 34c83c62f4..7f730eebfd 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/service/impl/MenuServiceImpl.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/service/impl/MenuServiceImpl.java @@ -26,7 +26,7 @@ import com.streamxhub.streamx.console.base.domain.router.RouterMeta; import com.streamxhub.streamx.console.base.domain.router.RouterTree; import com.streamxhub.streamx.console.base.domain.router.VueRouter; -import com.streamxhub.streamx.console.base.utils.TreeUtil; +import com.streamxhub.streamx.console.base.util.TreeUtils; import com.streamxhub.streamx.console.system.dao.MenuMapper; import com.streamxhub.streamx.console.system.entity.Menu; import com.streamxhub.streamx.console.system.entity.User; @@ -70,7 +70,7 @@ public Map findMenus(Menu menu) { if (StringUtils.equals(menu.getType(), Constant.TYPE_BUTTON)) { result.put("rows", trees); } else { - RouterTree

menuTree = TreeUtil.build(trees); + RouterTree menuTree = TreeUtils.build(trees); result.put("rows", menuTree); } result.put("total", menus.size()); @@ -133,7 +133,7 @@ public ArrayList> getUserRouters(User user) { route.setMeta(new RouterMeta(true, hidden, true, menu.getIcon())); routes.add(route); }); - return TreeUtil.buildVueRouter(routes); + return TreeUtils.buildVueRouter(routes); } private void buildTrees(List> trees, List menus, List ids) { diff --git a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/service/impl/UserServiceImpl.java b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/service/impl/UserServiceImpl.java index 2bb1590e56..d11545ced6 100644 --- a/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/service/impl/UserServiceImpl.java +++ b/streamx-console/streamx-console-service/src/main/java/com/streamxhub/streamx/console/system/service/impl/UserServiceImpl.java @@ -26,7 +26,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.streamxhub.streamx.console.base.domain.RestRequest; -import com.streamxhub.streamx.console.base.utils.ShaHashUtil; +import com.streamxhub.streamx.console.base.util.ShaHashUtils; import com.streamxhub.streamx.console.system.dao.UserMapper; import com.streamxhub.streamx.console.system.entity.Menu; import com.streamxhub.streamx.console.system.entity.User; @@ -88,8 +88,8 @@ public void createUser(User user) throws Exception { // 创建用户 user.setCreateTime(new Date()); user.setAvatar(User.DEFAULT_AVATAR); - String salt = ShaHashUtil.getRandomSalt(26); - String password = ShaHashUtil.encrypt(salt, user.getPassword()); + String salt = ShaHashUtils.getRandomSalt(26); + String password = ShaHashUtils.encrypt(salt, user.getPassword()); user.setSalt(salt); user.setPassword(password); save(user); @@ -137,8 +137,8 @@ public void updateAvatar(String username, String avatar) throws Exception { @Transactional(rollbackFor = Exception.class) public void updatePassword(String username, String password) throws Exception { User user = new User(); - String salt = ShaHashUtil.getRandomSalt(26); - password = ShaHashUtil.encrypt(salt, password); + String salt = ShaHashUtils.getRandomSalt(26); + password = ShaHashUtils.encrypt(salt, password); user.setSalt(salt); user.setPassword(password); this.baseMapper.update(user, new LambdaQueryWrapper().eq(User::getUsername, username)); @@ -149,8 +149,8 @@ public void updatePassword(String username, String password) throws Exception { public void resetPassword(String[] usernames) throws Exception { for (String username : usernames) { User user = new User(); - String salt = ShaHashUtil.getRandomSalt(26); - String password = ShaHashUtil.encrypt(salt, User.DEFAULT_PASSWORD); + String salt = ShaHashUtils.getRandomSalt(26); + String password = ShaHashUtils.encrypt(salt, User.DEFAULT_PASSWORD); user.setSalt(salt); user.setPassword(password); this.baseMapper.update(user, new LambdaQueryWrapper().eq(User::getUsername, username)); diff --git a/streamx-console/streamx-console-service/src/main/resources/db/migration/V1_0__init_db.sql b/streamx-console/streamx-console-service/src/main/resources/db/migration/V1_0__init_db.sql index 34bad27b58..4d0f37a1e8 100644 --- a/streamx-console/streamx-console-service/src/main/resources/db/migration/V1_0__init_db.sql +++ b/streamx-console/streamx-console-service/src/main/resources/db/migration/V1_0__init_db.sql @@ -26,7 +26,7 @@ CREATE TABLE `t_flame_graph` ( `APP_ID` bigint DEFAULT NULL, `PROFILER` varchar(255) DEFAULT NULL, `TIMELINE` datetime DEFAULT NULL, -`CONTENT` varchar(2000) DEFAULT NULL, +`CONTENT` text DEFAULT NULL, PRIMARY KEY (`ID`) USING BTREE, KEY `INX_TIME` (`TIMELINE`) USING HASH, KEY `INX_APPID` (`APP_ID`) USING HASH diff --git a/streamx-console/streamx-console-service/src/main/resources/mapper/core/FlameGraphMapper.xml b/streamx-console/streamx-console-service/src/main/resources/mapper/core/FlameGraphMapper.xml index 786b0000fd..daeca284c3 100644 --- a/streamx-console/streamx-console-service/src/main/resources/mapper/core/FlameGraphMapper.xml +++ b/streamx-console/streamx-console-service/src/main/resources/mapper/core/FlameGraphMapper.xml @@ -6,6 +6,6 @@ - + diff --git a/streamx-flink/streamx-flink-core/src/main/java/com/streamxhub/streamx/flink/core/java/sink/JdbcSink.java b/streamx-flink/streamx-flink-core/src/main/java/com/streamxhub/streamx/flink/core/java/sink/JdbcSink.java index 35fece2f83..73418c1484 100644 --- a/streamx-flink/streamx-flink-core/src/main/java/com/streamxhub/streamx/flink/core/java/sink/JdbcSink.java +++ b/streamx-flink/streamx-flink-core/src/main/java/com/streamxhub/streamx/flink/core/java/sink/JdbcSink.java @@ -20,7 +20,7 @@ */ package com.streamxhub.streamx.flink.core.java.sink; -import com.streamxhub.streamx.common.util.AssertUtil; +import com.streamxhub.streamx.common.util.AssertUtils; import com.streamxhub.streamx.common.util.ConfigUtils; import com.streamxhub.streamx.flink.core.java.function.SQLFromFunction; import com.streamxhub.streamx.flink.core.scala.StreamingContext; @@ -60,7 +60,7 @@ public JdbcSink sql(SQLFromFunction func) { } public DataStreamSink sink(DataStream dataStream) { - AssertUtil.notNull(sqlFunc); + AssertUtils.notNull(sqlFunc); this.jdbc = this.jdbc == null ? ConfigUtils.getJdbcConf(context.parameter().toMap(), alias) : this.jdbc; JdbcSinkFunction sinkFun = new JdbcSinkFunction<>(this.jdbc, this.sqlFunc); return dataStream.addSink(sinkFun); diff --git a/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/source/HBaseSource.scala b/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/source/HBaseSource.scala index bd974ed228..52d266acbf 100644 --- a/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/source/HBaseSource.scala +++ b/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/source/HBaseSource.scala @@ -22,11 +22,10 @@ package com.streamxhub.streamx.flink.core.scala.source import com.streamxhub.streamx.common.enums.ApiType import com.streamxhub.streamx.common.enums.ApiType.ApiType -import com.streamxhub.streamx.common.util.{Logger, Utils} +import com.streamxhub.streamx.common.util.{FlinkUtils, Logger, Utils} import com.streamxhub.streamx.flink.core.java.function.{HBaseQueryFunction, HBaseResultFunction, RunningFunction} import com.streamxhub.streamx.flink.core.java.wrapper.HBaseQuery import com.streamxhub.streamx.flink.core.scala.StreamingContext -import com.streamxhub.streamx.flink.core.scala.util.FlinkUtils import org.apache.flink.api.common.state.ListState import org.apache.flink.api.common.typeinfo.TypeInformation import org.apache.flink.configuration.Configuration diff --git a/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/source/JdbcSource.scala b/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/source/JdbcSource.scala index 9ce1240ebc..6def2ea83a 100644 --- a/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/source/JdbcSource.scala +++ b/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/source/JdbcSource.scala @@ -22,10 +22,9 @@ package com.streamxhub.streamx.flink.core.scala.source import com.streamxhub.streamx.common.enums.ApiType import com.streamxhub.streamx.common.enums.ApiType.ApiType -import com.streamxhub.streamx.common.util.{JdbcUtils, Logger, Utils} +import com.streamxhub.streamx.common.util.{FlinkUtils, JdbcUtils, Logger, Utils} import com.streamxhub.streamx.flink.core.java.function.{RunningFunction, SQLQueryFunction, SQLResultFunction} import com.streamxhub.streamx.flink.core.scala.StreamingContext -import com.streamxhub.streamx.flink.core.scala.util.FlinkUtils import org.apache.flink.api.common.state.ListState import org.apache.flink.api.common.typeinfo.TypeInformation import org.apache.flink.runtime.state.{CheckpointListener, FunctionInitializationContext, FunctionSnapshotContext} diff --git a/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/source/MongoSource.scala b/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/source/MongoSource.scala index aa2be8bcb5..d7f5cc3e26 100644 --- a/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/source/MongoSource.scala +++ b/streamx-flink/streamx-flink-core/src/main/scala/com/streamxhub/streamx/flink/core/scala/source/MongoSource.scala @@ -24,10 +24,9 @@ import com.mongodb.MongoClient import com.mongodb.client.{FindIterable, MongoCollection, MongoCursor} import com.streamxhub.streamx.common.enums.ApiType import com.streamxhub.streamx.common.enums.ApiType.ApiType -import com.streamxhub.streamx.common.util.{Logger, MongoConfig, Utils} +import com.streamxhub.streamx.common.util.{FlinkUtils, Logger, MongoConfig, Utils} import com.streamxhub.streamx.flink.core.java.function.{MongoQueryFunction, MongoResultFunction, RunningFunction} import com.streamxhub.streamx.flink.core.scala.StreamingContext -import com.streamxhub.streamx.flink.core.scala.util.FlinkUtils import org.apache.flink.api.common.state.ListState import org.apache.flink.api.common.typeinfo.TypeInformation import org.apache.flink.configuration.Configuration diff --git a/streamx-parent/pom.xml b/streamx-parent/pom.xml index 78b33a3a44..9a91e197ef 100644 --- a/streamx-parent/pom.xml +++ b/streamx-parent/pom.xml @@ -18,7 +18,7 @@ UTF-8 2.2.0 2.3.4 - 1.12.0 + 1.13.0 2.0.39 3.8.5 2.10.1 diff --git a/streamx-plugin/streamx-flink-submit/src/main/scala/com/streamxhub/streamx/flink/submit/impl/ApplicationSubmit.scala b/streamx-plugin/streamx-flink-submit/src/main/scala/com/streamxhub/streamx/flink/submit/impl/ApplicationSubmit.scala index 95bbceee15..21f0c559fd 100644 --- a/streamx-plugin/streamx-flink-submit/src/main/scala/com/streamxhub/streamx/flink/submit/impl/ApplicationSubmit.scala +++ b/streamx-plugin/streamx-flink-submit/src/main/scala/com/streamxhub/streamx/flink/submit/impl/ApplicationSubmit.scala @@ -32,10 +32,13 @@ import org.apache.flink.client.deployment.application.ApplicationConfiguration import org.apache.flink.client.program.PackagedProgramUtils import org.apache.flink.configuration._ import org.apache.flink.runtime.security.{SecurityConfiguration, SecurityUtils} +import org.apache.flink.runtime.util.HadoopUtils import org.apache.flink.util.Preconditions.checkNotNull import org.apache.flink.yarn.configuration.{YarnConfigOptions, YarnDeploymentTarget} +import org.apache.hadoop.security.UserGroupInformation import org.apache.hadoop.yarn.api.records.ApplicationId +import java.lang.{Boolean => JavaBool} import java.util.concurrent.Callable import java.util.{Collections, List => JavaList} import scala.collection.JavaConverters._ @@ -83,7 +86,7 @@ object ApplicationSubmit extends YarnSubmitTrait { logInfo( s""" ||--------------------------<>--------------------------| - || Flink Job Started: applicationId: $applicationId | + || Flink Job Started: applicationId: $applicationId| ||_____________________________________________________________________| |""".stripMargin) @@ -148,6 +151,17 @@ object ApplicationSubmit extends YarnSubmitTrait { } providedLibs -> programArgs } + + val currentUser = UserGroupInformation.getCurrentUser + logDebug(s"UserGroupInformation currentUser: $currentUser") + if (HadoopUtils.isKerberosSecurityEnabled(currentUser)) { + logDebug(s"kerberos Security is Enabled...") + val useTicketCache = getOptionFromDefaultFlinkConfig[JavaBool](submitRequest.flinkHome, SecurityOptions.KERBEROS_LOGIN_USETICKETCACHE) + if (!HadoopUtils.areKerberosCredentialsValid(currentUser, useTicketCache)) { + throw new RuntimeException(s"Hadoop security with Kerberos is enabled but the login user ${currentUser} does not have Kerberos credentials or delegation tokens!") + } + } + //yarn.provided.lib.dirs effectiveConfiguration.set(YarnConfigOptions.PROVIDED_LIB_DIRS, providedLibs.asJava) //flinkDistJar