Author: peter_firmstone Date: Tue Apr 29 12:13:29 2014 New Revision: 1590959
URL: http://svn.apache.org/r1590959 Log: Update to ClassLoading to prevent interaction with profilers. Change RandomStressTest to utilize ExecutorService version of RetryTask, instead of deprecated TaskManager constructor, reduce number of transaction participants and tasks to sensible levels, higher levels stresses the test code, not Mahalo, the tests don't really phase Mahalo, which consumes less resources than the test code. Fixed a hotspot in TcpServerEndpoint. Modified: river/jtsk/skunk/qa_refactor/trunk/qa/ (props changed) river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/AbortCommitStressTask.java river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/AbortStressTask.java river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/CommitAbortStressTask.java river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/CommitStressTask.java river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTask.java river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTest.java river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTest.td river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/RetryTask.java river/jtsk/skunk/qa_refactor/trunk/src/net/jini/jeri/tcp/TcpServerEndpoint.java river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/ClassLoading.java Propchange: river/jtsk/skunk/qa_refactor/trunk/qa/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Tue Apr 29 12:13:29 2014 @@ -1,11 +1,13 @@ hs_err_pid4712.log classes result -lib-ext -lib -build.properties riverruntimelastbuild soul build LeaseRenewDurRFE-sharedVMDir-TestService_0 +hs_err_pid5956.log +lib-ext +hs_err_pid9196.log +lib +build.properties hs_err_pid10959.log Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/AbortCommitStressTask.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/AbortCommitStressTask.java?rev=1590959&r1=1590958&r2=1590959&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/AbortCommitStressTask.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/AbortCommitStressTask.java Tue Apr 29 12:13:29 2014 @@ -16,26 +16,26 @@ * limitations under the License. */ package com.sun.jini.test.impl.mahalo; -import net.jini.core.transaction.*; -import net.jini.core.transaction.server.*; -import com.sun.jini.mahalo.*; -import com.sun.jini.mahalo.log.*; -import com.sun.jini.thread.*; -import java.util.*; -import java.rmi.*; +import com.sun.jini.thread.WakeupManager; +import java.rmi.RemoteException; +import java.util.concurrent.ExecutorService; +import net.jini.core.transaction.CannotAbortException; +import net.jini.core.transaction.CannotCommitException; +import net.jini.core.transaction.TransactionException; +import net.jini.core.transaction.UnknownTransactionException; +import net.jini.core.transaction.server.TransactionManager; /** */ public class AbortCommitStressTask extends RandomStressTask { - private int attempt; + private volatile int attempt; // thread confined private static final int MAX_ATTEMPTS = 5; private static final boolean DEBUG = false; - public AbortCommitStressTask(TaskManager threadpool, - WakeupManager wakeupManager, TransactionManager mgr, int numParts) + public AbortCommitStressTask(ExecutorService executor, WakeupManager wakeupManager, TransactionManager mgr, int numParts) { - super(threadpool, wakeupManager, mgr, numParts); + super(executor, wakeupManager, mgr, numParts); } /* Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/AbortStressTask.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/AbortStressTask.java?rev=1590959&r1=1590958&r2=1590959&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/AbortStressTask.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/AbortStressTask.java Tue Apr 29 12:13:29 2014 @@ -16,26 +16,23 @@ * limitations under the License. */ package com.sun.jini.test.impl.mahalo; -import net.jini.core.transaction.*; -import net.jini.core.transaction.server.*; -import com.sun.jini.mahalo.*; -import com.sun.jini.mahalo.log.*; -import com.sun.jini.thread.*; -import java.util.*; -import java.rmi.*; +import com.sun.jini.thread.WakeupManager; +import java.rmi.RemoteException; +import java.util.concurrent.ExecutorService; +import net.jini.core.transaction.TransactionException; +import net.jini.core.transaction.server.TransactionManager; /** */ public class AbortStressTask extends RandomStressTask { - private int attempt; + private volatile int attempt;// thread confined private static final int MAX_ATTEMPTS = 5; private static final boolean DEBUG = false; - public AbortStressTask(TaskManager threadpool, WakeupManager wakeupManager, - TransactionManager mgr, int numParts) + public AbortStressTask(ExecutorService executor, WakeupManager wakeupManager, TransactionManager mgr, int numParts) { - super(threadpool, wakeupManager, mgr, numParts); + super(executor, wakeupManager, mgr, numParts); } /* Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/CommitAbortStressTask.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/CommitAbortStressTask.java?rev=1590959&r1=1590958&r2=1590959&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/CommitAbortStressTask.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/CommitAbortStressTask.java Tue Apr 29 12:13:29 2014 @@ -16,26 +16,26 @@ * limitations under the License. */ package com.sun.jini.test.impl.mahalo; -import net.jini.core.transaction.*; -import net.jini.core.transaction.server.*; -import com.sun.jini.mahalo.*; -import com.sun.jini.mahalo.log.*; -import com.sun.jini.thread.*; -import java.util.*; -import java.rmi.*; +import com.sun.jini.thread.WakeupManager; +import java.rmi.RemoteException; +import java.util.concurrent.ExecutorService; +import net.jini.core.transaction.CannotAbortException; +import net.jini.core.transaction.CannotCommitException; +import net.jini.core.transaction.TransactionException; +import net.jini.core.transaction.UnknownTransactionException; +import net.jini.core.transaction.server.TransactionManager; /** */ public class CommitAbortStressTask extends RandomStressTask { - private int attempt; + private volatile int attempt;// thread confined private static final int MAX_ATTEMPTS = 5; private static final boolean DEBUG = false; - public CommitAbortStressTask(TaskManager threadpool, - WakeupManager wakeupManager, TransactionManager mgr, int numParts) + public CommitAbortStressTask(ExecutorService executor, WakeupManager wakeupManager, TransactionManager mgr, int numParts) { - super(threadpool, wakeupManager, mgr, numParts); + super(executor, wakeupManager, mgr, numParts); } /* Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/CommitStressTask.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/CommitStressTask.java?rev=1590959&r1=1590958&r2=1590959&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/CommitStressTask.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/CommitStressTask.java Tue Apr 29 12:13:29 2014 @@ -23,19 +23,19 @@ import com.sun.jini.mahalo.log.*; import com.sun.jini.thread.*; import java.util.*; import java.rmi.*; +import java.util.concurrent.ExecutorService; /** */ public class CommitStressTask extends RandomStressTask { - private int attempt; + private volatile int attempt; //thread confined private static final int MAX_ATTEMPTS = 5; private static final boolean DEBUG = false; - public CommitStressTask(TaskManager threadpool, - WakeupManager wakeupManager, TransactionManager mgr, int numParts) + public CommitStressTask(ExecutorService executor, WakeupManager wakeupManager, TransactionManager mgr, int numParts) { - super(threadpool, wakeupManager, mgr, numParts); + super(executor, wakeupManager, mgr, numParts); } /* Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTask.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTask.java?rev=1590959&r1=1590958&r2=1590959&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTask.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTask.java Tue Apr 29 12:13:29 2014 @@ -28,6 +28,7 @@ import com.sun.jini.test.share.TestParti import com.sun.jini.test.share.TxnManagerTestOpcodes; import com.sun.jini.test.share.TxnTestUtils; import com.sun.jini.thread.TaskManager.Task; +import java.util.concurrent.ExecutorService; /** @@ -40,10 +41,9 @@ public abstract class RandomStressTask e protected ServerTransaction str; TestParticipant[] testparts; - public RandomStressTask(TaskManager threadpool, - WakeupManager wakeupManager, TransactionManager mgr, int numParts) + public RandomStressTask(ExecutorService executor, WakeupManager wakeupManager, TransactionManager mgr, int numParts) { - super(threadpool, wakeupManager); + super(executor, wakeupManager); if (numParts <= 0) { throw new IllegalArgumentException("RandomStressTask: numParts " Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTest.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTest.java?rev=1590959&r1=1590958&r2=1590959&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTest.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTest.java Tue Apr 29 12:13:29 2014 @@ -18,20 +18,18 @@ package com.sun.jini.test.impl.mahalo; import java.util.logging.Level; -import com.sun.jini.mahalo.*; -import net.jini.core.lease.*; -import net.jini.core.transaction.*; -import net.jini.core.transaction.server.*; -import com.sun.jini.thread.*; -import java.io.*; -import java.rmi.*; -import java.util.*; // Test harness specific classes import com.sun.jini.qa.harness.QAConfig; import com.sun.jini.qa.harness.Test; import com.sun.jini.qa.harness.TestException; import com.sun.jini.test.share.TxnManagerTest; +import com.sun.jini.thread.WakeupManager; +import java.util.Date; +import java.util.Random; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import net.jini.core.transaction.server.TransactionManager; /** @@ -69,7 +67,7 @@ public class RandomStressTest extends Tx // Another values. private volatile TransactionManager mgr = null; - private TaskManager threadpool = null; + private ExecutorService threadpool = null; private volatile WakeupManager wakeupManager = null; private volatile Random random; private volatile long seed = 0; @@ -182,7 +180,8 @@ public class RandomStressTest extends Tx + sleep_time); } random = new Random(seed); - threadpool = new TaskManager(threads, timeout, LOAD); + threadpool = Executors.newFixedThreadPool(threads); + //new TaskManager(threads, timeout, LOAD); wakeupManager = new WakeupManager(); startTxnMgr(); @@ -198,7 +197,7 @@ public class RandomStressTest extends Tx if (task == null) { throw new TestException("error creating a RandomStressTask"); } - threadpool.add(task); + threadpool.submit(task); alltasks[i] = task; if (DEBUG) { Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTest.td URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTest.td?rev=1590959&r1=1590958&r2=1590959&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTest.td (original) +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTest.td Tue Apr 29 12:13:29 2014 @@ -5,5 +5,5 @@ testCategories=txnmanager,txnmanager_imp # test may need up to 3 hours to run on an Ultra1 # value specified in seconds com.sun.jini.qa.harness.timeout=10800 -com.sun.jini.test.impl.mahalo.RandomStressTest.parts=200 +com.sun.jini.test.impl.mahalo.RandomStressTest.parts=50 com.sun.jini.test.impl.mahalo.RandomStressTest.tasks=5000 Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/RetryTask.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/RetryTask.java?rev=1590959&r1=1590958&r2=1590959&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/RetryTask.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/RetryTask.java Tue Apr 29 12:13:29 2014 @@ -115,7 +115,9 @@ public abstract class RetryTask<V> imple * Create a new <code>RetryTask</code> that will be scheduled with * the given task manager, and which will perform retry scheduling * using the given wakeup manager. + * @deprecated */ + @Deprecated public RetryTask(TaskManager manager, WakeupManager wakeupManager) { this.manager = manager; this.executor = null; Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/jeri/tcp/TcpServerEndpoint.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/jeri/tcp/TcpServerEndpoint.java?rev=1590959&r1=1590958&r2=1590959&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/jeri/tcp/TcpServerEndpoint.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/jeri/tcp/TcpServerEndpoint.java Tue Apr 29 12:13:29 2014 @@ -129,10 +129,51 @@ public final class TcpServerEndpoint imp private static final boolean useNIO = // default false ((Boolean) AccessController.doPrivileged(new GetBooleanAction( "com.sun.jini.jeri.tcp.useNIO"))).booleanValue(); + + private static final InetAddress localAdd; + private static final UnknownHostException exception; + + static { + /* The following was originally in + * enumerateListenEndpoints(ListenContext listenContext) + * however, InetAddress.getLocalHost() proved to be a hotspot in + * mahalo RandomStressTests for test code, which was attempting to + * stress Mahalo, but this was futile, given the test CPU usage + * for the test itself was 10x Mahalo, which wasn't raising a sweat. + * - Peter Firmstone 28th April 2014 + */ + InetAddress localAddr = null; + UnknownHostException exc = null; + try { + localAddr = (InetAddress) AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Object run() throws UnknownHostException { + return InetAddress.getLocalHost(); + } + }); + } catch (PrivilegedActionException e) { + try { + /* + * Only expose UnknownHostException thrown directly by + * InetAddress.getLocalHost if it would also be thrown + * in the caller's security context; otherwise, throw + * a new UnknownHostException without the host name. + */ + InetAddress.getLocalHost(); + } catch (UnknownHostException ex) { + exc = ex; + } + if (exc == null) + exc = new UnknownHostException("access to resolve local host denied"); + } + + localAdd = localAddr; + exception = exc; + } /** name for local host to fill in to corresponding TcpEndpoints */ private final String host; - + /** the TCP port that this TcpServerEndpoint listens on */ private final int port; @@ -519,35 +560,17 @@ public final class TcpServerEndpoint imp String localHost = host; if (localHost == null) { - InetAddress localAddr; - try { - localAddr = (InetAddress) AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public Object run() throws UnknownHostException { - return InetAddress.getLocalHost(); - } - }); - } catch (PrivilegedActionException e) { - /* - * Only expose UnknownHostException thrown directly by - * InetAddress.getLocalHost if it would also be thrown - * in the caller's security context; otherwise, throw - * a new UnknownHostException without the host name. - */ - InetAddress.getLocalHost(); - throw new UnknownHostException( - "access to resolve local host denied"); - } + if (exception != null) throw exception; SecurityManager sm = System.getSecurityManager(); if (sm != null) { try { - sm.checkConnect(localAddr.getHostName(), -1); + sm.checkConnect(localAdd.getHostName(), -1); } catch (SecurityException e) { throw new SecurityException( "access to resolve local host denied"); } } - localHost = localAddr.getHostAddress(); + localHost = localAdd.getHostAddress(); } LE listenEndpoint = new LE(); // REMIND: needn't be new? Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/ClassLoading.java URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/ClassLoading.java?rev=1590959&r1=1590958&r2=1590959&view=diff ============================================================================== --- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/ClassLoading.java (original) +++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/ClassLoading.java Tue Apr 29 12:13:29 2014 @@ -37,7 +37,6 @@ import java.util.concurrent.ConcurrentHa import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.concurrent.FutureTask; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; @@ -63,10 +62,8 @@ import org.apache.river.impl.thread.Name * As explained in River-336 this isn't always practical for IDE's or other * frameworks. To solve River-336, ClassLoading now uses {@link ServiceLoader} * to determine a {@link RMIClassLoaderSpi} provider, however unlike - * {@link RMIClassLoader}, it uses ClassLoading's {@link ClassLoader#getResources} - * instance to find providers. So if ClassLoading is loaded by a framework - * {@link ClassLoader}, resources will be selected from ClassLoaders reachable - * from ClassLoading's own ClassLoader. + * {@link RMIClassLoader}, by default it uses ClassLoading's {@link ClassLoader#getResources} + * instance to find providers. * </p><p> * To define a new RMIClassLoaderSpi for River to utilize, create a file in * your providers jar file called: @@ -578,6 +575,10 @@ public final class ClassLoading { throws ClassNotFoundException { if (loader == null) return Class.forName(name, initialize, loader); + // Don't thread confine profiler ClassLoaders. + if (loader.toString().startsWith("javax.management.remote.rmi.RMIConnectionImpl") ) + return Class.forName(name, initialize, loader); + ExecutorService exec = loaderMap.get(loader); if (exec == null){ exec = new ThreadPoolExecutor(
