Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 92771200AC8 for ; Tue, 7 Jun 2016 21:06:43 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 90FB5160A36; Tue, 7 Jun 2016 19:06:43 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 44A88160968 for ; Tue, 7 Jun 2016 21:06:41 +0200 (CEST) Received: (qmail 28020 invoked by uid 500); 7 Jun 2016 19:06:40 -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 28004 invoked by uid 99); 7 Jun 2016 19:06:40 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Jun 2016 19:06:40 +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 EC9BA1A1051 for ; Tue, 7 Jun 2016 19:06:39 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id lBTNu8wet_LW for ; Tue, 7 Jun 2016 19:06:24 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id 3930C5FD39 for ; Tue, 7 Jun 2016 19:06:21 +0000 (UTC) Received: (qmail 21269 invoked by uid 99); 7 Jun 2016 19:06:21 -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; Tue, 07 Jun 2016 19:06:21 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1077ADFC61; Tue, 7 Jun 2016 19:06:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hiteshkhamesra@apache.org To: commits@geode.incubator.apache.org Date: Tue, 07 Jun 2016 19:07:00 -0000 Message-Id: <27dd4c1edef9470fba497ba46761f20b@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [41/55] [abbrv] incubator-geode git commit: GEODE-308: Separate hydra from dunit and junit tests in gemfire-core archived-at: Tue, 07 Jun 2016 19:06:43 -0000 GEODE-308: Separate hydra from dunit and junit tests in gemfire-core Removed hydra classes. Merge branch 'feature/GEODE-308' of https://github.com/kjduling/incubator-geode into pull Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/fb719d0a Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/fb719d0a Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/fb719d0a Branch: refs/heads/feature/GEODE-1372 Commit: fb719d0a1a5d2a33045c210807b4b4b5c1d80afe Parents: 61ad7e4 Author: Kevin J. Duling Authored: Tue May 31 15:39:16 2016 -0700 Committer: Jinmei Liao Committed: Fri Jun 3 14:10:06 2016 -0700 ---------------------------------------------------------------------- .../PartitionedRegionTestUtilsDUnitTest.java | 10 +- .../gemfire/test/dunit/standalone/ChildVM.java | 28 +- geode-core/src/test/java/hydra/GsRandom.java | 311 ----------- .../test/java/hydra/HydraRuntimeException.java | 33 -- geode-core/src/test/java/hydra/Log.java | 219 -------- .../src/test/java/hydra/LogVersionHelper.java | 45 -- .../src/test/java/hydra/log/AnyLogWriter.java | 555 ------------------- .../java/hydra/log/CircularOutputStream.java | 131 ----- .../parReg/query/unittest/NewPortfolio.java | 37 +- .../src/test/java/perffmwk/Formatter.java | 14 +- .../PartitionedRegionCqQueryDUnitTest.java | 39 +- 11 files changed, 51 insertions(+), 1371 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fb719d0a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionTestUtilsDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionTestUtilsDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionTestUtilsDUnitTest.java index c0c7529..d1083ad 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionTestUtilsDUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/cache/PartitionedRegionTestUtilsDUnitTest.java @@ -17,15 +17,13 @@ package com.gemstone.gemfire.internal.cache; -import hydra.GsRandom; - import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.io.Serializable; -import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Random; import java.util.Set; import com.gemstone.gemfire.DataSerializable; @@ -88,7 +86,7 @@ public class PartitionedRegionTestUtilsDUnitTest extends vm0.invoke(new CacheSerializableRunnable("GetSomeKeys") { public void run2() throws CacheException { PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(r); - GsRandom rand = new GsRandom(123); + Random rand = new Random(123); // Assert that its empty for(int i=0; i<5; i++) { LogWriterUtils.getLogWriter().info("Invocation " + i + " of getSomeKeys"); @@ -125,7 +123,7 @@ public class PartitionedRegionTestUtilsDUnitTest extends val = (Integer) pr.get(key); assertNotNull(val); assertTrue(val.intValue() >= 0); - assertTrue(val.intValue() < MAXKEYS); + assertTrue(val.intValue() < MAXKEYS); } } catch (ClassNotFoundException cnfe) { Assert.fail("GetSomeKeys failed with ClassNotFoundException", cnfe); @@ -530,7 +528,7 @@ public class PartitionedRegionTestUtilsDUnitTest extends assertNotNull(p); assertEquals(3, p.getTotalNumberOfBuckets()); // Create one bucket - p.put(new Integer(0), "zero"); + p.put(new Integer(0), "zero"); assertEquals(1, p.getRegionAdvisor().getCreatedBucketsCount()); } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fb719d0a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ChildVM.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ChildVM.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ChildVM.java index 5301ffe..b1fe786 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ChildVM.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/standalone/ChildVM.java @@ -18,14 +18,12 @@ package com.gemstone.gemfire.test.dunit.standalone; import java.rmi.Naming; -import hydra.HydraRuntimeException; -import hydra.Log; -import org.apache.logging.log4j.Logger; - import com.gemstone.gemfire.internal.OSProcess; import com.gemstone.gemfire.internal.logging.LogService; import com.gemstone.gemfire.test.dunit.standalone.DUnitLauncher.MasterRemote; +import org.apache.logging.log4j.Logger; + /** * */ @@ -39,24 +37,19 @@ public class ChildVM { public static void stopVM() { stopMainLoop = true; } - - static { - createHydraLogWriter(); - } - + private final static Logger logger = LogService.getLogger(); - private static RemoteDUnitVM dunitVM; - + public static void main(String[] args) throws Throwable { try { - int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM).intValue(); - int vmNum = Integer.getInteger(DUnitLauncher.VM_NUM_PARAM).intValue(); + int namingPort = Integer.getInteger(DUnitLauncher.RMI_PORT_PARAM); + int vmNum = Integer.getInteger(DUnitLauncher.VM_NUM_PARAM); int pid = OSProcess.getId(); logger.info("VM" + vmNum + " is launching" + (pid > 0? " with PID " + pid : "")); MasterRemote holder = (MasterRemote) Naming.lookup("//localhost:" + namingPort + "/" + DUnitLauncher.MASTER_PARAM); DUnitLauncher.init(holder); DUnitLauncher.locatorPort = holder.getLocatorPort(); - dunitVM = new RemoteDUnitVM(); + final RemoteDUnitVM dunitVM = new RemoteDUnitVM(); Naming.rebind("//localhost:" + namingPort + "/vm" + vmNum, dunitVM); holder.signalVMReady(); //This loop is here so this VM will die even if the master is mean killed. @@ -69,11 +62,4 @@ public class ChildVM { System.exit(1); } } - - private static void createHydraLogWriter() { - try { - Log.createLogWriter("dunit-childvm", "fine"); - } catch (HydraRuntimeException ignore) { - } - } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fb719d0a/geode-core/src/test/java/hydra/GsRandom.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/hydra/GsRandom.java b/geode-core/src/test/java/hydra/GsRandom.java deleted file mode 100644 index bed02da..0000000 --- a/geode-core/src/test/java/hydra/GsRandom.java +++ /dev/null @@ -1,311 +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 hydra; - -import java.io.*; -import java.util.*; - -/** - * This is a simple extension of java.util.Random that allows for the - * generation of random numbers within ranges. It also allows for the - * generation of random strings (within ranges as well). - * @see java.lang.Math#random() - * @see java.util.Random - * @since JDK1.0 - */ - -public class GsRandom extends java.util.Random implements Serializable { - - /** - * - * ourString is a privately held instance of a String with - * with some junk characters - * - */ - - static protected String ourString = "854ku45Q985a.lsdk;,.ifpq4z58Ao45u.sdflkjsdgkjqwJKL:EIUR[p4pnm,.zxc239*h1@0*Fn/~5.+3&gwNa(.3K-c/2bd(kb1.(=wvz!/56NIwk-4/(#mDhn%kd#9jas9_n!KC0-c>3*(fbn3Fl)Fhaw.2?nz~l;1q3=Fbak1>ah1Bci23fripB319v*bnFl2Ba-cH$lfb?A)_2bgFo2_+Vv$al+b124kasbFV[2G}b@9ASFbCk2.KIhb4K"; - - /** - * Creates a new random number generator. Its seed is initialized to - * a value based on the current time. - * - * @see java.lang.System#currentTimeMillis() - * @see java.util.Random#Random() - */ - - public GsRandom() { - super(); - } - - /** - * Creates a new random number generator using a single - * long seed. - * - * @param seed the initial seed. - * @see java.util.Random#Random(long) - */ - - public GsRandom(long seed) { - super(seed); - } - - /** - * Returns the next pseudorandom, uniformly distributed boolean - * value from this random number generator's sequence - * - * @return the next pseudorandom, uniformly distributed boolean - * value from this random number generator's sequence. - */ - - public boolean nextBoolean() { - - return (this.next(1) == 0); - } - - /** - * Returns the next pseudorandom, uniformly distributed char - * value from this random number generator's sequence - * There is a hack here to prevent '}' so as to eliminate the possiblity - * of generating a sequence which would falsely get marked as a suspect - * string while we are matching the pattern {[0-9]+}. - * @return the next pseudorandom, uniformly distributed char - * value from this random number generator's sequence. - */ - - public char nextChar() { - - char c = (char) this.next(16); - if( c == '}' ) c = nextChar(); //prevent right bracket, try again - return c; - } - - /** - * Returns the next pseudorandom, uniformly distributed byte - * value from this random number generator's sequence - * - * @return the next pseudorandom, uniformly distributed byte - * value from this random number generator's sequence. - */ - - public byte nextByte() { - - return (byte) this.next(8); - } - - /** - * Returns the next pseudorandom, uniformly distributed double - * value from this random number generator's sequence within a range - * from 0 to max. - * - * @param max the maximum range (inclusive) for the pseudorandom. - * @return the next pseudorandom, uniformly distributed double - * value from this random number generator's sequence. - */ - public double nextDouble(double max) { - - return nextDouble(0.0, max); - - } - - /** - * Returns the next pseudorandom, uniformly distributed double - * value from this random number generator's sequence within a range - * from min to max. - * - * @param min the minimum range (inclusive) for the pseudorandom. - * @param max the maximum range (inclusive) for the pseudorandom. - * @return the next pseudorandom, uniformly distributed double - * value from this random number generator's sequence. - */ - - public double nextDouble(double min, double max) { - - return nextDouble() * (max - min) + min; - - // return nextDouble(max-min) + min; - } - - public short nextShort() { - return (short) this.nextChar(); - } - - /** - * Returns the next pseudorandom, uniformly distributed long - * value from this random number generator's sequence within a range - * from 0 to max. - * - * @param max the maximum range (inclusive) for the pseudorandom. - * @return the next pseudorandom, uniformly distributed long - * value from this random number generator's sequence. - */ - - public long nextLong(long max) { - - if (max == Long.MAX_VALUE) { - max--; - } - - return Math.abs(this.nextLong()) % (max+1); - } - - /** - * Returns the next pseudorandom, uniformly distributed long - * value from this random number generator's sequence within a range - * from min to max. - * - * @param min the minimum range (inclusive) for the pseudorandom. - * @param max the maximum range (inclusive) for the pseudorandom. - * @return the next pseudorandom, uniformly distributed long - * value from this random number generator's sequence. - */ - - public long nextLong(long min, long max) { - - - return nextLong(max-min) + min; - } - - /** - * Returns the next pseudorandom, uniformly distributed int - * value from this random number generator's sequence within a range - * from 0 to max (inclusive -- which is different from {@link - * Random#nextInt}). - * - * @param max the maximum range (inclusive) for the pseudorandom. - * @return the next pseudorandom, uniformly distributed int - * value from this random number generator's sequence. - */ - - public int nextInt(int max) { - - if (max == Integer.MAX_VALUE) { - max--; - } - - int theNext = this.nextInt(); - // Math.abs behaves badly when given min int, so avoid - if (theNext == Integer.MIN_VALUE) { - theNext = Integer.MIN_VALUE + 1; - } - return Math.abs(theNext) % (max+1); - } - - /** - * Returns the next pseudorandom, uniformly distributed int - * value from this random number generator's sequence within a range - * from min to max. - * If max < min, returns 0 . - * - * @param min the minimum range (inclusive) for the pseudorandom. - * @param max the maximum range (inclusive) for the pseudorandom. - * @return the next pseudorandom, uniformly distributed int - * value from this random number generator's sequence. - */ - - public int nextInt(int min, int max) { - if (max < min) - return 0; // handle max == 0 and avoid divide-by-zero exceptions - - return nextInt(max-min) + min; - } - - /** - * Returns a large, pregenerated string. - * - * @return a large, pregenerated string. - */ - - private String string() { - return ourString; - } - - /** - * - * Returns a random Date. - * - * @return A random Date. - */ - - public Date nextDate() { - return new Date(nextLong()); - } - - /** - * - * Returns a randomly-selected element of Vector vec. - * - */ - public Object randomElement(Vector vec) { - Object result; - synchronized (vec) { // fix 26810 - int index = nextInt(0, vec.size() - 1); - result = vec.elementAt(index); - } - return result; - } - - /** - * Returns a random subset of a pregenerated string. Both the - * length and offset of the string are pseudorandom values. - * - * @return a random subset of a pregenerated string. - */ - - public String randomString() { - - return this.randomString(this.string().length()); - } - - /** - * Returns a bounded random subset of a pregenerated large - * string. The length can be no longer than max. max must be no - * longer than the length of the pregenerated string. - * - * @param max the maximum length of the random string to generate. - * @return a bounded random string with a length between 0 and - * max length inclusive. - */ - - public String randomString(int max) { - - int length = this.nextInt(0, max); - byte[] bytes = new byte[length]; - this.nextBytes(bytes); - return new String(bytes); - } - - /** - * - * Like randomString(), but returns only readable characters. - * - */ - public String randomReadableString(int max) { - - int stringlen = this.string().length(); - if ( max > stringlen ) - throw new HydraRuntimeException - ( - "GsRandom.randomReadableString is limited to " + stringlen + - " characters, cannot create string of length " + max - ); - - int length = this.nextInt(0, max); - int offset = this.nextInt(0, stringlen - length); - return this.string().substring(offset, offset+length); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fb719d0a/geode-core/src/test/java/hydra/HydraRuntimeException.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/hydra/HydraRuntimeException.java b/geode-core/src/test/java/hydra/HydraRuntimeException.java deleted file mode 100644 index 668c191..0000000 --- a/geode-core/src/test/java/hydra/HydraRuntimeException.java +++ /dev/null @@ -1,33 +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 hydra; - -import com.gemstone.gemfire.*; - -public class HydraRuntimeException extends GemFireException { - - public HydraRuntimeException(String s) { - super(s); - } - public HydraRuntimeException(String s,Exception e) { - super(s,e); - } - public HydraRuntimeException(String s,Throwable t) { - super(s,t); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fb719d0a/geode-core/src/test/java/hydra/Log.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/hydra/Log.java b/geode-core/src/test/java/hydra/Log.java deleted file mode 100644 index 2c306be..0000000 --- a/geode-core/src/test/java/hydra/Log.java +++ /dev/null @@ -1,219 +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 hydra; - -import com.gemstone.gemfire.LogWriter; - -import hydra.log.AnyLogWriter; - -import java.util.Hashtable; - -/** -* -* Manages a singleton instance of {@link com.gemstone.gemfire.LogWriter} -* to do all the logging for a VM. The instance is created using -* createLogWriter and accessed using getLogWriter. -* -*/ -public class Log { - - // the singleton instance - private static AnyLogWriter logWriter; - - // the name of the singleton instance - private static String logName; - - // cache for log writers - private static Hashtable cache; - - /** - * Creates a singleton log writer that logs to stdout. - * @param name the name of the singleton log writer. - * @param levelName only messages at this level or higher will be logged. - * @return the singleton log writer. - * @throws HydraRuntimeException if log writer has already been created. - * @throws IllegalArgumentException if level is illegal. - */ - public synchronized static LogWriter createLogWriter( String name, String levelName ) { - if ( logWriter == null ) { - logWriter = new AnyLogWriter( levelName ); - } else { - throw new HydraRuntimeException( "Log writer has already been created" ); - } - logName = name; - return logWriter; - } - /** - * Creates a singleton log writer that logs to a file. - * @param name the name of the singleton log writer. - * @param filePrefix the prefix for the name of the log file. - * @param levelName only messages at this level or higher will be logged. - * @param append whether to append to an existing log file. - * @return the singleton log writer. - * @throws HydraRuntimeException if log writer has already been created. - * @throws IllegalArgumentException if level is illegal. - */ - public synchronized static LogWriter createLogWriter( String name, String filePrefix, String levelName, boolean append ) { - if ( logWriter == null ) { - logWriter = new AnyLogWriter( filePrefix, levelName, append ); - } else { - throw new HydraRuntimeException( "Log writer has already been created" ); - } - logName = name; - return logWriter; - } - /** - * Creates a singleton log writer that logs to a file in a specified directory. - * @param name the name of the singleton log writer. - * @param filePrefix the prefix for the name of the log file. - * @param levelName only messages at this level or higher will be logged. - * @param dir the directory in which to create the log file. - * @param append whether to append to an existing log file. - * @return the singleton log writer. - * @throws HydraRuntimeException if log writer has already been created. - * @throws IllegalArgumentException if level is illegal. - */ - public synchronized static LogWriter createLogWriter( String name, String filePrefix, String levelName, String dir, boolean append ) { - if ( logWriter == null ) { - logWriter = new AnyLogWriter( filePrefix, levelName, dir, append ); - } else { - throw new HydraRuntimeException( "Log writer has already been created" ); - } - logName = name; - return logWriter; - } - /** - * Creates a singleton log writer that logs to a file. - * @param name the name of the singleton log writer. - * @param filePrefix the prefix for files created by this log writer. - * - * @return the singleton log writer. - * @throws HydraRuntimeException if file can't be created or if log writer has - * already been created. - * @throws IllegalArgumentException if level is illegal. - */ - public synchronized static LogWriter createLogWriter( String name, - String filePrefix, - boolean fileLogging, - String fileLogLevelName, - int fileMaxKBPerVM ) { - if ( logWriter == null ) { - logWriter = new AnyLogWriter( filePrefix, fileLogging, fileLogLevelName, - fileMaxKBPerVM ); - } else { - throw new HydraRuntimeException( "Log writer has already been created" ); - } - logName = name; - return logWriter; - } - /** - * Closes the singleton log writer. After this method executes, there is no - * singleton log writer. - * @throws HydraRuntimeException if the singleton log writer does not exist. - */ - public static void closeLogWriter() { - if ( logWriter == null ) { - throw new HydraRuntimeException( "Log writer does not exist" ); - } else { - logName = null; - logWriter = null; - } - } - /** - * Caches the singleton log writer so another log writer can be created. - * After this method executes, there is no singleton log writer. - * @throws HydraRuntimeException if the singleton log writer does not exist or - * has already been cached. - */ - public static void cacheLogWriter() { - if ( logWriter == null ) { - throw new HydraRuntimeException( "Log writer has not been created" ); - } else { - if ( cache == null ) - cache = new Hashtable(); - if ( cache.get( logName ) != null ) - throw new HydraRuntimeException( "Log writer " + logName + " has already been cached" ); - cache.put( logName, logWriter ); - logName = null; - logWriter = null; - } - } - /** - * Uncaches the log writer with the specified name, blowing away the existing one - * (unless it was previously cached). After this method executes, the named log - * writer is the singleton log writer. - * @param name the name of the log writer to uncache. - * @return the uncached (now active) log writer. - * @throws HydraRuntimeException if the named log writer does not exist or there - * is already a singleton log writer. - */ - public static LogWriter uncacheLogWriter( String name ) { - if ( cache == null ) - throw new HydraRuntimeException( "Log writer " + name + " has not been cached" ); - if ( logWriter != null ) - throw new HydraRuntimeException( "Log writer " + name + " is still active" ); - AnyLogWriter lw = (AnyLogWriter) cache.get( name ); - if ( lw == null ) - throw new HydraRuntimeException( "Log writer " + name + " has not been cached" ); - logName = name; - logWriter = lw; - return logWriter; - } - /** - * Fetches the singleton log writer. - * @throws HydraRuntimeException if log writer has not been created. - */ - public static LogWriter getLogWriter() { - if ( logWriter == null ) - throw new HydraRuntimeException( "Attempt to getLogWriter() before createLogWriter()" ); - return logWriter; - } - /** - * - * Fetches the current log level of the singleton log writer. - * - */ - public static String getLogWriterLevel() { - return LogVersionHelper.levelToString(logWriter.getLevel()); - } - /** - * - * Resets the log level of the singleton log writer. - * - */ - public static void setLogWriterLevel( String levelName ) { - logWriter.setLevel(LogVersionHelper.levelNameToCode(levelName)); - } - /** - * Small Log test program - */ - public static void main(String[] args) { - Thread.currentThread().setName( "chester" ); - - Log.createLogWriter( "test", "finer" ); - - Log.getLogWriter().fine( "fine" ); - Log.getLogWriter().finer( "finer" ); - Log.getLogWriter().finest( "finest" ); - - Log.setLogWriterLevel( "all" ); - Log.getLogWriter().fine( "fine" ); - Log.getLogWriter().finer( "finer" ); - Log.getLogWriter().finest( "finest" ); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fb719d0a/geode-core/src/test/java/hydra/LogVersionHelper.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/hydra/LogVersionHelper.java b/geode-core/src/test/java/hydra/LogVersionHelper.java deleted file mode 100644 index 9278ab2..0000000 --- a/geode-core/src/test/java/hydra/LogVersionHelper.java +++ /dev/null @@ -1,45 +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 hydra; - -import com.gemstone.gemfire.internal.logging.InternalLogWriter; -import com.gemstone.gemfire.internal.logging.LoggingThreadGroup; -import com.gemstone.gemfire.internal.logging.LogWriterImpl; -import com.gemstone.gemfire.LogWriter; - -/** - * Provides version-dependent support for logging changes. - */ -public class LogVersionHelper { - - protected static String levelToString(int level) { - return LogWriterImpl.levelToString(level); - } - - protected static int levelNameToCode(String level) { - return LogWriterImpl.levelNameToCode(level); - } - - protected static ThreadGroup getLoggingThreadGroup(String group, LogWriter logger) { - return LoggingThreadGroup.createThreadGroup(group, (InternalLogWriter)logger); - } - - protected static String getMergeLogFilesClassName() { - return "com.gemstone.gemfire.internal.logging.MergeLogFiles"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fb719d0a/geode-core/src/test/java/hydra/log/AnyLogWriter.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/hydra/log/AnyLogWriter.java b/geode-core/src/test/java/hydra/log/AnyLogWriter.java deleted file mode 100644 index 369f35b..0000000 --- a/geode-core/src/test/java/hydra/log/AnyLogWriter.java +++ /dev/null @@ -1,555 +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 hydra.log; - -import hydra.HydraRuntimeException; - -import com.gemstone.gemfire.*; -import com.gemstone.gemfire.i18n.LogWriterI18n; -import com.gemstone.gemfire.internal.logging.InternalLogWriter; -import com.gemstone.gemfire.internal.logging.LocalLogWriter; -import com.gemstone.gemfire.internal.logging.LogWriterImpl; -import com.gemstone.gemfire.i18n.StringId; - -import java.io.*; - -/** - * - * A {@link com.gemstone.gemfire.LogWriter} that writes to a file logger, - * depending on whether it is turned on via LogPrms#file_logging. - *

- * The log level query methods answer true if a file logger is active and - * answer true. See LogPrms#file_logLevel. - */ - -public class AnyLogWriter implements InternalLogWriter { - - private boolean FILE_LOGGING; -// private String filePrefix; - private InternalLogWriter file; - - /** - * Create a log writer to stdout. - * @param levelName the log level. - */ - public AnyLogWriter( String levelName ) { - this.FILE_LOGGING = true; - int level = LogWriterImpl.levelNameToCode( levelName ); - this.file = new LocalLogWriter( level, System.out ); - } - - /** - * Create a log writer to a file of unlimited size. - * @param filePrefix the prefix for the filename of the log. - * @param levelName the log level. - */ - public AnyLogWriter( String filePrefix, String levelName, boolean append ) { - this.FILE_LOGGING = true; - FileOutputStream fos; - String fn = filePrefix + ".log"; - try { - fos = new FileOutputStream( fn, append ); - } catch( IOException e ) { - throw new HydraRuntimeException( "Unable to open " + fn, e ); - } - PrintStream ps = new PrintStream( fos, true ); // autoflush - System.setOut( ps ); System.setErr( ps ); - int level = LogWriterImpl.levelNameToCode( levelName ); - this.file = new LocalLogWriter( level, ps ); - } - - /** - * Create a log writer to a file of unlimited size in the specified directory. - * @param filePrefix the prefix for the filename of the log. - * @param levelName the log level. - * @param dir the directory in which to create the file. - */ - public AnyLogWriter( String filePrefix, String levelName, String dir, boolean append ) { - this.FILE_LOGGING = true; - FileOutputStream fos; - String fn = dir + File.separator + filePrefix + ".log"; - try { - fos = new FileOutputStream( fn, append ); - } catch( IOException e ) { - throw new HydraRuntimeException( "Unable to open " + fn, e ); - } - PrintStream ps = new PrintStream( fos, true ); // autoflush - System.setOut( ps ); System.setErr( ps ); - int level = LogWriterImpl.levelNameToCode( levelName ); - this.file = new LocalLogWriter( level, ps ); - } - - /** - * Create a log writer to a file. May be circular. - * @param filePrefix the prefix for names of files created by this logwriter. - * @param fileLogging turn on logging to the file. - * @param fileLogLevelName name of the file log level. - * @param fileMaxKBPerVM the maximum size of the file log per VM, in kilobytes . - */ - public AnyLogWriter( String filePrefix, boolean fileLogging, - String fileLogLevelName, int fileMaxKBPerVM ) { - -// this.filePrefix = filePrefix; - if ( fileLogging ) { - this.FILE_LOGGING = fileLogging; - if ( fileMaxKBPerVM < 0 ) - throw new IllegalArgumentException( "Illegal (negative) file log length: " + fileMaxKBPerVM ); - int maxBytes = fileMaxKBPerVM * 1024; - CircularOutputStream cos; - String fn = filePrefix + ".log"; - try { - cos = new CircularOutputStream( fn, maxBytes ); - } catch( IOException e ) { - throw new HydraRuntimeException( "Unable to create " + fn, e ); - } - // create a local log writer using the circular file - int level = LogWriterImpl.levelNameToCode( fileLogLevelName ); - this.file = new LocalLogWriter( level, new PrintStream( cos ) ); - } - } - - /** - * Gets the writer's level. Returns the level obtained from active logger. - */ - public int getLevel() { - if ( FILE_LOGGING ) - return ((LocalLogWriter)file).getLogWriterLevel(); - else - return LogWriterImpl.NONE_LEVEL; - } - /** - * Sets the writer's level. Applies to any active logger. - * @throws IllegalArgumentException if level is not in legal range - */ - public void setLevel(int newLevel) { - if ( FILE_LOGGING ) - ((LocalLogWriter)file).setLevel( newLevel ); - } - - public void setLogWriterLevel(int newLevel) { - setLevel(newLevel); - } - -//////////////////////////////////////////////////////////////////////////////// -//// LOGWRITER INTERFACE ///// -//////////////////////////////////////////////////////////////////////////////// - - /** - * Implements {@link com.gemstone.gemfire.LogWriter#severeEnabled}. - * Answers true if the file logger answers true. - */ - public boolean severeEnabled() { - if ( FILE_LOGGING ) - return file.severeEnabled(); - else - return false; - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#severe(String,Throwable)}. - */ - public void severe(String msg, Throwable ex) { - if ( FILE_LOGGING ) file.severe(msg,ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#severe(String)}. - */ - public void severe(String msg) { - if ( FILE_LOGGING ) file.severe(msg); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#severe(Throwable)}. - */ - public void severe(Throwable ex) { - if ( FILE_LOGGING ) file.severe(ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#errorEnabled}. - * Answers true if the file logger answers true. - */ - public boolean errorEnabled() { - if ( FILE_LOGGING ) - return file.errorEnabled(); - else - return false; - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#error(String,Throwable)}. - */ - public void error(String msg, Throwable ex) { - if ( FILE_LOGGING ) file.error(msg, ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#error(String)}. - */ - public void error(String msg) { - if ( FILE_LOGGING ) file.error(msg); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#error(Throwable)}. - */ - public void error(Throwable ex) { - if ( FILE_LOGGING ) file.error(ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#warningEnabled}. - * Answers true if the file logger answers true. - */ - public boolean warningEnabled() { - if ( FILE_LOGGING ) - return file.warningEnabled(); - else - return false; - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#warning(String,Throwable)}. - */ - public void warning(String msg, Throwable ex) { - if ( FILE_LOGGING ) file.warning(msg,ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#warning(String)}. - */ - public void warning(String msg) { - if ( FILE_LOGGING ) file.warning(msg); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#warning(Throwable)}. - */ - public void warning(Throwable ex) { - if ( FILE_LOGGING ) file.warning(ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#infoEnabled}. - * Answers true if the file logger answers true. - */ - public boolean infoEnabled() { - if ( FILE_LOGGING ) - return file.infoEnabled(); - else - return false; - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#info(String,Throwable)}. - */ - public void info(String msg, Throwable ex) { - if ( FILE_LOGGING ) file.info(msg,ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#info(String)}. - */ - public void info(String msg) { - if ( FILE_LOGGING ) file.info(msg); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#info(Throwable)}. - */ - public void info(Throwable ex) { - if ( FILE_LOGGING ) file.info(ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#configEnabled}. - * Answers true if the file logger answers true. - */ - public boolean configEnabled() { - if ( FILE_LOGGING ) - return file.configEnabled(); - else - return false; - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#config(String,Throwable)}. - */ - public void config(String msg, Throwable ex) { - if ( FILE_LOGGING ) file.config(msg,ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#config(String)}. - */ - public void config(String msg) { - if ( FILE_LOGGING ) file.config(msg); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#config(Throwable)}. - */ - public void config(Throwable ex) { - if ( FILE_LOGGING ) file.config(ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#fineEnabled}. - * Answers true if the file logger answers true. - */ - public boolean fineEnabled() { - if ( FILE_LOGGING ) - return file.fineEnabled(); - else - return false; - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#fine(String,Throwable)}. - */ - public void fine(String msg, Throwable ex) { - if ( FILE_LOGGING ) file.fine(msg,ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#fine(String)}. - */ - public void fine(String msg) { - if ( FILE_LOGGING ) file.fine(msg); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#fine(Throwable)}. - */ - public void fine(Throwable ex) { - if ( FILE_LOGGING ) file.fine(ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#finerEnabled}. - * Answers true if the file logger answers true. - */ - public boolean finerEnabled() { - if ( FILE_LOGGING ) - return file.finerEnabled(); - else - return false; - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#finer(String,Throwable)}. - */ - public void finer(String msg, Throwable ex) { - if ( FILE_LOGGING ) file.finer(msg,ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#finer(String)}. - */ - public void finer(String msg) { - if ( FILE_LOGGING ) file.finer(msg); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#finer(Throwable)}. - */ - public void finer(Throwable ex) { - if ( FILE_LOGGING ) file.finer(ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#finestEnabled}. - * Answers true if the file logger answers true. - */ - public boolean finestEnabled() { - if ( FILE_LOGGING ) - return file.finestEnabled(); - else - return false; - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#finest(String,Throwable)}. - */ - public void finest(String msg, Throwable ex) { - if ( FILE_LOGGING ) file.finest(msg,ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#finest(String)}. - */ - public void finest(String msg) { - if ( FILE_LOGGING ) file.finest(msg); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#finest(Throwable)}. - */ - public void finest(Throwable ex) { - if ( FILE_LOGGING ) file.finest(ex); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#entering(String,String)}. - */ - public void entering(String sourceClass, String sourceMethod) { - if ( FILE_LOGGING ) file.entering(sourceClass,sourceMethod); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#exiting(String,String)}. - */ - public void exiting(String sourceClass, String sourceMethod) { - if ( FILE_LOGGING ) file.exiting(sourceClass,sourceMethod); - } - /** - * Implements {@link com.gemstone.gemfire.LogWriter#throwing(String,String,Throwable)}. - */ - public void throwing(String sourceClass, String sourceMethod, Throwable thrown) { - if ( FILE_LOGGING ) file.throwing(sourceClass,sourceMethod,thrown); - } - public java.util.logging.Handler getHandler() { - return null; - } - - public void config(StringId msgId, Object param, Throwable ex) { - config(msgId.toLocalizedString(param), ex); - } - - public void config(StringId msgId, Object param) { - config(msgId.toLocalizedString(param)); - } - - public void config(StringId msgId, Object[] params, Throwable ex) { - config(msgId.toLocalizedString(params), ex); - } - - public void config(StringId msgId, Object[] params) { - config(msgId.toLocalizedString(params)); - } - - public void config(StringId msgId, Throwable ex) { - config(msgId.toLocalizedString(), ex); - } - - public void config(StringId msgId) { - config(msgId.toLocalizedString()); - } - - public void error(StringId msgId, Object param, Throwable ex) { - error(msgId.toLocalizedString(param), ex); - } - - public void error(StringId msgId, Object param) { - error(msgId.toLocalizedString(param)); - } - - public void error(StringId msgId, Object[] params, Throwable ex) { - error(msgId.toLocalizedString(params), ex); - } - - public void error(StringId msgId, Object[] params) { - error(msgId.toLocalizedString(params)); - } - - public void error(StringId msgId, Throwable ex) { - error(msgId.toLocalizedString(), ex); - } - - public void error(StringId msgId) { - error(msgId.toLocalizedString()); - } - - public void info(StringId msgId, Object param, Throwable ex) { - info(msgId.toLocalizedString(param), ex); - } - - public void info(StringId msgId, Object param) { - info(msgId.toLocalizedString(param)); - } - - public void info(StringId msgId, Object[] params, Throwable ex) { - info(msgId.toLocalizedString(params), ex); - } - - public void info(StringId msgId, Object[] params) { - info(msgId.toLocalizedString(params)); - } - - public void info(StringId msgId, Throwable ex) { - info(msgId.toLocalizedString(), ex); - } - - public void info(StringId msgId) { - info(msgId.toLocalizedString()); - } - - public void severe(StringId msgId, Object param, Throwable ex) { - severe(msgId.toLocalizedString(param), ex); - } - - public void severe(StringId msgId, Object param) { - severe(msgId.toLocalizedString(param)); - } - - public void severe(StringId msgId, Object[] params, Throwable ex) { - severe(msgId.toLocalizedString(params), ex); - } - - public void severe(StringId msgId, Object[] params) { - severe(msgId.toLocalizedString(params)); - } - - public void severe(StringId msgId, Throwable ex) { - severe(msgId.toLocalizedString(), ex); - } - - public void severe(StringId msgId) { - severe(msgId.toLocalizedString()); - } - - public void warning(StringId msgId, Object param, Throwable ex) { - warning(msgId.toLocalizedString(param), ex); - } - - public void warning(StringId msgId, Object param) { - warning(msgId.toLocalizedString(param)); - } - - public void warning(StringId msgId, Object[] params, Throwable ex) { - warning(msgId.toLocalizedString(params), ex); - } - - public void warning(StringId msgId, Object[] params) { - warning(msgId.toLocalizedString(params)); - } - - public void warning(StringId msgId, Throwable ex) { - warning(msgId.toLocalizedString(), ex); - } - - public void warning(StringId msgId) { - warning(msgId.toLocalizedString()); - } - /* (non-Javadoc) - * @see com.gemstone.gemfire.LogWriterI18n#convertToLogWriter() - */ - public LogWriter convertToLogWriter() { - return this; - } - - /* (non-Javadoc) - * @see com.gemstone.gemfire.LogWriter#convertToLogWriterI18n() - */ - public LogWriterI18n convertToLogWriterI18n() { - return this; - } - - @Override - public int getLogWriterLevel() { - return file.getLogWriterLevel(); - } - - @Override - public boolean isSecure() { - return false; - } - - @Override - public String getConnectionName() { - return null; - } - - @Override - public void put(int msgLevel, String msg, Throwable exception) { - file.put(msgLevel, msg, exception); - } - - @Override - public void put(int msgLevel, StringId msgId, Object[] params,Throwable exception) { - file.put(msgLevel, msgId, params, exception); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fb719d0a/geode-core/src/test/java/hydra/log/CircularOutputStream.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/hydra/log/CircularOutputStream.java b/geode-core/src/test/java/hydra/log/CircularOutputStream.java deleted file mode 100644 index 266f57d..0000000 --- a/geode-core/src/test/java/hydra/log/CircularOutputStream.java +++ /dev/null @@ -1,131 +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 hydra.log; - -import java.io.*; - -/** - * Implements a circular output stream with an upper limit on the number of bytes - * it contains. - */ -public class CircularOutputStream extends OutputStream { - - private static byte marker = '%'; - - String name; - int maxBytes; - boolean rolling = false; - RandomAccessFile raf; - - /** - * Constructs a new circular output stream. - * @param name the name of the output stream. - * @param maxBytes the maximum number of bytes in the output stream. - * @throws IOException if the stream cannot be created or written. - */ - public CircularOutputStream( String name, int maxBytes ) - throws IOException { - this.name = name; - this.maxBytes = maxBytes; - this.rolling = ( maxBytes > 0 ); - try { - this.raf = new RandomAccessFile( name, "rw" ); - } catch( FileNotFoundException e ) { - e.printStackTrace(); - throw new IOException( "Unable to create stream named " + name ); - } - if ( this.rolling ) { - // write the initial marker - this.raf.write( marker ); - } - } - /** - * Implements {@link java.io.OutputStream#close}. - */ - /* - public void close() { - this.raf.close(); - } - */ - /** - * Implements {@link java.io.OutputStream#flush}. - */ - /* - public void flush() { - } - */ - /** - * Implements {@link java.io.OutputStream#write(byte[])}. - */ - @Override - public void write( byte[] b ) throws IOException { - write( b, 0, b.length ); - } - /** - * Implements {@link java.io.OutputStream#write(byte[],int,int)}. - */ - @Override - public void write( byte[] b, int off, int len ) throws IOException { - if ( this.rolling ) { - // back over marker character - long fptr = this.raf.getFilePointer() - 1; - this.raf.seek( fptr ); - // write bytes - int space = (int)( this.maxBytes - fptr ); - if ( len <= space ) { - this.raf.write( b, off, len ); - } else { - this.raf.write( b, off, space ); - this.raf.seek(0); - this.raf.write( b, off + space, len - space ); - } - // wrap around if landed at the end - if ( this.raf.getFilePointer() == this.maxBytes ) - this.raf.seek(0); - // write marker character - this.raf.write( marker ); - } else { - this.raf.write( b, off, len ); - } - } - /** - * Implements {@link java.io.OutputStream#write(int)}. - */ - @Override - public void write( int b ) throws IOException { - // back over marker character - long fptr = this.raf.getFilePointer() - 1; - this.raf.seek( fptr ); - // write byte - this.raf.writeByte( b ); - // wrap around if landed at the end - if ( this.raf.getFilePointer() == this.maxBytes ) - this.raf.seek(0); - // write marker character - this.raf.write( marker ); - } - - public static void main( String[] args ) throws IOException { - CircularOutputStream t = new CircularOutputStream( "frip", 10 ); - PrintStream ps = new PrintStream( t, true ); // autoflush - System.setOut( ps ); System.setErr( ps ); - - System.out.println( "WHERE WILL THIS GO?" ); - String s = "AND WHAT ABOUT THIS?\n"; - t.write( s.getBytes() ); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fb719d0a/geode-core/src/test/java/parReg/query/unittest/NewPortfolio.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/parReg/query/unittest/NewPortfolio.java b/geode-core/src/test/java/parReg/query/unittest/NewPortfolio.java index 9bdb861..65620f9 100755 --- a/geode-core/src/test/java/parReg/query/unittest/NewPortfolio.java +++ b/geode-core/src/test/java/parReg/query/unittest/NewPortfolio.java @@ -16,7 +16,6 @@ */ package parReg.query.unittest; -import hydra.Log; import java.io.Serializable; import java.util.*; @@ -96,7 +95,7 @@ public class NewPortfolio implements Serializable { } public void init( int i ) { - this.name = new Integer(i).toString(); + this.name = Integer.toString(i); this.id = i; this.status = i % 2 == 0 ? "active" : "inactive"; this.type = "type" + (i % NUM_OF_TYPES); @@ -119,7 +118,7 @@ public class NewPortfolio implements Serializable { secId += i * 7; if (secId > NUM_OF_SECURITIES) secId -= NUM_OF_SECURITIES; - props.setProperty("secId", new Integer(secId).toString()); + props.setProperty("secId", Integer.toString(secId)); Position pos = new Position(); pos.init(props); @@ -145,8 +144,8 @@ public class NewPortfolio implements Serializable { */ protected Properties getProps() { Properties props = new Properties(); - Double qty = new Double(rng.nextInt(MAX_QTY) * 100.00); - Double mktValue = new Double(rng.nextDouble() * MAX_PRICE); + Double qty = rng.nextInt(MAX_QTY) * 100.00; + Double mktValue = rng.nextDouble() * MAX_PRICE; props.setProperty("qty", qty.toString()); props.setProperty("mktValue", mktValue.toString()); @@ -162,36 +161,27 @@ public class NewPortfolio implements Serializable { if (anObj == null) { return false; } -// Log.getLogWriter().info("comparing\n"+this+"\n and "+anObj); if (anObj.getClass().getName().equals(this.getClass().getName())) { // cannot do class identity check for pdx tets -// Log.getLogWriter().info("checkpoint 1,.this class is checked " + this.getClass().getName() ); NewPortfolio np = (NewPortfolio)anObj; if (!np.name.equals(this.name) || (np.id != this.id) || !np.type.equals(this.type) || !np.status.equals(this.status)) { -// Log.getLogWriter().info("checkpoint 1,obj " +np.name + " " + np.id + " " + np.type ); return false; } -// Log.getLogWriter().info("checkpoint 2, NP name, id checked" ); - + if (np.positions == null) { if (this.positions != null) { return false; } } else { -// Log.getLogWriter().info("checkpoint 3, checking position size" ); if (np.positions.size() != this.positions.size()) { - Log.getLogWriter().info("checkpoint 3, position size failed" ); return false; } else { //loops thru the map of positions Iterator itr = np.positions.values().iterator(); Position pos; while (itr.hasNext()) { -// Log.getLogWriter().info("checkpoint 4, to check iteration" ); pos = (Position)itr.next(); -// Log.getLogWriter().info("checkpoint 4, to check pos" ); if (!this.positions.containsValue(pos)){ -// Log.getLogWriter().info("checkpoint 5, check pos failed" ); return false; } } @@ -199,7 +189,6 @@ public class NewPortfolio implements Serializable { } } else { //not same class -// Log.getLogWriter().info("checkpoint 6, not the same class"); return false; } return true; @@ -231,25 +220,9 @@ public class NewPortfolio implements Serializable { fieldMap.put("type", type); fieldMap.put("positions", positions); fieldMap.put("undefinedTestField", undefinedTestField); -// Log.getLogWriter().info("created map in tests/parReg.query.NewPortfolio: " + fieldMap); return fieldMap; } - /** Restore the fields of this instance using the values of the Map, created - * by createPdxHelperMap() - */ - public void restoreFromPdxHelperMap(Map aMap) { -// Log.getLogWriter().info("restoring from map into " + this.getClass().getName() + ": " + aMap); - this.myVersion = (String)aMap.get("myVersion"); - this.id = (Integer)aMap.get("id"); - this.name = (String)aMap.get("name"); - this.status = (String)aMap.get("status"); - this.type = (String)aMap.get("type"); - this.positions = (Map)aMap.get("positions"); - this.undefinedTestField = (String)aMap.get("undefinedTestField"); -// Log.getLogWriter().info("returning instance from map in tests/parReg.query.NewPortfolio: " + this); - } - @Override public String toString() { StringBuffer sb = new StringBuffer(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fb719d0a/geode-core/src/test/java/perffmwk/Formatter.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/perffmwk/Formatter.java b/geode-core/src/test/java/perffmwk/Formatter.java index 410c850..1f6a49c 100644 --- a/geode-core/src/test/java/perffmwk/Formatter.java +++ b/geode-core/src/test/java/perffmwk/Formatter.java @@ -17,11 +17,11 @@ package perffmwk; -import hydra.HydraRuntimeException; - -import java.io.*; -import java.text.*; -import java.util.*; +import java.io.PrintWriter; +import java.text.DecimalFormat; +import java.util.Collection; +import java.util.Iterator; +import java.util.Vector; /** * Contains common code used to format reports. @@ -111,7 +111,7 @@ public class Formatter { */ public static String padLeft( String s, int length ) { if ( s.length() > length ) { - throw new HydraRuntimeException( s + " cannot be padded to length " + length + ", it is too long" ); + throw new RuntimeException( s + " cannot be padded to length " + length + ", it is too long" ); } String t = ""; for ( int i = 0; i < length - s.length(); i++ ) { @@ -124,7 +124,7 @@ public class Formatter { */ public static String padRight( String s, int length ) { if ( s.length() > length ) { - throw new HydraRuntimeException( s + " cannot be padded to length " + length + ", it is too long" ); + throw new RuntimeException( s + " cannot be padded to length " + length + ", it is too long" ); } String t = new String( s ); for ( int i = 0; i < length - s.length(); i++ ) { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fb719d0a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/PartitionedRegionCqQueryDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/PartitionedRegionCqQueryDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/PartitionedRegionCqQueryDUnitTest.java index acede33..de93c75 100644 --- a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/PartitionedRegionCqQueryDUnitTest.java +++ b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/PartitionedRegionCqQueryDUnitTest.java @@ -16,24 +16,43 @@ */ package com.gemstone.gemfire.cache.query.cq.dunit; -import com.gemstone.gemfire.cache.*; +import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; + +import java.io.IOException; +import java.util.HashSet; + +import com.gemstone.gemfire.cache.AttributesFactory; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.CacheException; +import com.gemstone.gemfire.cache.CacheFactory; +import com.gemstone.gemfire.cache.PartitionAttributes; +import com.gemstone.gemfire.cache.PartitionAttributesFactory; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.RegionAttributes; +import com.gemstone.gemfire.cache.Scope; import com.gemstone.gemfire.cache.client.ClientCache; import com.gemstone.gemfire.cache.client.ClientCacheFactory; import com.gemstone.gemfire.cache.client.ClientRegionShortcut; -import com.gemstone.gemfire.cache.query.*; +import com.gemstone.gemfire.cache.query.CqAttributes; +import com.gemstone.gemfire.cache.query.CqAttributesFactory; +import com.gemstone.gemfire.cache.query.CqListener; +import com.gemstone.gemfire.cache.query.CqQuery; +import com.gemstone.gemfire.cache.query.QueryService; +import com.gemstone.gemfire.cache.query.SelectResults; +import com.gemstone.gemfire.cache.query.Struct; import com.gemstone.gemfire.cache.query.data.Portfolio; import com.gemstone.gemfire.cache.server.CacheServer; import com.gemstone.gemfire.cache30.CacheSerializableRunnable; import com.gemstone.gemfire.cache30.CacheTestCase; import com.gemstone.gemfire.cache30.ClientServerTestCase; import com.gemstone.gemfire.internal.cache.LocalRegion; -import com.gemstone.gemfire.test.dunit.*; -import hydra.Log; - -import java.io.IOException; -import java.util.HashSet; - -import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*; +import com.gemstone.gemfire.test.dunit.Assert; +import com.gemstone.gemfire.test.dunit.Host; +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; /** * Test class for Partitioned Region and CQs @@ -1418,8 +1437,6 @@ public class PartitionedRegionCqQueryDUnitTest extends CacheTestCase { if (localRegion != null) { // REGION NULL - Log.getLogWriter().info("Local region is NOT null in client 1"); - Wait.pause(5*1000); CqQuery[] cqs = getCache().getQueryService().getCqs(); if (cqs != null && cqs.length > 0) {