From a2feabbc29f8bbfd5a4f94f5c70f34117f3bbd1c Mon Sep 17 00:00:00 2001 From: saranyaloganathan23 Date: Mon, 12 Aug 2024 12:29:23 +0530 Subject: [PATCH 1/2] main class and main jar file changes --- src/jobs/submitJob.tsx | 64 +++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/src/jobs/submitJob.tsx b/src/jobs/submitJob.tsx index 8a6c3817..baf11c6d 100644 --- a/src/jobs/submitJob.tsx +++ b/src/jobs/submitJob.tsx @@ -495,26 +495,50 @@ function SubmitJob({ jarFileSelected: string[] | string, argumentSelected: string[] | string ) => { - return { - sparkJob: { - mainJarFileUri: mainClassSelected, - ...(propertyObject && { - properties: propertyObject - }), - ...(archieveFileSelected !== '' && { - archiveUris: archieveFileSelected - }), - ...(fileSelected !== '' && { - fileUris: [fileSelected] - }), - ...(jarFileSelected !== '' && { - jarFileUris: jarFileSelected - }), - ...(argumentSelected !== '' && { - args: argumentSelected - }) - } - }; + if(mainClassSelected.includes('.jar')){ + return { + sparkJob: { + mainJarFileUri: mainClassSelected, + ...(propertyObject && { + properties: propertyObject + }), + ...(archieveFileSelected !== '' && { + archiveUris: archieveFileSelected + }), + ...(fileSelected !== '' && { + fileUris: [fileSelected] + }), + ...(jarFileSelected !== '' && { + jarFileUris: jarFileSelected + }), + ...(argumentSelected !== '' && { + args: argumentSelected + }) + } + }; + } + else{ + return { + sparkJob: { + mainClass: mainClassSelected, + ...(propertyObject && { + properties: propertyObject + }), + ...(archieveFileSelected !== '' && { + archiveUris: archieveFileSelected + }), + ...(fileSelected !== '' && { + fileUris: [fileSelected] + }), + ...(jarFileSelected !== '' && { + jarFileUris: jarFileSelected + }), + ...(argumentSelected !== '' && { + args: argumentSelected + }) + } + }; + } }; const createSparkRPayload = ( From 07304179434a046e15ee8b4f645d14b7458214dc Mon Sep 17 00:00:00 2001 From: saranyaloganathan23 Date: Mon, 12 Aug 2024 14:56:08 +0530 Subject: [PATCH 2/2] code optimised --- src/jobs/submitJob.tsx | 65 ++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 44 deletions(-) diff --git a/src/jobs/submitJob.tsx b/src/jobs/submitJob.tsx index baf11c6d..0e403e83 100644 --- a/src/jobs/submitJob.tsx +++ b/src/jobs/submitJob.tsx @@ -495,50 +495,27 @@ function SubmitJob({ jarFileSelected: string[] | string, argumentSelected: string[] | string ) => { - if(mainClassSelected.includes('.jar')){ - return { - sparkJob: { - mainJarFileUri: mainClassSelected, - ...(propertyObject && { - properties: propertyObject - }), - ...(archieveFileSelected !== '' && { - archiveUris: archieveFileSelected - }), - ...(fileSelected !== '' && { - fileUris: [fileSelected] - }), - ...(jarFileSelected !== '' && { - jarFileUris: jarFileSelected - }), - ...(argumentSelected !== '' && { - args: argumentSelected - }) - } - }; - } - else{ - return { - sparkJob: { - mainClass: mainClassSelected, - ...(propertyObject && { - properties: propertyObject - }), - ...(archieveFileSelected !== '' && { - archiveUris: archieveFileSelected - }), - ...(fileSelected !== '' && { - fileUris: [fileSelected] - }), - ...(jarFileSelected !== '' && { - jarFileUris: jarFileSelected - }), - ...(argumentSelected !== '' && { - args: argumentSelected - }) - } - }; - } + const isJar = mainClassSelected.includes('.jar'); + return { + sparkJob: { + ...(isJar ? { mainJarFileUri: mainClassSelected } : { mainClass: mainClassSelected }), + ...(propertyObject && { + properties: propertyObject + }), + ...(archieveFileSelected !== '' && { + archiveUris: archieveFileSelected + }), + ...(fileSelected !== '' && { + fileUris: [fileSelected] + }), + ...(jarFileSelected !== '' && { + jarFileUris: jarFileSelected + }), + ...(argumentSelected !== '' && { + args: argumentSelected + }) + } + }; }; const createSparkRPayload = (