Search in sources :

Example 1 with YarnComponent

use of com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.YarnComponent in project cloudbreak by hortonworks.

the class ApplicationSubmissionHandler method submitApplication.

public void submitApplication(ContainerConfig config, OrchestrationCredential cred, ContainerConstraint constraint, int componentNumber) throws CloudbreakOrchestratorFailedException {
    // Set Ambari DB hostname, if available
    if (ComponentType.AMBARIDB.equals(applicationUtils.getComponentType(constraint))) {
        ambariDbHostname = applicationUtils.getComponentHostName(constraint, cred, componentNumber);
    }
    // Set Ambari Server hostname, if available
    if (ComponentType.AMBARISERVER.equals(applicationUtils.getComponentType(constraint))) {
        ambariServerHostname = applicationUtils.getComponentHostName(constraint, cred, componentNumber);
    }
    // Application level attributes
    String applicationName = applicationUtils.getApplicationName(constraint, componentNumber);
    CreateApplicationRequest createApplicationRequest = new CreateApplicationRequest();
    createApplicationRequest.setName(applicationName);
    createApplicationRequest.setQueue(config.getQueue());
    createApplicationRequest.setLifetime(UNLIMITED);
    // Define the artifact (docker image) for the component
    Artifact artifact = new Artifact();
    artifact.setId(getDockerImageName(config));
    artifact.setType("DOCKER");
    // Define the resources for the component
    Resource resource = new Resource();
    resource.setCpus(getCpusForContainerType(constraint));
    resource.setMemory(getMemForContainerType(constraint));
    // Add the component
    List<YarnComponent> components = new ArrayList<>();
    YarnComponent component = new YarnComponent();
    component.setName(applicationUtils.getComponentName(constraint, componentNumber));
    component.setNumberOfContainers(ONE);
    component.setLaunchCommand(getFullEntrypoint(constraint, cred, componentNumber));
    component.setArtifact(artifact);
    component.setDependencies(new ArrayList<>());
    component.setResource(resource);
    component.setRunPrivilegedContainer(true);
    components.add(component);
    createApplicationRequest.setComponents(components);
    // Submit the request
    YarnClient yarnHttpClient = new YarnHttpClient(cred.getApiEndpoint());
    try {
        submitCreateApplicationRequest(createApplicationRequest, yarnHttpClient);
    } catch (RuntimeException e) {
        throw new CloudbreakOrchestratorFailedException(e);
    }
}
Also used : CreateApplicationRequest(com.sequenceiq.cloudbreak.orchestrator.yarn.model.request.CreateApplicationRequest) YarnHttpClient(com.sequenceiq.cloudbreak.orchestrator.yarn.client.YarnHttpClient) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) Resource(com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.Resource) ArrayList(java.util.ArrayList) YarnComponent(com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.YarnComponent) Artifact(com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.Artifact) YarnClient(com.sequenceiq.cloudbreak.orchestrator.yarn.client.YarnClient)

Example 2 with YarnComponent

use of com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.YarnComponent in project cloudbreak by hortonworks.

the class CreateApplicationToJsonConverterTest method testConvert.

@Test
public void testConvert() throws Exception {
    // CreateApplicationRequest object
    CreateApplicationRequest createApplicationRequest = new CreateApplicationRequest();
    createApplicationRequest.setName(NAME);
    createApplicationRequest.setLifetime(LIFETIME);
    createApplicationRequest.setComponents(COMPONENTS);
    // Create a component
    YarnComponent component = new YarnComponent();
    // Create the Dependency
    Dependency dependency = new Dependency();
    dependency.setItem(DEPENDENCY_ITEM);
    DEPENDENCIES.add(dependency);
    // Create the Artifact
    Artifact artifact = new Artifact();
    artifact.setId(ARTIFACT_ID);
    artifact.setType(ARTIFACT_TYPE);
    // Create the Resource
    Resource resource = new Resource();
    resource.setCpus(RESOURCE_CPUS);
    resource.setMemory(RESOURCE_MEMORY);
    // Populate the component
    component.setName(COMPONENT_NAME);
    component.setDependencies(DEPENDENCIES);
    component.setNumberOfContainers(NUM_OF_CONTAINTERS);
    component.setArtifact(artifact);
    component.setLaunchCommand(LAUNCH_COMMAND);
    component.setResource(resource);
    // Add the component to the Create Application Request
    COMPONENTS.add(component);
    CreateApplicationRequestToJsonConverter createApplicationRequestToJsonConverter = new CreateApplicationRequestToJsonConverter();
    String jsonResult = createApplicationRequestToJsonConverter.convert(createApplicationRequest);
    LOGGER.info(jsonResult);
}
Also used : CreateApplicationRequest(com.sequenceiq.cloudbreak.orchestrator.yarn.model.request.CreateApplicationRequest) Resource(com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.Resource) Dependency(com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.Dependency) CreateApplicationRequestToJsonConverter(com.sequenceiq.cloudbreak.orchestrator.yarn.converter.request.CreateApplicationRequestToJsonConverter) YarnComponent(com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.YarnComponent) Artifact(com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.Artifact) Test(org.junit.Test)

Example 3 with YarnComponent

use of com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.YarnComponent in project cloudbreak by hortonworks.

the class ComponentTest method testNumberOfContainers.

@Test
public void testNumberOfContainers() {
    YarnComponent component = new YarnComponent();
    component.setNumberOfContainers(NUM_OF_CONTAINERS);
    assertEquals(NUM_OF_CONTAINERS, component.getNumberOfContainers());
}
Also used : YarnComponent(com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.YarnComponent) Test(org.junit.Test)

Example 4 with YarnComponent

use of com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.YarnComponent in project cloudbreak by hortonworks.

the class ComponentTest method testDependencies.

@Test
public void testDependencies() {
    Dependency dependency = new Dependency();
    YarnComponent component = new YarnComponent();
    List<Dependency> dependencies = new ArrayList<>();
    dependencies.add(dependency);
    component.setDependencies(dependencies);
    assertEquals(1, component.getDependencies().size());
}
Also used : ArrayList(java.util.ArrayList) Dependency(com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.Dependency) YarnComponent(com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.YarnComponent) Test(org.junit.Test)

Example 5 with YarnComponent

use of com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.YarnComponent in project cloudbreak by hortonworks.

the class ComponentTest method testLaunchCommand.

@Test
public void testLaunchCommand() {
    YarnComponent component = new YarnComponent();
    component.setLaunchCommand(LAUNCH_COMMAND);
    assertEquals(LAUNCH_COMMAND, component.getLaunchCommand());
}
Also used : YarnComponent(com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.YarnComponent) Test(org.junit.Test)

Aggregations

YarnComponent (com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.YarnComponent)7 Test (org.junit.Test)6 CreateApplicationRequest (com.sequenceiq.cloudbreak.orchestrator.yarn.model.request.CreateApplicationRequest)3 ArrayList (java.util.ArrayList)3 Artifact (com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.Artifact)2 Dependency (com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.Dependency)2 Resource (com.sequenceiq.cloudbreak.orchestrator.yarn.model.core.Resource)2 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)1 YarnClient (com.sequenceiq.cloudbreak.orchestrator.yarn.client.YarnClient)1 YarnHttpClient (com.sequenceiq.cloudbreak.orchestrator.yarn.client.YarnHttpClient)1 CreateApplicationRequestToJsonConverter (com.sequenceiq.cloudbreak.orchestrator.yarn.converter.request.CreateApplicationRequestToJsonConverter)1