Search in sources :

Example 11 with NodeException

use of org.objectweb.proactive.core.node.NodeException in project scheduling by ow2-proactive.

the class ForkedTaskVariablesManagerTest method testAddBindingsToScriptHandlerContainsPreviousTaskResults.

@Test
public void testAddBindingsToScriptHandlerContainsPreviousTaskResults() throws InvalidScriptException, NodeException, NoSuchFieldException, IllegalAccessException {
    // Create task result array
    TaskResultImpl taskResult = new TaskResultImpl(TaskIdImpl.createTaskId(new JobIdImpl(jobIdValue, jobNameValue), taskNameValue, taskIdValue), new Exception("Exception"));
    TaskResult[] taskResultArray = { taskResult };
    // Create TaskContext with task result array
    TaskContext taskContext = createTaskContext(taskResultArray);
    // Expect taskResultArray to be inside the map
    validateThatScriptHandlerBindingsContain(new ScriptHandler(), taskContext, new VariablesMap(), new HashMap<String, String>(), new HashMap<String, String>(), SchedulerConstants.RESULTS_VARIABLE, taskResultArray);
}
Also used : TaskContext(org.ow2.proactive.scheduler.task.context.TaskContext) TaskResultImpl(org.ow2.proactive.scheduler.task.TaskResultImpl) TaskResult(org.ow2.proactive.scheduler.common.task.TaskResult) VariablesMap(org.ow2.proactive.scheduler.task.utils.VariablesMap) JobIdImpl(org.ow2.proactive.scheduler.job.JobIdImpl) KeyException(java.security.KeyException) InvalidScriptException(org.ow2.proactive.scripting.InvalidScriptException) NodeException(org.objectweb.proactive.core.node.NodeException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ScriptHandler(org.ow2.proactive.scripting.ScriptHandler) Test(org.junit.Test)

Example 12 with NodeException

use of org.objectweb.proactive.core.node.NodeException in project scheduling by ow2-proactive.

the class SchedulerStateRest method publish.

/**
 * Accepts an {@link EventSubscription} instance which specifies the types
 * of SchedulerEvents which interest the client. When such Scheduler event
 * occurs, it will be communicated to the client in the form of
 * {@link EventNotification} utilizing the WebSocket channel initialized
 * previously.
 */
@POST
@Path("/events")
@Produces("application/json")
public EventNotification publish(@Context HttpServletRequest req, EventSubscription subscription) throws NotConnectedRestException, PermissionRestException {
    HttpSession session = req.getSession();
    String broadcasterId = (String) session.getAttribute(ATM_BROADCASTER_ID);
    final SchedulerProxyUserInterface scheduler = checkAccess(broadcasterId);
    SchedulerEventBroadcaster eventListener = new SchedulerEventBroadcaster(broadcasterId);
    try {
        final SchedulerEventBroadcaster activedEventListener = PAActiveObject.turnActive(eventListener);
        scheduler.addEventListener(activedEventListener, subscription.isMyEventsOnly(), EventUtil.toSchedulerEvents(subscription.getEvents()));
        AtmosphereResource atmResource = getAtmosphereResourceFactory().find((String) session.getAttribute(ATM_RESOURCE_ID));
        atmResource.addEventListener(new WebSocketEventListenerAdapter() {

            @Override
            public void onDisconnect(@SuppressWarnings("rawtypes") WebSocketEvent event) {
                try {
                    logger.info("#### websocket disconnected remove listener ####");
                    scheduler.removeEventListener();
                } catch (Exception e) {
                    logger.error(e);
                }
                PAActiveObject.terminateActiveObject(activedEventListener, true);
            }
        });
    } catch (NotConnectedException e) {
        throw new NotConnectedRestException(e);
    } catch (PermissionException e) {
        throw new PermissionRestException(e);
    } catch (ActiveObjectCreationException | NodeException e) {
        throw new RuntimeException(e);
    }
    return new EventNotification(EventNotification.Action.NONE, null, null);
}
Also used : PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) EventNotification(org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification) WebSocketEventListenerAdapter(org.atmosphere.websocket.WebSocketEventListenerAdapter) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) AtmosphereResource(org.atmosphere.cpr.AtmosphereResource) HttpSession(javax.servlet.http.HttpSession) SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface) NodeException(org.objectweb.proactive.core.node.NodeException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) KeyException(java.security.KeyException) UnknownJobException(org.ow2.proactive.scheduler.common.exception.UnknownJobException) SchedulerRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SchedulerRestException) InternalSchedulerException(org.ow2.proactive.scheduler.common.exception.InternalSchedulerException) LogForwardingRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.LogForwardingRestException) NodeException(org.objectweb.proactive.core.node.NodeException) JobCreationException(org.ow2.proactive.scheduler.common.exception.JobCreationException) PermissionException(org.ow2.proactive.scheduler.common.exception.PermissionException) NotConnectedException(org.ow2.proactive.scheduler.common.exception.NotConnectedException) UnknownTaskException(org.ow2.proactive.scheduler.common.exception.UnknownTaskException) JobCreationRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.JobCreationRestException) ConnectionException(org.ow2.proactive.scheduler.common.exception.ConnectionException) IOException(java.io.IOException) SchedulerException(org.ow2.proactive.scheduler.common.exception.SchedulerException) NotConnectedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException) LoginException(javax.security.auth.login.LoginException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) URISyntaxException(java.net.URISyntaxException) UnknownTaskRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownTaskRestException) LogForwardingException(org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingException) JobAlreadyFinishedException(org.ow2.proactive.scheduler.common.exception.JobAlreadyFinishedException) UnknownJobRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.UnknownJobRestException) SubmissionClosedException(org.ow2.proactive.scheduler.common.exception.SubmissionClosedException) JobAlreadyFinishedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.JobAlreadyFinishedRestException) SubmissionClosedRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.SubmissionClosedRestException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) PermissionRestException(org.ow2.proactive_grid_cloud_portal.scheduler.exception.PermissionRestException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 13 with NodeException

use of org.objectweb.proactive.core.node.NodeException in project scheduling by ow2-proactive.

the class HostsPinger method ping.

/**
 * Pings remote nodes and returns distances to hosts where these nodes are located.
 *
 * @param nodes to ping
 * @return distances map to hosts where these nodes are located
 */
public HashMap<InetAddress, Long> ping(NodeSet nodes) {
    HashMap<InetAddress, Long> results = new HashMap<>();
    for (Node node : nodes) {
        try {
            InetAddress current = NodeFactory.getDefaultNode().getVMInformation().getInetAddress();
            InetAddress nodeAddress = node.getVMInformation().getInetAddress();
            if (current.equals(nodeAddress)) {
                // nodes on the same host
                results.put(nodeAddress, new Long(0));
            } else {
                results.put(nodeAddress, pingHost(nodeAddress));
            }
        } catch (NodeException e) {
        }
    }
    return results;
}
Also used : HashMap(java.util.HashMap) Node(org.objectweb.proactive.core.node.Node) NodeException(org.objectweb.proactive.core.node.NodeException) InetAddress(java.net.InetAddress)

Aggregations

NodeException (org.objectweb.proactive.core.node.NodeException)13 IOException (java.io.IOException)5 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)5 Node (org.objectweb.proactive.core.node.Node)5 StartNode (org.objectweb.proactive.core.node.StartNode)4 InetAddress (java.net.InetAddress)3 LoginException (javax.security.auth.login.LoginException)3 HttpSession (javax.servlet.http.HttpSession)3 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 InternalSchedulerException (org.ow2.proactive.scheduler.common.exception.InternalSchedulerException)3 SchedulerException (org.ow2.proactive.scheduler.common.exception.SchedulerException)3 MalformedURLException (java.net.MalformedURLException)2 AlreadyBoundException (java.rmi.AlreadyBoundException)2 KeyException (java.security.KeyException)2 HashMap (java.util.HashMap)2 ExecutionException (java.util.concurrent.ExecutionException)2 Consumes (javax.ws.rs.Consumes)2 ProActiveTimeoutException (org.objectweb.proactive.core.ProActiveTimeoutException)2