You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by hi...@apache.org on 2016/09/20 22:34:35 UTC
[18/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JmxManagerFinder.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JmxManagerFinder.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JmxManagerFinder.java
new file mode 100644
index 0000000..f2d211a
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JmxManagerFinder.java
@@ -0,0 +1,169 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal.data;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketAddress;
+
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import com.vmware.geode.tools.pulse.internal.util.ConnectionUtil;
+
+/**
+ * This class can be used to connect to a locator and ask it to find a jmx
+ * manager. If the locator can find a jmx manager that is already running it
+ * returns it. Otherwise the locator will attempt to start a jmx manager and
+ * then return it.
+ *
+ * This code does not depend on gemfire.jar but in order to do this some of
+ * GemFire's internal serialization codes and byte sequences have been hard
+ * coded into this code.
+ *
+ * @since GemFire version 7.0.Beta 2012-09-23
+ *
+ */
+public class JmxManagerFinder {
+
+ private final static PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+
+ /*
+ * public static void main(String[] args) throws IOException { if (args.length
+ * != 2) { System.err.println(
+ * "Usage: JmxManagerFinder locatorHost locatorPort. Expected two arguments but found "
+ * + args.length); return; } String locatorHost = args[0]; int locatorPort =
+ * Integer.parseInt(args[1]);
+ *
+ * InetAddress addr = InetAddress.getByName(locatorHost); JmxManagerInfo
+ * locRes = askLocatorForJmxManager(addr, locatorPort, 15000);
+ *
+ * if (locRes.port == 0) {
+ * System.out.println("Locator could not find a jmx manager"); } else {
+ * System.out.println("Locator on host " + locRes.host + " port " +
+ * locRes.port + (locRes.ssl ? " ssl" : "")); } }
+ */
+ private static final short JMX_MANAGER_LOCATOR_REQUEST = 2150;
+ private static final short JMX_MANAGER_LOCATOR_RESPONSE = 2151;
+ private static final byte DS_FIXED_ID_SHORT = 2;
+ private static final int GOSSIPVERSION = 1001;
+ private static final byte STRING_BYTES = 87;
+ private static final byte NULL_STRING = 69;
+
+ /**
+ * Describes the location of a jmx manager. If a jmx manager does not exist
+ * then port will be 0.
+ *
+ *
+ */
+ public static class JmxManagerInfo {
+ JmxManagerInfo(String host, int port, boolean ssl) {
+ this.host = host;
+ this.port = port;
+ this.ssl = ssl;
+ }
+
+ /**
+ * The host/address the jmx manager is listening on.
+ */
+ public final String host;
+ /**
+ * The port the jmx manager is listening on.
+ */
+ public final int port;
+ /**
+ * True if the jmx manager is using SSL.
+ */
+ public final boolean ssl;
+ }
+
+ /**
+ * Ask a locator to find a jmx manager. The locator will start one if one is
+ * not already running.
+ *
+ * @param addr
+ * the host address the locator is listening on
+ * @param port
+ * the port the locator is listening on
+ * @param timeout
+ * the number of milliseconds to wait for a response; 15000 is a
+ * reasonable default
+ * @return describes the location of the jmx manager. The port will be zero if
+ * no jmx manager was found.
+ * @throws IOException
+ * if a problem occurs trying to connect to the locator or
+ * communicate with it.
+ */
+ public static JmxManagerInfo askLocatorForJmxManager(InetAddress addr,
+ int port, int timeout, boolean usessl) throws IOException {
+ SocketAddress sockaddr = new InetSocketAddress(addr, port);
+ Socket sock = ConnectionUtil.getSocketFactory(usessl).createSocket();
+ try {
+ sock.connect(sockaddr, timeout);
+ sock.setSoTimeout(timeout);
+ DataOutputStream out = new DataOutputStream(sock.getOutputStream());
+
+ out.writeInt(GOSSIPVERSION);
+ out.writeByte(DS_FIXED_ID_SHORT);
+ out.writeShort(JMX_MANAGER_LOCATOR_REQUEST);
+ out.flush();
+
+ DataInputStream in = new DataInputStream(sock.getInputStream());
+ byte header = in.readByte();
+ if (header != DS_FIXED_ID_SHORT) {
+ throw new IllegalStateException("Expected " + DS_FIXED_ID_SHORT
+ + " but found " + header);
+ }
+ int msgType = in.readShort();
+ if (msgType != JMX_MANAGER_LOCATOR_RESPONSE) {
+ throw new IllegalStateException("Expected "
+ + JMX_MANAGER_LOCATOR_RESPONSE + " but found " + msgType);
+ }
+ byte hostHeader = in.readByte();
+ String host;
+ if (hostHeader == NULL_STRING) {
+ host = "";
+ } else if (hostHeader == STRING_BYTES) {
+ int len = in.readUnsignedShort();
+ byte[] buf = new byte[len];
+ in.readFully(buf, 0, len);
+ @SuppressWarnings("deprecation")
+ String str = new String(buf, 0);
+ host = str;
+ } else {
+ throw new IllegalStateException("Expected " + STRING_BYTES + " or "
+ + NULL_STRING + " but found " + hostHeader);
+ }
+ int jmport = in.readInt();
+ boolean ssl = in.readBoolean();
+ if (host.equals("")) {
+ jmport = 0;
+ }
+ return new JmxManagerInfo(host, jmport, ssl);
+ } finally {
+ try {
+ sock.close();
+ } catch (Exception e) {
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/PulseConfig.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/PulseConfig.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/PulseConfig.java
new file mode 100644
index 0000000..cfd6b62
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/PulseConfig.java
@@ -0,0 +1,139 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal.data;
+
+import java.util.logging.Level;
+
+/**
+ * Class PulseConfig
+ *
+ * PulseConfig is used for configuring Pulse application.
+ *
+ * @since GemFire 7.0.1
+ *
+ */
+public class PulseConfig {
+
+ // Log file name
+ private String LogFileName;
+
+ // Log file location
+ private String LogFileLocation;
+
+ // Log file size in MBs
+ private int logFileSize;
+
+ // Number of cyclic log files
+ private int logFileCount;
+
+ // Log messages date pattern
+ private String logDatePattern;
+
+ // Log level
+ private Level logLevel;
+
+ // Flag for appending log messages
+ private Boolean logAppend;
+
+ // Query history log file
+ private String queryHistoryFileName;
+
+ public PulseConfig() {
+ this.setLogFileName(PulseConstants.PULSE_LOG_FILE_NAME);
+ this.LogFileLocation = PulseConstants.PULSE_LOG_FILE_LOCATION;
+ this.logFileSize = PulseConstants.PULSE_LOG_FILE_SIZE;
+ this.logFileCount = PulseConstants.PULSE_LOG_FILE_COUNT;
+ this.logDatePattern = PulseConstants.PULSE_LOG_MESSAGE_DATE_PATTERN;
+ this.logLevel = PulseConstants.PULSE_LOG_LEVEL;
+ this.logAppend = PulseConstants.PULSE_LOG_APPEND;
+ this.queryHistoryFileName = PulseConstants.PULSE_QUERY_HISTORY_FILE_LOCATION
+ + System.getProperty("file.separator")
+ + PulseConstants.PULSE_QUERY_HISTORY_FILE_NAME;
+
+ }
+
+ public String getLogFileName() {
+ return LogFileName;
+ }
+
+ public void setLogFileName(String logFileName) {
+ this.LogFileName = logFileName + "_%g.log";
+ }
+
+ public String getLogFileLocation() {
+ return LogFileLocation;
+ }
+
+ public void setLogFileLocation(String logFileLocation) {
+ this.LogFileLocation = logFileLocation;
+ }
+
+ public String getLogFileFullName() {
+ return this.LogFileLocation + "/" + this.LogFileName;
+ }
+
+ public int getLogFileSize() {
+ return logFileSize;
+ }
+
+ public void setLogFileSize(int logFileSize) {
+ this.logFileSize = logFileSize;
+ }
+
+ public int getLogFileCount() {
+ return logFileCount;
+ }
+
+ public void setLogFileCount(int logFileCount) {
+ this.logFileCount = logFileCount;
+ }
+
+ public String getLogDatePattern() {
+ return logDatePattern;
+ }
+
+ public void setLogDatePattern(String logDatePattern) {
+ this.logDatePattern = logDatePattern;
+ }
+
+ public Level getLogLevel() {
+ return logLevel;
+ }
+
+ public void setLogLevel(Level logLevel) {
+ this.logLevel = logLevel;
+ }
+
+ public Boolean getLogAppend() {
+ return logAppend;
+ }
+
+ public void setLogAppend(Boolean logAppend) {
+ this.logAppend = logAppend;
+ }
+
+ public String getQueryHistoryFileName() {
+ return queryHistoryFileName;
+ }
+
+ public void setQueryHistoryFileName(String queryHistoryFileName) {
+ this.queryHistoryFileName = queryHistoryFileName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/PulseConstants.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/PulseConstants.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/PulseConstants.java
new file mode 100644
index 0000000..c9e711a
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/PulseConstants.java
@@ -0,0 +1,434 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal.data;
+
+import java.util.logging.Level;
+
+public class PulseConstants {
+
+ public static final String APP_NAME = "PULSE";
+ public static final String PULSE_LOG_FILE = APP_NAME + ".log";
+ // public static final String PULSE_LOG_FILE_LOCATION =
+ // System.getProperty("user.home");
+ public static final String PULSE_PROPERTIES_FILE = "pulse.properties";
+ public static final String PULSE_SECURITY_PROPERTIES_FILE = "pulsesecurity.properties";
+ public static final String PULSE_NOTIFICATION_ALERT_DATE_PATTERN = "yyyy-MM-dd'T'HH:mm'Z'";
+ public static final String LOG_MESSAGE_DATE_PATTERN = "yyyy/MM/dd HH:mm:ss.SSS z";
+
+ public static final String LOG_MESSAGES_FILE = "LogMessages";
+ public static final String APPLICATION_LANGUAGE = "en";
+ public static final String APPLICATION_COUNTRY = "US";
+
+ // Pulse version details properties from properties file
+ public static final String PULSE_VERSION_PROPERTIES_FILE = "GemFireVersion.properties";
+ public static final String PROPERTY_PULSE_VERSION = "Product-Version";
+ public static final String PROPERTY_BUILD_ID = "Build-Id";
+ public static final String PROPERTY_BUILD_DATE = "Build-Date";
+ public static final String PROPERTY_SOURCE_DATE = "Source-Date";
+ public static final String PROPERTY_SOURCE_REVISION = "Source-Revision";
+ public static final String PROPERTY_SOURCE_REPOSITORY = "Source-Repository";
+
+ // DEFAULT CONFIGUARTION VALUES FOR PULSE LOGGER
+ // Log File
+ public static final String PULSE_QUERY_HISTORY_FILE_NAME = APP_NAME
+ + "_QueryHistory.json";
+ // Log File location
+ public static final String PULSE_QUERY_HISTORY_FILE_LOCATION = System
+ .getProperty("user.home");
+ // Date pattern to be used in log messages
+ public static final String PULSE_QUERY_HISTORY_DATE_PATTERN = "EEE, MMM dd yyyy, HH:mm:ss z";
+
+ // Decimal format pattern "###.##" and "0.0000"
+ public static final String DECIMAL_FORMAT_PATTERN = "###.##";
+ public static final String DECIMAL_FORMAT_PATTERN_2 = "0.0000";
+
+ // DEFAULT VALUES
+ public static final String GEMFIRE_DEFAULT_HOST = "localhost";
+ public static final String GEMFIRE_DEFAULT_PORT = "1099";
+
+ // DEFAULT CONFIGUARTION VALUES FOR PULSE LOGGER
+ // Log File
+ public static final String PULSE_LOG_FILE_NAME = APP_NAME;
+ // Log File location
+ public static final String PULSE_LOG_FILE_LOCATION = System
+ .getProperty("user.home");
+ // Date pattern to be used in log messages
+ public static final String PULSE_LOG_MESSAGE_DATE_PATTERN = "yyyy/MM/dd HH:mm:ss.SSS z";
+ // Log file size - 1MB.
+ public static final int PULSE_LOG_FILE_SIZE = 1024 * 1024;
+ // The log file count - 4 files.
+ public static final int PULSE_LOG_FILE_COUNT = 4;
+ // Append logs - true.
+ public static final boolean PULSE_LOG_APPEND = true;
+ // Log level - FINE
+ public static final Level PULSE_LOG_LEVEL = Level.FINE;
+
+ // SYSTEM PROPERTIES
+ public static final String SYSTEM_PROPERTY_PULSE_EMBEDDED = "pulse.embedded";
+ public static final String SYSTEM_PROPERTY_PULSE_EMBEDDED_SQLF = "pulse.embedded.sqlf";
+ public static final String SYSTEM_PROPERTY_PULSE_USELOCATOR = "pulse.useLocator";
+ public static final String SYSTEM_PROPERTY_PULSE_HOST = "pulse.host";
+ public static final String SYSTEM_PROPERTY_PULSE_PORT = "pulse.port";
+
+ // APPLICATION PROPERTIES
+ public static final String APPLICATION_PROPERTY_PULSE_USELOCATOR = "pulse.useLocator";
+ public static final String APPLICATION_PROPERTY_PULSE_HOST = "pulse.host";
+ public static final String APPLICATION_PROPERTY_PULSE_PORT = "pulse.port";
+ public static final String APPLICATION_PROPERTY_PULSE_JMXUSERNAME = "pulse.jmxUserName";
+ public static final String APPLICATION_PROPERTY_PULSE_JMXPASSWORD = "pulse.jmxUserPassword";
+ public static final String APPLICATION_PROPERTY_PULSE_LOGFILENAME = "pulse.Log-File-Name";
+ public static final String APPLICATION_PROPERTY_PULSE_LOGFILELOCATION = "pulse.Log-File-Location";
+ public static final String APPLICATION_PROPERTY_PULSE_LOGFILESIZE = "pulse.Log-File-Size";
+ public static final String APPLICATION_PROPERTY_PULSE_LOGFILECOUNT = "pulse.Log-File-Count";
+ public static final String APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN = "pulse.Log-Date-Pattern";
+ public static final String APPLICATION_PROPERTY_PULSE_LOGLEVEL = "pulse.Log-Level";
+ public static final String APPLICATION_PROPERTY_PULSE_LOGAPPEND = "pulse.Log-Append";
+ public static final String APPLICATION_PROPERTY_PULSE_PRODUCTSUPPORT = "pulse.product";
+ public static final String APPLICATION_PROPERTY_PULSE_SEC_PROFILE_GEMFIRE = "pulse.authentication.gemfire";
+ public static final String APPLICATION_PROPERTY_PULSE_SEC_PROFILE_DEFAULT = "pulse.authentication.default";
+ public static final String APPLICATION_PROPERTY_PULSE_SPRING_PROFILE_KEY = "spring.profiles.default";
+
+ // STRING FLAGS
+ public static final String STRING_FLAG_TRUE = "true";
+ public static final String STRING_FLAG_FALSE = "false";
+ public static final String DEFAULT_SERVER_GROUP = "Default";
+ public static final String DEFAULT_REDUNDANCY_ZONE = "Default";
+ public static final String JVM_PAUSES_TYPE_CLUSTER = "cluster";
+ public static final String JVM_PAUSES_TYPE_MEMBER = "member";
+
+ // CONSTANTS FOR MBEAN DATA
+ public static final String OBJECT_DOMAIN_NAME_GEMFIRE = "GemFire";
+ public static final String OBJECT_DOMAIN_NAME_SQLFIRE = "GemFireXD";
+ public static final String OBJECT_NAME_MEMBER = OBJECT_DOMAIN_NAME_GEMFIRE + ":type=Member,*";
+ public static final String OBJECT_NAME_MEMBER_MANAGER = OBJECT_DOMAIN_NAME_GEMFIRE + ":service=Manager,type=Member,*";
+ public static final String OBJECT_NAME_SYSTEM_DISTRIBUTED = OBJECT_DOMAIN_NAME_GEMFIRE + ":service=System,type=Distributed";
+ public static final String OBJECT_NAME_REGION_DISTRIBUTED = OBJECT_DOMAIN_NAME_GEMFIRE + ":service=Region,type=Distributed,*";
+ public static final String OBJECT_NAME_STATEMENT_DISTRIBUTED = OBJECT_DOMAIN_NAME_SQLFIRE + ":service=Statement,type=Aggregate,*";
+ public static final String OBJECT_NAME_SF_CLUSTER = OBJECT_DOMAIN_NAME_SQLFIRE + ":service=Cluster";
+ public static final String OBJECT_NAME_SF_MEMBER_PATTERN = OBJECT_DOMAIN_NAME_SQLFIRE + ":group=*,type=Member,member=";
+ public static final String OBJECT_NAME_TABLE_AGGREGATE = OBJECT_DOMAIN_NAME_SQLFIRE + ":service=Table,type=Aggregate,table=*";
+ public static final String OBJECT_NAME_TABLE_AGGREGATE_PATTERN = OBJECT_DOMAIN_NAME_SQLFIRE + ":service=Table,type=Aggregate,table=";
+ public static final String OBJECT_NAME_REGION_ON_MEMBER_REGION = OBJECT_DOMAIN_NAME_GEMFIRE + ":service=Region,name=";
+ public static final String OBJECT_NAME_REGION_ON_MEMBER_MEMBER = ",type=Member,member=";
+ public static final String OBJECT_NAME_ACCESSCONTROL_MBEAN = "GemFire:service=AccessControl,type=Distributed";
+
+ public static final String MBEAN_KEY_PROPERTY_SERVICE = "service";
+ public static final String MBEAN_KEY_PROPERTY_SERVICE_VALUE_REGION = "Region";
+ public static final String MBEAN_KEY_PROPERTY_SERVICE_VALUE_CACHESERVER = "CacheServer";
+ public static final String MBEAN_KEY_PROPERTY_SERVICE_VALUE_GATEWAYRECEIVER = "GatewayReceiver";
+ public static final String MBEAN_KEY_PROPERTY_SERVICE_VALUE_GATEWAYSENDER = "GatewaySender";
+ public static final String MBEAN_KEY_PROPERTY_SERVICE_VALUE_ASYNCEVENTQUEUE = "AsyncEventQueue";
+ public static final String MBEAN_KEY_PROPERTY_SERVICE_VALUE_LOCATOR = "Locator";
+ public static final String MBEAN_KEY_PROPERTY_REGION_NAME = "name";
+
+ public static final String MBEAN_KEY_PROPERTY_MEMBER = "member";
+
+ public static final String MBEAN_ATTRIBUTE_MEMBER = "Member";
+ public static final String MBEAN_ATTRIBUTE_MEMBERS = "Members";
+ public static final String MBEAN_ATTRIBUTE_MANAGER = "Manager";
+ public static final String MBEAN_ATTRIBUTE_LOCATOR = "Locator";
+ public static final String MBEAN_ATTRIBUTE_SERVER = "Server";
+ public static final String MBEAN_ATTRIBUTE_SERVERGROUPS = "Groups";
+ public static final String MBEAN_ATTRIBUTE_REDUNDANCYZONES = "RedundancyZone";
+ public static final String MBEAN_ATTRIBUTE_DATASTORE = "DataStore";
+ public static final String MBEAN_ATTRIBUTE_ID = "Id";
+
+ public static final String MBEAN_ATTRIBUTE_GEMFIREVERSION = "Version";
+ public static final String MBEAN_ATTRIBUTE_MEMBERCOUNT = "MemberCount";
+ public static final String MBEAN_ATTRIBUTE_NUMCLIENTS = "NumClients";
+ public static final String MBEAN_ATTRIBUTE_NETWORKSERVERCLIENTCONNECTIONSTATS = "NetworkServerClientConnectionStats";
+ public static final String MBEAN_ATTRIBUTE_DISTRIBUTEDSYSTEMID = "DistributedSystemId";
+ public static final String MBEAN_ATTRIBUTE_LOCATORCOUNT = "LocatorCount";
+ public static final String MBEAN_ATTRIBUTE_TOTALREGIONCOUNT = "TotalRegionCount";
+ public static final String MBEAN_ATTRIBUTE_NUMRUNNIGFUNCTION = "NumRunningFunctions";
+ public static final String MBEAN_ATTRIBUTE_PROCEDURECALLSCOMPLETED = "ProcedureCallsCompleted";
+ public static final String MBEAN_ATTRIBUTE_PROCEDURECALLSINPROGRESS = "ProcedureCallsInProgress";
+ public static final String MBEAN_ATTRIBUTE_REGISTEREDCQCOUNT = "RegisteredCQCount";
+ public static final String MBEAN_ATTRIBUTE_NUMSUBSCRIPTIONS = "NumSubscriptions";
+ public static final String MBEAN_ATTRIBUTE_NUMTXNCOMMITTED = "TransactionCommitted";
+ public static final String MBEAN_ATTRIBUTE_NUMTXNROLLBACK = "TransactionRolledBack";
+ public static final String MBEAN_ATTRIBUTE_TOTALHEAPSIZE = "TotalHeapSize";
+ public static final String MBEAN_ATTRIBUTE_USEDHEAPSIZE = "UsedHeapSize";
+ public static final String MBEAN_ATTRIBUTE_OFFHEAPFREESIZE = "OffHeapFreeSize";
+ public static final String MBEAN_ATTRIBUTE_OFFHEAPUSEDSIZE = "OffHeapUsedSize";
+ public static final String MBEAN_ATTRIBUTE_TOTALREGIONENTRYCOUNT = "TotalRegionEntryCount";
+ public static final String MBEAN_ATTRIBUTE_CURRENTENTRYCOUNT = "CurrentQueryCount";
+ public static final String MBEAN_ATTRIBUTE_TOTALDISKUSAGE = "TotalDiskUsage";
+ public static final String MBEAN_ATTRIBUTE_DISKWRITESRATE = "DiskWritesRate";
+ public static final String MBEAN_ATTRIBUTE_AVERAGEWRITES = "AverageWrites";
+ public static final String MBEAN_ATTRIBUTE_DISKREADSRATE = "DiskReadsRate";
+ public static final String MBEAN_ATTRIBUTE_AVERAGEREADS = "AverageReads";
+ public static final String MBEAN_ATTRIBUTE_QUERYREQUESTRATE = "QueryRequestRate";
+ public static final String MBEAN_ATTRIBUTE_JVMPAUSES = "JVMPauses";
+ public static final String MBEAN_ATTRIBUTE_HOST = "Host";
+ public static final String MBEAN_ATTRIBUTE_HOSTNAMEFORCLIENTS = "HostnameForClients";
+ public static final String MBEAN_ATTRIBUTE_HOSTNAMEFORCLIENTS_ALT = "HostNameForClients";
+ public static final String MBEAN_ATTRIBUTE_BINDADDRESS = "BindAddress";
+ public static final String MBEAN_ATTRIBUTE_PORT = "Port";
+ public static final String MBEAN_ATTRIBUTE_EVENTRECEIVEDDATE = "EventsReceivedRate";
+ public static final String MBEAN_ATTRIBUTE_AVEARGEBATCHPROCESSINGTIME = "AverageBatchProcessingTime";
+ public static final String MBEAN_ATTRIBUTE_RUNNING = "Running";
+ public static final String MBEAN_ATTRIBUTE_BATCHSIZE = "BatchSize";
+ public static final String MBEAN_ATTRIBUTE_SENDERID = "SenderId";
+ public static final String MBEAN_ATTRIBUTE_EVENTQUEUESIZE = "EventQueueSize";
+ public static final String MBEAN_ATTRIBUTE_PRIMARY = "Primary";
+ public static final String MBEAN_ATTRIBUTE_PERSISTENCEENABLED = "PersistenceEnabled";
+ public static final String MBEAN_ATTRIBUTE_PARALLEL = "Parallel";
+ public static final String MBEAN_ATTRIBUTE_REMOTE_DS_ID = "RemoteDSId";
+ public static final String MBEAN_ATTRIBUTE_EVENTS_EXCEEDING_ALERT_THRESHOLD = "EventsExceedingAlertThreshold";
+ public static final String MBEAN_ATTRIBUTE_FULLPATH = "FullPath";
+ public static final String MBEAN_ATTRIBUTE_EMPTYNODES = "EmptyNodes";
+ public static final String MBEAN_ATTRIBUTE_GETSRATE = "GetsRate";
+ public static final String MBEAN_ATTRIBUTE_PUTSRATE = "PutsRate";
+ public static final String MBEAN_ATTRIBUTE_LRUEVICTIONRATE = "LruEvictionRate";
+ public static final String MBEAN_ATTRIBUTE_REGIONTYPE = "RegionType";
+ public static final String MBEAN_ATTRIBUTE_ENTRYSIZE = "EntrySize";
+ public static final String MBEAN_ATTRIBUTE_SYSTEMREGIONENTRYCOUNT = "SystemRegionEntryCount";
+ public static final String MBEAN_ATTRIBUTE_PERSISTENTENABLED = "PersistentEnabled";
+ public static final String MBEAN_ATTRIBUTE_NAME = "Name";
+ public static final String MBEAN_ATTRIBUTE_GATEWAYENABLED = "GatewayEnabled";
+ public static final String MBEAN_ATTRIBUTE_DISKUSAGE = "DiskUsage";
+ public static final String MBEAN_ATTRIBUTE_TOTALFILEDESCRIPTOROPEN = "TotalFileDescriptorOpen";
+ public static final String MBEAN_ATTRIBUTE_LOADAVERAGE = "LoadAverage";
+ public static final String MBEAN_ATTRIBUTE_CURRENTHEAPSIZE = "CurrentHeapSize"; // deprecated in Gemfire8.1
+ public static final String MBEAN_ATTRIBUTE_USEDMEMORY = "UsedMemory";
+ public static final String MBEAN_ATTRIBUTE_MAXIMUMHEAPSIZE = "MaximumHeapSize"; // deprecated in Gemfire8.1
+ public static final String MBEAN_ATTRIBUTE_MAXMEMORY = "MaxMemory";
+ public static final String MBEAN_ATTRIBUTE_NUMTHREADS = "NumThreads";
+ public static final String MBEAN_ATTRIBUTE_MEMBERUPTIME = "MemberUpTime";
+ public static final String MBEAN_ATTRIBUTE_TOTALBYTESONDISK = "TotalBytesOnDisk";
+ public static final String MBEAN_ATTRIBUTE_CPUUSAGE = "CpuUsage";
+ public static final String MBEAN_ATTRIBUTE_HOSTCPUUSAGE = "HostCpuUsage";
+ public static final String MBEAN_ATTRIBUTE_ENTRYCOUNT = "EntryCount";
+ public static final String MBEAN_ATTRIBUTE_NUMBEROFROWS = "NumberOfRows";
+ public static final String MBEAN_ATTRIBUTE_LOCALMAXMEMORY = "LocalMaxMemory";
+
+ public static final String MBEAN_ATTRIBUTE_NUMTIMESCOMPILED = "NumTimesCompiled";
+ public static final String MBEAN_ATTRIBUTE_NUMEXECUTION = "NumExecution";
+ public static final String MBEAN_ATTRIBUTE_NUMEXECUTIONSINPROGRESS = "NumExecutionsInProgress";
+ public static final String MBEAN_ATTRIBUTE_NUMTIMESGLOBALINDEXLOOKUP = "NumTimesGlobalIndexLookup";
+ public static final String MBEAN_ATTRIBUTE_NUMROWSMODIFIED = "NumRowsModified";
+ public static final String MBEAN_ATTRIBUTE_PARSETIME = "ParseTime";
+ public static final String MBEAN_ATTRIBUTE_BINDTIME = "BindTime";
+ public static final String MBEAN_ATTRIBUTE_OPTIMIZETIME = "OptimizeTime";
+ public static final String MBEAN_ATTRIBUTE_ROUTINGINFOTIME = "RoutingInfoTime";
+ public static final String MBEAN_ATTRIBUTE_GENERATETIME = "GenerateTime";
+ public static final String MBEAN_ATTRIBUTE_TOTALCOMPILATIONTIME = "TotalCompilationTime";
+ public static final String MBEAN_ATTRIBUTE_EXECUTIONTIME = "ExecutionTime";
+ public static final String MBEAN_ATTRIBUTE_PROJECTIONTIME = "ProjectionTime";
+ public static final String MBEAN_ATTRIBUTE_TOTALEXECUTIONTIME = "TotalExecutionTime";
+ public static final String MBEAN_ATTRIBUTE_ROWSMODIFICATIONTIME = "RowsModificationTime";
+ public static final String MBEAN_ATTRIBUTE_QNNUMROWSSEEN = "QNNumRowsSeen";
+ public static final String MBEAN_ATTRIBUTE_QNMSGSENDTIME = "QNMsgSendTime";
+ public static final String MBEAN_ATTRIBUTE_QNMSGSERTIME = "QNMsgSerTime";
+ public static final String MBEAN_ATTRIBUTE_QNRESPDESERTIME = "QNRespDeSerTime";
+ public static final String MBEAN_ATTRIBUTE_QUERYDEFINITION = "Query";
+
+ public static final String MBEAN_ATTRIBUTE_AEQ_ASYNCEVENTID = "Id";
+ public static final String MBEAN_ATTRIBUTE_AEQ_PRIMARY = "Primary";
+ public static final String MBEAN_ATTRIBUTE_AEQ_PARALLEL = "Parallel";
+ public static final String MBEAN_ATTRIBUTE_AEQ_BATCH_SIZE = "BatchSize";
+ public static final String MBEAN_ATTRIBUTE_AEQ_BATCH_TIME_INTERVAL = "BatchTimeInterval";
+ public static final String MBEAN_ATTRIBUTE_AEQ_BATCH_CONFLATION_ENABLED = "BatchConflationEnabled";
+ public static final String MBEAN_ATTRIBUTE_AEQ_ASYNC_EVENT_LISTENER = "AsyncEventListener";
+ public static final String MBEAN_ATTRIBUTE_AEQ_EVENT_QUEUE_SIZE = "EventQueueSize";
+
+ // column names
+ public static final String MBEAN_COLNAME_NUMTIMESCOMPILED = "NumTimesCompiled";
+ public static final String MBEAN_COLNAME_NUMEXECUTION = "NumExecution";
+ public static final String MBEAN_COLNAME_NUMEXECUTIONSINPROGRESS = "NumExecutionsInProgress";
+ public static final String MBEAN_COLNAME_NUMTIMESGLOBALINDEXLOOKUP = "NumTimesGlobalIndexLookup";
+ public static final String MBEAN_COLNAME_NUMROWSMODIFIED = "NumRowsModified";
+ public static final String MBEAN_COLNAME_PARSETIME = "ParseTime(ms)";
+ public static final String MBEAN_COLNAME_BINDTIME = "BindTime(ms)";
+ public static final String MBEAN_COLNAME_OPTIMIZETIME = "OptimizeTime(ms)";
+ public static final String MBEAN_COLNAME_ROUTINGINFOTIME = "RoutingInfoTime(ms)";
+ public static final String MBEAN_COLNAME_GENERATETIME = "GenerateTime(ms)";
+ public static final String MBEAN_COLNAME_TOTALCOMPILATIONTIME = "TotalCompilationTime(ms)";
+ public static final String MBEAN_COLNAME_EXECUTIONTIME = "ExecutionTime(ns)";
+ public static final String MBEAN_COLNAME_PROJECTIONTIME = "ProjectionTime(ns)";
+ public static final String MBEAN_COLNAME_TOTALEXECUTIONTIME = "TotalExecutionTime(ns)";
+ public static final String MBEAN_COLNAME_ROWSMODIFICATIONTIME = "RowsModificationTime(ns)";
+ public static final String MBEAN_COLNAME_QNNUMROWSSEEN = "QNNumRowsSeen";
+ public static final String MBEAN_COLNAME_QNMSGSENDTIME = "QNMsgSendTime(ns)";
+ public static final String MBEAN_COLNAME_QNMSGSERTIME = "QNMsgSerTime(ns)";
+ public static final String MBEAN_COLNAME_QNRESPDESERTIME = "QNRespDeSerTime(ns)";
+ public static final String MBEAN_COLNAME_QUERYDEFINITION = "Query";
+
+ // TODO : add attributes for aggregate statistics
+ // public static final String MBEAN_ATTRIBUTE_ENTRYCOUNT = "EntryCount";
+
+ public static final String MBEAN_MANAGER_ATTRIBUTE_PULSEURL = "PulseURL";
+
+ public static final String MBEAN_OPERATION_LISTCACHESERVER = "listCacheServers";
+ public static final String MBEAN_OPERATION_LISTSERVERS = "listServers";
+ public static final String MBEAN_OPERATION_VIEWREMOTECLUSTERSTATUS = "viewRemoteClusterStatus";
+ public static final String MBEAN_OPERATION_SHOWALLCLIENTS = "showAllClientStats";
+ public static final String MBEAN_OPERATION_LISTREGIONATTRIBUTES = "listRegionAttributes";
+ public static final String MBEAN_OPERATION_QUERYDATABROWSER = "queryData";
+
+ // COMPOSITE DATA KEYS
+ public static final String COMPOSITE_DATA_KEY_CLIENTID = "clientId";
+ public static final String COMPOSITE_DATA_KEY_NAME = "name";
+ public static final String COMPOSITE_DATA_KEY_HOSTNAME = "hostName";
+ public static final String COMPOSITE_DATA_KEY_QUEUESIZE = "queueSize";
+ public static final String COMPOSITE_DATA_KEY_PROCESSCPUTIME = "processCpuTime";
+ public static final String COMPOSITE_DATA_KEY_UPTIME = "upTime";
+ public static final String COMPOSITE_DATA_KEY_NUMOFTHREADS = "numOfThreads";
+ public static final String COMPOSITE_DATA_KEY_NUMOFGETS = "numOfGets";
+ public static final String COMPOSITE_DATA_KEY_NUMOFPUTS = "numOfPuts";
+ public static final String COMPOSITE_DATA_KEY_CPUS = "cpus";
+ public static final String COMPOSITE_DATA_KEY_CLIENTCQCOUNT = "clientCQCount";
+ public static final String COMPOSITE_DATA_KEY_SUBSCRIPTIONENABLED = "subscriptionEnabled";
+ public static final String COMPOSITE_DATA_KEY_SCOPE = "scope";
+ public static final String COMPOSITE_DATA_KEY_DISKSTORENAME = "diskStoreName";
+ public static final String COMPOSITE_DATA_KEY_DISKSYNCHRONOUS = "diskSynchronous";
+ public static final String COMPOSITE_DATA_KEY_COMPRESSIONCODEC = "compressionCodec";
+ public static final String COMPOSITE_DATA_KEY_ENABLEOFFHEAPMEMORY = "enableOffHeapMemory";
+ public static final String COMPOSITE_DATA_KEY_CONNECTIONSACTIVE = "connectionsActive";
+ public static final String COMPOSITE_DATA_KEY_CONNECTED = "connected";
+
+ public static final String ALERT_DESC_SEVERE = "Severe Alert! The cluster is on fire !";
+ public static final String ALERT_DESC_ERROR = "Error Alert! There is a problem with your cluster ! Better fix it !";
+ public static final String ALERT_DESC_WARNING = "Warning Alert! Look at this cluster after you finish your coffee !";
+ public static final String ALERT_DESC_INFO = "Info Alert! For your kind information !";
+
+ public static final String NOTIFICATION_TYPE_SYSTEM_ALERT = "system.alert";
+ public static final String NOTIFICATION_TYPE_CACHE_MEMBER_DEPARTED = "gemfire.distributedsystem.cache.member.departed";
+ public static final String NOTIFICATION_TYPE_REGION_DESTROYED = "gemfire.distributedsystem.cache.region.closed";
+
+ public static final String PRODUCT_NAME_GEMFIRE = "gemfire"; // For GemFire
+ public static final String PRODUCT_NAME_SQLFIRE = "gemfirexd"; // For SQLFire
+
+ //Following attributes are not present in 9.0
+ //"Members"
+ //"EmptyNodes"
+ //"SystemRegionEntryCount"
+ //"MemberCount"
+ public static final String[] REGION_MBEAN_ATTRIBUTES = {
+ MBEAN_ATTRIBUTE_MEMBERS, MBEAN_ATTRIBUTE_FULLPATH,
+ MBEAN_ATTRIBUTE_DISKREADSRATE, MBEAN_ATTRIBUTE_DISKWRITESRATE,
+ MBEAN_ATTRIBUTE_EMPTYNODES, MBEAN_ATTRIBUTE_GETSRATE,
+ MBEAN_ATTRIBUTE_LRUEVICTIONRATE, MBEAN_ATTRIBUTE_PUTSRATE,
+ MBEAN_ATTRIBUTE_REGIONTYPE, MBEAN_ATTRIBUTE_ENTRYSIZE,
+ MBEAN_ATTRIBUTE_ENTRYCOUNT, MBEAN_ATTRIBUTE_SYSTEMREGIONENTRYCOUNT,
+ MBEAN_ATTRIBUTE_MEMBERCOUNT, MBEAN_ATTRIBUTE_PERSISTENTENABLED,
+ MBEAN_ATTRIBUTE_NAME, MBEAN_ATTRIBUTE_GATEWAYENABLED,
+ MBEAN_ATTRIBUTE_DISKUSAGE, MBEAN_ATTRIBUTE_LOCALMAXMEMORY };
+
+ public static final String[] CLUSTER_MBEAN_ATTRIBUTES = {
+ MBEAN_ATTRIBUTE_MEMBERCOUNT, MBEAN_ATTRIBUTE_NUMCLIENTS,
+ MBEAN_ATTRIBUTE_DISTRIBUTEDSYSTEMID, MBEAN_ATTRIBUTE_LOCATORCOUNT,
+ MBEAN_ATTRIBUTE_TOTALREGIONCOUNT, MBEAN_ATTRIBUTE_NUMRUNNIGFUNCTION,
+ MBEAN_ATTRIBUTE_REGISTEREDCQCOUNT, MBEAN_ATTRIBUTE_NUMSUBSCRIPTIONS,
+ MBEAN_ATTRIBUTE_NUMTXNCOMMITTED, MBEAN_ATTRIBUTE_NUMTXNROLLBACK,
+ MBEAN_ATTRIBUTE_TOTALHEAPSIZE, MBEAN_ATTRIBUTE_USEDHEAPSIZE,
+ MBEAN_ATTRIBUTE_TOTALREGIONENTRYCOUNT, MBEAN_ATTRIBUTE_CURRENTENTRYCOUNT,
+ MBEAN_ATTRIBUTE_TOTALDISKUSAGE, MBEAN_ATTRIBUTE_DISKWRITESRATE,
+ MBEAN_ATTRIBUTE_AVERAGEWRITES, MBEAN_ATTRIBUTE_AVERAGEREADS,
+ MBEAN_ATTRIBUTE_QUERYREQUESTRATE, MBEAN_ATTRIBUTE_DISKREADSRATE,
+ MBEAN_ATTRIBUTE_JVMPAUSES };
+
+ public static final String[] GATEWAY_MBEAN_ATTRIBUTES = {
+ MBEAN_ATTRIBUTE_PORT, MBEAN_ATTRIBUTE_EVENTRECEIVEDDATE,
+ MBEAN_ATTRIBUTE_AVEARGEBATCHPROCESSINGTIME, MBEAN_ATTRIBUTE_RUNNING };
+
+ public static final String[] GATEWAYSENDER_MBEAN_ATTRIBUTES = {
+ MBEAN_ATTRIBUTE_EVENTRECEIVEDDATE, MBEAN_ATTRIBUTE_BATCHSIZE,
+ MBEAN_ATTRIBUTE_SENDERID, MBEAN_ATTRIBUTE_EVENTQUEUESIZE,
+ MBEAN_ATTRIBUTE_RUNNING, MBEAN_ATTRIBUTE_PRIMARY,
+ MBEAN_ATTRIBUTE_PERSISTENCEENABLED, MBEAN_ATTRIBUTE_PARALLEL,
+ MBEAN_ATTRIBUTE_REMOTE_DS_ID, MBEAN_ATTRIBUTE_EVENTS_EXCEEDING_ALERT_THRESHOLD};
+
+ public static final String[] ASYNC_EVENT_QUEUE_MBEAN_ATTRIBUTES = {
+ MBEAN_ATTRIBUTE_AEQ_ASYNCEVENTID, MBEAN_ATTRIBUTE_AEQ_PRIMARY,
+ MBEAN_ATTRIBUTE_AEQ_PARALLEL, MBEAN_ATTRIBUTE_AEQ_BATCH_SIZE,
+ MBEAN_ATTRIBUTE_AEQ_BATCH_TIME_INTERVAL, MBEAN_ATTRIBUTE_AEQ_BATCH_CONFLATION_ENABLED,
+ MBEAN_ATTRIBUTE_AEQ_ASYNC_EVENT_LISTENER, MBEAN_ATTRIBUTE_AEQ_EVENT_QUEUE_SIZE};
+
+ public static final String[] MEMBER_MBEAN_ATTRIBUTES = {
+ MBEAN_ATTRIBUTE_MANAGER, MBEAN_ATTRIBUTE_TOTALREGIONCOUNT,
+ MBEAN_ATTRIBUTE_LOCATOR, MBEAN_ATTRIBUTE_TOTALDISKUSAGE,
+ MBEAN_ATTRIBUTE_SERVER, MBEAN_ATTRIBUTE_TOTALFILEDESCRIPTOROPEN,
+ MBEAN_ATTRIBUTE_LOADAVERAGE, MBEAN_ATTRIBUTE_DISKWRITESRATE,
+ MBEAN_ATTRIBUTE_DISKREADSRATE, MBEAN_ATTRIBUTE_JVMPAUSES,
+ MBEAN_ATTRIBUTE_USEDMEMORY, MBEAN_ATTRIBUTE_MAXMEMORY,
+ MBEAN_ATTRIBUTE_NUMTHREADS, MBEAN_ATTRIBUTE_MEMBERUPTIME,
+ MBEAN_ATTRIBUTE_HOST, MBEAN_ATTRIBUTE_HOSTNAMEFORCLIENTS,
+ MBEAN_ATTRIBUTE_BINDADDRESS, MBEAN_ATTRIBUTE_TOTALBYTESONDISK,
+ MBEAN_ATTRIBUTE_CPUUSAGE, MBEAN_ATTRIBUTE_HOSTCPUUSAGE,
+ MBEAN_ATTRIBUTE_MEMBER, MBEAN_ATTRIBUTE_ID, MBEAN_ATTRIBUTE_AVERAGEREADS,
+ MBEAN_ATTRIBUTE_AVERAGEWRITES, MBEAN_ATTRIBUTE_OFFHEAPFREESIZE,
+ MBEAN_ATTRIBUTE_OFFHEAPUSEDSIZE, MBEAN_ATTRIBUTE_SERVERGROUPS,
+ MBEAN_ATTRIBUTE_REDUNDANCYZONES, MBEAN_ATTRIBUTE_GEMFIREVERSION };
+
+ public static final String[] STATEMENT_MBEAN_ATTRIBUTES = {
+ MBEAN_ATTRIBUTE_NAME, MBEAN_ATTRIBUTE_NUMTIMESCOMPILED,
+ MBEAN_ATTRIBUTE_NUMEXECUTION, MBEAN_ATTRIBUTE_NUMEXECUTIONSINPROGRESS,
+ MBEAN_ATTRIBUTE_NUMTIMESGLOBALINDEXLOOKUP,
+ MBEAN_ATTRIBUTE_NUMROWSMODIFIED, MBEAN_ATTRIBUTE_PARSETIME,
+ MBEAN_ATTRIBUTE_BINDTIME, MBEAN_ATTRIBUTE_OPTIMIZETIME,
+ MBEAN_ATTRIBUTE_ROUTINGINFOTIME, MBEAN_ATTRIBUTE_GENERATETIME,
+ MBEAN_ATTRIBUTE_TOTALCOMPILATIONTIME, MBEAN_ATTRIBUTE_EXECUTIONTIME,
+ MBEAN_ATTRIBUTE_PROJECTIONTIME, MBEAN_ATTRIBUTE_TOTALEXECUTIONTIME,
+ MBEAN_ATTRIBUTE_ROWSMODIFICATIONTIME, MBEAN_ATTRIBUTE_QNNUMROWSSEEN,
+ MBEAN_ATTRIBUTE_QNMSGSENDTIME, MBEAN_ATTRIBUTE_QNMSGSERTIME };
+
+ public static final String[] REGION_ON_MEMBER_MBEAN_ATTRIBUTES = {
+ MBEAN_ATTRIBUTE_ENTRYSIZE,
+ MBEAN_ATTRIBUTE_ENTRYCOUNT,
+ MBEAN_ATTRIBUTE_PUTSRATE,
+ MBEAN_ATTRIBUTE_GETSRATE,
+ MBEAN_ATTRIBUTE_DISKREADSRATE,
+ MBEAN_ATTRIBUTE_DISKWRITESRATE,
+ MBEAN_ATTRIBUTE_LOCALMAXMEMORY
+ };
+
+ public static final String[] SF_CLUSTER_MBEAN_ATTRIBUTES = {
+ MBEAN_ATTRIBUTE_PROCEDURECALLSINPROGRESS,
+ MBEAN_ATTRIBUTE_NETWORKSERVERCLIENTCONNECTIONSTATS };
+
+ public static final String[] SF_MEMBER_MBEAN_ATTRIBUTES = {
+ MBEAN_ATTRIBUTE_DATASTORE,
+ MBEAN_ATTRIBUTE_NETWORKSERVERCLIENTCONNECTIONSTATS };
+
+ public static final String[] SF_TABLE_MBEAN_ATTRIBUTES = {
+ MBEAN_ATTRIBUTE_ENTRYSIZE, MBEAN_ATTRIBUTE_NUMBEROFROWS };
+
+ public static final String PULSE_ROLES[] = {
+ "CLUSTER:READ",
+ "DATA:READ"
+ };
+
+ // SSL Related attributes
+
+ public static final String SSL_KEYSTORE = "javax.net.ssl.keyStore";
+ public static final String SSL_KEYSTORE_PASSWORD = "javax.net.ssl.keyStorePassword";
+ public static final String SSL_TRUSTSTORE = "javax.net.ssl.trustStore";
+ public static final String SSL_TRUSTSTORE_PASSWORD = "javax.net.ssl.trustStorePassword";
+ public static final String SSL_ENABLED_CIPHERS = "javax.rmi.ssl.client.enabledCipherSuites";
+ public static final String SSL_ENABLED_PROTOCOLS = "javax.rmi.ssl.client.enabledProtocols";
+
+ public static final String SYSTEM_PROPERTY_PULSE_USESSL_LOCATOR = "pulse.useSSL.locator";
+ public static final String SYSTEM_PROPERTY_PULSE_USESSL_MANAGER = "pulse.useSSL.manager";
+
+ public static final String REQUEST_PARAM_REGION_FULL_PATH = "regionFullPath";
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/PulseVersion.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/PulseVersion.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/PulseVersion.java
new file mode 100644
index 0000000..e7b62a2
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/PulseVersion.java
@@ -0,0 +1,103 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal.data;
+
+import java.util.ResourceBundle;
+
+/**
+ * Class PulseVersion
+ *
+ * This class is for holding Pulse Applications Version's details (like version
+ * details, build details, source details, etc) from properties file
+ *
+ * @since GemFire version Helios
+ */
+
+public class PulseVersion {
+
+ private String pulseVersion;
+
+ public String getPulseVersion() {
+ return pulseVersion;
+ }
+
+ public void setPulseVersion(String pulseVersion) {
+ this.pulseVersion = pulseVersion;
+ }
+
+ private String pulseBuildId;
+
+ public String getPulseBuildId() {
+ return pulseBuildId;
+ }
+
+ public void setPulseBuildId(String pulseBuildId) {
+ this.pulseBuildId = pulseBuildId;
+ }
+
+ private String pulseBuildDate;
+
+ public String getPulseBuildDate() {
+ return pulseBuildDate;
+ }
+
+ public void setPulseBuildDate(String pulseBuildDate) {
+ this.pulseBuildDate = pulseBuildDate;
+ }
+
+ private String pulseSourceDate;
+
+ public String getPulseSourceDate() {
+ return pulseSourceDate;
+ }
+
+ public void setPulseSourceDate(String pulseSourceDate) {
+ this.pulseSourceDate = pulseSourceDate;
+ }
+
+ private String pulseSourceRevision;
+
+ public String getPulseSourceRevision() {
+ return pulseSourceRevision;
+ }
+
+ public void setPulseSourceRevision(String pulseSourceRevision) {
+ this.pulseSourceRevision = pulseSourceRevision;
+ }
+
+ private String pulseSourceRepository;
+
+ public String getPulseSourceRepository() {
+ return pulseSourceRepository;
+ }
+
+ public void setPulseSourceRepository(String pulseSourceRepository) {
+ this.pulseSourceRepository = pulseSourceRepository;
+ }
+
+ public String getPulseVersionLogMessage() {
+ ResourceBundle resourceBundle = Repository.get().getResourceBundle();
+ String logMessage = resourceBundle.getString("LOG_MSG_PULSE_VERSION") + " "
+ + this.getPulseVersion() + " " + this.getPulseBuildId() + " "
+ + this.getPulseBuildDate();
+ return logMessage;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java
new file mode 100644
index 0000000..8eea7cc
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Repository.java
@@ -0,0 +1,246 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal.data;
+
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+import java.net.ConnectException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+/**
+ * A Singleton instance of the memory cache for clusters.
+ *
+ * @since GemFire version 7.0.Beta 2012-09-23
+ */
+public class Repository {
+ private PulseLogWriter LOGGER;
+
+ private static Repository instance = new Repository();
+ private HashMap<String, Cluster> clusterMap = new HashMap<String, Cluster>();
+ private Boolean jmxUseLocator;
+ private String jmxHost;
+ private String jmxPort;
+ private String jmxUserName;
+ private String jmxUserPassword;
+ private Boolean isEmbeddedMode;
+ private boolean useSSLLocator = false;
+ private boolean useSSLManager = false;
+ private boolean useGemFireCredentials = false;
+
+
+ private String pulseWebAppUrl;
+
+ Locale locale = new Locale(PulseConstants.APPLICATION_LANGUAGE,
+ PulseConstants.APPLICATION_COUNTRY);
+
+ private ResourceBundle resourceBundle = ResourceBundle.getBundle(
+ PulseConstants.LOG_MESSAGES_FILE, locale);
+
+ private PulseConfig pulseConfig = new PulseConfig();
+
+ private Repository() {
+
+ }
+
+ public static Repository get() {
+ return instance;
+ }
+
+ public Boolean getJmxUseLocator() {
+ return this.jmxUseLocator;
+ }
+
+ public void setJmxUseLocator(Boolean jmxUseLocator) {
+ this.jmxUseLocator = jmxUseLocator;
+ }
+
+ public String getJmxHost() {
+ return this.jmxHost;
+ }
+
+ public void setJmxHost(String jmxHost) {
+ this.jmxHost = jmxHost;
+ }
+
+ public String getJmxPort() {
+ return this.jmxPort;
+ }
+
+ public void setJmxPort(String jmxPort) {
+ this.jmxPort = jmxPort;
+ }
+
+ public String getJmxUserName() {
+ return this.jmxUserName;
+ }
+
+ public void setJmxUserName(String jmxUserName) {
+ this.jmxUserName = jmxUserName;
+ }
+
+ public String getJmxUserPassword() {
+ return this.jmxUserPassword;
+ }
+
+ public void setJmxUserPassword(String jmxUserPassword) {
+ this.jmxUserPassword = jmxUserPassword;
+ }
+
+ public Boolean getIsEmbeddedMode() {
+ return this.isEmbeddedMode;
+ }
+
+ public void setIsEmbeddedMode(Boolean isEmbeddedMode) {
+ this.isEmbeddedMode = isEmbeddedMode;
+ }
+
+ public boolean isUseSSLLocator() {
+ return useSSLLocator;
+ }
+
+ public void setUseSSLLocator(boolean useSSLLocator) {
+ this.useSSLLocator = useSSLLocator;
+ }
+
+ public boolean isUseSSLManager() {
+ return useSSLManager;
+ }
+
+ public void setUseSSLManager(boolean useSSLManager) {
+ this.useSSLManager = useSSLManager;
+ }
+
+ public String getPulseWebAppUrl() {
+ return this.pulseWebAppUrl;
+ }
+
+ public void setPulseWebAppUrl(String pulseWebAppUrl) {
+ this.pulseWebAppUrl = pulseWebAppUrl;
+ }
+
+ public PulseConfig getPulseConfig() {
+ return this.pulseConfig;
+ }
+
+ public void setPulseConfig(PulseConfig pulseConfig) {
+ this.pulseConfig = pulseConfig;
+ }
+
+ /**
+ * we're maintaining a 1:1 mapping between webapp and cluster, there is no need for a map of clusters based on the host and port
+ * We are using this clusterMap to maintain cluster for different users now.
+ * For a single-user connection to gemfire JMX, we will use the default username/password in the pulse.properties
+ * (# JMX User Properties )
+ * pulse.jmxUserName=admin
+ * pulse.jmxUserPassword=admin
+ *
+ * But for multi-user connections to gemfireJMX, i.e pulse that uses gemfire integrated security, we will need to get the username form the context
+ */
+ public Cluster getCluster() {
+ String username = null;
+ String password = null;
+ if(useGemFireCredentials) {
+ Authentication auth = SecurityContextHolder.getContext().getAuthentication();
+ if(auth!=null) {
+ username = auth.getName();
+ password = (String) auth.getCredentials();
+ }
+ }
+ else{
+ username = this.jmxUserName;
+ password = this.jmxUserPassword;
+ }
+ return this.getCluster(username, password);
+ }
+
+ public Cluster getCluster(String username, String password) {
+ synchronized (this.clusterMap) {
+ String key = username;
+ Cluster data = this.clusterMap.get(key);
+
+ LOGGER = PulseLogWriter.getLogger();
+
+ if (data == null) {
+ try {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_CREATE_NEW_THREAD")
+ + " : " + key);
+ }
+ data = new Cluster(this.jmxHost, this.jmxPort, username, password);
+ // Assign name to thread created
+ data.setName(PulseConstants.APP_NAME + "-" + this.jmxHost + ":" + this.jmxPort + ":" + username);
+ // Start Thread
+ data.start();
+ this.clusterMap.put(key, data);
+ } catch (ConnectException e) {
+ data = null;
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine(e.getMessage());
+ }
+ }
+ }
+ return data;
+ }
+ }
+
+ private String getClusterKey(String host, String port) {
+ return host + ":" + port;
+ }
+
+ // This method is used to remove all cluster threads
+ public void removeAllClusters() {
+
+ Iterator<Map.Entry<String, Cluster>> iter = clusterMap.entrySet()
+ .iterator();
+
+ while (iter.hasNext()) {
+ Map.Entry<String, Cluster> entry = iter.next();
+ Cluster c = entry.getValue();
+ String clusterKey = entry.getKey();
+ c.stopThread();
+ iter.remove();
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_REMOVE_THREAD") + " : "
+ + clusterKey.toString());
+ }
+ }
+ }
+
+ public ResourceBundle getResourceBundle() {
+ return this.resourceBundle;
+ }
+
+ public boolean isUseGemFireCredentials() {
+ return useGemFireCredentials;
+ }
+
+ public void setUseGemFireCredentials(boolean useGemFireCredentials) {
+ this.useGemFireCredentials = useGemFireCredentials;
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/CDL.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/CDL.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/CDL.java
new file mode 100644
index 0000000..56ffeb8
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/CDL.java
@@ -0,0 +1,274 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal.json;
+
+/**
+ * This provides static methods to convert comma delimited text into a
+ * JSONArray, and to covert a JSONArray into comma delimited text. Comma
+ * delimited text is a very popular format for data interchange. It is
+ * understood by most database, spreadsheet, and organizer programs.
+ * <p>
+ * Each row of text represents a row in a table or a data record. Each row
+ * ends with a NEWLINE character. Each row contains one or more values.
+ * Values are separated by commas. A value can contain any character except
+ * for comma, unless is is wrapped in single quotes or double quotes.
+ * <p>
+ * The first row usually contains the names of the columns.
+ * <p>
+ * A comma delimited list can be converted into a JSONArray of JSONObjects.
+ * The names for the elements in the JSONObjects can be taken from the names
+ * in the first row.
+ * @author JSON.org
+ * @version 2010-12-24
+ */
+public class CDL {
+
+ /**
+ * Get the next value. The value can be wrapped in quotes. The value can
+ * be empty.
+ * @param x A JSONTokener of the source text.
+ * @return The value string, or null if empty.
+ * @throws JSONException if the quoted string is badly formed.
+ */
+ private static String getValue(JSONTokener x) throws JSONException {
+ char c;
+ char q;
+ StringBuffer sb;
+ do {
+ c = x.next();
+ } while (c == ' ' || c == '\t');
+ switch (c) {
+ case 0:
+ return null;
+ case '"':
+ case '\'':
+ q = c;
+ sb = new StringBuffer();
+ for (;;) {
+ c = x.next();
+ if (c == q) {
+ break;
+ }
+ if (c == 0 || c == '\n' || c == '\r') {
+ throw x.syntaxError("Missing close quote '" + q + "'.");
+ }
+ sb.append(c);
+ }
+ return sb.toString();
+ case ',':
+ x.back();
+ return "";
+ default:
+ x.back();
+ return x.nextTo(',');
+ }
+ }
+
+ /**
+ * Produce a JSONArray of strings from a row of comma delimited values.
+ * @param x A JSONTokener of the source text.
+ * @return A JSONArray of strings.
+ * @throws JSONException
+ */
+ public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException {
+ JSONArray ja = new JSONArray();
+ for (;;) {
+ String value = getValue(x);
+ char c = x.next();
+ if (value == null ||
+ (ja.length() == 0 && value.length() == 0 && c != ',')) {
+ return null;
+ }
+ ja.put(value);
+ for (;;) {
+ if (c == ',') {
+ break;
+ }
+ if (c != ' ') {
+ if (c == '\n' || c == '\r' || c == 0) {
+ return ja;
+ }
+ throw x.syntaxError("Bad character '" + c + "' (" +
+ (int)c + ").");
+ }
+ c = x.next();
+ }
+ }
+ }
+
+ /**
+ * Produce a JSONObject from a row of comma delimited text, using a
+ * parallel JSONArray of strings to provides the names of the elements.
+ * @param names A JSONArray of names. This is commonly obtained from the
+ * first row of a comma delimited text file using the rowToJSONArray
+ * method.
+ * @param x A JSONTokener of the source text.
+ * @return A JSONObject combining the names and values.
+ * @throws JSONException
+ */
+ public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x)
+ throws JSONException {
+ JSONArray ja = rowToJSONArray(x);
+ return ja != null ? ja.toJSONObject(names) : null;
+ }
+
+ /**
+ * Produce a comma delimited text row from a JSONArray. Values containing
+ * the comma character will be quoted. Troublesome characters may be
+ * removed.
+ * @param ja A JSONArray of strings.
+ * @return A string ending in NEWLINE.
+ */
+ public static String rowToString(JSONArray ja) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < ja.length(); i += 1) {
+ if (i > 0) {
+ sb.append(',');
+ }
+ Object object = ja.opt(i);
+ if (object != null) {
+ String string = object.toString();
+ if (string.length() > 0 && (string.indexOf(',') >= 0 ||
+ string.indexOf('\n') >= 0 || string.indexOf('\r') >= 0 ||
+ string.indexOf(0) >= 0 || string.charAt(0) == '"')) {
+ sb.append('"');
+ int length = string.length();
+ for (int j = 0; j < length; j += 1) {
+ char c = string.charAt(j);
+ if (c >= ' ' && c != '"') {
+ sb.append(c);
+ }
+ }
+ sb.append('"');
+ } else {
+ sb.append(string);
+ }
+ }
+ }
+ sb.append('\n');
+ return sb.toString();
+ }
+
+ /**
+ * Produce a JSONArray of JSONObjects from a comma delimited text string,
+ * using the first row as a source of names.
+ * @param string The comma delimited text.
+ * @return A JSONArray of JSONObjects.
+ * @throws JSONException
+ */
+ public static JSONArray toJSONArray(String string) throws JSONException {
+ return toJSONArray(new JSONTokener(string));
+ }
+
+ /**
+ * Produce a JSONArray of JSONObjects from a comma delimited text string,
+ * using the first row as a source of names.
+ * @param x The JSONTokener containing the comma delimited text.
+ * @return A JSONArray of JSONObjects.
+ * @throws JSONException
+ */
+ public static JSONArray toJSONArray(JSONTokener x) throws JSONException {
+ return toJSONArray(rowToJSONArray(x), x);
+ }
+
+ /**
+ * Produce a JSONArray of JSONObjects from a comma delimited text string
+ * using a supplied JSONArray as the source of element names.
+ * @param names A JSONArray of strings.
+ * @param string The comma delimited text.
+ * @return A JSONArray of JSONObjects.
+ * @throws JSONException
+ */
+ public static JSONArray toJSONArray(JSONArray names, String string)
+ throws JSONException {
+ return toJSONArray(names, new JSONTokener(string));
+ }
+
+ /**
+ * Produce a JSONArray of JSONObjects from a comma delimited text string
+ * using a supplied JSONArray as the source of element names.
+ * @param names A JSONArray of strings.
+ * @param x A JSONTokener of the source text.
+ * @return A JSONArray of JSONObjects.
+ * @throws JSONException
+ */
+ public static JSONArray toJSONArray(JSONArray names, JSONTokener x)
+ throws JSONException {
+ if (names == null || names.length() == 0) {
+ return null;
+ }
+ JSONArray ja = new JSONArray();
+ for (;;) {
+ JSONObject jo = rowToJSONObject(names, x);
+ if (jo == null) {
+ break;
+ }
+ ja.put(jo);
+ }
+ if (ja.length() == 0) {
+ return null;
+ }
+ return ja;
+ }
+
+
+ /**
+ * Produce a comma delimited text from a JSONArray of JSONObjects. The
+ * first row will be a list of names obtained by inspecting the first
+ * JSONObject.
+ * @param ja A JSONArray of JSONObjects.
+ * @return A comma delimited text.
+ * @throws JSONException
+ */
+ public static String toString(JSONArray ja) throws JSONException {
+ JSONObject jo = ja.optJSONObject(0);
+ if (jo != null) {
+ JSONArray names = jo.names();
+ if (names != null) {
+ return rowToString(names) + toString(names, ja);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Produce a comma delimited text from a JSONArray of JSONObjects using
+ * a provided list of names. The list of names is not included in the
+ * output.
+ * @param names A JSONArray of strings.
+ * @param ja A JSONArray of JSONObjects.
+ * @return A comma delimited text.
+ * @throws JSONException
+ */
+ public static String toString(JSONArray names, JSONArray ja)
+ throws JSONException {
+ if (names == null || names.length() == 0) {
+ return null;
+ }
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < ja.length(); i += 1) {
+ JSONObject jo = ja.optJSONObject(i);
+ if (jo != null) {
+ sb.append(rowToString(jo.toJSONArray(names)));
+ }
+ }
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/Cookie.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/Cookie.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/Cookie.java
new file mode 100644
index 0000000..8e208f0
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/Cookie.java
@@ -0,0 +1,164 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal.json;
+
+/**
+ * Convert a web browser cookie specification to a JSONObject and back.
+ * JSON and Cookies are both notations for name/value pairs.
+ * @author JSON.org
+ * @version 2010-12-24
+ */
+public class Cookie {
+
+ /**
+ * Produce a copy of a string in which the characters '+', '%', '=', ';'
+ * and control characters are replaced with "%hh". This is a gentle form
+ * of URL encoding, attempting to cause as little distortion to the
+ * string as possible. The characters '=' and ';' are meta characters in
+ * cookies. By convention, they are escaped using the URL-encoding. This is
+ * only a convention, not a standard. Often, cookies are expected to have
+ * encoded values. We encode '=' and ';' because we must. We encode '%' and
+ * '+' because they are meta characters in URL encoding.
+ * @param string The source string.
+ * @return The escaped result.
+ */
+ public static String escape(String string) {
+ char c;
+ String s = string.trim();
+ StringBuffer sb = new StringBuffer();
+ int length = s.length();
+ for (int i = 0; i < length; i += 1) {
+ c = s.charAt(i);
+ if (c < ' ' || c == '+' || c == '%' || c == '=' || c == ';') {
+ sb.append('%');
+ sb.append(Character.forDigit((char)((c >>> 4) & 0x0f), 16));
+ sb.append(Character.forDigit((char)(c & 0x0f), 16));
+ } else {
+ sb.append(c);
+ }
+ }
+ return sb.toString();
+ }
+
+
+ /**
+ * Convert a cookie specification string into a JSONObject. The string
+ * will contain a name value pair separated by '='. The name and the value
+ * will be unescaped, possibly converting '+' and '%' sequences. The
+ * cookie properties may follow, separated by ';', also represented as
+ * name=value (except the secure property, which does not have a value).
+ * The name will be stored under the key "name", and the value will be
+ * stored under the key "value". This method does not do checking or
+ * validation of the parameters. It only converts the cookie string into
+ * a JSONObject.
+ * @param string The cookie specification string.
+ * @return A JSONObject containing "name", "value", and possibly other
+ * members.
+ * @throws JSONException
+ */
+ public static JSONObject toJSONObject(String string) throws JSONException {
+ String name;
+ JSONObject jo = new JSONObject();
+ Object value;
+ JSONTokener x = new JSONTokener(string);
+ jo.put("name", x.nextTo('='));
+ x.next('=');
+ jo.put("value", x.nextTo(';'));
+ x.next();
+ while (x.more()) {
+ name = unescape(x.nextTo("=;"));
+ if (x.next() != '=') {
+ if (name.equals("secure")) {
+ value = Boolean.TRUE;
+ } else {
+ throw x.syntaxError("Missing '=' in cookie parameter.");
+ }
+ } else {
+ value = unescape(x.nextTo(';'));
+ x.next();
+ }
+ jo.put(name, value);
+ }
+ return jo;
+ }
+
+
+ /**
+ * Convert a JSONObject into a cookie specification string. The JSONObject
+ * must contain "name" and "value" members.
+ * If the JSONObject contains "expires", "domain", "path", or "secure"
+ * members, they will be appended to the cookie specification string.
+ * All other members are ignored.
+ * @param jo A JSONObject
+ * @return A cookie specification string
+ * @throws JSONException
+ */
+ public static String toString(JSONObject jo) throws JSONException {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append(escape(jo.getString("name")));
+ sb.append("=");
+ sb.append(escape(jo.getString("value")));
+ if (jo.has("expires")) {
+ sb.append(";expires=");
+ sb.append(jo.getString("expires"));
+ }
+ if (jo.has("domain")) {
+ sb.append(";domain=");
+ sb.append(escape(jo.getString("domain")));
+ }
+ if (jo.has("path")) {
+ sb.append(";path=");
+ sb.append(escape(jo.getString("path")));
+ }
+ if (jo.optBoolean("secure")) {
+ sb.append(";secure");
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Convert <code>%</code><i>hh</i> sequences to single characters, and
+ * convert plus to space.
+ * @param string A string that may contain
+ * <code>+</code> <small>(plus)</small> and
+ * <code>%</code><i>hh</i> sequences.
+ * @return The unescaped string.
+ */
+ public static String unescape(String string) {
+ int length = string.length();
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < length; ++i) {
+ char c = string.charAt(i);
+ if (c == '+') {
+ c = ' ';
+ } else if (c == '%' && i + 2 < length) {
+ int d = JSONTokener.dehexchar(string.charAt(i + 1));
+ int e = JSONTokener.dehexchar(string.charAt(i + 2));
+ if (d >= 0 && e >= 0) {
+ c = (char)(d * 16 + e);
+ i += 2;
+ }
+ }
+ sb.append(c);
+ }
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/CookieList.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/CookieList.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/CookieList.java
new file mode 100644
index 0000000..e03f75c
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/CookieList.java
@@ -0,0 +1,85 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal.json;
+
+import java.util.Iterator;
+
+/**
+ * Convert a web browser cookie list string to a JSONObject and back.
+ * @author JSON.org
+ * @version 2010-12-24
+ */
+public class CookieList {
+
+ /**
+ * Convert a cookie list into a JSONObject. A cookie list is a sequence
+ * of name/value pairs. The names are separated from the values by '='.
+ * The pairs are separated by ';'. The names and the values
+ * will be unescaped, possibly converting '+' and '%' sequences.
+ *
+ * To add a cookie to a cooklist,
+ * cookielistJSONObject.put(cookieJSONObject.getString("name"),
+ * cookieJSONObject.getString("value"));
+ * @param string A cookie list string
+ * @return A JSONObject
+ * @throws JSONException
+ */
+ public static JSONObject toJSONObject(String string) throws JSONException {
+ JSONObject jo = new JSONObject();
+ JSONTokener x = new JSONTokener(string);
+ while (x.more()) {
+ String name = Cookie.unescape(x.nextTo('='));
+ x.next('=');
+ jo.put(name, Cookie.unescape(x.nextTo(';')));
+ x.next();
+ }
+ return jo;
+ }
+
+
+ /**
+ * Convert a JSONObject into a cookie list. A cookie list is a sequence
+ * of name/value pairs. The names are separated from the values by '='.
+ * The pairs are separated by ';'. The characters '%', '+', '=', and ';'
+ * in the names and values are replaced by "%hh".
+ * @param jo A JSONObject
+ * @return A cookie list string
+ * @throws JSONException
+ */
+ public static String toString(JSONObject jo) throws JSONException {
+ boolean b = false;
+ Iterator keys = jo.keys();
+ String string;
+ StringBuffer sb = new StringBuffer();
+ while (keys.hasNext()) {
+ string = keys.next().toString();
+ if (!jo.isNull(string)) {
+ if (b) {
+ sb.append(';');
+ }
+ sb.append(Cookie.escape(string));
+ sb.append("=");
+ sb.append(Cookie.escape(jo.getString(string)));
+ b = true;
+ }
+ }
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/HTTP.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/HTTP.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/HTTP.java
new file mode 100644
index 0000000..19c7d53
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/HTTP.java
@@ -0,0 +1,158 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal.json;
+
+import java.util.Iterator;
+
+/**
+ * Convert an HTTP header to a JSONObject and back.
+ * @author JSON.org
+ * @version 2010-12-24
+ */
+public class HTTP {
+
+ /** Carriage return/line feed. */
+ public static final String CRLF = "\r\n";
+
+ /**
+ * Convert an HTTP header string into a JSONObject. It can be a request
+ * header or a response header. A request header will contain
+ * <pre>{
+ * Method: "POST" (for example),
+ * "Request-URI": "/" (for example),
+ * "HTTP-Version": "HTTP/1.1" (for example)
+ * }</pre>
+ * A response header will contain
+ * <pre>{
+ * "HTTP-Version": "HTTP/1.1" (for example),
+ * "Status-Code": "200" (for example),
+ * "Reason-Phrase": "OK" (for example)
+ * }</pre>
+ * In addition, the other parameters in the header will be captured, using
+ * the HTTP field names as JSON names, so that <pre>
+ * Date: Sun, 26 May 2002 18:06:04 GMT
+ * Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s
+ * Cache-Control: no-cache</pre>
+ * become
+ * <pre>{...
+ * Date: "Sun, 26 May 2002 18:06:04 GMT",
+ * Cookie: "Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s",
+ * "Cache-Control": "no-cache",
+ * ...}</pre>
+ * It does no further checking or conversion. It does not parse dates.
+ * It does not do '%' transforms on URLs.
+ * @param string An HTTP header string.
+ * @return A JSONObject containing the elements and attributes
+ * of the XML string.
+ * @throws JSONException
+ */
+ public static JSONObject toJSONObject(String string) throws JSONException {
+ JSONObject jo = new JSONObject();
+ HTTPTokener x = new HTTPTokener(string);
+ String token;
+
+ token = x.nextToken();
+ if (token.toUpperCase().startsWith("HTTP")) {
+
+// Response
+
+ jo.put("HTTP-Version", token);
+ jo.put("Status-Code", x.nextToken());
+ jo.put("Reason-Phrase", x.nextTo('\0'));
+ x.next();
+
+ } else {
+
+// Request
+
+ jo.put("Method", token);
+ jo.put("Request-URI", x.nextToken());
+ jo.put("HTTP-Version", x.nextToken());
+ }
+
+// Fields
+
+ while (x.more()) {
+ String name = x.nextTo(':');
+ x.next(':');
+ jo.put(name, x.nextTo('\0'));
+ x.next();
+ }
+ return jo;
+ }
+
+
+ /**
+ * Convert a JSONObject into an HTTP header. A request header must contain
+ * <pre>{
+ * Method: "POST" (for example),
+ * "Request-URI": "/" (for example),
+ * "HTTP-Version": "HTTP/1.1" (for example)
+ * }</pre>
+ * A response header must contain
+ * <pre>{
+ * "HTTP-Version": "HTTP/1.1" (for example),
+ * "Status-Code": "200" (for example),
+ * "Reason-Phrase": "OK" (for example)
+ * }</pre>
+ * Any other members of the JSONObject will be output as HTTP fields.
+ * The result will end with two CRLF pairs.
+ * @param jo A JSONObject
+ * @return An HTTP header string.
+ * @throws JSONException if the object does not contain enough
+ * information.
+ */
+ public static String toString(JSONObject jo) throws JSONException {
+ Iterator keys = jo.keys();
+ String string;
+ StringBuffer sb = new StringBuffer();
+ if (jo.has("Status-Code") && jo.has("Reason-Phrase")) {
+ sb.append(jo.getString("HTTP-Version"));
+ sb.append(' ');
+ sb.append(jo.getString("Status-Code"));
+ sb.append(' ');
+ sb.append(jo.getString("Reason-Phrase"));
+ } else if (jo.has("Method") && jo.has("Request-URI")) {
+ sb.append(jo.getString("Method"));
+ sb.append(' ');
+ sb.append('"');
+ sb.append(jo.getString("Request-URI"));
+ sb.append('"');
+ sb.append(' ');
+ sb.append(jo.getString("HTTP-Version"));
+ } else {
+ throw new JSONException("Not enough material for an HTTP header.");
+ }
+ sb.append(CRLF);
+ while (keys.hasNext()) {
+ string = keys.next().toString();
+ if (!"HTTP-Version".equals(string) && !"Status-Code".equals(string) &&
+ !"Reason-Phrase".equals(string) && !"Method".equals(string) &&
+ !"Request-URI".equals(string) && !jo.isNull(string)) {
+ sb.append(string);
+ sb.append(": ");
+ sb.append(jo.getString(string));
+ sb.append(CRLF);
+ }
+ }
+ sb.append(CRLF);
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/HTTPTokener.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/HTTPTokener.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/HTTPTokener.java
new file mode 100644
index 0000000..536aee0
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/HTTPTokener.java
@@ -0,0 +1,72 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal.json;
+
+/**
+ * The HTTPTokener extends the JSONTokener to provide additional methods
+ * for the parsing of HTTP headers.
+ * @author JSON.org
+ * @version 2010-12-24
+ */
+public class HTTPTokener extends JSONTokener {
+
+ /**
+ * Construct an HTTPTokener from a string.
+ * @param string A source string.
+ */
+ public HTTPTokener(String string) {
+ super(string);
+ }
+
+
+ /**
+ * Get the next token or string. This is used in parsing HTTP headers.
+ * @throws JSONException
+ * @return A String.
+ */
+ public String nextToken() throws JSONException {
+ char c;
+ char q;
+ StringBuffer sb = new StringBuffer();
+ do {
+ c = next();
+ } while (Character.isWhitespace(c));
+ if (c == '"' || c == '\'') {
+ q = c;
+ for (;;) {
+ c = next();
+ if (c < ' ') {
+ throw syntaxError("Unterminated string.");
+ }
+ if (c == q) {
+ return sb.toString();
+ }
+ sb.append(c);
+ }
+ }
+ for (;;) {
+ if (c == 0 || Character.isWhitespace(c)) {
+ return sb.toString();
+ }
+ sb.append(c);
+ c = next();
+ }
+ }
+}