use of org.apache.pulsar.functions.runtime.RuntimeCustomizer in project incubator-pulsar by apache.
the class KubernetesRuntimeTest method createKubernetesRuntimeFactory.
KubernetesRuntimeFactory createKubernetesRuntimeFactory(String extraDepsDir, int percentMemoryPadding, double cpuOverCommitRatio, double memoryOverCommitRatio, String manifestCustomizerClassName, Map<String, Object> runtimeCustomizerConfig) throws Exception {
KubernetesRuntimeFactory factory = spy(new KubernetesRuntimeFactory());
doNothing().when(factory).setupClient();
WorkerConfig workerConfig = new WorkerConfig();
KubernetesRuntimeFactoryConfig kubernetesRuntimeFactoryConfig = new KubernetesRuntimeFactoryConfig();
kubernetesRuntimeFactoryConfig.setK8Uri(null);
kubernetesRuntimeFactoryConfig.setJobNamespace(null);
kubernetesRuntimeFactoryConfig.setJobName(null);
kubernetesRuntimeFactoryConfig.setPulsarDockerImageName(null);
kubernetesRuntimeFactoryConfig.setFunctionDockerImages(null);
kubernetesRuntimeFactoryConfig.setImagePullPolicy(null);
kubernetesRuntimeFactoryConfig.setPulsarRootDir(pulsarRootDir);
kubernetesRuntimeFactoryConfig.setSubmittingInsidePod(false);
kubernetesRuntimeFactoryConfig.setInstallUserCodeDependencies(true);
kubernetesRuntimeFactoryConfig.setPythonDependencyRepository("myrepo");
kubernetesRuntimeFactoryConfig.setPythonExtraDependencyRepository("anotherrepo");
kubernetesRuntimeFactoryConfig.setExtraFunctionDependenciesDir(extraDepsDir);
kubernetesRuntimeFactoryConfig.setCustomLabels(null);
kubernetesRuntimeFactoryConfig.setPercentMemoryPadding(percentMemoryPadding);
kubernetesRuntimeFactoryConfig.setCpuOverCommitRatio(cpuOverCommitRatio);
kubernetesRuntimeFactoryConfig.setMemoryOverCommitRatio(memoryOverCommitRatio);
kubernetesRuntimeFactoryConfig.setPulsarServiceUrl(pulsarServiceUrl);
kubernetesRuntimeFactoryConfig.setPulsarAdminUrl(pulsarAdminUrl);
kubernetesRuntimeFactoryConfig.setChangeConfigMapNamespace(null);
kubernetesRuntimeFactoryConfig.setChangeConfigMap(null);
kubernetesRuntimeFactoryConfig.setGrpcPort(4332);
kubernetesRuntimeFactoryConfig.setMetricsPort(4331);
kubernetesRuntimeFactoryConfig.setNarExtractionDirectory(narExtractionDirectory);
workerConfig.setFunctionRuntimeFactoryClassName(KubernetesRuntimeFactory.class.getName());
workerConfig.setFunctionRuntimeFactoryConfigs(ObjectMapperFactory.getThreadLocal().convertValue(kubernetesRuntimeFactoryConfig, Map.class));
workerConfig.setFunctionInstanceMinResources(null);
workerConfig.setStateStorageServiceUrl(stateStorageServiceUrl);
workerConfig.setAuthenticationEnabled(false);
workerConfig.setRuntimeCustomizerConfig(runtimeCustomizerConfig);
workerConfig.setRuntimeCustomizerClassName(manifestCustomizerClassName);
Optional<RuntimeCustomizer> manifestCustomizer = Optional.empty();
if (!org.apache.commons.lang3.StringUtils.isEmpty(workerConfig.getRuntimeCustomizerClassName())) {
manifestCustomizer = Optional.of(RuntimeCustomizer.getRuntimeCustomizer(workerConfig.getRuntimeCustomizerClassName()));
manifestCustomizer.get().initialize(Optional.ofNullable(workerConfig.getRuntimeCustomizerConfig()).orElse(Collections.emptyMap()));
}
factory.initialize(workerConfig, null, new TestSecretProviderConfigurator(), Mockito.mock(ConnectorsManager.class), Optional.empty(), manifestCustomizer);
return factory;
}
use of org.apache.pulsar.functions.runtime.RuntimeCustomizer in project pulsar by yahoo.
the class KubernetesRuntimeTest method createKubernetesRuntimeFactory.
KubernetesRuntimeFactory createKubernetesRuntimeFactory(String extraDepsDir, int percentMemoryPadding, double cpuOverCommitRatio, double memoryOverCommitRatio, String manifestCustomizerClassName, Map<String, Object> runtimeCustomizerConfig) throws Exception {
KubernetesRuntimeFactory factory = spy(new KubernetesRuntimeFactory());
doNothing().when(factory).setupClient();
WorkerConfig workerConfig = new WorkerConfig();
KubernetesRuntimeFactoryConfig kubernetesRuntimeFactoryConfig = new KubernetesRuntimeFactoryConfig();
kubernetesRuntimeFactoryConfig.setK8Uri(null);
kubernetesRuntimeFactoryConfig.setJobNamespace(null);
kubernetesRuntimeFactoryConfig.setJobName(null);
kubernetesRuntimeFactoryConfig.setPulsarDockerImageName(null);
kubernetesRuntimeFactoryConfig.setFunctionDockerImages(null);
kubernetesRuntimeFactoryConfig.setImagePullPolicy(null);
kubernetesRuntimeFactoryConfig.setPulsarRootDir(pulsarRootDir);
kubernetesRuntimeFactoryConfig.setSubmittingInsidePod(false);
kubernetesRuntimeFactoryConfig.setInstallUserCodeDependencies(true);
kubernetesRuntimeFactoryConfig.setPythonDependencyRepository("myrepo");
kubernetesRuntimeFactoryConfig.setPythonExtraDependencyRepository("anotherrepo");
kubernetesRuntimeFactoryConfig.setExtraFunctionDependenciesDir(extraDepsDir);
kubernetesRuntimeFactoryConfig.setCustomLabels(null);
kubernetesRuntimeFactoryConfig.setPercentMemoryPadding(percentMemoryPadding);
kubernetesRuntimeFactoryConfig.setCpuOverCommitRatio(cpuOverCommitRatio);
kubernetesRuntimeFactoryConfig.setMemoryOverCommitRatio(memoryOverCommitRatio);
kubernetesRuntimeFactoryConfig.setPulsarServiceUrl(pulsarServiceUrl);
kubernetesRuntimeFactoryConfig.setPulsarAdminUrl(pulsarAdminUrl);
kubernetesRuntimeFactoryConfig.setChangeConfigMapNamespace(null);
kubernetesRuntimeFactoryConfig.setChangeConfigMap(null);
kubernetesRuntimeFactoryConfig.setGrpcPort(4332);
kubernetesRuntimeFactoryConfig.setMetricsPort(4331);
kubernetesRuntimeFactoryConfig.setNarExtractionDirectory(narExtractionDirectory);
workerConfig.setFunctionRuntimeFactoryClassName(KubernetesRuntimeFactory.class.getName());
workerConfig.setFunctionRuntimeFactoryConfigs(ObjectMapperFactory.getThreadLocal().convertValue(kubernetesRuntimeFactoryConfig, Map.class));
workerConfig.setFunctionInstanceMinResources(null);
workerConfig.setStateStorageServiceUrl(stateStorageServiceUrl);
workerConfig.setAuthenticationEnabled(false);
workerConfig.setRuntimeCustomizerConfig(runtimeCustomizerConfig);
workerConfig.setRuntimeCustomizerClassName(manifestCustomizerClassName);
Optional<RuntimeCustomizer> manifestCustomizer = Optional.empty();
if (!org.apache.commons.lang3.StringUtils.isEmpty(workerConfig.getRuntimeCustomizerClassName())) {
manifestCustomizer = Optional.of(RuntimeCustomizer.getRuntimeCustomizer(workerConfig.getRuntimeCustomizerClassName()));
manifestCustomizer.get().initialize(Optional.ofNullable(workerConfig.getRuntimeCustomizerConfig()).orElse(Collections.emptyMap()));
}
factory.initialize(workerConfig, null, new TestSecretProviderConfigurator(), Mockito.mock(ConnectorsManager.class), Optional.empty(), manifestCustomizer);
return factory;
}
use of org.apache.pulsar.functions.runtime.RuntimeCustomizer in project pulsar by apache.
the class KubernetesRuntimeTest method createKubernetesRuntimeFactory.
KubernetesRuntimeFactory createKubernetesRuntimeFactory(String extraDepsDir, int percentMemoryPadding, double cpuOverCommitRatio, double memoryOverCommitRatio, String manifestCustomizerClassName, Map<String, Object> runtimeCustomizerConfig) throws Exception {
KubernetesRuntimeFactory factory = spy(new KubernetesRuntimeFactory());
doNothing().when(factory).setupClient();
WorkerConfig workerConfig = new WorkerConfig();
KubernetesRuntimeFactoryConfig kubernetesRuntimeFactoryConfig = new KubernetesRuntimeFactoryConfig();
kubernetesRuntimeFactoryConfig.setK8Uri(null);
kubernetesRuntimeFactoryConfig.setJobNamespace(null);
kubernetesRuntimeFactoryConfig.setJobName(null);
kubernetesRuntimeFactoryConfig.setPulsarDockerImageName(null);
kubernetesRuntimeFactoryConfig.setFunctionDockerImages(null);
kubernetesRuntimeFactoryConfig.setImagePullPolicy(null);
kubernetesRuntimeFactoryConfig.setPulsarRootDir(pulsarRootDir);
kubernetesRuntimeFactoryConfig.setSubmittingInsidePod(false);
kubernetesRuntimeFactoryConfig.setInstallUserCodeDependencies(true);
kubernetesRuntimeFactoryConfig.setPythonDependencyRepository("myrepo");
kubernetesRuntimeFactoryConfig.setPythonExtraDependencyRepository("anotherrepo");
kubernetesRuntimeFactoryConfig.setExtraFunctionDependenciesDir(extraDepsDir);
kubernetesRuntimeFactoryConfig.setCustomLabels(null);
kubernetesRuntimeFactoryConfig.setPercentMemoryPadding(percentMemoryPadding);
kubernetesRuntimeFactoryConfig.setCpuOverCommitRatio(cpuOverCommitRatio);
kubernetesRuntimeFactoryConfig.setMemoryOverCommitRatio(memoryOverCommitRatio);
kubernetesRuntimeFactoryConfig.setPulsarServiceUrl(pulsarServiceUrl);
kubernetesRuntimeFactoryConfig.setPulsarAdminUrl(pulsarAdminUrl);
kubernetesRuntimeFactoryConfig.setChangeConfigMapNamespace(null);
kubernetesRuntimeFactoryConfig.setChangeConfigMap(null);
kubernetesRuntimeFactoryConfig.setGrpcPort(4332);
kubernetesRuntimeFactoryConfig.setMetricsPort(4331);
kubernetesRuntimeFactoryConfig.setNarExtractionDirectory(narExtractionDirectory);
workerConfig.setFunctionRuntimeFactoryClassName(KubernetesRuntimeFactory.class.getName());
workerConfig.setFunctionRuntimeFactoryConfigs(ObjectMapperFactory.getThreadLocal().convertValue(kubernetesRuntimeFactoryConfig, Map.class));
workerConfig.setFunctionInstanceMinResources(null);
workerConfig.setStateStorageServiceUrl(stateStorageServiceUrl);
workerConfig.setAuthenticationEnabled(false);
workerConfig.setRuntimeCustomizerConfig(runtimeCustomizerConfig);
workerConfig.setRuntimeCustomizerClassName(manifestCustomizerClassName);
Optional<RuntimeCustomizer> manifestCustomizer = Optional.empty();
if (!org.apache.commons.lang3.StringUtils.isEmpty(workerConfig.getRuntimeCustomizerClassName())) {
manifestCustomizer = Optional.of(RuntimeCustomizer.getRuntimeCustomizer(workerConfig.getRuntimeCustomizerClassName()));
manifestCustomizer.get().initialize(Optional.ofNullable(workerConfig.getRuntimeCustomizerConfig()).orElse(Collections.emptyMap()));
}
factory.initialize(workerConfig, null, new TestSecretProviderConfigurator(), Mockito.mock(ConnectorsManager.class), Optional.empty(), manifestCustomizer);
return factory;
}
Aggregations