Package org.apache.airavata.gfac.core.monitor

Examples of org.apache.airavata.gfac.core.monitor.MonitorID


    public void run() {
        // before going to the while true mode we start unregister thread
        startRegister = true; // this will be unset by someone else
        while (startRegister || !ServerSettings.isStopAllThreads()) {
            try {
                MonitorID take = runningQueue.take();
                this.registerListener(take);
            } catch (AiravataMonitorException e) { // catch any exceptino inside the loop
                e.printStackTrace();
            } catch (InterruptedException e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
View Full Code Here


    }

    @Subscribe
    public boolean unRegisterListener(MonitorID monitorID) throws AiravataMonitorException {
        Iterator<MonitorID> iterator = finishQueue.iterator();
        MonitorID next = null;
        while(iterator.hasNext()){
            next = iterator.next();
            if(next.getJobID().endsWith(monitorID.getJobID())){
                break;
            }
        }
        if(next == null) {
            logger.error("Job has removed from the queue, old obsolete message recieved");
            return false;
        }
        String channelID = CommonUtils.getChannelID(next);
        if (JobState.FAILED.equals(monitorID.getStatus()) || JobState.COMPLETE.equals(monitorID.getStatus())) {
            finishQueue.remove(next);

            // if this is the last job in the queue at this point with the same username and same host we
            // close the channel and close the connection and remove it from availableChannels
            if (CommonUtils.isTheLastJobInQueue(finishQueue, next)) {
                logger.info("There are no jobs to monitor for common ChannelID:" + channelID + " , so we unsubscribe it" +
                        ", incase new job created we do subscribe again");
                Channel channel = availableChannels.get(channelID);
                if (channel == null) {
                    logger.error("Already Unregistered the listener");
                    throw new AiravataMonitorException("Already Unregistered the listener");
                } else {
                    try {
                        channel.queueUnbind(channel.queueDeclare().getQueue(), "glue2.computing_activity", CommonUtils.getRoutingKey(next));
                        channel.close();
                        channel.getConnection().close();
                        availableChannels.remove(channelID);
                    } catch (IOException e) {
                        logger.error("Error unregistering the listener");
                        throw new AiravataMonitorException("Error unregistering the listener");
                    }
                }
            }
        }
        next.setStatus(monitorID.getStatus());
        publisher.publish(new JobStatusChangeRequest(next, new JobIdentity(next.getExperimentID(), next.getWorkflowNodeID(), next.getTaskID(), next.getJobID()),next.getStatus()));
        return true;
    }
View Full Code Here

        //finished construction of job object
        System.out.println(jobDescriptor.toXML());
        for (int i = 0; i < 1; i++) {
            String jobID = pbsCluster.submitBatchJob(jobDescriptor);
            System.out.println("Job submitted successfully, Job ID: " +  jobID);
            MonitorID monitorID = new HPCMonitorID(hostDescription, jobID,null,null,null, "ogce");
            ((HPCMonitorID)monitorID).setAuthenticationInfo(authenticationInfo);
            try {
                org.apache.airavata.gfac.monitor.util.CommonUtils.addMonitortoQueue(pullQueue, monitorID);
            } catch (Exception e) {
                e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
View Full Code Here

        logger.debug("************************************************************");
        logger.debug("AMQP Message recieved \n" + message);
        logger.debug("************************************************************");
        try {
            String jobID = envelope.getRoutingKey().split("\\.")[0];
            MonitorID monitorID = new MonitorID(null, jobID, null, null, null, null);
            monitorID.setStatus(parser.parseMessage(message));
            publisher.publish(monitorID);
        } catch (AiravataMonitorException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

        this.availableChannels = channels;
    }

    @Subscribe
    private boolean unRegisterListener(JobStatusChangeRequest jobStatus) throws AiravataMonitorException {
        MonitorID monitorID = jobStatus.getMonitorID();
        String channelID = CommonUtils.getChannelID(monitorID);
        if (JobState.FAILED.equals(jobStatus.getState()) || JobState.COMPLETE.equals(jobStatus.getState())){
            Channel channel = availableChannels.get(channelID);
            if (channel == null) {
                logger.error("Already Unregistered the listener");
View Full Code Here

        //finished construction of job object
        System.out.println(jobDescriptor.toXML());
        String jobID = pbsCluster.submitBatchJob(jobDescriptor);
        System.out.println(jobID);
        try {
            pushQueue.add(new MonitorID(hostDescription, jobID,null,null,null, "ogce"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            pushThread.join();
View Full Code Here

TOP

Related Classes of org.apache.airavata.gfac.core.monitor.MonitorID

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.