-
Notifications
You must be signed in to change notification settings - Fork 991
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
13 changed files
with
342 additions
and
410 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
56 changes: 56 additions & 0 deletions
56
streampark-common/src/main/java/org/apache/streampark/common/enums/ApplicationType.java
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,56 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.streampark.common.enums; | ||
|
||
import java.io.Serializable; | ||
|
||
public enum ApplicationType implements Serializable { | ||
/** StreamPark Flink */ | ||
STREAMPARK_FLINK(1, "StreamPark Flink"), | ||
/** Apache Flink */ | ||
APACHE_FLINK(2, "Apache Flink"), | ||
/** StreamPark Spark */ | ||
STREAMPARK_SPARK(3, "StreamPark Spark"), | ||
/** Apache Spark */ | ||
APACHE_SPARK(4, "Apache Spark"); | ||
|
||
private final int type; | ||
private final String name; | ||
|
||
ApplicationType(int type, String name) { | ||
this.type = type; | ||
this.name = name; | ||
} | ||
|
||
public int getType() { | ||
return type; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public static ApplicationType of(int type) { | ||
for (ApplicationType appType : ApplicationType.values()) { | ||
if (appType.getType() == type) { | ||
return appType; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
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
121 changes: 121 additions & 0 deletions
121
streampark-common/src/main/java/org/apache/streampark/common/enums/ExecutionMode.java
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,121 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.streampark.common.enums; | ||
|
||
import com.google.common.collect.Lists; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
public enum ExecutionMode implements Serializable { | ||
|
||
/** Local mode */ | ||
LOCAL(0, "local"), | ||
/** remote */ | ||
REMOTE(1, "remote"), | ||
/** yarn-per-job mode */ | ||
YARN_PER_JOB(2, "yarn-per-job"), | ||
/** yarn session */ | ||
YARN_SESSION(3, "yarn-session"), | ||
/** yarn application */ | ||
YARN_APPLICATION(4, "yarn-application"), | ||
/** kubernetes session */ | ||
KUBERNETES_NATIVE_SESSION(5, "kubernetes-session"), | ||
/** kubernetes application */ | ||
KUBERNETES_NATIVE_APPLICATION(6, "kubernetes-application"); | ||
|
||
private final Integer mode; | ||
|
||
private final String name; | ||
|
||
ExecutionMode(Integer mode, String name) { | ||
this.mode = mode; | ||
this.name = name; | ||
} | ||
|
||
public static ExecutionMode of(Integer value) { | ||
for (ExecutionMode executionMode : values()) { | ||
if (executionMode.mode.equals(value)) { | ||
return executionMode; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public static ExecutionMode of(String name) { | ||
for (ExecutionMode executionMode : values()) { | ||
if (executionMode.name.equals(name)) { | ||
return executionMode; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public int getMode() { | ||
return mode; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public static boolean isYarnMode(ExecutionMode mode) { | ||
return YARN_PER_JOB.equals(mode) || YARN_APPLICATION.equals(mode) || YARN_SESSION.equals(mode); | ||
} | ||
|
||
public static boolean isYarnSessionMode(ExecutionMode mode) { | ||
return YARN_SESSION.equals(mode); | ||
} | ||
|
||
public static boolean isYarnMode(Integer value) { | ||
return isYarnMode(of(value)); | ||
} | ||
|
||
public static boolean isKubernetesSessionMode(Integer value) { | ||
return KUBERNETES_NATIVE_SESSION.equals(of(value)); | ||
} | ||
|
||
public static boolean isKubernetesMode(ExecutionMode mode) { | ||
return KUBERNETES_NATIVE_SESSION.equals(mode) || KUBERNETES_NATIVE_APPLICATION.equals(mode); | ||
} | ||
|
||
public static boolean isKubernetesMode(Integer value) { | ||
return isKubernetesMode(of(value)); | ||
} | ||
|
||
public static boolean isKubernetesApplicationMode(Integer value) { | ||
return KUBERNETES_NATIVE_APPLICATION.equals(of(value)); | ||
} | ||
|
||
public static List<Integer> getKubernetesMode() { | ||
return Lists.newArrayList( | ||
KUBERNETES_NATIVE_SESSION.getMode(), KUBERNETES_NATIVE_APPLICATION.getMode()); | ||
} | ||
|
||
public static boolean isSessionMode(ExecutionMode mode) { | ||
return KUBERNETES_NATIVE_SESSION.equals(mode) || YARN_SESSION.equals(mode); | ||
} | ||
|
||
public static boolean isRemoteMode(Integer value) { | ||
return isRemoteMode(of(value)); | ||
} | ||
|
||
public static boolean isRemoteMode(ExecutionMode mode) { | ||
return REMOTE.equals(mode); | ||
} | ||
} |
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
Oops, something went wrong.