From: <ble...@us...> - 2010-09-27 13:34:25
|
Revision: 3632 http://bigdata.svn.sourceforge.net/bigdata/?rev=3632&view=rev Author: blevine218 Date: 2010-09-27 13:34:16 +0000 (Mon, 27 Sep 2010) Log Message: ----------- Delete unit tests that have been moved to bigdata-integ Modified Paths: -------------- branches/maven_scaleout/bigdata-core/src/test/deploy/testing/test.xml branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/TestAll.java Removed Paths: ------------- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/TestAll.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/AbstractFedZooTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/DestroyTransactionService.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/MockListener.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestAll.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestJiniCoreServicesProcessHelper.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceConfigurationMonitoring.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceConfigurationMonitoringRemote.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceConfigurationZNodeEnum.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceStarter.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceStarterRemote.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/config/TestAll.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/config/TestServiceConfiguration.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/config/TestServiceConfigurationRemote.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/config/TestZookeeperServerEntry.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/jini/AbstractServerTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/jini/PerformanceTest.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/jini/TestAll.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/jini/TestBigdataClient.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/jini/TestBigdataClientRemote.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/zookeeper/AbstractZooTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/zookeeper/TestAll.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/zookeeper/TestHierarchicalZNodeWatcher.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/zookeeper/TestUnknownChildrenWatcher.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/zookeeper/TestZLockImpl.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/zookeeper/TestZNodeCreatedWatcher.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/zookeeper/TestZNodeDeletedWatcher.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/zookeeper/TestZooBarrier.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/zookeeper/TestZooElection.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/zookeeper/TestZooQueue.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/zookeeper/TestZookeeperAccessor.java Modified: branches/maven_scaleout/bigdata-core/src/test/deploy/testing/test.xml =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/deploy/testing/test.xml 2010-09-25 17:41:54 UTC (rev 3631) +++ branches/maven_scaleout/bigdata-core/src/test/deploy/testing/test.xml 2010-09-27 13:34:16 UTC (rev 3632) @@ -277,9 +277,6 @@ <test name="com.bigdata.search.TestAll" todir="${test.results.dir}" unless="testName" /> <test name="com.bigdata.relation.TestAll" todir="${test.results.dir}" unless="testName" /> - <!-- See https://sourceforge.net/apps/trac/bigdata/ticket/53 --> - <test name="com.bigdata.jini.TestAll" todir="${test.results.dir}" unless="testName" /> - <test name="com.bigdata.rdf.TestAll" todir="${test.results.dir}" unless="testName" /> <test name="com.bigdata.rdf.sail.TestAll" todir="${test.results.dir}" unless="testName" /> Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/TestAll.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/TestAll.java 2010-09-25 17:41:54 UTC (rev 3631) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/TestAll.java 2010-09-27 13:34:16 UTC (rev 3632) @@ -113,8 +113,6 @@ suite.addTest( com.bigdata.relation.TestAll.suite() ); // suite.addTest( com.bigdata.service.mapReduce.TestAll.suite() ); - // Jini integration - suite.addTest(com.bigdata.jini.TestAll.suite()); // RDF suite.addTest(com.bigdata.rdf.TestAll.suite()); Deleted: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/TestAll.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/TestAll.java 2010-09-25 17:41:54 UTC (rev 3631) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/TestAll.java 2010-09-27 13:34:16 UTC (rev 3632) @@ -1,95 +0,0 @@ -/** - -Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* - * Created on Jun 26, 2006 - */ -package com.bigdata.jini; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import com.bigdata.service.jini.AbstractServerTestCase; - -/** - * Aggregates tests in dependency order. The service tests require that Jini is - * running, that you have specified a suitable security policy, etc. See - * {@link AbstractServerTestCase} for <strong>required</strong> system - * properties in order to run this test suite - * - * @version $Id$ - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - */ -public class TestAll extends TestCase { - - public TestAll() { - } - - public TestAll(String name) { - super(name); - } - - public static Test suite() { - - /* - * log4j defaults to DEBUG which will produce simply huge amounts of - * logging information when running the unit tests. Therefore we - * explicitly set the default logging level to WARN. If you are using a - * log4j configuration file then this is unlikely to interact with your - * configuration, and in any case you can override specific loggers. - */ - { - - final Logger log = Logger.getRootLogger(); - - if (log.getLevel().equals(Level.DEBUG)) { - - log.setLevel(Level.WARN); - - log - .warn("Defaulting debugging level to WARN for the unit tests"); - - } - - } - - final TestSuite suite = new TestSuite("jini"); - - // zookeeper client library (queues, locks, etc). - suite.addTest(com.bigdata.zookeeper.TestAll.suite()); - - // concrete impls of bigdata services using jini. - suite.addTest(com.bigdata.service.jini.TestAll.suite()); - - // bigdata services manager test suite. - suite.addTest(com.bigdata.jini.start.TestAll.suite()); - - return suite; - - } - -} Deleted: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/AbstractFedZooTestCase.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/AbstractFedZooTestCase.java 2010-09-25 17:41:54 UTC (rev 3631) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/AbstractFedZooTestCase.java 2010-09-27 13:34:16 UTC (rev 3632) @@ -1,234 +0,0 @@ -/* - -Copyright (C) SYSTAP, LLC 2006-2008. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* - * Created on Jan 7, 2009 - */ - -package com.bigdata.jini.start; - -import java.io.File; -import java.util.List; -import java.util.UUID; - -import com.bigdata.DataFinder; -import junit.framework.TestCase2; -import net.jini.config.Configuration; -import net.jini.config.ConfigurationProvider; - -import org.apache.zookeeper.CreateMode; -import org.apache.zookeeper.ZooKeeper; -import org.apache.zookeeper.KeeperException.NodeExistsException; -import org.apache.zookeeper.ZooDefs.Ids; -import org.apache.zookeeper.data.ACL; - -import com.bigdata.jini.start.config.ZookeeperClientConfig; -import com.bigdata.jini.start.process.ProcessHelper; -import com.bigdata.jini.start.process.ZookeeperProcessHelper; -import com.bigdata.resources.ResourceFileFilter; -import com.bigdata.service.jini.JiniClient; -import com.bigdata.service.jini.JiniFederation; - -/** - * Abstract base class for unit tests requiring a running zookeeper and a - * running federation as configured from a test resource. - * <p> - * You MUST specify a security policy, e.g.: - * - * <pre> - * -Djava.security.policy=policy.all - * </pre> - * - * for these tests to run. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ -public class AbstractFedZooTestCase extends TestCase2 { - - /** - * - */ - public AbstractFedZooTestCase() { - } - - /** - * @param arg0 - */ - public AbstractFedZooTestCase(String arg0) { - super(arg0); - } - - /** - * A configuration file used by some of the unit tests in this package. - */ - protected final String configFile = DataFinder.bestURI("testing/data/com/bigdata/jini/start/testfed.config").toASCIIString(); - - // ACL used for the unit tests. - protected final List<ACL> acl = Ids.OPEN_ACL_UNSAFE; - - Configuration config; - - final protected MockListener listener = new MockListener(); - - JiniFederation fed; - - String zrootname = null; - - public void setUp() throws Exception { - - zrootname = getName() + "_" + UUID.randomUUID(); - - if (new File(zrootname).exists()) { - // clean out old files. - recursiveDelete(new File(zrootname)); - } - - // a unique zroot in the /test namespace. - final String zroot = "/"+zrootname;//"/test/" + zrootname; - - System.err.println(getName() + ": setting up zrootname=" + zrootname); - - final String[] args = new String[] { configFile, - // Note: overrides the zroot to be unique. - ZookeeperClientConfig.Options.NAMESPACE + "." - + ZookeeperClientConfig.Options.ZROOT + "=" + "\"" - + zroot + "\"" , -// // Override the federation name. -// "bigdata.fedname=\""+fedname+"\"" - }; - - // apply the federation name to the configuration file. - System.setProperty("bigdata.zrootname", zrootname); - - config = ConfigurationProvider.getInstance(args); - - // if necessary, start zookeeper (a server instance). - ZookeeperProcessHelper.startZookeeper(config, listener); - - /* - * FIXME We need to start a jini lookup service for groups = {fedname} - * for this test to succeed. - */ - - fed = JiniClient.newInstance(args).connect(); - - /* - * Create the federation zroot and config znodes. - */ - final ZooKeeper zookeeper = fed.getZookeeper(); - - // make sure that we have the zroot that we overrode above. - assertEquals(zroot, fed.getZooConfig().zroot); - - fed.createKeyZNodes(zookeeper); - - } - - public void tearDown() throws Exception { - - System.err.println(getName() + ": tearing down zrootname=" + zrootname); - - // destroy any processes started by this test suite. - for (ProcessHelper t : listener.running) { - - t.kill(true/*immediateShutdown*/); - - } - - if (fed != null) { - - /* - * @todo if we do this to kill zk then we must ensure that a private - * instance was started on the desired port. That means an override - * for the configuration file and an unused port assigned for the - * client and peers on the zk instance started for this unit test. - */ -// ZooHelper.kill(clientPort); - - fed.shutdownNow(); - - } - - if (zrootname != null && new File(zrootname).exists()) { - - /* - * Wait a bit and then try and delete the federation directory - * structure. - */ - - try { - Thread.sleep(250); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - - recursiveDelete(new File(zrootname)); - - } - - } - - /** - * Recursively removes any files and subdirectories and then removes the - * file (or directory) itself. - * <p> - * Note: Files that are not recognized will be logged by the - * {@link ResourceFileFilter}. - * - * @param f - * A file or directory. - */ - private void recursiveDelete(final File f) { - - if (f.isDirectory()) { - - final File[] children = f.listFiles(); - - if (children == null) { - - // The directory does not exist. - return; - - } - - for (int i = 0; i < children.length; i++) { - - recursiveDelete(children[i]); - - } - - } - - if(log.isInfoEnabled()) - log.info("Removing: " + f); - - if (f.exists() && !f.delete()) { - - log.warn("Could not remove: " + f); - - } - - } - -} Deleted: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/DestroyTransactionService.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/DestroyTransactionService.java 2010-09-25 17:41:54 UTC (rev 3631) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/DestroyTransactionService.java 2010-09-27 13:34:16 UTC (rev 3632) @@ -1,111 +0,0 @@ -/* - -Copyright (C) SYSTAP, LLC 2006-2008. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* - * Created on Jan 10, 2009 - */ - -package com.bigdata.jini.start; - -import java.rmi.RemoteException; - -//BTM import com.bigdata.service.IService; -import com.bigdata.service.jini.JiniClient; -import com.bigdata.service.jini.JiniFederation; -import com.bigdata.service.jini.RemoteDestroyAdmin; -import com.bigdata.service.jini.TransactionServer; - -//BTM -import com.bigdata.journal.TransactionService; -import com.sun.jini.admin.DestroyAdmin; -import net.jini.admin.Administrable; - -/** - * Destroys a specific service - the {@link TransactionServer}. This is for use - * in testing the behavior of the {@link ServicesManagerServer} and the behavior - * of the other services in the federation when the {@link TransactionServer} is - * lost. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ -public class DestroyTransactionService { - - /** - * @param args - * Configuration file and optional overrides. - * - * @throws InterruptedException - * @throws RemoteException - */ - public static void main(String[] args) throws InterruptedException, - RemoteException { - - JiniFederation fed = JiniClient.newInstance(args).connect(); - - try { - -//BTM IService service = fed.getTransactionService(); -TransactionService service = fed.getTransactionService(); - - if (service == null) { - - System.err.println("Service not found."); - - } else { -if(service instanceof RemoteDestroyAdmin) { - ((RemoteDestroyAdmin) service).destroy(); - System.err.println("destroyed transaction service [remote implementation]"); -} else if(service instanceof Administrable) { - try { - Object serviceAdmin = ((Administrable)service).getAdmin(); - if(serviceAdmin instanceof DestroyAdmin) { - try { - ((DestroyAdmin)serviceAdmin).destroy(); - System.err.println("destroyed transaction service [smart proxy implementation]"); - } catch(Throwable t) { - System.err.println("ERROR: exception while destroying transaction service ["+t+"]"); - } - } else { - System.err.println("FAILURE: transaction service admin not instance of DestroyAdmin"); - } - } catch(Throwable t) { - System.err.println("ERROR: exception from call to getAdmin while destroying transaction service ["+t+"]"); - } -} else { - System.err.println("FAILURE: transaction service not instance of Administrable"); -} - -//BTM System.err.println("Service destroyed."); - - } - - } finally { - - fed.shutdown(); - - } - - } - -} Deleted: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/MockListener.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/MockListener.java 2010-09-25 17:41:54 UTC (rev 3631) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/MockListener.java 2010-09-27 13:34:16 UTC (rev 3632) @@ -1,44 +0,0 @@ -package com.bigdata.jini.start; - -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; - -import org.apache.log4j.Logger; - -import com.bigdata.jini.start.process.ProcessHelper; - -/** - * Mock implementation used by some unit tests. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ -public class MockListener implements IServiceListener { - - protected static final Logger log = Logger.getLogger(MockListener.class); - - protected static final boolean INFO = log.isInfoEnabled(); - - protected static final boolean DEBUG = log.isDebugEnabled(); - - public Queue<ProcessHelper> running = new ConcurrentLinkedQueue<ProcessHelper>(); - - public void add(ProcessHelper service) { - - if (INFO) - log.info("adding: " + service); - - running.add(service); - - } - - public void remove(ProcessHelper service) { - - if (INFO) - log.info("removing: " + service); - - running.remove(service); - - } - -} Deleted: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestAll.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestAll.java 2010-09-25 17:41:54 UTC (rev 3631) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestAll.java 2010-09-27 13:34:16 UTC (rev 3632) @@ -1,72 +0,0 @@ -/** - -Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* - * Created on Jun 26, 2006 - */ -package com.bigdata.jini.start; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import com.bigdata.jini.start.config.TestZookeeperServerEntry; -import com.bigdata.service.jini.AbstractServerTestCase; - -/** - * Aggregates tests in dependency order - see {@link AbstractServerTestCase} for - * <strong>required</strong> system properties in order to run this test suite. - * - * @version $Id$ - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - */ -public class TestAll extends TestCase { - - public TestAll() { - } - - public TestAll(String name) { - super(name); - } - - public static Test suite() { - - final TestSuite suite = new TestSuite("start"); - - // - suite.addTestSuite(TestServiceConfigurationZNodeEnum.class); - - // test suite for parsing zookeeper server entries. - suite.addTestSuite(TestZookeeperServerEntry.class); - - // test suite for starting a bigdata service from a service config. - suite.addTestSuite(TestServiceStarter.class); - - // test suite for managing a logical service using a watcher. - suite.addTestSuite(TestServiceConfigurationMonitoring.class); - - return suite; - - } - -} Deleted: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestJiniCoreServicesProcessHelper.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestJiniCoreServicesProcessHelper.java 2010-09-25 17:41:54 UTC (rev 3631) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestJiniCoreServicesProcessHelper.java 2010-09-27 13:34:16 UTC (rev 3632) @@ -1,247 +0,0 @@ -/* - -Copyright (C) SYSTAP, LLC 2006-2008. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* - * Created on Jan 11, 2009 - */ - -package com.bigdata.jini.start; - -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import com.bigdata.DataFinder; -import junit.framework.TestCase2; -import net.jini.admin.Administrable; -import net.jini.config.Configuration; -import net.jini.config.ConfigurationProvider; -import net.jini.core.lookup.ServiceItem; -import net.jini.core.lookup.ServiceRegistrar; -import net.jini.core.lookup.ServiceTemplate; -import net.jini.discovery.LookupDiscoveryManager; -import net.jini.lookup.ServiceDiscoveryManager; - -import com.bigdata.jini.start.config.JiniCoreServicesConfiguration; -import com.bigdata.jini.start.config.JiniCoreServicesConfiguration.Options; -import com.bigdata.jini.start.process.JiniCoreServicesProcessHelper; -import com.bigdata.jini.util.ConfigMath; -import com.bigdata.service.jini.JiniClientConfig; -import com.bigdata.service.jini.util.JiniServicesHelper; - -/** - * Test suite for the {@link JiniCoreServicesProcessHelper} - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ -public class TestJiniCoreServicesProcessHelper extends TestCase2 { - - /** - * - */ - public TestJiniCoreServicesProcessHelper() { - - } - - /** - * @param arg0 - */ - public TestJiniCoreServicesProcessHelper(String arg0) { - super(arg0); - - } - - /** - * The configuration file used the unit tests. - */ - protected final String configFile = DataFinder.bestURI("testing/data/com/bigdata/jini/start/testjini.config").toASCIIString(); - - /** - * The configuration read from that file with any overrides applied. - */ - protected Configuration config; - - protected final MockListener listener = new MockListener(); - - /** - * Reads the {@link #config} from the {@link #configFile}. - * <p> - * Note: You can specify JINI_HOME in your environment in order to override - * the location where jini is installed on your machine. - */ - protected void setUp() throws Exception { - - final String[] args; - { - - final String home = System.getenv("JINI_HOME"); - - if (home == null) { - - args = new String[] { configFile }; - - } else { - - /* - * Overrides the serviceDir to your jini install location. - */ - - args = new String[] { - configFile, - JiniCoreServicesConfiguration.Options.NAMESPACE + "." - + Options.SERVICE_DIR + "=" - + ConfigMath.q(home) }; - - } - - } - - // read the configuration, applying the override if set above. - config = ConfigurationProvider.getInstance(args); - -// logLevel = jiniLog.getLevel(); -// -// jiniLog.addHandler(new Handler(){ -// -// @Override -// public void close() throws SecurityException { -// // TODO Auto-generated method stub -// -// } -// -// @Override -// public void flush() { -// // TODO Auto-generated method stub -// -// } -// -// @Override -// public void publish(LogRecord record) { -// System.err.println("jini: "+record); -// }}); -// -// System.err.println("logLevel="+logLevel); -// -// // turn on lots of logging. -// jiniLog.setLevel( -// java.util.logging.Level.ALL); - - } - -// final static Logger jiniLog = Logger.getLogger("net.jini.discovery.LookupDiscovery"); -// -// private java.util.logging.Level logLevel; -// -// public void tearDown() throws Exception { -// -// // restore the log level. -// jiniLog.setLevel(logLevel); -// -// } - - /** - * @todo this is not really a unit test yet - more of a tool to helper debug - * the behavior when starting and (trying to) kill the jini core - * services. - * <p> - * The main problem with testability is that I have not figured out - * how to kill jini programmatically. One consequence is that this - * "test" will not terminate if it starts a jini instance until you - * close the jini instance in the gui. - * - * @see JiniCoreServicesProcessHelper#startCoreServices(Configuration, - * IServiceListener) - */ - public void test_findStartKill() throws Exception { - - final JiniCoreServicesConfiguration serviceConfig = new JiniCoreServicesConfiguration( - config); - - final JiniClientConfig clientConfig = new JiniClientConfig( - null/* class */, config); - - // make sure jini is not running before we start this test. - assertFalse("Jini already running: locators=" - + Arrays.toString(clientConfig.locators), JiniServicesHelper - .isJiniRunning(clientConfig.groups, clientConfig.locators, 500, - TimeUnit.MILLISECONDS)); - - boolean serviceStarted = - JiniCoreServicesProcessHelper.startCoreServices(config, listener); - String testName = (this.getClass()).getSimpleName(); - if(serviceStarted) { - // Find and shutdown lookup service started above - ServiceDiscoveryManager sdm = - new ServiceDiscoveryManager - (new LookupDiscoveryManager(clientConfig.groups, - clientConfig.locators, null), - null); - Class[] types = new Class[] { ServiceRegistrar.class }; - ServiceTemplate tmpl = new ServiceTemplate(null, types, null); - ServiceItem regItem = sdm.lookup(tmpl, null, 5L*1000L); - if(regItem == null) { - System.err.println - ("WARNING ["+testName+"]: lookup service started but " - +"could not discover it for shutdown"); - } else { - ServiceRegistrar reg = (ServiceRegistrar)(regItem.service); - List<String> groupsList = Arrays.asList(reg.getGroups()); - System.err.println - ("INFO ["+testName+"]: lookup service started " - +"[groups="+groupsList+"] - shutting it down"); - Object admin = ((Administrable)reg).getAdmin(); - ((com.sun.jini.admin.DestroyAdmin)admin).destroy(); - System.err.println - ("INFO ["+testName+"]: lookup service started and " - +"destroyed - [groups="+groupsList+"]"); - } - } - - // Shutdown the httpd class server - String httpdStopCmd = - (String)config.getEntry("jini", "httpdStopCmd", String.class, - null /*force exception if not in config*/); - System.err.println - ("INFO ["+testName+"]: shutdown class server ["+httpdStopCmd+"]"); - Runtime.getRuntime().exec(httpdStopCmd); - - assertTrue(serviceStarted); - -// -// final JiniCoreServicesStarter<JiniCoreServicesProcessHelper> serviceStarter = serviceConfig -// .newServiceStarter(listener); -// -// // start jini. -// final JiniCoreServicesProcessHelper processHelper = serviceStarter.call(); -// -// // make sure jini is running. -// assertTrue(JiniServicesHelper.isJiniRunning(clientConfig.groups, -// clientConfig.locators, 500, TimeUnit.MILLISECONDS)); -// -// // destroy jini. -// processHelper.kill(); - - } - -} Deleted: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceConfigurationMonitoring.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceConfigurationMonitoring.java 2010-09-25 17:41:54 UTC (rev 3631) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceConfigurationMonitoring.java 2010-09-27 13:34:16 UTC (rev 3632) @@ -1,203 +0,0 @@ -/* - -Copyright (C) SYSTAP, LLC 2006-2008. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* - * Created on Jan 7, 2009 - */ - -package com.bigdata.jini.start; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.TimeoutException; - -import net.jini.config.ConfigurationException; - -import org.apache.zookeeper.CreateMode; -import org.apache.zookeeper.KeeperException; -import org.apache.zookeeper.ZooKeeper; - -import com.bigdata.io.SerializerUtil; -import com.bigdata.jini.start.config.ServiceConfiguration; -import com.bigdata.jini.start.config.TransactionServerConfiguration; -import com.bigdata.service.jini.TransactionServer; - -/** - * Test suite for monitoring state changes for a {@link ServiceConfiguration} - * and creating a new physical service instance. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ -public class TestServiceConfigurationMonitoring extends AbstractFedZooTestCase { - - protected boolean serviceImplRemote; - - /** - * - */ - public TestServiceConfigurationMonitoring() { - this.serviceImplRemote = false; - } - - /** - * @param arg0 - */ - public TestServiceConfigurationMonitoring(String arg0) { - super(arg0); - this.serviceImplRemote = false; - } - - public TestServiceConfigurationMonitoring - (boolean serviceImplRemote) - { - this.serviceImplRemote = serviceImplRemote; - } - - public TestServiceConfigurationMonitoring - (String arg0, boolean serviceImplRemote) - { - super(arg0); - this.serviceImplRemote = serviceImplRemote; - } - - /** - * @throws InterruptedException - * @throws KeeperException - * @throws ConfigurationException - * @throws ExecutionException - * @throws TimeoutException - * - * @todo Unit test where the appropriate watchers are established and we - * then create the service configuration znode and let the watchers - * handle the creation of the logical and physical services and their - * znodes. - * - * @todo verify that normal service shutdown does remove the ephemeral znode - * and that service restart re-creates the SAME ephemeral znode (both - * should be true as the znode is created using the assigned service - * UUID rather than SEQUENTIAL so that it can be a restart safe - * zpath). - */ - public void test_logicalServiceWatcher() throws KeeperException, - InterruptedException, ConfigurationException, ExecutionException, - TimeoutException { - - // the config for that fake zroot. - final String zconfig = fed.getZooConfig().zroot + BigdataZooDefs.ZSLASH - + BigdataZooDefs.CONFIG; - - final ZooKeeper zookeeper = fed.getZookeeper(); - - final int numBefore = listener.running.size(); - - // zpath for the service configuration znode. - final String serviceConfigurationZPath = zconfig - + BigdataZooDefs.ZSLASH - + TransactionServer.class.getName(); - - // create monitor task that will compete for locks and start procsses. - MonitorCreatePhysicalServiceLocksTask task1 = new MonitorCreatePhysicalServiceLocksTask( - fed, listener); - - final Future f1 = fed.getExecutorService().submit(task1); - - assertFalse(f1.isDone()); - - // create monitor task for a specific service config node. - ServiceConfigurationZNodeMonitorTask task = new ServiceConfigurationZNodeMonitorTask( - fed, listener, TransactionServer.class.getName()); - - final Future f = fed.getExecutorService().submit(task); - - assertFalse(f.isDone()); - - /* - * Create znode for the ServiceConfiguration. - * - * Note: This should trigger the watcher. In turn, then watcher should - * create an instance of the service on our behalf. - */ - log.info("Creating zpath [serviceImplRemote="+serviceImplRemote+"]: " - +serviceConfigurationZPath); - - if(serviceImplRemote) { - zookeeper.create(serviceConfigurationZPath, SerializerUtil - .serialize(new TransactionServerConfiguration(TransactionServer.class, config)), acl, - CreateMode.PERSISTENT); - } else { - zookeeper.create(serviceConfigurationZPath, SerializerUtil - .serialize(new TransactionServerConfiguration(com.bigdata.transaction.ServiceImpl.class, config)), acl, - CreateMode.PERSISTENT); - } - - log.info("Created zpath: " + serviceConfigurationZPath); - - /* - * Verify that a logicalService znode was created for that configuration - * znode. - */ - - // pause a moment. - Thread.sleep(1000/*ms*/); - - log.info("logicalServices: " - + zookeeper.getChildren(serviceConfigurationZPath, false)); - - assertEquals(1, zookeeper.getChildren(serviceConfigurationZPath, false) - .size()); - - /* - * Let things run for few seconds. - * - * This give the task the chance to notice the ServiceConfiguration - * znode (we just created it) and to execute the task that creates the - * new logical service. - */ - - Thread.sleep(10000/*ms*/); - - if (f.isDone()) { - f.get(); - fail("not expecting task to end by itself."); - } else - f.cancel(true/* mayInterruptIfRunning */); - - if (f1.isDone()) { - f1.get(); - fail("not expecting task to end by itself."); - } else - f1.cancel(true/* mayInterruptIfRunning */); - - /* - * FIXME verify service is created, discover and query that service and - * verify that it is the instance that we wanted, then shutdown service - * and then verify service restart re-creates the same ephemeral node. - */ - - // verify a process was started. - assertEquals(numBefore + 1, listener.running.size()); - - } - -} Deleted: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceConfigurationMonitoringRemote.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceConfigurationMonitoringRemote.java 2010-09-25 17:41:54 UTC (rev 3631) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceConfigurationMonitoringRemote.java 2010-09-27 13:34:16 UTC (rev 3632) @@ -1,42 +0,0 @@ -/* - -Copyright (C) SYSTAP, LLC 2006-2008. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package com.bigdata.jini.start; - -/** - * Test suite for monitoring state changes for a {@link ServiceConfiguration} - * and creating a new physical service instance using the purely remote - * service implementation. - */ -public class TestServiceConfigurationMonitoringRemote - extends TestServiceConfigurationMonitoring -{ - public TestServiceConfigurationMonitoringRemote() { - super(true); - } - - public TestServiceConfigurationMonitoringRemote(String arg0) { - super(arg0, true); - } -} Deleted: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceConfigurationZNodeEnum.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceConfigurationZNodeEnum.java 2010-09-25 17:41:54 UTC (rev 3631) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceConfigurationZNodeEnum.java 2010-09-27 13:34:16 UTC (rev 3632) @@ -1,131 +0,0 @@ -/* - -Copyright (C) SYSTAP, LLC 2006-2008. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* - * Created on Jan 12, 2009 - */ - -package com.bigdata.jini.start; - -import com.bigdata.service.jini.TransactionServer; - -import junit.framework.TestCase2; - -/** - * Test suite for {@link ServiceConfigurationZNodeEnum}. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ -public class TestServiceConfigurationZNodeEnum extends TestCase2 { - - /** - * - */ - public TestServiceConfigurationZNodeEnum() { - - } - - /** - * @param arg0 - */ - public TestServiceConfigurationZNodeEnum(String arg0) { - - super(arg0); - - } - - final String serviceConfigZPath = "test-fed/" + BigdataZooDefs.CONFIG + "/" - + TransactionServer.class.getName(); - - /** - * <p> - * The behavior can be best interpreted with reference to an example: - * - * <pre> - * test-fed - * locks - * serviceConfigMonitor - * com.bigdata.service.jini.TransactionServer - * lock0000000000 (Ephemeral) - * createPhysicalService - * config - * W com.bigdata.service.jini.TransactionServer {TransactionServiceConfiguration} - * W logicalService0000000000 - * W physicalServices - * W abde9b91-24d5-4dc5-9bbf-41d7e7cac272 (Ephemeral) - * masterElection - * lock0000000000 (Ephemeral) - * </pre> - * - * In this example, the <code>W</code> appears at the start of each - * watched znode for the {@link TransactionServerConfiguration} znode. The - * master election znode can be seen directly below that. - */ - public void test01() { - - assertEquals(ServiceConfigurationZNodeEnum.ServiceConfiguration, - ServiceConfigurationZNodeEnum - .getType(serviceConfigZPath, serviceConfigZPath)); - - assertEquals(ServiceConfigurationZNodeEnum.LogicalService, - ServiceConfigurationZNodeEnum.getType(serviceConfigZPath, - serviceConfigZPath + "/" - + BigdataZooDefs.LOGICAL_SERVICE_PREFIX - + "0000000000")); - - assertEquals(ServiceConfigurationZNodeEnum.PhysicalServicesContainer, - ServiceConfigurationZNodeEnum.getType(serviceConfigZPath, - serviceConfigZPath + "/" - + BigdataZooDefs.LOGICAL_SERVICE_PREFIX - + "0000000000"+"/" - + BigdataZooDefs.PHYSICAL_SERVICES_CONTAINER)); - - - assertEquals(ServiceConfigurationZNodeEnum.PhysicalService, - ServiceConfigurationZNodeEnum.getType(serviceConfigZPath, - serviceConfigZPath + "/" - + BigdataZooDefs.LOGICAL_SERVICE_PREFIX - + "0000000000" + "/" - + BigdataZooDefs.PHYSICAL_SERVICES_CONTAINER - + "/" + "abde9b91-24d5-4dc5-9bbf-41d7e7cac272")); - - assertEquals(ServiceConfigurationZNodeEnum.MasterElection, - ServiceConfigurationZNodeEnum.getType(serviceConfigZPath, - serviceConfigZPath + "/" - + BigdataZooDefs.LOGICAL_SERVICE_PREFIX - + "0000000000" + "/" - + BigdataZooDefs.MASTER_ELECTION - )); - - assertEquals(ServiceConfigurationZNodeEnum.MasterElectionLock, - ServiceConfigurationZNodeEnum.getType(serviceConfigZPath, - serviceConfigZPath + "/" - + BigdataZooDefs.LOGICAL_SERVICE_PREFIX - + "0000000000" + "/" - + BigdataZooDefs.MASTER_ELECTION - + "/" + "lock0000000000")); - - } - -} Deleted: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceStarter.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceStarter.java 2010-09-25 17:41:54 UTC (rev 3631) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/jini/start/TestServiceStarter.java 2010-09-27 13:34:16 UTC (rev 3632) @@ -1,316 +0,0 @@ -/* - -Copyright (C) SYSTAP, LLC 2006-2008. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* - * Created on Jan 5, 2009 - */ - -package com.bigdata.jini.start; - -import java.io.IOException; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -import net.jini.config.ConfigurationException; -import net.jini.core.lookup.ServiceID; -import net.jini.core.lookup.ServiceItem; -import net.jini.core.lookup.ServiceTemplate; -import net.jini.lease.LeaseRenewalManager; -import net.jini.lookup.ServiceDiscoveryManager; - -import org.apache.zookeeper.CreateMode; -import org.apache.zookeeper.ZooKeeper; -import org.apache.zookeeper.data.Stat; - -import com.bigdata.io.SerializerUtil; -import com.bigdata.jini.start.config.BigdataServiceConfiguration; -import com.bigdata.jini.start.config.ServiceConfiguration; -import com.bigdata.jini.start.config.TransactionServerConfiguration; -import com.bigdata.jini.start.config.ManagedServiceConfiguration.ManagedServiceStarter; -import com.bigdata.jini.start.process.ProcessHelper; -import com.bigdata.jini.util.JiniUtil; -import com.bigdata.service.IService; -import com.bigdata.service.Service; -import com.bigdata.service.jini.RemoteDestroyAdmin; -import com.bigdata.service.jini.TransactionServer; -import com.bigdata.zookeeper.ZNodeDeletedWatcher; -import com.bigdata.zookeeper.ZooHelper; - -/** - * Test suite for starting a bigdata service based on a - * {@link ServiceConfiguration} stored in {@link ZooKeeper}. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ -public class TestServiceStarter extends AbstractFedZooTestCase { - - protected boolean serviceImplRemote; - - /** - * - */ - public TestServiceStarter() { - this.serviceImplRemote = false; - - } - - /** - * @param arg0 - */ - public TestServiceStarter(String arg0) { - - super(arg0); - this.serviceImplRemote = false; - - } - - public TestServiceStarter(boolean serviceImplRemote) { - this.serviceImplRemote = serviceImplRemote; - } - - public TestServiceStarter(String arg0, boolean serviceImplRemote) { - super(arg0); - this.serviceImplRemote = serviceImplRemote; - } - - /** - * Unit test verifies that we can start and destroy a service instance using - * a {@link BigdataServiceConfiguration}. The test waits until the service - * has been assigned its serviceId by jini and verify that the serviceId is - * recorded in the physicalService znode. - * - * @throws ConfigurationException - * @throws Exception - */ - public void test_startServer() throws ConfigurationException, Exception { - -// // create a unique fake zroot -// final String zroot = createTestZRoot(); -// -// // the config for that fake zroot. -// final String zconfig = zroot + BigdataZooDefs.ZSLASH -// + BigdataZooDefs.CONFIG; - - final ZooKeeper zookeeper = fed.getZookeeper(); - - TransactionServerConfiguration serviceConfig = null; - if(serviceImplRemote) { - serviceConfig = new TransactionServerConfiguration - (TransactionServer.class, config); - } else { - serviceConfig = - new TransactionServerConfiguration - (com.bigdata.transaction.ServiceImpl.class, config); - } - - // znode for serviceConfiguration - final String zserviceConfig = zookeeper.create(fed.getZooConfig().zroot - + BigdataZooDefs.ZSLASH + BigdataZooDefs.CONFIG - + BigdataZooDefs.ZSLASH - + TransactionServer.class.getName(), SerializerUtil - .serialize(serviceConfig), acl, CreateMode.PERSISTENT); - - /* - * znode for a logical service (the logical service is either a - * collection of peers or a service failover chain, depending on the - * type of the service). Logical services are persistent. Each one is - * assigned a unique (sequential) identifier by zookeeper. It is also - * assigned a random UUID. - */ - final String logicalServiceZPath = zookeeper.create(zserviceConfig - + BigdataZooDefs.LOGICAL_SERVICE_PREFIX, SerializerUtil.serialize(UUID - .randomUUID()), acl, CreateMode.PERSISTENT_SEQUENTIAL); - - /* - * Create the znode that is the parent for the physical service - * instances (direct child of the logicalSevice znode). - */ - final String parentZNode = logicalServiceZPath + "/" + BigdataZooDefs.PHYSICAL_SERVICES_CONTAINER; - final ManagedServiceStarter serviceStarter = - (ManagedServiceStarter) serviceConfig.newServiceStarter - (fed, listener, logicalServiceZPath, null/* attributes */); - zookeeper.create(parentZNode, - SerializerUtil.serialize(serviceStarter.serviceUUID), - acl, CreateMode.PERSISTENT); - - /* - * Create the znode for the election of the primary physical service for - * this logical service (direct child of the logicalSevice znode). - */ - zookeeper.create(logicalServiceZPath + "/" - + BigdataZooDefs.MASTER_ELECTION, new byte[0], acl, - CreateMode.PERSISTENT); - - // will be zero unless we started a zookeeper server above. - final int processCountBefore = listener.running.size(); - - // start the service. - final ProcessHelper processHelper = serviceStarter.call(); - - // verify listener was notified of service start. - assertEquals(processCountBefore + 1, listener.running.size()); - - // verify that the physicalService was registered with zookeeper. - final ServiceItem serviceItem; - IService proxy = null; - Service smartProxy = null; - final String physicalServiceZPath; - { - - final List<String> children = zookeeper.getChildren( - logicalServiceZPath, false/* watch */); - - System.err.println("physicalServices=" + children); - - // will fail if the znode was not registered. - assertEquals(2, children.size()); - - /* - * There should be only one child, which is the physical service - * that we created. - * - * Note: You could explicitly build the correct zpath using the - * serviceUUID obtained from the service proxy. - */ - physicalServiceZPath = logicalServiceZPath + "/" - + children.get(0); - - // get the serviceUUID from the physicalServiceZNode's data. - final UUID serviceUUID = (UUID) SerializerUtil - .deserialize(zookeeper.getData(physicalServiceZPath, - false/* watch */, new Stat())); - - serviceItem = discoverService(serviceUUID); - - // verify that the service item is registered with jini. - assertNotNull(serviceItem); - - // save reference to the service proxy. - if(serviceItem.service instanceof IService) { - proxy = (IService)serviceItem.service; - } else if(serviceItem.service instanceof Service) { - smartProxy = (Service)serviceItem.service; - } else { - fail("service not an instance of either Service or IService"); - } - } - - // Verify the service UUID using the proxy - if(proxy == null) { - assertEquals(JiniUtil.serviceID2UUID(serviceItem.serviceID), smartProxy.getServiceUUID()); - } else { - assertEquals(JiniUtil.serviceID2UUID(serviceItem.serviceID), proxy.getServiceUUID()); - } - - // Verify the service name using the proxy - // (Note: only do this for the remote case, - // names will be different for smart proxy case) - if(proxy != null) { - assertEquals(serviceStarter.serviceName, proxy.getServiceName()); - } - - // Tell the service to destroy itself. - if(proxy == null) { - try { - ((com.sun.jini.admin.DestroyAdmin)(((net.jini.admin.Administrable)smartProxy).getAdmin())).destroy(); - } catch(Throwable t) { - System.out.println("TestServiceStarter: SHUTDOWN WARNING ["+t+"]"); - t.printStackTrace(); - } - } else { - ((RemoteDestroyAdmin)proxy).destroy(); - } -// listener.running.get(0).destroy(); - - // wait a bit for the process to die. - processHelper.exitValue(10L, TimeUnit.SECONDS); - - // verify that it has been removed from our listener. - assertEquals("Expected " + processCountBefore + ", but #running=" - + listener.running.size() + ", processes=" - + listener.running.toString(), processCountBefore, - listener.running.size()); - - ZooHelper.destroyZNodes(zookeeper, parentZNode, 1); - - /* - * Wait until the znode for the physical service has been removed. - * - * Note: An ephemeral znode will be removed once the zookeeper client - * either times out or is explicitly closed. Since we are killing the - * process rather than terminating the service normally we may have to - * raise the timeout before zookeeper will delete the service's znode on - * its behalf. - */ - if (!ZNodeDeletedWatcher.awaitDelete(zookeeper, physicalServiceZPath, - 20000, TimeUnit.MILLISECONDS)) { - - fail("znode not removed: zpath=" + physicalServiceZPath); - - } - - } - - /** - * Looks up the service item in any joined jini registrars but does not wait - * for the service item to become registered. - * - * @param serviceUUID - * - * @return - * - * @throws IOException - */ - protected ServiceItem discoverService(final UUID serviceUUID) throws IOException { - - final ServiceID serviceId = JiniUtil.uuid2ServiceID(serviceUUID); - - ServiceDiscoveryManager serviceDiscoveryManager = null; - try { - - serviceDiscoveryManager = new ServiceDiscoveryManager(fed - .getDiscoveryManagement(), new LeaseRenewalManager()); - - final ServiceItem item = serviceDiscoveryManager - .lookup(new ServiceTemplate(serviceId, null/* iface[] */, - null/* entry[] */),// - null // filter - ); - - return item; - - } finally { - - if (serviceDiscoveryManager != null) { - - serviceDiscoveryManager.terminate(); - - } - - } - -... [truncated message content] |