Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
6b6b52e8
Unverified
Commit
6b6b52e8
authored
Mar 20, 2024
by
Pandas886
Committed by
GitHub
Mar 20, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Optimization] optimization execute jar params parse (#3277)
Co-authored-by:
Pandas886
<
Pandas886@users.noreply.github.com
>
parent
8a9b5302
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
3 deletions
+89
-3
ExecuteJarOperation.java
...rc/main/java/org/dinky/trans/dml/ExecuteJarOperation.java
+29
-3
ExecuteJarOperationTest.java
...est/java/org/dinky/trans/dml/ExecuteJarOperationTest.java
+60
-0
No files found.
dinky-client/dinky-client-base/src/main/java/org/dinky/trans/dml/ExecuteJarOperation.java
View file @
6b6b52e8
...
...
@@ -23,9 +23,9 @@ import org.dinky.executor.CustomTableEnvironment;
import
org.dinky.trans.AbstractOperation
;
import
org.dinky.trans.ExtendOperation
;
import
org.dinky.trans.parse.ExecuteJarParseStrategy
;
import
org.dinky.utils.RunTimeUtil
;
import
org.dinky.utils.URLUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.flink.api.dag.Pipeline
;
import
org.apache.flink.client.program.PackagedProgram
;
import
org.apache.flink.client.program.PackagedProgramUtils
;
...
...
@@ -37,7 +37,10 @@ import org.apache.flink.table.api.TableResult;
import
java.io.File
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Optional
;
...
...
@@ -99,7 +102,7 @@ public class ExecuteJarOperation extends AbstractOperation implements ExtendOper
.
setEntryPointClassName
(
submitParam
.
getMainClass
())
.
setConfiguration
(
configuration
)
.
setSavepointRestoreSettings
(
savepointRestoreSettings
)
.
setArguments
(
RunTimeUtil
.
handleCmds
(
submitParam
.
getArgs
()
))
.
setArguments
(
extractArgs
(
submitParam
.
getArgs
().
trim
()).
toArray
(
new
String
[
0
]
))
.
setUserClassPaths
(
classpaths
)
.
build
();
int
parallelism
=
StrUtil
.
isNumeric
(
submitParam
.
getParallelism
())
...
...
@@ -114,6 +117,30 @@ public class ExecuteJarOperation extends AbstractOperation implements ExtendOper
}
}
public
static
List
<
String
>
extractArgs
(
String
args
)
{
List
<
String
>
programArgs
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotEmpty
(
args
))
{
String
[]
array
=
args
.
split
(
"\\s+"
);
Iterator
<
String
>
iter
=
Arrays
.
asList
(
array
).
iterator
();
while
(
iter
.
hasNext
())
{
String
v
=
iter
.
next
();
String
p
=
v
.
substring
(
0
,
1
);
if
(
p
.
equals
(
"'"
)
||
p
.
equals
(
"\""
))
{
String
value
=
v
;
if
(!
v
.
endsWith
(
p
))
{
while
(!
value
.
endsWith
(
p
)
&&
iter
.
hasNext
())
{
value
+=
" "
+
iter
.
next
();
}
}
programArgs
.
add
(
value
.
substring
(
1
,
value
.
length
()
-
1
));
}
else
{
programArgs
.
add
(
v
);
}
}
}
return
programArgs
;
}
@Override
public
String
asSummaryString
()
{
return
statement
;
...
...
@@ -142,7 +169,6 @@ public class ExecuteJarOperation extends AbstractOperation implements ExtendOper
public
static
JarSubmitParam
build
(
String
statement
)
{
JarSubmitParam
submitParam
=
ExecuteJarParseStrategy
.
getInfo
(
statement
);
Assert
.
notBlank
(
submitParam
.
getUri
());
Assert
.
notBlank
(
submitParam
.
getMainClass
());
return
submitParam
;
}
}
...
...
dinky-client/dinky-client-base/src/test/java/org/dinky/trans/dml/ExecuteJarOperationTest.java
0 → 100644
View file @
6b6b52e8
/*
*
* 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
.
dinky
.
trans
.
dml
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
java.util.List
;
import
org.junit.Assert
;
import
org.junit.jupiter.api.Test
;
import
com.google.common.collect.Lists
;
class
ExecuteJarOperationTest
{
public
static
final
List
<
String
>
RESULT1
=
Lists
.
newArrayList
(
"merge_into"
,
"--warehouse"
,
"hdfs:///tmp/paimon"
,
"--database"
,
"default"
,
"--table"
,
"T"
,
"--source_table"
,
"S"
,
"--on"
,
"T.id = S.order_id"
,
"--merge_actions"
,
"matched-upsert,matched-delete"
,
"--matched_upsert_condition"
,
"T.price > 100"
,
"--matched_upsert_set"
,
"mark = 'important'"
,
"--matched_delete_condition"
,
"T.price < 10"
);
@Test
void
extractArgs
()
{
List
<
String
>
args1
=
ExecuteJarOperation
.
extractArgs
(
"merge_into --warehouse hdfs:///tmp/paimon --database default --table T --source_table S --on \"T.id = S.order_id\" --merge_actions matched-upsert,matched-delete --matched_upsert_condition \"T.price > 100\" --matched_upsert_set \"mark = 'important'\" --matched_delete_condition \"T.price < 10\""
);
Assert
.
assertArrayEquals
(
args1
.
toArray
(
new
String
[
0
]),
RESULT1
.
toArray
(
new
String
[
0
]));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment