void mergePreferThis(ServiceSettings other) { Arrays.stream(getClass().getDeclaredMethods()).forEach(m -> { m.setAccessible(true); if (!m.getName().startsWith("get")) { return; } String setterName = "s" + m.getName().substring(1); Method s; try { s = getClass().getDeclaredMethod(setterName, m.getReturnType()); } catch (NoSuchMethodException e) { return; } try { Object oThis = m.invoke(this); Object oOther = m.invoke(other); if (oThis == null) { s.invoke(this, oOther); } } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException("Unable to merge service settings: " + e.getMessage(), e); } finally { m.setAccessible(false); } }); Map<String, String> fullEnvironment = new HashMap<>(other.getEnv()); fullEnvironment.putAll(this.getEnv()); this.setEnv(fullEnvironment); }
void mergePreferThis(ServiceSettings other) { Arrays.stream(getClass().getDeclaredMethods()).forEach(m -> { m.setAccessible(true); if (!m.getName().startsWith("get")) { return; } String setterName = "s" + m.getName().substring(1); Method s; try { s = getClass().getDeclaredMethod(setterName, m.getReturnType()); } catch (NoSuchMethodException e) { return; } try { Object oThis = m.invoke(this); Object oOther = m.invoke(other); if (oThis == null) { s.invoke(this, oOther); } } catch (IllegalAccessException | InvocationTargetException e) { throw new RuntimeException("Unable to merge service settings: " + e.getMessage(), e); } finally { m.setAccessible(false); } }); Map<String, String> fullEnvironment = new HashMap<>(other.getEnv()); fullEnvironment.putAll(this.getEnv()); this.setEnv(fullEnvironment); }
)); env.putAll(settings.getEnv());
}).collect(Collectors.toList()); env.putAll(settings.getEnv());
env.putAll(thisServiceSettings.getEnv());
env.putAll(thisServiceSettings.getEnv());
default ServiceSettings buildServiceSettings(DeploymentConfiguration deploymentConfiguration) { KubernetesSharedServiceSettings kubernetesSharedServiceSettings = new KubernetesSharedServiceSettings(deploymentConfiguration); ServiceSettings settings = defaultServiceSettings(deploymentConfiguration); String location = kubernetesSharedServiceSettings.getDeployLocation(); settings.setAddress(buildAddress(location)) .setArtifactId(getArtifactId(deploymentConfiguration.getName())) .setLocation(location) .setEnabled(isEnabled(deploymentConfiguration)); if (runsOnJvm()) { // Use half the available memory allocated to the container for the JVM heap settings.getEnv().put("JAVA_OPTS", "-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=2"); } return settings; }
default ServiceSettings buildServiceSettings(DeploymentConfiguration deploymentConfiguration) { KubernetesSharedServiceSettings kubernetesSharedServiceSettings = new KubernetesSharedServiceSettings(deploymentConfiguration); ServiceSettings settings = defaultServiceSettings(deploymentConfiguration); String location = kubernetesSharedServiceSettings.getDeployLocation(); settings.setAddress(buildAddress(location)) .setArtifactId(getArtifactId(deploymentConfiguration.getName())) .setLocation(location) .setEnabled(isEnabled(deploymentConfiguration)); if (runsOnJvm()) { // Use half the available memory allocated to the container for the JVM heap settings.getEnv().put("JAVA_OPTS", "-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=2"); } return settings; }
static Container buildContainer(String name, ServiceSettings settings, List<ConfigSource> configSources, DeploymentEnvironment deploymentEnvironment) { int port = settings.getPort(); List<EnvVar> envVars = settings.getEnv().entrySet().stream().map(e -> { EnvVarBuilder envVarBuilder = new EnvVarBuilder(); return envVarBuilder.withName(e.getKey()).withValue(e.getValue()).build();
static Container buildContainer(String name, ServiceSettings settings, List<ConfigSource> configSources, DeploymentEnvironment deploymentEnvironment) { int port = settings.getPort(); List<EnvVar> envVars = settings.getEnv().entrySet().stream().map(e -> { EnvVarBuilder envVarBuilder = new EnvVarBuilder(); return envVarBuilder.withName(e.getKey()).withValue(e.getValue()).build();
settings.getEnv().forEach((k, v) -> { KubernetesEnvVar envVar = new KubernetesEnvVar(); envVar.setName(k);
settings.getEnv().forEach((k, v) -> { KubernetesEnvVar envVar = new KubernetesEnvVar(); envVar.setName(k);