@Test public void getGoInstanceCmd() throws IOException { InstanceConfig instanceConfig = new InstanceConfig(); instanceConfig.setClusterName("kluster"); instanceConfig.setInstanceId(3000); instanceConfig.setFunctionId("func-7734"); instanceConfig.setFunctionVersion("1.0.0"); instanceConfig.setMaxBufferedTuples(5); instanceConfig.setPort(1337); JSONObject userConfig = new JSONObject(); userConfig.put("word-of-the-day", "der Weltschmerz"); JSONObject secretsMap = new JSONObject(); secretsMap.put("secret", "cake is a lie"); Function.SourceSpec sources = Function.SourceSpec.newBuilder() .setCleanupSubscription(true) .setSubscriptionName("go-func-sub") .setTimeoutMs(500) .putInputSpecs("go-func-input", Function.ConsumerSpec.newBuilder().setIsRegexPattern(false).build()) .build(); Function.RetryDetails retryDetails = Function.RetryDetails.newBuilder() .setDeadLetterTopic("go-func-deadletter") .setMaxMessageRetries(1) .build(); Function.Resources resources = Function.Resources.newBuilder() .setCpu(2) .setDisk(1024) .setRam(32) .build(); Function.FunctionDetails functionDetails = Function.FunctionDetails.newBuilder() .setAutoAck(true) .setTenant("public") .setNamespace("default") .setName("go-func") .setLogTopic("go-func-log") .setProcessingGuarantees(Function.ProcessingGuarantees.ATLEAST_ONCE) .setSecretsMap(secretsMap.toJSONString()) .setParallelism(1) .setSource(sources) .setRetryDetails(retryDetails) .setResources(resources) .setUserConfig(userConfig.toJSONString()) .build(); instanceConfig.setFunctionDetails(functionDetails); List<String> commands = RuntimeUtils.getGoInstanceCmd(instanceConfig, "config", "pulsar: HashMap goInstanceConfig = new ObjectMapper().readValue(commands.get(2), HashMap.class); Assert.assertEquals(commands.toArray().length, 3); Assert.assertEquals(commands.get(0), "config"); Assert.assertEquals(commands.get(1), "-instance-conf"); Assert.assertEquals(goInstanceConfig.get("maxBufTuples"), 5); Assert.assertEquals(goInstanceConfig.get("maxMessageRetries"), 1); Assert.assertEquals(goInstanceConfig.get("killAfterIdleMs"), 0); Assert.assertEquals(goInstanceConfig.get("parallelism"), 1); Assert.assertEquals(goInstanceConfig.get("className"), ""); Assert.assertEquals(goInstanceConfig.get("sourceSpecsTopic"), "go-func-input"); Assert.assertEquals(goInstanceConfig.get("secretsMap"), secretsMap.toString()); Assert.assertEquals(goInstanceConfig.get("sourceSchemaType"), ""); Assert.assertEquals(goInstanceConfig.get("sinkSpecsTopic"), ""); Assert.assertEquals(goInstanceConfig.get("clusterName"), "kluster"); Assert.assertEquals(goInstanceConfig.get("nameSpace"), "default"); Assert.assertEquals(goInstanceConfig.get("receiverQueueSize"), 0); Assert.assertEquals(goInstanceConfig.get("tenant"), "public"); Assert.assertEquals(goInstanceConfig.get("ram"), 32); Assert.assertEquals(goInstanceConfig.get("logTopic"), "go-func-log"); Assert.assertEquals(goInstanceConfig.get("processingGuarantees"), 0); Assert.assertEquals(goInstanceConfig.get("autoAck"), true); Assert.assertEquals(goInstanceConfig.get("regexPatternSubscription"), false); Assert.assertEquals(goInstanceConfig.get("pulsarServiceURL"), "pulsar: Assert.assertEquals(goInstanceConfig.get("runtime"), 0); Assert.assertEquals(goInstanceConfig.get("cpu"), 2.0); Assert.assertEquals(goInstanceConfig.get("funcID"), "func-7734"); Assert.assertEquals(goInstanceConfig.get("funcVersion"), "1.0.0"); Assert.assertEquals(goInstanceConfig.get("disk"), 1024); Assert.assertEquals(goInstanceConfig.get("instanceID"), 3000); Assert.assertEquals(goInstanceConfig.get("cleanupSubscription"), true); Assert.assertEquals(goInstanceConfig.get("port"), 1337); Assert.assertEquals(goInstanceConfig.get("subscriptionType"), 0); Assert.assertEquals(goInstanceConfig.get("timeoutMs"), 500); Assert.assertEquals(goInstanceConfig.get("subscriptionName"), "go-func-sub"); Assert.assertEquals(goInstanceConfig.get("name"), "go-func"); Assert.assertEquals(goInstanceConfig.get("expectedHealthCheckInterval"), 0); Assert.assertEquals(goInstanceConfig.get("deadLetterTopic"), "go-func-deadletter"); Assert.assertEquals(goInstanceConfig.get("userConfig"), userConfig.toString()); }
public static List<String> getGoInstanceCmd(InstanceConfig instanceConfig, String originalCodeFileName, String pulsarServiceUrl) throws IOException { final List<String> args = new LinkedList<>(); GoInstanceConfig goInstanceConfig = new GoInstanceConfig(); if (instanceConfig.getClusterName() != null) { goInstanceConfig.setClusterName(instanceConfig.getClusterName()); } if (instanceConfig.getInstanceId() != 0) { goInstanceConfig.setInstanceID(instanceConfig.getInstanceId()); } if (instanceConfig.getFunctionId() != null) { goInstanceConfig.setFuncID(instanceConfig.getFunctionId()); } if (instanceConfig.getFunctionVersion() != null) { goInstanceConfig.setFuncVersion(instanceConfig.getFunctionVersion()); } if (instanceConfig.getFunctionDetails().getAutoAck()) { goInstanceConfig.setAutoAck(instanceConfig.getFunctionDetails().getAutoAck()); } if (instanceConfig.getFunctionDetails().getTenant() != null) { goInstanceConfig.setTenant(instanceConfig.getFunctionDetails().getTenant()); } if (instanceConfig.getFunctionDetails().getNamespace() != null) { goInstanceConfig.setNameSpace(instanceConfig.getFunctionDetails().getNamespace()); } if (instanceConfig.getFunctionDetails().getName() != null) { goInstanceConfig.setName(instanceConfig.getFunctionDetails().getName()); } if (instanceConfig.getFunctionDetails().getLogTopic() != null) { goInstanceConfig.setLogTopic(instanceConfig.getFunctionDetails().getLogTopic()); } if (instanceConfig.getFunctionDetails().getProcessingGuarantees() != null) { goInstanceConfig.setProcessingGuarantees(instanceConfig.getFunctionDetails().getProcessingGuaranteesValue()); } if (instanceConfig.getFunctionDetails().getSecretsMap() != null) { goInstanceConfig.setSecretsMap(instanceConfig.getFunctionDetails().getSecretsMap()); } if (instanceConfig.getFunctionDetails().getUserConfig() != null) { goInstanceConfig.setUserConfig(instanceConfig.getFunctionDetails().getUserConfig()); } if (instanceConfig.getFunctionDetails().getParallelism() != 0) { goInstanceConfig.setParallelism(instanceConfig.getFunctionDetails().getParallelism()); } if (instanceConfig.getMaxBufferedTuples() != 0) { goInstanceConfig.setMaxBufTuples(instanceConfig.getMaxBufferedTuples()); } if (pulsarServiceUrl != null) { goInstanceConfig.setPulsarServiceURL(pulsarServiceUrl); } if (instanceConfig.getFunctionDetails().getSource().getCleanupSubscription()) { goInstanceConfig.setCleanupSubscription(instanceConfig.getFunctionDetails().getSource().getCleanupSubscription()); } if (instanceConfig.getFunctionDetails().getSource().getSubscriptionName() != null) { goInstanceConfig.setSubscriptionName(instanceConfig.getFunctionDetails().getSource().getSubscriptionName()); } if (instanceConfig.getFunctionDetails().getSource().getInputSpecsMap() != null) { for (String inputTopic : instanceConfig.getFunctionDetails().getSource().getInputSpecsMap().keySet()) { goInstanceConfig.setSourceSpecsTopic(inputTopic); } } if (instanceConfig.getFunctionDetails().getSource().getTimeoutMs() != 0) { goInstanceConfig.setTimeoutMs(instanceConfig.getFunctionDetails().getSource().getTimeoutMs()); } if (instanceConfig.getFunctionDetails().getSink().getTopic() != null) { goInstanceConfig.setSinkSpecsTopic(instanceConfig.getFunctionDetails().getSink().getTopic()); } if (instanceConfig.getFunctionDetails().getResources().getCpu() != 0) { goInstanceConfig.setCpu(instanceConfig.getFunctionDetails().getResources().getCpu()); } if (instanceConfig.getFunctionDetails().getResources().getRam() != 0) { goInstanceConfig.setRam(instanceConfig.getFunctionDetails().getResources().getRam()); } if (instanceConfig.getFunctionDetails().getResources().getDisk() != 0) { goInstanceConfig.setDisk(instanceConfig.getFunctionDetails().getResources().getDisk()); } if (instanceConfig.getFunctionDetails().getRetryDetails().getDeadLetterTopic() != null) { goInstanceConfig.setDeadLetterTopic(instanceConfig.getFunctionDetails().getRetryDetails().getDeadLetterTopic()); } if (instanceConfig.getFunctionDetails().getRetryDetails().getMaxMessageRetries() != 0) { goInstanceConfig.setMaxMessageRetries(instanceConfig.getFunctionDetails().getRetryDetails().getMaxMessageRetries()); } goInstanceConfig.setKillAfterIdleMs(0); goInstanceConfig.setPort(instanceConfig.getPort()); ObjectMapper objectMapper = ObjectMapperFactory.getThreadLocal(); String configContent = objectMapper.writeValueAsString(goInstanceConfig); args.add(originalCodeFileName); args.add("-instance-conf"); args.add(configContent); return args; }
RuntimeUtils { public static List<String> getGoInstanceCmd(InstanceConfig instanceConfig, String originalCodeFileName, String pulsarServiceUrl) throws IOException { final List<String> args = new LinkedList<>(); GoInstanceConfig goInstanceConfig = new GoInstanceConfig(); if (instanceConfig.getClusterName() != null) { goInstanceConfig.setClusterName(instanceConfig.getClusterName()); } if (instanceConfig.getInstanceId() != 0) { goInstanceConfig.setInstanceID(instanceConfig.getInstanceId()); } if (instanceConfig.getFunctionId() != null) { goInstanceConfig.setFuncID(instanceConfig.getFunctionId()); } if (instanceConfig.getFunctionVersion() != null) { goInstanceConfig.setFuncVersion(instanceConfig.getFunctionVersion()); } if (instanceConfig.getFunctionDetails().getAutoAck()) { goInstanceConfig.setAutoAck(instanceConfig.getFunctionDetails().getAutoAck()); } if (instanceConfig.getFunctionDetails().getTenant() != null) { goInstanceConfig.setTenant(instanceConfig.getFunctionDetails().getTenant()); } if (instanceConfig.getFunctionDetails().getNamespace() != null) { goInstanceConfig.setNameSpace(instanceConfig.getFunctionDetails().getNamespace()); } if (instanceConfig.getFunctionDetails().getName() != null) { goInstanceConfig.setName(instanceConfig.getFunctionDetails().getName()); } if (instanceConfig.getFunctionDetails().getLogTopic() != null) { goInstanceConfig.setLogTopic(instanceConfig.getFunctionDetails().getLogTopic()); } if (instanceConfig.getFunctionDetails().getProcessingGuarantees() != null) { goInstanceConfig.setProcessingGuarantees(instanceConfig.getFunctionDetails().getProcessingGuaranteesValue()); } if (instanceConfig.getFunctionDetails().getSecretsMap() != null) { goInstanceConfig.setSecretsMap(instanceConfig.getFunctionDetails().getSecretsMap()); } if (instanceConfig.getFunctionDetails().getUserConfig() != null) { goInstanceConfig.setUserConfig(instanceConfig.getFunctionDetails().getUserConfig()); } if (instanceConfig.getFunctionDetails().getParallelism() != 0) { goInstanceConfig.setParallelism(instanceConfig.getFunctionDetails().getParallelism()); } if (instanceConfig.getMaxBufferedTuples() != 0) { goInstanceConfig.setMaxBufTuples(instanceConfig.getMaxBufferedTuples()); } if (pulsarServiceUrl != null) { goInstanceConfig.setPulsarServiceURL(pulsarServiceUrl); } if (instanceConfig.getFunctionDetails().getSource().getCleanupSubscription()) { goInstanceConfig.setCleanupSubscription(instanceConfig.getFunctionDetails().getSource().getCleanupSubscription()); } if (instanceConfig.getFunctionDetails().getSource().getSubscriptionName() != null) { goInstanceConfig.setSubscriptionName(instanceConfig.getFunctionDetails().getSource().getSubscriptionName()); } if (instanceConfig.getFunctionDetails().getSource().getInputSpecsMap() != null) { for (String inputTopic : instanceConfig.getFunctionDetails().getSource().getInputSpecsMap().keySet()) { goInstanceConfig.setSourceSpecsTopic(inputTopic); } } if (instanceConfig.getFunctionDetails().getSource().getTimeoutMs() != 0) { goInstanceConfig.setTimeoutMs(instanceConfig.getFunctionDetails().getSource().getTimeoutMs()); } if (instanceConfig.getFunctionDetails().getSink().getTopic() != null) { goInstanceConfig.setSinkSpecsTopic(instanceConfig.getFunctionDetails().getSink().getTopic()); } if (instanceConfig.getFunctionDetails().getResources().getCpu() != 0) { goInstanceConfig.setCpu(instanceConfig.getFunctionDetails().getResources().getCpu()); } if (instanceConfig.getFunctionDetails().getResources().getRam() != 0) { goInstanceConfig.setRam(instanceConfig.getFunctionDetails().getResources().getRam()); } if (instanceConfig.getFunctionDetails().getResources().getDisk() != 0) { goInstanceConfig.setDisk(instanceConfig.getFunctionDetails().getResources().getDisk()); } if (instanceConfig.getFunctionDetails().getRetryDetails().getDeadLetterTopic() != null) { goInstanceConfig.setDeadLetterTopic(instanceConfig.getFunctionDetails().getRetryDetails().getDeadLetterTopic()); } if (instanceConfig.getFunctionDetails().getRetryDetails().getMaxMessageRetries() != 0) { goInstanceConfig.setMaxMessageRetries(instanceConfig.getFunctionDetails().getRetryDetails().getMaxMessageRetries()); } goInstanceConfig.setKillAfterIdleMs(0); goInstanceConfig.setPort(instanceConfig.getPort()); ObjectMapper objectMapper = ObjectMapperFactory.getThreadLocal(); String configContent = objectMapper.writeValueAsString(goInstanceConfig); args.add(originalCodeFileName); args.add("-instance-conf"); args.add(configContent); return args; } }
RuntimeUtils { public static List<String> getGoInstanceCmd(InstanceConfig instanceConfig, String originalCodeFileName, String pulsarServiceUrl) throws IOException { final List<String> args = new LinkedList<>(); GoInstanceConfig goInstanceConfig = new GoInstanceConfig(); if (instanceConfig.getClusterName() != null) { goInstanceConfig.setClusterName(instanceConfig.getClusterName()); } if (instanceConfig.getInstanceId() != 0) { goInstanceConfig.setInstanceID(instanceConfig.getInstanceId()); } if (instanceConfig.getFunctionId() != null) { goInstanceConfig.setFuncID(instanceConfig.getFunctionId()); } if (instanceConfig.getFunctionVersion() != null) { goInstanceConfig.setFuncVersion(instanceConfig.getFunctionVersion()); } if (instanceConfig.getFunctionDetails().getAutoAck()) { goInstanceConfig.setAutoAck(instanceConfig.getFunctionDetails().getAutoAck()); } if (instanceConfig.getFunctionDetails().getTenant() != null) { goInstanceConfig.setTenant(instanceConfig.getFunctionDetails().getTenant()); } if (instanceConfig.getFunctionDetails().getNamespace() != null) { goInstanceConfig.setNameSpace(instanceConfig.getFunctionDetails().getNamespace()); } if (instanceConfig.getFunctionDetails().getName() != null) { goInstanceConfig.setName(instanceConfig.getFunctionDetails().getName()); } if (instanceConfig.getFunctionDetails().getLogTopic() != null) { goInstanceConfig.setLogTopic(instanceConfig.getFunctionDetails().getLogTopic()); } if (instanceConfig.getFunctionDetails().getProcessingGuarantees() != null) { goInstanceConfig.setProcessingGuarantees(instanceConfig.getFunctionDetails().getProcessingGuaranteesValue()); } if (instanceConfig.getFunctionDetails().getSecretsMap() != null) { goInstanceConfig.setSecretsMap(instanceConfig.getFunctionDetails().getSecretsMap()); } if (instanceConfig.getFunctionDetails().getUserConfig() != null) { goInstanceConfig.setUserConfig(instanceConfig.getFunctionDetails().getUserConfig()); } if (instanceConfig.getFunctionDetails().getParallelism() != 0) { goInstanceConfig.setParallelism(instanceConfig.getFunctionDetails().getParallelism()); } if (instanceConfig.getMaxBufferedTuples() != 0) { goInstanceConfig.setMaxBufTuples(instanceConfig.getMaxBufferedTuples()); } if (pulsarServiceUrl != null) { goInstanceConfig.setPulsarServiceURL(pulsarServiceUrl); } if (instanceConfig.getFunctionDetails().getSource().getCleanupSubscription()) { goInstanceConfig.setCleanupSubscription(instanceConfig.getFunctionDetails().getSource().getCleanupSubscription()); } if (instanceConfig.getFunctionDetails().getSource().getSubscriptionName() != null) { goInstanceConfig.setSubscriptionName(instanceConfig.getFunctionDetails().getSource().getSubscriptionName()); } if (instanceConfig.getFunctionDetails().getSource().getInputSpecsMap() != null) { for (String inputTopic : instanceConfig.getFunctionDetails().getSource().getInputSpecsMap().keySet()) { goInstanceConfig.setSourceSpecsTopic(inputTopic); } } if (instanceConfig.getFunctionDetails().getSource().getTimeoutMs() != 0) { goInstanceConfig.setTimeoutMs(instanceConfig.getFunctionDetails().getSource().getTimeoutMs()); } if (instanceConfig.getFunctionDetails().getSink().getTopic() != null) { goInstanceConfig.setSinkSpecsTopic(instanceConfig.getFunctionDetails().getSink().getTopic()); } if (instanceConfig.getFunctionDetails().getResources().getCpu() != 0) { goInstanceConfig.setCpu(instanceConfig.getFunctionDetails().getResources().getCpu()); } if (instanceConfig.getFunctionDetails().getResources().getRam() != 0) { goInstanceConfig.setRam(instanceConfig.getFunctionDetails().getResources().getRam()); } if (instanceConfig.getFunctionDetails().getResources().getDisk() != 0) { goInstanceConfig.setDisk(instanceConfig.getFunctionDetails().getResources().getDisk()); } if (instanceConfig.getFunctionDetails().getRetryDetails().getDeadLetterTopic() != null) { goInstanceConfig.setDeadLetterTopic(instanceConfig.getFunctionDetails().getRetryDetails().getDeadLetterTopic()); } if (instanceConfig.getFunctionDetails().getRetryDetails().getMaxMessageRetries() != 0) { goInstanceConfig.setMaxMessageRetries(instanceConfig.getFunctionDetails().getRetryDetails().getMaxMessageRetries()); } goInstanceConfig.setKillAfterIdleMs(0); goInstanceConfig.setPort(instanceConfig.getPort()); ObjectMapper objectMapper = ObjectMapperFactory.getThreadLocal(); String configContent = objectMapper.writeValueAsString(goInstanceConfig); args.add(originalCodeFileName); args.add("-instance-conf"); args.add(configContent); return args; }  }
RuntimeUtils { public static List<String> getGoInstanceCmd(InstanceConfig instanceConfig, String originalCodeFileName, String pulsarServiceUrl) throws IOException { final List<String> args = new LinkedList<>(); GoInstanceConfig goInstanceConfig = new GoInstanceConfig(); if (instanceConfig.getClusterName() != null) { goInstanceConfig.setClusterName(instanceConfig.getClusterName()); } if (instanceConfig.getInstanceId() != 0) { goInstanceConfig.setInstanceID(instanceConfig.getInstanceId()); } if (instanceConfig.getFunctionId() != null) { goInstanceConfig.setFuncID(instanceConfig.getFunctionId()); } if (instanceConfig.getFunctionVersion() != null) { goInstanceConfig.setFuncVersion(instanceConfig.getFunctionVersion()); } if (instanceConfig.getFunctionDetails().getAutoAck()) { goInstanceConfig.setAutoAck(instanceConfig.getFunctionDetails().getAutoAck()); } if (instanceConfig.getFunctionDetails().getTenant() != null) { goInstanceConfig.setTenant(instanceConfig.getFunctionDetails().getTenant()); } if (instanceConfig.getFunctionDetails().getNamespace() != null) { goInstanceConfig.setNameSpace(instanceConfig.getFunctionDetails().getNamespace()); } if (instanceConfig.getFunctionDetails().getName() != null) { goInstanceConfig.setName(instanceConfig.getFunctionDetails().getName()); } if (instanceConfig.getFunctionDetails().getLogTopic() != null) { goInstanceConfig.setLogTopic(instanceConfig.getFunctionDetails().getLogTopic()); } if (instanceConfig.getFunctionDetails().getProcessingGuarantees() != null) { goInstanceConfig.setProcessingGuarantees(instanceConfig.getFunctionDetails().getProcessingGuaranteesValue()); } if (instanceConfig.getFunctionDetails().getSecretsMap() != null) { goInstanceConfig.setSecretsMap(instanceConfig.getFunctionDetails().getSecretsMap()); } if (instanceConfig.getFunctionDetails().getUserConfig() != null) { goInstanceConfig.setUserConfig(instanceConfig.getFunctionDetails().getUserConfig()); } if (instanceConfig.getFunctionDetails().getParallelism() != 0) { goInstanceConfig.setParallelism(instanceConfig.getFunctionDetails().getParallelism()); } if (instanceConfig.getMaxBufferedTuples() != 0) { goInstanceConfig.setMaxBufTuples(instanceConfig.getMaxBufferedTuples()); } if (pulsarServiceUrl != null) { goInstanceConfig.setPulsarServiceURL(pulsarServiceUrl); } if (instanceConfig.getFunctionDetails().getSource().getCleanupSubscription()) { goInstanceConfig.setCleanupSubscription(instanceConfig.getFunctionDetails().getSource().getCleanupSubscription()); } if (instanceConfig.getFunctionDetails().getSource().getSubscriptionName() != null) { goInstanceConfig.setSubscriptionName(instanceConfig.getFunctionDetails().getSource().getSubscriptionName()); } if (instanceConfig.getFunctionDetails().getSource().getInputSpecsMap() != null) { for (String inputTopic : instanceConfig.getFunctionDetails().getSource().getInputSpecsMap().keySet()) { goInstanceConfig.setSourceSpecsTopic(inputTopic); } } if (instanceConfig.getFunctionDetails().getSource().getTimeoutMs() != 0) { goInstanceConfig.setTimeoutMs(instanceConfig.getFunctionDetails().getSource().getTimeoutMs()); } if (instanceConfig.getFunctionDetails().getSink().getTopic() != null) { goInstanceConfig.setSinkSpecsTopic(instanceConfig.getFunctionDetails().getSink().getTopic()); } if (instanceConfig.getFunctionDetails().getResources().getCpu() != 0) { goInstanceConfig.setCpu(instanceConfig.getFunctionDetails().getResources().getCpu()); } if (instanceConfig.getFunctionDetails().getResources().getRam() != 0) { goInstanceConfig.setRam(instanceConfig.getFunctionDetails().getResources().getRam()); } if (instanceConfig.getFunctionDetails().getResources().getDisk() != 0) { goInstanceConfig.setDisk(instanceConfig.getFunctionDetails().getResources().getDisk()); } if (instanceConfig.getFunctionDetails().getRetryDetails().getDeadLetterTopic() != null) { goInstanceConfig.setDeadLetterTopic(instanceConfig.getFunctionDetails().getRetryDetails().getDeadLetterTopic()); } if (instanceConfig.getFunctionDetails().getRetryDetails().getMaxMessageRetries() != 0) { goInstanceConfig.setMaxMessageRetries(instanceConfig.getFunctionDetails().getRetryDetails().getMaxMessageRetries()); } goInstanceConfig.setKillAfterIdleMs(0); goInstanceConfig.setPort(instanceConfig.getPort()); ObjectMapper objectMapper = ObjectMapperFactory.getThreadLocal(); String configContent = objectMapper.writeValueAsString(goInstanceConfig); args.add(originalCodeFileName); args.add("-instance-conf"); args.add(configContent); return args; }  static List<String> composeCmd(InstanceConfig instanceConfig,
                                          String instanceFile,
                                          String extraDependenciesDir, /* extra dependencies for running instances */
                                          String logDirectory,
                                          String originalCodeFileName,
                                          String pulsarServiceUrl,
                                          String stateStorageServiceUrl,
                                          AuthenticationConfig authConfig,
                                          String shardId,
                                          Integer grpcPort,
                                          Long expectedHealthCheckInterval,
                                          String logConfigFile,
                                          String secretsProviderClassName,
                                          String secretsProviderConfig,
                                          Boolean installUserCodeDependencies,
                                          String pythonDependencyRepository,
                                          String pythonExtraDependencyRepository,
                                          int metricsPort,
                                          String narExtractionDirectory); static List<String> getArgsBeforeCmd(InstanceConfig instanceConfig, String extraDependenciesDir); static List<String> getGoInstanceCmd(InstanceConfig instanceConfig,
                                                String originalCodeFileName,
                                                String pulsarServiceUrl); static List<String> getCmd(InstanceConfig instanceConfig,
                                      String instanceFile,
                                      String extraDependenciesDir, /* extra dependencies for running instances */
                                      String logDirectory,
                                      String originalCodeFileName,
                                      String pulsarServiceUrl,
                                      String stateStorageServiceUrl,
                                      AuthenticationConfig authConfig,
                                      String shardId,
                                      Integer grpcPort,
                                      Long expectedHealthCheckInterval,
                                      String logConfigFile,
                                      String secretsProviderClassName,
                                      String secretsProviderConfig,
                                      Boolean installUserCodeDependencies,
                                      String pythonDependencyRepository,
                                      String pythonExtraDependencyRepository,
                                      int metricsPort,
                                      String narExtractionDirectory); static String genFunctionLogFolder(String logDirectory, InstanceConfig instanceConfig); static String getPrometheusMetrics(int metricsPort); static String[] splitRuntimeArgs(String input); static T getRuntimeFunctionConfig(Map<String, Object> configMap, Class<T> functionRuntimeConfigClass); }
RuntimeUtils { public static List<String> getGoInstanceCmd(InstanceConfig instanceConfig, String originalCodeFileName, String pulsarServiceUrl) throws IOException { final List<String> args = new LinkedList<>(); GoInstanceConfig goInstanceConfig = new GoInstanceConfig(); if (instanceConfig.getClusterName() != null) { goInstanceConfig.setClusterName(instanceConfig.getClusterName()); } if (instanceConfig.getInstanceId() != 0) { goInstanceConfig.setInstanceID(instanceConfig.getInstanceId()); } if (instanceConfig.getFunctionId() != null) { goInstanceConfig.setFuncID(instanceConfig.getFunctionId()); } if (instanceConfig.getFunctionVersion() != null) { goInstanceConfig.setFuncVersion(instanceConfig.getFunctionVersion()); } if (instanceConfig.getFunctionDetails().getAutoAck()) { goInstanceConfig.setAutoAck(instanceConfig.getFunctionDetails().getAutoAck()); } if (instanceConfig.getFunctionDetails().getTenant() != null) { goInstanceConfig.setTenant(instanceConfig.getFunctionDetails().getTenant()); } if (instanceConfig.getFunctionDetails().getNamespace() != null) { goInstanceConfig.setNameSpace(instanceConfig.getFunctionDetails().getNamespace()); } if (instanceConfig.getFunctionDetails().getName() != null) { goInstanceConfig.setName(instanceConfig.getFunctionDetails().getName()); } if (instanceConfig.getFunctionDetails().getLogTopic() != null) { goInstanceConfig.setLogTopic(instanceConfig.getFunctionDetails().getLogTopic()); } if (instanceConfig.getFunctionDetails().getProcessingGuarantees() != null) { goInstanceConfig.setProcessingGuarantees(instanceConfig.getFunctionDetails().getProcessingGuaranteesValue()); } if (instanceConfig.getFunctionDetails().getSecretsMap() != null) { goInstanceConfig.setSecretsMap(instanceConfig.getFunctionDetails().getSecretsMap()); } if (instanceConfig.getFunctionDetails().getUserConfig() != null) { goInstanceConfig.setUserConfig(instanceConfig.getFunctionDetails().getUserConfig()); } if (instanceConfig.getFunctionDetails().getParallelism() != 0) { goInstanceConfig.setParallelism(instanceConfig.getFunctionDetails().getParallelism()); } if (instanceConfig.getMaxBufferedTuples() != 0) { goInstanceConfig.setMaxBufTuples(instanceConfig.getMaxBufferedTuples()); } if (pulsarServiceUrl != null) { goInstanceConfig.setPulsarServiceURL(pulsarServiceUrl); } if (instanceConfig.getFunctionDetails().getSource().getCleanupSubscription()) { goInstanceConfig.setCleanupSubscription(instanceConfig.getFunctionDetails().getSource().getCleanupSubscription()); } if (instanceConfig.getFunctionDetails().getSource().getSubscriptionName() != null) { goInstanceConfig.setSubscriptionName(instanceConfig.getFunctionDetails().getSource().getSubscriptionName()); } if (instanceConfig.getFunctionDetails().getSource().getInputSpecsMap() != null) { for (String inputTopic : instanceConfig.getFunctionDetails().getSource().getInputSpecsMap().keySet()) { goInstanceConfig.setSourceSpecsTopic(inputTopic); } } if (instanceConfig.getFunctionDetails().getSource().getTimeoutMs() != 0) { goInstanceConfig.setTimeoutMs(instanceConfig.getFunctionDetails().getSource().getTimeoutMs()); } if (instanceConfig.getFunctionDetails().getSink().getTopic() != null) { goInstanceConfig.setSinkSpecsTopic(instanceConfig.getFunctionDetails().getSink().getTopic()); } if (instanceConfig.getFunctionDetails().getResources().getCpu() != 0) { goInstanceConfig.setCpu(instanceConfig.getFunctionDetails().getResources().getCpu()); } if (instanceConfig.getFunctionDetails().getResources().getRam() != 0) { goInstanceConfig.setRam(instanceConfig.getFunctionDetails().getResources().getRam()); } if (instanceConfig.getFunctionDetails().getResources().getDisk() != 0) { goInstanceConfig.setDisk(instanceConfig.getFunctionDetails().getResources().getDisk()); } if (instanceConfig.getFunctionDetails().getRetryDetails().getDeadLetterTopic() != null) { goInstanceConfig.setDeadLetterTopic(instanceConfig.getFunctionDetails().getRetryDetails().getDeadLetterTopic()); } if (instanceConfig.getFunctionDetails().getRetryDetails().getMaxMessageRetries() != 0) { goInstanceConfig.setMaxMessageRetries(instanceConfig.getFunctionDetails().getRetryDetails().getMaxMessageRetries()); } goInstanceConfig.setKillAfterIdleMs(0); goInstanceConfig.setPort(instanceConfig.getPort()); ObjectMapper objectMapper = ObjectMapperFactory.getThreadLocal(); String configContent = objectMapper.writeValueAsString(goInstanceConfig); args.add(originalCodeFileName); args.add("-instance-conf"); args.add(configContent); return args; }  static List<String> composeCmd(InstanceConfig instanceConfig,
                                          String instanceFile,
                                          String extraDependenciesDir, /* extra dependencies for running instances */
                                          String logDirectory,
                                          String originalCodeFileName,
                                          String pulsarServiceUrl,
                                          String stateStorageServiceUrl,
                                          AuthenticationConfig authConfig,
                                          String shardId,
                                          Integer grpcPort,
                                          Long expectedHealthCheckInterval,
                                          String logConfigFile,
                                          String secretsProviderClassName,
                                          String secretsProviderConfig,
                                          Boolean installUserCodeDependencies,
                                          String pythonDependencyRepository,
                                          String pythonExtraDependencyRepository,
                                          int metricsPort,
                                          String narExtractionDirectory); static List<String> getArgsBeforeCmd(InstanceConfig instanceConfig, String extraDependenciesDir); static List<String> getGoInstanceCmd(InstanceConfig instanceConfig,
                                                String originalCodeFileName,
                                                String pulsarServiceUrl); static List<String> getCmd(InstanceConfig instanceConfig,
                                      String instanceFile,
                                      String extraDependenciesDir, /* extra dependencies for running instances */
                                      String logDirectory,
                                      String originalCodeFileName,
                                      String pulsarServiceUrl,
                                      String stateStorageServiceUrl,
                                      AuthenticationConfig authConfig,
                                      String shardId,
                                      Integer grpcPort,
                                      Long expectedHealthCheckInterval,
                                      String logConfigFile,
                                      String secretsProviderClassName,
                                      String secretsProviderConfig,
                                      Boolean installUserCodeDependencies,
                                      String pythonDependencyRepository,
                                      String pythonExtraDependencyRepository,
                                      int metricsPort,
                                      String narExtractionDirectory); static String genFunctionLogFolder(String logDirectory, InstanceConfig instanceConfig); static String getPrometheusMetrics(int metricsPort); static String[] splitRuntimeArgs(String input); static T getRuntimeFunctionConfig(Map<String, Object> configMap, Class<T> functionRuntimeConfigClass); static final String FUNCTIONS_INSTANCE_CLASSPATH; }