http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java index 36888e8..ef25e8f 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java +++ b/geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java @@ -14,12 +14,6 @@ */ package org.apache.geode.internal.statistics; -import org.apache.geode.GemFireIOException; -import org.apache.geode.InternalGemFireException; -import org.apache.geode.internal.Assert; -import org.apache.geode.internal.i18n.LocalizedStrings; -import org.apache.geode.internal.logging.DateFormatter; - import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.EOFException; @@ -46,6 +40,13 @@ import java.util.SimpleTimeZone; import java.util.TimeZone; import java.util.zip.GZIPInputStream; +import org.apache.geode.GemFireIOException; +import org.apache.geode.InternalGemFireException; +import org.apache.geode.internal.Assert; +import org.apache.geode.internal.ExitCode; +import org.apache.geode.internal.i18n.LocalizedStrings; +import org.apache.geode.internal.logging.DateFormatter; + /** * StatArchiveReader provides APIs to read statistic snapshots from an archive file. */ @@ -222,7 +223,7 @@ public class StatArchiveReader implements StatArchiveFormat { String archiveName = null; if (args.length > 1) { System.err.println("Usage: [archiveName]"); - System.exit(1); + ExitCode.FATAL.doSystemExit(); } else if (args.length == 1) { archiveName = args[0]; } else { @@ -397,7 +398,7 @@ public class StatArchiveReader implements StatArchiveFormat { } } - public static interface StatValue { + public interface StatValue { /** * {@link StatArchiveReader.StatValue} filter that causes the statistic values to be unfiltered. * This causes the raw values written to the archive to be used. @@ -405,7 +406,7 @@ public class StatArchiveReader implements StatArchiveFormat { * This is the default filter for non-counter statistics. To determine if a statistic is not a * counter use {@link StatArchiveReader.StatDescriptor#isCounter}. */ - public static final int FILTER_NONE = 0; + int FILTER_NONE = 0; /** * {@link StatArchiveReader.StatValue} filter that causes the statistic values to be filtered to * reflect how often they change per second. Since the difference between two samples is used to @@ -417,7 +418,7 @@ public class StatArchiveReader implements StatArchiveFormat { * This is the default filter for counter statistics. To determine if a statistic is a counter * use {@link StatArchiveReader.StatDescriptor#isCounter}. */ - public static final int FILTER_PERSEC = 1; + int FILTER_PERSEC = 1; /** * {@link StatArchiveReader.StatValue} filter that causes the statistic values to be filtered to * reflect how much they changed between sample periods. Since the difference between two @@ -426,90 +427,90 @@ public class StatArchiveReader implements StatArchiveFormat { * per second value is the instance's first time stamp * {@link StatArchiveReader.ResourceInst#getFirstTimeMillis}. */ - public static final int FILTER_PERSAMPLE = 2; + int FILTER_PERSAMPLE = 2; /** * Creates and returns a trimmed version of this stat value. Any samples taken before * <code>startTime</code> and after <code>endTime</code> are discarded from the resulting value. * Set a time parameter to <code>-1</code> to not trim that side. */ - public StatValue createTrimmed(long startTime, long endTime); + StatValue createTrimmed(long startTime, long endTime); /** * Returns true if value has data that has been trimmed off it by a start timestamp. */ - public boolean isTrimmedLeft(); + boolean isTrimmedLeft(); /** * Gets the {@link StatArchiveReader.ResourceType type} of the resources that this value belongs * to. */ - public ResourceType getType(); + ResourceType getType(); /** * Gets the {@link StatArchiveReader.ResourceInst resources} that this value belongs to. */ - public ResourceInst[] getResources(); + ResourceInst[] getResources(); /** * Returns an array of timestamps for each unfiltered snapshot in this value. Each returned time * stamp is the number of millis since midnight, Jan 1, 1970 UTC. */ - public long[] getRawAbsoluteTimeStamps(); + long[] getRawAbsoluteTimeStamps(); /** * Returns an array of timestamps for each unfiltered snapshot in this value. Each returned time * stamp is the number of millis since midnight, Jan 1, 1970 UTC. The resolution is seconds. */ - public long[] getRawAbsoluteTimeStampsWithSecondRes(); + long[] getRawAbsoluteTimeStampsWithSecondRes(); /** * Returns an array of doubles containing the unfiltered value of this statistic for each point * in time that it was sampled. */ - public double[] getRawSnapshots(); + double[] getRawSnapshots(); /** * Returns an array of doubles containing the filtered value of this statistic for each point in * time that it was sampled. */ - public double[] getSnapshots(); + double[] getSnapshots(); /** * Returns the number of samples taken of this statistic's value. */ - public int getSnapshotsSize(); + int getSnapshotsSize(); /** * Returns the smallest of all the samples taken of this statistic's value. */ - public double getSnapshotsMinimum(); + double getSnapshotsMinimum(); /** * Returns the largest of all the samples taken of this statistic's value. */ - public double getSnapshotsMaximum(); + double getSnapshotsMaximum(); /** * Returns the average of all the samples taken of this statistic's value. */ - public double getSnapshotsAverage(); + double getSnapshotsAverage(); /** * Returns the standard deviation of all the samples taken of this statistic's value. */ - public double getSnapshotsStandardDeviation(); + double getSnapshotsStandardDeviation(); /** * Returns the most recent value of all the samples taken of this statistic's value. */ - public double getSnapshotsMostRecent(); + double getSnapshotsMostRecent(); /** * Returns true if sample whose value was different from previous values has been added to this * StatValue since the last time this method was called. */ - public boolean hasValueChanged(); + boolean hasValueChanged(); /** * Returns the current filter used to calculate this statistic's values. It will be one of these @@ -520,7 +521,7 @@ public class StatArchiveReader implements StatArchiveFormat { * <li>{@link #FILTER_PERSEC} * </ul> */ - public int getFilter(); + int getFilter(); /** * Sets the current filter used to calculate this statistic's values. The default filter is @@ -535,12 +536,12 @@ public class StatArchiveReader implements StatArchiveFormat { * </ul> * @throws IllegalArgumentException if <code>filter</code> is not a valid filter constant. */ - public void setFilter(int filter); + void setFilter(int filter); /** * Returns a description of this statistic. */ - public StatDescriptor getDescriptor(); + StatDescriptor getDescriptor(); } protected static abstract class AbstractValue implements StatValue { @@ -826,11 +827,6 @@ public class StatArchiveReader implements StatArchiveFormat { if (values.length == 0) { return new long[0]; } - // for (int i=0; i < values.length; i++) { - // System.out.println("DEBUG: inst# " + i + " has " - // + values[i].getRawAbsoluteTimeStamps().length - // + " timestamps"); - // } long[] valueTimeStamps = values[0].getRawAbsoluteTimeStamps(); int tsCount = valueTimeStamps.length + 1; long[] ourTimeStamps = new long[(tsCount * 2) + 1]; @@ -867,8 +863,6 @@ public class StatArchiveReader implements StatArchiveFormat { ourIdx++; // never put the next timestamp at this index while (!closer(tsToInsert, ourTimeStamps[ourIdx - 1], ourTimeStamps[ourIdx]) && !mustInsert(j, valueTimeStamps, ourTimeStamps[ourIdx])) { - // System.out.println("DEBUG: skipping mergeTs[" + (ourIdx-1) + "]=" - // + tsAtInsertPoint + " because it was closer to the next one"); ourIdx++; // it is closer to the next one so skip forward on more } } else { @@ -880,22 +874,6 @@ public class StatArchiveReader implements StatArchiveFormat { endRunIdx++; } int numToCopy = endRunIdx - j; - // System.out.println("DEBUG: tsToInsert=" + tsToInsert - // + " tsAtInsertPoint=" + tsAtInsertPoint - // + " timeDelta=" + timeDelta - // + " vDelta=" + (Math.abs(tsToInsert-tsAtInsertPoint)/2) - // + " numToCopy=" + numToCopy); - // if (j > 0) { - // System.out.println("DEBUG: prevTsToInsert=" + valueTimeStamps[j-1]); - // } - // if (ourIdx > 0) { - // System.out.println("DEBUG ourTimeStamps[" + (ourIdx-1) + "]=" + - // ourTimeStamps[ourIdx-1]); - // } - - // if (numToCopy > 1) { - // System.out.println("DEBUG: endRunTs=" + valueTimeStamps[endRunIdx-1]); - // } if (tsCount + numToCopy > ourTimeStamps.length) { // grow our timestamp array long[] tmp = new long[(tsCount + numToCopy) * 2]; @@ -916,84 +894,16 @@ public class StatArchiveReader implements StatArchiveFormat { // skip over all inserted elements j += numToCopy; } - // System.out.println("DEBUG: inst #" + i - // + " valueTs[" + (j-1) + "]=" + tsToInsert - // + " found/inserted at" - // + " mergeTs[" + (ourIdx-1) + "]=" + ourTimeStamps[ourIdx-1]); - } - } - // for (int i=0; i < tsCount; i++) { - // System.out.println("DEBUG: mergedTs[" + i + "]=" + ourTimeStamps[i]); - // if (i > 0 && ourTimeStamps[i] <= ourTimeStamps[i-1]) { - // System.out.println("DEBUG: ERROR ts was not greater than previous"); - // } - // } - // Now make one more pass over all the timestamps and make sure they - // will all fit into the current merged timestamps in ourTimeStamps - // boolean changed; - // do { - // changed = false; - // for (int i=0; i < values.length; i++) { - // valueTimeStamps = values[i].getRawAbsoluteTimeStamps(); - // if (valueTimeStamps.length == 0) { - // continue; - // } - // int ourIdx = 0; - // for (int j=0; j < valueTimeStamps.length; j++) { - // while ((ourIdx < (tsCount-1)) - // && !isClosest(valueTimeStamps[j], ourTimeStamps, ourIdx)) { - // ourIdx++; - // } - // if (ourIdx == (tsCount-1)) { - // // we are at the end so we need to append all our remaining stamps - // [j..valueTimeStamps.length-1] - // // and then reappend the Long.MAX_VALUE that - // // is currently at tsCount-1 - // int numToCopy = valueTimeStamps.length - j; - // if (tsCount+numToCopy > ourTimeStamps.length) { - // // grow our timestamp array - // long[] tmp = new long[tsCount+numToCopy+1]; - // System.arraycopy(ourTimeStamps, 0, tmp, 0, tsCount); - // ourTimeStamps = tmp; - // } - // System.arraycopy(valueTimeStamps, j, - // ourTimeStamps, ourIdx, - // numToCopy); - // tsCount += numToCopy; - // ourTimeStamps[tsCount-1] = Long.MAX_VALUE; - // //changed = true; - // System.out.println("DEBUG: had to add " + numToCopy - // + " timestamps for inst#" + i + " starting at index " + j + " starting with ts=" + - // valueTimeStamps[j]); - // break; // our of the for j loop since we just finished off this guy - // } else { - // ourIdx++; - // } - // } - // } - // } while (changed); - // remove the max ts we added + } + } tsCount--; { int startIdx = 0; int endIdx = tsCount - 1; if (startTime != -1) { - // for (int i=0; i < tsCount; i++) { - // if (ourTimeStamps[i] >= startTime) { - // break; - // } - // startIdx++; - // } Assert.assertTrue(ourTimeStamps[startIdx] >= startTime); } if (endTime != -1) { - // endIdx = startIdx-1; - // for (int i=startIdx; i < tsCount; i++) { - // if (ourTimeStamps[i] >= endTime) { - // break; - // } - // endIdx++; - // } Assert.assertTrue(endIdx == startIdx - 1 || ourTimeStamps[endIdx] < endTime); } tsCount = (endIdx - startIdx) + 1; @@ -1036,7 +946,6 @@ public class StatArchiveReader implements StatArchiveFormat { private double[] getRawSnapshots(long[] ourTimeStamps) { double[] result = new double[ourTimeStamps.length]; - // System.out.println("DEBUG: producing " + result.length + " values"); if (result.length > 0) { for (int i = 0; i < values.length; i++) { long[] valueTimeStamps = values[i].getRawAbsoluteTimeStamps(); @@ -1046,19 +955,11 @@ public class StatArchiveReader implements StatArchiveFormat { if (values[i].isTrimmedLeft() && valueSnapshots.length > 0) { currentValue = valueSnapshots[0]; } - // System.out.println("DEBUG: inst#" + i + " has " + valueSnapshots.length + " values"); for (int j = 0; j < valueSnapshots.length; j++) { - // System.out.println("DEBUG: Doing v with" - // + " vTs[" + j + "]=" + valueTimeStamps[j] - // + " at mergeTs[" + curIdx + "]=" + ourTimeStamps[curIdx]); while (!isClosest(valueTimeStamps[j], ourTimeStamps, curIdx)) { if (descriptor.isCounter()) { result[curIdx] += currentValue; } - // System.out.println("DEBUG: skipping curIdx=" + curIdx - // + " valueTimeStamps[" + j + "]=" + valueTimeStamps[j] - // + " ourTimeStamps[" + curIdx + "]=" + ourTimeStamps[curIdx] - // + " ourTimeStamps[" + (curIdx+1) + "]=" + ourTimeStamps[curIdx+1]); curIdx++; } @@ -1104,11 +1005,6 @@ public class StatArchiveReader implements StatArchiveFormat { if (filter == FILTER_PERSEC) { long timeDelta = timestamps[i + 1] - timestamps[i]; result[i] = valueDelta / (timeDelta / 1000.0); - // if (result[i] > valueDelta) { - // System.out.println("DEBUG: timeDelta was " + timeDelta + " ms."); - // System.out.println("DEBUG: valueDelta was " + valueDelta); - // System.out.println("DEBUG: valueDelta/sec was " + result[i]); - // } } else { result[i] = valueDelta; } @@ -2176,7 +2072,6 @@ public class StatArchiveReader implements StatArchiveFormat { */ public static class ResourceType { private boolean loaded; - // private final int id; private final String name; private String desc; private final StatDescriptor[] stats; @@ -2193,7 +2088,6 @@ public class StatArchiveReader implements StatArchiveFormat { protected ResourceType(int id, String name, int statCount) { this.loaded = false; - // this.id = id; this.name = name; this.desc = null; this.stats = new StatDescriptor[statCount]; @@ -2202,7 +2096,6 @@ public class StatArchiveReader implements StatArchiveFormat { protected ResourceType(int id, String name, String desc, int statCount) { this.loaded = true; - // this.id = id; this.name = name; this.desc = desc; this.stats = new StatDescriptor[statCount]; @@ -2252,9 +2145,6 @@ public class StatArchiveReader implements StatArchiveFormat { } } - // private int getId() { - // return this.id; - // } /** * Returns the name of this resource type. */ @@ -2468,7 +2358,6 @@ public class StatArchiveReader implements StatArchiveFormat { public static class ResourceInst { private final boolean loaded; private final StatArchiveFile archive; - // private final int uniqueId; private final ResourceType type; private final String name; private final long id; @@ -2537,7 +2426,6 @@ public class StatArchiveReader implements StatArchiveFormat { ResourceType type, boolean loaded) { this.loaded = loaded; this.archive = archive; - // this.uniqueId = uniqueId; this.name = name; this.id = id; Assert.assertTrue(type != null); @@ -2751,26 +2639,26 @@ public class StatArchiveReader implements StatArchiveFormat { } } - public static interface StatSpec extends ValueFilter { + public interface StatSpec extends ValueFilter { /** * Causes all stats that matches this spec, in all archive files, to be combined into a single * global stat value. */ - public static final int GLOBAL = 2; + int GLOBAL = 2; /** * Causes all stats that matches this spec, in each archive file, to be combined into a single * stat value for each file. */ - public static final int FILE = 1; + int FILE = 1; /** * No combination is done. */ - public final int NONE = 0; + int NONE = 0; /** * Returns one of the following values: {@link #GLOBAL}, {@link #FILE}, {@link #NONE}. */ - public int getCombineType(); + int getCombineType(); } /** @@ -2778,30 +2666,30 @@ public class StatArchiveReader implements StatArchiveFormat { * when loading a statistic archive file to reduce the memory footprint. Only statistic data that * matches all four will be selected for loading. */ - public static interface ValueFilter { + public interface ValueFilter { /** * Returns true if the specified archive file matches this spec. Any archives whose name does * not match this spec will not be selected for loading by this spec. */ - public boolean archiveMatches(File archive); + boolean archiveMatches(File archive); /** * Returns true if the specified type name matches this spec. Any types whose name does not * match this spec will not be selected for loading by this spec. */ - public boolean typeMatches(String typeName); + boolean typeMatches(String typeName); /** * Returns true if the specified statistic name matches this spec. Any stats whose name does not * match this spec will not be selected for loading by this spec. */ - public boolean statMatches(String statName); + boolean statMatches(String statName); /** * Returns true if the specified instance matches this spec. Any instance whose text id and * numeric id do not match this spec will not be selected for loading by this spec. */ - public boolean instanceMatches(String textId, long numericId); + boolean instanceMatches(String textId, long numericId); } public static class StatArchiveFile { @@ -3098,7 +2986,6 @@ public class StatArchiveReader implements StatArchiveFormat { return true; } } - // System.out.println("DEBUG: don't load type=" + typeName); return false; } } @@ -3116,7 +3003,6 @@ public class StatArchiveReader implements StatArchiveFormat { return true; } } - // System.out.println("DEBUG: don't load stat=" + stat.getName()); stat.unload(); return false; } @@ -3143,8 +3029,6 @@ public class StatArchiveReader implements StatArchiveFormat { } } } - // System.out.println("DEBUG: don't load instance=" + textId); - // type.unload(); return false; } } @@ -3284,9 +3168,6 @@ public class StatArchiveReader implements StatArchiveFormat { } private int readResourceInstId() throws IOException { - /* - * if (this.archiveVersion <= 1) { return dataIn.readInt(); } - */ int token = dataIn.readUnsignedByte(); if (token <= MAX_BYTE_RESOURCE_INST_ID) { return token;
http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/main/java/org/apache/geode/management/internal/cli/Launcher.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/Launcher.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/Launcher.java index a5986f5..157bb91 100755 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/Launcher.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/Launcher.java @@ -25,6 +25,7 @@ import joptsimple.OptionParser; import joptsimple.OptionSet; import org.springframework.shell.core.ExitShellRequest; +import org.apache.geode.internal.ExitCode; import org.apache.geode.internal.GemFireVersion; import org.apache.geode.internal.PureJavaMode; import org.apache.geode.management.internal.cli.i18n.CliStrings; @@ -131,7 +132,8 @@ public class Launcher { } Launcher launcher = new Launcher(); - System.exit(launcher.parseCommandLine(args)); + int exitValue = launcher.parseCommandLine(args); + ExitCode.fromValue(exitValue).doSystemExit(); } private int parseCommandLineCommand(final String... args) { http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StatusLocatorCommand.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StatusLocatorCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StatusLocatorCommand.java index eebae0d..06f8350 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StatusLocatorCommand.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StatusLocatorCommand.java @@ -18,7 +18,13 @@ import static org.apache.geode.management.internal.cli.i18n.CliStrings.LOCATOR_T import static org.apache.geode.management.internal.cli.shell.MXBeanProvider.getMemberMXBean; import static org.apache.geode.management.internal.cli.util.HostUtils.getLocatorId; +import java.io.IOException; + +import org.springframework.shell.core.annotation.CliCommand; +import org.springframework.shell.core.annotation.CliOption; + import org.apache.geode.SystemFailure; +import org.apache.geode.distributed.AbstractLauncher; import org.apache.geode.distributed.LocatorLauncher; import org.apache.geode.internal.lang.StringUtils; import org.apache.geode.internal.lang.SystemUtils; @@ -31,10 +37,6 @@ import org.apache.geode.management.internal.cli.i18n.CliStrings; import org.apache.geode.management.internal.cli.result.InfoResultData; import org.apache.geode.management.internal.cli.result.ResultBuilder; import org.apache.geode.management.internal.configuration.utils.ClusterConfigurationStatusRetriever; -import org.springframework.shell.core.annotation.CliCommand; -import org.springframework.shell.core.annotation.CliOption; - -import java.io.IOException; public class StatusLocatorCommand implements GfshCommand { @CliCommand(value = CliStrings.STATUS_LOCATOR, help = CliStrings.STATUS_LOCATOR__HELP) @@ -75,8 +77,12 @@ public class StatusLocatorCommand implements GfshCommand { .setBindAddress(locatorHost).setDebug(isDebugging()).setPid(pid) .setPort(locatorPort).setWorkingDirectory(workingDirectory).build(); - final LocatorLauncher.LocatorState state = locatorLauncher.status(); - return createStatusLocatorResult(state); + final LocatorLauncher.LocatorState status = locatorLauncher.status(); + if (status.getStatus().equals(AbstractLauncher.Status.NOT_RESPONDING) + || status.getStatus().equals(AbstractLauncher.Status.STOPPED)) { + return ResultBuilder.createShellClientErrorResult(status.toString()); + } + return createStatusLocatorResult(status); } } catch (IllegalArgumentException | IllegalStateException e) { return ResultBuilder.createUserErrorResult(e.getMessage()); http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StatusServerCommand.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StatusServerCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StatusServerCommand.java index d8e77e6..43374ab 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StatusServerCommand.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/lifecycle/StatusServerCommand.java @@ -16,7 +16,11 @@ package org.apache.geode.management.internal.cli.commands.lifecycle; import static org.apache.geode.management.internal.cli.shell.MXBeanProvider.getMemberMXBean; +import org.springframework.shell.core.annotation.CliCommand; +import org.springframework.shell.core.annotation.CliOption; + import org.apache.geode.SystemFailure; +import org.apache.geode.distributed.AbstractLauncher; import org.apache.geode.distributed.ServerLauncher; import org.apache.geode.internal.lang.StringUtils; import org.apache.geode.management.MemberMXBean; @@ -26,8 +30,6 @@ import org.apache.geode.management.cli.Result; import org.apache.geode.management.internal.cli.commands.GfshCommand; import org.apache.geode.management.internal.cli.i18n.CliStrings; import org.apache.geode.management.internal.cli.result.ResultBuilder; -import org.springframework.shell.core.annotation.CliCommand; -import org.springframework.shell.core.annotation.CliOption; public class StatusServerCommand implements GfshCommand { @@ -70,9 +72,14 @@ public class StatusServerCommand implements GfshCommand { final ServerLauncher.ServerState status = serverLauncher.status(); + if (status.getStatus().equals(AbstractLauncher.Status.NOT_RESPONDING) + || status.getStatus().equals(AbstractLauncher.Status.STOPPED)) { + return ResultBuilder.createGemFireErrorResult(status.toString()); + } return ResultBuilder.createInfoResult(status.toString()); } } catch (IllegalArgumentException | IllegalStateException e) { + return ResultBuilder.createUserErrorResult(e.getMessage()); } catch (VirtualMachineError e) { SystemFailure.initiateFailure(e); http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Add.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Add.java b/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Add.java index e69006c..c2428a3 100644 --- a/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Add.java +++ b/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Add.java @@ -14,15 +14,20 @@ */ package com.main; +import static org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_SYSTEM_ID; +import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; +import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; +import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR; + +import java.util.Set; + import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; import org.apache.geode.cache.Region; import org.apache.geode.cache.wan.GatewaySender; import org.apache.geode.distributed.internal.DistributionConfig; - -import java.util.Set; - -import static org.apache.geode.distributed.ConfigurationProperties.*; +import org.apache.geode.internal.ExitCode; /** * This is a member representing site 1 who wants to send data to site 2 @@ -108,6 +113,6 @@ public class WANBootStrapping_Site1_Add { System.out.println("Sender " + sender.getId() + " is stopped"); - System.exit(0); + ExitCode.NORMAL.doSystemExit(); } } http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Remove.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Remove.java b/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Remove.java index e25f9d3..4ed7e74 100644 --- a/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Remove.java +++ b/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Remove.java @@ -14,15 +14,17 @@ */ package com.main; -import static org.apache.geode.distributed.ConfigurationProperties.*; - -import org.apache.geode.distributed.Locator; -import org.apache.geode.distributed.internal.DistributionConfig; +import static org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_SYSTEM_ID; +import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; +import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.distributed.ConfigurationProperties.REMOTE_LOCATORS; import java.io.IOException; import java.util.Properties; -import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import org.apache.geode.distributed.Locator; +import org.apache.geode.distributed.internal.DistributionConfig; +import org.apache.geode.internal.ExitCode; /** * This is a stand alone locator with a distributed-system-id = -1 @@ -68,7 +70,7 @@ public class WANBootStrapping_Site1_Remove { locator.stop(); System.out.println("Locator stopped "); - System.exit(0); + ExitCode.NORMAL.doSystemExit(); } } http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Add.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Add.java b/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Add.java index a5f9bbc..d191f25 100644 --- a/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Add.java +++ b/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Add.java @@ -14,13 +14,19 @@ */ package com.main; +import static org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_SYSTEM_ID; +import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; +import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; +import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.distributed.ConfigurationProperties.REMOTE_LOCATORS; +import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR; + import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; import org.apache.geode.cache.Region; import org.apache.geode.cache.wan.GatewayReceiver; import org.apache.geode.distributed.internal.DistributionConfig; - -import static org.apache.geode.distributed.ConfigurationProperties.*; +import org.apache.geode.internal.ExitCode; /** * This is a member representing site 2 who wants to receive data from site 1 @@ -92,7 +98,7 @@ public class WANBootStrapping_Site2_Add { } } - System.out.println("GatewayReciver " + receiver + " is stopped"); - System.exit(0); + System.out.println("GatewayReceiver " + receiver + " is stopped"); + ExitCode.NORMAL.doSystemExit(); } } http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Remove.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Remove.java b/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Remove.java index d9e321d..af32736 100644 --- a/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Remove.java +++ b/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Remove.java @@ -14,13 +14,17 @@ */ package com.main; -import org.apache.geode.distributed.Locator; -import org.apache.geode.distributed.internal.DistributionConfig; +import static org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_SYSTEM_ID; +import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; +import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.apache.geode.distributed.ConfigurationProperties.REMOTE_LOCATORS; import java.io.IOException; import java.util.Properties; -import static org.apache.geode.distributed.ConfigurationProperties.*; +import org.apache.geode.distributed.Locator; +import org.apache.geode.distributed.internal.DistributionConfig; +import org.apache.geode.internal.ExitCode; /** * This is a stand alone locator with a distributed-system-id = -2 @@ -62,7 +66,7 @@ public class WANBootStrapping_Site2_Remove { locator.stop(); System.out.println("Locator stopped "); - System.exit(0); + ExitCode.NORMAL.doSystemExit(); } http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/test/java/org/apache/geode/codeAnalysis/decode/CompiledClass.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/codeAnalysis/decode/CompiledClass.java b/geode-core/src/test/java/org/apache/geode/codeAnalysis/decode/CompiledClass.java index 91c22be..edf57f4 100644 --- a/geode-core/src/test/java/org/apache/geode/codeAnalysis/decode/CompiledClass.java +++ b/geode-core/src/test/java/org/apache/geode/codeAnalysis/decode/CompiledClass.java @@ -30,6 +30,7 @@ import org.apache.geode.codeAnalysis.decode.cp.CpClass; import org.apache.geode.codeAnalysis.decode.cp.CpDouble; import org.apache.geode.codeAnalysis.decode.cp.CpLong; import org.apache.geode.internal.DataSerializableFixedID; +import org.apache.geode.internal.ExitCode; import org.apache.geode.internal.logging.PureLogWriter; @@ -222,15 +223,15 @@ public class CompiledClass implements Comparable { classFile = new File(argv[0]); } catch (NullPointerException e) { System.err.println("You must give the name of a class file on the command line"); - exit(3); + System.exit(3); } if (classFile == null) { System.err.println("Unable to access " + argv[0]); - exit(3); + System.exit(3); } if (!classFile.canRead()) { System.err.println("Unable to read " + argv[0]); - exit(3); + System.exit(3); } try { instance = getInstance(classFile); @@ -253,23 +254,9 @@ public class CompiledClass implements Comparable { } } catch (Throwable e) { System.err.println("Error reading file: " + e.getMessage()); - exit(3); + System.exit(3); } - exit(0); - } - - private static void exit(int exitCode) { - int b; - // if (false) { - // if (exitCode == 0) - // System.out.println("Done - press Enter to exit: "); - // else - // System.out.println("Press Enter to exit:"); - // try { - // b = System.in.read(); - // } catch (java.io.IOException e) {}; - // } - System.exit(exitCode); + ExitCode.NORMAL.doSystemExit(); } } http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemConnectPerf.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemConnectPerf.java b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemConnectPerf.java index 9cdc04b..8f97ba5 100644 --- a/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemConnectPerf.java +++ b/geode-core/src/test/java/org/apache/geode/distributed/DistributedSystemConnectPerf.java @@ -14,10 +14,14 @@ */ package org.apache.geode.distributed; +import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS; +import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL; +import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; + import java.io.PrintStream; import java.util.Properties; -import static org.apache.geode.distributed.ConfigurationProperties.*; +import org.apache.geode.internal.ExitCode; /** * This program is used to measure the amount of time it takes to connect and re-connect to a @@ -40,7 +44,7 @@ public class DistributedSystemConnectPerf { + "to connect/disconnect to a DistributedSystem"); err.println(""); - System.exit(1); + ExitCode.FATAL.doSystemExit(); } public static void main(String[] args) throws Exception { @@ -120,7 +124,7 @@ public class DistributedSystemConnectPerf { out.println("** Average connect time took: " + (totalConnect / iterations) + " ms"); out.println("** Average disconnect time took: " + (totalDisconnect / iterations) + " ms"); - System.exit(0); + ExitCode.NORMAL.doSystemExit(); } } http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java index c7674c1..47e512a 100755 --- a/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java +++ b/geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java @@ -14,9 +14,16 @@ */ package org.apache.geode.distributed; -import static org.apache.geode.distributed.ConfigurationProperties.*; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; +import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileNotFoundException; @@ -28,12 +35,21 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + import org.apache.geode.distributed.AbstractLauncher.Status; import org.apache.geode.distributed.LocatorLauncher.Builder; import org.apache.geode.distributed.LocatorLauncher.LocatorState; import org.apache.geode.distributed.internal.DistributionConfig; import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.DistributionLocator; +import org.apache.geode.internal.ExitCode; import org.apache.geode.internal.GemFireVersion; import org.apache.geode.internal.logging.InternalLogWriter; import org.apache.geode.internal.logging.LocalLogWriter; @@ -45,13 +61,6 @@ import org.apache.geode.internal.process.ProcessUtils; import org.apache.geode.test.junit.categories.FlakyTest; import org.apache.geode.test.junit.categories.IntegrationTest; import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; /** * Integration tests for launching a Locator in a forked process. @@ -1036,7 +1045,7 @@ public class LocatorLauncherRemoteIntegrationTest logWriter.info(LocatorLauncherForkingProcess.class.getSimpleName() + "#main exiting..."); - System.exit(0); + ExitCode.NORMAL.doSystemExit(); } catch (Throwable t) { logWriter.info(LocatorLauncherForkingProcess.class.getSimpleName() + "#main error: " + t, t); http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java index 1dba3cf..d59cde1 100755 --- a/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java +++ b/geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java @@ -14,9 +14,16 @@ */ package org.apache.geode.distributed; -import static org.apache.geode.distributed.ConfigurationProperties.*; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; +import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.FileOutputStream; @@ -30,6 +37,10 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.experimental.categories.Category; + import org.apache.geode.cache.DataPolicy; import org.apache.geode.cache.Scope; import org.apache.geode.distributed.AbstractLauncher.Status; @@ -38,6 +49,7 @@ import org.apache.geode.distributed.ServerLauncher.ServerState; import org.apache.geode.distributed.internal.DistributionConfig; import org.apache.geode.internal.AvailablePort; import org.apache.geode.internal.AvailablePortHelper; +import org.apache.geode.internal.ExitCode; import org.apache.geode.internal.GemFireVersion; import org.apache.geode.internal.cache.AbstractCacheServer; import org.apache.geode.internal.cache.xmlcache.CacheCreation; @@ -54,9 +66,6 @@ import org.apache.geode.internal.process.ProcessUtils; import org.apache.geode.test.junit.categories.FlakyTest; import org.apache.geode.test.junit.categories.IntegrationTest; import org.apache.geode.test.process.ProcessWrapper; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; /** * Integration tests for launching a Server in a forked process. @@ -1445,7 +1454,7 @@ public class ServerLauncherRemoteIntegrationTest logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main exiting..."); // -System.out.println("exiting"); - System.exit(0); + ExitCode.NORMAL.doSystemExit(); } catch (Throwable t) { logWriter.info(ServerLauncherForkingProcess.class.getSimpleName() + "#main error: " + t, t); System.exit(-1); http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/test/java/org/apache/geode/internal/jta/functional/TestXACacheLoader.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/jta/functional/TestXACacheLoader.java b/geode-core/src/test/java/org/apache/geode/internal/jta/functional/TestXACacheLoader.java index 351c642..3394811 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/jta/functional/TestXACacheLoader.java +++ b/geode-core/src/test/java/org/apache/geode/internal/jta/functional/TestXACacheLoader.java @@ -14,16 +14,24 @@ */ package org.apache.geode.internal.jta.functional; -import org.apache.geode.cache.*; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import javax.naming.Context; import javax.sql.DataSource; -import javax.naming.*; +import javax.transaction.UserTransaction; -import java.sql.*; +import org.apache.geode.cache.AttributesFactory; +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.CacheLoader; +import org.apache.geode.cache.CacheLoaderException; +import org.apache.geode.cache.LoaderHelper; +import org.apache.geode.cache.Region; +import org.apache.geode.internal.ExitCode; import org.apache.geode.internal.jta.CacheUtils; -import javax.transaction.*; - /** * A <code>CacheLoader</code> used in testing. Users should override the "2" method. * @@ -81,7 +89,7 @@ public class TestXACacheLoader implements CacheLoader { utx.rollback(); System.out.println(re.get(args[0])); cache.close(); - System.exit(1); + ExitCode.FATAL.doSystemExit(); } catch (Exception e) { e.printStackTrace(); cache.close(); http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/test/java/org/apache/geode/sequence/GemfireSequenceDisplay.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/sequence/GemfireSequenceDisplay.java b/geode-core/src/test/java/org/apache/geode/sequence/GemfireSequenceDisplay.java index 4a24451..201e2c0 100644 --- a/geode-core/src/test/java/org/apache/geode/sequence/GemfireSequenceDisplay.java +++ b/geode-core/src/test/java/org/apache/geode/sequence/GemfireSequenceDisplay.java @@ -14,20 +14,38 @@ */ package org.apache.geode.sequence; -import org.apache.geode.internal.sequencelog.GraphType; -import org.apache.geode.internal.sequencelog.io.Filter; -import org.apache.geode.internal.sequencelog.io.GraphReader; -import org.apache.geode.internal.sequencelog.model.*; -import org.apache.geode.sequence.*; - -import javax.swing.*; -import java.awt.event.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.regex.Pattern; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.KeyStroke; + +import org.apache.geode.internal.ExitCode; +import org.apache.geode.internal.sequencelog.GraphType; +import org.apache.geode.internal.sequencelog.io.Filter; +import org.apache.geode.internal.sequencelog.io.GraphReader; +import org.apache.geode.internal.sequencelog.model.Edge; +import org.apache.geode.internal.sequencelog.model.Graph; +import org.apache.geode.internal.sequencelog.model.GraphID; +import org.apache.geode.internal.sequencelog.model.GraphSet; +import org.apache.geode.internal.sequencelog.model.Vertex; + /** */ public class GemfireSequenceDisplay { @@ -250,7 +268,7 @@ public class GemfireSequenceDisplay { + "\t-logs (expiremental) instead of using .graph files, parse the gemfire logs to generate the sequence display" + "\t-filterkey a java regular expression to match against key names. If specified\n" + "The list of key sequence diagrams will only contain matching keys"); - System.exit(1); + ExitCode.FATAL.doSystemExit(); return; } http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ChildVM.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ChildVM.java b/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ChildVM.java index b14ff1d..a1045f8 100644 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ChildVM.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/ChildVM.java @@ -16,15 +16,15 @@ package org.apache.geode.test.dunit.standalone; import java.rmi.Naming; +import org.apache.logging.log4j.Logger; + +import org.apache.geode.internal.ExitCode; import org.apache.geode.internal.OSProcess; import org.apache.geode.internal.Version; import org.apache.geode.internal.logging.LogService; -import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.internal.JUnit4DistributedTestCase; import org.apache.geode.test.dunit.standalone.DUnitLauncher.MasterRemote; -import org.apache.logging.log4j.Logger; - /** * */ @@ -68,7 +68,7 @@ public class ChildVM { } } catch (Throwable t) { logger.info("VM is exiting with error", t); - System.exit(1); + ExitCode.FATAL.doSystemExit(); } finally { logger.info("VM is exiting"); } http://git-wip-us.apache.org/repos/asf/geode/blob/9db5c8e5/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt ---------------------------------------------------------------------- diff --git a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt index 3232933..43220fa 100644 --- a/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt +++ b/geode-core/src/test/resources/org/apache/geode/codeAnalysis/excludedClasses.txt @@ -7,6 +7,7 @@ org/apache/geode/distributed/LocatorLauncher$Command org/apache/geode/distributed/ServerLauncher org/apache/geode/distributed/ServerLauncher$Command org/apache/geode/distributed/internal/DistributionManager +org/apache/geode/internal/ExitCode org/apache/geode/internal/JarDeployer org/apache/geode/internal/cache/BackupLock org/apache/geode/internal/logging/GemFireLevel