Search in sources :

Example 11 with NodeSource

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

the class RMCore method removeNodeSource.

/**
 * {@inheritDoc}
 */
public BooleanWrapper removeNodeSource(String nodeSourceName, boolean preempt) {
    if (!this.definedNodeSources.containsKey(nodeSourceName)) {
        throw new IllegalArgumentException("Unknown node source " + nodeSourceName);
    }
    NodeSource nodeSourceToRemove = this.definedNodeSources.get(nodeSourceName);
    this.caller.checkPermission(nodeSourceToRemove.getAdminPermission(), this.caller + " is not authorized to remove " + nodeSourceName);
    logger.info("Remove node source " + nodeSourceName + " with preempt=" + preempt + REQUESTED_BY_STRING + this.caller.getName());
    this.shutDownNodeSourceIfDeployed(nodeSourceName, preempt);
    this.removeDefinedNodeSource(nodeSourceName, nodeSourceToRemove);
    return new BooleanWrapper(true);
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper)

Example 12 with NodeSource

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

the class RMCore method nodeSourceUnregister.

/**
 * Unregisters node source from the resource manager core.
 */
public BooleanWrapper nodeSourceUnregister(String nodeSourceName, NodeSourceStatus nodeSourceStatus, RMNodeSourceEvent evt) {
    NodeSource nodeSource = this.deployedNodeSources.remove(nodeSourceName);
    if (nodeSource == null) {
        logger.warn("Attempt to remove non-existing node source " + nodeSourceName);
        return new BooleanWrapper(false);
    }
    this.disconnectNodeSourceClient(nodeSourceName, nodeSource);
    logger.info(NODE_SOURCE_STRING + nodeSourceName + " has been successfully " + evt.getEventType().getDescription());
    this.monitoring.nodeSourceEvent(evt);
    this.emitRemovedEventIfNodeSourceWasNotUndeployed(nodeSource, nodeSourceStatus);
    if ((this.deployedNodeSources.isEmpty()) && this.toShutDown) {
        this.finalizeShutdown();
    }
    return new BooleanWrapper(true);
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper)

Example 13 with NodeSource

use of org.ow2.proactive.resourcemanager.nodesource.NodeSource 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 14 with NodeSource

use of org.ow2.proactive.resourcemanager.nodesource.NodeSource 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 15 with NodeSource

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

the class RMCore method emitRemovedEventIfNodeSourceWasNotUndeployed.

private void emitRemovedEventIfNodeSourceWasNotUndeployed(NodeSource nodeSource, NodeSourceStatus nodeSourceStatus) {
    if (!nodeSourceStatus.equals(NodeSourceStatus.NODES_UNDEPLOYED)) {
        String nodeSourceAdministratorName = nodeSource.getAdministrator().getName();
        String nodeSourceName = nodeSource.getName();
        RMNodeSourceEvent removedEvent = new RMNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, nodeSourceAdministratorName, nodeSourceName, nodeSource.getDescription(), nodeSourceAdministratorName, nodeSourceStatus.toString());
        logger.info(NODE_SOURCE_STRING + nodeSourceName + " has been successfully " + removedEvent.getEventType().getDescription());
        this.monitoring.nodeSourceEvent(removedEvent);
    }
}
Also used : RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent)

Aggregations

NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)21 Test (org.junit.Test)17 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)13 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)11 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)11 Client (org.ow2.proactive.resourcemanager.authentication.Client)9 Node (org.objectweb.proactive.core.node.Node)8 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)7 ArrayList (java.util.ArrayList)6 RMNodeSourceEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent)6 Permission (java.security.Permission)5 NodeSourceData (org.ow2.proactive.resourcemanager.db.NodeSourceData)5 RMException (org.ow2.proactive.resourcemanager.exception.RMException)5 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)4 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 Matchers.anyString (org.mockito.Matchers.anyString)4