|
From: <fko...@us...> - 2010-07-28 18:31:58
|
Revision: 3336
http://bigdata.svn.sourceforge.net/bigdata/?rev=3336&view=rev
Author: fkoliver
Date: 2010-07-28 18:31:51 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
[trunk] Ticket #119: Replaced the signal handlers in the load balancer and
the services manager with remote methods. Extended the BroadcastSighup class
to call the new sighup methods on discovered services. Add broadcast_sighup
command as a wrapper around the class: arguments specify which type of service,
and whether all or only local services are affected. Update other scripts
to replace kill commands with the new script.
Modified Paths:
--------------
trunk/bigdata/src/java/com/bigdata/service/AbstractService.java
trunk/bigdata/src/java/com/bigdata/service/ILoadBalancerService.java
trunk/bigdata/src/java/com/bigdata/service/LoadBalancerService.java
trunk/bigdata-jini/src/java/com/bigdata/jini/start/AbstractServicesManagerService.java
trunk/bigdata-jini/src/java/com/bigdata/jini/start/ServicesManagerServer.java
trunk/bigdata-jini/src/java/com/bigdata/service/jini/AbstractServer.java
trunk/bigdata-jini/src/java/com/bigdata/service/jini/LoadBalancerServer.java
trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/BroadcastSighup.java
trunk/src/resources/scripts/archiveRun.sh
trunk/src/resources/scripts/bigdata
trunk/src/resources/scripts/extractCounters.sh
Added Paths:
-----------
trunk/src/resources/scripts/broadcast_sighup
Modified: trunk/bigdata/src/java/com/bigdata/service/AbstractService.java
===================================================================
--- trunk/bigdata/src/java/com/bigdata/service/AbstractService.java 2010-07-28 16:46:24 UTC (rev 3335)
+++ trunk/bigdata/src/java/com/bigdata/service/AbstractService.java 2010-07-28 18:31:51 UTC (rev 3336)
@@ -46,7 +46,7 @@
*/
abstract public class AbstractService implements IService {
- protected static final Logger log = Logger.getLogger(AbstractService.class);
+ private static final Logger log = Logger.getLogger(AbstractService.class);
private String serviceName;
private UUID serviceUUID;
Modified: trunk/bigdata/src/java/com/bigdata/service/ILoadBalancerService.java
===================================================================
--- trunk/bigdata/src/java/com/bigdata/service/ILoadBalancerService.java 2010-07-28 16:46:24 UTC (rev 3335)
+++ trunk/bigdata/src/java/com/bigdata/service/ILoadBalancerService.java 2010-07-28 18:31:51 UTC (rev 3336)
@@ -173,6 +173,11 @@
*/
public boolean isUnderUtilizedDataService(UUID serviceUUID) throws IOException;
+ /**
+ * Logs counters to a temp file. Replacement for sighup mechanism.
+ */
+ public void sighup() throws IOException;
+
// /**
// * Return the identifier(s) of under-utilized service(s).
// *
Modified: trunk/bigdata/src/java/com/bigdata/service/LoadBalancerService.java
===================================================================
--- trunk/bigdata/src/java/com/bigdata/service/LoadBalancerService.java 2010-07-28 16:46:24 UTC (rev 3335)
+++ trunk/bigdata/src/java/com/bigdata/service/LoadBalancerService.java 2010-07-28 18:31:51 UTC (rev 3336)
@@ -676,6 +676,7 @@
}
+ @Override
synchronized public void shutdown() {
if(!isOpen()) return;
@@ -692,7 +693,7 @@
* Obtain the exclusive write lock for the event BTree before flushing
* writes.
*/
- final Lock lock = eventReceiver.getWriteLock();
+ final Lock tmpLock = eventReceiver.getWriteLock();
try {
// Flush any buffered writes to the event store.
@@ -707,7 +708,7 @@
} finally {
- lock.unlock();
+ tmpLock.unlock();
}
@@ -718,6 +719,7 @@
}
+ @Override
synchronized public void shutdownNow() {
if(!isOpen()) return;
@@ -740,6 +742,7 @@
}
+ @Override
synchronized public void destroy() {
super.destroy();
@@ -2017,8 +2020,38 @@
}
}
-
+
/**
+ * Logs the counters on a file created using
+ * {@link File#createTempFile(String, String, File)} in the log
+ * directory.
+ *
+ * @throws IOException
+ *
+ * @todo this method is not exposed to RMI (it is not on any
+ * {@link Remote} interface) but it could be.
+ */
+ public void logCounters() throws IOException {
+
+ if (isTransient) {
+
+ log.warn("LBS is transient - request ignored.");
+
+ return;
+
+ }
+
+ final File file = File.createTempFile("counters-hup", ".xml", logDir);
+
+ logCounters(file);
+
+ }
+
+ public void sighup() throws IOException {
+ logCounters();
+ }
+
+ /**
* Notify the {@link LoadBalancerService} that a new service is available.
* <p>
* Note: Embedded services must invoke this method <em>directly</em> when
Modified: trunk/bigdata-jini/src/java/com/bigdata/jini/start/AbstractServicesManagerService.java
===================================================================
--- trunk/bigdata-jini/src/java/com/bigdata/jini/start/AbstractServicesManagerService.java 2010-07-28 16:46:24 UTC (rev 3335)
+++ trunk/bigdata-jini/src/java/com/bigdata/jini/start/AbstractServicesManagerService.java 2010-07-28 18:31:51 UTC (rev 3336)
@@ -13,6 +13,7 @@
import com.bigdata.service.IServiceShutdown;
import com.bigdata.service.jini.JiniFederation;
import com.bigdata.service.jini.RemoteDestroyAdmin;
+import org.apache.log4j.Logger;
/**
* Core impl.
@@ -23,6 +24,7 @@
public abstract class AbstractServicesManagerService extends AbstractService
implements IServicesManagerService, IServiceListener, IServiceShutdown {
+ private static final Logger log = Logger.getLogger(AbstractServicesManagerService.class);
private final Properties properties;
/**
Modified: trunk/bigdata-jini/src/java/com/bigdata/jini/start/ServicesManagerServer.java
===================================================================
--- trunk/bigdata-jini/src/java/com/bigdata/jini/start/ServicesManagerServer.java 2010-07-28 16:46:24 UTC (rev 3335)
+++ trunk/bigdata-jini/src/java/com/bigdata/jini/start/ServicesManagerServer.java 2010-07-28 18:31:51 UTC (rev 3336)
@@ -45,9 +45,6 @@
import org.apache.log4j.Logger;
import org.apache.log4j.MDC;
-import sun.misc.Signal;
-import sun.misc.SignalHandler;
-
import com.bigdata.btree.IndexSegment;
import com.bigdata.jini.start.config.IServiceConstraint;
import com.bigdata.jini.start.config.JiniCoreServicesConfiguration;
@@ -357,101 +354,9 @@
super(args, lifeCycle);
this.args = args;
-
- try {
-
- /*
- * Note: This signal is not supported under Windows. You can use the
- * sighup() method to accomplish the same ends via RMI.
- */
- new SigHUPHandler("HUP");
-
- } catch (IllegalArgumentException ex) {
-
- log.warn("Signal handler not installed: " + ex);
-
- }
-
}
/**
- * SIGHUP Handler.
- *
- * @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
- */
- private class SigHUPHandler implements SignalHandler {
-
- private final SignalHandler oldHandler;
-
- /**
- * Install handler.
- *
- * @param signalName
- * The signal name.
- * @param args
- * The command line arguments (these identify the
- * configuration and any overrides).
- *
- * @see http://www-128.ibm.com/developerworks/java/library/i-signalhandling/
- *
- * @see http://forum.java.sun.com/thread.jspa?threadID=514860&messageID=2451429
- * for the use of {@link Runtime#addShutdownHook(Thread)}.
- *
- * @see http://twit88.com/blog/2008/02/06/java-signal-handling/
- */
- @SuppressWarnings("all") // Signal is in the sun namespace
- protected SigHUPHandler(final String signalName) {
-
- final Signal signal = new Signal(signalName);
-
- this.oldHandler = Signal.handle(signal, this);
-
- if (log.isInfoEnabled())
- log.info("Installed handler: " + signal + ", oldHandler="
- + this.oldHandler);
-
- }
-
- @SuppressWarnings("all") // Signal is in the sun namespace
- public void handle(final Signal sig) {
-
- log.warn("Processing signal: " + sig);
-
- try {
-
- final AbstractServicesManagerService service = (AbstractServicesManagerService) impl;
-
- if (service != null) {
-
- service
- .sighup(true/* pushConfig */, true/*restartServices*/);
-
- }
-
- /*
- * This appears willing to halt the server so I am not chaining
- * back to the previous handler!
- */
-
-// // Chain back to previous handler, if one exists
-// if (oldHandler != SIG_DFL && oldHandler != SIG_IGN) {
-//
-// oldHandler.handle(sig);
-//
-// }
-
- } catch (Throwable t) {
-
- log.error("Signal handler failed : " + t, t);
-
- }
-
- }
-
- }
-
- /**
* Starts and maintains services based on the specified configuration file
* and/or an existing zookeeper ensemble.
*
Modified: trunk/bigdata-jini/src/java/com/bigdata/service/jini/AbstractServer.java
===================================================================
--- trunk/bigdata-jini/src/java/com/bigdata/service/jini/AbstractServer.java 2010-07-28 16:46:24 UTC (rev 3335)
+++ trunk/bigdata-jini/src/java/com/bigdata/service/jini/AbstractServer.java 2010-07-28 18:31:51 UTC (rev 3336)
@@ -158,7 +158,7 @@
abstract public class AbstractServer implements Runnable, LeaseListener,
ServiceIDListener {
- final static protected Logger log = Logger.getLogger(AbstractServer.class);
+ final static private Logger log = Logger.getLogger(AbstractServer.class);
// /**
// * True iff the {@link #log} level is log.isInfoEnabled() or less.
@@ -475,6 +475,13 @@
setSecurityManager();
+ Thread.setDefaultUncaughtExceptionHandler(
+ new Thread.UncaughtExceptionHandler() {
+ public void uncaughtException(Thread t, Throwable e) {
+ log.warn("Uncaught exception in thread", e);
+ }
+ });
+
/*
* Read jini configuration & service properties
*/
@@ -1757,7 +1764,7 @@
try {
- ((IService) tmp).destroy();
+ tmp.destroy();
} catch (Throwable ex) {
Modified: trunk/bigdata-jini/src/java/com/bigdata/service/jini/LoadBalancerServer.java
===================================================================
--- trunk/bigdata-jini/src/java/com/bigdata/service/jini/LoadBalancerServer.java 2010-07-28 16:46:24 UTC (rev 3335)
+++ trunk/bigdata-jini/src/java/com/bigdata/service/jini/LoadBalancerServer.java 2010-07-28 18:31:51 UTC (rev 3336)
@@ -1,12 +1,10 @@
package com.bigdata.service.jini;
-import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.ServerNotActiveException;
import java.util.Collection;
@@ -23,9 +21,6 @@
import org.apache.log4j.MDC;
-import sun.misc.Signal;
-import sun.misc.SignalHandler;
-
import com.bigdata.counters.CounterSet;
import com.bigdata.counters.httpd.CounterSetHTTPD;
import com.bigdata.journal.ITx;
@@ -84,19 +79,6 @@
public LoadBalancerServer(final String[] args, final LifeCycle lifeCycle) {
super(args, lifeCycle);
-
- try {
-
- /*
- * Note: This signal is not supported under Windows.
- */
- new SigHUPHandler("HUP");
-
- } catch (IllegalArgumentException ex) {
-
- log.warn("Signal handler not installed: " + ex);
-
- }
}
/**
@@ -153,80 +135,7 @@
return service;
}
-
- /**
- * SIGHUP Handler.
- *
- * @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
- */
- private class SigHUPHandler implements SignalHandler {
- private final SignalHandler oldHandler;
-
- /**
- * Install handler.
- *
- * @param signalName
- * The signal name.
- *
- * @see http://www-128.ibm.com/developerworks/java/library/i-signalhandling/
- *
- * @see http://forum.java.sun.com/thread.jspa?threadID=514860&messageID=2451429
- * for the use of {@link Runtime#addShutdownHook(Thread)}.
- *
- * @see http://twit88.com/blog/2008/02/06/java-signal-handling/
- */
- @SuppressWarnings("all") // Signal is in the sun namespace
- protected SigHUPHandler(final String signalName) {
-
- final Signal signal = new Signal(signalName);
-
- this.oldHandler = Signal.handle(signal, this);
-
- if (log.isInfoEnabled())
- log.info("Installed handler: " + signal + ", oldHandler="
- + this.oldHandler);
-
- }
-
- @SuppressWarnings("all") // Signal is in the sun namespace
- public void handle(final Signal sig) {
-
- log.warn("Processing signal: " + sig);
-
- try {
-
- final AdministrableLoadBalancer service = (AdministrableLoadBalancer) impl;
-
- if (service != null) {
-
- service.logCounters();
-
- }
-
- /*
- * This appears willing to halt the server so I am not chaining
- * back to the previous handler!
- */
-
-// // Chain back to previous handler, if one exists
-// if (oldHandler != SIG_DFL && oldHandler != SIG_IGN) {
-//
-// oldHandler.handle(sig);
-//
-// }
-
- } catch (Throwable t) {
-
- log.error("Signal handler failed : " + t, t);
-
- }
-
- }
-
- }
-
/**
* Overrides the {@link IFederationDelegate} leave/join behavior to notify
* the {@link LoadBalancerService}.
@@ -250,6 +159,7 @@
/**
* Notifies the {@link LoadBalancerService}.
*/
+ @Override
public void serviceJoin(IService service, UUID serviceUUID) {
try {
@@ -279,6 +189,7 @@
/**
* Notifies the {@link LoadBalancerService}.
*/
+ @Override
public void serviceLeave(UUID serviceUUID) {
if (log.isInfoEnabled())
@@ -334,6 +245,7 @@
* root path), dump of the indices in the federation (/indices), and
* events (/events).
*/
+ @Override
public AbstractHTTPD newHttpd(final int httpdPort,
final CounterSet counterSet) throws IOException {
@@ -451,6 +363,7 @@
final IndicesHandler indicesHandler = new IndicesHandler();
+ @Override
public Response doGet(String uri, String method, Properties header,
LinkedHashMap<String, Vector<String>> parms)
throws Exception {
@@ -668,33 +581,5 @@
return s;
}
-
- /**
- * Logs the counters on a file created using
- * {@link File#createTempFile(String, String, File)} in the log
- * directory.
- *
- * @throws IOException
- *
- * @todo this method is not exposed to RMI (it is not on any
- * {@link Remote} interface) but it could be.
- */
- public void logCounters() throws IOException {
-
- if (isTransient) {
-
- log.warn("LBS is transient - request ignored.");
-
- return;
-
- }
-
- final File file = File.createTempFile("counters-hup", ".xml", logDir);
-
- super.logCounters(file);
-
- }
-
}
-
}
Modified: trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/BroadcastSighup.java
===================================================================
--- trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/BroadcastSighup.java 2010-07-28 16:46:24 UTC (rev 3335)
+++ trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/BroadcastSighup.java 2010-07-28 18:31:51 UTC (rev 3336)
@@ -27,21 +27,35 @@
package com.bigdata.service.jini.util;
+import com.bigdata.jini.lookup.entry.Hostname;
+import java.io.IOException;
+import java.net.UnknownHostException;
import org.apache.log4j.Logger;
import net.jini.config.ConfigurationException;
import net.jini.core.lookup.ServiceItem;
import com.bigdata.jini.start.IServicesManagerService;
+import com.bigdata.service.ILoadBalancerService;
import com.bigdata.service.jini.JiniClient;
import com.bigdata.service.jini.JiniFederation;
+import java.net.InetAddress;
+import net.jini.config.Configuration;
+import net.jini.core.entry.Entry;
+import net.jini.core.lookup.ServiceTemplate;
+import net.jini.lookup.ServiceItemFilter;
/**
- * Utility will broadcast the {@link IServicesManagerService#sighup()} method to
- * all discovered {@link IServicesManagerService}s in federation to which it
+ * Utility will broadcast the
+ * {@link IServicesManagerService#sighup(boolean,boolean)} method or
+ * {@link ILoadBalancerService#sighup()} method to either local or
+ * all discovered {@link IServicesManagerService}s
+ * or {@link ILoadBalancerService}s in federation to which it
* connects. Each discovered {@link IServicesManagerService} will push the
* service configuration to zookeeper and then restart any processes for which
* it has responsibility which are not currently running.
+ * Each discovered {@link ILoadBalancerService} will log current counters to
+ * files.
* <p>
* Note: If you are running a federation on a cluster, you can achieve the same
* effect by changing the federation run state to <code>hup</code> and then
@@ -64,6 +78,16 @@
* following options are defined:
* <dl>
*
+ * <dt>localOrRemote</dt>
+ * <dd>If "local", then consider only services running on the local host
+ * (similar to what linux "kill -hup" signal used to do). If
+ * "all" then call sighup() on all services found. </dd>
+ *
+ * <dt>signalTarget</dt>
+ * <dd>If "servicesManager", then send signals only to instances of
+ * IServicesManagerService. If "loadBalancer", then send signals only to
+ * instances of ILoadBalancerService. </dd>
+ *
* <dt>discoveryDelay</dt>
* <dd>The time in milliseconds to wait for service discovery before
* proceeding.</dd>
@@ -84,57 +108,111 @@
* @throws InterruptedException
* @throws ConfigurationException
*/
- public static void main(final String[] args) throws InterruptedException,
- ConfigurationException {
+ public static void main(final String[] args) {
+ try {
+ main2(args);
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.warn("Unexpected exception", e);
+ }
+ }
- final JiniFederation fed = JiniClient.newInstance(args).connect();
+ private static void main2(final String[] args) throws InterruptedException,
+ ConfigurationException, UnknownHostException, IOException {
- final long discoveryDelay = (Long) fed
- .getClient()
- .getConfiguration()
+ // Get the configuration and set up the federation.
+
+ final JiniClient client = JiniClient.newInstance(args);
+ final JiniFederation fed = client.connect();
+ final Configuration config = client.getConfiguration();
+
+ final long discoveryDelay = (Long) config
.getEntry(COMPONENT, "discoveryDelay", Long.TYPE, 5000L/* default */);
- final boolean pushConfig = (Boolean) fed
- .getClient()
- .getConfiguration()
+ final boolean pushConfig = (Boolean) config
.getEntry(COMPONENT, "pushConfig", Boolean.TYPE, true/* default */);
- final boolean restartServices = (Boolean) fed.getClient()
- .getConfiguration().getEntry(COMPONENT, "restartServices",
+ final String localOrAll = (String) config
+ .getEntry(COMPONENT, "localOrAll", String.class, "all");
+
+ final String signalTarget = (String) config
+ .getEntry(COMPONENT, "signalTarget", String.class,
+ "servicesManager");
+
+ final boolean restartServices = (Boolean) config
+ .getEntry(COMPONENT, "restartServices",
Boolean.TYPE, true/* default */);
+ // Identify the bigdata interface associated with the service
+ // to which the signal will be delivered.
+
+ Class iface = null;
+ if (signalTarget.equals("servicesManager")) {
+ iface = IServicesManagerService.class;
+ } else if (signalTarget.equals("loadBalancer")) {
+ iface = ILoadBalancerService.class;
+ } else {
+ log.warn("Unexpected target for signal: " + signalTarget);
+ System.exit(1);
+ }
+
+ // Set up the service template and filter used to identify the service.
+
+ final String hostname = InetAddress.getLocalHost()
+ .getCanonicalHostName().toString();
+ ServiceTemplate template = new ServiceTemplate(null,
+ new Class[] { iface }, null);
+ ServiceItemFilter thisHostFilter = null;
+ if (localOrAll.equals("local")) {
+ thisHostFilter = new ServiceItemFilter() {
+ public boolean check(ServiceItem item) {
+ for (Entry entry : item.attributeSets) {
+ if (entry instanceof Hostname &&
+ ((Hostname)entry).hostname.equals(hostname)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ };
+ } else if (!localOrAll.equals("all")) {
+ log.warn("Unexpected option for signal: " + localOrAll);
+ System.exit(1);
+ }
+
+ // Use the federation's discovery manager to lookup bigdata
+ // services of interest.
+
System.out.println("Waiting " + discoveryDelay
+ "ms for service discovery.");
+ ServiceItem[] items =
+ fed.getServiceDiscoveryManager()
+ .lookup(template, Integer.MAX_VALUE, Integer.MAX_VALUE,
+ thisHostFilter, discoveryDelay);
- Thread.sleep(discoveryDelay/* ms */);
+ // Call the service's appropriate interface method.
- final ServiceItem[] a = fed.getServicesManagerClient()
- .getServiceCache()
- .getServiceItems(0/* maxCount */, null/* filter */);
-
int n = 0;
- for (ServiceItem item : a) {
-
+ for (ServiceItem item : items) {
try {
-
- ((IServicesManagerService) item.service).sighup(pushConfig,
- restartServices);
-
- n++;
-
- } catch(Throwable t) {
-
- log.warn(item, t);
+ if (signalTarget.equals("servicesManager")) {
+ ((IServicesManagerService) item.service)
+ .sighup(pushConfig, restartServices);
+ ++n;
+ } else if (signalTarget.equals("loadBalancer")) {
+ ((ILoadBalancerService) item.service).sighup();
+ ++n;
+
+ } else {
+ log.warn("Unexpected target for signal: " + signalTarget);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.warn("Unexpected target for signal: " + signalTarget);
}
-
}
-
- System.out.println("Signal sent to " + n + " of " + a.length
- + " services managers.");
-
- System.exit(0);
-
+ System.out.println("Signal sent to " + n + " of " + items.length
+ + " instances of " + signalTarget + ".");
}
-
}
Modified: trunk/src/resources/scripts/archiveRun.sh
===================================================================
--- trunk/src/resources/scripts/archiveRun.sh 2010-07-28 16:46:24 UTC (rev 3335)
+++ trunk/src/resources/scripts/archiveRun.sh 2010-07-28 18:31:51 UTC (rev 3336)
@@ -19,7 +19,8 @@
exit 1
fi
-source `dirname $0`/bigdataenv
+BINDIR=`dirname $0`
+source $BINDIR/bigdataenv
targetDir=$1
@@ -29,21 +30,13 @@
mkdir -p $targetDir/counters
mkdir -p $targetDir/indexDumps
-# Look for the load balancer service directory on the local host. If
-# we find it, then we read the pid for the LBS and send it a HUP signal
-# so it will write a snapshot of its performance counters.
+# Broadcast a HUP request to the load balancer in the federation so
+# that it will write a snapshot of its performance counters.
waitDur=60
-if [ -f "$lockFile" ]; then
- read pid < `find $LAS -name pid | grep LoadBalancerServer`
- if [ -z "$pid" ]; then
- echo "Could not find LoadBalancer process: `hostname` LAS=$LAS."
- else
- echo "Sending HUP to the LoadBalancer: $pid"
- kill -hup $pid
- echo "Waiting $waitDur seconds for the performance counter dump."
- sleep $waitDur
- fi
-fi
+echo "Sending HUP to the LoadBalancer: $pid"
+$BINDIR/broadcast_sighup local loadBalancer
+echo "Waiting $waitDur seconds for the performance counter dump."
+sleep $waitDur
# Copy the configuration file and the various log files.
cp -v $BIGDATA_CONFIG \
Modified: trunk/src/resources/scripts/bigdata
===================================================================
--- trunk/src/resources/scripts/bigdata 2010-07-28 16:46:24 UTC (rev 3335)
+++ trunk/src/resources/scripts/bigdata 2010-07-28 18:31:51 UTC (rev 3336)
@@ -266,7 +266,7 @@
if [ -z "$pidno" ]; then
echo $"`date` : `hostname` : process died? pid=$pid."
else
- kill -s hup $pid
+ ./broadcast_sighup local servicesManager
echo $"`date` : `hostname` : sent SIGHUP pid=$pid."
fi
else
Added: trunk/src/resources/scripts/broadcast_sighup
===================================================================
--- trunk/src/resources/scripts/broadcast_sighup (rev 0)
+++ trunk/src/resources/scripts/broadcast_sighup 2010-07-28 18:31:51 UTC (rev 3336)
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+##
+# Script sends equivalent of sighup to a services manager or load balancer.
+#
+
+usage() {
+ echo "Usage: $0 ( local | all ) ( servicesManager | loadBalancer )" 1>&2
+ exit 1
+}
+
+if [ $# -ne 2 ] ; then
+ usage
+fi
+if [ X"$1" != "Xlocal" -a X"$1" != "Xall" ] ; then
+ usage
+fi
+local_or_all=$1
+if [ X"$2" != "XservicesManager" -a X"$2" != "XloadBalancer" ] ; then
+ usage
+fi
+target=$2
+
+# Setup the environment.
+cd `dirname $0`
+source ./bigdataenv
+
+# Verify critical environment variables.
+if [ -z "$JAVA_OPTS" ]; then
+ echo $"`date` : hostname : environment not setup."
+ exit 1;
+fi
+if [ -z "$CLASSPATH" ]; then
+ echo $"`date` : hostname : environment not setup."
+ exit 1;
+fi
+if [ -z "$BIGDATA_CONFIG" ]; then
+ echo $"`date` : hostname : environment not setup."
+ exit 1;
+fi
+
+# Start the services manager on this host.
+#
+# Note: This explicitly specifies a small heap for the services manager since
+# it uses very little heap space and we can avoid problems with contention for
+# virtual memory by not permitting JVM defaults to grant this a large maximum
+# heap on machines with lots of RAM.
+#
+# Allow JVM to be available for debugger to attach.
+#NIC="lo"
+#IP_ADDR=`ifconfig ${NIC} | sed -n -e s'/.*inet addr:\([0-9.]*\).*/\1/p'`
+#JDWP_OPTS="transport=dt_socket,server=y,address=${IP_ADDR}:33340,suspend=y"
+#JAVA_OPTS="-ea -Xdebug -Xrunjdwp:${JDWP_OPTS} ${JAVA_OPTS}"
+java ${JAVA_OPTS} \
+ -cp ${CLASSPATH} \
+ com.bigdata.service.jini.util.BroadcastSighup \
+ ${BIGDATA_CONFIG} \
+ "com.bigdata.service.jini.util.BroadcastSighup.signalTarget=\"$target\"" \
+ "com.bigdata.service.jini.util.BroadcastSighup.localOrAll=\"$local_or_all\"" \
+ "com.bigdata.service.jini.util.BroadcastSighup.pushConfig=true" \
+ "com.bigdata.service.jini.util.BroadcastSighup.restartServices=true" \
+ ${BIGDATA_CONFIG_OVERRIDES}
+exit 0
Modified: trunk/src/resources/scripts/extractCounters.sh
===================================================================
--- trunk/src/resources/scripts/extractCounters.sh 2010-07-28 16:46:24 UTC (rev 3335)
+++ trunk/src/resources/scripts/extractCounters.sh 2010-07-28 18:31:51 UTC (rev 3336)
@@ -18,7 +18,8 @@
exit 1
fi
-source `dirname $0`/bigdataenv
+BINDIR=`dirname $0`
+source $BINDIR/bigdataenv
targetDir=$1
@@ -41,11 +42,8 @@
exit 1
fi
-#
-# Look for the load balancer service directory on the local host. If
-# we find it, then we read the pid for the LBS and send it a HUP signal
-# so it will write a snapshot of its performance counters.
-#
+# Broadcast a HUP request to the load balancer in the federation so
+# that it will write a snapshot of its performance counters.
# How long to wait for the LBS to dump a current snapshot.
waitDur=60
@@ -54,13 +52,8 @@
tarball=$targetDir-output.tgz
if [ -f "$lockFile" ]; then
- read pid < "$lbsDir/pid"
- if [ -z "$pid" ]; then
- echo "Could not find LoadBalancer process: `hostname` lbsDir=$lbsDir"
- exit 1
- fi
echo "Sending HUP to the LoadBalancer: $pid"
- kill -hup $pid
+ $BINDIR/broadcast_sighup local loadBalancer
echo "Waiting $waitDur seconds for the performance counter dump."
sleep $waitDur
ant "-Danalysis.counters.dir=$lbsDir"\
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|