use of com.aws.greengrass.componentmanager.KernelConfigResolver.CONFIGURATION_CONFIG_KEY in project aws-greengrass-nucleus by aws-greengrass.
the class DeviceConfiguration method persistInitialLaunchParams.
/**
* Persist initial launch parameters of JVM options.
*
* @param kernelAlts KernelAlternatives instance
*/
void persistInitialLaunchParams(KernelAlternatives kernelAlts) {
if (Files.exists(kernelAlts.getLaunchParamsPath())) {
logger.atDebug().log("Nucleus launch parameters has already been set up");
return;
}
// Persist initial Nucleus launch parameters
try {
String jvmOptions = ManagementFactory.getRuntimeMXBean().getInputArguments().stream().sorted().filter(s -> !s.startsWith(JVM_OPTION_ROOT_PATH)).collect(Collectors.joining(" "));
kernel.getConfig().lookup(SERVICES_NAMESPACE_TOPIC, getNucleusComponentName(), CONFIGURATION_CONFIG_KEY, DEVICE_PARAM_JVM_OPTIONS).withNewerValue(DEFAULT_VALUE_TIMESTAMP + 1, jvmOptions);
kernelAlts.writeLaunchParamsToFile(jvmOptions);
logger.atInfo().log("Successfully setup Nucleus launch parameters");
} catch (IOException e) {
logger.atError().log("Unable to setup Nucleus launch parameters", e);
}
}
use of com.aws.greengrass.componentmanager.KernelConfigResolver.CONFIGURATION_CONFIG_KEY in project aws-greengrass-nucleus by aws-greengrass.
the class AuthorizationPolicyParser method parseAllAuthorizationPolicies.
/**
* Given a kernel object, construct and return a map of AuthorizationPolicy objects that may exist,
* grouped into lists of the same destination component.
* This is used only upon kernel startup, to initialize all policies.
* Never returns null.
*
* @param kernel Kernel
* @return {@Map} of {@String} keys and {@List} of {@AuthorizationPolicy}'s as values"
*/
public Map<String, List<AuthorizationPolicy>> parseAllAuthorizationPolicies(Kernel kernel) {
Map<String, List<AuthorizationPolicy>> primaryAuthorizationPolicyMap = new HashMap<>();
Topics allServices = kernel.getConfig().findTopics(SERVICES_NAMESPACE_TOPIC);
if (allServices == null) {
logger.atWarn("load-authorization-all-services-component-config-retrieval-error").log("Unable to retrieve services config");
return primaryAuthorizationPolicyMap;
}
// For each component
for (Node service : allServices) {
if (service == null) {
continue;
}
if (!(service instanceof Topics)) {
continue;
}
Topics serviceConfig = (Topics) service;
String componentName = Kernel.findServiceForNode(serviceConfig);
Node accessControlMapTopic = serviceConfig.findNode(CONFIGURATION_CONFIG_KEY, ACCESS_CONTROL_NAMESPACE_TOPIC);
if (accessControlMapTopic == null) {
continue;
}
// Retrieve all policies, mapped to each policy type
Map<String, List<AuthorizationPolicy>> componentAuthorizationPolicyMap = parseAllPoliciesForComponent(accessControlMapTopic, componentName);
// For each policy type (e.g. aws.greengrass.ipc.pubsub)
for (Map.Entry<String, List<AuthorizationPolicy>> policyTypeList : componentAuthorizationPolicyMap.entrySet()) {
String policyType = policyTypeList.getKey();
List<AuthorizationPolicy> policyList = policyTypeList.getValue();
// If multiple components have policies for the same policy type
primaryAuthorizationPolicyMap.computeIfAbsent(policyType, k -> new ArrayList<>()).addAll(policyList);
}
}
return primaryAuthorizationPolicyMap;
}
use of com.aws.greengrass.componentmanager.KernelConfigResolver.CONFIGURATION_CONFIG_KEY in project aws-greengrass-nucleus by aws-greengrass.
the class DeploymentActivator method createDeploymentMergeBehavior.
protected UpdateBehaviorTree createDeploymentMergeBehavior(long deploymentTimestamp, Map<String, Object> newConfig) {
// root: MERGE
// services: MERGE
// *: REPLACE
// runtime: MERGE
// _private: MERGE
// configuration: REPLACE with deployment timestamp
// AUTH_TOKEN: MERGE
long now = System.currentTimeMillis();
UpdateBehaviorTree rootMergeBehavior = new UpdateBehaviorTree(UpdateBehaviorTree.UpdateBehavior.MERGE, now);
UpdateBehaviorTree servicesMergeBehavior = new UpdateBehaviorTree(UpdateBehaviorTree.UpdateBehavior.MERGE, now);
UpdateBehaviorTree insideServiceMergeBehavior = new UpdateBehaviorTree(UpdateBehaviorTree.UpdateBehavior.REPLACE, now);
UpdateBehaviorTree serviceRuntimeMergeBehavior = new UpdateBehaviorTree(UpdateBehaviorTree.UpdateBehavior.MERGE, now);
UpdateBehaviorTree servicePrivateMergeBehavior = new UpdateBehaviorTree(UpdateBehaviorTree.UpdateBehavior.MERGE, now);
rootMergeBehavior.getChildOverride().put(SERVICES_NAMESPACE_TOPIC, servicesMergeBehavior);
servicesMergeBehavior.getChildOverride().put(UpdateBehaviorTree.WILDCARD, insideServiceMergeBehavior);
servicesMergeBehavior.getChildOverride().put(AUTHENTICATION_TOKEN_LOOKUP_KEY, new UpdateBehaviorTree(UpdateBehaviorTree.UpdateBehavior.MERGE, now));
// Set merge mode for all builtin services
kernel.orderedDependencies().stream().filter(GreengrassService::isBuiltin).filter(s -> !((Map) newConfig.get(SERVICES_NAMESPACE_TOPIC)).containsKey(s.getServiceName())).forEach(s -> servicesMergeBehavior.getChildOverride().put(s.getServiceName(), new UpdateBehaviorTree(UpdateBehaviorTree.UpdateBehavior.MERGE, now)));
insideServiceMergeBehavior.getChildOverride().put(GreengrassService.RUNTIME_STORE_NAMESPACE_TOPIC, serviceRuntimeMergeBehavior);
insideServiceMergeBehavior.getChildOverride().put(GreengrassService.PRIVATE_STORE_NAMESPACE_TOPIC, servicePrivateMergeBehavior);
UpdateBehaviorTree serviceConfigurationMergeBehavior = new UpdateBehaviorTree(UpdateBehaviorTree.UpdateBehavior.REPLACE, deploymentTimestamp);
insideServiceMergeBehavior.getChildOverride().put(CONFIGURATION_CONFIG_KEY, serviceConfigurationMergeBehavior);
return rootMergeBehavior;
}
Aggregations