001/*
002 * JPPF.
003 * Copyright (C) 2005-2015 JPPF Team.
004 * http://www.jppf.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.jppf.management;
020
021import java.util.Map;
022
023import org.jppf.classloader.DelegationModel;
024
025
026/**
027 * Exposed interface of the JPPF node management bean.
028 * @author Laurent Cohen
029 */
030public interface JPPFNodeAdminMBean extends JPPFAdminMBean {
031  /**
032   * Name of the node's admin MBean.
033   */
034  String MBEAN_NAME = "org.jppf:name=admin,type=node";
035
036  /**
037   * Get the latest state information from the node.
038   * @return a <code>JPPFNodeState</code> information.
039   * @throws Exception if any error occurs.
040   */
041  JPPFNodeState state() throws Exception;
042
043  /**
044   * Set the size of the node's thread pool.
045   * @param size the size as an int.
046   * @throws Exception if any error occurs.
047   */
048  void updateThreadPoolSize(Integer size) throws Exception;
049
050  /**
051   * Update the priority of all execution threads.
052   * @param newPriority the new priority to set.
053   * @throws Exception if an error is raised when invoking the node mbean.
054   */
055  void updateThreadsPriority(Integer newPriority) throws Exception;
056
057  /**
058   * Restart the node.
059   * This is equivalent to calling {@code restart(true)}.
060   * @throws Exception if any error occurs.
061   */
062  void restart() throws Exception;
063
064  /**
065   * Restart the node.
066   * @param interruptIfRunning when {@code true}, then restart the node even if it is executing tasks,
067   * when {@code false}, then only restart the node when it is no longer executing.
068   * @throws Exception if any error occurs.
069   * @since 5.0
070   */
071  void restart(Boolean interruptIfRunning) throws Exception;
072
073  /**
074   * Shutdown the node.
075   * @throws Exception if any error occurs.
076   */
077  void shutdown() throws Exception;
078
079  /**
080   * Shutdown the node.
081   * @param interruptIfRunning when {@code true}, then shutdown the node even if it is executing tasks,
082   * when {@code false}, then only shutdown the node when it is no longer executing.
083   * @throws Exception if any error occurs.
084   * @since 5.0
085   */
086  void shutdown(Boolean interruptIfRunning) throws Exception;
087
088  /**
089   * Reset the node's executed tasks counter to zero.
090   * @throws Exception if any error occurs.
091   */
092  void resetTaskCounter() throws Exception;
093
094  /**
095   * Reset the node's executed tasks counter to the specified value.
096   * @param n the number to set the task counter to.
097   * @throws Exception if any error occurs.
098   */
099  void setTaskCounter(Integer n) throws Exception;
100
101  /**
102   * Update the configuration properties of the node.
103   * @param config the set of properties to update.
104   * @param reconnect specifies whether the node should reconnect ot the driver after updating the properties.
105   * @throws Exception if any error occurs.
106   */
107  void updateConfiguration(Map<Object, Object> config, Boolean reconnect) throws Exception;
108
109  /**
110   * Cancel the job with the specified id.
111   * @param jobId the id of the job to cancel.
112   * @param requeue true if the job should be requeued on the server side, false otherwise.
113   * @throws Exception if any error occurs.
114   */
115  void cancelJob(String jobId, Boolean requeue) throws Exception;
116
117  /**
118   * Get the current class loader delegation model for the node.
119   * @return either {@link org.jppf.classloader.DelegationModel#PARENT_FIRST PARENT_FIRST} or {@link org.jppf.classloader.DelegationModel#URL_FIRST LOCAL_FIRST}.
120   * @throws Exception if any error occurs.
121   * @see org.jppf.classloader.AbstractJPPFClassLoader#getDelegationModel()
122   */
123  DelegationModel getDelegationModel() throws Exception;
124
125  /**
126   * Set the current class loader delegation model for the node.
127   * @param model either either {@link org.jppf.classloader.DelegationModel#PARENT_FIRST PARENT_FIRST} or {@link org.jppf.classloader.DelegationModel#URL_FIRST LOCAL_FIRST}.
128   * If any other value is specified then this method has no effect.
129   * @throws Exception if any error occurs.
130   * @see org.jppf.classloader.AbstractJPPFClassLoader#setDelegationModel(org.jppf.classloader.DelegationModel)
131   */
132  void setDelegationModel(DelegationModel model) throws Exception;
133
134  /**
135   * Determine wether a deffered shutdwon or restartd was requested and not yet performed for the node.
136   * @return one of the possible pending actions specified in the enum {@link NodePendingAction}.
137   */
138  NodePendingAction pendingAction();
139
140  /**
141   * Cancel a previous deferred shutdown or restart request, if any.
142   * @return {@code true} if the node has a pending action and it was cancelled, {@code false} otherwise.
143   */
144  boolean cancelPendingAction();
145}