Package org.glite.ce.creamapi.cmdmanagement

Examples of org.glite.ce.creamapi.cmdmanagement.Command


                pstmt.setInt(index, limit);
            }

            rset = pstmt.executeQuery();

            Command command = null;
            Calendar calendar = null;
            Timestamp timestamp = null;

            if (rset != null) {               
                query = new StringBuffer(" IN (");

                while (rset.next()) {
                    command = new Command(rset.getString(NAME_FIELD), rset.getString(CATEGORY_FIELD));
                    command.setId(rset.getLong(ID_FIELD));
                    command.setUserId(rset.getString(USER_ID_FIELD));
                    command.setDescription(rset.getString(DESCRIPTION_FIELD));
                    command.setFailureReason(rset.getString(FAILURE_REASON_FIELD));
                    command.setCommandGroupId(rset.getString(COMMAND_GROUP_ID_FIELD));
                    command.setAsynchronous(true);
                    command.setPriorityLevel(rset.getInt(PRIORITY_LEVEL_FIELD));
                    command.setExecutionMode(ExecutionModeValues.PARALLEL.equals(rset.getString(EXECUTION_MODE_FIELD)) ? ExecutionModeValues.PARALLEL: ExecutionModeValues.SERIAL);

                    calendar = null;
                    timestamp = rset.getTimestamp(CREATION_TIME_FIELD);
                    if (timestamp != null) {
                        calendar = Calendar.getInstance();
                        calendar.setTimeInMillis(timestamp.getTime());
                        command.setCreationTime(calendar);
                    }

                    commandList.put(""+command.getId(), command);

                    query.append("'").append(command.getId()).append("',");
                }

                query.replace(query.length() - 1, query.length(), ")");

                if (commandList.size() > 0) {
                    StringBuffer setScheduledQuery = new StringBuffer("update ");
                    setScheduledQuery.append(QUEUE_TABLE).append(" set ").append(IS_SCHEDULED_FIELD);
                    setScheduledQuery.append(" = true where ").append(ID_FIELD).append(query);

                    pstmt = connection.prepareStatement(setScheduledQuery.toString());
                    pstmt.executeUpdate();

                    StringBuffer selectParameterQuery = new StringBuffer("select ");
                    selectParameterQuery.append(PARAMETER_TABLE).append(".").append(ID_FIELD).append(" as PARAMETER_ID, ");
                    selectParameterQuery.append(PARAMETER_TABLE).append(".").append(COMMAND_ID_FIELD).append(" as ").append(COMMAND_ID_FIELD).append(", ");
                    selectParameterQuery.append(PARAMETER_TABLE).append(".").append(NAME_FIELD).append(" as PARAMETER_NAME, ");
                    selectParameterQuery.append(PARAMETER_TABLE).append(".").append(VALUE_FIELD).append(" as PARAMETER_VALUE from ");
                    selectParameterQuery.append(PARAMETER_TABLE).append(" where ").append(COMMAND_ID_FIELD).append(query);

                    pstmt = connection.prepareStatement(selectParameterQuery.toString());
                    rset = pstmt.executeQuery();

                    if (rset != null) {
                        long commandId = -1;

                        while (rset.next()) {
                            commandId = rset.getLong(COMMAND_ID_FIELD);

                            command = commandList.get(""+commandId);

                            if (commandId > 0) {
                                parameterName = rset.getString("PARAMETER_NAME");
                                parameterValue = rset.getString("PARAMETER_VALUE");

                                if (command.containsParameterKey(parameterName)) {
                                    List<String> valueList = command.getParameterMultivalue(parameterName);
                                    valueList.add(parameterValue);

                                    command.addParameter(parameterName, valueList);
                                } else {
                                    command.addParameter(parameterName, parameterValue);
                                }
                            }
                        }
                    }
                }
View Full Code Here


        if (queue.size() == 0) {
            return null;
        }
       
        Command command = null;
       
        try {
            command =  queue.peek();

            synchronized (lastThroughputUpdate) {
View Full Code Here

       
        if (queue.size() == 0) {
            return null;
        }
       
        Command command = null;
       
        try {
            command =  queue.poll();
            dequeue(command);
View Full Code Here

       
        if (queue.size() == 0) {
            throw new CommandQueueException("the queue " + QUEUE_TABLE + " is empty!");
        }
       
        Command command = null;
       
        try {
            command =  queue.remove();
            dequeue(command);
           
View Full Code Here

     * Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.
     * @return the head of this queue.
     * @throws CommandQueueException - if this queue closed or if interrupted while waiting
     */
    public Command take() throws CommandQueueException {
        Command command = null;
       
        try {
            synchronized (queueLock) {
                while ((queue.size() == 0) && (isOpen)) {
                    logger.debug("Waiting for items because queue.size=0.");
View Full Code Here

                    update = true;
                }
            }

            if(update) {
                Command statusCmd = new Command(JobCommandConstant.SET_JOB_STATUS, getCategory());
                //statusCmd.setCommandExecutorName(blahExec.getName());
                statusCmd.setAsynchronous(true);
                statusCmd.setUserId("admin");
                statusCmd.addParameter("JOB_ID", lastStatus.getJobId());
                statusCmd.addParameter("STATUS_TYPE", ""+lastStatus.getType());
               // statusCmd.addParameter("STATUS_CHANGE_TIME", lastStatus.getTimestamp());
               // statusCmd.addParameter("WORKER_NODE", workerNode);
               // statusCmd.addParameter("LRMS_JOB_ID", batchJobId);
                statusCmd.addParameter("IS_ADMIN", "true");
                statusCmd.addParameter("EXIT_CODE", lastStatus.getExitCode());
                statusCmd.addParameter("FAILURE_REASON", lastStatus.getFailureReason());
                statusCmd.setPriorityLevel(Command.MEDIUM_PRIORITY);
                statusCmd.setExecutionMode(Command.ExecutionModeValues.SERIAL);
                statusCmd.setCommandGroupId(lastStatus.getJobId());

                if (lastStatus.getTimestamp() != null) {
                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

                    statusCmd.addParameter("STATUS_CHANGE_TIME", dateFormat.format(lastStatus.getTimestamp().getTime()));
                }

                try {
                    getCommandManager().execute(statusCmd);
                } catch (Throwable e) {
View Full Code Here

                    for (String jobId : jobIdList) {
                        if (terminate) {
                            break;
                        }

                        Command purgeCmd = new Command(JobCommandConstant.JOB_PURGE, JobCommandConstant.JOB_MANAGEMENT);
                        purgeCmd.setUserId("ADMIN");
                        purgeCmd.setDescription("Cancelled by CREAM's job purger");
                        purgeCmd.setAsynchronous(false);
                        purgeCmd.setCommandGroupId(jobId);
                        purgeCmd.addParameter("JOB_ID", jobId);
                        purgeCmd.addParameter("IS_ADMIN", Boolean.toString(true));
                        purgeCmd.setPriorityLevel(Command.LOW_PRIORITY);

                        executor.execute(purgeCmd);
                    }
                } catch (Throwable t) {
                    logger.error(t.getMessage());
View Full Code Here

TOP

Related Classes of org.glite.ce.creamapi.cmdmanagement.Command

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.