Class RuntimeUtils
java.lang.Object
org.apache.pulsar.functions.runtime.RuntimeUtils
Util class for common runtime functionality.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncomposeCmd(org.apache.pulsar.functions.instance.InstanceConfig instanceConfig, String instanceFile, String extraDependenciesDir, String logDirectory, String originalCodeFileName, String pulsarServiceUrl, String stateStorageServiceUrl, org.apache.pulsar.functions.instance.AuthenticationConfig authConfig, String shardId, Integer grpcPort, Long expectedHealthCheckInterval, String logConfigFile, String secretsProviderClassName, String secretsProviderConfig, Boolean installUserCodeDependencies, String pythonDependencyRepository, String pythonExtraDependencyRepository, String narExtractionDirectory, String functionInstanceClassPath, String pulsarWebServiceUrl) static StringgenFunctionLogFolder(String logDirectory, org.apache.pulsar.functions.instance.InstanceConfig instanceConfig) getArgsBeforeCmd(org.apache.pulsar.functions.instance.InstanceConfig instanceConfig, String extraDependenciesDir) getCmd(org.apache.pulsar.functions.instance.InstanceConfig instanceConfig, String instanceFile, String extraDependenciesDir, String logDirectory, String originalCodeFileName, String pulsarServiceUrl, String stateStorageServiceUrl, org.apache.pulsar.functions.instance.AuthenticationConfig authConfig, String shardId, Integer grpcPort, Long expectedHealthCheckInterval, String logConfigFile, String secretsProviderClassName, String secretsProviderConfig, Boolean installUserCodeDependencies, String pythonDependencyRepository, String pythonExtraDependencyRepository, String narExtractionDirectory, String functionInstanceClassPath, boolean k8sRuntime, String pulsarWebServiceUrl) getGoInstanceCmd(org.apache.pulsar.functions.instance.InstanceConfig instanceConfig, String originalCodeFileName, String pulsarServiceUrl, boolean k8sRuntime) Different from python and java function, Go function uploads a complete executable file(including: instance file + user code file).static StringgetPrometheusMetrics(int metricsPort) static <T> TgetRuntimeFunctionConfig(Map<String, Object> configMap, Class<T> functionRuntimeConfigClass) static voidregisterDefaultCollectors(org.apache.pulsar.functions.instance.stats.FunctionCollectorRegistry registry) static String[]splitRuntimeArgs(String input) Regex for splitting a string using space when not surrounded by single or double quotes.
-
Field Details
-
FUNCTIONS_INSTANCE_CLASSPATH
- See Also:
-
-
Constructor Details
-
RuntimeUtils
public RuntimeUtils()
-
-
Method Details
-
composeCmd
public static List<String> composeCmd(org.apache.pulsar.functions.instance.InstanceConfig instanceConfig, String instanceFile, String extraDependenciesDir, String logDirectory, String originalCodeFileName, String pulsarServiceUrl, String stateStorageServiceUrl, org.apache.pulsar.functions.instance.AuthenticationConfig authConfig, String shardId, Integer grpcPort, Long expectedHealthCheckInterval, String logConfigFile, String secretsProviderClassName, String secretsProviderConfig, Boolean installUserCodeDependencies, String pythonDependencyRepository, String pythonExtraDependencyRepository, String narExtractionDirectory, String functionInstanceClassPath, String pulsarWebServiceUrl) throws Exception - Throws:
Exception
-
getArgsBeforeCmd
-
getGoInstanceCmd
public static List<String> getGoInstanceCmd(org.apache.pulsar.functions.instance.InstanceConfig instanceConfig, String originalCodeFileName, String pulsarServiceUrl, boolean k8sRuntime) throws IOException Different from python and java function, Go function uploads a complete executable file(including: instance file + user code file). Its parameter list is provided to the broker in the form of a yaml file, the advantage of this approach is that backward compatibility is guaranteed. In Java and Python the instance is managed by broker (or function worker) so the changes in command line is under control; but in Go the instance is compiled with the user function, so pulsar doesn't have the control what instance is used in the function. Hence in order to support BC for go function, we can't dynamically add more commandline arguments. Using an instance config to pass the parameters from function worker to go instance is the best way for maintaining the BC.When we run the go function, we only need to specify the location of the go-function file and the yaml file. The content of the yaml file will be automatically generated according to the content provided by instanceConfig.
- Throws:
IOException
-
getCmd
public static List<String> getCmd(org.apache.pulsar.functions.instance.InstanceConfig instanceConfig, String instanceFile, String extraDependenciesDir, String logDirectory, String originalCodeFileName, String pulsarServiceUrl, String stateStorageServiceUrl, org.apache.pulsar.functions.instance.AuthenticationConfig authConfig, String shardId, Integer grpcPort, Long expectedHealthCheckInterval, String logConfigFile, String secretsProviderClassName, String secretsProviderConfig, Boolean installUserCodeDependencies, String pythonDependencyRepository, String pythonExtraDependencyRepository, String narExtractionDirectory, String functionInstanceClassPath, boolean k8sRuntime, String pulsarWebServiceUrl) throws Exception - Throws:
Exception
-
genFunctionLogFolder
-
getPrometheusMetrics
- Throws:
IOException
-
splitRuntimeArgs
Regex for splitting a string using space when not surrounded by single or double quotes. -
getRuntimeFunctionConfig
-
registerDefaultCollectors
public static void registerDefaultCollectors(org.apache.pulsar.functions.instance.stats.FunctionCollectorRegistry registry)
-