Search in sources :

Example 1 with KernelConfigResolver

use of com.aws.greengrass.componentmanager.KernelConfigResolver in project aws-greengrass-nucleus by aws-greengrass.

the class DeploymentTaskIntegrationTest method setupKernel.

@BeforeAll
static void setupKernel() throws IOException {
    kernel = new Kernel();
    rootDir = Paths.get(System.getProperty("root"));
    NoOpPathOwnershipHandler.register(kernel);
    ConfigPlatformResolver.initKernelWithMultiPlatformConfig(kernel, DeploymentTaskIntegrationTest.class.getResource("onlyMain.yaml"));
    kernel.launch();
    // get required instances from context
    componentManager = kernel.getContext().get(ComponentManager.class);
    componentStore = kernel.getContext().get(ComponentStore.class);
    dependencyResolver = kernel.getContext().get(DependencyResolver.class);
    kernelConfigResolver = kernel.getContext().get(KernelConfigResolver.class);
    deploymentConfigMerger = kernel.getContext().get(DeploymentConfigMerger.class);
    deploymentDocumentDownloader = kernel.getContext().get(DeploymentDocumentDownloader.class);
    thingGroupHelper = kernel.getContext().get(ThingGroupHelper.class);
}
Also used : ThingGroupHelper(com.aws.greengrass.deployment.ThingGroupHelper) DeploymentDocumentDownloader(com.aws.greengrass.deployment.DeploymentDocumentDownloader) DeploymentConfigMerger(com.aws.greengrass.deployment.DeploymentConfigMerger) ComponentManager(com.aws.greengrass.componentmanager.ComponentManager) KernelConfigResolver(com.aws.greengrass.componentmanager.KernelConfigResolver) Kernel(com.aws.greengrass.lifecyclemanager.Kernel) ComponentStore(com.aws.greengrass.componentmanager.ComponentStore) DependencyResolver(com.aws.greengrass.componentmanager.DependencyResolver) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with KernelConfigResolver

use of com.aws.greengrass.componentmanager.KernelConfigResolver in project aws-greengrass-nucleus by aws-greengrass.

the class PluginComponentTest method submitSampleJobDocument.

private static Future<DeploymentResult> submitSampleJobDocument(DeploymentDocument sampleJobDocument, Kernel kernel) {
    ComponentManager componentManager = kernel.getContext().get(ComponentManager.class);
    DependencyResolver dependencyResolver = kernel.getContext().get(DependencyResolver.class);
    KernelConfigResolver kernelConfigResolver = kernel.getContext().get(KernelConfigResolver.class);
    DeploymentConfigMerger deploymentConfigMerger = kernel.getContext().get(DeploymentConfigMerger.class);
    DeploymentDocumentDownloader deploymentDocumentDownloader = kernel.getContext().get(DeploymentDocumentDownloader.class);
    DefaultDeploymentTask deploymentTask = new DefaultDeploymentTask(dependencyResolver, componentManager, kernelConfigResolver, deploymentConfigMerger, LogManager.getLogger("Deployer"), new Deployment(sampleJobDocument, Deployment.DeploymentType.IOT_JOBS, "jobId", DEFAULT), Topics.of(kernel.getContext(), DeploymentService.DEPLOYMENT_SERVICE_TOPICS, null), kernel.getContext().get(ExecutorService.class), deploymentDocumentDownloader, thingGroupHelper);
    return kernel.getContext().get(ExecutorService.class).submit(deploymentTask);
}
Also used : DeploymentDocumentDownloader(com.aws.greengrass.deployment.DeploymentDocumentDownloader) DeploymentConfigMerger(com.aws.greengrass.deployment.DeploymentConfigMerger) ComponentManager(com.aws.greengrass.componentmanager.ComponentManager) KernelConfigResolver(com.aws.greengrass.componentmanager.KernelConfigResolver) ExecutorService(java.util.concurrent.ExecutorService) Deployment(com.aws.greengrass.deployment.model.Deployment) DefaultDeploymentTask(com.aws.greengrass.deployment.DefaultDeploymentTask) DependencyResolver(com.aws.greengrass.componentmanager.DependencyResolver)

Example 3 with KernelConfigResolver

use of com.aws.greengrass.componentmanager.KernelConfigResolver in project aws-greengrass-nucleus by aws-greengrass.

the class DeviceConfiguration method initializeNucleusLifecycleConfig.

void initializeNucleusLifecycleConfig(String nucleusComponentName, ComponentRecipe componentRecipe) {
    KernelConfigResolver kernelConfigResolver = kernel.getContext().get(KernelConfigResolver.class);
    // Add Nucleus dependencies
    Map<String, DependencyProperties> nucleusDependencies = componentRecipe.getDependencies();
    if (nucleusDependencies == null) {
        nucleusDependencies = Collections.emptyMap();
    }
    kernel.getConfig().lookup(DEFAULT_VALUE_TIMESTAMP, SERVICES_NAMESPACE_TOPIC, nucleusComponentName, SERVICE_DEPENDENCIES_NAMESPACE_TOPIC).dflt(kernelConfigResolver.generateServiceDependencies(nucleusDependencies));
    Topics nucleusLifecycle = kernel.getConfig().lookupTopics(DEFAULT_VALUE_TIMESTAMP, SERVICES_NAMESPACE_TOPIC, nucleusComponentName, SERVICE_LIFECYCLE_NAMESPACE_TOPIC);
    if (!nucleusLifecycle.children.isEmpty()) {
        logger.atDebug().log("Nucleus lifecycle has already been initialized");
        return;
    }
    // Add Nucleus lifecycle (after config interpolation)
    if (componentRecipe.getLifecycle() == null) {
        return;
    }
    try {
        Object interpolatedLifecycle = kernelConfigResolver.interpolate(componentRecipe.getLifecycle(), new ComponentIdentifier(nucleusComponentName, componentRecipe.getVersion()), nucleusDependencies.keySet(), kernel.getConfig().lookupTopics(SERVICES_NAMESPACE_TOPIC).toPOJO());
        nucleusLifecycle.replaceAndWait((Map<String, Object>) interpolatedLifecycle);
        logger.atInfo().log("Nucleus lifecycle has been initialized successfully");
    } catch (IOException e) {
        logger.atError().log("Unable to initialize Nucleus lifecycle", e);
    }
}
Also used : Topics(com.aws.greengrass.config.Topics) DependencyProperties(com.amazon.aws.iot.greengrass.component.common.DependencyProperties) KernelConfigResolver(com.aws.greengrass.componentmanager.KernelConfigResolver) ComponentIdentifier(com.aws.greengrass.componentmanager.models.ComponentIdentifier) CaseInsensitiveString(com.aws.greengrass.config.CaseInsensitiveString) IOException(java.io.IOException)

Aggregations

KernelConfigResolver (com.aws.greengrass.componentmanager.KernelConfigResolver)3 ComponentManager (com.aws.greengrass.componentmanager.ComponentManager)2 DependencyResolver (com.aws.greengrass.componentmanager.DependencyResolver)2 DeploymentConfigMerger (com.aws.greengrass.deployment.DeploymentConfigMerger)2 DeploymentDocumentDownloader (com.aws.greengrass.deployment.DeploymentDocumentDownloader)2 DependencyProperties (com.amazon.aws.iot.greengrass.component.common.DependencyProperties)1 ComponentStore (com.aws.greengrass.componentmanager.ComponentStore)1 ComponentIdentifier (com.aws.greengrass.componentmanager.models.ComponentIdentifier)1 CaseInsensitiveString (com.aws.greengrass.config.CaseInsensitiveString)1 Topics (com.aws.greengrass.config.Topics)1 DefaultDeploymentTask (com.aws.greengrass.deployment.DefaultDeploymentTask)1 ThingGroupHelper (com.aws.greengrass.deployment.ThingGroupHelper)1 Deployment (com.aws.greengrass.deployment.model.Deployment)1 Kernel (com.aws.greengrass.lifecyclemanager.Kernel)1 IOException (java.io.IOException)1 ExecutorService (java.util.concurrent.ExecutorService)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1