http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Invoke.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Invoke.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Invoke.java index edb742b..5a4ca15 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Invoke.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Invoke.java @@ -19,6 +19,22 @@ package com.gemstone.gemfire.test.dunit; import java.util.HashMap; import java.util.Map; +/** + * <code>Invoke</code> provides static utility methods that allow a + * <code>DistributedTest</code> to invoke a <code>SerializableRunnable</code> + * or <code>SerializableCallable</code> in a remote test <code>VM</code>. + * + * These methods can be used directly: <code>Invoke.invokeInEveryVM(...)</code>, + * however, they are intended to be referenced through static import: + * + * <pre> + * import static com.gemstone.gemfire.test.dunit.Invoke.*; + * ... + * invokeInEveryVM(...); + * </pre> + * + * Extracted from DistributedTestCase. + */ public class Invoke { protected Invoke() { @@ -28,17 +44,17 @@ public class Invoke { * Invokes a <code>SerializableRunnable</code> in every VM that * DUnit knows about. * <p> - * Apparently this does NOT include the controller VM. + * Note: this does NOT include the controller VM or locator VM. * - * @see VM#invoke(Runnable) + * @see VM#invoke(SerializableRunnableIF) */ - public static void invokeInEveryVM(final SerializableRunnableIF work) { - for (int h = 0; h < Host.getHostCount(); h++) { - Host host = Host.getHost(h); + public static void invokeInEveryVM(final SerializableRunnableIF runnable) { + for (int hostIndex = 0; hostIndex < Host.getHostCount(); hostIndex++) { + Host host = Host.getHost(hostIndex); - for (int v = 0; v < host.getVMCount(); v++) { - VM vm = host.getVM(v); - vm.invoke(work); + for (int vmIndex = 0; vmIndex < host.getVMCount(); vmIndex++) { + VM vm = host.getVM(vmIndex); + vm.invoke(runnable); } } } @@ -47,14 +63,16 @@ public class Invoke { * Invokes a method in every remote VM that DUnit knows about. * * @see VM#invoke(Class, String) + * @deprecated Please use {@link #invokeInEveryVM(SerializableRunnableIF)} or another non-deprecated method in <code>Invoke</code> instead. */ - public static void invokeInEveryVM(final Class c, final String method) { - for (int h = 0; h < Host.getHostCount(); h++) { - Host host = Host.getHost(h); + @Deprecated + public static void invokeInEveryVM(final Class<?> targetClass, final String targetMethod) { + for (int hostIndex = 0; hostIndex < Host.getHostCount(); hostIndex++) { + Host host = Host.getHost(hostIndex); - for (int v = 0; v < host.getVMCount(); v++) { - VM vm = host.getVM(v); - vm.invoke(c, method); + for (int vmIndex = 0; vmIndex < host.getVMCount(); vmIndex++) { + VM vm = host.getVM(vmIndex); + vm.invoke(targetClass, targetMethod); } } } @@ -63,14 +81,15 @@ public class Invoke { * Invokes a method in every remote VM that DUnit knows about. * * @see VM#invoke(Class, String) + * @deprecated Please use {@link #invokeInEveryVM(SerializableRunnableIF)} or another non-deprecated method in <code>Invoke</code> instead. */ - public static void invokeInEveryVM(final Class c, final String method, final Object[] methodArgs) { - for (int h = 0; h < Host.getHostCount(); h++) { - Host host = Host.getHost(h); + public static void invokeInEveryVM(final Class<?> targetClass, final String targetMethod, final Object[] methodArgs) { + for (int hostIndex = 0; hostIndex < Host.getHostCount(); hostIndex++) { + Host host = Host.getHost(hostIndex); - for (int v = 0; v < host.getVMCount(); v++) { - VM vm = host.getVM(v); - vm.invoke(c, method, methodArgs); + for (int vmIndex = 0; vmIndex < host.getVMCount(); vmIndex++) { + VM vm = host.getVM(vmIndex); + vm.invoke(targetClass, targetMethod, methodArgs); } } } @@ -79,54 +98,63 @@ public class Invoke { * Invokes a <code>SerializableCallable</code> in every VM that * DUnit knows about. * - * @return a Map of results, where the key is the VM and the value is the result + * @return a Map of results, where the key is the VM and the value is the result for that VM * @see VM#invoke(SerializableCallableIF) */ - public static <T> Map<VM, T> invokeInEveryVM(final SerializableCallableIF<T> work) { + public static <T> Map<VM, T> invokeInEveryVM(final SerializableCallableIF<T> callable) { Map<VM, T> ret = new HashMap<VM, T>(); for (int h = 0; h < Host.getHostCount(); h++) { Host host = Host.getHost(h); for (int v = 0; v < host.getVMCount(); v++) { VM vm = host.getVM(v); - ret.put(vm, vm.invoke(work)); + ret.put(vm, vm.invoke(callable)); } } return ret; } - public static void invokeInLocator(SerializableRunnableIF work) { - Host.getLocator().invoke(work); + public static void invokeInLocator(final SerializableRunnableIF runnable) { + Host.getLocator().invoke(runnable); } - public static void invokeRepeatingIfNecessary(final VM vm, final RepeatableRunnable task) { - vm.invokeRepeatingIfNecessary(task, 0); + /** + * @deprecated Please use {@link com.jayway.awaitility.Awaitility} with {@link #invokeInEveryVM(SerializableCallableIF)} instead. + */ + public static void invokeRepeatingIfNecessary(final VM vm, final RepeatableRunnable runnable) { + vm.invokeRepeatingIfNecessary(runnable, 0); } - public static void invokeRepeatingIfNecessary(final VM vm, final RepeatableRunnable task, final long repeatTimeoutMs) { - vm.invokeRepeatingIfNecessary(task, repeatTimeoutMs); + /** + * @deprecated Please use {@link com.jayway.awaitility.Awaitility} with {@link #invokeInEveryVM(SerializableCallableIF)} instead. + */ + public static void invokeRepeatingIfNecessary(final VM vm, final RepeatableRunnable runnable, final long repeatTimeoutMs) { + vm.invokeRepeatingIfNecessary(runnable, repeatTimeoutMs); } - public static void invokeInEveryVMRepeatingIfNecessary(final RepeatableRunnable work) { - Invoke.invokeInEveryVMRepeatingIfNecessary(work, 0); + /** + * @deprecated Please use {@link com.jayway.awaitility.Awaitility} with {@link #invokeInEveryVM(SerializableCallableIF)} instead. + */ + public static void invokeInEveryVMRepeatingIfNecessary(final RepeatableRunnable runnable) { + Invoke.invokeInEveryVMRepeatingIfNecessary(runnable, 0); } /** * Invokes a <code>SerializableRunnable</code> in every VM that - * DUnit knows about. If work.run() throws an assertion failure, + * DUnit knows about. If <code>run()</code> throws an assertion failure, * its execution is repeated, until no assertion failure occurs or - * repeatTimeout milliseconds have passed. + * <code>repeatTimeoutMs</code> milliseconds have passed. * - * @see VM#invoke(SerializableRunnableIF) + * @see VM#invoke(RepeatableRunnable) + * @deprecated Please use {@link com.jayway.awaitility.Awaitility} with {@link #invokeInEveryVM(SerializableCallableIF)} instead. */ - public static void invokeInEveryVMRepeatingIfNecessary(final RepeatableRunnable work, final long repeatTimeoutMs) { + public static void invokeInEveryVMRepeatingIfNecessary(final RepeatableRunnable runnable, final long repeatTimeoutMs) { for (int h = 0; h < Host.getHostCount(); h++) { Host host = Host.getHost(h); for (int v = 0; v < host.getVMCount(); v++) { VM vm = host.getVM(v); - vm.invokeRepeatingIfNecessary(work, repeatTimeoutMs); + vm.invokeRepeatingIfNecessary(runnable, repeatTimeoutMs); } } } - }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/LogWriterSupport.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/LogWriterSupport.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/LogWriterSupport.java deleted file mode 100755 index b804845..0000000 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/LogWriterSupport.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.gemstone.gemfire.test.dunit; - -import java.util.Properties; - -import org.apache.logging.log4j.Logger; - -import com.gemstone.gemfire.LogWriter; -import com.gemstone.gemfire.distributed.internal.DistributionConfig; -import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl; -import com.gemstone.gemfire.internal.logging.InternalLogWriter; -import com.gemstone.gemfire.internal.logging.LogService; -import com.gemstone.gemfire.internal.logging.LogWriterFactory; -import com.gemstone.gemfire.internal.logging.ManagerLogWriter; -import com.gemstone.gemfire.internal.logging.log4j.LogWriterLogger; - -public class LogWriterSupport { - - private static final Logger logger = LogService.getLogger(); - private static final LogWriterLogger oldLogger = LogWriterLogger.create(logger); - - /** - * Returns a <code>LogWriter</code> for logging information - * @deprecated Use a static logger from the log4j2 LogService.getLogger instead. - */ - @Deprecated - public static InternalLogWriter getLogWriter() { - return LogWriterSupport.oldLogger; - } - - /** - * Creates a new LogWriter and adds it to the config properties. The config - * can then be used to connect to DistributedSystem, thus providing early - * access to the LogWriter before connecting. This call does not connect - * to the DistributedSystem. It simply creates and returns the LogWriter - * that will eventually be used by the DistributedSystem that connects using - * config. - * - * @param config the DistributedSystem config properties to add LogWriter to - * @return early access to the DistributedSystem LogWriter - */ - public static LogWriter createLogWriter(Properties config) { // TODO:LOG:CONVERT: this is being used for ExpectedExceptions - Properties nonDefault = config; - if (nonDefault == null) { - nonDefault = new Properties(); - } - DistributedTestSupport.addHydraProperties(nonDefault); - - DistributionConfig dc = new DistributionConfigImpl(nonDefault); - LogWriter logger = LogWriterFactory.createLogWriterLogger( - false/*isLoner*/, false/*isSecurityLog*/, dc, - false); - - // if config was non-null, then these will be added to it... - nonDefault.put(DistributionConfig.LOG_WRITER_NAME, logger); - - return logger; - } - - /** - * This finds the log level configured for the test run. It should be used - * when creating a new distributed system if you want to specify a log level. - * @return the dunit log-level setting - */ - public static String getDUnitLogLevel() { - Properties p = DUnitEnv.get().getDistributedSystemProperties(); - String result = p.getProperty(DistributionConfig.LOG_LEVEL_NAME); - if (result == null) { - result = ManagerLogWriter.levelToString(DistributionConfig.DEFAULT_LOG_LEVEL); - } - return result; - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/LogWriterUtils.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/LogWriterUtils.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/LogWriterUtils.java new file mode 100755 index 0000000..9ecea61 --- /dev/null +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/LogWriterUtils.java @@ -0,0 +1,95 @@ +package com.gemstone.gemfire.test.dunit; + +import java.util.Properties; + +import org.apache.logging.log4j.Logger; + +import com.gemstone.gemfire.LogWriter; +import com.gemstone.gemfire.distributed.internal.DistributionConfig; +import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl; +import com.gemstone.gemfire.internal.logging.InternalLogWriter; +import com.gemstone.gemfire.internal.logging.LogService; +import com.gemstone.gemfire.internal.logging.LogWriterFactory; +import com.gemstone.gemfire.internal.logging.ManagerLogWriter; +import com.gemstone.gemfire.internal.logging.log4j.LogWriterLogger; + +/** + * <code>LogWriterUtils</code> provides static utility methods to access a + * <code>LogWriter</code> within a test. + * + * These methods can be used directly: <code>LogWriterUtils.getLogWriter(...)</code>, + * however, they are intended to be referenced through static import: + * + * <pre> + * import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*; + * ... + * LogWriter logWriter = getLogWriter(...); + * </pre> + * + * Extracted from DistributedTestCase. + * + * @deprecated Please use a <code>Logger</code> from {@link LogService#getLogger()} instead. + */ +@Deprecated +public class LogWriterUtils { + + private static final Logger logger = LogService.getLogger(); + private static final LogWriterLogger oldLogger = LogWriterLogger.create(logger); + + protected LogWriterUtils() { + } + + /** + * Returns a <code>LogWriter</code> for logging information + * + * @deprecated Please use a <code>Logger</code> from {@link LogService#getLogger()} instead. + */ + public static InternalLogWriter getLogWriter() { + return LogWriterUtils.oldLogger; + } + + /** + * Creates a new LogWriter and adds it to the config properties. The config + * can then be used to connect to DistributedSystem, thus providing early + * access to the LogWriter before connecting. This call does not connect + * to the DistributedSystem. It simply creates and returns the LogWriter + * that will eventually be used by the DistributedSystem that connects using + * config. + * + * @param properties the DistributedSystem config properties to add LogWriter to + * @return early access to the DistributedSystem LogWriter + * @deprecated Please use a <code>Logger</code> from {@link LogService#getLogger()} instead. + */ + public static LogWriter createLogWriter(final Properties properties) { + Properties nonDefault = properties; + if (nonDefault == null) { + nonDefault = new Properties(); + } + DistributedTestUtils.addHydraProperties(nonDefault); + + DistributionConfig dc = new DistributionConfigImpl(nonDefault); + LogWriter logger = LogWriterFactory.createLogWriterLogger( + false/*isLoner*/, false/*isSecurityLog*/, dc, + false); + + // if config was non-null, then these will be added to it... + nonDefault.put(DistributionConfig.LOG_WRITER_NAME, logger); + + return logger; + } + + /** + * This finds the log level configured for the test run. It should be used + * when creating a new distributed system if you want to specify a log level. + * + * @return the dunit log-level setting + */ + public static String getDUnitLogLevel() { + Properties dsProperties = DUnitEnv.get().getDistributedSystemProperties(); + String result = dsProperties.getProperty(DistributionConfig.LOG_LEVEL_NAME); + if (result == null) { + result = ManagerLogWriter.levelToString(DistributionConfig.DEFAULT_LOG_LEVEL); + } + return result; + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/NetworkSupport.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/NetworkSupport.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/NetworkSupport.java deleted file mode 100755 index cff1707..0000000 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/NetworkSupport.java +++ /dev/null @@ -1,48 +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 com.gemstone.gemfire.test.dunit; - -import java.net.UnknownHostException; - -import com.gemstone.gemfire.internal.SocketCreator; - -public class NetworkSupport { - - /** get the IP literal name for the current host, use this instead of - * "localhost" to avoid IPv6 name resolution bugs in the JDK/machine config. - * @return an ip literal, this method honors java.net.preferIPvAddresses - */ - public static String getIPLiteral() { - try { - return SocketCreator.getLocalHost().getHostAddress(); - } catch (UnknownHostException e) { - throw new Error("problem determining host IP address", e); - } - } - - /** get the host name to use for a server cache in client/server dunit - * testing - * @param host - * @return the host name - */ - public static String getServerHostName(Host host) { - return System.getProperty("gemfire.server-bind-address") != null? - System.getProperty("gemfire.server-bind-address") - : host.getHostName(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/NetworkUtils.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/NetworkUtils.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/NetworkUtils.java new file mode 100755 index 0000000..d83aecd --- /dev/null +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/NetworkUtils.java @@ -0,0 +1,69 @@ +/* + * 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 com.gemstone.gemfire.test.dunit; + +import java.net.UnknownHostException; + +import com.gemstone.gemfire.internal.SocketCreator; + +/** + * <code>NetworkUtils</code> provides static utility methods to perform + * network DNS lookups or similar actions. + * + * These methods can be used directly: <code>NetworkUtils.getIPLiteral()</code>, + * however, they are intended to be referenced through static import: + * + * <pre> + * import static com.gemstone.gemfire.test.dunit.NetworkUtils.*; + * ... + * String hostName = getIPLiteral(); + * </pre> + * + * Extracted from DistributedTestCase. + */ +public class NetworkUtils { + + protected NetworkUtils() { + } + + /** + * Get the IP literal name for the current host. Use this instead of + * "localhost" to avoid IPv6 name resolution bugs in the JDK/machine config. + * This method honors java.net.preferIPvAddresses + * + * @return an IP literal which honors java.net.preferIPvAddresses + */ + public static String getIPLiteral() { + try { + return SocketCreator.getLocalHost().getHostAddress(); + } catch (UnknownHostException e) { + throw new Error("Problem determining host IP address", e); + } + } + + /** + * Get the host name to use for a server cache in client/server dunit + * testing. + * + * @param host the dunit Host to get a machine host name for + * @return the host name + */ + public static String getServerHostName(final Host host) { + String serverBindAddress = System.getProperty("gemfire.server-bind-address"); + return serverBindAddress != null ? serverBindAddress : host.getHostName(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/RMIException.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/RMIException.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/RMIException.java index 8a555d2..1a5fac4 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/RMIException.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/RMIException.java @@ -42,8 +42,8 @@ import com.gemstone.gemfire.GemFireException; * see hydra.RemoteTestModuleIF * * @author David Whitlock - * */ +@SuppressWarnings("serial") public class RMIException extends GemFireException { /** SHADOWED FIELD that holds the cause exception (as opposed to the http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/RepeatableRunnable.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/RepeatableRunnable.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/RepeatableRunnable.java index 32e4369..9695c32 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/RepeatableRunnable.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/RepeatableRunnable.java @@ -20,8 +20,10 @@ package com.gemstone.gemfire.test.dunit; * A RepeatableRunnable is an object that implements a method that * can be invoked repeatably without causing any side affects. * - * @author dmonnie + * @author dmonnie + * @deprecated Please use SerializableRunnable with {@link com.jayway.awaitility.Awaitility} instead. */ +@Deprecated public interface RepeatableRunnable { public void runRepeatingIfNecessary(long repeatTimeoutMs); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableCallableIF.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableCallableIF.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableCallableIF.java index c3d3ae7..ddeb71e 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableCallableIF.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableCallableIF.java @@ -19,6 +19,8 @@ package com.gemstone.gemfire.test.dunit; import java.io.Serializable; import java.util.concurrent.Callable; +/** + * Interface for {@link SerializableCallable} to enable use with lambdas. + */ public interface SerializableCallableIF<T> extends Serializable, Callable<T> { - } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnable.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnable.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnable.java index 658924a..353cdc7 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnable.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnable.java @@ -46,8 +46,7 @@ import java.io.Serializable; * } * </PRE> */ -public abstract class SerializableRunnable - implements SerializableRunnableIF { +public abstract class SerializableRunnable implements SerializableRunnableIF { private static final long serialVersionUID = 7584289978241650456L; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnableIF.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnableIF.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnableIF.java index 648e4f8..5e5467d 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnableIF.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/SerializableRunnableIF.java @@ -18,6 +18,8 @@ package com.gemstone.gemfire.test.dunit; import java.io.Serializable; +/** + * Interface for {@link SerializableRunnable} to enable use with lambdas. + */ public interface SerializableRunnableIF extends Serializable, Runnable { - } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/StoppableWaitCriterion.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/StoppableWaitCriterion.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/StoppableWaitCriterion.java index d90917e..b7be9c5 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/StoppableWaitCriterion.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/StoppableWaitCriterion.java @@ -16,10 +16,20 @@ */ package com.gemstone.gemfire.test.dunit; +/** + * Defines an asynchronous criterion with an optional method to fail early + * before timeout. + * + * Extracted from DistributedTestCase. + * + * @deprecated Use {@link com.jayway.awaitility.Awaitility} instead. + */ public interface StoppableWaitCriterion extends WaitCriterion { + /** * If this method returns true then quit waiting even if we are not done. * This allows a wait to fail early. */ public boolean stopWaiting(); -} \ No newline at end of file + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/ThreadUtils.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/ThreadUtils.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/ThreadUtils.java new file mode 100755 index 0000000..6ba87ed --- /dev/null +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/ThreadUtils.java @@ -0,0 +1,155 @@ +/* + * 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 com.gemstone.gemfire.test.dunit; + +import static org.junit.Assert.fail; +import static com.gemstone.gemfire.test.dunit.Jitter.*; + +import org.apache.logging.log4j.Logger; + +import com.gemstone.gemfire.internal.OSProcess; +import com.gemstone.gemfire.internal.logging.LogService; + +/** + * <code>ThreadUtils</code> provides static utility methods to perform thread + * related actions such as dumping thread stacks. + * + * These methods can be used directly: <code>ThreadUtils.dumpAllStacks()</code>, + * however, they are intended to be referenced through static import: + * + * <pre> + * import static com.gemstone.gemfire.test.dunit.ThreadUtils.*; + * ... + * dumpAllStacks(); + * </pre> + * + * Extracted from DistributedTestCase. + */ +public class ThreadUtils { + + private static final Logger logger = LogService.getLogger(); + + protected ThreadUtils() { + } + + /** + * Print stack dumps for all vms. + * + * @author bruce + * @since 5.0 + */ + public static void dumpAllStacks() { + for (int h=0; h < Host.getHostCount(); h++) { + dumpStack(Host.getHost(h)); + } + } + + /** + * Dump all thread stacks + */ + public static void dumpMyThreads() { + OSProcess.printStacks(0, false); + } + + /** + * Print a stack dump for this vm. + * + * @author bruce + * @since 5.0 + */ + public static void dumpStack() { + OSProcess.printStacks(0, false); + } + + /** + * Print stack dumps for all vms on the given host. + * + * @author bruce + * @since 5.0 + */ + public static void dumpStack(final Host host) { + for (int v=0; v < host.getVMCount(); v++) { + host.getVM(v).invoke(com.gemstone.gemfire.test.dunit.DistributedTestCase.class, "dumpStack"); + } + } + + /** + * Print a stack dump for the given vm. + * + * @author bruce + * @since 5.0 + */ + public static void dumpStack(final VM vm) { + vm.invoke(com.gemstone.gemfire.test.dunit.DistributedTestCase.class, "dumpStack"); + } + + public static void dumpStackTrace(final Thread thread, final StackTraceElement[] stackTrace) { + StringBuilder msg = new StringBuilder(); + msg.append("Thread=<") + .append(thread) + .append("> stackDump:\n"); + for (int i=0; i < stackTrace.length; i++) { + msg.append("\t") + .append(stackTrace[i]) + .append("\n"); + } + logger.info(msg.toString()); + } + + /** + * Wait for a thread to join. + * + * @param thread thread to wait on + * @param timeoutMilliseconds maximum time to wait + * @throws AssertionError if the thread does not terminate + */ + public static void join(final Thread thread, final long timeoutMilliseconds) { + final long tilt = System.currentTimeMillis() + timeoutMilliseconds; + final long incrementalWait = jitterInterval(timeoutMilliseconds); + final long start = System.currentTimeMillis(); + for (;;) { + // I really do *not* understand why this check is necessary + // but it is, at least with JDK 1.6. According to the source code + // and the javadocs, one would think that join() would exit immediately + // if the thread is dead. However, I can tell you from experimentation + // that this is not the case. :-( djp 2008-12-08 + if (!thread.isAlive()) { + break; + } + try { + thread.join(incrementalWait); + } catch (InterruptedException e) { + fail("interrupted"); + } + if (System.currentTimeMillis() >= tilt) { + break; + } + } // for + if (thread.isAlive()) { + logger.info("HUNG THREAD"); + ThreadUtils.dumpStackTrace(thread, thread.getStackTrace()); + ThreadUtils.dumpMyThreads(); + thread.interrupt(); // We're in trouble! + fail("Thread did not terminate after " + timeoutMilliseconds + " ms: " + thread); + } + long elapsedMs = (System.currentTimeMillis() - start); + if (elapsedMs > 0) { + String msg = "Thread " + thread + " took " + elapsedMs + " ms to exit."; + logger.info(msg); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Threads.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Threads.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Threads.java deleted file mode 100755 index ff0b5ef..0000000 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Threads.java +++ /dev/null @@ -1,138 +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 com.gemstone.gemfire.test.dunit; - -import static org.junit.Assert.fail; - -import org.apache.logging.log4j.Logger; - -import com.gemstone.gemfire.LogWriter; -import com.gemstone.gemfire.internal.OSProcess; -import com.gemstone.gemfire.internal.logging.LocalLogWriter; -import com.gemstone.gemfire.internal.logging.LogService; -import com.gemstone.gemfire.internal.logging.LogWriterImpl; - -public class Threads { - private static final Logger logger = LogService.getLogger(); - - /** - * Wait for a thread to join - * @param t thread to wait on - * @param ms maximum time to wait - * @throws AssertionError if the thread does not terminate - */ - static public void join(Thread t, long ms, LogWriter logger) { - final long tilt = System.currentTimeMillis() + ms; - final long incrementalWait = Jitter.jitterInterval(ms); - final long start = System.currentTimeMillis(); - for (;;) { - // I really do *not* understand why this check is necessary - // but it is, at least with JDK 1.6. According to the source code - // and the javadocs, one would think that join() would exit immediately - // if the thread is dead. However, I can tell you from experimentation - // that this is not the case. :-( djp 2008-12-08 - if (!t.isAlive()) { - break; - } - try { - t.join(incrementalWait); - } catch (InterruptedException e) { - fail("interrupted"); - } - if (System.currentTimeMillis() >= tilt) { - break; - } - } // for - if (logger == null) { - logger = new LocalLogWriter(LogWriterImpl.INFO_LEVEL, System.out); - } - if (t.isAlive()) { - logger.info("HUNG THREAD"); - Threads.dumpStackTrace(t, t.getStackTrace(), logger); - Threads.dumpMyThreads(logger); - t.interrupt(); // We're in trouble! - fail("Thread did not terminate after " + ms + " ms: " + t); - // getLogWriter().warning("Thread did not terminate" - // /* , new Exception()*/ - // ); - } - long elapsedMs = (System.currentTimeMillis() - start); - if (elapsedMs > 0) { - String msg = "Thread " + t + " took " - + elapsedMs - + " ms to exit."; - logger.info(msg); - } - } - - public static void dumpStackTrace(Thread t, StackTraceElement[] stack, LogWriter logger) { - StringBuilder msg = new StringBuilder(); - msg.append("Thread=<") - .append(t) - .append("> stackDump:\n"); - for (int i=0; i < stack.length; i++) { - msg.append("\t") - .append(stack[i]) - .append("\n"); - } - logger.info(msg.toString()); - } - - /** - * Dump all thread stacks - */ - public static void dumpMyThreads(LogWriter logger) { - OSProcess.printStacks(0, false); - } - - /** print a stack dump for this vm - @author bruce - @since 5.0 - */ - public static void dumpStack() { - com.gemstone.gemfire.internal.OSProcess.printStacks(0, false); - } - - /** print a stack dump for the given vm - @author bruce - @since 5.0 - */ - public static void dumpStack(VM vm) { - vm.invoke(com.gemstone.gemfire.test.dunit.DistributedTestCase.class, "dumpStack"); - } - - /** print stack dumps for all vms on the given host - @author bruce - @since 5.0 - */ - public static void dumpStack(Host host) { - for (int v=0; v < host.getVMCount(); v++) { - host.getVM(v).invoke(com.gemstone.gemfire.test.dunit.DistributedTestCase.class, "dumpStack"); - } - } - - /** print stack dumps for all vms - @author bruce - @since 5.0 - */ - public static void dumpAllStacks() { - for (int h=0; h < Host.getHostCount(); h++) { - dumpStack(Host.getHost(h)); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java index d8bbd21..db3e302 100644 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/VM.java @@ -18,9 +18,9 @@ package com.gemstone.gemfire.test.dunit; import java.io.File; import java.io.PrintWriter; +import java.io.Serializable; import java.io.StringWriter; import java.rmi.RemoteException; -import java.util.concurrent.Callable; import com.gemstone.gemfire.test.dunit.standalone.BounceResult; import com.gemstone.gemfire.test.dunit.standalone.RemoteDUnitVMIF; @@ -31,9 +31,9 @@ import hydra.MethExecutorResult; * This class represents a Java Virtual Machine that runs on a host. * * @author David Whitlock - * */ -public class VM implements java.io.Serializable { +@SuppressWarnings("serial") +public class VM implements Serializable { /** The host on which this VM runs */ private Host host; @@ -53,7 +53,7 @@ public class VM implements java.io.Serializable { * Creates a new <code>VM</code> that runs on a given host with a * given process id. */ - public VM(Host host, int pid, RemoteDUnitVMIF client) { + public VM(final Host host, final int pid, final RemoteDUnitVMIF client) { this.host = host; this.pid = pid; this.client = client; @@ -83,7 +83,7 @@ public class VM implements java.io.Serializable { * <code>void</code> return type in this VM. If the return type of * the method is <code>void</code>, <code>null</code> is returned. * - * @param c + * @param targetClass * The class on which to invoke the method * @param methodName * The name of the method to invoke @@ -92,8 +92,8 @@ public class VM implements java.io.Serializable { * 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]); + public Object invoke(final Class targetClass, final String methodName) { + return invoke(targetClass, methodName, new Object[0]); } /** @@ -102,13 +102,13 @@ public class VM implements java.io.Serializable { * return type of the method is <code>void</code>, <code>null</code> * is returned. * - * @param c + * @param targetClass * 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); + public AsyncInvocation invokeAsync(final Class targetClass, final String methodName) { + return invokeAsync(targetClass, methodName, null); } /** @@ -116,7 +116,7 @@ public class VM implements java.io.Serializable { * <code>void</code> return type in this VM. If the return type of * the method is <code>void</code>, <code>null</code> is returned. * - * @param c + * @param targetClass * The class on which to invoke the method * @param methodName * The name of the method to invoke @@ -128,17 +128,17 @@ public class VM implements java.io.Serializable { * An exception occurred on while invoking the method in * this VM */ - public Object invoke(Class c, String methodName, Object[] args) { + public Object invoke(Class targetClass, String methodName, Object[] args) { if (!this.available) { String s = "VM not available: " + this; - throw new RMIException(this, c.getName(), methodName, + throw new RMIException(this, targetClass.getName(), methodName, new IllegalStateException(s)); } MethExecutorResult result = null; int retryCount = 120; do { try { - result = this.client.executeMethodOnClass(c.getName(), methodName, args); + result = this.client.executeMethodOnClass(targetClass.getName(), methodName, args); break; // out of while loop } catch( RemoteException e ) { boolean isWindows = false; @@ -157,7 +157,7 @@ public class VM implements java.io.Serializable { } } } else { - throw new RMIException(this, c.getName(), methodName, e ); + throw new RMIException(this, targetClass.getName(), methodName, e ); } } } while (true); @@ -167,7 +167,7 @@ public class VM implements java.io.Serializable { } else { Throwable thr = result.getException(); - throw new RMIException(this, c.getName(), methodName, thr, + throw new RMIException(this, targetClass.getName(), methodName, thr, result.getStackTrace()); } } @@ -177,7 +177,7 @@ public class VM implements java.io.Serializable { * <code>void</code> return type in this VM. If the return type of * the method is <code>void</code>, <code>null</code> is returned. * - * @param c + * @param targetClass * The class on which to invoke the method * @param methodName * The name of the method to invoke @@ -185,13 +185,13 @@ public class VM implements java.io.Serializable { * Arguments passed to the method call (must be {@link * java.io.Serializable}). */ - public AsyncInvocation invokeAsync(final Class c, + public AsyncInvocation invokeAsync(final Class targetClass, final String methodName, final Object[] args) { AsyncInvocation ai = - new AsyncInvocation(c, methodName, new Runnable() { + new AsyncInvocation(targetClass, methodName, new Runnable() { public void run() { - final Object o = invoke(c, methodName, args); + final Object o = invoke(targetClass, methodName, args); AsyncInvocation.setReturnValue(o); } }); @@ -282,12 +282,14 @@ public class VM implements java.io.Serializable { } /** - * Invokes the <code>run</code method of a {@link Runnable} in this + * Invokes the <code>run</code> method of a {@link Runnable} in this * VM. If the invocation throws AssertionFailedError, and repeatTimeoutMs * is >0, the <code>run</code> method is invoked repeatedly until it * either succeeds, or repeatTimeoutMs has passed. The AssertionFailedError * is thrown back to the sender of this method if <code>run</code> has not * completed successfully before repeatTimeoutMs has passed. + * + * @deprecated Please use {@link com.jayway.awaitility.Awaitility} with {@link #invoke(SerializableCallableIF)} instead. */ public void invokeRepeatingIfNecessary(RepeatableRunnable o, long repeatTimeoutMs) { invoke(o, "runRepeatingIfNecessary", new Object[] {new Long(repeatTimeoutMs)}); @@ -374,15 +376,15 @@ public class VM implements java.io.Serializable { /** * Invokes the <code>main</code> method of a given class * - * @param c + * @param targetClass * The class on which to invoke the <code>main</code> method * @param args * The "command line" arguments to pass to the * <code>main</code> method */ - public void invokeMain(Class c, String[] args) { + public void invokeMain(Class targetClass, String[] args) { Object[] stupid = new Object[] { args }; - invoke(c, "main", stupid); + invoke(targetClass, "main", stupid); } /** http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java index 55791e9..3e218df 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java @@ -17,101 +17,58 @@ package com.gemstone.gemfire.test.dunit; import static org.junit.Assert.fail; +import static com.gemstone.gemfire.test.dunit.Jitter.*; import org.apache.logging.log4j.Logger; -import com.gemstone.gemfire.LogWriter; import com.gemstone.gemfire.internal.cache.LocalRegion; import com.gemstone.gemfire.internal.logging.LogService; -import com.jayway.awaitility.Awaitility; +/** + * <code>Wait</code> provides static utility methods to wait for some + * asynchronous action with intermittent polling. + * + * These methods can be used directly: <code>Wait.waitForCriterion(...)</code>, + * however, they are intended to be referenced through static import: + * + * <pre> + * import static com.gemstone.gemfire.test.dunit.Wait.*; + * ... + * waitForCriterion(...); + * </pre> + * + * Extracted from DistributedTestCase. + * + * @deprecated Use {@link com.jayway.awaitility.Awaitility} instead. + */ +@Deprecated public class Wait { + private static final Logger logger = LogService.getLogger(); - /** - * Wait until given criterion is met - * @param ev criterion to wait on - * @param ms total time to wait, in milliseconds - * @param interval pause interval between waits - * @param throwOnTimeout if false, don't generate an error - * @deprecated Use {@link Awaitility} instead. - */ - @Deprecated - static public void waitForCriterion(WaitCriterion ev, long ms, - long interval, boolean throwOnTimeout) { - long waitThisTime = Jitter.jitterInterval(interval); - final long tilt = System.currentTimeMillis() + ms; - for (;;) { - // getLogWriter().info("Testing to see if event has occurred: " + ev.description()); - if (ev.done()) { - return; // success - } - if (ev instanceof StoppableWaitCriterion) { - StoppableWaitCriterion ev2 = (StoppableWaitCriterion)ev; - if (ev2.stopWaiting()) { - if (throwOnTimeout) { - fail("stopWaiting returned true: " + ev.description()); - } - return; - } - } + protected Wait() { + } - // Calculate time left - long timeLeft = tilt - System.currentTimeMillis(); - if (timeLeft <= 0) { - if (!throwOnTimeout) { - return; // not an error, but we're done - } - fail("Event never occurred after " + ms + " ms: " + ev.description()); - } - - if (waitThisTime > timeLeft) { - waitThisTime = timeLeft; - } - - // Wait a little bit - Thread.yield(); - try { - // getLogWriter().info("waiting " + waitThisTime + "ms for " + ev.description()); - Thread.sleep(waitThisTime); - } catch (InterruptedException e) { - fail("interrupted"); - } - } - } - /** - * Blocks until the clock used for expiration moves forward. - * @param baseTime the timestamp that the clock must exceed - * @return the last time stamp observed + * Pause for a default interval (250 milliseconds). + * + * @deprecated Please use {@link com.jayway.awaitility.Awaitility} instead. */ - public static final long waitForExpiryClockToChange(LocalRegion lr, final long baseTime) { - long nowTime; - do { - Thread.yield(); - nowTime = lr.cacheTimeMillis(); - } while ((nowTime - baseTime) <= 0L); - return nowTime; + public static void pause() { + pause(250); } /** - * Blocks until the clock used for expiration moves forward. - * @return the last time stamp observed + * Pause for the specified milliseconds. Make sure system clock has advanced + * by the specified number of millis before returning. + * + * @deprecated Please use {@link com.jayway.awaitility.Awaitility} instead. */ - public static final long waitForExpiryClockToChange(LocalRegion lr) { - return waitForExpiryClockToChange(lr, lr.cacheTimeMillis()); - } - - /** pause for specified ms interval - * Make sure system clock has advanced by the specified number of millis before - * returning. - */ - public static final void pause(int ms) { - LogWriter log = com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter(); - if (ms >= 1000 || log.fineEnabled()) { // check for fine but log at info - com.gemstone.gemfire.test.dunit.LogWriterSupport.getLogWriter().info("Pausing for " + ms + " ms..."/*, new Exception()*/); + public static final void pause(final int milliseconds) { + if (milliseconds >= 1000 || logger.isDebugEnabled()) { // check for debug but log at info + logger.info("Pausing for {} ms...", milliseconds); } - final long target = System.currentTimeMillis() + ms; + final long target = System.currentTimeMillis() + milliseconds; try { for (;;) { long msLeft = target - System.currentTimeMillis(); @@ -125,23 +82,102 @@ public class Wait { Assert.fail("interrupted", e); } } + + /** + * Wait until given criterion is met + * + * @param waitCriterion criterion to wait on + * @param timeoutMillis total time to wait, in milliseconds + * @param pollingInterval pause interval between waits + * @param throwOnTimeout if false, don't generate an error + * @deprecated Please use {@link com.jayway.awaitility.Awaitility} instead. + */ + @Deprecated + public static void waitForCriterion(final WaitCriterion waitCriterion, final long timeoutMillis, final long pollingInterval, final boolean throwOnTimeout) { + long waitThisTime = jitterInterval(pollingInterval); + final long tilt = System.currentTimeMillis() + timeoutMillis; + for (;;) { + if (waitCriterion.done()) { + return; // success + } + if (waitCriterion instanceof StoppableWaitCriterion) { + StoppableWaitCriterion ev2 = (StoppableWaitCriterion)waitCriterion; + if (ev2.stopWaiting()) { + if (throwOnTimeout) { + fail("stopWaiting returned true: " + waitCriterion.description()); + } + return; + } + } + + // Calculate time left + long timeLeft = tilt - System.currentTimeMillis(); + if (timeLeft <= 0) { + if (!throwOnTimeout) { + return; // not an error, but we're done + } + fail("Event never occurred after " + timeoutMillis + " ms: " + waitCriterion.description()); + } + + if (waitThisTime > timeLeft) { + waitThisTime = timeLeft; + } + + // Wait a little bit + Thread.yield(); + try { + Thread.sleep(waitThisTime); + } catch (InterruptedException e) { + fail("interrupted"); + } + } + } + + /** + * Blocks until the clock used for expiration moves forward. + * + * @param cacheTimeMillisSource region that provides cacheTimeMillis + * @return the last time stamp observed + * @deprecated Please use {@link com.jayway.awaitility.Awaitility} instead. + */ + public static final long waitForExpiryClockToChange(final LocalRegion cacheTimeMillisSource) { + return waitForExpiryClockToChange(cacheTimeMillisSource, cacheTimeMillisSource.cacheTimeMillis()); + } + + /** + * Blocks until the clock used for expiration moves forward. + * + * @param cacheTimeMillisSource region that provides cacheTimeMillis + * @param baseTime the timestamp that the clock must exceed + * @return the last time stamp observed + * @deprecated Please use {@link com.jayway.awaitility.Awaitility} instead. + */ + public static final long waitForExpiryClockToChange(final LocalRegion cacheTimeMillisSource, final long baseTime) { + long nowTime; + do { + Thread.yield(); + nowTime = cacheTimeMillisSource.cacheTimeMillis(); + } while ((nowTime - baseTime) <= 0L); + return nowTime; + } /** - * Wait on a mutex. This is done in a loop in order to address the + * Wait on a mutex. This is done in a loop in order to address the * "spurious wakeup" "feature" in Java. - * @param ev condition to test + * + * @param waitCriterion condition to test * @param mutex object to lock and wait on - * @param ms total amount of time to wait - * @param interval interval to pause for the wait + * @param milliseconds total amount of time to wait + * @param pollingInterval interval to pause for the wait * @param throwOnTimeout if false, no error is thrown. + * @deprecated Please use {@link com.jayway.awaitility.Awaitility} instead. */ - static public void waitMutex(WaitCriterion ev, Object mutex, long ms, - long interval, boolean throwOnTimeout) { - final long tilt = System.currentTimeMillis() + ms; - long waitThisTime = Jitter.jitterInterval(interval); + public static void waitMutex(final WaitCriterion waitCriterion, final Object mutex, final long milliseconds, final long pollingInterval, final boolean throwOnTimeout) { + final long tilt = System.currentTimeMillis() + milliseconds; + long waitThisTime = jitterInterval(pollingInterval); synchronized (mutex) { for (;;) { - if (ev.done()) { + if (waitCriterion.done()) { break; } @@ -150,7 +186,7 @@ public class Wait { if (!throwOnTimeout) { return; // not an error, but we're done } - fail("Event never occurred after " + ms + " ms: " + ev.description()); + fail("Event never occurred after " + milliseconds + " ms: " + waitCriterion.description()); } if (waitThisTime > timeLeft) { @@ -165,38 +201,4 @@ public class Wait { } // for } // synchronized } - - /** pause for a default interval */ - public static void pause() { - pause(250); - } - - /** - * Use of this function indicates a place in the tests tree where t - * he use of Thread.sleep() is - * highly questionable. - * <p> - * Some places in the system, especially those that test expirations and other - * timeouts, have a very good reason to call {@link Thread#sleep(long)}. The - * <em>other</em> places are marked by the use of this method. - * - * @param ms - */ - static public final void staticPause(int ms) { - // getLogWriter().info("FIXME: Pausing for " + ms + " ms..."/*, new Exception()*/); - final long target = System.currentTimeMillis() + ms; - try { - for (;;) { - long msLeft = target - System.currentTimeMillis(); - if (msLeft <= 0) { - break; - } - Thread.sleep(msLeft); - } - } - catch (InterruptedException e) { - Assert.fail("interrupted", e); - } - - } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/WaitCriterion.java ---------------------------------------------------------------------- diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/WaitCriterion.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/WaitCriterion.java index f835268..7575f8c 100755 --- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/WaitCriterion.java +++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/WaitCriterion.java @@ -16,7 +16,18 @@ */ package com.gemstone.gemfire.test.dunit; +/** + * Defines an asynchronous criterion to wait for by invoking a method in + * {@link Wait}. + * + * Extracted from DistributedTestCase. + * + * @deprecated Use {@link com.jayway.awaitility.Awaitility} instead. + */ public interface WaitCriterion { + public boolean done(); + public String description(); -} \ No newline at end of file + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataDUnitTest.java b/gemfire-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataDUnitTest.java index fbad416..5850e6f 100644 --- a/gemfire-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataDUnitTest.java +++ b/gemfire-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataDUnitTest.java @@ -43,10 +43,10 @@ import com.gemstone.gemfire.test.dunit.AsyncInvocation; import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.IgnoredException; import com.gemstone.gemfire.test.dunit.Invoke; -import com.gemstone.gemfire.test.dunit.LogWriterSupport; -import com.gemstone.gemfire.test.dunit.NetworkSupport; +import com.gemstone.gemfire.test.dunit.LogWriterUtils; +import com.gemstone.gemfire.test.dunit.NetworkUtils; import com.gemstone.gemfire.test.dunit.SerializableRunnable; -import com.gemstone.gemfire.test.dunit.Threads; +import com.gemstone.gemfire.test.dunit.ThreadUtils; import com.gemstone.gemfire.test.dunit.VM; import com.gemstone.gemfire.test.dunit.Wait; @@ -96,7 +96,7 @@ public class CqDataDUnitTest extends CacheTestCase { final int port = server.invokeInt(CqQueryDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server.getHost()); + final String host0 = NetworkUtils.getServerHostName(server.getHost()); // Create client. cqDUnitTest.createClient(client, port, host0); @@ -142,7 +142,7 @@ public class CqDataDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server1); final int port1 = server1.invokeInt(CqQueryDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server1.getHost()); + final String host0 = NetworkUtils.getServerHostName(server1.getHost()); final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2); @@ -259,7 +259,7 @@ public class CqDataDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server, 0, true); final int port = server.invokeInt(CqQueryDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server.getHost()); + final String host0 = NetworkUtils.getServerHostName(server.getHost()); // Create client. cqDUnitTest.createClient(client, port, host0); @@ -334,7 +334,7 @@ public class CqDataDUnitTest extends CacheTestCase { /* Create Server and Client */ cqDUnitTest.createServer(server); final int port = server.invokeInt(CqQueryDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server.getHost()); + final String host0 = NetworkUtils.getServerHostName(server.getHost()); cqDUnitTest.createClient(client1, port, host0); cqDUnitTest.createClient(client2, port, host0); @@ -403,7 +403,7 @@ public class CqDataDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server2, 0, false, MirrorType.KEYS); final int port1 = server1.invokeInt(CqQueryDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server1.getHost()); + final String host0 = NetworkUtils.getServerHostName(server1.getHost()); cqDUnitTest.createClient(client, port1, host0); @@ -451,7 +451,7 @@ public class CqDataDUnitTest extends CacheTestCase { final int evictionThreshold = 1; server1.invoke(new CacheSerializableRunnable("Create Cache Server") { public void run2() throws CacheException { - LogWriterSupport.getLogWriter().info("### Create Cache Server. ###"); + LogWriterUtils.getLogWriter().info("### Create Cache Server. ###"); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setDataPolicy(DataPolicy.REPLICATE); @@ -464,7 +464,7 @@ public class CqDataDUnitTest extends CacheTestCase { for (int i = 0; i < cqDUnitTest.regions.length; i++) { Region region = createRegion(cqDUnitTest.regions[i], factory.createRegionAttributes()); // Set CacheListener. - region.getAttributesMutator().setCacheListener(new CertifiableTestCacheListener(LogWriterSupport.getLogWriter())); + region.getAttributesMutator().setCacheListener(new CertifiableTestCacheListener(LogWriterUtils.getLogWriter())); } Wait.pause(2000); @@ -479,7 +479,7 @@ public class CqDataDUnitTest extends CacheTestCase { }); final int port1 = server1.invokeInt(CqQueryDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server1.getHost()); + final String host0 = NetworkUtils.getServerHostName(server1.getHost()); cqDUnitTest.createClient(client, port1, host0); @@ -521,7 +521,7 @@ public class CqDataDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server1, 0, false, MirrorType.KEYS_VALUES); final int port1 = server1.invokeInt(CqQueryDUnitTest.class, "getCacheServerPort"); - final String serverHost = NetworkSupport.getServerHostName(server1.getHost()); + final String serverHost = NetworkUtils.getServerHostName(server1.getHost()); final String[] regions = cqDUnitTest.regions; final int[] serverPorts = new int[] {port1}; @@ -530,7 +530,7 @@ public class CqDataDUnitTest extends CacheTestCase { SerializableRunnable createClientWithPool = new CacheSerializableRunnable("createClientWithPool") { public void run2() throws CacheException { - LogWriterSupport.getLogWriter().info("### Create Client. ###"); + LogWriterUtils.getLogWriter().info("### Create Client. ###"); // Initialize CQ Service. try { getCache().getQueryService(); @@ -544,7 +544,7 @@ public class CqDataDUnitTest extends CacheTestCase { ClientServerTestCase.configureConnectionPool(regionFactory, serverHost, serverPorts[0], -1, false, -1, -1, null); for (int i=0; i < regions.length; i++) { createRegion(regions[i], regionFactory.create() ); - LogWriterSupport.getLogWriter().info("### Successfully Created Region on Client :" + regions[i]); + LogWriterUtils.getLogWriter().info("### Successfully Created Region on Client :" + regions[i]); } } }; @@ -579,7 +579,7 @@ public class CqDataDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server1, 0, false, MirrorType.KEYS_VALUES); final int port1 = server1.invokeInt(CqQueryDUnitTest.class, "getCacheServerPort"); - final String serverHost = NetworkSupport.getServerHostName(server1.getHost()); + final String serverHost = NetworkUtils.getServerHostName(server1.getHost()); final String[] regions = cqDUnitTest.regions; final int[] serverPorts = new int[] {port1}; @@ -588,7 +588,7 @@ public class CqDataDUnitTest extends CacheTestCase { SerializableRunnable createClientWithPool = new CacheSerializableRunnable("createClientWithPool") { public void run2() throws CacheException { - LogWriterSupport.getLogWriter().info("### Create Client. ###"); + LogWriterUtils.getLogWriter().info("### Create Client. ###"); //Region region1 = null; // Initialize CQ Service. try { @@ -604,7 +604,7 @@ public class CqDataDUnitTest extends CacheTestCase { for (int i=0; i < regions.length; i++) { createRegion(regions[i], regionFactory.createRegionAttributes()); - LogWriterSupport.getLogWriter().info("### Successfully Created Region on Client :" + regions[i]); + LogWriterUtils.getLogWriter().info("### Successfully Created Region on Client :" + regions[i]); } } }; @@ -634,7 +634,7 @@ public class CqDataDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server1, 0, false, MirrorType.KEYS_VALUES); final int port1 = server1.invokeInt(CqQueryDUnitTest.class, "getCacheServerPort"); - final String serverHost = NetworkSupport.getServerHostName(server1.getHost()); + final String serverHost = NetworkUtils.getServerHostName(server1.getHost()); final String[] regions = cqDUnitTest.regions; final int[] serverPorts = new int[] {port1}; @@ -643,7 +643,7 @@ public class CqDataDUnitTest extends CacheTestCase { SerializableRunnable createClientWithConnectionPool = new CacheSerializableRunnable("createClientWithConnectionPool") { public void run2() throws CacheException { - LogWriterSupport.getLogWriter().info("### Create Client. ###"); + LogWriterUtils.getLogWriter().info("### Create Client. ###"); //Region region1 = null; // Initialize CQ Service. try { @@ -658,7 +658,7 @@ public class CqDataDUnitTest extends CacheTestCase { ClientServerTestCase.configureConnectionPool(regionFactory, serverHost, serverPorts[0], -1, true, -1, -1, null); for (int i=0; i < regions.length; i++) { createRegion(regions[i], regionFactory.createRegionAttributes()); - LogWriterSupport.getLogWriter().info("### Successfully Created Region on Client :" + regions[i]); + LogWriterUtils.getLogWriter().info("### Successfully Created Region on Client :" + regions[i]); } } }; @@ -688,7 +688,7 @@ public class CqDataDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server1, 0, false, MirrorType.KEYS_VALUES); final int port1 = server1.invokeInt(CqQueryDUnitTest.class, "getCacheServerPort"); - final String serverHost = NetworkSupport.getServerHostName(server1.getHost()); + final String serverHost = NetworkUtils.getServerHostName(server1.getHost()); final String[] regions = cqDUnitTest.regions; final int[] serverPorts = new int[] {port1}; @@ -697,7 +697,7 @@ public class CqDataDUnitTest extends CacheTestCase { SerializableRunnable createClientWithPool = new CacheSerializableRunnable("createClientWithPool") { public void run2() throws CacheException { - LogWriterSupport.getLogWriter().info("### Create Client. ###"); + LogWriterUtils.getLogWriter().info("### Create Client. ###"); //Region region1 = null; // Initialize CQ Service. try { @@ -714,7 +714,7 @@ public class CqDataDUnitTest extends CacheTestCase { for (int i=0; i < regions.length; i++) { createRegion(regions[i], regionFactory.createRegionAttributes()); - LogWriterSupport.getLogWriter().info("### Successfully Created Region on Client :" + regions[i]); + LogWriterUtils.getLogWriter().info("### Successfully Created Region on Client :" + regions[i]); } } }; @@ -753,7 +753,7 @@ public class CqDataDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server); final int port = server.invokeInt(CqQueryDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server.getHost()); + final String host0 = NetworkUtils.getServerHostName(server.getHost()); cqDUnitTest.createClient(client, port, host0); @@ -768,7 +768,7 @@ public class CqDataDUnitTest extends CacheTestCase { // Test for Event on Region Clear. server.invoke(new CacheSerializableRunnable("testRegionEvents"){ public void run2()throws CacheException { - LogWriterSupport.getLogWriter().info("### Clearing the region on the server ###"); + LogWriterUtils.getLogWriter().info("### Clearing the region on the server ###"); Region region = getCache().getRegion("/root/" + cqDUnitTest.regions[0]); for (int i = 1; i <=5; i++) { region.put(CqQueryDUnitTest.KEY+i, new Portfolio(i)); @@ -782,7 +782,7 @@ public class CqDataDUnitTest extends CacheTestCase { // Test for Event on Region invalidate. server.invoke(new CacheSerializableRunnable("testRegionEvents"){ public void run2()throws CacheException { - LogWriterSupport.getLogWriter().info("### Invalidate the region on the server ###"); + LogWriterUtils.getLogWriter().info("### Invalidate the region on the server ###"); Region region = getCache().getRegion("/root/" + cqDUnitTest.regions[0]); for (int i = 1; i <=5; i++) { region.put(CqQueryDUnitTest.KEY+i, new Portfolio(i)); @@ -796,7 +796,7 @@ public class CqDataDUnitTest extends CacheTestCase { // Test for Event on Region destroy. server.invoke(new CacheSerializableRunnable("testRegionEvents"){ public void run2()throws CacheException { - LogWriterSupport.getLogWriter().info("### Destroying the region on the server ###"); + LogWriterUtils.getLogWriter().info("### Destroying the region on the server ###"); Region region = getCache().getRegion("/root/" + cqDUnitTest.regions[1]); for (int i = 1; i <=5; i++) { region.put(CqQueryDUnitTest.KEY+i, new Portfolio(i)); @@ -834,7 +834,7 @@ public class CqDataDUnitTest extends CacheTestCase { final String cqName = "testEventsDuringQueryExecution_0"; cqDUnitTest.createServer(server); final int port = server.invokeInt(CqQueryDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server.getHost()); + final String host0 = NetworkUtils.getServerHostName(server.getHost()); // Initialize Client. cqDUnitTest.createClient(client, port, host0); @@ -943,7 +943,7 @@ public class CqDataDUnitTest extends CacheTestCase { }); //wait for 60 seconds for test to complete - Threads.join(processCqs, 60 * 1000, LogWriterSupport.getLogWriter()); + ThreadUtils.join(processCqs, 60 * 1000); // Close. cqDUnitTest.closeClient(client); @@ -974,7 +974,7 @@ public class CqDataDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server); final int port = server.invokeInt(CqQueryDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server.getHost()); + final String host0 = NetworkUtils.getServerHostName(server.getHost()); // Initialize Client. cqDUnitTest.createClient(client, port, host0); @@ -1119,7 +1119,7 @@ public class CqDataDUnitTest extends CacheTestCase { }); //wait for 60 seconds for test to complete - Threads.join(processCqs, 60 * 1000, LogWriterSupport.getLogWriter()); + ThreadUtils.join(processCqs, 60 * 1000); // Close. cqDUnitTest.closeClient(client); cqDUnitTest.closeServer(server); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c05f6798/gemfire-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolDUnitTest.java ---------------------------------------------------------------------- diff --git a/gemfire-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolDUnitTest.java b/gemfire-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolDUnitTest.java index 197467e..82d6279 100644 --- a/gemfire-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolDUnitTest.java +++ b/gemfire-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqDataUsingPoolDUnitTest.java @@ -62,8 +62,8 @@ import com.gemstone.gemfire.test.dunit.AsyncInvocation; import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.IgnoredException; import com.gemstone.gemfire.test.dunit.Invoke; -import com.gemstone.gemfire.test.dunit.LogWriterSupport; -import com.gemstone.gemfire.test.dunit.NetworkSupport; +import com.gemstone.gemfire.test.dunit.LogWriterUtils; +import com.gemstone.gemfire.test.dunit.NetworkUtils; import com.gemstone.gemfire.test.dunit.SerializableRunnable; import com.gemstone.gemfire.test.dunit.VM; import com.gemstone.gemfire.test.dunit.Wait; @@ -114,7 +114,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { final int port = server.invokeInt(CqQueryUsingPoolDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server.getHost()); + final String host0 = NetworkUtils.getServerHostName(server.getHost()); String poolName = "testClientWithFeederAndCQ"; cqDUnitTest.createPool(client, poolName, host0, port); @@ -161,7 +161,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server1); final int port1 = server1.invokeInt(CqQueryUsingPoolDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server1.getHost()); + final String host0 = NetworkUtils.getServerHostName(server1.getHost()); final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2); @@ -280,7 +280,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server, 0, true); final int port = server.invokeInt(CqQueryUsingPoolDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server.getHost()); + final String host0 = NetworkUtils.getServerHostName(server.getHost()); String poolName = "testCQWithDestroysAndInvalidates"; cqDUnitTest.createPool(client, poolName, host0, port); @@ -359,7 +359,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { /* Create Server and Client */ cqDUnitTest.createServer(server); final int port = server.invokeInt(CqQueryUsingPoolDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server.getHost()); + final String host0 = NetworkUtils.getServerHostName(server.getHost()); String poolName1 = "testCQWithMultipleClients1"; String poolName2 = "testCQWithMultipleClients2"; @@ -435,7 +435,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server2, 0, false, MirrorType.KEYS); final int port1 = server1.invokeInt(CqQueryUsingPoolDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server1.getHost()); + final String host0 = NetworkUtils.getServerHostName(server1.getHost()); String poolName = "testCQWithLoad"; cqDUnitTest.createPool(client, poolName, host0, port1); @@ -490,7 +490,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { final int evictionThreshold = 5; server1.invoke(new CacheSerializableRunnable("Create Cache Server") { public void run2() throws CacheException { - LogWriterSupport.getLogWriter().info("### Create Cache Server. ###"); + LogWriterUtils.getLogWriter().info("### Create Cache Server. ###"); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setMirrorType(MirrorType.NONE); @@ -500,7 +500,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { for (int i = 0; i < cqDUnitTest.regions.length; i++) { Region region = createRegion(cqDUnitTest.regions[i], factory.createRegionAttributes()); // Set CacheListener. - region.getAttributesMutator().setCacheListener(new CertifiableTestCacheListener(LogWriterSupport.getLogWriter())); + region.getAttributesMutator().setCacheListener(new CertifiableTestCacheListener(LogWriterUtils.getLogWriter())); } Wait.pause(2000); @@ -517,7 +517,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server2, 0, false, MirrorType.NONE); final int port1 = server1.invokeInt(CqQueryUsingPoolDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server1.getHost()); + final String host0 = NetworkUtils.getServerHostName(server1.getHost()); String poolName = "testCQWithEviction"; cqDUnitTest.createPool(client, poolName, host0, port1); @@ -598,7 +598,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server1, 0, false, MirrorType.KEYS_VALUES); final int port1 = server1.invokeInt(CqQueryUsingPoolDUnitTest.class, "getCacheServerPort"); - final String serverHost = NetworkSupport.getServerHostName(server1.getHost()); + final String serverHost = NetworkUtils.getServerHostName(server1.getHost()); // final String[] regions = cqDUnitTest.regions; // final int[] serverPorts = new int[] {port1}; @@ -648,7 +648,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server); final int port = server.invokeInt(CqQueryUsingPoolDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server.getHost()); + final String host0 = NetworkUtils.getServerHostName(server.getHost()); String poolName = "testRegionEvents"; cqDUnitTest.createPool(client, poolName, host0, port); @@ -666,7 +666,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { // Test for Event on Region Clear. server.invoke(new CacheSerializableRunnable("testRegionEvents"){ public void run2()throws CacheException { - LogWriterSupport.getLogWriter().info("### Clearing the region on the server ###"); + LogWriterUtils.getLogWriter().info("### Clearing the region on the server ###"); Region region = getCache().getRegion("/root/" + cqDUnitTest.regions[0]); for (int i = 1; i <=5; i++) { region.put(CqQueryUsingPoolDUnitTest.KEY+i, new Portfolio(i)); @@ -680,7 +680,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { // Test for Event on Region invalidate. server.invoke(new CacheSerializableRunnable("testRegionEvents"){ public void run2()throws CacheException { - LogWriterSupport.getLogWriter().info("### Invalidate the region on the server ###"); + LogWriterUtils.getLogWriter().info("### Invalidate the region on the server ###"); Region region = getCache().getRegion("/root/" + cqDUnitTest.regions[0]); for (int i = 1; i <=5; i++) { region.put(CqQueryUsingPoolDUnitTest.KEY+i, new Portfolio(i)); @@ -694,7 +694,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { // Test for Event on Region destroy. server.invoke(new CacheSerializableRunnable("testRegionEvents"){ public void run2()throws CacheException { - LogWriterSupport.getLogWriter().info("### Destroying the region on the server ###"); + LogWriterUtils.getLogWriter().info("### Destroying the region on the server ###"); Region region = getCache().getRegion("/root/" + cqDUnitTest.regions[1]); for (int i = 1; i <=5; i++) { region.put(CqQueryUsingPoolDUnitTest.KEY+i, new Portfolio(i)); @@ -732,7 +732,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { cqDUnitTest.createServer(server); final int port = server.invokeInt(CqQueryUsingPoolDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server.getHost()); + final String host0 = NetworkUtils.getServerHostName(server.getHost()); String poolName = "testEventsDuringQueryExecution"; cqDUnitTest.createPool(client, poolName, host0, port); @@ -875,11 +875,11 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { // Start a client client.invoke(CacheServerTestUtil.class, "createCacheClient", - new Object[] {getClientPool(NetworkSupport.getServerHostName(client.getHost()), server1Port), regionName}); + new Object[] {getClientPool(NetworkUtils.getServerHostName(client.getHost()), server1Port), regionName}); // Start a pub client client2.invoke(CacheServerTestUtil.class, "createCacheClient", - new Object[] {getClientPool(NetworkSupport.getServerHostName(client2.getHost()), server1Port), regionName}); + new Object[] {getClientPool(NetworkUtils.getServerHostName(client2.getHost()), server1Port), regionName}); //client has thread that invokes new and remove cq over and over client.invokeAsync(new CacheSerializableRunnable("Register cq") { @@ -944,7 +944,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { /* Create Server and Client */ cqDUnitTest.createServer(server); final int port = server.invokeInt(CqQueryUsingPoolDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server.getHost()); + final String host0 = NetworkUtils.getServerHostName(server.getHost()); final String poolName1 = "pool1"; final String poolName2 = "pool2"; @@ -1083,7 +1083,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { /* Create Server and Client */ cqDUnitTest.createServer(server); final int port = server.invokeInt(CqQueryUsingPoolDUnitTest.class, "getCacheServerPort"); - final String host0 = NetworkSupport.getServerHostName(server.getHost()); + final String host0 = NetworkUtils.getServerHostName(server.getHost()); final String poolName1 = "pool1"; @@ -1131,11 +1131,11 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { // Start client 1 client1.invoke(CacheServerTestUtil.class, "createClientCache", - new Object[] {getClientPool(NetworkSupport.getServerHostName(client1.getHost()), server1Port), regionName}); + new Object[] {getClientPool(NetworkUtils.getServerHostName(client1.getHost()), server1Port), regionName}); // Start client 2 client2.invoke(CacheServerTestUtil.class, "createClientCache", - new Object[] {getClientPool(NetworkSupport.getServerHostName(client2.getHost()), server1Port), regionName}); + new Object[] {getClientPool(NetworkUtils.getServerHostName(client2.getHost()), server1Port), regionName}); createClient1CqsAndDurableCqs(client1, regionName); createClient2CqsAndDurableCqs(client2, regionName); @@ -1193,11 +1193,11 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { // Start client 1 client1.invoke(CacheServerTestUtil.class, "createClientCache", - new Object[] {getClientPool(NetworkSupport.getServerHostName(client1.getHost()), server1Port), regionName, getDurableClientProperties("client1_dc", timeout)}); + new Object[] {getClientPool(NetworkUtils.getServerHostName(client1.getHost()), server1Port), regionName, getDurableClientProperties("client1_dc", timeout)}); // Start client 2 client2.invoke(CacheServerTestUtil.class, "createClientCache", - new Object[] {getClientPool(NetworkSupport.getServerHostName(client2.getHost()), server1Port), regionName, getDurableClientProperties("client2_dc", timeout)}); + new Object[] {getClientPool(NetworkUtils.getServerHostName(client2.getHost()), server1Port), regionName, getDurableClientProperties("client2_dc", timeout)}); createClient1CqsAndDurableCqs(client1, regionName); createClient2CqsAndDurableCqs(client2, regionName); @@ -1258,11 +1258,11 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { // Start client 1 client1.invoke(CacheServerTestUtil.class, "createClientCache", - new Object[] {getClientPool(NetworkSupport.getServerHostName(client1.getHost()), server1Port), regionName, getDurableClientProperties("client1_dc", timeout)}); + new Object[] {getClientPool(NetworkUtils.getServerHostName(client1.getHost()), server1Port), regionName, getDurableClientProperties("client1_dc", timeout)}); // Start client 2 client2.invoke(CacheServerTestUtil.class, "createClientCache", - new Object[] {getClientPool(NetworkSupport.getServerHostName(client2.getHost()), server1Port), regionName, getDurableClientProperties("client2_dc", timeout)}); + new Object[] {getClientPool(NetworkUtils.getServerHostName(client2.getHost()), server1Port), regionName, getDurableClientProperties("client2_dc", timeout)}); //create the test cqs createClient1CqsAndDurableCqs(client1, regionName); @@ -1463,7 +1463,7 @@ public class CqDataUsingPoolDUnitTest extends CacheTestCase { }); client.invoke(CacheServerTestUtil.class, "createClientCache", - new Object[] {getClientPool(NetworkSupport.getServerHostName(client.getHost()), serverPort), regionName, getDurableClientProperties(dcName, durableClientTimeout)}); + new Object[] {getClientPool(NetworkUtils.getServerHostName(client.getHost()), serverPort), regionName, getDurableClientProperties(dcName, durableClientTimeout)}); }
