Search in sources :

Example 1 with RMNodeSourceEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent in project scheduling by ow2-proactive.

the class RecoverLocalInfrastructureTest method restartRmAndCheckFinalState.

private void restartRmAndCheckFinalState(boolean nodesShouldBeRecreated) throws Exception {
    // restart RM
    this.rmHelper = new RMTHelper();
    this.startRmWithConfig(RESTART_CONFIG);
    assertThat(PAResourceManagerProperties.RM_PRESERVE_NODES_ON_SHUTDOWN.getValueAsBoolean()).isFalse();
    assertThat(this.rmHelper.isRMStarted()).isTrue();
    // re-snapshot the RM state
    RMMonitorEventReceiver resourceManagerMonitor = (RMMonitorEventReceiver) this.resourceManager;
    List<RMNodeSourceEvent> nodeSourceEvent = resourceManagerMonitor.getInitialState().getNodeSourceEvents();
    // the node source has been recovered on restart: we should have one node source with the same name
    assertThat(nodeSourceEvent.size()).isEqualTo(1);
    assertThat(nodeSourceEvent.get(0).getSourceName()).isEqualTo(NODE_SOURCE_NAME);
    // wait for nodes to be recreated if needed
    if (nodesShouldBeRecreated) {
        this.rmHelper.waitForAnyMultipleNodeEvent(RMEventType.NODE_STATE_CHANGED, NODE_NUMBER);
    }
}
Also used : RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) RMTHelper(functionaltests.utils.RMTHelper) RMMonitorEventReceiver(functionaltests.monitor.RMMonitorEventReceiver)

Example 2 with RMNodeSourceEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent in project scheduling by ow2-proactive.

the class RMInitialStateChunksTest2 method clientKnowsNothing.

@Test
public void clientKnowsNothing() {
    Map<String, RMNodeEvent> accumulatedNodeEvents = new HashMap<>();
    Map<String, RMNodeSourceEvent> accumulatedNodeSourceEvents = new HashMap<>();
    int numberOfRequests = 0;
    long currentCounter = RMInitialState.EMPTY_STATE;
    while (true) {
        final RMStateDelta rmStateDelta = rmInitialState.cloneAndFilter(currentCounter);
        ++numberOfRequests;
        rmStateDelta.getNodesEvents().forEach(rmNodeEvent -> {
            accumulatedNodeEvents.put(rmNodeEvent.getNodeSource() + rmNodeEvent.getNodeUrl(), rmNodeEvent);
        });
        rmStateDelta.getNodeSource().forEach(rmNodeSourceEvent -> {
            accumulatedNodeSourceEvents.put(rmNodeSourceEvent.getSourceName(), rmNodeSourceEvent);
        });
        if (rmStateDelta.getLatestCounter() == currentCounter) {
            break;
        } else {
            currentCounter = rmStateDelta.getLatestCounter();
        }
    }
    assertEquals(4, accumulatedNodeSourceEvents.size());
    assertEquals(200, accumulatedNodeEvents.size());
    assertEquals(6, numberOfRequests);
}
Also used : HashMap(java.util.HashMap) RMStateDelta(org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta) Test(org.junit.Test)

Example 3 with RMNodeSourceEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent in project scheduling by ow2-proactive.

the class RMGroupEventListener method notify.

public void notify(Collection<RMEvent> events) {
    for (RMEvent event : events) {
        if (event instanceof RMNodeEvent) {
            RMNodeEvent nodeEvent = (RMNodeEvent) event;
            nodeEvent(nodeEvent);
        } else if (event instanceof RMNodeSourceEvent) {
            RMNodeSourceEvent sourceEvent = (RMNodeSourceEvent) event;
            nodeSourceEvent(sourceEvent);
        } else {
            rmEvent(event);
        }
    }
}
Also used : RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) RMEvent(org.ow2.proactive.resourcemanager.common.event.RMEvent) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)

Example 4 with RMNodeSourceEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent in project scheduling by ow2-proactive.

the class RMRest method acquireNodes.

@Override
public Set<String> acquireNodes(String sessionId, String sourceName, int numberNodes, boolean synchronous, long timeout, String nodeConfigJson) throws NotConnectedException, RestException {
    if (numberNodes <= 0) {
        throw new IllegalArgumentException("Invalid number of nodes: " + numberNodes);
    }
    ResourceManager rm = checkAccess(sessionId);
    if (sourceName == null) {
        throw new IllegalArgumentException("Node source name should not be null.");
    }
    Optional<RMNodeSourceEvent> nodeSource = rm.getExistingNodeSourcesList().stream().filter(ns -> sourceName.equals(ns.getSourceName())).findAny();
    if (!nodeSource.isPresent()) {
        throw new IllegalArgumentException(String.format("Specified node source [%s] not exist.", sourceName));
    }
    if (!NODE_SOURCE_DEPLOYED_STATUS.equals(nodeSource.get().getNodeSourceStatus())) {
        throw new IllegalArgumentException(String.format("Specified node source [%s] is not deployed.", sourceName));
    }
    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> nodeConfig;
    try {
        nodeConfig = mapper.readValue(nodeConfigJson, new TypeReference<Map<String, ?>>() {
        });
    } catch (Exception e) {
        throw new IllegalArgumentException("Error during parsing the node configuration: " + nodeConfigJson, e);
    }
    if (synchronous) {
        String acquireRequestId = "tmp:" + UUID.randomUUID().toString();
        setRequestIdInNodeConfig(nodeConfig, acquireRequestId);
        rm.acquireNodes(sourceName, numberNodes, timeout * 1000, nodeConfig);
        waitUntil(timeout, "Nodes are not deployed within the specified timeout.", () -> rm.getNodesByTag(acquireRequestId).size() == numberNodes);
        return orThrowRpe(rm.getNodesByTag(acquireRequestId));
    } else {
        rm.acquireNodes(sourceName, numberNodes, timeout * 1000, nodeConfig);
        return new HashSet<>();
    }
}
Also used : LoginException(javax.security.auth.login.LoginException) RMStateDelta(org.ow2.proactive.resourcemanager.common.event.dto.RMStateDelta) CredData(org.ow2.proactive.authentication.crypto.CredData) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) IntrospectionException(javax.management.IntrospectionException) PAFuture(org.objectweb.proactive.api.PAFuture) KeyException(java.security.KeyException) RMListenerProxy(org.ow2.proactive.resourcemanager.common.util.RMListenerProxy) ScriptResult(org.ow2.proactive.scripting.ScriptResult) URISyntaxException(java.net.URISyntaxException) Path(javax.ws.rs.Path) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) ConfigurableField(org.ow2.proactive.resourcemanager.nodesource.common.ConfigurableField) BooleanSupplier(java.util.function.BooleanSupplier) InetAddress(java.net.InetAddress) Logger(org.apache.log4j.Logger) Matcher(java.util.regex.Matcher) NSState(org.ow2.proactive.resourcemanager.common.NSState) NodeFactory(org.objectweb.proactive.core.node.NodeFactory) URI(java.net.URI) StringEscapeUtils(org.apache.commons.lang3.StringEscapeUtils) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) ReflectionException(javax.management.ReflectionException) RMActiveObjectCreationException(org.ow2.proactive.resourcemanager.exception.RMActiveObjectCreationException) RMState(org.ow2.proactive.resourcemanager.common.RMState) ExceptionUtils.getStackTrace(org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace) RMNodeHistory(org.ow2.proactive.resourcemanager.common.event.RMNodeHistory) ObjectName(javax.management.ObjectName) Collectors(java.util.stream.Collectors) RMException(org.ow2.proactive.resourcemanager.exception.RMException) RMStateFull(org.ow2.proactive.resourcemanager.common.event.dto.RMStateFull) MalformedObjectNameException(javax.management.MalformedObjectNameException) JSONObject(org.json.simple.JSONObject) Response(javax.ws.rs.core.Response) NodeException(org.objectweb.proactive.core.node.NodeException) TypeReference(org.codehaus.jackson.type.TypeReference) TopologyData(org.ow2.proactive.resourcemanager.frontend.topology.TopologyData) Pattern(java.util.regex.Pattern) TopologyImpl(org.ow2.proactive.resourcemanager.frontend.topology.TopologyImpl) RMJMXBeans(org.ow2.proactive.resourcemanager.core.jmx.RMJMXBeans) PluginDescriptorData(org.ow2.proactive.resourcemanager.frontend.PluginDescriptorData) RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) MBeanInfoViewer(org.ow2.proactive.utils.console.MBeanInfoViewer) java.util(java.util) AttributeNotFoundException(javax.management.AttributeNotFoundException) ScriptException(org.ow2.proactive.scripting.ScriptException) GET(javax.ws.rs.GET) TargetType(org.ow2.proactive.resourcemanager.utils.TargetType) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) NodeSourceConfiguration(org.ow2.proactive.resourcemanager.nodesource.common.NodeSourceConfiguration) AttributeList(javax.management.AttributeList) JSONArray(org.json.simple.JSONArray) UserData(org.ow2.proactive.authentication.UserData) Lambda.mapKeys(org.ow2.proactive.utils.Lambda.mapKeys) Attribute(javax.management.Attribute) StatHistory(org.ow2.proactive_grid_cloud_portal.webapp.StatHistory) InstanceNotFoundException(javax.management.InstanceNotFoundException) JsonParser(org.codehaus.jackson.JsonParser) Credentials(org.ow2.proactive.authentication.crypto.Credentials) Lambda.mapValues(org.ow2.proactive.utils.Lambda.mapValues) RMConstants(org.ow2.proactive.resourcemanager.common.RMConstants) PortalConfiguration(org.ow2.proactive_grid_cloud_portal.webapp.PortalConfiguration) IOException(java.io.IOException) Node(org.objectweb.proactive.core.node.Node) org.ow2.proactive_grid_cloud_portal.common(org.ow2.proactive_grid_cloud_portal.common) TimeUnit(java.util.concurrent.TimeUnit) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) MultipartForm(org.jboss.resteasy.annotations.providers.multipart.MultipartForm) StatHistoryCacheEntry(org.ow2.proactive_grid_cloud_portal.common.StatHistoryCaching.StatHistoryCacheEntry) LoginForm(org.ow2.proactive_grid_cloud_portal.common.dto.LoginForm) RestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) RMNodeException(org.ow2.proactive.resourcemanager.exception.RMNodeException) PluginDescriptor(org.ow2.proactive.resourcemanager.nodesource.common.PluginDescriptor) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) RMNodeSourceEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent) JSONObject(org.json.simple.JSONObject) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) TypeReference(org.codehaus.jackson.type.TypeReference) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) LoginException(javax.security.auth.login.LoginException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) IntrospectionException(javax.management.IntrospectionException) KeyException(java.security.KeyException) URISyntaxException(java.net.URISyntaxException) ReflectionException(javax.management.ReflectionException) RMActiveObjectCreationException(org.ow2.proactive.resourcemanager.exception.RMActiveObjectCreationException) RMException(org.ow2.proactive.resourcemanager.exception.RMException) MalformedObjectNameException(javax.management.MalformedObjectNameException) NodeException(org.objectweb.proactive.core.node.NodeException) AttributeNotFoundException(javax.management.AttributeNotFoundException) ScriptException(org.ow2.proactive.scripting.ScriptException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) InstanceNotFoundException(javax.management.InstanceNotFoundException) IOException(java.io.IOException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) RestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.RestException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) RMNodeException(org.ow2.proactive.resourcemanager.exception.RMNodeException)

Example 5 with RMNodeSourceEvent

use of org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent 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);
    }
    logger.info(NODE_SOURCE_STRING + nodeSourceName + HAS_BEEN_SUCCESSFULLY + evt.getEventType().getDescription());
    this.monitoring.nodeSourceEvent(evt);
    this.emitRemovedEventIfNodeSourceWasNotUndeployed(nodeSource, nodeSourceStatus);
    return new BooleanWrapper(true);
}
Also used : NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper)

Aggregations

RMNodeSourceEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent)24 RMMonitorEventReceiver (functionaltests.monitor.RMMonitorEventReceiver)14 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)8 RMTHelper (functionaltests.utils.RMTHelper)6 NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)6 HashSet (java.util.HashSet)5 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)5 TestSSHInfrastructureV2 (functionaltests.nodesource.TestSSHInfrastructureV2)3 Set (java.util.Set)3 NSAdminPermission (org.ow2.proactive.permissions.NSAdminPermission)3 RMCoreAllPermission (org.ow2.proactive.permissions.RMCoreAllPermission)3 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)3 SSHInfrastructureV2 (org.ow2.proactive.resourcemanager.nodesource.infrastructure.SSHInfrastructureV2)3 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 File (java.io.File)2 Permission (java.security.Permission)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 Node (org.objectweb.proactive.core.node.Node)2