5266N/A * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @summary The juicer is the classic RMI stress test. The juicer makes 0N/A * a large number of concurrent, long running, remote method invocations 0N/A * between many threads which have exported remote objects. These 0N/A * threads use remote objects that carry on deep "two party" 169N/A * recursion. The juicer relies on Distributed Garbage Collection to 169N/A * unexport these remote objects when no more references are held to them. 0N/A * The two parties in the recursion are OrangeImpl and 0N/A * OrangeEchoImpl. OrangeImpl checks the base case of the recursion 0N/A * so that the program will exit. 0N/A * When the AppleUserImpl.main() method is invoked, the class binds an 0N/A * instance of itself in a registry. A second server process, 169N/A * an ApplicationServer, is started which looks up the recently 0N/A * bound AppleUser object. This server is either started up in 0N/A * the same VM or can optionally be started in a separate VM on the 169N/A * same host or on a different host. When this test is run on the 169N/A * RMI profile, ApplicationServer must be started by AppleUserImpl 0N/A * and the complete juicer runs in a single process. 0N/A * The second server process instructs the AppleUserImpl to "use" some apples. 0N/A * AppleUserImpl creates a new thread for each apple. These threads 0N/A * initiate the two party recursion. 0N/A * Each recursive call nests to a depth determined by this 169N/A * expression: (2 + Math.abs(random.nextInt() % (maxLevel + 1)), 0N/A * where maxLevel is a command line parameter. Thus each recursive 0N/A * call nests a random number of levels between 2 and maxLevel. 0N/A * The test ends when an exception is encountered or the stop time 0N/A * @library ../../testlibrary 5551N/A * Apple AppleEvent AppleImpl 5551N/A * Orange OrangeEcho OrangeEchoImpl OrangeImpl 0N/A * @author Peter Jones, Nigel Daley 0N/A * The AppleUserImpl class implements the behavior of the remote 0N/A * "apple user" objects exported by the server. The application server 0N/A * passes each of its remote "apple" objects to an apple user, and an 0N/A * AppleUserThread is created for each apple. 0N/A * Allows the other server process to indicate that it is ready 0N/A * to start "juicing". 0N/A * Allows the other server process to report an exception to this 0N/A * process and thereby terminate the test. 0N/A * "Use" supplied apple object. Create an AppleUserThread to 0N/A * The AppleUserThread class repeatedly invokes calls on its associated 0N/A * Apple object to stress the RMI system. 169N/A do {
// loop until stopTime is reached 169N/A * Notify apple with some apple events. This tests 0N/A * serialization of arrays. 169N/A * Request a new orange object be created in 0N/A * the application server. 169N/A * Create a large message of random ints to pass to orange. 169N/A * Invoke recursive call on the orange. Base case 0N/A * of recursion inverts messgage. 169N/A * Verify message was properly inverted and not corrupted 169N/A * through all the recursive method invocations. 169N/A "ERROR: CORRUPTED RESPONSE: " +
169N/A "wrong length of returned array " +
"(should be " +
169N/A "ERROR: CORRUPTED RESPONSE: " +
169N/A " of returned array (should be " +
169N/A "-seconds <seconds>]");
0N/A * Entry point for the "juicer" server process. Create and export 0N/A * an apple user implementation in an rmiregistry running on localhost. 169N/A // parse command line args 169N/A // create new registry and bind new AppleUserImpl in registry 169N/A // start the other server if applicable 169N/A // the other server must be running in a separate process 169N/A "started in separate process");
169N/A // wait for other server to call startTest method 0N/A "process to start");
169N/A // wait for exception to be reported or first thread to complete 169N/A "test to complete or exception to be thrown");
169N/A +
"unexpected exception", e);