Skip to content

Commit

Permalink
Remove install_usercode_dependencies from java instance main (apach…
Browse files Browse the repository at this point in the history
…e#2768)

`installUserCodeDependencies` is only valid for python instance; and python and java have different behaviors on
handling command args. so remove it from java instance to avoid confusion and problems
  • Loading branch information
sijie authored Oct 11, 2018
1 parent 04bd8bd commit a51e6d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ public class JavaInstanceMain implements AutoCloseable {
@Parameter(names = "--expected_healthcheck_interval", description = "Expected interval in seconds between healtchecks", required = true)
protected int expectedHealthCheckInterval;

@Parameter(names = "--install_usercode_dependencies", description = "Do we need to explictly install any user code dependencies(Does not apply to Java", required = false)
protected Boolean installUsercodeDependencies;

private Server server;
private RuntimeSpawner runtimeSpawner;
private ThreadRuntimeFactory containerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public static List<String> composeArgs(InstanceConfig instanceConfig,
args.add(logDirectory);
args.add("--logging_file");
args.add(instanceConfig.getFunctionDetails().getName());
// `installUserCodeDependencies` is only valid for python runtime
if (installUserCodeDepdendencies != null && installUserCodeDepdendencies) {
args.add("--install_usercode_dependencies");
args.add("True");
}
// TODO:- Find a platform independent way of controlling memory for a python application
}
args.add("--instance_id");
Expand Down Expand Up @@ -131,10 +136,6 @@ && isNotBlank(authConfig.getClientAuthenticationParameters())) {
}
args.add("--expected_healthcheck_interval");
args.add(String.valueOf(expectedHealthCheckInterval));
if (installUserCodeDepdendencies != null && installUserCodeDepdendencies) {
args.add("--install_usercode_dependencies");
args.add("True");
}
return args;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void testJavaConstructor() throws Exception {

KubernetesRuntime container = factory.createContainer(config, userJarFile, userJarFile, 30l);
List<String> args = container.getProcessArgs();
assertEquals(args.size(), 30);
assertEquals(args.size(), 28);
String expectedArgs = "java -cp " + javaInstanceJarFile
+ " -Dpulsar.functions.java.instance.jar=" + javaInstanceJarFile
+ " -Dlog4j.configurationFile=/pulsar/conf/log4j2.yaml "
Expand All @@ -135,7 +135,7 @@ public void testJavaConstructor() throws Exception {
+ "' --pulsar_serviceurl " + pulsarServiceUrl
+ " --max_buffered_tuples 1024 --port " + args.get(23)
+ " --state_storage_serviceurl " + stateStorageServiceUrl
+ " --expected_healthcheck_interval -1 --install_usercode_dependencies True";
+ " --expected_healthcheck_interval -1";
assertEquals(String.join(" ", args), expectedArgs);
}

Expand All @@ -147,14 +147,17 @@ public void testPythonConstructor() throws Exception {
List<String> args = container.getProcessArgs();
assertEquals(args.size(), 26);
String expectedArgs = "python " + pythonInstanceFile
+ " --py " + pulsarRootDir + "/" + userJarFile + " --logging_directory "
+ logDirectory + " --logging_file " + config.getFunctionDetails().getName() + " --instance_id "
+ "$SHARD_ID" + " --function_id " + config.getFunctionId()
+ " --py " + pulsarRootDir + "/" + userJarFile
+ " --logging_directory " + logDirectory
+ " --logging_file " + config.getFunctionDetails().getName()
+ " --install_usercode_dependencies True"
+ " --instance_id " + "$SHARD_ID"
+ " --function_id " + config.getFunctionId()
+ " --function_version " + config.getFunctionVersion()
+ " --function_details '" + JsonFormat.printer().omittingInsignificantWhitespace().print(config.getFunctionDetails())
+ "' --pulsar_serviceurl " + pulsarServiceUrl
+ " --max_buffered_tuples 1024 --port " + args.get(21)
+ " --expected_healthcheck_interval -1 --install_usercode_dependencies True";
+ " --max_buffered_tuples 1024 --port " + args.get(23)
+ " --expected_healthcheck_interval -1";
assertEquals(String.join(" ", args), expectedArgs);
}

Expand Down

0 comments on commit a51e6d1

Please sign in to comment.