-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from wolfboys/main
streamx 1.1.0 release
- Loading branch information
Showing
46 changed files
with
259 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
streamx-common/src/main/scala/com/streamxhub/streamx/common/util/FlinkClientUtils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2019 The StreamX Project | ||
* <p> | ||
* 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 | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <a href="mailto:[email protected]">Ben</a> | ||
* @see <b>对象为Null返回true,集合的大小为0也返回true,迭代器没有下一个也返回true..</b> | ||
* @since 1.0 | ||
*/ | ||
|
@@ -110,7 +109,6 @@ public static Boolean isEmpty(Object... objs) { | |
* | ||
* @param obj 要判断,处理的对象 | ||
* @return Boolean | ||
* @author <a href="mailto:[email protected]">Ben</a> | ||
* @see <b>与非空相反</b> | ||
* @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 <K, V extends Comparable<? super V>> Map<K, V> sortMapByValue(Map< | |
} | ||
|
||
public static <T> T[] arrayRemoveElements(T[] array, T... elem) { | ||
AssertUtil.notNull(array); | ||
AssertUtils.notNull(array); | ||
List<T> arrayList = new ArrayList<>(0); | ||
Collections.addAll(arrayList, array); | ||
if (isEmpty(elem)) { | ||
|
@@ -453,7 +451,7 @@ public static <T> T[] arrayRemoveElements(T[] array, T... elem) { | |
} | ||
|
||
public static <T> 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> T[] arrayRemoveIndex(T[] array, int... index) { | |
} | ||
|
||
public static <T> T[] arrayInsertIndex(T[] array, int index, T t) { | ||
AssertUtil.notNull(array); | ||
AssertUtils.notNull(array); | ||
List<T> arrayList = new ArrayList<T>(array.length + 1); | ||
if (index == 0) { | ||
arrayList.add(t); | ||
|
@@ -579,8 +577,8 @@ public static <T> List<Map<String, Object>> objectsToMaps(List<T> objList) { | |
if (objList != null && objList.size() > 0) { | ||
Map<String, Object> 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 <T> List<T> mapsToObjects(List<Map<String, Object>> maps, Class<T> | |
throws InstantiationException, IllegalAccessException { | ||
List<T> list = new ArrayList<>(); | ||
if (maps != null && maps.size() > 0) { | ||
Map<String, Object> map = null; | ||
T bean = null; | ||
for (int i = 0, size = maps.size(); i < size; i++) { | ||
map = maps.get(i); | ||
Map<String, Object> map; | ||
T bean; | ||
for (Map<String, Object> stringObjectMap : maps) { | ||
map = stringObjectMap; | ||
bean = clazz.newInstance(); | ||
mapToBean(map, bean); | ||
list.add(bean); | ||
|
Oops, something went wrong.