Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B1CB91811E for ; Fri, 29 Jan 2016 01:16:29 +0000 (UTC) Received: (qmail 33582 invoked by uid 500); 29 Jan 2016 01:16:29 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 33537 invoked by uid 500); 29 Jan 2016 01:16:29 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 33407 invoked by uid 99); 29 Jan 2016 01:16:29 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Jan 2016 01:16:29 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 14F811A09E8 for ; Fri, 29 Jan 2016 01:16:29 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.227 X-Spam-Level: * X-Spam-Status: No, score=1.227 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.554, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id RYMAFcOadLI3 for ; Fri, 29 Jan 2016 01:16:21 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id 9DF8931AB5 for ; Fri, 29 Jan 2016 01:16:19 +0000 (UTC) Received: (qmail 31903 invoked by uid 99); 29 Jan 2016 01:16:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Jan 2016 01:16:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B9572DFF96; Fri, 29 Jan 2016 01:16:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dschneider@apache.org To: commits@geode.incubator.apache.org Date: Fri, 29 Jan 2016 01:16:18 -0000 Message-Id: <7953555325cd412f9d6803766f987267@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/52] [abbrv] incubator-geode git commit: GEODE-819: Move dunit to com.gemstone.gemfire.test.dunit Repository: incubator-geode Updated Branches: refs/heads/feature/GEODE-831 3dd04f2f4 -> 4c951aff4 http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d89038db/gemfire-core/src/test/java/dunit/VM.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/dunit/VM.java b/gemfire-core/src/test/java/dunit/VM.java deleted file mode 100644 index f4cde93..0000000 --- a/gemfire-core/src/test/java/dunit/VM.java +++ /dev/null @@ -1,1347 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package dunit; - -import java.io.File; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.rmi.RemoteException; -import java.util.concurrent.Callable; -//import java.util.Iterator; -//import java.util.Vector; - -import hydra.MethExecutorResult; - -import com.gemstone.gemfire.test.dunit.standalone.BounceResult; -import com.gemstone.gemfire.test.dunit.standalone.RemoteDUnitVMIF; - -/** - * This class represents a Java Virtual Machine that runs on a host. - * - * @author David Whitlock - * - */ -public class VM implements java.io.Serializable { - - /** The host on which this VM runs */ - private Host host; - - /** The process id of this VM */ - private int pid; - - /** The hydra client for this VM */ - private RemoteDUnitVMIF client; - - /** The state of this VM */ - private volatile boolean available; - - //////////////////// Constructors //////////////////// - - /** - * Creates a new VM that runs on a given host with a - * given process id. - */ - public VM(Host host, int pid, RemoteDUnitVMIF client) { - this.host = host; - this.pid = pid; - this.client = client; - this.available = true; - } - - ////////////////////// Accessors ////////////////////// - - /** - * Returns the host on which this VM runs - */ - public Host getHost() { - return this.host; - } - - /** - * Returns the process id of this VM - */ - public int getPid() { - return this.pid; - } - - ///////////////// Remote Method Invocation /////////////// - - /** - * Invokes a static zero-arg method with an {@link Object} or - * void return type in this VM. If the return type of - * the method is void, null is returned. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public Object invoke(Class c, String methodName) { - return invoke(c, methodName, new Object[0]); - } - - /** - * Asynchronously invokes a static zero-arg method with an {@link - * Object} or void return type in this VM. If the - * return type of the method is void, null - * is returned. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - */ - public AsyncInvocation invokeAsync(Class c, String methodName) { - return invokeAsync(c, methodName, null); - } - - /** - * Invokes a static method with an {@link Object} or - * void return type in this VM. If the return type of - * the method is void, null is returned. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public Object invoke(Class c, String methodName, Object[] args) { - if (!this.available) { - String s = "VM not available: " + this; - throw new RMIException(this, c.getName(), methodName, - new IllegalStateException(s)); - } - MethExecutorResult result = null; - int retryCount = 120; - do { - try { - result = this.client.executeMethodOnClass(c.getName(), methodName, args); - break; // out of while loop - } catch( RemoteException e ) { - boolean isWindows = false; - String os = System.getProperty("os.name"); - if (os != null) { - if (os.indexOf("Windows") != -1) { - isWindows = true; - } - } - if (isWindows && retryCount-- > 0) { - boolean interrupted = Thread.interrupted(); - try { Thread.sleep(1000); } catch (InterruptedException ignore) {interrupted = true;} - finally { - if (interrupted) { - Thread.currentThread().interrupt(); - } - } - } else { - throw new RMIException(this, c.getName(), methodName, e ); - } - } - } while (true); - - if (!result.exceptionOccurred()) { - return result.getResult(); - - } else { - Throwable thr = result.getException(); - throw new RMIException(this, c.getName(), methodName, thr, - result.getStackTrace()); - } - } - - /** - * Asynchronously invokes a static method with an {@link Object} or - * void return type in this VM. If the return type of - * the method is void, null is returned. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - */ - public AsyncInvocation invokeAsync(final Class c, - final String methodName, - final Object[] args) { - AsyncInvocation ai = - new AsyncInvocation(c, methodName, new Runnable() { - public void run() { - final Object o = invoke(c, methodName, args); - AsyncInvocation.setReturnValue(o); - } - }); - ai.start(); - return ai; - } - - /** - * Asynchronously invokes an instance method with an {@link Object} or - * void return type in this VM. If the return type of - * the method is void, null is returned. - * - * @param o - * The object on which to invoke the method - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - */ - public AsyncInvocation invokeAsync(final Object o, - final String methodName, - final Object[] args) { - AsyncInvocation ai = - new AsyncInvocation(o, methodName, new Runnable() { - public void run() { - final Object ret = invoke(o, methodName, args); - AsyncInvocation.setReturnValue(ret); - } - }); - ai.start(); - return ai; - } - - /** - * Invokes the run method of a {@link Runnable} in this - * VM. Recall that run takes no arguments and has no - * return value. - * - * @param r - * The Runnable to be run - * - * @see SerializableRunnable - */ - public AsyncInvocation invokeAsync(Runnable r) { - return invokeAsync(r, "run", new Object[0]); - } - - /** - * Invokes the call method of a {@link Runnable} in this - * VM. - * - * @param c - * The Callable to be run - * - * @see SerializableCallable - */ - public AsyncInvocation invokeAsync(Callable c) { - return invokeAsync(c, "call", new Object[0]); - } - - /** - * Invokes the run method of a {@link Runnable} in this - * VM. Recall that run takes no arguments and has no - * return value. - * - * @param r - * The Runnable to be run - * - * @see SerializableRunnable - */ - public void invoke(Runnable r) { - invoke(r, "run"); - } - - /** - * Invokes the run method of a {@link Runnable} in this - * VM. Recall that run takes no arguments and has no - * return value. - * - * @param c - * The Callable to be run - * - * @see SerializableCallable - */ - public Object invoke(Callable c) { - return invoke(c, "call"); - } - - /** - * Invokes the run0, the run method is invoked repeatedly until it - * either succeeds, or repeatTimeoutMs has passed. The AssertionFailedError - * is thrown back to the sender of this method if run has not - * completed successfully before repeatTimeoutMs has passed. - */ - public void invokeRepeatingIfNecessary(RepeatableRunnable o, long repeatTimeoutMs) { - invoke(o, "runRepeatingIfNecessary", new Object[] {new Long(repeatTimeoutMs)}); - } - - /** - * Invokes an instance method with no arguments on an object that is - * serialized into this VM. The return type of the method can be - * either {@link Object} or void. If the return type - * of the method is void, null is - * returned. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public Object invoke(Object o, String methodName) { - return invoke(o, methodName, new Object[0]); - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method can be either {@link - * Object} or void. If the return type of the method - * is void, null is returned. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public Object invoke(Object o, String methodName, Object[] args) { - if (!this.available) { - String s = "VM not available: " + this; - throw new RMIException(this, o.getClass().getName(), methodName, - new IllegalStateException(s)); - } - MethExecutorResult result = null; - int retryCount = 120; - do { - try { - if ( args == null ) - result = this.client.executeMethodOnObject(o, methodName); - else - result = this.client.executeMethodOnObject(o, methodName, args); - break; // out of while loop - } catch( RemoteException e ) { - if (retryCount-- > 0) { - boolean interrupted = Thread.interrupted(); - try { Thread.sleep(1000); } catch (InterruptedException ignore) {interrupted = true;} - finally { - if (interrupted) { - Thread.currentThread().interrupt(); - } - } - } else { - throw new RMIException(this, o.getClass().getName(), methodName, e ); - } - } - } while (true); - - if (!result.exceptionOccurred()) { - return result.getResult(); - - } else { - Throwable thr = result.getException(); - throw new RMIException(this, o.getClass().getName(), methodName, thr, - result.getStackTrace()); - } - } - - /** - * Invokes the main method of a given class - * - * @param c - * The class on which to invoke the main method - * @param args - * The "command line" arguments to pass to the - * main method - */ - public void invokeMain(Class c, String[] args) { - Object[] stupid = new Object[] { args }; - invoke(c, "main", stupid); - } - - /** - * Asynchronously invokes the main method of a given - * class - * - * @param c - * The class on which to invoke the main method - * @param args - * The "command line" arguments to pass to the - * main method - */ - public AsyncInvocation invokeMainAsync(Class c, String[] args) { - Object[] stupid = new Object[] { args }; - return invokeAsync(c, "main", stupid); - } - - /** - * Invokes a static method with a boolean return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a boolean - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public boolean invokeBoolean(Class c, String methodName) { - return invokeBoolean(c, methodName, new Object[0]); - } - - /** - * Invokes a static method with a boolean return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a boolean - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public boolean invokeBoolean(Class c, String methodName, Object[] args) { - Object result = invoke(c, methodName, args); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a boolean"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Boolean) { - return ((Boolean) result).booleanValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a boolean"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is boolean. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a boolean - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public boolean invokeBoolean(Object o, String methodName) { - return invokeBoolean(o, methodName, new Object[0]); - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is boolean. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a boolean - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public boolean invokeBoolean(Object o, String methodName, Object[] args) { - Object result = invoke(o, methodName, args); - Class c = o.getClass(); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a boolean"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Boolean) { - return ((Boolean) result).booleanValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a boolean"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes a static method with a char return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a char - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public char invokeChar(Class c, String methodName) { - return invokeChar(c, methodName, new Object[0]); - } - - /** - * Invokes a static method with a char return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a char - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public char invokeChar(Class c, String methodName, Object[] args) { - Object result = invoke(c, methodName, args); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a char"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Character) { - return ((Character) result).charValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a char"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is char. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a char - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public char invokeChar(Object o, String methodName) { - return invokeChar(o, methodName, new Object[0]); - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is char. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a char - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public char invokeChar(Object o, String methodName, Object[] args) { - Object result = invoke(o, methodName, args); - Class c = o.getClass(); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a char"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Character) { - return ((Character) result).charValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a char"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes a static method with a byte return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a byte - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public byte invokeByte(Class c, String methodName) { - return invokeByte(c, methodName, new Object[0]); - } - - /** - * Invokes a static method with a byte return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a byte - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public byte invokeByte(Class c, String methodName, Object[] args) { - Object result = invoke(c, methodName, args); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a byte"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Byte) { - return ((Byte) result).byteValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a byte"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is byte. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a byte - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public byte invokeByte(Object o, String methodName) { - return invokeByte(o, methodName, new Object[0]); - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is byte. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a byte - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public byte invokeByte(Object o, String methodName, Object[] args) { - Object result = invoke(o, methodName, args); - Class c = o.getClass(); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a byte"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Byte) { - return ((Byte) result).byteValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a byte"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes a static method with a short return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a short - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public short invokeShort(Class c, String methodName) { - return invokeShort(c, methodName, new Object[0]); - } - - /** - * Invokes a static method with a short return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a short - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public short invokeShort(Class c, String methodName, Object[] args) { - Object result = invoke(c, methodName, args); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a short"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Short) { - return ((Short) result).shortValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a short"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is short. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a short - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public short invokeShort(Object o, String methodName) { - return invokeShort(o, methodName, new Object[0]); - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is short. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a short - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public short invokeShort(Object o, String methodName, Object[] args) { - Object result = invoke(o, methodName, args); - Class c = o.getClass(); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a short"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Short) { - return ((Short) result).shortValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a short"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes a static method with a int return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a int - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public int invokeInt(Class c, String methodName) { - return invokeInt(c, methodName, new Object[0]); - } - - /** - * Invokes a static method with a int return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a int - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public int invokeInt(Class c, String methodName, Object[] args) { - Object result = invoke(c, methodName, args); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a int"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Integer) { - return ((Integer) result).intValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a int"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is int. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a int - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public int invokeInt(Object o, String methodName) { - return invokeInt(o, methodName, new Object[0]); - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is int. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a int - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public int invokeInt(Object o, String methodName, Object[] args) { - Object result = invoke(o, methodName, args); - Class c = o.getClass(); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a int"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Integer) { - return ((Integer) result).intValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a int"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes a static method with a long return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a long - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public long invokeLong(Class c, String methodName) { - return invokeLong(c, methodName, new Object[0]); - } - - /** - * Invokes a static method with a long return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a long - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public long invokeLong(Class c, String methodName, Object[] args) { - Object result = invoke(c, methodName, args); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a long"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Long) { - return ((Long) result).longValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a long"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is long. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a long - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public long invokeLong(Object o, String methodName) { - return invokeLong(o, methodName, new Object[0]); - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is long. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a long - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public long invokeLong(Object o, String methodName, Object[] args) { - Object result = invoke(o, methodName, args); - Class c = o.getClass(); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a long"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Long) { - return ((Long) result).longValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a long"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes a static method with a float return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a float - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public float invokeFloat(Class c, String methodName) { - return invokeFloat(c, methodName, new Object[0]); - } - - /** - * Invokes a static method with a float return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a float - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public float invokeFloat(Class c, String methodName, Object[] args) { - Object result = invoke(c, methodName, args); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a float"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Float) { - return ((Float) result).floatValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a float"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is float. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a float - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public float invokeFloat(Object o, String methodName) { - return invokeFloat(o, methodName, new Object[0]); - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is float. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a float - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public float invokeFloat(Object o, String methodName, Object[] args) { - Object result = invoke(o, methodName, args); - Class c = o.getClass(); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a float"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Float) { - return ((Float) result).floatValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a float"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes a static method with a double return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a double - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public double invokeDouble(Class c, String methodName) { - return invokeDouble(c, methodName, new Object[0]); - } - - /** - * Invokes a static method with a double return type - * in this VM. - * - * @param c - * The class on which to invoke the method - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a double - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public double invokeDouble(Class c, String methodName, Object[] args) { - Object result = invoke(c, methodName, args); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a double"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Double) { - return ((Double) result).doubleValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a double"; - throw new IllegalArgumentException(s); - } - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is double. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * - * @throws IllegalArgumentException - * The method does not return a double - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public double invokeDouble(Object o, String methodName) { - return invokeDouble(o, methodName, new Object[0]); - } - - /** - * Invokes an instance method on an object that is serialized into - * this VM. The return type of the method is double. - * - * @param o - * The receiver of the method invocation - * @param methodName - * The name of the method to invoke - * @param args - * Arguments passed to the method call (must be {@link - * java.io.Serializable}). - * - * @throws IllegalArgumentException - * The method does not return a double - * @throws RMIException - * An exception occurred on while invoking the method in - * this VM - */ - public double invokeDouble(Object o, String methodName, Object[] args) { - Object result = invoke(o, methodName, args); - Class c = o.getClass(); - if (result == null) { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned null, expected a double"; - throw new IllegalArgumentException(s); - - } else if (result instanceof Double) { - return ((Double) result).doubleValue(); - - } else { - String s = "Method \"" + methodName + "\" in class \"" + - c.getName() + "\" returned a \"" + result.getClass().getName() - + "\" expected a double"; - throw new IllegalArgumentException(s); - } - } - - /** - * Synchronously bounces (mean kills and restarts) this VM. - * Concurrent bounce attempts are synchronized but attempts to invoke - * methods on a bouncing VM will cause test failure. Tests using bounce - * should be placed at the end of the dunit test suite, since an exception - * here will cause all tests using the unsuccessfully bounced VM to fail. - * - * This method is currently not supported by the standalone dunit - * runner. - * - * @throws RMIException if an exception occurs while bouncing this VM, for - * example a HydraTimeoutException if the VM fails to stop within {@link - * hydra.Prms#maxClientShutdownWaitSec} or restart within {@link - * hydra.Prms#maxClientStartupWaitSec}. - */ - public synchronized void bounce() { - if (!this.available) { - String s = "VM not available: " + this; - throw new RMIException(this, this.getClass().getName(), "bounceVM", - new IllegalStateException(s)); - } - this.available = false; - try { - BounceResult result = DUnitEnv.get().bounce(this.pid); - - this.pid = result.getNewPid(); - this.client = result.getNewClient(); - this.available = true; - } catch (UnsupportedOperationException e) { - this.available = true; - throw e; - } catch (RemoteException e) { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw, true)); - RMIException rmie = new RMIException(this, this.getClass().getName(), - "bounceVM", e, sw.toString()); - throw rmie; - } - } - - ///////////////////// Utility Methods //////////////////// - - public String toString() { - return "VM " + this.getPid() + " running on " + this.getHost(); - } - - public static int getCurrentVMNum() { - return DUnitEnv.get().getVMID(); - } - - public File getWorkingDirectory() { - return DUnitEnv.get().getWorkingDirectory(this.getPid()); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/d89038db/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java index 4ba1fc7..f24b136 100644 --- a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java +++ b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/distributed/LuceneFunctionReadPathDUnitTest.java @@ -45,12 +45,11 @@ import com.gemstone.gemfire.cache.lucene.internal.LuceneServiceImpl; import com.gemstone.gemfire.cache30.CacheTestCase; import com.gemstone.gemfire.internal.cache.EvictionAttributesImpl; import com.gemstone.gemfire.internal.cache.PartitionedRegion; +import com.gemstone.gemfire.test.dunit.Host; +import com.gemstone.gemfire.test.dunit.SerializableCallable; +import com.gemstone.gemfire.test.dunit.VM; import com.gemstone.gemfire.test.junit.categories.DistributedTest; -import dunit.Host; -import dunit.SerializableCallable; -import dunit.VM; - @Category(DistributedTest.class) public class LuceneFunctionReadPathDUnitTest extends CacheTestCase { private static final String INDEX_NAME = "index";