Search in sources :

Example 1 with EventNotification

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification in project scheduling by ow2-proactive.

the class SchedulerEventBroadcaster method schedulerStateUpdatedEvent.

@Override
public void schedulerStateUpdatedEvent(SchedulerEvent schedulerEvent) {
    logEvent(schedulerEvent);
    broadcast(new EventNotification(EventNotification.Action.SCHEDULER_STATE_UPDATED, schedulerEvent.name(), null));
}
Also used : EventNotification(org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification)

Example 2 with EventNotification

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification in project scheduling by ow2-proactive.

the class SchedulerEventBroadcaster method jobUpdatedFullDataEvent.

@Override
public void jobUpdatedFullDataEvent(JobState jobState) {
    logEvent(jobState);
    broadcast(new EventNotification(EventNotification.Action.JOB_FULL_DATA_UPDATED, SchedulerEvent.JOB_UPDATED.name(), jobState));
}
Also used : EventNotification(org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification)

Example 3 with EventNotification

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification in project scheduling by ow2-proactive.

the class SchedulerEventBroadcaster method taskStateUpdatedEvent.

@Override
public void taskStateUpdatedEvent(NotificationData<TaskInfo> notification) {
    logEvent(notification);
    TaskInfoData taskInfoData = dozerMapper.map(notification.getData(), TaskInfoData.class);
    broadcast(new EventNotification(EventNotification.Action.TASK_STATE_UPDATED, eventTypeName(notification), taskInfoData));
}
Also used : EventNotification(org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification) TaskInfoData(org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData)

Example 4 with EventNotification

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification in project scheduling by ow2-proactive.

the class SchedulerEventBroadcaster method jobStateUpdatedEvent.

@Override
public void jobStateUpdatedEvent(NotificationData<JobInfo> notification) {
    logEvent(notification);
    broadcast(new EventNotification(EventNotification.Action.JOB_STATE_UPDATED, eventTypeName(notification), notification.getData()));
}
Also used : EventNotification(org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification)

Example 5 with EventNotification

use of org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification 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 RestException {
    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 (SchedulerException e) {
        throw RestException.wrapExceptionToRest(e);
    } catch (ActiveObjectCreationException | NodeException e) {
        throw new RuntimeException(e);
    }
    return new EventNotification(EventNotification.Action.NONE, null, null);
}
Also used : EventNotification(org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification) WebSocketEventListenerAdapter(org.atmosphere.websocket.WebSocketEventListenerAdapter) 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) LoginException(javax.security.auth.login.LoginException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException) KeyException(java.security.KeyException) URISyntaxException(java.net.URISyntaxException) LogForwardingException(org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingException) NodeException(org.objectweb.proactive.core.node.NodeException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException)

Aggregations

EventNotification (org.ow2.proactive_grid_cloud_portal.scheduler.dto.eventing.EventNotification)7 URISyntaxException (java.net.URISyntaxException)1 KeyException (java.security.KeyException)1 LoginException (javax.security.auth.login.LoginException)1 HttpSession (javax.servlet.http.HttpSession)1 AtmosphereResource (org.atmosphere.cpr.AtmosphereResource)1 WebSocketEventListenerAdapter (org.atmosphere.websocket.WebSocketEventListenerAdapter)1 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)1 NodeException (org.objectweb.proactive.core.node.NodeException)1 SchedulerProxyUserInterface (org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface)1 LogForwardingException (org.ow2.proactive.scheduler.common.util.logforwarder.LogForwardingException)1 TaskInfoData (org.ow2.proactive_grid_cloud_portal.scheduler.dto.TaskInfoData)1