idok-commit AT lists.psi.ch
Subject: Commit emails of the iDok project
List archive
[idok-commit] idok commit r249 - in trunk: java/ch/idok/dmsd/impl/controller java/ch/idok/dmsd/main sites/psi/scripts/admin/dmsd
Chronological Thread
- From: "AFS account Stadler Hans Christian" <stadler_h AT savannah.psi.ch>
- To: idok-commit AT lists.psi.ch
- Subject: [idok-commit] idok commit r249 - in trunk: java/ch/idok/dmsd/impl/controller java/ch/idok/dmsd/main sites/psi/scripts/admin/dmsd
- Date: Wed, 24 Sep 2008 17:00:28 +0200
- List-archive: <https://lists.web.psi.ch/pipermail/idok-commit/>
- List-id: Commit emails of the iDok project <idok-commit.lists.psi.ch>
Author: stadler_h
Date: Wed Sep 24 17:00:27 2008
New Revision: 249
Log:
Improved external command logging
Modified:
trunk/java/ch/idok/dmsd/impl/controller/ExternalDaemonController.java
trunk/java/ch/idok/dmsd/main/Daemon.java
trunk/sites/psi/scripts/admin/dmsd/build.xml
Modified:
trunk/java/ch/idok/dmsd/impl/controller/ExternalDaemonController.java
==============================================================================
--- trunk/java/ch/idok/dmsd/impl/controller/ExternalDaemonController.java
(original)
+++ trunk/java/ch/idok/dmsd/impl/controller/ExternalDaemonController.java
Wed Sep 24 17:00:27 2008
@@ -27,6 +27,7 @@
import ch.idok.common.errorhandling.DmsException;
import ch.idok.common.errorhandling.ErrorType;
+import ch.idok.dmsd.config.Setup;
import ch.idok.dmsd.management.ExternalDaemonControl;
/**
@@ -75,23 +76,30 @@
* If the connection fails.
*/
private SimpleControllerManagerMBean jmxConnect(String host, String port)
- throws Exception {
- JMXServiceURL jmxURL = new JMXServiceURL(
- "service:jmx:rmi:///jndi/rmi://" + host + ":" + port
- + "/jmxrmi");
- JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxURL);
- SimpleControllerManagerMBean simpleControl =
(SimpleControllerManagerMBean) MBeanServerInvocationHandler
- .newProxyInstance(jmxConnector.getMBeanServerConnection(),
- new
ObjectName(SimpleControllerManagerMBean.MBeanName),
- SimpleControllerManagerMBean.class, false);
- if (simpleControl == null)
- DmsException
- .throwIt(
- ErrorType.JMX_ACCESS,
- this,
- "Cannot communicate with the DMS daemon",
- "MBeanServerInvocationHandler.newProxyInstance
failed for SimpleControllerManagerMBean");
- return simpleControl;
+ throws DmsException {
+ try {
+ JMXServiceURL jmxURL = new JMXServiceURL(
+ "service:jmx:rmi:///jndi/rmi://" + host + ":" + port
+ + "/jmxrmi");
+ JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxURL);
+ SimpleControllerManagerMBean simpleControl =
(SimpleControllerManagerMBean) MBeanServerInvocationHandler
+
.newProxyInstance(jmxConnector.getMBeanServerConnection(),
+ new
ObjectName(SimpleControllerManagerMBean.MBeanName),
+ SimpleControllerManagerMBean.class, false);
+ if (simpleControl == null)
+ DmsException
+ .throwIt(
+ ErrorType.JMX_ACCESS,
+ this,
+ "Cannot communicate with the DMS daemon",
+
"MBeanServerInvocationHandler.newProxyInstance failed for
SimpleControllerManagerMBean");
+ return simpleControl;
+ } catch (DmsException ex) {
+ throw ex;
+ } catch (Throwable th) {
+ DmsException.throwIt(ErrorType.JMX_ACCESS, this, "Cannot connect
to the daemon", th.getLocalizedMessage());
+ return null;
+ }
}
/**
@@ -114,6 +122,9 @@
+ args.length + " arguments");
break;
}
+ Setup.getConfig()
+ .getLogger("ExternalCommand")
+ .severe("******** Executing command "+args[0]);
SimpleControllerManagerMBean simpleControl = jmxConnect(
args[3], args[4]);
if (args[0].equals("loglevel")) {
@@ -124,10 +135,11 @@
break;
}
String msg = simpleControl.setLogLevel(args[5]);
- if (msg.startsWith("logLevel=")) {
+ if (msg == null) {
+ } else if (msg.startsWith("logLevel=")) {
System.out.println(msg);
msg = null;
- } else if (msg != null) {
+ } else {
ex = new DmsException(ErrorType.BAD_ARG, this, msg,
"This error message was returned from the
daemon");
break;
@@ -154,6 +166,8 @@
}
return;
} while (false);
+ } catch (DmsException dex) {
+ ex = dex;
} catch (Throwable e) {
ex = new DmsException(ErrorType.BAD_ARG, this,
"Cannot execute the comand", e.getLocalizedMessage());
Modified: trunk/java/ch/idok/dmsd/main/Daemon.java
==============================================================================
--- trunk/java/ch/idok/dmsd/main/Daemon.java (original)
+++ trunk/java/ch/idok/dmsd/main/Daemon.java Wed Sep 24 17:00:27 2008
@@ -23,6 +23,7 @@
import java.util.logging.Logger;
import ch.idok.common.errorhandling.DmsException;
+import ch.idok.common.errorhandling.ErrorType;
import ch.idok.dmsd.config.Config;
import ch.idok.dmsd.config.Setup;
import ch.idok.dmsd.management.ExternalDaemonControl;
@@ -80,8 +81,12 @@
logger.severe("Operation " + args[0] + " finished successfully");
System.exit(0);
} catch (DmsException ex) {
- logger.severe(usage(proxy.argDesc()).toString());
- logger.log(Level.SEVERE, ex.getLogMessage(), ex);
+ if (ex.getErrorType() == ErrorType.JMX_ACCESS) {
+ logger.info("Command "+args[0]+": "+ex.getLogMessage());
+ } else {
+ logger.severe(usage(proxy.argDesc()).toString());
+ logger.log(Level.SEVERE, ex.getLogMessage(), ex);
+ }
} catch (Throwable th) {
logger.severe(proxy.argDesc().toString());
logger.log(Level.SEVERE, th.getLocalizedMessage(), th);
Modified: trunk/sites/psi/scripts/admin/dmsd/build.xml
==============================================================================
--- trunk/sites/psi/scripts/admin/dmsd/build.xml (original)
+++ trunk/sites/psi/scripts/admin/dmsd/build.xml Wed Sep 24 17:00:27
2008
@@ -147,7 +147,8 @@
<exec executable="svnversion" failonerror="true"
outputproperty="svnversion">
<arg value="-n"/>
</exec>
- <replace file="${dist}/dmsd" token="DEFINE_DMSD_DIR"
value="DMSD_DIR=${dest}"/>
+ <echo message="svnversion is ${svnversion}"/>
+ <replace file="${dist}/dmsd" token="DEFINE_DMSD_DIR"
value="DMSD_DIR=${dest}" summary="yes"/>
<replace file="${dist}/dmsd" token="DEFINE_DMSD_VERSION"
value="DMSD_VERSION=${svnversion}"/>
<replace file="${dist}/dmsd.config" token="DEFINE_CLASS_PATH"
value="${lib-all}"/>
<replace file="${dist}/dmsd.config" token="${dist}/"
value=""/>
- [idok-commit] idok commit r249 - in trunk: java/ch/idok/dmsd/impl/controller java/ch/idok/dmsd/main sites/psi/scripts/admin/dmsd, AFS account Stadler Hans Christian, 09/24/2008
Archive powered by MHonArc 2.6.19.