Permalink
Browse files

First commit of nimbus-admin tools method. Run bin/nimbus-admin to use.

  • Loading branch information...
1 parent 66232b0 commit 9f5a2fa94da8b439d3e4d7734a0bde7e52f7ee91 @rrusnak1 rrusnak1 committed with oldpatricka Jun 13, 2011
View
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+NIMBUS_HOME_REL="`dirname $0`/.."
+NIMBUS_HOME=`cd $NIMBUS_HOME_REL; pwd`
+export NIMBUS_HOME
+
+JAVALIB_DIR="$NIMBUS_HOME/services/lib"
+NATIVELIB_DIR="$NIMBUS_HOME/services/lib-native"
+CONF="$NIMBUS_HOME/services/etc/nimbus/workspace-service/admin.conf"
+
+EXEC="org.globus.workspace.remoting.admin.client.RemoteAdminToolsMain"
+JAVA_OPTIONS="-Dorg.newsclub.net.unix.library.path=${NATIVELIB_DIR}"
+CMD_OPTIONS="--conf ${CONF}"
+
+JARS="nimbus-workspace-service.jar nimbus-service-api.jar gson-1.4.jar \
+junixsocket-1.3.jar junixsocket-rmi-1.3.jar commons-cli-2.0.jar \
+log4j-1.2.15.jar commons-logging.jar"
+
+CLASSPATH=""
+for JAR in $JARS; do
+ CLASSPATH="${CLASSPATH}${JAVALIB_DIR}/${JAR}:"
+done
+
+if [ "X$JAVA_HOME" = "X" ] ; then
+ JAVA=java
+else
+ JAVA="$JAVA_HOME"/bin/java
+fi
+
+exec ${JAVA} ${JAVA_OPTIONS} ${OPTIONS} -classpath "${CLASSPATH}" ${EXEC} ${CMD_OPTIONS} "$@"
+
@@ -1,11 +1,29 @@
package org.nimbustools.api.services.admin;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.Hashtable;
+
/**
- * Created by IntelliJ IDEA.
+ * 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.
+ *
* User: rrusnak
- * Date: 5/26/11
- * Time: 11:06 AM
- * To change this template use File | Settings | File Templates.
*/
-public class RemoteAdminToolsManagement {
+public interface RemoteAdminToolsManagement extends Remote {
+
+ public Hashtable getAllRunningVMs() throws RemoteException;
+
}
@@ -32,4 +32,6 @@ socket.dir=$NIMBUS_HOME/var/run/privileged/
################################################################################
# name used for binding the VMM node management implementation
-rmi.binding.nodemgmt=nodemgmt
+rmi.binding.nodemgmt=nodemgmt
+# name used for binding the admin tools management implementation
+rmi.binding.admintools=admintools
@@ -735,16 +735,27 @@
<map>
<entry key="$ADMIN{rmi.binding.nodemgmt}"
value-ref="nimbus-remoting-nodemgmt" />
+ <entry key="$ADMIN{rmi.binding.admintools}"
+ value-ref="nimbus-remoting-admintoolsmgmt" />
</map>
</property>
</bean>
<bean id="nimbus-remoting-nodemgmt"
- class="org.globus.workspace.remoting.admin.defaults.DefaultRemoteNodeManagement"
- init-method="initialize">
+ class="org.globus.workspace.remoting.admin.defaults.DefaultRemoteNodeManagement">
<property name="nodeManagement" ref="nimbus-rm.scheduler.SlotManagement"/>
</bean>
+ <bean id="nimbus-remoting-admintoolsmgmt"
+ class="org.globus.workspace.remoting.admin.defaults.DefaultRemoteAdminToolsMgmt"
+ init-method="initialize">
+
+ <property name="manager"
+ ref="nimbus-rm.manager" />
+ <property name="reprFactory"
+ ref="nimbus-repr.ReprFactory" />
+ </bean>
+
<!-- ===================================================================
Externally written classes that are brought in as beans
=================================================================== -->
@@ -32,9 +32,10 @@
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.*;
+import java.util.concurrent.ExecutionException;
-public class AdminClient {
+public class AdminClient extends RMIConfig {
private static final Log logger =
LogFactory.getLog(AdminClient.class.getName());
@@ -44,7 +45,6 @@
public static final int EXIT_EXECUTION_PROBLEM = 2;
public static final int EXIT_UNKNOWN_PROBLEM = 3;
- private static final String PROP_SOCKET_DIR = "socket.dir";
private static final String PROP_RMI_BINDING_NODEMGMT_DIR = "rmi.binding.nodemgmt";
private static final String PROP_DEFAULT_MEMORY = "node.memory.default";
private static final String PROP_DEFAULT_NETWORKS = "node.networks.default";
@@ -85,9 +85,6 @@
private boolean nodeActive = true;
private boolean nodeActiveConfigured;
- private String configPath;
- private File socketDirectory;
- private String nodePoolBindingName;
private RemoteNodeManagement remoteNodeManagement;
private Reporter reporter;
private OutputStream outStream;
@@ -170,8 +167,8 @@ public void run(String[] args)
return;
}
- this.loadConfig(this.configPath);
- this.setupRemoting();
+ this.loadAdminClientConfig();
+ this.remoteNodeManagement = (RemoteNodeManagement) super.setupRemoting();
switch (this.action) {
case AddNodes:
@@ -287,110 +284,28 @@ private void run_updateNodes() throws ExecutionProblem {
}
}
- private void setupRemoting() throws ExecutionProblem {
- final RemotingClient client = new RemotingClient();
- client.setSocketDirectory(this.socketDirectory);
- try {
- client.initialize();
- } catch (RemoteException e) {
- handleRemoteException(e);
- }
-
- try {
- final Remote remote = client.lookup(this.nodePoolBindingName);
- logger.debug("Found remote object " + remote.toString());
- this.remoteNodeManagement = (RemoteNodeManagement) remote;
- } catch (RemoteException e) {
- handleRemoteException(e);
- } catch (NotBoundException e) {
- throw new ExecutionProblem("Failed to bind to object '" +
- this.nodePoolBindingName +
- "'. There may be a configuration problem between the "+
- "client and service. Error: "+ e.getMessage(), e);
- }
- }
-
- private void handleRemoteException(RemoteException e) throws ExecutionProblem {
- throw new ExecutionProblem(
- "Failed to connect to Nimbus service over domain sockets. "+
- "Is the service running?\n\nSocket directory: " +
- this.socketDirectory.getAbsolutePath() + "\n\nError: " +
- e.getMessage(), e);
- }
-
- private void loadConfig(String configPath)
- throws ParameterProblem, ExecutionProblem {
- if (configPath == null) {
- throw new ParameterProblem("Config path is invalid");
- }
-
- final File configFile = new File(configPath);
-
- logger.debug("Loading config file: " + configFile.getAbsolutePath());
-
- if (!configFile.canRead()) {
- throw new ParameterProblem(
- "Specified config file path does not exist or is not readable: " +
- configFile.getAbsolutePath());
- }
-
- final Properties props = new Properties();
- try {
- FileInputStream inputStream = null;
- try {
- inputStream = new FileInputStream(configFile);
- props.load(inputStream);
- } finally {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- } catch (IOException e) {
- logger.debug("Caught error reading config file " + configFile.getAbsolutePath(), e);
- throw new ParameterProblem("Failed to load config file: " +
- configFile.getAbsolutePath() + ": " + e.getMessage(), e);
- }
-
- final String sockDir = props.getProperty(PROP_SOCKET_DIR);
- if (sockDir == null) {
- throw new ExecutionProblem("Configuration file is missing "+
- PROP_SOCKET_DIR + " entry: " + configFile.getAbsolutePath());
- }
-
- final NimbusHomePathResolver resolver = new NimbusHomePathResolver();
- String path = resolver.resolvePath(sockDir);
- if (path == null) {
- path = sockDir;
- }
- this.socketDirectory = new File(path);
-
- final String nodePoolBinding = props.getProperty(PROP_RMI_BINDING_NODEMGMT_DIR);
- if (nodePoolBinding == null) {
- throw new ExecutionProblem("Configuration file is missing " +
- PROP_RMI_BINDING_NODEMGMT_DIR + " entry: "+
- configFile.getAbsolutePath());
- }
- this.nodePoolBindingName = nodePoolBinding;
+ private void loadAdminClientConfig() throws ParameterProblem, ExecutionProblem {
+ super.loadConfig(PROP_RMI_BINDING_NODEMGMT_DIR);
// only need node parameter values if doing add-nodes
if (this.action == AdminAction.AddNodes) {
if (!this.nodeMemoryConfigured) {
- final String memString = props.getProperty(PROP_DEFAULT_MEMORY);
+ final String memString = properties.getProperty(PROP_DEFAULT_MEMORY);
if (memString != null) {
this.nodeMemory = parseMemory(memString);
this.nodeMemoryConfigured = true;
}
}
if (this.nodeNetworks == null) {
- this.nodeNetworks = props.getProperty(PROP_DEFAULT_NETWORKS);
+ this.nodeNetworks = properties.getProperty(PROP_DEFAULT_NETWORKS);
}
if (this.nodePool == null) {
// if missing or invalid, error will come later if this value is actually needed
- this.nodePool = props.getProperty(PROP_DEFAULT_POOL);
+ this.nodePool = properties.getProperty(PROP_DEFAULT_POOL);
}
}
}
Oops, something went wrong.

0 comments on commit 9f5a2fa

Please sign in to comment.