Skip to content

Commit 6dd9776

Browse files
authored
[flink] Fix MultipleParameterTool ClassNotFoundException in tiering service (#2063)
1 parent 71d00e4 commit 6dd9776

File tree

8 files changed

+218
-2
lines changed

8 files changed

+218
-2
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.fluss.flink.adapter;
19+
20+
/** Test for {@link MultipleParameterToolAdapter} in flink 1.18. */
21+
public class Flink118MultipleParameterToolTest extends FlinkMultipleParameterToolTest {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.fluss.flink.adapter;
19+
20+
/** Test for {@link MultipleParameterToolAdapter} in flink 1.19. */
21+
public class Flink119MultipleParameterToolTest extends FlinkMultipleParameterToolTest {}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.fluss.flink.adapter;
19+
20+
/** Test for {@link MultipleParameterToolAdapter} in flink 1.20. */
21+
public class Flink120MultipleParameterToolTest extends FlinkMultipleParameterToolTest {}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.fluss.flink.adapter;
19+
20+
import org.apache.flink.util.MultipleParameterTool;
21+
22+
import java.util.Map;
23+
24+
/**
25+
* An adapter for Flink {@link MultipleParameterTool} class. The {@link MultipleParameterTool} is
26+
* moved to a new package since Flink 2.x, so this adapter helps to bridge compatibility for
27+
* different Flink versions.
28+
*
29+
* <p>TODO: remove this class when no longer support all the Flink 1.x series.
30+
*/
31+
public class MultipleParameterToolAdapter {
32+
33+
private MultipleParameterToolAdapter() {}
34+
35+
private MultipleParameterTool multipleParameterTool;
36+
37+
public static MultipleParameterToolAdapter fromArgs(String[] args) {
38+
MultipleParameterToolAdapter adapter = new MultipleParameterToolAdapter();
39+
adapter.multipleParameterTool = MultipleParameterTool.fromArgs(args);
40+
return adapter;
41+
}
42+
43+
public Map<String, String> toMap() {
44+
return this.multipleParameterTool.toMap();
45+
}
46+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.fluss.flink.adapter;
19+
20+
/** Test for {@link MultipleParameterToolAdapter} in flink 2.1. */
21+
public class Flink21MultipleParameterToolTest extends FlinkMultipleParameterToolTest {}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.fluss.flink.adapter;
19+
20+
import org.apache.flink.api.java.utils.MultipleParameterTool;
21+
22+
import java.util.Map;
23+
24+
/**
25+
* An adapter for Flink {@link MultipleParameterTool} class. The {@link MultipleParameterTool} is
26+
* moved to a new package since Flink 2.x, so this adapter helps to bridge compatibility for
27+
* different Flink versions.
28+
*
29+
* <p>TODO: remove this class when no longer support all the Flink 1.x series.
30+
*/
31+
public class MultipleParameterToolAdapter {
32+
33+
private MultipleParameterToolAdapter() {}
34+
35+
private MultipleParameterTool multipleParameterTool;
36+
37+
public static MultipleParameterToolAdapter fromArgs(String[] args) {
38+
MultipleParameterToolAdapter adapter = new MultipleParameterToolAdapter();
39+
adapter.multipleParameterTool = MultipleParameterTool.fromArgs(args);
40+
return adapter;
41+
}
42+
43+
public Map<String, String> toMap() {
44+
return this.multipleParameterTool.toMap();
45+
}
46+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.fluss.flink.adapter;
19+
20+
import org.junit.jupiter.api.Test;
21+
22+
import static org.assertj.core.api.Assertions.assertThat;
23+
24+
/** Test for {@link MultipleParameterToolAdapter}. */
25+
abstract class FlinkMultipleParameterToolTest {
26+
27+
@Test
28+
public void testToMap() {
29+
String[] args =
30+
new String[] {
31+
"--multi1", "multiValue1", "--multi2", "multiValue2", "--multi1", "multiValue3"
32+
};
33+
34+
MultipleParameterToolAdapter adapter = MultipleParameterToolAdapter.fromArgs(args);
35+
36+
// The last value is used.
37+
assertThat(adapter.toMap()).containsEntry("multi1", "multiValue3");
38+
assertThat(adapter.toMap()).containsEntry("multi2", "multiValue2");
39+
}
40+
}

fluss-flink/fluss-flink-tiering/src/main/java/org/apache/fluss/flink/tiering/FlussLakeTieringEntrypoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
import org.apache.fluss.config.ConfigOptions;
2121
import org.apache.fluss.config.Configuration;
22+
import org.apache.fluss.flink.adapter.MultipleParameterToolAdapter;
2223

23-
import org.apache.flink.api.java.utils.MultipleParameterTool;
2424
import org.apache.flink.configuration.JobManagerOptions;
2525
import org.apache.flink.core.execution.JobClient;
2626
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
@@ -39,7 +39,7 @@ public class FlussLakeTieringEntrypoint {
3939
public static void main(String[] args) throws Exception {
4040

4141
// parse params
42-
final MultipleParameterTool params = MultipleParameterTool.fromArgs(args);
42+
final MultipleParameterToolAdapter params = MultipleParameterToolAdapter.fromArgs(args);
4343
Map<String, String> paramsMap = params.toMap();
4444

4545
// extract fluss config

0 commit comments

Comments
 (0)