Search in sources :

Example 1 with NodeSourcePolicy

use of org.ow2.proactive.resourcemanager.nodesource.policy.NodeSourcePolicy in project scheduling by ow2-proactive.

the class NodeSourceTest method setUp.

@Before
public void setUp() {
    PAResourceManagerProperties.RM_TOPOLOGY_ENABLED.updateProperty("false");
    infrastructureManager = mock(InfrastructureManager.class);
    when(infrastructureManager.isUsingDeployingNode()).thenReturn(false);
    NodeSourcePolicy nodeSourcePolicy = mock(NodeSourcePolicy.class);
    when(nodeSourcePolicy.getProviderAccessType()).thenReturn(AccessType.ALL);
    client = new Client(Subjects.create("user"), false);
    nodeSource = createNodeSource(infrastructureManager, nodeSourcePolicy, client);
    RMCore.topologyManager = new TopologyManager(HostsPinger.class);
}
Also used : TopologyManager(org.ow2.proactive.resourcemanager.selection.topology.TopologyManager) HostsPinger(org.ow2.proactive.resourcemanager.frontend.topology.pinging.HostsPinger) InfrastructureManager(org.ow2.proactive.resourcemanager.nodesource.infrastructure.InfrastructureManager) Client(org.ow2.proactive.resourcemanager.authentication.Client) NodeSourcePolicy(org.ow2.proactive.resourcemanager.nodesource.policy.NodeSourcePolicy) Before(org.junit.Before)

Example 2 with NodeSourcePolicy

use of org.ow2.proactive.resourcemanager.nodesource.policy.NodeSourcePolicy in project scheduling by ow2-proactive.

the class RMCore method configureDeployedNodeSource.

private void configureDeployedNodeSource(String nodeSourceName, NodeSourceDescriptor nodeSourceDescriptor, NodeSource nodeSourceStub, NodeSourcePolicy nodeSourcePolicyStub) {
    // Adding access to the core for node source and policy.
    // In order to do it node source and policy active objects are added to the clients list.
    // They will be removed from this list when node source is unregistered.
    UniqueID nsId = Client.getId(nodeSourceStub);
    UniqueID policyId = Client.getId(nodeSourcePolicyStub);
    if (nsId == null || policyId == null) {
        throw new IllegalStateException("Cannot register the node source");
    }
    BooleanWrapper result = nodeSourceStub.activate();
    if (!result.getBooleanValue()) {
        logger.error(NODE_SOURCE_STRING + nodeSourceName + " cannot be activated");
    }
    Client provider = nodeSourceDescriptor.getProvider();
    Client nsService = new Client(provider.getSubject(), false);
    Client policyService = new Client(provider.getSubject(), false);
    nsService.setId(nsId);
    policyService.setId(policyId);
    RMCore.clients.put(nsId, nsService);
    RMCore.clients.put(policyId, policyService);
}
Also used : UniqueID(org.objectweb.proactive.core.UniqueID) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) Client(org.ow2.proactive.resourcemanager.authentication.Client)

Example 3 with NodeSourcePolicy

use of org.ow2.proactive.resourcemanager.nodesource.policy.NodeSourcePolicy in project scheduling by ow2-proactive.

the class RMCore method recoverNodeSource.

/**
 * Recreate a node source from a node source descriptor and deploy it if
 * the node source descriptor specifies a deployed status. The flow is
 * inspired from {@link #defineNodeSource} and {@link #deployNodeSource}
 * but this version does not emit events as the recovered node sources are
 * supposed to have been created and deployed already in the past.
 *
 * @param nodeSourceDescriptor the descriptor of the node source to recover
 */
protected void recoverNodeSource(NodeSourceDescriptor nodeSourceDescriptor) {
    String nodeSourceName = nodeSourceDescriptor.getName();
    NodeSource nodeSource = this.createNodeSourceInstance(nodeSourceDescriptor);
    this.definedNodeSources.put(nodeSourceDescriptor.getName(), nodeSource);
    if (nodeSourceDescriptor.getStatus().equals(NodeSourceStatus.NODES_DEPLOYED)) {
        NodeSource nodeSourceToDeploy = this.createNodeSourceInstance(nodeSourceDescriptor);
        boolean recoverNodes = false;
        if (this.isNodeRecoveryEnabledForNodeSource(nodeSourceToDeploy)) {
            recoverNodes = this.nodesRecoveryManager.recoverFullyDeployedInfrastructureOrReset(nodeSourceName, nodeSourceToDeploy, nodeSourceDescriptor);
        }
        NodeSourcePolicy nodeSourcePolicyStub = this.createNodeSourcePolicyActivity(nodeSourceDescriptor, nodeSourceToDeploy);
        NodeSource nodeSourceStub = this.createNodeSourceActivity(nodeSourceName, nodeSourceToDeploy);
        if (recoverNodes) {
            this.nodesRecoveryManager.recoverNodes(nodeSourceStub);
        }
        this.configureDeployedNodeSource(nodeSourceName, nodeSourceDescriptor, nodeSourceStub, nodeSourcePolicyStub);
        this.deployedNodeSources.put(nodeSourceName, nodeSourceStub);
    }
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) NodeSourcePolicy(org.ow2.proactive.resourcemanager.nodesource.policy.NodeSourcePolicy)

Example 4 with NodeSourcePolicy

use of org.ow2.proactive.resourcemanager.nodesource.policy.NodeSourcePolicy in project scheduling by ow2-proactive.

the class RMCore method deployNodeSource.

/**
 * {@inheritDoc}
 */
@Override
public BooleanWrapper deployNodeSource(String nodeSourceName) {
    if (!this.deployedNodeSources.containsKey(nodeSourceName)) {
        NodeSourceDescriptor nodeSourceDescriptor = this.retrieveNodeSourceDescriptorOrFail(nodeSourceName);
        logger.info("Deploy node source " + nodeSourceName + REQUESTED_BY_STRING + this.caller.getName());
        this.updateNodeSourceDescriptorWithStatusAndPersist(nodeSourceDescriptor, NodeSourceStatus.NODES_DEPLOYED);
        NodeSource nodeSourceToDeploy = this.createNodeSourceInstance(nodeSourceDescriptor);
        NodeSourcePolicy nodeSourcePolicyStub = this.createNodeSourcePolicyActivity(nodeSourceDescriptor, nodeSourceToDeploy);
        NodeSource nodeSourceStub = this.createNodeSourceActivity(nodeSourceName, nodeSourceToDeploy);
        this.configureDeployedNodeSource(nodeSourceName, nodeSourceDescriptor, nodeSourceStub, nodeSourcePolicyStub);
        this.deployedNodeSources.put(nodeSourceName, nodeSourceStub);
        this.monitoring.nodeSourceEvent(new RMNodeSourceEvent(RMEventType.NODESOURCE_CREATED, this.caller.getName(), nodeSourceStub.getName(), nodeSourceStub.getDescription(), nodeSourceStub.getAdministrator().getName(), nodeSourceStub.getStatus().toString()));
        logger.info(NODE_SOURCE_STRING + nodeSourceName + " has been successfully deployed");
    }
    return new BooleanWrapper(true);
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) NodeSourceDescriptor(org.ow2.proactive.resourcemanager.nodesource.NodeSourceDescriptor) NodeSourcePolicy(org.ow2.proactive.resourcemanager.nodesource.policy.NodeSourcePolicy)

Example 5 with NodeSourcePolicy

use of org.ow2.proactive.resourcemanager.nodesource.policy.NodeSourcePolicy in project scheduling by ow2-proactive.

the class RMCore method createNodeSourcePolicyActivity.

private NodeSourcePolicy createNodeSourcePolicyActivity(NodeSourceDescriptor nodeSourceDescriptor, NodeSource nodeSourceToDeploy) {
    NodeSourcePolicy nodeSourcePolicyStub = NodeSourcePolicyFactory.activate(nodeSourceToDeploy.getPolicy(), nodeSourceDescriptor.getPolicyParameters());
    nodeSourceToDeploy.setActivePolicy(nodeSourcePolicyStub);
    return nodeSourcePolicyStub;
}
Also used : NodeSourcePolicy(org.ow2.proactive.resourcemanager.nodesource.policy.NodeSourcePolicy)

Aggregations

NodeSourcePolicy (org.ow2.proactive.resourcemanager.nodesource.policy.NodeSourcePolicy)5 NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)3 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)2 Client (org.ow2.proactive.resourcemanager.authentication.Client)2 InfrastructureManager (org.ow2.proactive.resourcemanager.nodesource.infrastructure.InfrastructureManager)2 Before (org.junit.Before)1 UniqueID (org.objectweb.proactive.core.UniqueID)1 RMNodeSourceEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent)1 RMCore (org.ow2.proactive.resourcemanager.core.RMCore)1 NodeSourceData (org.ow2.proactive.resourcemanager.db.NodeSourceData)1 RMMonitoringImpl (org.ow2.proactive.resourcemanager.frontend.RMMonitoringImpl)1 HostsPinger (org.ow2.proactive.resourcemanager.frontend.topology.pinging.HostsPinger)1 NodeSourceDescriptor (org.ow2.proactive.resourcemanager.nodesource.NodeSourceDescriptor)1 DefaultInfrastructureManager (org.ow2.proactive.resourcemanager.nodesource.infrastructure.DefaultInfrastructureManager)1 TopologyManager (org.ow2.proactive.resourcemanager.selection.topology.TopologyManager)1