001/*
002 * JPPF.
003 * Copyright (C) 2005-2018 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 configOverrides the set of properties to update.
104   * @param restart specifies whether the node should be restarted after updating the properties.
105   * @param interruptIfRunning when {@code true}, then restart the node even if it is executing tasks, when {@code false}, then only shutdown the node when it is no longer executing.
106   * This parameter only applies when the {@code restart} parameter is {@code true}.
107   * @throws Exception if any error occurs.
108   * @since 5.2
109   */
110  void updateConfiguration(Map<Object, Object> configOverrides, Boolean restart, Boolean interruptIfRunning) throws Exception;
111
112  /**
113   * Update the configuration properties of the node. This method is equivalent to calling {@link #updateConfiguration(Map, Boolean, Boolean) updateConfiguration(configOverrides, restart, true)}.
114   * @param configOverrides the set of properties to update.
115   * @param restart specifies whether the node should be restarted after updating the properties.
116   * @throws Exception if any error occurs.
117   */
118  void updateConfiguration(Map<Object, Object> configOverrides, Boolean restart) throws Exception;
119
120  /**
121   * Cancel the job with the specified id.
122   * @param jobId the id of the job to cancel.
123   * @param requeue true if the job should be requeued on the server side, false otherwise.
124   * @throws Exception if any error occurs.
125   */
126  void cancelJob(String jobId, Boolean requeue) throws Exception;
127
128  /**
129   * Get the current class loader delegation model for the node.
130   * @return either {@link org.jppf.classloader.DelegationModel#PARENT_FIRST PARENT_FIRST} or {@link org.jppf.classloader.DelegationModel#URL_FIRST LOCAL_FIRST}.
131   * @throws Exception if any error occurs.
132   */
133  DelegationModel getDelegationModel() throws Exception;
134
135  /**
136   * Set the current class loader delegation model for the node.
137   * @param model either either {@link org.jppf.classloader.DelegationModel#PARENT_FIRST PARENT_FIRST} or {@link org.jppf.classloader.DelegationModel#URL_FIRST LOCAL_FIRST}.
138   * If any other value is specified then this method has no effect.
139   * @throws Exception if any error occurs.
140   */
141  void setDelegationModel(DelegationModel model) throws Exception;
142
143  /**
144   * Determine wether a deffered shutdwon or restartd was requested and not yet performed for the node.
145   * @return one of the possible pending actions specified in the enum {@link NodePendingAction}.
146   */
147  NodePendingAction pendingAction();
148
149  /**
150   * Cancel a previous deferred shutdown or restart request, if any.
151   * @return {@code true} if the node has a pending action and it was cancelled, {@code false} otherwise.
152   */
153  boolean cancelPendingAction();
154}