This is an automated email from the ASF dual-hosted git repository.
panyuepeng pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new 900c7aad3 [ISSUE-3046][Improve] Improve streampark-common module base
on 3.3 Methods Rule (#3389)
900c7aad3 is described below
commit 900c7aad31c538abb485f6db95532ac49c61c966
Author: zhengkezhou <[email protected]>
AuthorDate: Thu Dec 14 10:00:37 2023 +0800
[ISSUE-3046][Improve] Improve streampark-common module base on 3.3 Methods
Rule (#3389)
* [ISSUE-3046][Improve] Improve streampark-common module base on 3.3
Methods Rule
---
.../streampark/common/enums/ApplicationType.java | 8 ++++-
.../streampark/common/enums/ClusterState.java | 14 ++++++---
.../common/enums/FlinkDevelopmentMode.java | 10 +++++--
.../common/enums/FlinkExecutionMode.java | 35 +++++++++++++---------
.../common/enums/FlinkK8sRestExposedType.java | 10 +++++--
.../streampark/common/enums/FlinkRestoreMode.java | 7 ++++-
.../common/enums/FlinkSqlValidationFailedType.java | 3 ++
.../streampark/common/enums/ResolveOrder.java | 10 +++++--
.../apache/streampark/common/enums/Semantic.java | 6 +++-
.../streampark/common/enums/StorageType.java | 9 ++++--
.../streampark/common/util/ExceptionUtils.java | 6 +++-
11 files changed, 88 insertions(+), 30 deletions(-)
diff --git
a/streampark-common/src/main/java/org/apache/streampark/common/enums/ApplicationType.java
b/streampark-common/src/main/java/org/apache/streampark/common/enums/ApplicationType.java
index 70c992d82..b2bf8998e 100644
---
a/streampark-common/src/main/java/org/apache/streampark/common/enums/ApplicationType.java
+++
b/streampark-common/src/main/java/org/apache/streampark/common/enums/ApplicationType.java
@@ -17,6 +17,9 @@
package org.apache.streampark.common.enums;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
public enum ApplicationType {
/** StreamPark Flink */
@@ -34,7 +37,7 @@ public enum ApplicationType {
private final int type;
private final String name;
- ApplicationType(int type, String name) {
+ ApplicationType(int type, @Nonnull String name) {
this.type = type;
this.name = name;
}
@@ -43,10 +46,13 @@ public enum ApplicationType {
return type;
}
+ @Nonnull
public String getName() {
return name;
}
+ /** switch param use this, can't be null */
+ @Nullable
public static ApplicationType of(int type) {
for (ApplicationType appType : ApplicationType.values()) {
if (appType.getType() == type) {
diff --git
a/streampark-common/src/main/java/org/apache/streampark/common/enums/ClusterState.java
b/streampark-common/src/main/java/org/apache/streampark/common/enums/ClusterState.java
index b2599b74c..bf62ca5e4 100644
---
a/streampark-common/src/main/java/org/apache/streampark/common/enums/ClusterState.java
+++
b/streampark-common/src/main/java/org/apache/streampark/common/enums/ClusterState.java
@@ -17,6 +17,9 @@
package org.apache.streampark.common.enums;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
/** @since 1.2.3 */
public enum ClusterState {
@@ -49,11 +52,12 @@ public enum ClusterState {
private final Integer state;
- ClusterState(Integer state) {
+ ClusterState(@Nonnull Integer state) {
this.state = state;
}
- public static ClusterState of(Integer value) {
+ @Nonnull
+ public static ClusterState of(@Nullable Integer value) {
for (ClusterState clusterState : values()) {
if (clusterState.state.equals(value)) {
return clusterState;
@@ -62,7 +66,8 @@ public enum ClusterState {
return ClusterState.UNKNOWN;
}
- public static ClusterState of(String name) {
+ @Nonnull
+ public static ClusterState of(@Nullable String name) {
for (ClusterState clusterState : values()) {
if (clusterState.name().equals(name)) {
return clusterState;
@@ -71,11 +76,12 @@ public enum ClusterState {
return ClusterState.UNKNOWN;
}
+ @Nonnull
public Integer getState() {
return state;
}
- public static boolean isRunning(ClusterState state) {
+ public static boolean isRunning(@Nullable ClusterState state) {
return RUNNING.equals(state);
}
}
diff --git
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkDevelopmentMode.java
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkDevelopmentMode.java
index 38c545e91..2ad4fc7e5 100644
---
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkDevelopmentMode.java
+++
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkDevelopmentMode.java
@@ -17,6 +17,9 @@
package org.apache.streampark.common.enums;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
public enum FlinkDevelopmentMode {
/** custom code */
@@ -32,12 +35,14 @@ public enum FlinkDevelopmentMode {
private final Integer mode;
- FlinkDevelopmentMode(String name, Integer mode) {
+ FlinkDevelopmentMode(@Nonnull String name, @Nonnull Integer mode) {
this.name = name;
this.mode = mode;
}
- public static FlinkDevelopmentMode of(Integer value) {
+ /** switch param use this, can't be null */
+ @Nullable
+ public static FlinkDevelopmentMode of(@Nullable Integer value) {
for (FlinkDevelopmentMode flinkDevelopmentMode : values()) {
if (flinkDevelopmentMode.mode.equals(value)) {
return flinkDevelopmentMode;
@@ -46,6 +51,7 @@ public enum FlinkDevelopmentMode {
return null;
}
+ @Nonnull
public Integer getMode() {
return mode;
}
diff --git
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkExecutionMode.java
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkExecutionMode.java
index 47632bca5..5a373dc1f 100644
---
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkExecutionMode.java
+++
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkExecutionMode.java
@@ -19,6 +19,9 @@ package org.apache.streampark.common.enums;
import com.google.common.collect.Lists;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
import java.util.List;
public enum FlinkExecutionMode {
@@ -48,12 +51,14 @@ public enum FlinkExecutionMode {
private final String name;
- FlinkExecutionMode(Integer mode, String name) {
+ FlinkExecutionMode(@Nonnull Integer mode, @Nonnull String name) {
this.mode = mode;
this.name = name;
}
- public static FlinkExecutionMode of(Integer value) {
+ /** switch param use this, can't be null */
+ @Nullable
+ public static FlinkExecutionMode of(@Nullable Integer value) {
for (FlinkExecutionMode mode : values()) {
if (mode.mode.equals(value)) {
return mode;
@@ -62,7 +67,7 @@ public enum FlinkExecutionMode {
return null;
}
- public static FlinkExecutionMode of(String name) {
+ public static FlinkExecutionMode of(@Nullable String name) {
for (FlinkExecutionMode mode : values()) {
if (mode.name.equals(name)) {
return mode;
@@ -75,58 +80,60 @@ public enum FlinkExecutionMode {
return mode;
}
+ @Nonnull
public String getName() {
return name;
}
- public static boolean isYarnMode(FlinkExecutionMode mode) {
+ public static boolean isYarnMode(@Nullable FlinkExecutionMode mode) {
return YARN_PER_JOB == mode || YARN_APPLICATION == mode || YARN_SESSION ==
mode;
}
// TODO: We'll inline this method back to the corresponding caller lines
// after dropping the yarn perjob mode.
- public static boolean isYarnPerJobOrAppMode(FlinkExecutionMode mode) {
+ public static boolean isYarnPerJobOrAppMode(@Nullable FlinkExecutionMode
mode) {
return YARN_PER_JOB == mode || YARN_APPLICATION == mode;
}
- public static boolean isYarnSessionMode(FlinkExecutionMode mode) {
+ public static boolean isYarnSessionMode(@Nullable FlinkExecutionMode mode) {
return YARN_SESSION == mode;
}
- public static boolean isYarnMode(Integer value) {
+ public static boolean isYarnMode(@Nullable Integer value) {
return isYarnMode(of(value));
}
- public static boolean isKubernetesSessionMode(Integer value) {
+ public static boolean isKubernetesSessionMode(@Nullable Integer value) {
return KUBERNETES_NATIVE_SESSION == of(value);
}
- public static boolean isKubernetesMode(FlinkExecutionMode mode) {
+ public static boolean isKubernetesMode(@Nullable FlinkExecutionMode mode) {
return KUBERNETES_NATIVE_SESSION == mode || KUBERNETES_NATIVE_APPLICATION
== mode;
}
- public static boolean isKubernetesMode(Integer value) {
+ public static boolean isKubernetesMode(@Nullable Integer value) {
return isKubernetesMode(of(value));
}
- public static boolean isKubernetesApplicationMode(Integer value) {
+ public static boolean isKubernetesApplicationMode(@Nullable Integer value) {
return KUBERNETES_NATIVE_APPLICATION == of(value);
}
+ @Nonnull
public static List<Integer> getKubernetesMode() {
return Lists.newArrayList(
KUBERNETES_NATIVE_SESSION.getMode(),
KUBERNETES_NATIVE_APPLICATION.getMode());
}
- public static boolean isSessionMode(FlinkExecutionMode mode) {
+ public static boolean isSessionMode(@Nullable FlinkExecutionMode mode) {
return KUBERNETES_NATIVE_SESSION == mode || YARN_SESSION == mode;
}
- public static boolean isRemoteMode(Integer value) {
+ public static boolean isRemoteMode(@Nullable Integer value) {
return isRemoteMode(of(value));
}
- public static boolean isRemoteMode(FlinkExecutionMode mode) {
+ public static boolean isRemoteMode(@Nullable FlinkExecutionMode mode) {
return REMOTE == mode;
}
}
diff --git
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkK8sRestExposedType.java
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkK8sRestExposedType.java
index c87c5a3a6..c1fec9616 100644
---
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkK8sRestExposedType.java
+++
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkK8sRestExposedType.java
@@ -17,6 +17,9 @@
package org.apache.streampark.common.enums;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
/** kubernetes.rest-service.exposed.type */
public enum FlinkK8sRestExposedType {
@@ -33,12 +36,13 @@ public enum FlinkK8sRestExposedType {
private final Integer type;
- FlinkK8sRestExposedType(String name, Integer type) {
+ FlinkK8sRestExposedType(@Nonnull String name, @Nonnull Integer type) {
this.name = name;
this.type = type;
}
- public static FlinkK8sRestExposedType of(Integer value) {
+ @Nullable
+ public static FlinkK8sRestExposedType of(@Nullable Integer value) {
for (FlinkK8sRestExposedType order : values()) {
if (order.type.equals(value)) {
return order;
@@ -47,10 +51,12 @@ public enum FlinkK8sRestExposedType {
return null;
}
+ @Nonnull
public String getName() {
return name;
}
+ @Nonnull
public Integer getType() {
return type;
}
diff --git
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkRestoreMode.java
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkRestoreMode.java
index ae88a4216..025c12fd6 100644
---
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkRestoreMode.java
+++
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkRestoreMode.java
@@ -17,6 +17,9 @@
package org.apache.streampark.common.enums;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
import java.util.Objects;
public enum FlinkRestoreMode {
@@ -55,11 +58,13 @@ public enum FlinkRestoreMode {
this.mode = mode;
}
+ @Nonnull
public String getName() {
return this.toString();
}
- public static FlinkRestoreMode of(Integer value) {
+ @Nullable
+ public static FlinkRestoreMode of(@Nullable Integer value) {
for (FlinkRestoreMode flinkRestoreModeEnum : values()) {
if (Objects.equals(flinkRestoreModeEnum.mode, value)) {
return flinkRestoreModeEnum;
diff --git
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkSqlValidationFailedType.java
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkSqlValidationFailedType.java
index 6f9b8a067..8f750455b 100644
---
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkSqlValidationFailedType.java
+++
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkSqlValidationFailedType.java
@@ -17,6 +17,8 @@
package org.apache.streampark.common.enums;
+import javax.annotation.Nullable;
+
public enum FlinkSqlValidationFailedType {
/** Basic test failed (such as null, etc.) */
@@ -40,6 +42,7 @@ public enum FlinkSqlValidationFailedType {
this.failedType = failedType;
}
+ @Nullable
public static FlinkSqlValidationFailedType of(Integer value) {
for (FlinkSqlValidationFailedType type : values()) {
if (type.failedType == value) {
diff --git
a/streampark-common/src/main/java/org/apache/streampark/common/enums/ResolveOrder.java
b/streampark-common/src/main/java/org/apache/streampark/common/enums/ResolveOrder.java
index e69823e27..ed800bc0a 100644
---
a/streampark-common/src/main/java/org/apache/streampark/common/enums/ResolveOrder.java
+++
b/streampark-common/src/main/java/org/apache/streampark/common/enums/ResolveOrder.java
@@ -17,6 +17,9 @@
package org.apache.streampark.common.enums;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
/** classloader.resolve-order */
public enum ResolveOrder {
@@ -30,12 +33,13 @@ public enum ResolveOrder {
private final Integer order;
- ResolveOrder(String name, Integer order) {
+ ResolveOrder(@Nonnull String name, @Nonnull Integer order) {
this.name = name;
this.order = order;
}
- public static ResolveOrder of(Integer value) {
+ @Nullable
+ public static ResolveOrder of(@Nullable Integer value) {
for (ResolveOrder order : values()) {
if (order.order.equals(value)) {
return order;
@@ -44,10 +48,12 @@ public enum ResolveOrder {
return null;
}
+ @Nonnull
public String getName() {
return name;
}
+ @Nonnull
public Integer getOrder() {
return order;
}
diff --git
a/streampark-common/src/main/java/org/apache/streampark/common/enums/Semantic.java
b/streampark-common/src/main/java/org/apache/streampark/common/enums/Semantic.java
index f405f2818..655a9f85a 100644
---
a/streampark-common/src/main/java/org/apache/streampark/common/enums/Semantic.java
+++
b/streampark-common/src/main/java/org/apache/streampark/common/enums/Semantic.java
@@ -17,6 +17,9 @@
package org.apache.streampark.common.enums;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
/** Flink consistency semantics */
public enum Semantic {
@@ -31,7 +34,8 @@ public enum Semantic {
/** After the fault occurs, the counting results may be lost. */
NONE;
- public static Semantic of(String name) {
+ @Nullable
+ public static Semantic of(@Nonnull String name) {
for (Semantic semantic : Semantic.values()) {
if (name.equals(semantic.name())) {
return semantic;
diff --git
a/streampark-common/src/main/java/org/apache/streampark/common/enums/StorageType.java
b/streampark-common/src/main/java/org/apache/streampark/common/enums/StorageType.java
index 11be2cbec..7fe57ae18 100644
---
a/streampark-common/src/main/java/org/apache/streampark/common/enums/StorageType.java
+++
b/streampark-common/src/main/java/org/apache/streampark/common/enums/StorageType.java
@@ -19,6 +19,9 @@ package org.apache.streampark.common.enums;
import org.apache.commons.lang3.StringUtils;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
public enum StorageType {
/** hdfs */
@@ -29,15 +32,17 @@ public enum StorageType {
private final String type;
- StorageType(String type) {
+ StorageType(@Nonnull String type) {
this.type = type;
}
+ @Nonnull
public String getType() {
return type;
}
- public static StorageType of(String identifier) {
+ @Nonnull
+ public static StorageType of(@Nullable String identifier) {
if (StringUtils.isBlank(identifier)) {
return LFS;
}
diff --git
a/streampark-common/src/main/java/org/apache/streampark/common/util/ExceptionUtils.java
b/streampark-common/src/main/java/org/apache/streampark/common/util/ExceptionUtils.java
index 712686493..43d897f8e 100644
---
a/streampark-common/src/main/java/org/apache/streampark/common/util/ExceptionUtils.java
+++
b/streampark-common/src/main/java/org/apache/streampark/common/util/ExceptionUtils.java
@@ -17,6 +17,9 @@
package org.apache.streampark.common.util;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -26,7 +29,8 @@ public class ExceptionUtils {
private ExceptionUtils() {}
- public static String stringifyException(Throwable throwable) {
+ @Nonnull
+ public static String stringifyException(@Nullable Throwable throwable) {
if (throwable == null) {
return "(null)";
}