Skip to content

Commit

Permalink
Standardize Code Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ailiujiarui committed Sep 25, 2024
1 parent f5c544d commit 82b5e91
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

package org.apache.dolphinscheduler.plugin.task.java;

import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;

import org.apache.commons.lang3.StringUtils;

import java.util.List;

import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;

import java.io.File;

import lombok.extern.slf4j.Slf4j;
import com.google.common.base.Preconditions;

import com.google.common.base.Preconditions;

@Slf4j
public class JavaTask extends AbstractTask {
Expand All @@ -57,7 +58,6 @@ public class JavaTask extends AbstractTask {
*/
private TaskExecutionContext taskRequest;


public JavaTask(TaskExecutionContext taskRequest) {
super(taskRequest);
this.taskRequest = taskRequest;
Expand Down Expand Up @@ -88,9 +88,11 @@ public void init() {
public void handle(TaskCallBack taskCallBack) throws TaskException {
try {
// Step 1: judge if is java or jar run type.
// Step 2 case1: the fat jar run type builds the command directly, adding resource to the java -jar class when
// Step 2 case1: the fat jar run type builds the command directly, adding resource to the java -jar class
// when
// building the command
// Step 2 case2: the normal jar run type builds the command directly, adding resource to the java -cp class when
// Step 2 case2: the normal jar run type builds the command directly, adding resource to the java -cp class
// when
// building the command
// Step 3: to run the command
String command = null;
Expand Down Expand Up @@ -129,7 +131,6 @@ public void handle(TaskCallBack taskCallBack) throws TaskException {
}
}


/**
* Construct a shell command for the java -jar Run mode
*
Expand All @@ -151,7 +152,6 @@ protected String buildJarCommand() {
return builder.toString();
}


/**
* Construct a shell command for the java -cp run mode
*
Expand All @@ -163,11 +163,10 @@ protected String buildNormalJarCommand() {
javaParameters.getMainJar()
.getResourceName())
.getResourceAbsolutePathInLocal();
String mainJarName=null;
try{
String mainJarName = null;
try {
mainJarName = MainClassExtractor.getMainClassName(mainJarAbsolutePathInLocal);
}
catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
StringBuilder builder = new StringBuilder();
Expand Down Expand Up @@ -220,7 +219,6 @@ protected String buildResourcePath() {
return builder.toString();
}


/**
* Gets the operating system absolute path to the Java command
*
Expand All @@ -230,5 +228,4 @@ private String getJavaCommandPath() {
return JAVA_HOME_VAR + File.separator + "bin" + File.separator;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.dolphinscheduler.plugin.task.java;

import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ public void buildJarCommand() {
@Test
public void buildNormalJarCommand() {
JavaTask javaTask = runNormalJarType();
try{
assertThat(javaTask.buildNormalJarCommand())
.isEqualTo("${JAVA_HOME}/bin/java -classpath .:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar:/tmp/dolphinscheduler/test/executepath/opt/share/jar/main.jar HelloWorldWithGuava -host 127.0.0.1 -port 8080 -xms:50m");
}
catch(Exception e){
try {
assertThat(javaTask.buildNormalJarCommand())
.isEqualTo(
"${JAVA_HOME}/bin/java -classpath .:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar:/tmp/dolphinscheduler/test/executepath/opt/share/jar/main.jar HelloWorldWithGuava -host 127.0.0.1 -port 8080 -xms:50m");
} catch (Exception e) {
e.printStackTrace();
}

Expand Down Expand Up @@ -99,7 +99,6 @@ public JavaParameters createNormalJarJavaParameters(String runType) {
return javaParameters;
}


/**
* Add the fat jar parameters
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import { useTaskNodeStore } from '@/store/project/task-node'
import utils from '@/utils'
import type { IJsonItem, ProgramType, IMainJar } from '../types'

export function useJavaTaskNormalJar(model: { [field: string]: any }): IJsonItem {
export function useJavaTaskNormalJar(model: {
[field: string]: any
}): IJsonItem {
const { t } = useI18n()
const mainJarOptions = ref([] as IMainJar[])
const taskStore = useTaskNodeStore()
Expand All @@ -42,7 +44,6 @@ export function useJavaTaskNormalJar(model: { [field: string]: any }): IJsonItem
taskStore.updateMainJar(programType, res)
}


onMounted(() => {
getMainJars(model.programType)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { useI18n } from 'vue-i18n'
import { useCustomParams, useResources, useJavaTaskMainJar } from '.'
import type { IJsonItem } from '../types'
import {useJavaTaskNormalJar} from "@/views/projects/task/components/node/fields/use-java-task-normal-jar";
import { useJavaTaskNormalJar } from '@/views/projects/task/components/node/fields/use-java-task-normal-jar'

export function useJava(model: { [field: string]: any }): IJsonItem[] {
const { t } = useI18n()
Expand Down Expand Up @@ -71,5 +71,4 @@ export const RUN_TYPES = [
label: 'NORMAL_JAR',
value: 'NORMAL_JAR'
}

]
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export function formatParams(data: INodeData): {
taskParams.mainArgs = data.mainArgs
taskParams.jvmArgs = data.jvmArgs
taskParams.isModulePath = data.isModulePath
if ((data.runType === 'FAT_JAR'||data.runType=== 'NORMAL_JAR') && data.mainJar) {
if (
(data.runType === 'FAT_JAR' || data.runType === 'NORMAL_JAR') &&
data.mainJar
) {
taskParams.mainJar = { resourceName: data.mainJar }
}
}
Expand Down

0 comments on commit 82b5e91

Please sign in to comment.