Skip to content
Browse files

when pilot is enabled, the nimbus-nodes program will get an error

  • Loading branch information...
1 parent 77fab4d commit 0ff2d63a269604fd96a8852e62332237f287adff @timf timf committed Nov 8, 2010
View
58 .../source/src/org/globus/workspace/remoting/admin/defaults/DefaultRemoteNodeManagement.java
@@ -25,6 +25,7 @@
import org.globus.workspace.scheduler.NodeExistsException;
import org.globus.workspace.scheduler.NodeInUseException;
import org.globus.workspace.scheduler.NodeManagement;
+import org.globus.workspace.scheduler.NodeManagementDisabled;
import org.globus.workspace.scheduler.NodeNotFoundException;
import org.globus.workspace.scheduler.defaults.ResourcepoolEntry;
@@ -41,7 +42,7 @@
private final Gson gson;
private final TypeToken<Collection<VmmNode>> vmmNodeCollectionTypeToken;
- private NodeManagement nodeManagement;
+ private NodeManagement nodeManagement = null;
public DefaultRemoteNodeManagement() {
this.gson = new Gson();
@@ -50,7 +51,7 @@ public DefaultRemoteNodeManagement() {
public void initialize() throws Exception {
if (nodeManagement == null) {
- throw new IllegalArgumentException("nodeManagement may not be null");
+ logger.warn("Node management disabled");
}
}
@@ -94,16 +95,36 @@ public String addNodes(String nodeJson) throws RemoteException {
logger.info("VMM node " + hostname + " already existed");
reports.add(new NodeReport(hostname,
NodeReport.STATE_NODE_EXISTS, null));
+ } catch (NodeManagementDisabled e) {
+ throw new RemoteException(e.getMessage());
}
}
return gson.toJson(reports);
}
- public String listNodes() {
+ /**
+ * If a mgmt ooperation is attempted and there is no active node management instance,
+ * return a disabled message.
+ */
+ private void checkActive() throws RemoteException {
+ if (this.nodeManagement == null) {
+ throw new RemoteException("Remote node administration is disabled. " +
+ "Are you in pilot mode?");
+ }
+ }
+ public String listNodes() throws RemoteException {
+
+ checkActive();
+
logger.debug("Listing VMM nodes");
- final List<ResourcepoolEntry> entries = nodeManagement.getNodes();
+ final List<ResourcepoolEntry> entries;
+ try {
+ entries = nodeManagement.getNodes();
+ } catch (NodeManagementDisabled e) {
+ throw new RemoteException(e.getMessage());
+ }
final List<VmmNode> nodes = new ArrayList<VmmNode>(entries.size());
for (ResourcepoolEntry entry : entries) {
nodes.add(translateResourcepoolEntry(entry));
@@ -112,7 +133,7 @@ public String listNodes() {
return gson.toJson(nodes);
}
- public String getNode(String hostname) {
+ public String getNode(String hostname) throws RemoteException {
if (hostname == null) {
throw new IllegalArgumentException("hostname may not be null");
@@ -121,15 +142,21 @@ public String getNode(String hostname) {
logger.debug("Listing VMM node " + hostname);
- final ResourcepoolEntry entry = nodeManagement.getNode(hostname);
+ final ResourcepoolEntry entry;
+ try {
+ entry = nodeManagement.getNode(hostname);
+ } catch (NodeManagementDisabled e) {
+ throw new RemoteException(e.getMessage());
+ }
return gson.toJson(translateResourcepoolEntry(entry));
}
public String updateNodes(String[] hostnames,
Boolean active,
String pool,
Integer memory,
- String networks) {
+ String networks) throws RemoteException {
+
if (hostnames == null) {
throw new IllegalArgumentException("hostnames may not be null");
}
@@ -153,8 +180,13 @@ public String updateNodes(String[] hostnames,
logger.info("Updating VMM node: " + hostname);
try {
- final ResourcepoolEntry entry = nodeManagement.updateNode(
- hostname, pool, networks, memory, active);
+ final ResourcepoolEntry entry;
+ try {
+ entry = nodeManagement.updateNode(
+ hostname, pool, networks, memory, active);
+ } catch (NodeManagementDisabled e) {
+ throw new RemoteException(e.getMessage());
+ }
final VmmNode node = translateResourcepoolEntry(entry);
reports.add(new NodeReport(hostname, NodeReport.STATE_UPDATED,
@@ -175,12 +207,12 @@ public String updateNodes(String[] hostnames,
return gson.toJson(reports);
}
- public String removeNode(String hostname) {
+ public String removeNode(String hostname) throws RemoteException {
NodeReport report = _removeNode(hostname);
return gson.toJson(report);
}
- private NodeReport _removeNode(String hostname) {
+ private NodeReport _removeNode(String hostname) throws RemoteException {
if (hostname == null) {
throw new IllegalArgumentException("hostname may not be null");
}
@@ -199,12 +231,14 @@ private NodeReport _removeNode(String hostname) {
}
} catch (NodeInUseException e) {
state = NodeReport.STATE_NODE_IN_USE;
+ } catch (NodeManagementDisabled e) {
+ throw new RemoteException(e.getMessage());
}
return new NodeReport(hostname, state, null);
}
- public String removeNodes(String[] hostnames) {
+ public String removeNodes(String[] hostnames) throws RemoteException {
if (hostnames == null || hostnames.length == 0) {
throw new IllegalArgumentException("hostnames may not be null or empty");
}
View
10 service/service/java/source/src/org/globus/workspace/scheduler/NodeManagement.java
@@ -27,11 +27,11 @@ public ResourcepoolEntry addNode(String hostname,
String networks,
int memory,
boolean active)
- throws NodeExistsException;
+ throws NodeExistsException, NodeManagementDisabled;
//Read
- public List<ResourcepoolEntry> getNodes();
- public ResourcepoolEntry getNode(String hostname);
+ public List<ResourcepoolEntry> getNodes() throws NodeManagementDisabled;
+ public ResourcepoolEntry getNode(String hostname) throws NodeManagementDisabled;
//Update
@@ -54,9 +54,9 @@ public ResourcepoolEntry updateNode(String hostname,
String networks,
Integer memory,
Boolean active)
- throws NodeInUseException, NodeNotFoundException;
+ throws NodeInUseException, NodeNotFoundException, NodeManagementDisabled;
//Delete `
public boolean removeNode(String hostname)
- throws NodeInUseException;
+ throws NodeInUseException, NodeManagementDisabled;
}
View
39 service/service/java/source/src/org/globus/workspace/scheduler/NodeManagementDisabled.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 1999-2010 University of Chicago
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.globus.workspace.scheduler;
+
+import org.globus.workspace.WorkspaceException;
+
+public class NodeManagementDisabled extends WorkspaceException {
+
+ public NodeManagementDisabled() {
+ super();
+ }
+
+ public NodeManagementDisabled(String message) {
+ super(message);
+ }
+
+ public NodeManagementDisabled(String message, Exception e) {
+ super(message, e);
+
+ }
+
+ public NodeManagementDisabled(Exception e) {
+ super("", e);
+ }
+}
View
38 ...ce/java/source/src/org/globus/workspace/scheduler/defaults/pilot/PilotSlotManagement.java
@@ -20,6 +20,12 @@
import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.globus.workspace.scheduler.NodeExistsException;
+import org.globus.workspace.scheduler.NodeInUseException;
+import org.globus.workspace.scheduler.NodeManagement;
+import org.globus.workspace.scheduler.NodeManagementDisabled;
+import org.globus.workspace.scheduler.NodeNotFoundException;
+import org.globus.workspace.scheduler.defaults.ResourcepoolEntry;
import org.nimbustools.api.services.rm.DoesNotExistException;
import org.nimbustools.api.services.rm.ResourceRequestDeniedException;
import org.nimbustools.api.services.rm.ManageException;
@@ -51,9 +57,11 @@
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
+import java.util.List;
public class PilotSlotManagement implements SlotManagement,
- SlotPollCallback {
+ SlotPollCallback,
+ NodeManagement {
// -------------------------------------------------------------------------
// STATIC VARIABLES
@@ -67,6 +75,9 @@
"pilot). Please contact your administrator with the time of " +
"this problem and any relevant information";
+ private static final String REMOTE_NODE_MGR_DISABLED = "Pilot mode: node management " +
+ "is not possible, use the LRM for node management";
+
private static final Exception SEVERE_PILOT_FAULT =
new Exception(SEVERE_PILOT_ISSUE);
@@ -1630,4 +1641,29 @@ private void cancelWorkspace(int vmid,
}
}
}
+
+ public ResourcepoolEntry addNode(String hostname, String pool, String networks, int memory,
+ boolean active)
+ throws NodeExistsException, NodeManagementDisabled {
+ throw new NodeManagementDisabled(REMOTE_NODE_MGR_DISABLED);
+ }
+
+ public List<ResourcepoolEntry> getNodes() throws NodeManagementDisabled {
+ throw new NodeManagementDisabled(REMOTE_NODE_MGR_DISABLED);
+ }
+
+ public ResourcepoolEntry getNode(String hostname) throws NodeManagementDisabled {
+ throw new NodeManagementDisabled(REMOTE_NODE_MGR_DISABLED);
+ }
+
+ public ResourcepoolEntry updateNode(String hostname, String pool, String networks,
+ Integer memory, Boolean active)
+ throws NodeInUseException, NodeNotFoundException, NodeManagementDisabled {
+ throw new NodeManagementDisabled(REMOTE_NODE_MGR_DISABLED);
+ }
+
+ public boolean removeNode(String hostname)
+ throws NodeInUseException, NodeManagementDisabled {
+ throw new NodeManagementDisabled(REMOTE_NODE_MGR_DISABLED);
+ }
}

0 comments on commit 0ff2d63

Please sign in to comment.
Something went wrong with that request. Please try again.