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:18 UTC
[01/35] incubator-geode git commit: GEODE-37 import change in pulse
module
Repository: incubator-geode
Updated Branches:
refs/heads/develop 06436dba0 -> e9bf1176b
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/controllers/PulseControllerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/controllers/PulseControllerJUnitTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/controllers/PulseControllerJUnitTest.java
index 06d7f3d..cc11985 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/controllers/PulseControllerJUnitTest.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/controllers/PulseControllerJUnitTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.vmware.geode.tools.pulse.controllers;
+package org.apache.geode.tools.pulse.controllers;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.*;
@@ -35,14 +35,14 @@ import java.util.UUID;
import javax.servlet.ServletContextListener;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.vmware.geode.tools.pulse.internal.PulseAppListener;
+import org.apache.geode.tools.pulse.internal.PulseAppListener;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.geode.test.junit.categories.UnitTest;
-import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.PulseConfig;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.controllers.PulseController;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.PulseConfig;
+import org.apache.geode.tools.pulse.internal.data.Repository;
import org.apache.commons.collections.buffer.CircularFifoBuffer;
import org.junit.Before;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemFireDistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemFireDistributedSystem.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemFireDistributedSystem.java
index 4b25a8d..90c66c0 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemFireDistributedSystem.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemFireDistributedSystem.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.testbed;
+package org.apache.geode.tools.pulse.testbed;
import java.io.IOException;
import java.util.ArrayList;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemfireTopology.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemfireTopology.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemfireTopology.java
index 6470195..b5028a9 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemfireTopology.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemfireTopology.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.testbed;
+package org.apache.geode.tools.pulse.testbed;
public class GemfireTopology {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropFileHelper.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropFileHelper.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropFileHelper.java
index 1892292..4f00ab1 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropFileHelper.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropFileHelper.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.testbed;
+package org.apache.geode.tools.pulse.testbed;
import java.io.File;
import java.io.FileInputStream;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
index 007be75..e1659fb 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
@@ -16,24 +16,24 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.testbed;
+package org.apache.geode.tools.pulse.testbed;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Cluster.Alert;
-import com.vmware.geode.tools.pulse.internal.data.Cluster.Client;
-import com.vmware.geode.tools.pulse.internal.data.Cluster.GatewayReceiver;
-import com.vmware.geode.tools.pulse.internal.data.Cluster.GatewaySender;
-import com.vmware.geode.tools.pulse.internal.data.Cluster.Member;
-import com.vmware.geode.tools.pulse.internal.data.Cluster.Region;
-import com.vmware.geode.tools.pulse.internal.data.IClusterUpdater;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Locator;
-import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Peer;
-import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Server;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Cluster.Alert;
+import org.apache.geode.tools.pulse.internal.data.Cluster.Client;
+import org.apache.geode.tools.pulse.internal.data.Cluster.GatewayReceiver;
+import org.apache.geode.tools.pulse.internal.data.Cluster.GatewaySender;
+import org.apache.geode.tools.pulse.internal.data.Cluster.Member;
+import org.apache.geode.tools.pulse.internal.data.Cluster.Region;
+import org.apache.geode.tools.pulse.internal.data.IClusterUpdater;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Locator;
+import org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Peer;
+import org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Server;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -167,11 +167,11 @@ public class PropMockDataUpdater implements IClusterUpdater {
//Read from property file
int randomInt = (randomGenerator.nextInt(5)) + 1;
- List<com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Region> thisMemberRegions = testbed.getRootDs().getRegions(memberSet.getValue().getName());
+ List<org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Region> thisMemberRegions = testbed.getRootDs().getRegions(memberSet.getValue().getName());
int regionExists = 0;
int index=0;
- for (com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Region thisMemberRegion : thisMemberRegions) {
+ for (org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Region thisMemberRegion : thisMemberRegions) {
Region region = initMemberRegion(index++,thisMemberRegion.getName(),memberSet.getValue().getName(),
thisMemberRegion.getEntryCount(),thisMemberRegion.getType(), thisMemberRegion.getMembers().size()); //read from property file
if (regionsList.size() > 0) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/TestBed.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/TestBed.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/TestBed.java
index ba04c32..fa61e29 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/TestBed.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/TestBed.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.testbed;
+package org.apache.geode.tools.pulse.testbed;
import java.io.File;
import java.io.FileInputStream;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/driver/PulseUITest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/driver/PulseUITest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/driver/PulseUITest.java
index c2d55c3..a2365a2 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/driver/PulseUITest.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/driver/PulseUITest.java
@@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.vmware.geode.tools.pulse.testbed.driver;
+package org.apache.geode.tools.pulse.testbed.driver;
-import static com.vmware.geode.tools.pulse.tests.PulseAbstractTest.*;
+import static org.apache.geode.tools.pulse.tests.PulseAbstractTest.*;
import static org.junit.Assert.*;
import java.net.InetAddress;
@@ -39,11 +39,11 @@ import org.apache.geode.internal.net.SSLConfigurationFactory;
import org.apache.geode.internal.security.SecurableCommunicationChannel;
import org.apache.geode.management.internal.JettyHelper;
import org.apache.geode.test.junit.categories.UITest;
-import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Locator;
-import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Peer;
-import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Region;
-import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Server;
-import com.vmware.geode.tools.pulse.testbed.TestBed;
+import org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Locator;
+import org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Peer;
+import org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Region;
+import org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Server;
+import org.apache.geode.tools.pulse.testbed.TestBed;
@Ignore("TODO: test is ignored")
@Category(UITest.class)
@@ -70,7 +70,7 @@ public class PulseUITest {
int port = 8080;
String context = "/pulse";
path = getPulseWarPath();
- //System.setProperty("pulse.propMockDataUpdaterClass", "com.vmware.geode.tools.pulse.testbed.PropMockDataUpdater");
+ //System.setProperty("pulse.propMockDataUpdaterClass", "org.apache.geode.tools.pulse.testbed.PropMockDataUpdater");
jetty = JettyHelper.initJetty(host, port, SSLConfigurationFactory.getSSLConfigForComponent(SecurableCommunicationChannel.WEB));
JettyHelper.addWebApplication(jetty, context, getPulseWarPath());
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatement.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatement.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatement.java
index ebd310d..b4ad0a2 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatement.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatement.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
public class AggregateStatement extends JMXBaseBean implements AggregateStatementMBean {
private String name = null;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatementMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatementMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatementMBean.java
index b58b53b..e1c968d 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatementMBean.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatementMBean.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
public interface AggregateStatementMBean {
String OBJECT_NAME = "GemFireXD:service=Statement,type=Aggregate";
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/DataBrowserResultLoader.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/DataBrowserResultLoader.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/DataBrowserResultLoader.java
index 09fbda3..b7895a6 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/DataBrowserResultLoader.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/DataBrowserResultLoader.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import java.io.BufferedReader;
import java.io.File;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTable.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTable.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTable.java
index 957d074..079117b 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTable.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTable.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import javax.management.NotificationBroadcasterSupport;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTableMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTableMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTableMBean.java
index db0f45d..c7f2e94 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTableMBean.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTableMBean.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
public interface GemFireXDAggregateTableMBean {
public static final String OBJECT_NAME = "GemFireXD:service=Table,type=Aggregate,table=";
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDCluster.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDCluster.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDCluster.java
index a2b1edc..bc8f6f5 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDCluster.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDCluster.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import javax.management.NotificationBroadcasterSupport;
import javax.management.openmbean.CompositeData;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDClusterMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDClusterMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDClusterMBean.java
index 5a42d10..8b31dd3 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDClusterMBean.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDClusterMBean.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import javax.management.openmbean.CompositeData;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMember.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMember.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMember.java
index 16da77d..b2faca4 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMember.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMember.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMemberMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMemberMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMemberMBean.java
index ceda56d..91491ea 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMemberMBean.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMemberMBean.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import javax.management.openmbean.CompositeData;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXBaseBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXBaseBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXBaseBean.java
index 2d1ffad..5bf1481 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXBaseBean.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXBaseBean.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
public abstract class JMXBaseBean {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXProperties.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXProperties.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXProperties.java
index 1562594..cb5d0fc 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXProperties.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXProperties.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import java.io.File;
import java.io.FileInputStream;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Member.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Member.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Member.java
index 1192297..d4606c5 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Member.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Member.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
public class Member extends JMXBaseBean implements MemberMBean {
private String name = null;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/MemberMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/MemberMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/MemberMBean.java
index 6051270..ad3c2a1 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/MemberMBean.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/MemberMBean.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
public interface MemberMBean {
String OBJECT_NAME = "GemFire:type=Member";
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAbstractTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAbstractTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAbstractTest.java
index e30b560..5024250 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAbstractTest.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAbstractTest.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import static org.junit.Assert.*;
@@ -47,7 +47,7 @@ import org.openqa.selenium.support.ui.WebDriverWait;
import org.apache.geode.internal.net.SSLConfigurationFactory;
import org.apache.geode.internal.security.SecurableCommunicationChannel;
import org.apache.geode.management.internal.JettyHelper;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
@SuppressWarnings("deprecated")
public abstract class PulseAbstractTest extends PulseBaseTest {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAuthTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAuthTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAuthTest.java
index e5e30d2..a77e0ca 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAuthTest.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAuthTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import org.apache.geode.test.junit.categories.UITest;
import org.junit.BeforeClass;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAutomatedTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAutomatedTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAutomatedTest.java
index 90e1bd9..a4f14f8 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAutomatedTest.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAutomatedTest.java
@@ -26,7 +26,7 @@
* @version 1.0
* @since GemFire 2014-04-02
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import static org.junit.Assert.*;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseBaseTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseBaseTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseBaseTest.java
index a854a48..47b4e7e 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseBaseTest.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseBaseTest.java
@@ -16,9 +16,9 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
-import static com.vmware.geode.tools.pulse.tests.PulseAbstractTest.*;
+import static org.apache.geode.tools.pulse.tests.PulseAbstractTest.*;
import static org.junit.Assert.*;
import java.util.Collections;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseNoAuthTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseNoAuthTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseNoAuthTest.java
index e9765c5..e1021df 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseNoAuthTest.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseNoAuthTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import org.apache.geode.test.junit.categories.UITest;
import org.junit.BeforeClass;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestData.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestData.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestData.java
index ca716fa..e299786 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestData.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestData.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
public class PulseTestData {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestLocators.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestLocators.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestLocators.java
index d5ff5d4..6e76218 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestLocators.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestLocators.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
public class PulseTestLocators {
public static class HtmlAttributes{
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Region.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Region.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Region.java
index fd835c7..1c1ef9f 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Region.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Region.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import java.util.HashMap;
import java.util.Map;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionMBean.java
index 0ee8201..c0a32e6 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionMBean.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionMBean.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import javax.management.openmbean.CompositeData;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMember.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMember.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMember.java
index 86ba550..18259f1 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMember.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMember.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
/**
* Region on member mbean
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMemberMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMemberMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMemberMBean.java
index 5fac9da..c63eb33 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMemberMBean.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMemberMBean.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
/**
* Region on members mbean
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
index 20f5312..ecf15eb 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import java.io.IOException;
import java.lang.management.ManagementFactory;
@@ -38,7 +38,7 @@ import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
import org.apache.geode.security.templates.SampleSecurityManager;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.mgt.DefaultSecurityManager;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObject.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObject.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObject.java
index adc1361..11afb70 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObject.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObject.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObjectMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObjectMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObjectMBean.java
index 8f1bc54..46ad620 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObjectMBean.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObjectMBean.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests;
+package org.apache.geode.tools.pulse.tests;
import javax.management.openmbean.TabularData;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/BaseServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/BaseServiceTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/BaseServiceTest.java
index 29fae16..d66d1c8 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/BaseServiceTest.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/BaseServiceTest.java
@@ -16,13 +16,13 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests.junit;
+package org.apache.geode.tools.pulse.tests.junit;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.geode.test.junit.categories.UITest;
import com.google.gson.JsonObject;
-import com.vmware.geode.tools.pulse.internal.json.JSONObject;
+import org.apache.geode.tools.pulse.internal.json.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpUriRequest;
@@ -208,7 +208,7 @@ public abstract class BaseServiceTest {
*
* Tests that service returns json object
*
- * Test method for {@link com.vmware.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
+ * Test method for {@link org.apache.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
*/
@Test
public void testServerLoginLogout() {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java
index 22adcaf..bfee425 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests.junit;
+package org.apache.geode.tools.pulse.tests.junit;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@@ -31,8 +31,8 @@ import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.util.EntityUtils;
import org.junit.*;
-import com.vmware.geode.tools.pulse.internal.json.JSONArray;
-import com.vmware.geode.tools.pulse.internal.json.JSONObject;
+import org.apache.geode.tools.pulse.internal.json.JSONArray;
+import org.apache.geode.tools.pulse.internal.json.JSONObject;
/**
* JUnit Tests for ClusterSelectedRegionService in the back-end server for region detail page
@@ -177,7 +177,7 @@ public class ClusterSelectedRegionServiceTest extends BaseServiceTest {
*
* Tests that response is for same region
*
- * Test method for {@link com.vmware.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
+ * Test method for {@link org.apache.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
*
*/
@Test
@@ -231,7 +231,7 @@ public class ClusterSelectedRegionServiceTest extends BaseServiceTest {
*
* Tests that response is for same region
*
- * Test method for {@link com.vmware.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
+ * Test method for {@link org.apache.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
*
*/
@Test
@@ -283,7 +283,7 @@ public class ClusterSelectedRegionServiceTest extends BaseServiceTest {
*
* Tests that service returns json object
*
- * Test method for {@link com.vmware.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
+ * Test method for {@link org.apache.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
*
*/
@Test
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java
index 54b96ba..f27f08a 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests.junit;
+package org.apache.geode.tools.pulse.tests.junit;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@@ -32,7 +32,7 @@ import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.util.EntityUtils;
import org.junit.*;
-import com.vmware.geode.tools.pulse.internal.json.JSONObject;
+import org.apache.geode.tools.pulse.internal.json.JSONObject;
/**
* JUnit Tests for ClusterSelectedRegionsMemberService in the back-end server for region detail page
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java
index 0a2fe0a..be774b5 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.tests.junit;
+package org.apache.geode.tools.pulse.tests.junit;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@@ -31,8 +31,8 @@ import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.util.EntityUtils;
import org.junit.*;
-import com.vmware.geode.tools.pulse.internal.json.JSONArray;
-import com.vmware.geode.tools.pulse.internal.json.JSONObject;
+import org.apache.geode.tools.pulse.internal.json.JSONArray;
+import org.apache.geode.tools.pulse.internal.json.JSONObject;
/**
* JUnit Tests for MemberGatewayHubService in the back-end server for region detail page
@@ -128,7 +128,7 @@ public class MemberGatewayHubServiceTest extends BaseServiceTest {
*
* Tests that response is for same region
*
- * Test method for {@link com.vmware.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+ * Test method for {@link org.apache.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
*
*/
@Test
@@ -181,7 +181,7 @@ public class MemberGatewayHubServiceTest extends BaseServiceTest {
*
* Tests that response is for same region
*
- * Test method for {@link com.vmware.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+ * Test method for {@link org.apache.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
*
*/
@Test
@@ -237,7 +237,7 @@ public class MemberGatewayHubServiceTest extends BaseServiceTest {
*
* Tests that response is for same region
*
- * Test method for {@link com.vmware.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+ * Test method for {@link org.apache.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
*
*/
@Test
@@ -296,7 +296,7 @@ public class MemberGatewayHubServiceTest extends BaseServiceTest {
*
* Tests that response is for same region
*
- * Test method for {@link com.vmware.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+ * Test method for {@link org.apache.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
*
*/
@Test
@@ -358,7 +358,7 @@ public class MemberGatewayHubServiceTest extends BaseServiceTest {
*
* Tests that response is for same region
*
- * Test method for {@link com.vmware.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+ * Test method for {@link org.apache.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
*
*/
@Test
[11/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/driver/PulseUITest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/driver/PulseUITest.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/driver/PulseUITest.java
deleted file mode 100644
index 7d047ed..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/driver/PulseUITest.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.vmware.gemfire.tools.pulse.testbed.driver;
-
-import static com.vmware.gemfire.tools.pulse.tests.PulseAbstractTest.*;
-import static org.junit.Assert.*;
-
-import java.net.InetAddress;
-import java.util.List;
-
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.firefox.FirefoxDriver;
-import org.openqa.selenium.support.ui.ExpectedCondition;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-import org.apache.geode.internal.net.SSLConfigurationFactory;
-import org.apache.geode.internal.security.SecurableCommunicationChannel;
-import org.apache.geode.management.internal.JettyHelper;
-import org.apache.geode.test.junit.categories.UITest;
-import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Locator;
-import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Peer;
-import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Region;
-import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Server;
-import com.vmware.gemfire.tools.pulse.testbed.TestBed;
-
-@Ignore("TODO: test is ignored")
-@Category(UITest.class)
-public class PulseUITest {
-
- private static WebDriver driver;
- private static TestBed testBed;
- private static String pulseURL;
- private static String path;
- private static org.eclipse.jetty.server.Server jetty = null;
-
- private static final String userName = "admin";
- private static final String pasword = "admin";
-
- private static final String DATA_VIEW_LABEL = "Data View";
- private static final String CLUSTER_VIEW_MEMBERS_ID = "clusterTotalMembersText";
- private static final String CLUSTER_VIEW_SERVERS_ID = "clusterServersText";
- private static final String CLUSTER_VIEW_LOCATORS_ID = "clusterLocatorsText";
- private static final String CLUSTER_VIEW_REGIONS_ID = "clusterTotalRegionsText";
-
- @BeforeClass
- public static void setUpJetty() throws Exception {
- String host = InetAddress.getLocalHost().getHostAddress();
- int port = 8080;
- String context = "/pulse";
- path = getPulseWarPath();
- //System.setProperty("pulse.propMockDataUpdaterClass", "com.vmware.gemfire.tools.pulse.testbed.PropMockDataUpdater");
-
- jetty = JettyHelper.initJetty(host, port, SSLConfigurationFactory.getSSLConfigForComponent(SecurableCommunicationChannel.WEB));
- JettyHelper.addWebApplication(jetty, context, getPulseWarPath());
- jetty.start();
-
- pulseURL = "http://" + host + ":" + port + context;
- Thread.sleep(1000); //wait till tomcat settles down
- driver = new FirefoxDriver();
- driver.manage().window().maximize();//required to make all elements visible
-
- Thread.sleep(5000); //wait till pulse starts polling threads...
- testBed = new TestBed();
- loginToPulse(driver, userName, pasword);
- }
-
- @AfterClass
- public static void stopJetty() throws Exception {
- jetty.stop();
- }
-
- @After
- public void closeSession() {
- driver.close();
- }
-
- private static void loginToPulse(WebDriver driver, String userName,String password){
- driver.get(pulseURL);
- WebElement userNameElement = driver.findElement(By.id("user_name"));
- WebElement passwordElement = driver.findElement(By.id("user_password"));
- userNameElement.sendKeys(userName);
- passwordElement.sendKeys(password);
- passwordElement.submit();
- WebElement userNameOnPulsePage = (new WebDriverWait(driver, 10))
- .until(new ExpectedCondition<WebElement>() {
- @Override
- public WebElement apply(WebDriver d) {
- return d.findElement(By.id("userName"));
- }
- });
- assertNotNull(userNameOnPulsePage);
- }
-
-
- private void searchByLinkAndClick(String linkText){
- WebElement dataViewButton= By.linkText(linkText).findElement(driver);
- assertNotNull(dataViewButton);
- dataViewButton.click();
- }
-
- private void searchByIdAndClick(String id){
- WebElement element = driver.findElement(By.id(id));
- assertNotNull(element);
- element.click();
- }
-
- private void searchByXPathAndClick(String xpath){
- WebElement element = driver.findElement(By.xpath(xpath));
- assertNotNull(element);
- element.click();
- }
-
- private void waitForElementByClassName(final String className, int seconds){
- WebElement linkTextOnPulsePage1 = (new WebDriverWait(driver, seconds))
- .until(new ExpectedCondition<WebElement>() {
- @Override
- public WebElement apply(WebDriver d) {
- return d.findElement(By.className(className));
- }
- });
- assertNotNull(linkTextOnPulsePage1);
- }
-
- private void waitForElementById(final String id, int seconds){
- WebElement element = (new WebDriverWait(driver, 10))
- .until(new ExpectedCondition<WebElement>() {
- @Override
- public WebElement apply(WebDriver d) {
- return d.findElement(By.id(id));
- }
- });
- assertNotNull(element);
- }
-
- @Test
- public void testClusterViewTopRibbon() {
- List<Server> servers = testBed.getRootDs().getServers();
- List<Locator> locators = testBed.getRootDs().getLocators();
- List<Peer> peers = testBed.getRootDs().getPeers();
- List<Region> regions = testBed.getRootDs().getRegions();
- int totalMembers = servers.size() + locators.size() + peers.size();
- int clusterMembers = Integer.parseInt(driver.findElement(
- By.id(CLUSTER_VIEW_MEMBERS_ID)).getText());
- int clusterServers = Integer.parseInt(driver.findElement(
- By.id(CLUSTER_VIEW_SERVERS_ID)).getText());
- int clusterLocators = Integer.parseInt(driver.findElement(
- By.id(CLUSTER_VIEW_LOCATORS_ID)).getText());
- int clusterRegions = Integer.parseInt(driver.findElement(
- By.id(CLUSTER_VIEW_REGIONS_ID)).getText());
- assertEquals(totalMembers, clusterMembers);
- assertEquals(servers.size(), clusterServers);
- assertEquals(locators.size(), clusterLocators);
- assertEquals(regions.size(), clusterRegions);
- }
-
-
- @Test
- public void testDataViewRegionProperties() {
- searchByLinkAndClick(DATA_VIEW_LABEL);
- waitForElementByClassName("pointDetailsPadding",10);
- searchByIdAndClick("btngridIcon");
-
- for(int i=1;i<testBed.getRootDs().getRegions().size();i++){
- searchByIdAndClick(""+i);
- String regionName1 = driver.findElement(By.id("regionName")).getText();
- @SuppressWarnings("rawtypes")
- List regionMemberscount1 = testBed.getRootDs().getRegion(regionName1)
- .getMembers();
- int regionEntCount1 = testBed.getRootDs().getRegion(regionName1)
- .getEntryCount();
- int regionMembers1 = Integer.parseInt(driver.findElement(
- By.id("regionMembers")).getText());
- int regionEntryCount1 = Integer.parseInt(driver.findElement(
- By.id("regionEntryCount")).getText());
- assertEquals(regionMemberscount1.size(), regionMembers1);
- assertEquals(regionEntCount1, regionEntryCount1);
- }
- }
-
-
- @Test
- public void testMemberViewRegions() {
-
- searchByLinkAndClick(DATA_VIEW_LABEL);
- waitForElementByClassName("pointDetailsPadding",10);
- searchByXPathAndClick("//div[@title='peer1']");
- waitForElementById("memberRegionsCount",10);
-
- List<Server> servers = testBed.getRootDs().getServers();
- List<Locator> locators = testBed.getRootDs().getLocators();
- List<Peer> peers = testBed.getRootDs().getPeers();
-
- String prevSelectedMember = "peer1";
-
- for (Peer p : peers) {
- String peer = p.getName();
- System.out.println("Checking regions mapping for member " + peer);
- WebElement comboBox = driver.findElement(By.linkText(prevSelectedMember));
- comboBox.click();
- WebElement comboList = driver.findElement(By.id("clusterMembersContainer"));
- WebElement selectedMember = comboList.findElement(By.linkText(peer));
- selectedMember.click();
- timeout();
- String peername = driver.findElement(By.id("memberName")).getText();
- List<Region> peerRegionscount = testBed.getRootDs().getRegions(peer);
- int peerRegions = Integer.parseInt(driver.findElement(
- By.id("memberRegionsCount")).getText());
- assertEquals(peerRegionscount.size(), peerRegions);
- prevSelectedMember = peername;
- }
-
- for (Server s : servers) {
- String server = s.getName();
- System.out.println("Checking regions mapping for server " + server);
- WebElement comboBox = driver.findElement(By.linkText(prevSelectedMember));
- comboBox.click();
- WebElement comboList = driver.findElement(By.id("clusterMembersContainer"));
- WebElement selectedMember = comboList.findElement(By.linkText(server));
- selectedMember.click();
- timeout();
- String peername = driver.findElement(By.id("memberName")).getText();
- List<Region> serverRegionscount = testBed.getRootDs().getRegions(server);
- int serverRegions = Integer.parseInt(driver.findElement(
- By.id("memberRegionsCount")).getText());
- assertEquals(serverRegionscount.size(), serverRegions);
- prevSelectedMember = peername;
- }
- /*
- for (Locator l : locators) {
- String locator = l.getName();
- System.out.println("Checking regions mapping for locator " + locator);
- WebElement comboBox = driver.findElement(By.linkText(prevSelectedMember));
- comboBox.click();
- WebElement comboList = driver.findElement(By.id("clusterMembersContainer"));
- WebElement selectedMember = comboList.findElement(By.linkText(locator));
- selectedMember.click();
- timeout();
- String peername = driver.findElement(By.id("memberName")).getText();
- List<Region> locatorRegionscount = testBed.getRootDs().getRegions(locator);
- int locatorRegions = Integer.parseInt(driver.findElement(
- By.id("memberRegionsCount")).getText());
- assertIndexDetailsEquals(locatorRegionscount.size(), locatorRegions);
- prevSelectedMember = peername;
- }*/
- }
-
- public void timeout() {
- WebElement memberNameOnPulsePage = (new WebDriverWait(driver, 10))
- .until(new ExpectedCondition<WebElement>() {
- @Override
- public WebElement apply(WebDriver d) {
- return d.findElement(By.id("memberName"));
- }
- });
- assertNotNull(memberNameOnPulsePage);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/AggregateStatement.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/AggregateStatement.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/AggregateStatement.java
deleted file mode 100644
index 3c5b507..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/AggregateStatement.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-public class AggregateStatement extends JMXBaseBean implements AggregateStatementMBean {
- private String name = null;
-
- public AggregateStatement(String name) {
- this.name = name;
- }
-
- protected String getKey(String propName) {
- return "aggregatestatement." + name + "." + propName;
- }
-
- /**
- * Query definition
- *
- * @return
- */
- public String getQueryDefinition(){
- return getString("queryDefinition");
- }
-
- /**
- * Number of times this statement is compiled (including re compilations)
- *
- * @return
- */
- @Override
- public long getNumTimesCompiled(){
- return getLong("numTimesCompiled");
- }
-
- /**
- * Number of times this statement is executed
- *
- * @return
- */
- @Override
- public long getNumExecution(){
- return getLong("numExecution");
- }
-
- /**
- * Statements that are actively being processed during the statistics snapshot
- *
- * @return
- */
- public long getNumExecutionsInProgress(){
- return getLong("numExecutionsInProgress");
- }
-
- /**
- * Number of times global index lookup message exchanges occurred
- *
- * @return
- */
- public long getNumTimesGlobalIndexLookup(){
- return getLong("numTimesGlobalIndexLookup");
- }
-
- /**
- * Number of rows modified by DML operation of insert/delete/update
- *
- * @return
- */
- public long getNumRowsModified(){
- return getLong("numRowsModified");
- }
-
- /**
- * Time spent(in milliseconds) in parsing the query string
- *
- * @return
- */
- public long getParseTime(){
- return getLong("parseTime");
- }
-
- /**
- * Time spent (in milliseconds) mapping this statement with database object's metadata (bind)
- *
- * @return
- */
- public long getBindTime(){
- return getLong("bindTime");
- }
-
- /**
- * Time spent (in milliseconds) determining the best execution path for this statement
- * (optimize)
- *
- * @return
- */
- public long getOptimizeTime(){
- return getLong("optimizeTime");
- }
-
- /**
- * Time spent (in milliseconds) compiling details about routing information of query strings to
- * data node(s) (processQueryInfo)
- *
- * @return
- */
- public long getRoutingInfoTime(){
- return getLong("routingInfoTime");
- }
-
- /**
- * Time spent (in milliseconds) to generate query execution plan definition (activation class)
- *
- * @return
- */
- public long getGenerateTime(){
- return getLong("generateTime");
- }
-
- /**
- * Total compilation time (in milliseconds) of the statement on this node (prepMinion)
- *
- * @return
- */
- public long getTotalCompilationTime(){
- return getLong("totalCompilationTime");
- }
-
- /**
- * Time spent (in nanoseconds) in creation of all the layers of query processing (ac.execute)
- *
- * @return
- */
- public long getExecutionTime(){
- return getLong("executionTime");
- }
-
- /**
- * Time to apply (in nanoseconds) the projection and additional filters. (projectrestrict)
- *
- * @return
- */
- public long getProjectionTime(){
- return getLong("projectionTime");
- }
-
- /**
- * Total execution time (in nanoseconds) taken to process the statement on this node
- * (execute/open/next/close)
- *
- * @return
- */
- public long getTotalExecutionTime(){
- return getLong("totalExecutionTime");
- }
-
- /**
- * Time taken (in nanoseconds) to modify rows by DML operation of insert/delete/update
- *
- * @return
- */
- public long getRowsModificationTime(){
- return getLong("rowsModificationTime");
- }
-
- /**
- * Number of rows returned from remote nodes (ResultHolder/Get convertibles)
- *
- * @return
- */
- public long getQNNumRowsSeen(){
- return getLong("qnNumRowsSeen");
- }
-
- /**
- * TCP send time (in nanoseconds) of all the messages including serialization time and queue
- * wait time
- *
- * @return
- */
- public long getQNMsgSendTime(){
- return getLong("qnMsgSendTime");
- }
-
- /**
- * Serialization time (in nanoseconds) for all the messages while sending to remote node(s)
- *
- * @return
- */
- public long getQNMsgSerTime(){
- return getLong("qnMsgSerTime");
- }
-
- /**
- *
- *
- * @return
- */
- public long getQNRespDeSerTime(){
- return getLong("qnRespDeSerTime");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/AggregateStatementMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/AggregateStatementMBean.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/AggregateStatementMBean.java
deleted file mode 100644
index 02c431f..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/AggregateStatementMBean.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-public interface AggregateStatementMBean {
- String OBJECT_NAME = "GemFireXD:service=Statement,type=Aggregate";
-
- /**
- * Query definition
- *
- * @return
- */
- String getQueryDefinition();
-
- /**
- * Number of times this statement is compiled (including re compilations)
- *
- * @return
- */
- long getNumTimesCompiled();
-
- /**
- * Number of times this statement is executed
- *
- * @return
- */
- long getNumExecution();
-
- /**
- * Statements that are actively being processed during the statistics snapshot
- *
- * @return
- */
- long getNumExecutionsInProgress();
-
- /**
- * Number of times global index lookup message exchanges occurred
- *
- * @return
- */
- long getNumTimesGlobalIndexLookup();
-
- /**
- * Number of rows modified by DML operation of insert/delete/update
- *
- * @return
- */
- long getNumRowsModified();
-
- /**
- * Time spent(in milliseconds) in parsing the query string
- *
- * @return
- */
- long getParseTime();
-
- /**
- * Time spent (in milliseconds) mapping this statement with database object's metadata (bind)
- *
- * @return
- */
- long getBindTime();
-
- /**
- * Time spent (in milliseconds) determining the best execution path for this statement
- * (optimize)
- *
- * @return
- */
- long getOptimizeTime();
-
- /**
- * Time spent (in milliseconds) compiling details about routing information of query strings to
- * data node(s) (processQueryInfo)
- *
- * @return
- */
- long getRoutingInfoTime();
-
- /**
- * Time spent (in milliseconds) to generate query execution plan definition (activation class)
- *
- * @return
- */
- long getGenerateTime();
-
- /**
- * Total compilation time (in milliseconds) of the statement on this node (prepMinion)
- *
- * @return
- */
- long getTotalCompilationTime();
-
- /**
- * Time spent (in nanoseconds) in creation of all the layers of query processing (ac.execute)
- *
- * @return
- */
- long getExecutionTime();
-
- /**
- * Time to apply (in nanoseconds) the projection and additional filters. (projectrestrict)
- *
- * @return
- */
- long getProjectionTime();
-
- /**
- * Total execution time (in nanoseconds) taken to process the statement on this node
- * (execute/open/next/close)
- *
- * @return
- */
- long getTotalExecutionTime();
-
- /**
- * Time taken (in nanoseconds) to modify rows by DML operation of insert/delete/update
- *
- * @return
- */
- long getRowsModificationTime();
-
- /**
- * Number of rows returned from remote nodes (ResultHolder/Get convertibles)
- *
- * @return
- */
- long getQNNumRowsSeen();
-
- /**
- * TCP send time (in nanoseconds) of all the messages including serialization time and queue
- * wait time
- *
- * @return
- */
- long getQNMsgSendTime();
-
- /**
- * Serialization time (in nanoseconds) for all the messages while sending to remote node(s)
- *
- * @return
- */
- long getQNMsgSerTime();
-
- /**
- *
- *
- * @return
- */
- long getQNRespDeSerTime();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/DataBrowserResultLoader.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/DataBrowserResultLoader.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/DataBrowserResultLoader.java
deleted file mode 100644
index e595ef2..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/DataBrowserResultLoader.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-
-public class DataBrowserResultLoader {
- private static DataBrowserResultLoader dbResultLoader = new DataBrowserResultLoader();
-
- public static DataBrowserResultLoader getInstance() {
- return dbResultLoader;
- }
-
- public String load(String queryString) throws IOException {
-
- URL url = null;
- InputStream inputStream = null;
- BufferedReader streamReader = null;
- String inputStr = null;
- StringBuilder sampleQueryResultResponseStrBuilder = null;
-
- try {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
- if (queryString.equals(PulseAbstractTest.QUERY_TYPE_ONE)) {
- url = classLoader.getResource("testQueryResultClusterSmall.txt");
- } else if (queryString.equals(PulseAbstractTest.QUERY_TYPE_TWO)) {
- url = classLoader.getResource("testQueryResultSmall.txt");
- } else if (queryString.equals(PulseAbstractTest.QUERY_TYPE_THREE)) {
- url = classLoader.getResource("testQueryResult.txt");
- } else if (queryString.equals(PulseAbstractTest.QUERY_TYPE_FOUR)) {
- url = classLoader.getResource("testQueryResultWithStructSmall.txt");
- } else if (queryString.equals(PulseAbstractTest.QUERY_TYPE_FIVE)) {
- url = classLoader.getResource("testQueryResultClusterWithStruct.txt");
- } else if (queryString.equals(PulseAbstractTest.QUERY_TYPE_SIX)) {
- url = classLoader.getResource("testQueryResultHashMapSmall.txt");
- } else if (queryString.equals(PulseAbstractTest.QUERY_TYPE_SEVENE)) {
- url = classLoader.getResource("testQueryResult1000.txt");
- } else {
- url = classLoader.getResource("testQueryResult.txt");
- }
-
- File sampleQueryResultFile = new File(url.getPath());
- inputStream = new FileInputStream(sampleQueryResultFile);
- streamReader = new BufferedReader(new InputStreamReader(inputStream,
- "UTF-8"));
- sampleQueryResultResponseStrBuilder = new StringBuilder();
-
- while ((inputStr = streamReader.readLine()) != null) {
- sampleQueryResultResponseStrBuilder.append(inputStr);
- }
-
- // close stream reader
- streamReader.close();
-
- } catch (IOException ex) {
- ex.printStackTrace();
- }
-
- return sampleQueryResultResponseStrBuilder.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDAggregateTable.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDAggregateTable.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDAggregateTable.java
deleted file mode 100644
index 18a452e..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDAggregateTable.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import javax.management.NotificationBroadcasterSupport;
-
-public class GemFireXDAggregateTable extends NotificationBroadcasterSupport
- implements GemFireXDAggregateTableMBean {
- private String name = null;
-
- public GemFireXDAggregateTable(String name) {
- this.name = name;
- }
-
- private String getKey(String propName) {
- return "table." + name + "." + propName;
- }
-
- @Override
- public long getEntrySize() {
- return Long.parseLong(JMXProperties.getInstance().getProperty(
- getKey("EntrySize")));
- }
-
- @Override
- public int getNumberOfRows() {
- return Integer.parseInt(JMXProperties.getInstance().getProperty(
- getKey("NumberOfRows")));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDAggregateTableMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDAggregateTableMBean.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDAggregateTableMBean.java
deleted file mode 100644
index 774db0b..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDAggregateTableMBean.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-public interface GemFireXDAggregateTableMBean {
- public static final String OBJECT_NAME = "GemFireXD:service=Table,type=Aggregate,table=";
-
- public long getEntrySize();
-
- public int getNumberOfRows();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDCluster.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDCluster.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDCluster.java
deleted file mode 100644
index c4a60a7..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDCluster.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-
-public class GemFireXDCluster extends NotificationBroadcasterSupport implements
- GemFireXDClusterMBean {
- private String name = null;
-
- private static String[] itemNames = { "connectionsAttempted",
- "connectionsActive", "connectionsClosed", "connectionsFailed" };;
- private static String[] itemDescriptions = { "connectionsAttempted",
- "connectionsActive", "connectionsClosed", "connectionsFailed" };
- private static OpenType[] itemTypes = { SimpleType.LONG, SimpleType.LONG,
- SimpleType.LONG, SimpleType.LONG };
- private static CompositeType networkServerClientConnectionStats = null;
-
- static {
- try {
- networkServerClientConnectionStats = new CompositeType(
- "NetworkServerClientConnectionStats",
- "Network Server Client Connection Stats Information", itemNames,
- itemDescriptions, itemTypes);
-
- } catch (OpenDataException e) {
- e.printStackTrace();
- }
- }
-
- public GemFireXDCluster(String name) {
- this.name = name;
- }
-
- private String getKey(String propName) {
- return "gemfirexd." + name + "." + propName;
- }
-
- @Override
- public int getProcedureCallsCompleted() {
- return Integer.parseInt(JMXProperties.getInstance().getProperty(
- getKey("ProcedureCallsCompleted")));
- }
-
- @Override
- public int getProcedureCallsInProgress() {
- return Integer.parseInt(JMXProperties.getInstance().getProperty(
- getKey("ProcedureCallsInProgress")));
- }
-
- @Override
- public CompositeData getNetworkServerClientConnectionStats() {
- String value = JMXProperties.getInstance().getProperty(
- getKey("NetworkServerClientConnectionStats"), "");
- String[] values = value.split(",");
- Long[] itemValues = new Long[values.length];
- for (int i = 0; i < values.length; i++) {
- itemValues[i] = Long.parseLong(values[i]);
- }
-
- CompositeData nscCompData;
- try {
- nscCompData = new CompositeDataSupport(
- networkServerClientConnectionStats, itemNames, itemValues);
- } catch (OpenDataException e) {
- e.printStackTrace();
- nscCompData = null;
- }
- return nscCompData;
-
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDClusterMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDClusterMBean.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDClusterMBean.java
deleted file mode 100644
index 43b8f92..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDClusterMBean.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import javax.management.openmbean.CompositeData;
-
-public interface GemFireXDClusterMBean {
- public static final String OBJECT_NAME = "GemFireXD:service=Cluster";
-
- public int getProcedureCallsCompleted();
-
- public int getProcedureCallsInProgress();
-
- public CompositeData getNetworkServerClientConnectionStats();
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDMember.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDMember.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDMember.java
deleted file mode 100644
index 1c042c6..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDMember.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-
-public class GemFireXDMember extends JMXBaseBean implements
- GemFireXDMemberMBean {
- private String name = null;
-
- private static String[] itemNames = { "connectionsAttempted",
- "connectionsActive", "connectionsClosed", "connectionsFailed" };;
- private static String[] itemDescriptions = { "connectionsAttempted",
- "connectionsActive", "connectionsClosed", "connectionsFailed" };
- private static OpenType[] itemTypes = { SimpleType.LONG, SimpleType.LONG,
- SimpleType.LONG, SimpleType.LONG };
- private static CompositeType networkServerClientConnectionStats = null;
-
- static {
- try {
- networkServerClientConnectionStats = new CompositeType(
- "NetworkServerClientConnectionStats",
- "Network Server Client Connection Stats Information", itemNames,
- itemDescriptions, itemTypes);
-
- } catch (OpenDataException e) {
- e.printStackTrace();
- }
- }
-
- public GemFireXDMember(String name) {
- this.name = name;
- }
-
- @Override
- protected String getKey(String propName) {
- return "gemfirexdmember." + name + "." + propName;
- }
-
- @Override
- public boolean getDataStore() {
- return getBoolean("DataStore");
- }
-
- @Override
- public CompositeData getNetworkServerClientConnectionStats() {
- Long[] itemValues = getLongArray("NetworkServerClientConnectionStats");
- CompositeData nscCompData;
- try {
- nscCompData = new CompositeDataSupport(
- networkServerClientConnectionStats, itemNames, itemValues);
- } catch (OpenDataException e) {
- e.printStackTrace();
- nscCompData = null;
- }
- return nscCompData;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDMemberMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDMemberMBean.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDMemberMBean.java
deleted file mode 100644
index f4392cf..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/GemFireXDMemberMBean.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import javax.management.openmbean.CompositeData;
-
-public interface GemFireXDMemberMBean {
-
- public static final String OBJECT_NAME = "GemFireXD:group=DEFAULT,type=Member";
-
- public boolean getDataStore();
-
- public CompositeData getNetworkServerClientConnectionStats();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/JMXBaseBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/JMXBaseBean.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/JMXBaseBean.java
deleted file mode 100644
index cff8d9a..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/JMXBaseBean.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-public abstract class JMXBaseBean {
-
- protected abstract String getKey(String propName);
-
- protected String getString(String key) {
- return JMXProperties.getInstance().getProperty(getKey(key));
- }
-
- protected String[] getStringArray(String key) {
- return JMXProperties.getInstance().getProperty(getKey(key), "").split(" ");
- }
-
- protected boolean getBoolean(String key) {
- return Boolean.parseBoolean(JMXProperties.getInstance().getProperty(
- getKey(key)));
- }
-
- protected int getInt(String key) {
- return Integer.parseInt(JMXProperties.getInstance()
- .getProperty(getKey(key)));
- }
-
- protected long getLong(String key) {
- return Long.parseLong(JMXProperties.getInstance().getProperty(getKey(key)));
- }
-
- protected Long[] getLongArray(String key) {
- String value = JMXProperties.getInstance().getProperty(getKey(key), "");
- String[] values = value.split(",");
- Long[] longValues = new Long[values.length];
- for (int i = 0; i < values.length; i++) {
- longValues[i] = Long.parseLong(values[i]);
- }
- return longValues;
- }
-
- protected double getDouble(String key) {
- return Double.parseDouble(JMXProperties.getInstance().getProperty(
- getKey(key)));
- }
-
- protected float getFloat(String key) {
- return Float.parseFloat(JMXProperties.getInstance()
- .getProperty(getKey(key)));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/JMXProperties.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/JMXProperties.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/JMXProperties.java
deleted file mode 100644
index bc91254..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/JMXProperties.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Properties;
-
-public class JMXProperties extends Properties {
- private static final long serialVersionUID = -6210901350494570026L;
-
- private static JMXProperties props = new JMXProperties();
-
- public static JMXProperties getInstance() {
- return props;
- }
-
- public void load(String propFile) throws IOException {
- if (propFile != null) {
- FileInputStream fin;
- fin = new FileInputStream(new File(propFile));
- if (fin != null) {
- clear();
- load(fin);
- }
-
- fin.close();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Member.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Member.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Member.java
deleted file mode 100644
index 98e015e..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Member.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-public class Member extends JMXBaseBean implements MemberMBean {
- private String name = null;
-
- public Member(String name) {
- this.name = name;
- }
-
- protected String getKey(String propName) {
- return "member." + name + "." + propName;
- }
-
- @Override
- public boolean getManager() {
- return getBoolean("manager");
- }
-
- @Override
- public int getTotalRegionCount() {
-// This count is built dynamically in Pulse backend and region count is maintained in Cluster.Member data structure
-// return getInt("totalRegionCount");
- return 0;
- }
-
- @Override
- public boolean getLocator() {
- return getBoolean("locator");
- }
-
- @Override
- public long getTotalDiskUsage() {
- return getLong("totalDiskUsage");
- }
-
- @Override
- public boolean getServer() {
- return getBoolean("sever");
- }
-
- @Override
- public String[] getGroups() {
- return getStringArray("Groups");
- }
-
- @Override
- /*public String[] getRedundancyZone() {
- return getStringArray("RedundancyZone");
- }*/
- public String getRedundancyZone() {
- return getString("RedundancyZone");
- }
-
- @Override
- public long getTotalFileDescriptorOpen() {
- return getLong("totalFileDescriptorOpen");
- }
-
- @Override
- public double getLoadAverage() {
- return getDouble("loadAverage");
- }
-
- @Override
- public double getDiskWritesRate() {
- return getDouble("diskWritesRate");
- }
-
- @Override
- public long getJVMPauses() {
- return getLong("JVMPauses");
- }
-
- @Override
- public long getCurrentHeapSize() {
-// return getLong("currentHeapSize");
- return getLong("UsedMemory");
- }
-
- @Override
- public long getMaximumHeapSize() {
-// return getLong("maximumHeapSize");
- return getLong("MaxMemory");
- }
-
- @Override
- public long getUsedMemory() {
- return getLong("UsedMemory");
- }
-
- @Override
- public long getMaxMemory() {
- return getLong("MaxMemory");
- }
-
- @Override
- public int getNumThreads() {
- return getInt("numThreads");
- }
-
- @Override
- public long getMemberUpTime() {
- return getLong("memberUpTime");
- }
-
- @Override
- public String getHost() {
- return getString("host");
- }
-
- @Override
- public long getTotalBytesOnDisk() {
- return getLong("totalBytesOnDisk");
- }
-
- @Override
- public double getCpuUsage() {
- return getDouble("cpuUsage");
- }
-
- @Override
- public String getMember() {
- return getString("member");
- }
-
- @Override
- public String getId() {
- return getString("id");
- }
-
- @Override
- public double getAverageReads() {
- return getDouble("averageReads");
- }
-
- @Override
- public double getAverageWrites() {
- return getDouble("averageWrites");
- }
-
- @Override
- public int getPort() {
- return getInt("port");
- }
-
- @Override
- public long getFoo() {
- return getLong("foo");
- }
-
- @Override
- public long getOffHeapFreeSize() {
- return getLong("OffHeapFreeSize");
- }
-
- @Override
- public long getOffHeapUsedSize() {
- return getLong("OffHeapUsedSize");
- }
-
- @Override
- public long getOffHeapFreeMemory() {
- return getLong("OffHeapFreeMemory");
- }
-
- @Override
- public long getOffHeapUsedMemory() {
- return getLong("OffHeapUsedMemory");
- }
-
- @Override
- public String getVersion() {
- return getString("Version");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/MemberMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/MemberMBean.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/MemberMBean.java
deleted file mode 100644
index f57d80f..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/MemberMBean.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-public interface MemberMBean {
- String OBJECT_NAME = "GemFire:type=Member";
-
- boolean getManager();
-
- int getTotalRegionCount();
-
- boolean getLocator();
-
- long getTotalDiskUsage();
-
- boolean getServer();
-
- String[] getGroups();
-
- //public String[] getRedundancyZone();
- String getRedundancyZone();
-
- long getTotalFileDescriptorOpen();
-
- double getLoadAverage();
-
- double getDiskWritesRate();
-
- long getJVMPauses();
-
- long getCurrentHeapSize();
-
- long getMaximumHeapSize();
-
- long getUsedMemory();
-
- long getMaxMemory();
-
- int getNumThreads();
-
- long getMemberUpTime();
-
- String getHost();
-
- long getTotalBytesOnDisk();
-
- double getCpuUsage();
-
- String getMember();
-
- String getId();
-
- double getAverageReads();
-
- double getAverageWrites();
-
- int getPort();
-
- long getFoo();
-
- long getOffHeapFreeSize();
-
- long getOffHeapUsedSize();
-
- long getOffHeapFreeMemory();
-
- long getOffHeapUsedMemory();
-
- String getVersion();
-}
[12/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java
deleted file mode 100644
index f09fa8c..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java
+++ /dev/null
@@ -1,816 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.vmware.gemfire.tools.pulse.controllers;
-
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.powermock.api.mockito.PowerMockito.spy;
-import static org.powermock.api.mockito.PowerMockito.when;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
-
-import java.io.File;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.UUID;
-import javax.servlet.ServletContextListener;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.vmware.gemfire.tools.pulse.internal.PulseAppListener;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.geode.test.junit.categories.UnitTest;
-import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConfig;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-
-import org.apache.commons.collections.buffer.CircularFifoBuffer;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-import org.powermock.modules.junit4.PowerMockRunnerDelegate;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-import org.springframework.web.context.WebApplicationContext;
-
-import org.apache.geode.test.junit.categories.IntegrationTest;
-
-@Category(IntegrationTest.class)
-@PrepareForTest(Repository.class)
-@RunWith(PowerMockRunner.class)
-@PowerMockRunnerDelegate(SpringJUnit4ClassRunner.class)
-@WebAppConfiguration
-@ContextConfiguration("classpath*:mvc-dispatcher-servlet.xml")
-@PowerMockIgnore("*.IntegrationTest")
-public class PulseControllerJUnitTest {
-
- private static final String PRINCIPAL_USER = "test-user";
-
- private static final String MEMBER_ID = "member1";
- private static final String MEMBER_NAME = "localhost-server";
- private static final String CLUSTER_NAME = "mock-cluster";
- private static final String REGION_NAME = "mock-region";
- private static final String REGION_PATH = "/" + REGION_NAME;
- private static final String REGION_TYPE = "PARTITION";
- private static final String AEQ_LISTENER = "async-event-listener";
- private static final String CLIENT_NAME = "client-1";
- private static final String PHYSICAL_HOST_NAME = "physical-host-1";
- private static final String GEMFIRE_VERSION = "1.0.0";
-
- private static final Principal principal;
-
- static {
- principal = () -> PRINCIPAL_USER;
- }
-
- @Rule
- public TemporaryFolder tempFolder = new TemporaryFolder();
-
- @Autowired
- private WebApplicationContext wac;
-
- private MockMvc mockMvc;
-
- private Cluster cluster;
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- @Before
- public void setup() throws Exception {
- this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
-
-
- cluster = Mockito.spy(Cluster.class);
-
- Cluster.Region region = new Cluster.Region();
- region.setName(REGION_NAME);
- region.setFullPath(REGION_PATH);
- region.setRegionType(REGION_TYPE);
- region.setMemberCount(1);
- region.setMemberName(new ArrayList<String>() {{
- add(MEMBER_NAME);
- }});
- region.setPutsRate(12.31D);
- region.setGetsRate(27.99D);
- Cluster.RegionOnMember regionOnMember = new Cluster.RegionOnMember();
- regionOnMember.setRegionFullPath(REGION_PATH);
- regionOnMember.setMemberName(MEMBER_NAME);
- region.setRegionOnMembers(new ArrayList<Cluster.RegionOnMember>() {{
- add(regionOnMember);
- }});
- cluster.addClusterRegion(REGION_PATH, region);
-
- Cluster.Member member = new Cluster.Member();
- member.setId(MEMBER_ID);
- member.setName(MEMBER_NAME);
- member.setUptime(1L);
- member.setHost(PHYSICAL_HOST_NAME);
- member.setGemfireVersion(GEMFIRE_VERSION);
- member.setCpuUsage(55.77123D);
-
- member.setMemberRegions(new HashMap<String, Cluster.Region>() {{
- put(REGION_NAME, region);
- }});
-
- Cluster.AsyncEventQueue aeq = new Cluster.AsyncEventQueue();
- aeq.setAsyncEventListener(AEQ_LISTENER);
- member.setAsyncEventQueueList(new ArrayList() {{
- add(aeq);
- }});
-
- Cluster.Client client = new Cluster.Client();
- client.setId("100");
- client.setName(CLIENT_NAME);
- client.setUptime(1L);
- member.setMemberClientsHMap(new HashMap<String, Cluster.Client>() {{
- put(CLIENT_NAME, client);
- }});
-
- cluster.setMembersHMap(new HashMap() {{
- put(MEMBER_NAME, member);
- }});
- cluster.setPhysicalToMember(new HashMap() {{
- put(PHYSICAL_HOST_NAME, new ArrayList() {{
- add(member);
- }});
- }});
- cluster.setServerName(CLUSTER_NAME);
- cluster.setMemoryUsageTrend(new CircularFifoBuffer() {{
- add(1);
- add(2);
- add(3);
- }});
- cluster.setWritePerSecTrend(new CircularFifoBuffer() {{
- add(1.29);
- add(2.3);
- add(3.0);
- }});
- cluster.setThroughoutReadsTrend(new CircularFifoBuffer() {{
- add(1);
- add(2);
- add(3);
- }});
- cluster.setThroughoutWritesTrend(new CircularFifoBuffer() {{
- add(4);
- add(5);
- add(6);
- }});
-
- Repository repo = Mockito.spy(Repository.class);
-
- // Set up a partial mock for some static methods
- spy(Repository.class);
- when(Repository.class, "get").thenReturn(repo);
- doReturn(cluster).when(repo).getCluster();
-
- PulseConfig config = new PulseConfig();
- File tempQueryLog = tempFolder.newFile("query_history.log");
- config.setQueryHistoryFileName(tempQueryLog.toString());
- doReturn(config).when(repo).getPulseConfig();
-
- PulseController.pulseVersion.setPulseVersion("not empty");
- PulseController.pulseVersion.setPulseBuildId("not empty");
- PulseController.pulseVersion.setPulseBuildDate("not empty");
- PulseController.pulseVersion.setPulseSourceDate("not empty");
- PulseController.pulseVersion.setPulseSourceRevision("not empty");
- PulseController.pulseVersion.setPulseSourceRepository("not empty");
- }
-
- @Test
- public void pulseUpdateForClusterDetails() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"ClusterDetails\":\"{}\"}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.ClusterDetails.userName").value(PRINCIPAL_USER))
- .andExpect(jsonPath("$.ClusterDetails.totalHeap").value(0D))
- .andExpect(jsonPath("$.ClusterDetails.clusterName").value(CLUSTER_NAME))
- ;
- }
-
- @Test
- public void pulseUpdateForClusterDiskThroughput() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"ClusterDiskThroughput\":\"{}\"}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.ClusterDiskThroughput.currentThroughputWrites").value(0D))
- .andExpect(jsonPath("$.ClusterDiskThroughput.throughputReads", contains(1, 2, 3)))
- .andExpect(jsonPath("$.ClusterDiskThroughput.currentThroughputReads").value(0D))
- .andExpect(jsonPath("$.ClusterDiskThroughput.throughputWrites", contains(4, 5, 6)))
- ;
- }
-
- @Test
- public void pulseUpdateForClusterGCPauses() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"ClusterJVMPauses\":\"{}\"}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.ClusterJVMPauses.currentGCPauses").value(0))
- .andExpect(jsonPath("$.ClusterJVMPauses.gCPausesTrend").isEmpty())
- ;
- }
-
- @Test
- public void pulseUpdateForClusterKeyStatistics() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"ClusterKeyStatistics\":\"{}\"}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.ClusterKeyStatistics.readPerSecTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterKeyStatistics.queriesPerSecTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterKeyStatistics.writePerSecTrend", contains(1.29, 2.3, 3.0)))
- ;
- }
-
- @Test
- public void pulseUpdateForClusterMember() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"ClusterMembers\":\"{}\"}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.ClusterMembers.members[0].serverGroups[0]").value("Default"))
- .andExpect(jsonPath("$.ClusterMembers.members[0].cpuUsage").value(55.77D))
- .andExpect(jsonPath("$.ClusterMembers.members[0].clients").value(1))
- .andExpect(jsonPath("$.ClusterMembers.members[0].heapUsage").value(0))
- .andExpect(jsonPath("$.ClusterMembers.members[0].name").value(MEMBER_NAME))
- .andExpect(jsonPath("$.ClusterMembers.members[0].currentHeapUsage").value(0))
- .andExpect(jsonPath("$.ClusterMembers.members[0].isManager").value(false))
- .andExpect(jsonPath("$.ClusterMembers.members[0].threads").value(0))
- .andExpect(jsonPath("$.ClusterMembers.members[0].memberId").value(MEMBER_ID))
- .andExpect(jsonPath("$.ClusterMembers.members[0].redundancyZones[0]").value("Default"))
- ;
- }
-
- @Test
- public void pulseUpdateForClusterMembersRGraph() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"ClusterMembersRGraph\":\"{}\"}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.ClusterMembersRGraph.memberCount").value(0))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.data").isEmpty())
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.name").value(0))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.id").value(0))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].id").value(PHYSICAL_HOST_NAME))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].name").value(PHYSICAL_HOST_NAME))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.loadAvg").value(0D))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.sockets").value(0))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.threads").value(0))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.cpuUsage").value(0D))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.memoryUsage").value(0))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.hostStatus").value("Normal"))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.$type").value("hostNormalNode"))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].id").value(MEMBER_ID))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].name").value(MEMBER_NAME))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.gemfireVersion").value(GEMFIRE_VERSION))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.memoryUsage").value(0))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.cpuUsage").value(55.77D))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.regions").value(1))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.host").value(PHYSICAL_HOST_NAME))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.port").value("-"))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.clients").value(1))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.gcPauses").value(0))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.numThreads").value(0))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.nodeType").value("memberNormalNode"))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.$type").value("memberNormalNode"))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.gatewaySender").value(0))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.gatewayReceiver").value(0))
- .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].children").isEmpty())
- ;
- }
-
- @Test
- public void pulseUpdateForClusterMemoryUsage() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"ClusterMemoryUsage\":\"{}\"}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.ClusterMemoryUsage.currentMemoryUsage").value(0))
- .andExpect(jsonPath("$.ClusterMemoryUsage.memoryUsageTrend", containsInAnyOrder(1, 2, 3)))
- ;
- }
-
- @Test
- public void pulseUpdateForClusterRegion() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"ClusterRegion\":\"{}\"}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.ClusterRegion.clusterName").value(CLUSTER_NAME))
- .andExpect(jsonPath("$.ClusterRegion.userName").value(PRINCIPAL_USER))
- .andExpect(jsonPath("$.ClusterRegion.region[0].regionPath").value(REGION_PATH))
- .andExpect(jsonPath("$.ClusterRegion.region[0].diskReadsTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterRegion.region[0].memoryUsage").value("0.0000"))
- .andExpect(jsonPath("$.ClusterRegion.region[0].getsRate").value(27.99D))
- .andExpect(jsonPath("$.ClusterRegion.region[0].wanEnabled").value(false))
- .andExpect(jsonPath("$.ClusterRegion.region[0].memberCount").value(1))
- .andExpect(jsonPath("$.ClusterRegion.region[0].memberNames[0].name").value(MEMBER_NAME))
- .andExpect(jsonPath("$.ClusterRegion.region[0].memberNames[0].id").value(MEMBER_ID))
- .andExpect(jsonPath("$.ClusterRegion.region[0].emptyNodes").value(0))
- .andExpect(jsonPath("$.ClusterRegion.region[0].type").value(REGION_TYPE))
- .andExpect(jsonPath("$.ClusterRegion.region[0].isEnableOffHeapMemory").value("OFF"))
- .andExpect(jsonPath("$.ClusterRegion.region[0].putsRate").value(12.31D))
- .andExpect(jsonPath("$.ClusterRegion.region[0].totalMemory").value(0))
- .andExpect(jsonPath("$.ClusterRegion.region[0].entryCount").value(0))
- .andExpect(jsonPath("$.ClusterRegion.region[0].compressionCodec").value("NA"))
- .andExpect(jsonPath("$.ClusterRegion.region[0].name").value(REGION_NAME))
- .andExpect(jsonPath("$.ClusterRegion.region[0].systemRegionEntryCount").value(0))
- .andExpect(jsonPath("$.ClusterRegion.region[0].persistence").value("OFF"))
- .andExpect(jsonPath("$.ClusterRegion.region[0].memoryReadsTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterRegion.region[0].diskWritesTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterRegion.region[0].memoryWritesTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterRegion.region[0].dataUsage").value(0))
- .andExpect(jsonPath("$.ClusterRegion.region[0].entrySize").value("0.0000"))
- ;
- }
-
- @Test
- public void pulseUpdateForClusterRegions() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"ClusterRegions\":\"{}\"}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.ClusterRegions.regions[0].regionPath").value(REGION_PATH))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].diskReadsTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterRegions.regions[0].memoryUsage").value("0.0000"))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].getsRate").value(27.99D))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].wanEnabled").value(false))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].memberCount").value(1))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].memberNames[0].name").value(MEMBER_NAME))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].memberNames[0].id").value(MEMBER_ID))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].emptyNodes").value(0))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].type").value(REGION_TYPE))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].isEnableOffHeapMemory").value("OFF"))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].putsRate").value(12.31D))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].totalMemory").value(0))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].entryCount").value(0))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].compressionCodec").value("NA"))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].name").value(REGION_NAME))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].systemRegionEntryCount").value(0))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].persistence").value("OFF"))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].memoryReadsTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterRegions.regions[0].diskWritesTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterRegions.regions[0].memoryWritesTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterRegions.regions[0].dataUsage").value(0))
- .andExpect(jsonPath("$.ClusterRegions.regions[0].entrySize").value("0.0000"))
- ;
- }
-
- @Test
- public void pulseUpdateForClusterSelectedRegion() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"ClusterSelectedRegion\":{\"regionFullPath\":\"" + REGION_PATH + "\"}}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.lruEvictionRate").value(0D))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.getsRate").value(27.99D))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.emptyNodes").value(0))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.type").value(REGION_TYPE))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.isEnableOffHeapMemory").value("OFF"))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.path").value(REGION_PATH))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].cpuUsage").value(55.77D))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].clients").value(1))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].heapUsage").value(0))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].name").value(MEMBER_NAME))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].currentHeapUsage").value(0))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].isManager").value(false))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].threads").value(0))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].memberId").value(MEMBER_ID))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].uptime").value("0 Hours 0 Mins 1 Secs"))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.memoryReadsTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.diskWritesTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.dataUsage").value(0))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.regionPath").value(REGION_PATH))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.diskReadsTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.memoryUsage").value("0.0000"))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.wanEnabled").value(false))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.memberCount").value(1))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.putsRate").value(12.31D))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.totalMemory").value(0))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.entryCount").value(0))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.compressionCodec").value("NA"))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.name").value(REGION_NAME))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.systemRegionEntryCount").value(0))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.persistence").value("OFF"))
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.memoryWritesTrend").isEmpty())
- .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.entrySize").value("0.0000"))
- ;
- }
-
- @Test
- public void pulseUpdateForClusterSelectedRegionsMember() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"ClusterSelectedRegionsMember\":{\"regionFullPath\":\"" + REGION_PATH + "\"}}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.diskReadsTrend", MEMBER_NAME).isEmpty())
- .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.regionFullPath", MEMBER_NAME).value(REGION_PATH))
- .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.entryCount", MEMBER_NAME).value(0))
- .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.accessor", MEMBER_NAME).value("True"))
- .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.memberName", MEMBER_NAME).value(MEMBER_NAME))
- .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.memoryReadsTrend", MEMBER_NAME).isEmpty())
- .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.diskWritesTrend", MEMBER_NAME).isEmpty())
- .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.memoryWritesTrend", MEMBER_NAME).isEmpty())
- .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.entrySize", MEMBER_NAME).value(0))
- .andExpect(jsonPath("$.ClusterSelectedRegionsMember.clusterName").value(CLUSTER_NAME))
- .andExpect(jsonPath("$.ClusterSelectedRegionsMember.userName").value(PRINCIPAL_USER))
- ;
- }
-
- @Test
- public void pulseUpdateForClusterWANInfo() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"ClusterWANInfo\":\"{}\"}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.ClusterWANInfo.connectedClusters").isEmpty())
- ;
- }
-
- @Test
- public void pulseUpdateForMemberAsynchEventQueues() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"MemberAsynchEventQueues\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.MemberAsynchEventQueues.isAsyncEventQueuesPresent").value(true))
- .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].batchTimeInterval").value(0))
- .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].batchConflationEnabled").value(false))
- .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].queueSize").value(0))
- .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].senderType").value(false))
- .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].asyncEventListener").value(AEQ_LISTENER))
- .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].batchSize").value(0))
- .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].primary").value(false))
- ;
- }
-
- @Test
- public void pulseUpdateForMemberClients() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"MemberClients\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.MemberClients.name").value(MEMBER_NAME))
- .andExpect(jsonPath("$.MemberClients.memberClients[0].puts").value(0))
- .andExpect(jsonPath("$.MemberClients.memberClients[0].cpuUsage").value("0.0000"))
- .andExpect(jsonPath("$.MemberClients.memberClients[0].clientId").value("100"))
- .andExpect(jsonPath("$.MemberClients.memberClients[0].queueSize").value(0))
- .andExpect(jsonPath("$.MemberClients.memberClients[0].clientCQCount").value(0))
- .andExpect(jsonPath("$.MemberClients.memberClients[0].name").value(CLIENT_NAME))
- .andExpect(jsonPath("$.MemberClients.memberClients[0].isConnected").value("No"))
- .andExpect(jsonPath("$.MemberClients.memberClients[0].threads").value(0))
- .andExpect(jsonPath("$.MemberClients.memberClients[0].isSubscriptionEnabled").value("No"))
- .andExpect(jsonPath("$.MemberClients.memberClients[0].gets").value(0))
- .andExpect(jsonPath("$.MemberClients.memberClients[0].uptime").value("0 Hours 0 Mins 1 Secs"))
- ;
- }
-
- @Test
- public void pulseUpdateForMemberDetails() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"MemberDetails\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.MemberDetails.name").value(MEMBER_NAME))
- .andExpect(jsonPath("$.MemberDetails.offHeapUsedSize").value(0))
- .andExpect(jsonPath("$.MemberDetails.diskStorageUsed").value(0D))
- .andExpect(jsonPath("$.MemberDetails.regionsCount").value(1))
- .andExpect(jsonPath("$.MemberDetails.clusterName").value(CLUSTER_NAME))
- .andExpect(jsonPath("$.MemberDetails.name").value(MEMBER_NAME))
- .andExpect(jsonPath("$.MemberDetails.threads").value(0))
- .andExpect(jsonPath("$.MemberDetails.clusterId").isNotEmpty())
- .andExpect(jsonPath("$.MemberDetails.numClients").value(1))
- .andExpect(jsonPath("$.MemberDetails.userName").value(PRINCIPAL_USER))
- .andExpect(jsonPath("$.MemberDetails.offHeapFreeSize").value(0))
- .andExpect(jsonPath("$.MemberDetails.memberId").value(MEMBER_ID))
- .andExpect(jsonPath("$.MemberDetails.status").value("Normal"))
- ;
- }
-
- @Test
- public void pulseUpdateForMemberDiskThroughput() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"MemberDiskThroughput\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.MemberDiskThroughput.throughputWritesTrend").isEmpty())
- .andExpect(jsonPath("$.MemberDiskThroughput.throughputReadsTrend").isEmpty())
- .andExpect(jsonPath("$.MemberDiskThroughput.throughputWrites").value(0D))
- .andExpect(jsonPath("$.MemberDiskThroughput.throughputReads").value(0D))
- ;
- }
-
- @Test
- public void pulseUpdateForMemberGatewayHub() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"MemberGatewayHub\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.MemberGatewayHub.isGatewayReceiver").value(false))
- .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].batchTimeInterval").value(0))
- .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].batchConflationEnabled").value(false))
- .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].queueSize").value(0))
- .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].senderType").value(false))
- .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].asyncEventListener").value(AEQ_LISTENER))
- .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].batchSize").value(0))
- .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].primary").value(false))
- .andExpect(jsonPath("$.MemberGatewayHub.isGatewaySender").value(false))
- .andExpect(jsonPath("$.MemberGatewayHub.regionsInvolved").isEmpty())
- .andExpect(jsonPath("$.MemberGatewayHub.gatewaySenders").isEmpty())
- ;
- }
-
- @Test
- public void pulseUpdateForMemberGCPauses() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"MemberGCPauses\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.MemberGCPauses.gcPausesCount").value(0))
- .andExpect(jsonPath("$.MemberGCPauses.gcPausesTrend").isEmpty())
- ;
- }
-
- @Test
- public void pulseUpdateForMemberHeapUsage() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"MemberHeapUsage\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.MemberHeapUsage.heapUsageTrend").isEmpty())
- .andExpect(jsonPath("$.MemberHeapUsage.currentHeapUsage").value(0))
- ;
- }
-
- @Test
- public void pulseUpdateForMemberKeyStatistics() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"MemberKeyStatistics\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.MemberKeyStatistics.readPerSecTrend").isEmpty())
- .andExpect(jsonPath("$.MemberKeyStatistics.cpuUsageTrend").isEmpty())
- .andExpect(jsonPath("$.MemberKeyStatistics.memoryUsageTrend").isEmpty())
- .andExpect(jsonPath("$.MemberKeyStatistics.writePerSecTrend").isEmpty())
- ;
- }
-
- @Test
- public void pulseUpdateForMemberRegions() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"MemberRegions\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.MemberRegions.name").value(MEMBER_NAME))
- .andExpect(jsonPath("$.MemberRegions.memberRegions[0].fullPath").value(REGION_PATH))
- .andExpect(jsonPath("$.MemberRegions.memberRegions[0].entryCount").value(0))
- .andExpect(jsonPath("$.MemberRegions.memberRegions[0].name").value(REGION_NAME))
- .andExpect(jsonPath("$.MemberRegions.memberRegions[0].diskStoreName").value(""))
- .andExpect(jsonPath("$.MemberRegions.memberRegions[0].gatewayEnabled").value(false))
- .andExpect(jsonPath("$.MemberRegions.memberRegions[0].entrySize").value("0.0000"))
- .andExpect(jsonPath("$.MemberRegions.memberId").value(MEMBER_ID))
- .andExpect(jsonPath("$.MemberRegions.status").value("Normal"))
- ;
- }
-
- @Test
- public void pulseUpdateForMembersList() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"MembersList\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.MembersList.clusterMembers[0].name").value(MEMBER_NAME))
- .andExpect(jsonPath("$.MembersList.clusterMembers[0].memberId").value(MEMBER_ID))
- .andExpect(jsonPath("$.MembersList.clusterName").value(CLUSTER_NAME))
- ;
- }
-
- @Test
- public void pulseUpdateForPulseVersion() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"PulseVersion\":\"{}\"}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.PulseVersion.sourceDate").value("not empty"))
- .andExpect(jsonPath("$.PulseVersion.sourceRepository").value("not empty"))
- .andExpect(jsonPath("$.PulseVersion.pulseVersion").value("not empty"))
- .andExpect(jsonPath("$.PulseVersion.sourceRevision").value("not empty"))
- .andExpect(jsonPath("$.PulseVersion.buildId").value("not empty"))
- .andExpect(jsonPath("$.PulseVersion.buildDate").value("not empty"))
- ;
- }
-
- @Test
- public void pulseUpdateForQueryStatistics() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"QueryStatistics\":\"{}\"}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.QueryStatistics.queriesList").isEmpty())
- .andExpect(jsonPath("$.QueryStatistics.connectedFlag").value(false))
- .andExpect(jsonPath("$.QueryStatistics.connectedErrorMsg").value(""))
- ;
- }
-
- @Test
- public void pulseUpdateForSystemAlerts() throws Exception {
- this.mockMvc.perform(post("/pulseUpdate")
- .param("pulseData", "{\"SystemAlerts\":{\"pageNumber\":\"1\"}}")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.SystemAlerts.pageNumber").value(1))
- .andExpect(jsonPath("$.SystemAlerts.connectedFlag").value(false))
- .andExpect(jsonPath("$.SystemAlerts.connectedErrorMsg").value(""))
- .andExpect(jsonPath("$.SystemAlerts.systemAlerts").isEmpty())
- ;
- }
-
- @Test
- public void authenticateUserNotLoggedIn() throws Exception {
- this.mockMvc.perform(get("/authenticateUser")
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.isUserLoggedIn").value(false));
- }
-
- @Test
- public void authenticateUserLoggedIn() throws Exception {
- this.mockMvc.perform(get("/authenticateUser")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.isUserLoggedIn").value(true));
- }
-
- @Test
- public void pulseVersion() throws Exception {
- this.mockMvc.perform(get("/pulseVersion")
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.pulseVersion").isNotEmpty())
- .andExpect(jsonPath("$.buildId").isNotEmpty())
- .andExpect(jsonPath("$.buildDate").isNotEmpty())
- .andExpect(jsonPath("$.sourceDate").isNotEmpty())
- .andExpect(jsonPath("$.sourceRevision").isNotEmpty())
- .andExpect(jsonPath("$.sourceRepository").isNotEmpty())
- ;
- }
-
- @Test
- public void clearAlerts() throws Exception {
- this.mockMvc.perform(get("/clearAlerts")
- .param("alertType", "1")
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.pageNumber").value(1))
- .andExpect(jsonPath("$.systemAlerts").isEmpty())
- .andExpect(jsonPath("$.connectedFlag").value(false))
- .andExpect(jsonPath("$.status").value("deleted"))
- ;
- }
-
- @Test
- public void acknowledgeAlert() throws Exception {
- this.mockMvc.perform(get("/acknowledgeAlert")
- .param("alertId", "1")
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.status").value("deleted"));
- }
-
- @Test
- public void dataBrowserRegions() throws Exception {
- this.mockMvc.perform(get("/dataBrowserRegions")
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.clusterName").value(CLUSTER_NAME))
- .andExpect(jsonPath("$.connectedFlag").value(false))
- .andExpect(jsonPath("$.clusterRegions[0].fullPath").value(REGION_PATH))
- .andExpect(jsonPath("$.clusterRegions[0].regionType").value(REGION_TYPE))
- ;
- }
-
- @Test
- public void dataBrowserQuery() throws Exception {
- doReturn(mapper.createObjectNode().put("foo", "bar")).when(cluster).executeQuery(anyString(), anyString(), anyInt());
-
- this.mockMvc.perform(get("/dataBrowserQuery")
- .param("query", "SELECT * FROM " + REGION_PATH)
- .param("members", MEMBER_NAME)
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.foo").value("bar"))
- ;
- }
-
- @Test
- public void dataBrowserQueryHistory() throws Exception {
- dataBrowserQuery();
-
- this.mockMvc.perform(get("/dataBrowserQueryHistory")
- .param("action", "view")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.queryHistory[0].queryText").value("\"SELECT * FROM " + REGION_PATH + "\""))
- ;
- }
-
- @Test
- public void pulseProductSupport() throws Exception {
- this.mockMvc.perform(get("/pulseProductSupport")
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.product").value("gemfire"))
- ;
- }
-
- @Test
- public void getQueryStatisticsGridModel() throws Exception {
- this.mockMvc.perform(get("/getQueryStatisticsGridModel")
- .principal(principal)
- .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
- .andExpect(status().isOk())
- .andExpect(jsonPath("$.columnNames", containsInAnyOrder("Query",
- "NumExecution",
- "TotalExecutionTime(ns)",
- "NumExecutionsInProgress",
- "NumTimesCompiled",
- "NumTimesGlobalIndexLookup",
- "NumRowsModified",
- "ParseTime(ms)",
- "BindTime(ms)",
- "OptimizeTime(ms)",
- "RoutingInfoTime(ms)",
- "GenerateTime(ms)",
- "TotalCompilationTime(ms)",
- "ExecutionTime(ns)",
- "ProjectionTime(ns)",
- "RowsModificationTime(ns)",
- "QNNumRowsSeen",
- "QNMsgSendTime(ns)",
- "QNMsgSerTime(ns)",
- "QNRespDeSerTime(ns)")))
- ;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/GemFireDistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/GemFireDistributedSystem.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/GemFireDistributedSystem.java
deleted file mode 100644
index cf2bc86..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/GemFireDistributedSystem.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.testbed;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
-
-
-/**
- *
- * TODO
- * 0. SystemAlerts
- * 1. Operations like member-up/down/crash, region create/destroy [7.5 scope]
- * 2. Read events like member-up/down/crash, region create/destroy [7.5 scope]
- * 3. PropFile Writing
- * 4. Link to other remote systems, topology - multi-cluster [7.5]
- *
- *
- */
-public class GemFireDistributedSystem {
-
- private static final String SERVERS = "servers";
- private static final String LOCATORS_NAME = LOCATORS;
- private static final String PEERS = "peers";
- private static final String HOSTS = "hosts";
- private static final String REGIONS = "regions";
- private static final String CLIENTS = "clients";
- private static final String SEP = ".";
- private static final String FUNCTIONS = null;
- private static final String CQS = null;
-
-
- List<Server> servers = new ArrayList<Server>();
- List<Client> clients = new ArrayList<Client>();
- List<Locator> locators = new ArrayList<Locator>();
- List<Peer> peers = new ArrayList<Peer>();
- List<Host> hosts = new ArrayList<Host>();
- List<Region> regions = new ArrayList<Region>();
- List<Function> functions = new ArrayList<Function>();
- List<CQ> cqs = new ArrayList<CQ>();
- String dsName = null;
-
- public GemFireDistributedSystem(String name,Properties pr){
- PropFileHelper propertiesFile = new PropFileHelper(pr);
- this.dsName = name;
- readGemfireDS(propertiesFile);
- }
-
- public GemFireDistributedSystem(String name,String fileName) throws IOException{
- PropFileHelper propertiesFile = new PropFileHelper(fileName);
- this.dsName = name;
- readGemfireDS(propertiesFile);
- }
-
- private void readGemfireDS(PropFileHelper propertiesFile) {
- String serverStrings[] = propertiesFile.readValues(dsName + SEP + SERVERS);
- System.out.println("Servers = " + serverStrings.length);
- for(String serverName : serverStrings){
- Server server = new Server();
- server.init(propertiesFile,dsName,serverName);
- servers.add(server);
- }
-
- String clientStrings[] = propertiesFile.readValues(dsName + SEP + CLIENTS);
- System.out.println("Clients = " + clientStrings.length);
- for(String clientName : clientStrings){
- Client client = new Client();
- client.init(propertiesFile,dsName,clientName);
- clients.add(client);
- }
-
- String locatorStrings[] = propertiesFile.readValues(dsName + SEP + LOCATORS);
- System.out.println("Locators = " + locatorStrings.length);
- for(String locatorName : locatorStrings){
- Locator locator = new Locator();
- locator.init(propertiesFile,dsName,locatorName);
- locators.add(locator);
- }
-
- String peerStrings[] = propertiesFile.readValues(dsName + SEP + PEERS);
- System.out.println("Peers = " + peerStrings.length);
- for(String peerName : peerStrings){
- Peer peer = new Peer();
- peer.init(propertiesFile,dsName,peerName);
- peers.add(peer);
- }
-
- String hostsStrings[] = propertiesFile.readValues(dsName + SEP + HOSTS);
- for(String hostName : hostsStrings){
- Host host = new Host();
- host.init(propertiesFile,dsName,hostName);
- hosts.add(host);
- }
-
- String regionsStrings[] = propertiesFile.readValues(dsName + SEP + REGIONS);
- for(String regionName : regionsStrings){
- Region region = new Region();
- region.init(propertiesFile,dsName,regionName);
- regions.add(region);
- }
-
- String functionStrings[] = propertiesFile.readValues(dsName + SEP + FUNCTIONS);
- for(String functionName : functionStrings){
- Function function = new Function();
- function.init(propertiesFile,dsName,functionName);
- functions.add(function);
- }
-
- String cqStrings[] = propertiesFile.readValues(dsName + SEP + CQS);
- for(String cqName : cqStrings){
- CQ cq = new CQ();
- cq.init(propertiesFile,dsName,cqName);
- cqs.add(cq);
- }
-
- }
-
- public List<Region> getRegions(String memberName) {
- List<Region> list = new ArrayList<Region>();
- for(Region r : regions){
- if(r.getMembers().contains(memberName))
- list.add(r);
- }
- return list;
- }
-
- public Region getRegion(String regionName) {
- Region r = null;
- for (Region rn : getRegions()) {
- if (rn.getName().equals(regionName)) {
- r = rn;
- break;
- }
- }
- return r;
- }
-
- public List<Region> getRegions() {
- return regions;
- }
-
- public List<Function> getFunction() {
- return functions;
- }
-
- public List<CQ> getCQs() {
- return cqs;
- }
-
- public List<Server> getServers(){
- return servers;
- }
-
- public List<Client> getClients(){
- return clients;
- }
-
- public List<Peer> getPeers(){
- return peers;
- }
-
- public List<Locator> getLocators(){
- return locators;
- }
-
- public List<Host> getPhysicalHosts(){
- return hosts;
- }
-
- public static class Base{
- protected Map<String,String> properties=null;
- protected String name;
-
- public void init(PropFileHelper propertiesFile, String dsName, String name) {
- this.name = name;
- String leadingkey = dsName + SEP + name;
- Map<String,String> map = propertiesFile.readObject(leadingkey);
- map.put("name",name);
- this.properties = map;
- }
-
- public String getName(){
- return properties.get("name");
- }
-
- public String key(String string) {
- return properties.get(string);
- }
-
- public int keyInt(String string) {
- String str = properties.get(string);
- try{
- int index = Integer.parseInt(str);
- return index;
- }catch(Exception e){
- return -1;
- }
- }
-
- public List<String> values(String string) {
- String values= properties.get(string);
- String array[] = values.split(",");
- List<String> list = new ArrayList<String>();
- for(String s:array)
- list.add(s);
- return list;
- }
-
- }
-
- public static class Host extends Base{
-
- }
-
- public static class Server extends Base{
- public String toString(){
- return properties.get("name") + "[on host=" + properties.get("host");
- }
-
- public String getHost(){
- return properties.get("host");
- }
- }
-
- public static class Client extends Base{
- public String toString(){
- return properties.get("name") ;//+ "[on host=" + properties.get("host");
- }
-
- public String getHost(){
- return properties.get("host");
- }
- }
-
- public static class Locator extends Base{
- public String getHost(){
- return properties.get("host");
- }
- }
-
- public static class Peer extends Base{
-
- public String getHost(){
- return properties.get("host");
- }
- }
-
- public static class Region extends Base{
- public String toString(){
- return properties.get("name") + "[type=" + properties.get("type");
- }
-
- public String getType(){
- return key("type");
- }
-
- public int getEntryCount(){
- return keyInt("entryCount");
- }
-
- public List<String> getWanSenders(){
- return values("wanSenders");
- }
-
- public List<String> getMembers(){
- return values("members");
- }
-
- }
-
- public static class WanSender extends Base{
-
- }
-
- public static class Function extends Base{
- public String getMemberId(){
- return key("memberId");
- }
- }
-
- public static class CQ extends Base{
- public String getQuery(){
- return key("query");
- }
-
- public String getClient(){
- return key("client");
- }
- }
-
- public static class SystemAlert extends Base{
- //TODO
- }
-
- public static void main(String[] args) throws IOException {
-
- GemFireDistributedSystem ds = new GemFireDistributedSystem("t1", "config/testbed.properties");
- System.out.println("Servers = " + ds.getServers());
- System.out.println("Regions = " + ds.getRegions());
- System.out.println("Clients = " + ds.getClients());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/GemfireTopology.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/GemfireTopology.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/GemfireTopology.java
deleted file mode 100644
index 24eed8d..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/GemfireTopology.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.testbed;
-
-public class GemfireTopology {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/PropFileHelper.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/PropFileHelper.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/PropFileHelper.java
deleted file mode 100644
index 02d4f91..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/PropFileHelper.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.testbed;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-public class PropFileHelper {
-
- private String filePath=null;
- private Properties pr=null;
-
- public PropFileHelper(String filePath) throws FileNotFoundException, IOException{
- this.filePath = filePath;
- pr = new Properties();
- pr.load(new FileInputStream(new File(this.filePath)));
- }
-
- public PropFileHelper(Properties pr2) {
- this.pr =pr2;
- }
-
- public String[] readValues(String property){
- return readValues(property,",");
- }
-
- public String[] readValues(String property, String separator){
- String value = readKey(property);
- if(value!=null){
- String[] array = value.split(separator);
- return array;
- }else{
- return new String[0];
- }
- }
-
- public String readKey(String key){
- String value = pr.getProperty(key);
- if(value!=null)
- return value.trim();
- else return value;
- }
-
- public Map<String,String> readObject(String leadingkey){
- Map<String,String> map = new HashMap<String,String>();
- String leadingKeyString = leadingkey+".";
- for(Object keyObject : pr.keySet()){
- String key = (String)keyObject;
- String value = readKey(key);
- if(key.startsWith(leadingKeyString)){
- String innerProp = key.substring(leadingKeyString.length());
- /* inner object stuff
- if(checkForMultipleValues){
- if(innerProp.contains(separator)){
- String array[] = readValues(key);
- }
- }else*/
- {
- //System.out.println("Adding prop with key " + innerProp + " k=" + leadingkey);
- map.put(innerProp, value);
- }
- }
- }
- return map;
- }
-
- public static void main(String[] args) {
-
- Properties pr = new Properties();
- pr.put("topologies", "t1,t2");
- pr.put("t1.id", "1");
- pr.put("t2.id", "2");
-
- pr.put("t1.prop1", "prop11");
- pr.put("t1.prop2", "prop12");
- pr.put("t1.prop3", "prop13");
- pr.put("t2.prop1", "1");
- pr.put("t2.prop2", "2");
- pr.put("t2.prop3", "3");
-
- PropFileHelper helper = new PropFileHelper(pr);
- String topologies[] = helper.readValues("topologies");
- for(String topology : topologies){
- Map<String,String> topologyMap = helper.readObject(topology);
- System.out.println(topologyMap);
- }
-
- }
-
- public Properties getProperties() {
- return pr;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/PropMockDataUpdater.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/PropMockDataUpdater.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/PropMockDataUpdater.java
deleted file mode 100644
index ee530d2..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/PropMockDataUpdater.java
+++ /dev/null
@@ -1,513 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.testbed;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster.Alert;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster.Client;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster.GatewayReceiver;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster.GatewaySender;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster.Member;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster.Region;
-import com.vmware.gemfire.tools.pulse.internal.data.IClusterUpdater;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Locator;
-import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Peer;
-import com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Server;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Random;
-import java.util.ResourceBundle;
-
-public class PropMockDataUpdater implements IClusterUpdater {
- private static final int MAX_HOSTS = 40;
- private static final PulseLogWriter LOGGER = PulseLogWriter.getLogger();
- private final ResourceBundle resourceBundle = Repository.get().getResourceBundle();
- private static final int POLL_INTERVAL = 5000;
- public static final int MAX_SAMPLE_SIZE = 180;
- public static final int ALERTS_MAX_SIZE = 1000;
- public static final int PAGE_ALERTS_MAX_SIZE = 100;
-
- private Cluster cluster= null;
- private TestBed testbed;
- private final String testbedFile = System.getProperty("pulse.propMockDataUpdaterFile");;
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public PropMockDataUpdater(Cluster cluster) {
- this.cluster = cluster;
- try {
- loadPropertiesFile();
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- private void loadPropertiesFile() throws FileNotFoundException, IOException{
- this.testbed = new TestBed(testbedFile,true);
- }
-
- /**
- * function used for updating Cluster data
- * for Mock
- */
- @Override
- public boolean updateData() {
- cluster.setConnectedFlag(true);
- Random r = new Random(System.currentTimeMillis());
- long totalHeapSize = Math.abs(r.nextInt(3200 - 2048) + 2048);
- cluster.setTotalHeapSize(totalHeapSize);
- long usedHeapSize = Math.abs(r.nextInt(2048));
- cluster.setUsedHeapSize(usedHeapSize);
- double writePerSec = Math.abs(r.nextInt(100));
- cluster.setWritePerSec(writePerSec);
-
- //propfile
- cluster.setSubscriptionCount(testbed.getRootDs().getClients().size());
- cluster.setRegisteredCQCount((long) testbed.getRootDs().getCQs().size());
- cluster.setRunningFunctionCount(testbed.getRootDs().getFunction().size());
-
-
- cluster.setClusterId( Math.abs(r.nextInt(100)));
- cluster.getWritePerSecTrend().add(writePerSec);
- cluster.setDiskWritesRate(writePerSec);
-
- long garbageCollectionCount = Math.abs(r.nextInt(100));
- cluster.setGarbageCollectionCount(garbageCollectionCount);
- cluster.getGarbageCollectionTrend().add(garbageCollectionCount);
-
- long readPerSec = Math.abs(r.nextInt(100));
- cluster.setReadPerSec(readPerSec);
- cluster.getReadPerSecTrend().add(readPerSec);
-
- long diskReadsRate = readPerSec;cluster.setDiskReadsRate(diskReadsRate);
- cluster.setDiskReadsRate(readPerSec);
- long queriesPerSec = Math.abs(r.nextInt(100));
- cluster.setQueriesPerSec(queriesPerSec);
- cluster.getQueriesPerSecTrend().add(queriesPerSec);
-
- long loadPerSec = Math.abs(r.nextInt(100));
- cluster.setLoadPerSec(loadPerSec);
- cluster.setTotalHeapSize(totalHeapSize);
- long totalBytesOnDisk = totalHeapSize;
- cluster.setTotalBytesOnDisk(totalBytesOnDisk);
-
- cluster.getTotalBytesOnDiskTrend().add(totalBytesOnDisk);
-
- cluster.getMemoryUsageTrend().add(usedHeapSize);
- cluster.getThroughoutWritesTrend().add(writePerSec);
-
- cluster.setMemberCount(0);
-
- Map<String,Cluster.Member> membersHMap = cluster.getMembersHMap();
- List<Cluster.Region> regionsList = (List<Cluster.Region>)cluster.getClusterRegions().values();
- Map<String, Boolean> wanInformation = cluster.getWanInformation();
-
- // Create 3 members first time around
- int locatorCount=0;
- if (membersHMap.size() == 0) {
- for(Locator locator : testbed.getRootDs().getLocators()){
- String id = "(Launcher_Locator-1099-13-40-24-5368)-"+locatorCount++;
- String name = locator.getName();
- membersHMap.put(id+name, initializeMember(id,name, true, true, true, false, locator.getHost()));
- }
- cluster.setLocatorCount(testbed.getRootDs().getLocators().size());
-
- int serverCount=0;
- for(Server server : testbed.getRootDs().getServers()){
- String id = "(Launcher_Server-1099-13-40-24-5368)-"+serverCount++;
- String name = server.getName();
- membersHMap.put(id+name, initializeMember(id,name, false, true, false, true, server.getHost()));
- }
- cluster.setServerCount(testbed.getRootDs().getServers().size());
-
- int peerCount=0;
- for(Peer peer : testbed.getRootDs().getPeers()){
- String id = "(Launcher_Peer-1099-13-40-24-5368)-"+peerCount++;
- String name = peer.getName();
- membersHMap.put( id+name, initializeMember(id,name, false, true, false, false, peer.getHost()));
- }
-
- for(Entry<String, Member> memberSet : membersHMap.entrySet())
- {
- HashMap<String,Cluster.Region> memberRegions = new HashMap<String,Cluster.Region>();
- HashMap<String,Cluster.Client> memberClientsHM = new HashMap<String,Cluster.Client>();
-
- Random randomGenerator = new Random();
-
- //Read from property file
- int randomInt = (randomGenerator.nextInt(5)) + 1;
- List<com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Region> thisMemberRegions = testbed.getRootDs().getRegions(memberSet.getValue().getName());
-
- int regionExists = 0;
- int index=0;
- for (com.vmware.gemfire.tools.pulse.testbed.GemFireDistributedSystem.Region thisMemberRegion : thisMemberRegions) {
- Region region = initMemberRegion(index++,thisMemberRegion.getName(),memberSet.getValue().getName(),
- thisMemberRegion.getEntryCount(),thisMemberRegion.getType(), thisMemberRegion.getMembers().size()); //read from property file
- if (regionsList.size() > 0) {
- for (Region clusterRegion : regionsList) {
- if ((region.getName()).equals(clusterRegion.getName())) {
- clusterRegion.getMemberName().add(memberSet.getValue().getName());
- //clusterRegion.memberCount = clusterRegion.memberCount + 1;
- //int mcount = clusterRegion.getMemberCount() + 1;
- //clusterRegion.setMemberCount(mcount);
- regionExists = 1;
- break;
- }
- }
- if (regionExists == 0){
- regionsList.add(region);
- }
- } else{
- regionsList.add(region);
- }
- memberRegions.put(region.getFullPath(),region);
- //totalRegionCount = regionsList.size();
- cluster.setTotalRegionCount(regionsList.size());
- }
- membersHMap.get(memberSet.getKey()).setMemberRegions(memberRegions);
-
- if (memberSet.getValue().isCache()) {
- Client client = initMemberClient(0, memberSet.getValue().getHost()); //read from prop File
- memberClientsHM.put(client.getId(), client);
- randomInt = randomGenerator.nextInt(10);
- for (int y = 1; y < randomInt; y++) {
- Client newClient = initMemberClient(y, memberSet.getValue()
- .getHost());
- memberClientsHM.put(newClient.getId(), newClient);
- }
- membersHMap.get(memberSet.getKey()).updateMemberClientsHMap(memberClientsHM);
- /*clientConnectionCount = clientConnectionCount
- + membersHMap.get(memberSet.getKey()).getMemberClientsHMap().size();*/
- long clientConnectionCount = cluster.getClientConnectionCount() + membersHMap.get(memberSet.getKey()).getMemberClientsHMap().size();
- cluster.setClientConnectionCount(clientConnectionCount);
- }
-
- }
- }
- wanInformation.clear(); //read from property file
- int wanInfoSize = Math.abs(r.nextInt(10));
- wanInfoSize++;
- for (int i = 0; i < wanInfoSize; i++) {
- String name = "Mock Cluster" + i;
- Boolean value = false;
- if (i % 2 == 0){
- value = true;
- }
- wanInformation.put(name, value);
- }
- //memberCount = membersHMap.size();
- cluster.setMemberCount(membersHMap.size());
-
- totalHeapSize = 0;
- for(Entry<String, Member> memberSet : membersHMap.entrySet())
- {
- refresh(membersHMap.get(memberSet.getKey()));
- Member member = membersHMap.get(memberSet.getKey());
- totalHeapSize += member.getCurrentHeapSize();
- }
-
- for (Region region : regionsList) {
- region.setGetsRate((Math.abs(r.nextInt(100))) + 1);
- region.setPutsRate((Math.abs(r.nextInt(100))) +1);
- region.getGetsPerSecTrend().add(region.getGetsRate());
- region.getPutsPerSecTrend().add(region.getPutsRate());
- }
-
- return true;
- }
-
-
- private Region initMemberRegion(int count, String regionName, String memName, int entryCount, String type, int memberCount) {
- Region memberRegion = new Region();
- memberRegion.setName(regionName);
- memberRegion.setFullPath("/"+regionName);
- Random randomGenerator = new Random();
- memberRegion.setSystemRegionEntryCount(entryCount);
- // memberRegion.setEntrySize("N/A");
- memberRegion.setEntrySize(Math.abs(randomGenerator.nextInt(10)));
- memberRegion.setDiskStoreName("ABC");
- memberRegion.setScope("DISTRIBUTED_NO_ACK");
- memberRegion.setDiskSynchronous(true);
- memberRegion.setRegionType(type);
- if(type.contains("PERSISTENT"))
- memberRegion.setPersistentEnabled(true);
- else
- memberRegion.setPersistentEnabled(false);
- if (count % 2 == 0){
- memberRegion.setWanEnabled(true);
- }
- else{
- memberRegion.setWanEnabled(false);
- }
- memberRegion.setWanEnabled(true);
- /*memberRegion.setSystemRegionEntryCount(Long.valueOf(String.valueOf(Math
- .abs(randomGenerator.nextInt(100)))));*/
- memberRegion.getMemberName().add(memName);
- memberRegion.setMemberCount(memberCount);
- return memberRegion;
- }
-
-
- private Client initMemberClient(int count, String host) {
-
- Client memberClient = new Client();
- Random r = new Random(System.currentTimeMillis());
- memberClient.setName("Name_" + count);
- long processCpuTime = (long) (r.nextDouble() * 100);
- memberClient.setProcessCpuTime(processCpuTime);
- memberClient.setCpuUsage(0);
- memberClient.setGets(Math.abs(r.nextInt(100)));
- memberClient.setHost(host);
- memberClient.setId(String.valueOf(1000 + count));
- memberClient.setPuts(Math.abs(r.nextInt(100)));
- memberClient.setCpus(Math.abs(r.nextInt(20)));
- memberClient.setQueueSize(Math.abs(r.nextInt(100)));
- if ((count % 2) == 0){
- memberClient.setStatus("up");
- }
- else{
- memberClient.setStatus("down");
- }
- memberClient.setThreads(Math.abs(r.nextInt(100)));
- memberClient
- .setUptime(Math.abs(System.currentTimeMillis() - r.nextLong()));
-
- return memberClient;
- }
-
- private Member initializeMember(String id, String name, boolean manager,
- boolean isCache, boolean isLocator, boolean isServer, String host) {
- Member m = new Member();
-
- m.setId(id);
- m.setName(name);
-
- //m.setHost(getHostName(System.currentTimeMillis()));
- m.setHost(host);
-
- m.setMaxHeapSize(247);
-
- Random r = new Random(System.currentTimeMillis());
-
- m.setCache(isCache);
- m.setLocator(isLocator);
- m.setServer(isServer);
- m.setManager(manager);
-
- m.setLoadAverage((double) Math.abs(r.nextInt(100)));
- m.setNumThreads(Math.abs(r.nextInt(100)));
- m.setGarbageCollectionCount((long) Math.abs(r.nextInt(100)));
- m.getGarbageCollectionSamples().add(m.getGarbageCollectionCount());
-
- m.setTotalFileDescriptorOpen((long) Math.abs(r.nextInt(100)));
- m.setTotalDiskUsage(Math.abs(r.nextInt(100)));
-
-
- m.setThroughputWrites(Math.abs(r.nextInt(10)));
- m.getThroughputWritesTrend().add(m.getThroughputWrites());
-
- GatewayReceiver gatewayReceiver = m.getGatewayReceiver();
- String port = cluster.getPort();
- if(port==null || "".equals(port))
- port = "1099";
- gatewayReceiver.setListeningPort(Integer.parseInt(port));
- gatewayReceiver.setLinkThroughput(Math.abs(r.nextInt(10)));
- gatewayReceiver.setAvgBatchProcessingTime((long) Math.abs(r.nextInt(10)));
- gatewayReceiver.setId(String.valueOf(Math.abs(r.nextInt(10))));
- gatewayReceiver.setQueueSize(Math.abs(r.nextInt(10)));
- gatewayReceiver.setStatus(true);
- gatewayReceiver.setBatchSize(Math.abs(r.nextInt(10)));
-
- int gatewaySenderCount = Math.abs(r.nextInt(10));
-
- List<GatewaySender> list = m.getGatewaySenderList();
-
- for (int i = 0; i < gatewaySenderCount; i++) {
- list.add(createGatewaySenderCount(r));
- }
-
- Map<String, List<Member>> physicalToMember = cluster.getPhysicalToMember();
-
- List<Cluster.Member> memberArrList = physicalToMember.get(m.getHost());
- if (memberArrList != null){
- memberArrList.add(m);
- }
- else {
- ArrayList<Cluster.Member> memberList = new ArrayList<Cluster.Member>();
- memberList.add(m);
- physicalToMember.put(m.getHost(), memberList);
- }
- int memberCount = cluster.getMemberCount();memberCount++;cluster.setMemberCount(memberCount);
- return m;
- }
-
- private GatewaySender createGatewaySenderCount(Random r) {
-
- GatewaySender gatewaySender = new GatewaySender();
-
- gatewaySender.setBatchSize(Math.abs(r.nextInt(10)));
- gatewaySender.setId(String.valueOf(Math.abs(r.nextInt(10))));
- gatewaySender.setLinkThroughput(Math.abs(r.nextInt(10)));
- gatewaySender.setPersistenceEnabled(true);
- gatewaySender.setPrimary(true);
- gatewaySender.setQueueSize(Math.abs(r.nextInt(10)));
- gatewaySender.setSenderType(false);
- gatewaySender.setStatus(true);
-
- return gatewaySender;
- }
-
- /*
- private String getHostName(long rndSeed) {
- Random rnd = new Random(rndSeed);
- String hName = null;
-
- int index = Math.abs(rnd.nextInt(MAX_HOSTS));
-
- ArrayList<String> hostNames = cluster.getHostNames();
-
- if (hostNames.size() <= index) {
- hName = "host" + hostNames.size();
- hostNames.add(hName);
- } else {
- hName = hostNames.get(index);
- }
-
- Map<String, ArrayList<Member>> physicalToMember = cluster.getPhysicalToMember();
-
- ArrayList<Member> memberArrList = physicalToMember.get(hName);
- if (memberArrList != null) {
- if (memberArrList.size() > 4){
- hName = getHostName(rndSeed + rnd.nextLong());
- }
- }
- return hName;
- }*/
-
- private void refresh(Member m) {
- if(LOGGER.infoEnabled()){
- LOGGER.info(resourceBundle.getString("LOG_MSG_REFRESHING_MEMBER_DATA")+" : " + m.getName());
- }
-
- Random r = new Random(System.currentTimeMillis());
-
- m.setUptime(System.currentTimeMillis());
- m.setQueueBacklog("" + Math.abs(r.nextInt(500)));
- m.setCurrentHeapSize(Math.abs(r.nextInt(Math.abs((int) m.getMaxHeapSize()))));
- m.setTotalDiskUsage(Math.abs(r.nextInt(100)));
-
- double cpuUsage = r.nextDouble() * 100;
- m.getCpuUsageSamples().add(cpuUsage);
- m.setCpuUsage(cpuUsage);
-
- m.getHeapUsageSamples().add(m.getCurrentHeapSize());
- m.setLoadAverage((double) Math.abs(r.nextInt(100)));
- m.setNumThreads(Math.abs(r.nextInt(100)));
- m.setGarbageCollectionCount((long) Math.abs(r.nextInt(100)));
- m.getGarbageCollectionSamples().add(m.getGarbageCollectionCount());
-
- m.setTotalFileDescriptorOpen((long) Math.abs(r.nextInt(100)));
-
- m.setThroughputWrites(Math.abs(r.nextInt(10)));
- m.getThroughputWritesTrend().add(m.getThroughputWrites());
-
- m.setGetsRate(Math.abs(r.nextInt(5000)));
- m.getGetsPerSecond().add(m.getGetsRate());
-
- m.setPutsRate(Math.abs(r.nextInt(5000)));
- m.getPutsPerSecond().add(m.getPutsRate());
-
- Alert[] alerts = cluster.getAlertsList();
- List<Alert> alertsList = Arrays.asList(alerts);
-
- if (r.nextBoolean()) {
- // Generate alerts
- if (r.nextBoolean()) {
- if (r.nextInt(10) > 5) {
- alertsList.add(createAlert(Alert.SEVERE, m.getName(), alertsList.size()));
- if(alertsList.size() > ALERTS_MAX_SIZE){
- alertsList.remove(0);
- }
- }
- }
-
- if (r.nextBoolean()) {
- if (r.nextInt(10) > 5) {
- alertsList.add(createAlert(Alert.ERROR, m.getName(), alertsList.size()));
- if(alertsList.size() > ALERTS_MAX_SIZE){
- alertsList.remove(0);
- }
- }
- }
-
- if (r.nextBoolean()) {
- if (r.nextInt(10) > 5) {
- alertsList.add(createAlert(Alert.WARNING, m.getName(), alertsList.size()));
- if(alertsList.size() > ALERTS_MAX_SIZE){
- alertsList.remove(0);
- }
- }
- }
- }
- }
-
- private Alert createAlert(int sev, String memberName, int index) {
-
- Alert alert = new Alert();
- alert.setSeverity(sev);
- alert.setId(index);
- alert.setMemberName(memberName);
- alert.setTimestamp(new Date());
-
- switch (sev) {
- case Alert.SEVERE:
- alert.setDescription(PulseConstants.ALERT_DESC_SEVERE);
- break;
- case Alert.ERROR:
- alert.setDescription(PulseConstants.ALERT_DESC_ERROR);
- break;
- case Alert.WARNING:
- alert.setDescription(PulseConstants.ALERT_DESC_WARNING);
- break;
- }
- return alert;
- }
-
- @Override
- public ObjectNode executeQuery(String queryText, String members, int limit) {
- // TODO for Sushant/Sachin - Add implementation for MockUpdater for Automation
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/TestBed.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/TestBed.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/TestBed.java
deleted file mode 100644
index db1ebd3..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/testbed/TestBed.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.testbed;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-public class TestBed {
-
- private String fileName=null;
- PropFileHelper propertiesFile =null;
- GemFireDistributedSystem ds = null;
-
- public TestBed(){
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- InputStream inputStream = classLoader.getResourceAsStream("testbed.properties");
- Properties properties = new Properties();
- try {
- properties.load(inputStream);
- } catch (IOException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- propertiesFile = new PropFileHelper(properties);
- ds = new GemFireDistributedSystem("t1", propertiesFile.getProperties());
- }
-
- public TestBed(String fileName) throws FileNotFoundException, IOException{
- this.fileName = fileName;
- propertiesFile = new PropFileHelper(fileName);
- ds = new GemFireDistributedSystem("t1", propertiesFile.getProperties());
- }
-
-
- public TestBed(String fileName,boolean flag) throws FileNotFoundException, IOException{
-// ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-// InputStream inputStream = classLoader.getResourceAsStream("testbed.properties");
-// System.out.println("Inputstream : " + inputStream);
- Properties properties = new Properties();
- try {
- properties.load(new FileInputStream(new File(fileName)));
- } catch (IOException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- this.fileName = fileName;
- propertiesFile = new PropFileHelper(properties);
- ds = new GemFireDistributedSystem("t1", propertiesFile.getProperties());
- }
-
-
- public String getBrowserForDriver(){
- return propertiesFile.readKey("browser");
- }
-
- public String getBrowserVersionForDriver(String browser){
- return propertiesFile.readKey("browserVersion");
- }
-
- public GemFireDistributedSystem getRootDs(){
- return ds;
- }
-
-}
\ No newline at end of file
[20/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/DataBrowser.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/DataBrowser.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/DataBrowser.java
new file mode 100644
index 0000000..668b74c
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/DataBrowser.java
@@ -0,0 +1,248 @@
+/*
+ *
+ * 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.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Iterator;
+import java.util.ResourceBundle;
+import java.util.Scanner;
+
+/**
+ * Class DataBrowser This class contains Data browser functionalities for
+ * managing queries and histories.
+ *
+ * @since GemFire version 7.5.Beta 2013-03-25
+ */
+public class DataBrowser {
+
+ private final PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+ private final ResourceBundle resourceBundle = Repository.get()
+ .getResourceBundle();
+
+ private SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
+ PulseConstants.PULSE_QUERY_HISTORY_DATE_PATTERN);
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ /**
+ * addQueryInHistory method adds user's query into query history file
+ *
+ * @param userId
+ * Logged in User's Id
+ * @param queryText
+ * Query text to execute
+ */
+ public boolean addQueryInHistory(String queryText, String userId) {
+ boolean operationStatus = false;
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(queryText)
+ && StringUtils.isNotNullNotEmptyNotWhiteSpace(userId)) {
+
+ // Fetch all queries from query log file
+ ObjectNode queries = fetchAllQueriesFromFile();
+
+ // Get user's query history list
+ ObjectNode userQueries = (ObjectNode) queries.get(userId);
+ if (userQueries == null) {
+ userQueries = mapper.createObjectNode();
+ }
+
+ // Add query in user's query history list
+ userQueries.put(Long.toString(System.currentTimeMillis()), queryText);
+ queries.put(userId, userQueries);
+
+ // Store queries in file back
+ operationStatus = storeQueriesInFile(queries);
+ }
+
+ return operationStatus;
+ }
+
+ /**
+ * deleteQueryById method deletes query from query history file
+ *
+ * @param userId
+ * Logged in user's Unique Id
+ * @param queryId
+ * Unique Id of Query to be deleted
+ * @return boolean
+ */
+ public boolean deleteQueryById(String userId, String queryId) {
+
+ boolean operationStatus = false;
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(queryId)
+ && StringUtils.isNotNullNotEmptyNotWhiteSpace(userId)) {
+
+ // Fetch all queries from query log file
+ ObjectNode queries = fetchAllQueriesFromFile();
+
+ // Get user's query history list
+ ObjectNode userQueries = (ObjectNode) queries.get(userId);
+
+ if (userQueries != null) {
+ // Remove user's query
+ userQueries.remove(queryId);
+ queries.put(userId, userQueries);
+
+ // Store queries in file back
+ operationStatus = storeQueriesInFile(queries);
+ }
+ }
+
+ return operationStatus;
+ }
+
+ /**
+ * getQueryHistoryByUserId method reads and lists out the queries from history
+ * file
+ *
+ * @param userId
+ * Logged in User's Id
+ */
+ public ArrayNode getQueryHistoryByUserId(String userId) {
+
+ ArrayNode queryList = mapper.createArrayNode();
+
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(userId)) {
+
+ // Fetch all queries from query log file
+ ObjectNode queries = fetchAllQueriesFromFile();
+
+ // Get user's query history list
+ ObjectNode userQueries = (ObjectNode) queries.get(userId);
+
+ if (userQueries != null) {
+ Iterator<String> it = userQueries.fieldNames();
+ while (it.hasNext()) {
+ String key = it.next();
+ ObjectNode queryItem = mapper.createObjectNode();
+ queryItem.put("queryId", key);
+ queryItem.put("queryText", userQueries.get(key).toString());
+ queryItem.put("queryDateTime", simpleDateFormat.format(Long.valueOf(key)));
+ queryList.add(queryItem);
+ }
+ }
+ }
+
+ return queryList;
+ }
+
+ /**
+ * generateQueryKey method fetches queries from query history file
+ *
+ * @return Properties A collection queries in form of key and values
+ */
+ private ObjectNode fetchAllQueriesFromFile() {
+ InputStream inputStream = null;
+ JsonNode queriesJSON = mapper.createObjectNode();
+
+ try {
+ inputStream = new FileInputStream(Repository.get().getPulseConfig().getQueryHistoryFileName());
+ String inputStreamString = new Scanner(inputStream, "UTF-8").useDelimiter("\\A").next();
+ queriesJSON = mapper.readTree(inputStreamString);
+ } catch (FileNotFoundException e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine(resourceBundle
+ .getString("LOG_MSG_DATA_BROWSER_QUERY_HISTORY_FILE_NOT_FOUND")
+ + " : " + e.getMessage());
+ }
+ } catch (Exception e) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(e.getMessage());
+ }
+ } finally {
+ // Close input stream
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(e.getMessage());
+ }
+ }
+ }
+ }
+
+ return (ObjectNode) queriesJSON;
+ }
+
+ /**
+ * generateQueryKey method stores queries in query history file.
+ *
+ * @return Boolean true is operation is successful, false otherwise
+ */
+ private boolean storeQueriesInFile(ObjectNode queries) {
+ boolean operationStatus = false;
+ FileOutputStream fileOut = null;
+
+ File file = new File(Repository.get().getPulseConfig().getQueryHistoryFileName());
+ try {
+ fileOut = new FileOutputStream(file);
+
+ // if file does not exists, then create it
+ if (!file.exists()) {
+ file.createNewFile();
+ }
+
+ // get the content in bytes
+ byte[] contentInBytes = queries.toString().getBytes();
+
+ fileOut.write(contentInBytes);
+ fileOut.flush();
+
+ operationStatus = true;
+ } catch (FileNotFoundException e) {
+
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine(resourceBundle
+ .getString("LOG_MSG_DATA_BROWSER_QUERY_HISTORY_FILE_NOT_FOUND")
+ + " : " + e.getMessage());
+ }
+ } catch (IOException e) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(e.getMessage());
+ }
+ } finally {
+ if (fileOut != null) {
+ try {
+ fileOut.close();
+ } catch (IOException e) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(e.getMessage());
+ }
+ }
+ }
+ }
+ return operationStatus;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/IClusterUpdater.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/IClusterUpdater.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/IClusterUpdater.java
new file mode 100644
index 0000000..106ea63
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/IClusterUpdater.java
@@ -0,0 +1,35 @@
+/*
+ *
+ * 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.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Interface having updateData() function which is getting Override by both
+ * MockDataUpdater and JMXDataUpdater
+ *
+ * @since GemFire version 7.0.Beta 2012-09-23
+ *
+ */
+public interface IClusterUpdater {
+ boolean updateData();
+
+ ObjectNode executeQuery(String queryText, String members, int limit);
+}
[14/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemberService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemberService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemberService.java
new file mode 100644
index 0000000..6a42c0d
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemberService.java
@@ -0,0 +1,132 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.util.TimeUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Class ClusterMemberService
+ *
+ * This class contains implementations of getting Cluster Member's details
+ *
+ * @since GemFire version 7.5
+ */
+@Component
+// @Service("ClusterMember")
+@Service("ClusterMembers")
+@Scope("singleton")
+public class ClusterMemberService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ private final String HEAP_USAGE = "heapUsage";
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ Cluster.Member[] clusterMembersList = cluster.getMembers();
+
+ // create members json
+ ArrayNode memberListJson = mapper.createArrayNode();
+ for (Cluster.Member clusterMember : clusterMembersList) {
+ ObjectNode memberJSON = mapper.createObjectNode();
+ // getting members detail
+ memberJSON.put("gemfireVersion", clusterMember.getGemfireVersion());
+ memberJSON.put("memberId", clusterMember.getId());
+ memberJSON.put("name", clusterMember.getName());
+ memberJSON.put("host", clusterMember.getHost());
+
+ List<String> serverGroups = clusterMember.getServerGroups();
+ if(serverGroups.size() == 0){
+ serverGroups = new ArrayList<>();
+ serverGroups.add(PulseConstants.DEFAULT_SERVER_GROUP);
+ }
+
+ memberJSON.put("serverGroups", mapper.valueToTree(serverGroups));
+
+ List<String> redundancyZones = clusterMember.getRedundancyZones();
+ if(redundancyZones.size() == 0){
+ redundancyZones = new ArrayList<String>();
+ redundancyZones.add(PulseConstants.DEFAULT_REDUNDANCY_ZONE);
+ }
+ memberJSON.put("redundancyZones", mapper.valueToTree(redundancyZones));
+
+ long usedHeapSize = cluster.getUsedHeapSize();
+ long currentHeap = clusterMember.getCurrentHeapSize();
+ if (usedHeapSize > 0) {
+ double heapUsage = ((double) currentHeap / (double) usedHeapSize) * 100;
+ memberJSON.put(this.HEAP_USAGE, truncate(heapUsage, 2));
+ } else {
+ memberJSON.put(this.HEAP_USAGE, 0);
+ }
+ double currentCPUUsage = clusterMember.getCpuUsage();
+ double loadAvg = clusterMember.getLoadAverage();
+
+ memberJSON.put("cpuUsage", truncate(currentCPUUsage, 2));
+ memberJSON.put("currentHeapUsage", clusterMember.getCurrentHeapSize());
+ memberJSON.put("isManager", clusterMember.isManager());
+ memberJSON.put("uptime", TimeUtils.convertTimeSecondsToHMS(clusterMember.getUptime()));
+ memberJSON.put("loadAvg", truncate(loadAvg, 2));
+ memberJSON.put("sockets", clusterMember.getTotalFileDescriptorOpen());
+ memberJSON.put("threads", clusterMember.getNumThreads());
+
+ // Number of member clients
+ if (PulseController.getPulseProductSupport().equalsIgnoreCase(
+ PulseConstants.PRODUCT_NAME_SQLFIRE)){
+ memberJSON.put("clients", clusterMember.getNumSqlfireClients());
+ }else{
+ memberJSON.put("clients", clusterMember.getMemberClientsHMap().size());
+ }
+ memberJSON.put("queues", clusterMember.getQueueBacklog());
+
+ memberListJson.add(memberJSON);
+ }
+ // cluster's Members
+ responseJSON.put("members", memberListJson);
+ // Send json response
+ return responseJSON;
+ }
+
+ private double truncate(double value, int places) {
+ return new BigDecimal(value).setScale(places, RoundingMode.HALF_UP).doubleValue();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMembersRGraphService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMembersRGraphService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMembersRGraphService.java
new file mode 100644
index 0000000..f8617cb
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMembersRGraphService.java
@@ -0,0 +1,359 @@
+/*
+ *
+ * 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.service;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+
+/**
+ * Class ClusterMembersRGraphService
+ *
+ * This class contains implementations of getting List of Cluster members and
+ * their details
+ *
+ * @since GemFire version 7.5
+ */
+@Component
+@Service("ClusterMembersRGraph")
+@Scope("singleton")
+public class ClusterMembersRGraphService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ // String constants used for forming a json response
+ private final String CLUSTER = "clustor";
+ private final String MEMBER_COUNT = "memberCount";
+ private final String ID = "id";
+ private final String NAME = "name";
+ private final String DATA = "data";
+ private final String MEMORY_USAGE = "memoryUsage";
+ private final String CPU_USAGE = "cpuUsage";
+ private final String REGIONS = "regions";
+ private final String HOST = "host";
+ private final String PORT = "port";
+ private final String CLIENTS = "clients";
+ private final String GC_PAUSES = "gcPauses";
+ private final String GATEWAY_SENDER = "gatewaySender";
+ private final String GATEWAY_RECEIVER = "gatewayReceiver";
+ private final String LOAD_AVG = "loadAvg";
+ private final String SOCKETS = "sockets";
+ private final String THREADS = "threads";
+ private final String NUM_THREADS = "numThreads";
+
+ private final String MEMBER_NODE_TYPE_NORMAL = "Normal";
+ private final String MEMBER_NODE_TYPE_WARNING = "Warning";
+ private final String MEMBER_NODE_TYPE_ERROR = "Error";
+ private final String MEMBER_NODE_TYPE_SEVERE = "Severe";
+ private final String CHILDREN = "children";
+
+ // traversing the alert array list and members which have severe, error or
+ // warnings
+ // alerts saving them in three different arraylists
+ private List<String> severeAlertList;
+ private List<String> errorAlertsList;
+ private List<String> warningAlertsList;
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // Reference to repository
+ Repository repository = Repository.get();
+
+ // get cluster object
+ Cluster cluster = repository.getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ // cluster's Members
+ responseJSON.put(this.CLUSTER,
+ getPhysicalServerJson(cluster, repository.getJmxHost(), repository.getJmxPort()));
+ responseJSON.put(this.MEMBER_COUNT, cluster.getMemberCount());
+
+ // Send json response
+ return responseJSON;
+ }
+
+ /**
+ * function used for getting all members details in format of JSON Object
+ * array defined under a cluster. This function create json based on the
+ * relation of physical host and members related to it.
+ *
+ * @param cluster
+ * @param host
+ * @param port
+ * @return Array list of JSON objects for required fields of members in
+ * cluster
+ */
+ private ObjectNode getPhysicalServerJson(Cluster cluster, String host, String port) {
+ Map<String, List<Cluster.Member>> physicalToMember = cluster.getPhysicalToMember();
+
+ ObjectNode clusterTopologyJSON = mapper.createObjectNode();
+
+ clusterTopologyJSON.put(this.ID, cluster.getClusterId());
+ clusterTopologyJSON.put(this.NAME, cluster.getClusterId());
+ ObjectNode data1 = mapper.createObjectNode();
+ clusterTopologyJSON.put(this.DATA, data1);
+ ArrayNode childHostArray = mapper.createArrayNode();
+ DecimalFormat df2 = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN);
+
+ updateAlertLists(cluster);
+
+ for (Map.Entry<String, List<Cluster.Member>> physicalToMem : physicalToMember.entrySet()) {
+ String hostName = physicalToMem.getKey();
+ double hostCpuUsage = 0.0;
+ long hostMemoryUsage = 0;
+ double hostLoadAvg = 0.0;
+ int hostNumThreads = 0;
+ long hostSockets = 0;
+ boolean hostSevere = false;
+ boolean hostError = false;
+ boolean hostWarning = false;
+ String hostStatus;
+ ObjectNode childHostObject = mapper.createObjectNode();
+ childHostObject.put(this.ID, hostName);
+ childHostObject.put(this.NAME, hostName);
+
+ ArrayNode membersArray = mapper.createArrayNode();
+
+ List<Cluster.Member> memberList = physicalToMem.getValue();
+ for (Cluster.Member member : memberList) {
+ ObjectNode memberJSONObj = mapper.createObjectNode();
+
+ memberJSONObj.put(this.ID, member.getId());
+ memberJSONObj.put(this.NAME, member.getName());
+
+ ObjectNode memberData = mapper.createObjectNode();
+
+ memberData.put("gemfireVersion", member.getGemfireVersion());
+
+ Long currentHeap = member.getCurrentHeapSize();
+ Long usedHeapSize = cluster.getUsedHeapSize();
+
+ if (usedHeapSize > 0) {
+ double heapUsage = (currentHeap.doubleValue() / usedHeapSize.doubleValue()) * 100;
+
+ memberData.put(this.MEMORY_USAGE,
+ Double.valueOf(df2.format(heapUsage)));
+ } else
+ memberData.put(this.MEMORY_USAGE, 0);
+
+ double currentCPUUsage = member.getCpuUsage();
+
+ memberData.put(this.CPU_USAGE,
+ Double.valueOf(df2.format(currentCPUUsage)));
+ memberData.put(this.REGIONS, member.getMemberRegions().size());
+ memberData.put(this.HOST, member.getHost());
+ if ((member.getMemberPort() == null)
+ || (member.getMemberPort().equals(""))) {
+ memberData.put(this.PORT, "-");
+ } else {
+ memberData.put(this.PORT, member.getMemberPort());
+ }
+ memberData.put(this.CLIENTS, member.getMemberClientsHMap().size());
+ memberData.put(this.GC_PAUSES, member.getGarbageCollectionCount());
+ memberData.put(this.NUM_THREADS, member.getNumThreads());
+
+ // Host CPU Usage is aggregate of all members cpu usage
+ // hostCpuUsage = hostCpuUsage + currentCPUUsage;
+ hostCpuUsage = member.getHostCpuUsage();
+ hostMemoryUsage = hostMemoryUsage + member.getCurrentHeapSize();
+ hostLoadAvg = member.getLoadAverage();
+ hostNumThreads = member.getNumThreads();
+ hostSockets = member.getTotalFileDescriptorOpen();
+
+ // defining the status of Member Icons for R Graph based on the alerts
+ // created for that member
+ String memberNodeType = "";
+ // for severe alert
+ if (severeAlertList.contains(member.getName())) {
+ memberNodeType = getMemberNodeType(member, this.MEMBER_NODE_TYPE_SEVERE);
+ if (!hostSevere) {
+ hostSevere = true;
+ }
+ } else if (errorAlertsList.contains(member.getName())) {
+ // for error alerts
+ memberNodeType = getMemberNodeType(member,
+ this.MEMBER_NODE_TYPE_ERROR);
+ if (!hostError) {
+ hostError = true;
+ }
+ }
+ // for warning alerts
+ else if (warningAlertsList.contains(member.getName())) {
+ memberNodeType = getMemberNodeType(member, this.MEMBER_NODE_TYPE_WARNING);
+ if (!hostWarning) {
+ hostWarning = true;
+ }
+ } else {
+ memberNodeType = getMemberNodeType(member, this.MEMBER_NODE_TYPE_NORMAL);
+ }
+
+ memberData.put("nodeType", memberNodeType);
+ memberData.put("$type", memberNodeType);
+ memberData.put(this.GATEWAY_SENDER, member.getGatewaySenderList().size());
+ if (member.getGatewayReceiver() != null) {
+ memberData.put(this.GATEWAY_RECEIVER, 1);
+ } else {
+ memberData.put(this.GATEWAY_RECEIVER, 0);
+ }
+ memberJSONObj.put(this.DATA, memberData);
+ memberJSONObj.put(this.CHILDREN, mapper.createArrayNode());
+ membersArray.add(memberJSONObj);
+ }
+ ObjectNode data = mapper.createObjectNode();
+
+ data.put(this.LOAD_AVG, Double.valueOf(df2.format(hostLoadAvg)));
+ data.put(this.SOCKETS, hostSockets);
+ data.put(this.THREADS, hostNumThreads);
+ data.put(this.CPU_USAGE, Double.valueOf(df2.format(hostCpuUsage)));
+ data.put(this.MEMORY_USAGE, hostMemoryUsage);
+
+ String hostNodeType;
+ // setting physical host status
+ if (hostSevere) {
+ hostStatus = this.MEMBER_NODE_TYPE_SEVERE;
+ hostNodeType = "hostSevereNode";
+ } else if (hostError) {
+ hostStatus = this.MEMBER_NODE_TYPE_ERROR;
+ hostNodeType = "hostErrorNode";
+ } else if (hostWarning) {
+ hostStatus = this.MEMBER_NODE_TYPE_WARNING;
+ hostNodeType = "hostWarningNode";
+ } else {
+ hostStatus = this.MEMBER_NODE_TYPE_NORMAL;
+ hostNodeType = "hostNormalNode";
+ }
+ data.put("hostStatus", hostStatus);
+ data.put("$type", hostNodeType);
+
+ childHostObject.put(this.DATA, data);
+
+ childHostObject.put(this.CHILDREN, membersArray);
+ childHostArray.add(childHostObject);
+ }
+ clusterTopologyJSON.put(this.CHILDREN, childHostArray);
+
+ return clusterTopologyJSON;
+ }
+
+ /**
+ * used for getting member node type based on member's current state
+ *
+ * @param member
+ * Member
+ * @param memberState
+ * i.e Severe, Error, Warning or Normal
+ * @return
+ */
+ private String getMemberNodeType(Cluster.Member member, String memberState) {
+ String memberNodeType = "";
+
+ if ((member.isLocator()) && (member.isServer()) && (member.isManager())) {
+ memberNodeType = "memberLocatorManagerServer" + memberState + "Node";
+ } else if ((member.isLocator()) && (member.isServer())
+ && !(member.isManager())) {
+ memberNodeType = "memberLocatorServer" + memberState + "Node";
+ } else if ((member.isLocator()) && !(member.isServer())
+ && (member.isManager())) {
+ memberNodeType = "memberLocatorManager" + memberState + "Node";
+ } else if ((member.isLocator()) && !(member.isServer())
+ && !(member.isManager())) {
+ memberNodeType = "memberLocator" + memberState + "Node";
+ } else if (!(member.isLocator()) && (member.isServer())
+ && (member.isManager())) {
+ memberNodeType = "memberManagerServer" + memberState + "Node";
+ } else if (!(member.isLocator()) && (member.isServer())
+ && !(member.isManager())) {
+ memberNodeType = "memberServer" + memberState + "Node";
+ } else if (!(member.isLocator()) && !(member.isServer())
+ && (member.isManager())) {
+ memberNodeType = "memberManager" + memberState + "Node";
+ } else if (!(member.isLocator()) && !(member.isServer())
+ && !(member.isManager())) {
+ memberNodeType = "member" + memberState + "Node";
+ }
+ return memberNodeType;
+ }
+
+ /**
+ * function used for getting list of all the alerts and save the member names
+ * in respective error, warning and severe alert lists
+ *
+ * @param cluster
+ */
+ private void updateAlertLists(Cluster cluster) {
+
+ severeAlertList = new ArrayList<String>();
+ errorAlertsList = new ArrayList<String>();
+ warningAlertsList = new ArrayList<String>();
+
+ Cluster.Alert[] alertsList = cluster.getAlertsList();
+
+ for (Cluster.Alert alert : alertsList) {
+ // if alert is severe
+ if (alert.getSeverity() == Cluster.Alert.SEVERE) {
+ if (errorAlertsList.contains(alert.getMemberName())) {
+ errorAlertsList.remove(alert.getMemberName());
+ } else if (warningAlertsList.contains(alert.getMemberName())) {
+ warningAlertsList.remove(alert.getMemberName());
+ }
+ if (!severeAlertList.contains(alert.getMemberName())) {
+ severeAlertList.add(alert.getMemberName());
+ }
+ }
+ // if alert is error
+ else if (alert.getSeverity() == Cluster.Alert.ERROR) {
+ if (!severeAlertList.contains(alert.getMemberName())) {
+ if (warningAlertsList.contains(alert.getMemberName())) {
+ warningAlertsList.remove(alert.getMemberName());
+ }
+ if (!errorAlertsList.contains(alert.getMemberName())) {
+ errorAlertsList.add(alert.getMemberName());
+ }
+ }
+ }
+ // if alert is warning
+ else if (alert.getSeverity() == Cluster.Alert.WARNING) {
+ if (!severeAlertList.contains(alert.getMemberName())) {
+ if (!errorAlertsList.contains(alert.getMemberName())) {
+ if (!warningAlertsList.contains(alert.getMemberName())) {
+ warningAlertsList.add(alert.getMemberName());
+ }
+ }
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemoryUsageService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemoryUsageService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemoryUsageService.java
new file mode 100644
index 0000000..519deb1
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemoryUsageService.java
@@ -0,0 +1,65 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Class ClusterMemoryUsageService
+ *
+ * This class contains implementations of getting Cluster's overall current
+ * memory usage details and its trend over the time.
+ *
+ * @since GemFire version 7.5
+ */
+
+@Component
+@Service("ClusterMemoryUsage")
+@Scope("singleton")
+public class ClusterMemoryUsageService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ // cluster's Memory Usage trend added to json response object
+
+ responseJSON.put("currentMemoryUsage", cluster.getUsedHeapSize());
+ responseJSON.put("memoryUsageTrend",
+ mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_MEMORY_USAGE)));
+
+ // Send json response
+ return responseJSON;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionService.java
new file mode 100644
index 0000000..1723a98
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionService.java
@@ -0,0 +1,211 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Class ClusterRegionService
+ *
+ * This class contains implementations of getting Cluster's regions details
+ *
+ * @since GemFire version 7.5
+ */
+
+@Component
+@Service("ClusterRegion")
+@Scope("singleton")
+public class ClusterRegionService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ // String constants used for forming a json response
+ private final String ENTRY_SIZE = "entrySize";
+
+ // Comparator based upon regions entry count
+ private static Comparator<Cluster.Region> regionEntryCountComparator = (r1, r2) -> {
+ long r1Cnt = r1.getSystemRegionEntryCount();
+ long r2Cnt = r2.getSystemRegionEntryCount();
+ if (r1Cnt < r2Cnt) {
+ return -1;
+ } else if (r1Cnt > r2Cnt) {
+ return 1;
+ } else {
+ return 0;
+ }
+ };
+
+ @Override
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ String userName = request.getUserPrincipal().getName();
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ // getting cluster's Regions
+ responseJSON.put("clusterName", cluster.getServerName());
+ responseJSON.put("userName", userName);
+ responseJSON.put("region", getRegionJson(cluster));
+
+ // Send json response
+ return responseJSON;
+ }
+
+ /**
+ * This method is used to get various regions associated with the given
+ * cluster and create json for each region fields and returns Array List for
+ * all the regions associated with given cluster
+ *
+ * @param cluster
+ * @return ArrayNode Array List
+ */
+ private ArrayNode getRegionJson(Cluster cluster) {
+
+ Long totalHeapSize = cluster.getTotalHeapSize();
+ Long totalDiskUsage = cluster.getTotalBytesOnDisk();
+
+ Map<String, Cluster.Region> clusterRegions = cluster.getClusterRegions();
+
+ List<Cluster.Region> clusterRegionsList = new ArrayList<Cluster.Region>();
+ clusterRegionsList.addAll(clusterRegions.values());
+
+ Collections.sort(clusterRegionsList, regionEntryCountComparator);
+
+ ArrayNode regionListJson = mapper.createArrayNode();
+ for (int count = 0; count < clusterRegionsList.size(); count++) {
+ Cluster.Region reg = clusterRegionsList.get(count);
+ ObjectNode regionJSON = mapper.createObjectNode();
+
+ regionJSON.put("name", reg.getName());
+ regionJSON.put("totalMemory", totalHeapSize);
+ regionJSON.put("systemRegionEntryCount", reg.getSystemRegionEntryCount());
+ regionJSON.put("memberCount", reg.getMemberCount());
+
+ final String regionType = reg.getRegionType();
+ regionJSON.put("type", regionType);
+ regionJSON.put("getsRate", reg.getGetsRate());
+ regionJSON.put("putsRate", reg.getPutsRate());
+
+ Cluster.Member[] clusterMembersList = cluster.getMembers();
+
+ ArrayNode memberNameArray = mapper.createArrayNode();
+ for (String memberName : reg.getMemberName()) {
+ for (Cluster.Member member : clusterMembersList) {
+ String name = member.getName();
+ name = name.replace(":", "-");
+ String id = member.getId();
+ id = id.replace(":", "-");
+
+ if ((memberName.equals(id)) || (memberName.equals(name))) {
+ ObjectNode regionMember = mapper.createObjectNode();
+ regionMember.put("id", member.getId());
+ regionMember.put("name", member.getName());
+ memberNameArray.add(regionMember);
+ break;
+ }
+ }
+ }
+
+ regionJSON.put("memberNames", memberNameArray);
+ regionJSON.put("entryCount", reg.getSystemRegionEntryCount());
+
+ Boolean persistent = reg.getPersistentEnabled();
+ if (persistent) {
+ regionJSON.put("persistence", VALUE_ON);
+ } else {
+ regionJSON.put("persistence", VALUE_OFF);
+ }
+
+ Boolean isEnableOffHeapMemory = reg.isEnableOffHeapMemory();
+ if (isEnableOffHeapMemory) {
+ regionJSON.put("isEnableOffHeapMemory", VALUE_ON);
+ } else {
+ regionJSON.put("isEnableOffHeapMemory", VALUE_OFF);
+ }
+
+ String regCompCodec = reg.getCompressionCodec();
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(regCompCodec)) {
+ regionJSON.put("compressionCodec", reg.getCompressionCodec());
+ } else {
+ regionJSON.put("compressionCodec", VALUE_NA);
+ }
+
+ if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController
+ .getPulseProductSupport())) {
+ // Convert region path to dot separated region path
+ regionJSON.put("regionPath",
+ StringUtils.getTableNameFromRegionName(reg.getFullPath()));
+ } else {
+ regionJSON.put("regionPath", reg.getFullPath());
+ }
+
+ regionJSON.put("memoryReadsTrend",
+ mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_GETS_PER_SEC_TREND)));
+ regionJSON.put("memoryWritesTrend",
+ mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_PUTS_PER_SEC_TREND)));
+ regionJSON.put("diskReadsTrend",
+ mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_READS_PER_SEC_TREND)));
+ regionJSON.put("diskWritesTrend",
+ mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_WRITES_PER_SEC_TREND)));
+ regionJSON.put("emptyNodes", reg.getEmptyNode());
+ Long entrySize = reg.getEntrySize();
+ DecimalFormat form = new DecimalFormat(
+ PulseConstants.DECIMAL_FORMAT_PATTERN_2);
+ String entrySizeInMB = form.format(entrySize / (1024f * 1024f));
+
+ if (entrySize < 0) {
+ regionJSON.put(this.ENTRY_SIZE, VALUE_NA);
+ } else {
+ regionJSON.put(this.ENTRY_SIZE, entrySizeInMB);
+ }
+ regionJSON.put("dataUsage", reg.getDiskUsage());
+ regionJSON.put("wanEnabled", reg.getWanEnabled());
+ regionJSON.put("totalDataUsage", totalDiskUsage);
+
+ regionJSON.put("memoryUsage", entrySizeInMB);
+
+ regionListJson.add(regionJSON);
+ }
+
+ return regionListJson;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionsService.java
new file mode 100644
index 0000000..0568451
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionsService.java
@@ -0,0 +1,206 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Class ClusterRegionsService
+ *
+ * This class contains implementations of getting Cluster's regions details
+ *
+ * @since GemFire version 7.5
+ */
+
+@Component
+@Service("ClusterRegions")
+@Scope("singleton")
+public class ClusterRegionsService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ // String constants used for forming a json response
+ private final String ENTRY_SIZE = "entrySize";
+
+ // Comparator based upon regions entry count
+ private static Comparator<Cluster.Region> regionEntryCountComparator = (r1, r2) -> {
+ long r1Cnt = r1.getSystemRegionEntryCount();
+ long r2Cnt = r2.getSystemRegionEntryCount();
+ if (r1Cnt < r2Cnt) {
+ return -1;
+ } else if (r1Cnt > r2Cnt) {
+ return 1;
+ } else {
+ return 0;
+ }
+ };
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ // getting cluster's Regions
+ responseJSON.put("regions", getRegionJson(cluster));
+
+ // Send json response
+ return responseJSON;
+ }
+
+ /**
+ * This method is used to get various regions associated with the given
+ * cluster and create json for each region fields and returns Array List for
+ * all the regions associated with given cluster
+ *
+ * @param cluster
+ * @return JSONObject Array List
+ */
+ private ArrayNode getRegionJson(Cluster cluster) {
+
+ Long totalHeapSize = cluster.getTotalHeapSize();
+ Long totalDiskUsage = cluster.getTotalBytesOnDisk();
+
+ Map<String, Cluster.Region> clusterRegions = cluster.getClusterRegions();
+
+ List<Cluster.Region> clusterRegionsList = new ArrayList<Cluster.Region>();
+ clusterRegionsList.addAll(clusterRegions.values());
+
+ Collections.sort(clusterRegionsList, regionEntryCountComparator);
+
+ ArrayNode regionListJson = mapper.createArrayNode();
+ for (int count = 0; count < clusterRegionsList.size(); count++) {
+ Cluster.Region reg = clusterRegionsList.get(count);
+ ObjectNode regionJSON = mapper.createObjectNode();
+
+ regionJSON.put("name", reg.getName());
+ regionJSON.put("totalMemory", totalHeapSize);
+ regionJSON.put("systemRegionEntryCount", reg.getSystemRegionEntryCount());
+ regionJSON.put("memberCount", reg.getMemberCount());
+
+ final String regionType = reg.getRegionType();
+ regionJSON.put("type", regionType);
+ regionJSON.put("getsRate", reg.getGetsRate());
+ regionJSON.put("putsRate", reg.getPutsRate());
+
+ Cluster.Member[] clusterMembersList = cluster.getMembers();
+
+ ArrayNode memberNameArray = mapper.createArrayNode();
+ for (String memberName : reg.getMemberName()) {
+ for (Cluster.Member member : clusterMembersList) {
+ String name = member.getName();
+ name = name.replace(":", "-");
+ String id = member.getId();
+ id = id.replace(":", "-");
+
+ if ((memberName.equals(id)) || (memberName.equals(name))) {
+ ObjectNode regionMember = mapper.createObjectNode();
+ regionMember.put("id", member.getId());
+ regionMember.put("name", member.getName());
+ memberNameArray.add(regionMember);
+ break;
+ }
+ }
+ }
+
+ regionJSON.put("memberNames", memberNameArray);
+ regionJSON.put("entryCount", reg.getSystemRegionEntryCount());
+
+ Boolean persistent = reg.getPersistentEnabled();
+ if (persistent) {
+ regionJSON.put("persistence", this.VALUE_ON);
+ } else {
+ regionJSON.put("persistence", this.VALUE_OFF);
+ }
+
+ Boolean isEnableOffHeapMemory = reg.isEnableOffHeapMemory();
+ if (isEnableOffHeapMemory) {
+ regionJSON.put("isEnableOffHeapMemory", this.VALUE_ON);
+ } else {
+ regionJSON.put("isEnableOffHeapMemory", this.VALUE_OFF);
+ }
+
+ String regCompCodec = reg.getCompressionCodec();
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(regCompCodec)) {
+ regionJSON.put("compressionCodec", reg.getCompressionCodec());
+ } else {
+ regionJSON.put("compressionCodec", this.VALUE_NA);
+ }
+
+ if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController.getPulseProductSupport())) {
+ // Convert region path to dot separated region path
+ regionJSON.put("regionPath",
+ StringUtils.getTableNameFromRegionName(reg.getFullPath()));
+ regionJSON.put("id",
+ StringUtils.getTableNameFromRegionName(reg.getFullPath()));
+ } else {
+ regionJSON.put("regionPath", reg.getFullPath());
+ regionJSON.put("id", reg.getFullPath());
+ }
+
+ regionJSON.put("memoryReadsTrend",
+ mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_GETS_PER_SEC_TREND)));
+ regionJSON.put("memoryWritesTrend",
+ mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_PUTS_PER_SEC_TREND)));
+ regionJSON.put("diskReadsTrend",
+ mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_READS_PER_SEC_TREND)));
+ regionJSON.put("diskWritesTrend",
+ mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_WRITES_PER_SEC_TREND)));
+ regionJSON.put("emptyNodes", reg.getEmptyNode());
+ Long entrySize = reg.getEntrySize();
+ DecimalFormat form = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN_2);
+ String entrySizeInMB = form.format(entrySize / (1024f * 1024f));
+
+ if (entrySize < 0) {
+ regionJSON.put(this.ENTRY_SIZE, this.VALUE_NA);
+ } else {
+ regionJSON.put(this.ENTRY_SIZE, entrySizeInMB);
+ }
+ regionJSON.put("dataUsage", reg.getDiskUsage());
+ regionJSON.put("wanEnabled", reg.getWanEnabled());
+ regionJSON.put("totalDataUsage", totalDiskUsage);
+
+ regionJSON.put("memoryUsage", entrySizeInMB);
+
+ regionListJson.add(regionJSON);
+ }
+
+ return regionListJson;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java
new file mode 100644
index 0000000..4dfc941
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java
@@ -0,0 +1,237 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import com.vmware.geode.tools.pulse.internal.util.TimeUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Class ClusterSelectedRegionService
+ *
+ * This class contains implementations of getting Cluster's selected region details
+ *
+ * @since GemFire version 7.5 cedar 2014-03-01
+ */
+
+@Component
+@Service("ClusterSelectedRegion")
+@Scope("singleton")
+public class ClusterSelectedRegionService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ // String constants used for forming a json response
+ private final String ENTRY_SIZE = "entrySize";
+
+ // Comparator based upon regions entry count
+ private static Comparator<Cluster.Member> memberCurrentHeapUsageComparator = (m1, m2) -> {
+ long m1HeapUsage = m1.getCurrentHeapSize();
+ long m2HeapUsage = m2.getCurrentHeapSize();
+ if (m1HeapUsage < m2HeapUsage) {
+ return -1;
+ } else if (m1HeapUsage > m2HeapUsage) {
+ return 1;
+ } else {
+ return 0;
+ }
+ };
+
+ @Override
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ String userName = request.getUserPrincipal().getName();
+ String pulseData = request.getParameter("pulseData");
+ JsonNode parameterMap = mapper.readTree(pulseData);
+ String selectedRegionFullPath = parameterMap.get("ClusterSelectedRegion").get("regionFullPath").textValue();
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ // getting cluster's Regions
+ responseJSON.put("clusterName", cluster.getServerName());
+ responseJSON.put("userName", userName);
+ responseJSON.put("selectedRegion", getSelectedRegionJson(cluster, selectedRegionFullPath));
+
+ // Send json response
+ return responseJSON;
+ }
+
+ /**
+ * Create JSON for selected cluster region
+ *
+ * @param cluster
+ * @return ObjectNode Array List
+ */
+ private ObjectNode getSelectedRegionJson(Cluster cluster, String selectedRegionFullPath) {
+ PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+ Long totalHeapSize = cluster.getTotalHeapSize();
+ Long totalDiskUsage = cluster.getTotalBytesOnDisk();
+
+ Cluster.Region reg = cluster.getClusterRegion(selectedRegionFullPath);
+ if (reg != null){
+ ObjectNode regionJSON = mapper.createObjectNode();
+
+ regionJSON.put("name", reg.getName());
+ regionJSON.put("path", reg.getFullPath());
+ regionJSON.put("totalMemory", totalHeapSize);
+ regionJSON.put("systemRegionEntryCount", reg.getSystemRegionEntryCount());
+ regionJSON.put("memberCount", reg.getMemberCount());
+
+ final String regionType = reg.getRegionType();
+ regionJSON.put("type", regionType);
+ regionJSON.put("getsRate", reg.getGetsRate());
+ regionJSON.put("putsRate", reg.getPutsRate());
+ regionJSON.put("lruEvictionRate", reg.getLruEvictionRate());
+
+ DecimalFormat df2 = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN);
+ Cluster.Member[] clusterMembersList = cluster.getMembers();
+
+ // collect members of this region
+ List<Cluster.Member> clusterMembersL = new ArrayList<Cluster.Member>();
+ for (String memberName : reg.getMemberName()) {
+ for (Cluster.Member member : clusterMembersList) {
+ String name = member.getName();
+ name = name.replace(":", "-");
+ String id = member.getId();
+ id = id.replace(":", "-");
+
+ if ((memberName.equals(id)) || (memberName.equals(name))) {
+ clusterMembersL.add(member);
+ }
+ }
+ }
+
+ // sort members of this region
+ Collections.sort(clusterMembersL, memberCurrentHeapUsageComparator);
+
+ // return sorted member list by heap usage
+ ArrayNode memberArray = mapper.createArrayNode();
+ for (Cluster.Member member : clusterMembersL) {
+ ObjectNode regionMember = mapper.createObjectNode();
+ regionMember.put("memberId", member.getId());
+ regionMember.put("name", member.getName());
+ regionMember.put("host", member.getHost());
+
+ long usedHeapSize = cluster.getUsedHeapSize();
+ long currentHeap = member.getCurrentHeapSize();
+ if (usedHeapSize > 0) {
+ double heapUsage = ((double) currentHeap / (double) usedHeapSize) * 100;
+ regionMember.put("heapUsage", Double.valueOf(df2.format(heapUsage)));
+ } else {
+ regionMember.put("heapUsage", 0);
+ }
+ double currentCPUUsage = member.getCpuUsage();
+ double loadAvg = member.getLoadAverage();
+
+ regionMember.put("cpuUsage", Double.valueOf(df2.format(currentCPUUsage)));
+ regionMember.put("currentHeapUsage", member.getCurrentHeapSize());
+ regionMember.put("isManager", member.isManager());
+ regionMember.put("uptime", TimeUtils.convertTimeSecondsToHMS(member.getUptime()));
+
+ regionMember.put("loadAvg", Double.valueOf(df2.format(loadAvg)));
+ regionMember.put("sockets", member.getTotalFileDescriptorOpen());
+ regionMember.put("threads", member.getNumThreads());
+
+ if (PulseController.getPulseProductSupport().equalsIgnoreCase(
+ PulseConstants.PRODUCT_NAME_SQLFIRE)){
+ regionMember.put("clients", member.getNumSqlfireClients());
+ }else{
+ regionMember.put("clients", member.getMemberClientsHMap().size());
+ }
+ regionMember.put("queues", member.getQueueBacklog());
+ memberArray.add(regionMember);
+ }
+
+ regionJSON.put("members", memberArray);
+ regionJSON.put("entryCount", reg.getSystemRegionEntryCount());
+
+ regionJSON.put("persistence", reg.getPersistentEnabled() ? PulseService.VALUE_ON : PulseService.VALUE_OFF);
+
+ regionJSON.put("isEnableOffHeapMemory", reg.isEnableOffHeapMemory() ? PulseService.VALUE_ON : PulseService.VALUE_OFF);
+
+ String regCompCodec = reg.getCompressionCodec();
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(regCompCodec)) {
+ regionJSON.put("compressionCodec", reg.getCompressionCodec());
+ } else {
+ regionJSON.put("compressionCodec", PulseService.VALUE_NA);
+ }
+
+ if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController.getPulseProductSupport())) {
+ // Convert region path to dot separated region path
+ regionJSON.put("regionPath", StringUtils.getTableNameFromRegionName(reg.getFullPath()));
+ } else {
+ regionJSON.put("regionPath", reg.getFullPath());
+ }
+
+ regionJSON.put("memoryReadsTrend",
+ mapper.<JsonNode>valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_GETS_PER_SEC_TREND)));
+ regionJSON.put("memoryWritesTrend",
+ mapper.<JsonNode>valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_PUTS_PER_SEC_TREND)));
+ regionJSON.put("diskReadsTrend",
+ mapper.<JsonNode>valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_READS_PER_SEC_TREND)));
+ regionJSON.put("diskWritesTrend",
+ mapper.<JsonNode>valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_WRITES_PER_SEC_TREND)));
+
+ regionJSON.put("emptyNodes", reg.getEmptyNode());
+ Long entrySize = reg.getEntrySize();
+ DecimalFormat form = new DecimalFormat(
+ PulseConstants.DECIMAL_FORMAT_PATTERN_2);
+ String entrySizeInMB = form.format(entrySize / (1024f * 1024f));
+ if (entrySize < 0) {
+ regionJSON.put(this.ENTRY_SIZE, PulseService.VALUE_NA);
+ } else {
+ regionJSON.put(this.ENTRY_SIZE, entrySizeInMB);
+ }
+ regionJSON.put("dataUsage", reg.getDiskUsage());
+ regionJSON.put("wanEnabled", reg.getWanEnabled());
+ regionJSON.put("totalDataUsage", totalDiskUsage);
+ regionJSON.put("memoryUsage", entrySizeInMB);
+
+ LOGGER.fine("calling getSelectedRegionJson :: regionJSON = " + regionJSON);
+ return regionJSON;
+ } else {
+ ObjectNode responseJSON = mapper.createObjectNode();
+ responseJSON.put("errorOnRegion", "Region [" + selectedRegionFullPath + "] is not available");
+ return responseJSON;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
new file mode 100644
index 0000000..1f3ffd6
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
@@ -0,0 +1,143 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Cluster.RegionOnMember;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Class ClusterSelectedRegionsMemberService
+ *
+ * This class contains implementations of getting Cluster's selected region's member specific details
+ * for all members in that region
+ *
+ * @since GemFire version 7.5 cedar 2014-03-01
+ */
+
+@Component
+@Service("ClusterSelectedRegionsMember")
+@Scope("singleton")
+public class ClusterSelectedRegionsMemberService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ //Comparator based upon regions entry count
+ private static Comparator<Cluster.RegionOnMember> romEntryCountComparator = (m1, m2) -> {
+ long m1EntryCount = m1.getEntryCount();
+ long m2EntryCount = m2.getEntryCount();
+ if (m1EntryCount < m2EntryCount) {
+ return -1;
+ } else if (m1EntryCount > m2EntryCount) {
+ return 1;
+ } else {
+ return 0;
+ }
+ };
+
+ @Override
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+ PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+ String userName = request.getUserPrincipal().getName();
+ String pulseData = request.getParameter("pulseData");
+ JsonNode parameterMap = mapper.readTree(pulseData);
+ String selectedRegionFullPath = parameterMap.get("ClusterSelectedRegionsMember").get("regionFullPath").textValue();
+ LOGGER.finest("ClusterSelectedRegionsMemberService selectedRegionFullPath = " + selectedRegionFullPath);
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ // getting cluster's Regions
+ responseJSON.put("clusterName", cluster.getServerName());
+ responseJSON.put("userName", userName);
+ responseJSON.put("selectedRegionsMembers", getSelectedRegionsMembersJson(cluster, selectedRegionFullPath));
+ // Send json response
+ return responseJSON;
+ }
+
+ /**
+ * Create JSON for selected cluster region's all members
+ */
+ private ObjectNode getSelectedRegionsMembersJson(Cluster cluster, String selectedRegionFullPath) {
+ PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+ Cluster.Region reg = cluster.getClusterRegion(selectedRegionFullPath);
+
+ if (reg != null){
+ ObjectNode regionMemberJSON = mapper.createObjectNode();
+ RegionOnMember[] regionOnMembers = reg.getRegionOnMembers();
+
+ //sort on entry count
+ List<RegionOnMember> romList = Arrays.asList(regionOnMembers);
+ Collections.sort(romList, romEntryCountComparator);
+
+ for(RegionOnMember rom : romList) {
+ ObjectNode memberJSON = mapper.createObjectNode();
+ memberJSON.put("memberName", rom.getMemberName());
+ memberJSON.put("regionFullPath", rom.getRegionFullPath());
+ memberJSON.put("entryCount", rom.getEntryCount());
+ memberJSON.put("entrySize", rom.getEntrySize());
+
+ memberJSON.put("accessor", ((rom.getLocalMaxMemory() == 0) ? "True" : "False"));
+ LOGGER.finest("calling getSelectedRegionsMembersJson :: rom.getLocalMaxMemory() = " + rom.getLocalMaxMemory());
+
+ memberJSON.put("memoryReadsTrend",
+ mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_GETS_PER_SEC_TREND)));
+ LOGGER.finest("memoryReadsTrend = " + rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_GETS_PER_SEC_TREND).length);
+
+ memberJSON.put("memoryWritesTrend",
+ mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_PUTS_PER_SEC_TREND)));
+ LOGGER.finest("memoryWritesTrend = " + rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_PUTS_PER_SEC_TREND).length);
+
+ memberJSON.put("diskReadsTrend",
+ mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_DISK_READS_PER_SEC_TREND)));
+ LOGGER.finest("diskReadsTrend = " + rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_DISK_READS_PER_SEC_TREND).length);
+
+ memberJSON.put("diskWritesTrend",
+ mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_DISK_WRITES_PER_SEC_TREND)));
+ LOGGER.finest("diskWritesTrend = " + rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_DISK_WRITES_PER_SEC_TREND).length);
+
+ regionMemberJSON.put(rom.getMemberName(), memberJSON);
+ }
+
+ LOGGER.fine("calling getSelectedRegionsMembersJson :: regionJSON = " + regionMemberJSON);
+ return regionMemberJSON;
+ } else {
+ ObjectNode responseJSON = mapper.createObjectNode();
+ responseJSON.put("errorOnRegion", "Region [" + selectedRegionFullPath + "] is not available");
+ return responseJSON;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterWANInfoService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterWANInfoService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterWANInfoService.java
new file mode 100644
index 0000000..7e26724
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterWANInfoService.java
@@ -0,0 +1,75 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+/**
+ * Class ClusterWANInfoService
+ *
+ * This class contains implementations of getting Cluster's WAN Informations
+ * (connected clusters)
+ *
+ * @since GemFire version 7.5
+ */
+@Component
+@Service("ClusterWANInfo")
+@Scope("singleton")
+public class ClusterWANInfoService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ // members list
+ ArrayNode connectedClusterListJson = mapper.createArrayNode();
+
+ for (Map.Entry<String, Boolean> entry : cluster.getWanInformation()
+ .entrySet()) {
+ ObjectNode clusterJSON = mapper.createObjectNode();
+ clusterJSON.put("clusterId", entry.getKey());
+ clusterJSON.put("name", entry.getKey());
+ clusterJSON.put("status", entry.getValue());
+
+ connectedClusterListJson.add(clusterJSON);
+ }
+ // Response JSON
+ responseJSON.put("connectedClusters", connectedClusterListJson);
+ // Send json response
+ return responseJSON;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberAsynchEventQueuesService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberAsynchEventQueuesService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberAsynchEventQueuesService.java
new file mode 100644
index 0000000..5fe6785
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberAsynchEventQueuesService.java
@@ -0,0 +1,99 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Class MemberAsynchEventQueuesService
+ *
+ * This class contains implementations of getting Asynchronous Event Queues
+ * details of Cluster Member.
+ *
+ * @since GemFire version 7.5
+ */
+@Component
+@Service("MemberAsynchEventQueues")
+@Scope("singleton")
+public class MemberAsynchEventQueuesService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
+ String memberName = requestDataJSON.get("MemberAsynchEventQueues").get("memberName").textValue();
+
+ Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
+
+ if (clusterMember != null) {
+ // response
+ Cluster.AsyncEventQueue[] asyncEventQueues = clusterMember
+ .getMemberAsyncEventQueueList();
+ ArrayNode asyncEventQueueJsonList = mapper.createArrayNode();
+
+ if (asyncEventQueues != null && asyncEventQueues.length > 0) {
+ responseJSON.put("isAsyncEventQueuesPresent", true);
+
+ for (Cluster.AsyncEventQueue asyncEventQueue : asyncEventQueues) {
+ ObjectNode asyncEventQueueJSON = mapper.createObjectNode();
+ asyncEventQueueJSON.put("id", asyncEventQueue.getId());
+ asyncEventQueueJSON.put("primary", asyncEventQueue.getPrimary());
+ asyncEventQueueJSON.put("senderType", asyncEventQueue.isParallel());
+ asyncEventQueueJSON
+ .put("batchSize", asyncEventQueue.getBatchSize());
+ asyncEventQueueJSON.put("batchTimeInterval",
+ asyncEventQueue.getBatchTimeInterval());
+ asyncEventQueueJSON.put("batchConflationEnabled",
+ asyncEventQueue.isBatchConflationEnabled());
+ asyncEventQueueJSON.put("asyncEventListener",
+ asyncEventQueue.getAsyncEventListener());
+ asyncEventQueueJSON.put("queueSize",
+ asyncEventQueue.getEventQueueSize());
+
+ asyncEventQueueJsonList.add(asyncEventQueueJSON);
+ }
+ responseJSON.put("asyncEventQueues", asyncEventQueueJsonList);
+ } else {
+ responseJSON.put("isAsyncEventQueuesPresent", false);
+ }
+
+ }
+ // Send json response
+ return responseJSON;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberClientsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberClientsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberClientsService.java
new file mode 100644
index 0000000..41f3684
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberClientsService.java
@@ -0,0 +1,101 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import com.vmware.geode.tools.pulse.internal.util.TimeUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Class MemberClientsService
+ *
+ * This class contains implementations of getting Memeber's Clients.
+ *
+ * @since GemFire version 7.5
+ */
+@Component
+@Service("MemberClients")
+@Scope("singleton")
+public class MemberClientsService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ // String constants used for forming a json response
+ private final String NAME = "name";
+ private final String HOST = "host";
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
+ String memberName = requestDataJSON.get("MemberClients").get("memberName").textValue();
+
+ ArrayNode clientListJson = mapper.createArrayNode();
+
+ Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
+ if (clusterMember != null) {
+ responseJSON.put("memberId", clusterMember.getId());
+ responseJSON.put(this.NAME, clusterMember.getName());
+ responseJSON.put(this.HOST, clusterMember.getHost());
+
+ // member's clients
+
+ Cluster.Client[] memberClients = clusterMember.getMemberClients();
+ for (Cluster.Client memberClient : memberClients) {
+ ObjectNode regionJSON = mapper.createObjectNode();
+ regionJSON.put("clientId", memberClient.getId());
+ regionJSON.put(this.NAME, memberClient.getName());
+ regionJSON.put(this.HOST, memberClient.getHost());
+ regionJSON.put("queueSize", memberClient.getQueueSize());
+ regionJSON.put("clientCQCount", memberClient.getClientCQCount());
+ regionJSON.put("isConnected", memberClient.isConnected() ? "Yes" : "No");
+ regionJSON.put("isSubscriptionEnabled", memberClient.isSubscriptionEnabled() ? "Yes" : "No");
+ regionJSON.put("uptime", TimeUtils.convertTimeSecondsToHMS(memberClient.getUptime()));
+
+ regionJSON.put("cpuUsage", String.format("%.4f", memberClient.getCpuUsage()).toString());
+ // regionJSON.put("cpuUsage", memberClient.getCpuUsage());
+ regionJSON.put("threads", memberClient.getThreads());
+ regionJSON.put("gets", memberClient.getGets());
+ regionJSON.put("puts", memberClient.getPuts());
+
+ clientListJson.add(regionJSON);
+ }
+ responseJSON.put("memberClients", clientListJson);
+ }
+ // Send json response
+ return responseJSON;
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDetailsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDetailsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDetailsService.java
new file mode 100644
index 0000000..c4f2ff7
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDetailsService.java
@@ -0,0 +1,122 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.DecimalFormat;
+
+/**
+ * Class MemberDetailsService
+ *
+ * This class contains implementations of getting Memeber's Statistics.
+ *
+ * @since GemFire version 7.5
+ */
+@Component
+@Service("MemberDetails")
+@Scope("singleton")
+public class MemberDetailsService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ String userName = request.getUserPrincipal().getName();
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
+ String memberName = requestDataJSON.get("MemberDetails").get("memberName").textValue();
+ DecimalFormat df2 = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN);
+
+ Cluster.Member clusterMember = cluster.getMember(StringUtils
+ .makeCompliantName(memberName));
+ if (clusterMember != null) {
+ responseJSON.put("memberId", clusterMember.getId());
+ responseJSON.put("name", clusterMember.getName());
+ responseJSON.put("host", clusterMember.getHost());
+ responseJSON.put("clusterId", cluster.getId());
+ responseJSON.put("clusterName", cluster.getServerName());
+ responseJSON.put("userName", userName);
+ double loadAvg = clusterMember.getLoadAverage();
+ responseJSON.put("loadAverage", Double.valueOf(df2.format(loadAvg)));
+ responseJSON.put("sockets", clusterMember.getTotalFileDescriptorOpen());
+ responseJSON.put("threads", clusterMember.getNumThreads());
+ responseJSON.put("offHeapFreeSize", clusterMember.getOffHeapFreeSize());
+ responseJSON.put("offHeapUsedSize", clusterMember.getOffHeapUsedSize());
+ responseJSON.put("regionsCount", clusterMember.getMemberRegionsList().length);
+
+ // Number of member clients
+ if (PulseController.getPulseProductSupport().equalsIgnoreCase(
+ PulseConstants.PRODUCT_NAME_SQLFIRE)){
+ responseJSON.put("numClients", clusterMember.getNumSqlfireClients());
+ } else {
+ responseJSON.put("numClients", clusterMember.getMemberClientsHMap().size());
+ }
+
+ Long diskUsageVal = clusterMember.getTotalDiskUsage();
+ Double diskUsage = diskUsageVal.doubleValue() / 1024;
+
+ responseJSON.put("diskStorageUsed", Double.valueOf(df2.format(diskUsage)));
+
+ Cluster.Alert[] alertsList = cluster.getAlertsList();
+
+ String status = "Normal";
+
+ for (Cluster.Alert alert : alertsList) {
+ if (clusterMember.getName().equals(alert.getMemberName())) {
+ if (alert.getSeverity() == Cluster.Alert.SEVERE) {
+ status = "Severe";
+ break;
+ } else if (alert.getSeverity() == Cluster.Alert.ERROR) {
+ status = "Error";
+ } else if (alert.getSeverity() == Cluster.Alert.WARNING) {
+ status = "Warning";
+ }
+ }
+ }
+
+ responseJSON.put("status", status);
+
+ } else {
+ responseJSON.put("errorOnMember", "Member [" + memberName
+ + "] is not available");
+ }
+
+ // Send json response
+ return responseJSON;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDiskThroughputService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDiskThroughputService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDiskThroughputService.java
new file mode 100644
index 0000000..2dd8b55
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDiskThroughputService.java
@@ -0,0 +1,76 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Class MemberDiskThroughputService
+ *
+ * This class contains implementations for getting Memeber's current Disk
+ * Throughput trends over the time.
+ *
+ * @since GemFire version 7.5
+ */
+@Component
+@Service("MemberDiskThroughput")
+@Scope("singleton")
+public class MemberDiskThroughputService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ // members list
+ JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
+ String memberName = requestDataJSON.get("MemberDiskThroughput").get("memberName").textValue();
+
+ Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
+
+ if (clusterMember != null) {
+ // response
+ responseJSON.put("throughputWrites", clusterMember.getThroughputWrites());
+ responseJSON.put("throughputWritesTrend",
+ mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_THROUGHPUT_WRITES)));
+ responseJSON.put("throughputReads", clusterMember.getThroughputWrites());
+ responseJSON.put("throughputReadsTrend",
+ mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_THROUGHPUT_READS)));
+ }
+
+ // Send json response
+ return responseJSON;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGCPausesService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGCPausesService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGCPausesService.java
new file mode 100644
index 0000000..5b34c73
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGCPausesService.java
@@ -0,0 +1,73 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Class MemberGCPausesService
+ *
+ * This class contains implementations of getting Memeber's GC Pauses (JVM
+ * Pauses) details and its trend over the time.
+ *
+ * @since GemFire version 7.5
+ */
+
+@Component
+@Service("MemberGCPauses")
+@Scope("singleton")
+public class MemberGCPausesService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ // members list
+ JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
+ String memberName = requestDataJSON.get("MemberGCPauses").get("memberName").textValue();
+ Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
+
+ if (clusterMember != null) {
+ // response
+ responseJSON.put("gcPausesTrend",
+ mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_GARBAGE_COLLECTION)));
+ responseJSON.put("gcPausesCount", clusterMember.getGarbageCollectionCount());
+ }
+
+ // Send json response
+ return responseJSON;
+ }
+}
[35/35] incubator-geode git commit: GEODE-37 changed sequence.gemfire
to org.apache.geode
Posted by hi...@apache.org.
GEODE-37 changed sequence.gemfire to org.apache.geode
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/5ba853da
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/5ba853da
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/5ba853da
Branch: refs/heads/develop
Commit: 5ba853daac384a5d8a0b6490cedbd556682e7034
Parents: 06436db
Author: Hitesh Khamesra <hk...@pivotal.io>
Authored: Mon Sep 19 13:45:10 2016 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Tue Sep 20 14:29:51 2016 -0700
----------------------------------------------------------------------
.../java/org/apache/geode/sequence/Arrow.java | 124 +++++++
.../geode/sequence/DefaultLineMapper.java | 41 +++
.../geode/sequence/GemfireSequenceDisplay.java | 335 +++++++++++++++++++
.../apache/geode/sequence/HydraLineMapper.java | 134 ++++++++
.../org/apache/geode/sequence/Lifeline.java | 98 ++++++
.../apache/geode/sequence/LifelineState.java | 114 +++++++
.../org/apache/geode/sequence/LineMapper.java | 35 ++
.../geode/sequence/SelectGraphDialog.java | 155 +++++++++
.../apache/geode/sequence/SequenceDiagram.java | 315 +++++++++++++++++
.../apache/geode/sequence/SequencePanel.java | 83 +++++
.../apache/geode/sequence/StateColorMap.java | 66 ++++
.../org/apache/geode/sequence/TimeAxis.java | 122 +++++++
.../org/apache/geode/sequence/ZoomingPanel.java | 188 +++++++++++
.../test/java/org/apache/sequence/Arrow.java | 124 -------
.../test/java/org/apache/sequence/Lifeline.java | 98 ------
.../java/org/apache/sequence/LifelineState.java | 114 -------
.../java/org/apache/sequence/LineMapper.java | 35 --
.../org/apache/sequence/SequenceDiagram.java | 315 -----------------
.../java/org/apache/sequence/SequencePanel.java | 83 -----
.../java/org/apache/sequence/StateColorMap.java | 66 ----
.../test/java/org/apache/sequence/TimeAxis.java | 122 -------
.../java/org/apache/sequence/ZoomingPanel.java | 188 -----------
.../sequence/gemfire/DefaultLineMapper.java | 41 ---
.../gemfire/GemfireSequenceDisplay.java | 335 -------------------
.../sequence/gemfire/HydraLineMapper.java | 134 --------
.../sequence/gemfire/SelectGraphDialog.java | 155 ---------
26 files changed, 1810 insertions(+), 1810 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/geode/sequence/Arrow.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/sequence/Arrow.java b/geode-core/src/test/java/org/apache/geode/sequence/Arrow.java
new file mode 100644
index 0000000..060af88
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/sequence/Arrow.java
@@ -0,0 +1,124 @@
+/*
+ * 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 org.apache.geode.sequence;
+
+import java.awt.*;
+import java.awt.geom.GeneralPath;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dsmith
+ * Date: Nov 12, 2010
+ * Time: 12:02:20 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class Arrow {
+ private static int ARROW_WIDTH=10;
+ private static int CIRCLE_WIDTH=6;
+ private static int LABEL_OFFSET=10;
+
+ private final String label;
+ private final LifelineState startingState;
+ private final LifelineState endingState;
+
+ public Arrow(String label, LifelineState startingState, LifelineState endingState) {
+ this.label = label;
+ this.startingState = startingState;
+ this.endingState = endingState;
+ }
+
+
+ public void paint(Graphics2D g) {
+ Rectangle boundary = g.getClipBounds();
+ int y = endingState.getStartY();
+
+ //don't paint if we're not in the clip area
+ if(y + ARROW_WIDTH < boundary.getMinY() || y - ARROW_WIDTH > boundary.getMaxY()) {
+ return;
+ }
+
+ //TODO - we need to clip by X coordinate as well.
+
+ boolean isReflexsive = getStartingLine() == getEndingLine();
+ if(isReflexsive) {
+ paintReflexive(g);
+ } else {
+ paintNormal(g);
+ }
+ }
+
+ private Lifeline getStartingLine() {
+ return startingState.getLine();
+ }
+
+ private Lifeline getEndingLine() {
+ return endingState.getLine();
+ }
+
+ private void paintReflexive(Graphics2D g) {
+ Lifeline startingLine = getStartingLine();
+ int x = startingLine.getX();
+ int y = endingState.getStartY();
+
+ g.drawArc(x + startingLine.getWidth() - ARROW_WIDTH / 2, y - ARROW_WIDTH, ARROW_WIDTH, ARROW_WIDTH, 90, -180);
+ g.drawString(label, x + startingLine.getWidth() + LABEL_OFFSET, y);
+// GeneralPath path = new GeneralPath();
+// path.moveTo(x, y - ARROW_WIDTH);
+// path.quadTo(x, y - ARROW_WIDTH);
+ }
+
+ private void paintNormal(Graphics2D g) {
+ Lifeline startingLine = getStartingLine();
+ Lifeline endingLine = getEndingLine();
+ int x1 = startingLine.getX();
+ int x2 = endingLine.getX();
+ int y = endingState.getStartY();
+
+ if(x2 > x1) {
+ int startX = x1 + startingLine.getWidth();
+ int endX = x2;
+
+ GeneralPath path = new GeneralPath();
+ path.moveTo(startX, y);
+ path.lineTo(endX, y);
+ path.lineTo(endX - ARROW_WIDTH, y - ARROW_WIDTH);
+ path.moveTo(endX, y);
+ path.lineTo(endX - ARROW_WIDTH, y + ARROW_WIDTH);
+ g.draw(path);
+ g.fillArc(startX, y - CIRCLE_WIDTH/2, CIRCLE_WIDTH, CIRCLE_WIDTH, 0, 360);
+ g.drawString(label, startX + LABEL_OFFSET, y - LABEL_OFFSET);
+ } else {
+ int startX = x1;
+ int endX = x2 + endingLine.getWidth();
+
+ GeneralPath path = new GeneralPath();
+ path.moveTo(startX, y);
+ path.lineTo(endX, y);
+ path.lineTo(endX + ARROW_WIDTH, y - ARROW_WIDTH);
+ path.moveTo(endX, y);
+ path.lineTo(endX + ARROW_WIDTH, y + ARROW_WIDTH);
+ g.draw(path);
+ int labelWidth = g.getFontMetrics().stringWidth(label);
+ g.fillArc(startX - CIRCLE_WIDTH/2, y - CIRCLE_WIDTH/2, CIRCLE_WIDTH, CIRCLE_WIDTH, 0, 360);
+ g.drawString(label, startX - LABEL_OFFSET - labelWidth, y - LABEL_OFFSET);
+ }
+ }
+
+ public LifelineState getStartingState() {
+ return startingState;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/geode/sequence/DefaultLineMapper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/sequence/DefaultLineMapper.java b/geode-core/src/test/java/org/apache/geode/sequence/DefaultLineMapper.java
new file mode 100644
index 0000000..fcec33c
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/sequence/DefaultLineMapper.java
@@ -0,0 +1,41 @@
+/*
+ * 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 org.apache.geode.sequence;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.geode.sequence.LineMapper;
+
+/**
+ * A lifeline mapper that just returns a shortened version of
+ * a member id.
+ *
+ */
+public class DefaultLineMapper implements LineMapper {
+ private static Pattern MEMBER_ID_RE = Pattern.compile(".*\\((\\d+)(:admin)?(:loner)?\\).*:\\d+(/\\d+|.*:.*)");
+
+ public String getShortNameForLine(String name) {
+ Matcher matcher = MEMBER_ID_RE.matcher(name);
+ if(matcher.matches()) {
+ return matcher.group(1);
+ } else {
+ return name;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/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
new file mode 100644
index 0000000..7fb06b9
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/sequence/GemfireSequenceDisplay.java
@@ -0,0 +1,335 @@
+/*
+ * 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 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.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.*;
+import java.util.regex.Pattern;
+
+/**
+ */
+public class GemfireSequenceDisplay {
+
+ private JLabel selectedGraphsLabel;
+ private SelectGraphDialog selectGraphDialog;
+
+ private Map<GraphID, Map<String, Lifeline>> lineMap = new HashMap();
+ private Map<GraphID, List<Arrow>> arrowMap = new HashMap();
+ private SequenceDiagram sequenceDiagram;
+ private JFrame frame;
+ private SequencePanel sequencePanel;
+
+ /**
+ * Create the GUI and show it. For thread safety,
+ * this method should be invoked from the
+ * event-dispatching thread.
+ *
+ * @param graphs
+ * @param lineMapper
+ */
+ private void createAndShowGUI(final GraphSet graphs, LineMapper lineMapper) {
+ //Create and set up the window.
+
+ frame = new JFrame("SequenceDiagram");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+ createMenu();
+ createSequenceDiagram(graphs, lineMapper);
+ createSequenceMaps(graphs);
+
+ createSelectGraphDialog(graphs);
+
+ // for (GraphID id : graphs.getMap().keySet()) {
+ // showSubDiagram(id);
+ //
+ // }
+
+ sequencePanel = new SequencePanel(sequenceDiagram);
+ frame.getContentPane().add(sequencePanel);
+ //Display the window.
+ frame.pack();
+ frame.setVisible(true);
+ showGraphSelector();
+ }
+
+ private void createMenu() {
+ JMenuBar menuBar = new JMenuBar();
+
+ JMenu sequenceMenu = new JMenu("Sequence");
+ sequenceMenu.setMnemonic(KeyEvent.VK_S);
+ sequenceMenu.getAccessibleContext().setAccessibleDescription(
+ "The only menu in this program that has menu items");
+ menuBar.add(sequenceMenu);
+ JMenuItem selectGraphs = new JMenuItem("Choose Graphs",
+ KeyEvent.VK_G);
+ selectGraphs.setAccelerator(KeyStroke.getKeyStroke(
+ KeyEvent.VK_G, ActionEvent.ALT_MASK));
+ selectGraphs.getAccessibleContext().setAccessibleDescription(
+ "Select what graphs to display");
+ selectGraphs.setActionCommand("selectgraphs");
+ selectGraphs.addActionListener(new ActionListener() {
+
+ public void actionPerformed(ActionEvent e) {
+ showGraphSelector();
+ }
+ });
+
+ sequenceMenu.add(selectGraphs);
+ frame.setJMenuBar(menuBar);
+ }
+
+ private void createSelectGraphDialog(final GraphSet graphs) {
+ selectGraphDialog = new SelectGraphDialog(graphs);
+ selectGraphDialog.addSelectionListener(new SelectGraphDialog.SelectionListener() {
+
+ public void selectionChanged(List<GraphID> selectedIds) {
+ updateGraphs(selectedIds);
+ }
+ });
+ selectGraphDialog.pack();
+ }
+
+ private void updateGraphs(List<GraphID> selectedIds) {
+ List<GraphID> existingDiagrams =(List) sequenceDiagram.getSubDiagramsNames();
+ for(GraphID id : selectedIds) {
+ showSubDiagram(id);
+ existingDiagrams.remove(id);
+ }
+ for(GraphID id : existingDiagrams) {
+ hideSubDiagram(id);
+ }
+
+ sequenceDiagram.resizeMe(sequenceDiagram.getWidth(), sequenceDiagram.getHeight());
+ sequencePanel.revalidate();
+ sequencePanel.repaint();
+ // sequenceDiagram.revalidate();
+ // sequenceDiagram.repaint();
+ }
+
+ private void showGraphSelector() {
+ selectGraphDialog.setVisible(true);
+ }
+
+ private void hideGraphSelector() {
+ selectGraphDialog.setVisible(false);
+ }
+
+ // private static SequenceDiagram createSequenceDiagram() {
+ // long startTime = System.currentTimeMillis();
+ // List<Lifeline> lines = new ArrayList<Lifeline>();
+ // List<Arrow> arrows = new ArrayList<Arrow>();
+ // for(int i =0 ; i < 10; i++) {
+ // List<LifelineState> states = new ArrayList<LifelineState>();
+ // for(int j =0; j < 5; j++) {
+ // LifelineState state = new LifelineState(startTime + 20* j, startTime + 20 * j + 20);
+ // states.add(state);
+ // }
+ // Lifeline line = new Lifeline(i, states);
+ // lines.add(line);
+ //
+ // if(i > 0) {
+ // Arrow arrow = new Arrow("arrow" + i, line, lines.get(i - 1), line.getStates().get(2));
+ // arrows.add(arrow);
+ // }
+ // }
+ //
+ // SequenceDiagram diag = new SequenceDiagram(startTime, startTime + 20 * 5, lines, arrows);
+ // return diag;
+ // }
+
+ private void createSequenceMaps(GraphSet graphs) {
+
+ Map<GraphID, Graph> map = graphs.getMap();
+ for (Map.Entry<GraphID, Graph> entry : map.entrySet()) {
+ GraphID graphId = entry.getKey();
+ Graph graph = entry.getValue();
+ Map<String, Lifeline> lines = new LinkedHashMap<String, Lifeline>(graphs.getLocations().size());
+ List<Arrow> arrows = new ArrayList<Arrow>();
+ Map<Vertex, LifelineState> states = new HashMap<Vertex, LifelineState>();
+ for (String location : graphs.getLocations()) {
+ lines.put(location, new Lifeline(graphId, location));
+ }
+
+ Collection<Edge> edges = graph.getEdges();
+ for (Edge edge : edges) {
+ Vertex dest = edge.getDest();
+ Vertex source = edge.getSource();
+ if (dest == null) {
+ dest = source;
+ }
+ if (source == null) {
+ source = dest;
+ }
+ LifelineState destState = states.get(dest);
+ if (destState == null) {
+ final Lifeline lifeline = lines.get(dest.getName());
+ destState = createState(lifeline, graphs, dest);
+ lifeline.addState(destState);
+ states.put(dest, destState);
+ }
+ LifelineState sourceState = states.get(source);
+ if (sourceState == null) {
+ final Lifeline lifeline = lines.get(source.getName());
+ sourceState = createState(lifeline, graphs, source);
+ lifeline.addState(sourceState);
+ states.put(source, sourceState);
+ }
+ Arrow arrow = new Arrow(edge.getName(), sourceState, destState);
+ arrows.add(arrow);
+ destState.addInboundArrow(arrow);
+ }
+
+
+ lineMap.put(graphId, lines);
+ arrowMap.put(graphId, arrows);
+ }
+ }
+
+ public void showSubDiagram(GraphID id) {
+ sequenceDiagram.addSubDiagram(id, lineMap.get(id), arrowMap.get(id));
+ }
+
+ public void hideSubDiagram(GraphID id) {
+ sequenceDiagram.removeSubDiagram(id);
+ }
+
+ private SequenceDiagram createSequenceDiagram(GraphSet graphs, LineMapper lineMapper) {
+
+ sequenceDiagram = new SequenceDiagram(graphs.getMinTime(), graphs.getMaxTime(), graphs.getLocations(), lineMapper);
+ return sequenceDiagram;
+ }
+
+ private static LifelineState createState(Lifeline lifeline, GraphSet graphs, Vertex dest) {
+ long start = dest.getTimestamp();
+ long end = dest.getNextVertexOnDest() == null ? graphs.getMaxTime() : dest.getNextVertexOnDest().getTimestamp();
+ return new LifelineState(lifeline, dest.getState(), start, end);
+ }
+
+ public static void main(String[] args) throws IOException {
+ File[] files;
+ Set<String> keyFilters = new HashSet<String>();
+ boolean areGemfireLogs = false;
+ if (args.length > 0) {
+ ArrayList<File> fileList = new ArrayList<File>();
+ for (int i =0; i < args.length; i++) {
+ String arg = args[i];
+ if(arg.equals("-filterkey")) {
+ keyFilters.add(args[i+1]);
+ i++;
+ } else if(arg.equals("-logs")) {
+ areGemfireLogs = true;
+ }
+ else {
+ fileList.add(new File(args[i]));
+ }
+
+ }
+ files = fileList.toArray(new File[0]);
+ } else {
+ System.err.println("Usage: java -jar sequence.jar (-logs) (-filterkey key)* <file>+\n\n" +
+ "\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);
+ return;
+ }
+
+ final GraphSet graphs;
+
+ graphs = getGraphs(areGemfireLogs, keyFilters, files);
+
+ final LineMapper lineMapper = getLineMapper(files);
+ final GemfireSequenceDisplay display = new GemfireSequenceDisplay();
+ //Schedule a job for the event-dispatching thread:
+ //creating and showing this application's GUI.
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ display.createAndShowGUI(graphs, lineMapper);
+ }
+ });
+ }
+
+ private static GraphSet getGraphs(boolean useLogFiles, Set<String> keyFilters, File[] files)
+ throws IOException {
+ Filter graphFilter = new KeyFilter(keyFilters);
+
+
+ GraphReader reader = new GraphReader(files);
+ final GraphSet graphs;
+ if(keyFilters.isEmpty()) {
+ graphs = reader.readGraphs(useLogFiles);
+ } else {
+ graphs = reader.readGraphs(graphFilter, useLogFiles);
+ }
+ return graphs;
+ }
+
+ /**
+ * @param files
+ * @return
+ */
+ private static LineMapper getLineMapper(File[] files) {
+ if(HydraLineMapper.isInHydraRun(files)) {
+ return new HydraLineMapper(files);
+ } else {
+ return new DefaultLineMapper();
+ }
+ }
+
+ private static class KeyFilter implements Filter {
+ Set<Pattern> patterns = new HashSet<Pattern>();
+
+
+ public KeyFilter(Set<String> keyFilters) {
+ for(String filterString : keyFilters) {
+ patterns.add(Pattern.compile(filterString));
+ }
+ }
+
+ public boolean accept(GraphType graphType, String name, String edgeName,
+ String source, String dest) {
+ if(graphType.equals(GraphType.KEY)) {
+ for(Pattern pattern : patterns) {
+ if(pattern.matcher(name).find()) {
+ return true;
+ }
+ }
+
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ public boolean acceptPattern(GraphType graphType, Pattern pattern,
+ String edgeName, String source, String dest) {
+ return true;
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/geode/sequence/HydraLineMapper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/sequence/HydraLineMapper.java b/geode-core/src/test/java/org/apache/geode/sequence/HydraLineMapper.java
new file mode 100644
index 0000000..af82c47
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/sequence/HydraLineMapper.java
@@ -0,0 +1,134 @@
+/*
+ * 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 org.apache.geode.sequence;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.geode.sequence.LineMapper;
+
+/**
+ *
+ */
+public class HydraLineMapper implements LineMapper {
+ private static final Pattern VM_NAME_PATTERN = Pattern.compile("(vm_\\d+).*_(\\d+)(_end)?\\.log");
+ private static final Pattern DISK_DIR_PATTERN = Pattern.compile("vm_(\\d+).*_disk_1");
+ private final Map<String, String> processIdToVMName = new HashMap<String, String>();
+ private final DefaultLineMapper defaultMapper = new DefaultLineMapper();
+
+ public HydraLineMapper(File[] graphFiles) {
+ File firstFile = graphFiles[0];
+ File directory = firstFile.getParentFile();
+ if(directory == null || ! new File(directory, "latest.prop").exists()) {
+ directory = new File(".");
+ }
+ String[] files = directory.list();
+ for(String file : files) {
+ Matcher matcher = VM_NAME_PATTERN.matcher(file);
+ if(matcher.matches()) {
+ processIdToVMName.put(matcher.group(2), matcher.group(1));
+ }
+ }
+
+ for(String file : files) {
+ Matcher matcher = DISK_DIR_PATTERN.matcher(file);
+ if(matcher.matches()) {
+
+ String storeId = getDiskStoreId(file);
+ if(storeId != null) {
+ processIdToVMName.put(storeId, "disk_" + matcher.group(1));
+ }
+ }
+ }
+
+
+ }
+
+ private String getDiskStoreId(String diskStoreDir) {
+ File dir = new File(diskStoreDir);
+ String[] files = dir.list();
+ for(String fileName : files) {
+ if(fileName.endsWith(".if")) {
+ try {
+ return getDiskStoreIdFromInitFile(dir, fileName);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private String getDiskStoreIdFromInitFile(File dir, String fileName)
+ throws FileNotFoundException, IOException {
+ FileInputStream fis = new FileInputStream(new File(dir, fileName));
+ try {
+ byte[] bytes = new byte[1 + 8 + 8];
+ fis.read(bytes);
+ ByteBuffer buffer = ByteBuffer.wrap(bytes);
+ //Skip the record type.
+ buffer.get();
+ long least = buffer.getLong();
+ long most = buffer.getLong();
+ UUID id = new UUID(most, least);
+ return id.toString();
+ } finally {
+ fis.close();
+ }
+ }
+
+ public String getShortNameForLine(String lineName) {
+ String name = defaultMapper.getShortNameForLine(lineName);
+ if(processIdToVMName.containsKey(name)) {
+ return processIdToVMName.get(name);
+ } else {
+ return name;
+ }
+ }
+
+ public static boolean isInHydraRun(File[] graphFiles) {
+ if(graphFiles.length == 0) {
+ return false;
+ }
+ File firstFile = graphFiles[0];
+ File parentFile = firstFile.getParentFile();
+ for(File file : graphFiles) {
+ if(parentFile == null && file.getParentFile() == null) {
+ return true;
+ }
+ if (parentFile == null || file.getParentFile() == null
+ || !file.getParentFile().equals(parentFile)) {
+ return false;
+ }
+ }
+
+ return new File(parentFile, "latest.prop").exists()
+ || new File("latest.prop").exists();
+
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/geode/sequence/Lifeline.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/sequence/Lifeline.java b/geode-core/src/test/java/org/apache/geode/sequence/Lifeline.java
new file mode 100644
index 0000000..f80b533
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/sequence/Lifeline.java
@@ -0,0 +1,98 @@
+/*
+ * 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 org.apache.geode.sequence;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dsmith
+ * Date: Oct 29, 2010
+ * Time: 3:59:02 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class Lifeline {
+ private List<LifelineState> states;
+ private final String name;
+ private final Comparable diagramName;
+ private int x;
+ private int width;
+
+ public String getName() {
+ return name;
+ }
+
+ public int getX() {
+ return x;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public void addState(LifelineState state) {
+ this.states.add(state);
+ }
+
+ public Lifeline(Comparable diagramName, String name) {
+ this.name = name;
+ this.states = new ArrayList<LifelineState>();
+ this.diagramName = diagramName;
+ }
+
+ public void resize(int x, int lineWidth, long Ybase, double Yscale) {
+ for(LifelineState state : states) {
+ state.resize(Yscale, Ybase);
+ }
+
+ this.x = x;
+ width = lineWidth;
+ }
+
+ public void paint(Graphics2D g, StateColorMap colorMap) {
+ Rectangle boundary = g.getClipBounds();
+ if(x > boundary.getMaxX() || x + width < boundary.getMinX()) {
+ //no need to paint if this line isn't displayed
+ return;
+ }
+ //TODO - we need to clip these to the visible states
+ for(LifelineState state : states) {
+ state.paint(g, colorMap);
+ }
+ }
+
+ public List<LifelineState> getStates() {
+ return states;
+ }
+
+ public LifelineState getStateAt(int y) {
+ for(LifelineState state : states) {
+ if(state.getStartY() < y && state.getStartY() + state.getHeight() > y) {
+ return state;
+ }
+ }
+ return null;
+ }
+
+ public Comparable getDiagramName() {
+ return diagramName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/geode/sequence/LifelineState.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/sequence/LifelineState.java b/geode-core/src/test/java/org/apache/geode/sequence/LifelineState.java
new file mode 100644
index 0000000..c1a57bf
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/sequence/LifelineState.java
@@ -0,0 +1,114 @@
+/*
+ * 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 org.apache.geode.sequence;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.swing.JLabel;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dsmith
+ * Date: Oct 29, 2010
+ * Time: 3:45:07 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class LifelineState {
+ private final long startTime;
+ private final long endTime;
+ private final String stateName;
+ private int startY;
+ private int height;
+ private final Lifeline line;
+ private final Set<Arrow> inboundArrows = new HashSet<Arrow>();
+ private static final int ARC_SIZE = 10;
+
+ public int getStartY() {
+ return startY;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+
+ public LifelineState(Lifeline line, String stateName, long startTime, long endTime) {
+ this.line = line;
+ this.stateName = stateName;
+ this.startTime = startTime;
+ this.endTime = endTime;
+ }
+
+ public void paint(Graphics2D g, StateColorMap colorMap) {
+ Rectangle bounds = g.getClipBounds();
+ if(startY > bounds.getMaxY() || startY+height <bounds.getMinY()) {
+ return;
+ }
+
+ int x = line.getX();
+ int width = line.getWidth();
+
+ Color color = colorMap.getColor(stateName);
+ g.setColor(color);
+ g.fillRoundRect(x, startY, width, height, ARC_SIZE, ARC_SIZE);
+ g.setColor(Color.BLACK);
+ }
+
+ public void highlight(Graphics2D g) {
+ Rectangle bounds = g.getClipBounds();
+ if(startY > bounds.getMaxY() || startY+height <bounds.getMinY()) {
+ return;
+ }
+
+ int x = line.getX();
+ int width = line.getWidth();
+
+ g.drawRoundRect(x, startY, width, height, ARC_SIZE, ARC_SIZE);
+ }
+
+ public void resize(double scale, long base) {
+ startY = (int) ((startTime - base) * scale);
+ height = (int) ((endTime - startTime) * scale);
+ }
+
+ public Component getPopup() {
+ return new JLabel("<html>Object: " + line.getDiagramName() + "<br>Member: " + line.getName() + "<br>State: " + stateName + "<br>Time:" + new Date(startTime) + "</html>");
+ }
+
+ public Lifeline getLine() {
+ return line;
+ }
+
+ public void addInboundArrow(Arrow arrow) {
+ inboundArrows.add(arrow);
+ }
+
+ public Set<Arrow> getInboundArrows() {
+ return inboundArrows;
+ }
+
+ @Override
+ public String toString() {
+ return line.getName() + "@" + startTime + ":" + stateName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/geode/sequence/LineMapper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/sequence/LineMapper.java b/geode-core/src/test/java/org/apache/geode/sequence/LineMapper.java
new file mode 100644
index 0000000..91f7d6c
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/sequence/LineMapper.java
@@ -0,0 +1,35 @@
+/*
+ * 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 org.apache.geode.sequence;
+
+/**
+ * An interface for mapping a lifeline name to a shorter version of the same
+ * line. This could also consolodate multiple lifelines onto a single line.
+ *
+ * The most common case for this is that a lifeline represents a VM that is
+ * restarted several times. Eg time, the line name changes, but we want to put
+ * all of the states for that "logical" vm on the same line.
+ *
+ */
+public interface LineMapper {
+
+ /**
+ * Return the short name for this lifeline.
+ */
+ public String getShortNameForLine(String lineName);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/geode/sequence/SelectGraphDialog.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/sequence/SelectGraphDialog.java b/geode-core/src/test/java/org/apache/geode/sequence/SelectGraphDialog.java
new file mode 100644
index 0000000..caa37e5
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/sequence/SelectGraphDialog.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geode.sequence;
+
+import org.apache.geode.internal.sequencelog.model.GraphID;
+import org.apache.geode.internal.sequencelog.model.GraphSet;
+
+import javax.swing.*;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.*;
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dsmith
+ * Date: Dec 9, 2010
+ * Time: 3:34:38 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SelectGraphDialog extends JDialog {
+ private List<GraphID> selectedIds = new ArrayList<GraphID>();
+ private Set<SelectionListener> listeners = new HashSet<SelectionListener>();
+
+ public SelectGraphDialog(final GraphSet graphs) {
+
+ final List<GraphID> ids = new ArrayList<GraphID>(graphs.getMap().keySet());
+ Collections.sort(ids);
+ final FilterableListModel listModel = new FilterableListModel(ids);
+ final JList list = new JList(listModel);
+
+ JScrollPane selectGraphPane = new JScrollPane(list);
+ selectGraphPane.setPreferredSize(new Dimension(500, 500));
+
+ JButton apply = new JButton("Apply");
+ apply.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ selectedIds = (List) Arrays.asList(list.getSelectedValues());
+ fireSelectionChanged();
+ setVisible(false);
+ }
+ });
+
+ JButton cancel= new JButton("Cancel");
+ cancel.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ setVisible(false);
+ }
+ });
+
+ JPanel buttonPane = new JPanel();
+ buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
+ buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
+ buttonPane.add(Box.createHorizontalGlue());
+ buttonPane.add(apply);
+ buttonPane.add(cancel);
+
+ final JTextField searchField = new JTextField(10);
+ searchField.getDocument().addDocumentListener(new DocumentListener() {
+ public void removeUpdate(DocumentEvent e) {
+ doUpdate();
+ }
+
+ public void insertUpdate(DocumentEvent e) {
+ doUpdate();
+ }
+
+ public void changedUpdate(DocumentEvent e) {
+ doUpdate();
+ }
+
+ private void doUpdate() {
+ listModel.updateFilter(searchField.getText());
+ }
+ });
+
+
+ Container contentPane = getContentPane();
+ contentPane.add(searchField, BorderLayout.PAGE_START);
+ contentPane.add(selectGraphPane, BorderLayout.CENTER);
+ contentPane.add(buttonPane, BorderLayout.PAGE_END);
+ }
+
+ private void fireSelectionChanged() {
+ for(SelectionListener listener : listeners) {
+ listener.selectionChanged(selectedIds);
+ }
+ }
+
+ public void addSelectionListener(SelectionListener listener) {
+ listeners.add(listener);
+
+ }
+
+ public void removeSelectionListener(SelectionListener listener) {
+ listeners.remove(listener);
+ }
+
+ /**
+ * A listener for changes to the graph selections
+ */
+ public static interface SelectionListener {
+ void selectionChanged(List<GraphID> selectedIds);
+ }
+
+ private static class FilterableListModel extends AbstractListModel {
+ private final List<?> allElements;
+ private List<Object> filteredElements;
+
+ public FilterableListModel(List<?> elements) {
+ this.allElements = elements;
+ this.filteredElements = new ArrayList<Object>(elements);
+ }
+
+ public int getSize() {
+ return filteredElements.size();
+ }
+
+ public Object getElementAt(int index) {
+ return filteredElements.get(index);
+ }
+
+ public void updateFilter(String filter) {
+ Pattern pattern = Pattern.compile(filter);
+ filteredElements = new ArrayList<Object>();
+ for(Object element : allElements) {
+ if(pattern.matcher(element.toString()).find()) {
+ filteredElements.add(element);
+ }
+ }
+
+ fireContentsChanged(this, 0, filteredElements.size());
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/geode/sequence/SequenceDiagram.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/sequence/SequenceDiagram.java b/geode-core/src/test/java/org/apache/geode/sequence/SequenceDiagram.java
new file mode 100644
index 0000000..5064d8a
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/sequence/SequenceDiagram.java
@@ -0,0 +1,315 @@
+/*
+ * 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 org.apache.geode.sequence;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.*;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dsmith
+ * Date: Oct 29, 2010
+ * Time: 4:18:40 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SequenceDiagram extends JPanel {
+
+ /**
+ *
+ */
+ private static final Color HIGHLIGHT_COLOR = Color.RED;
+
+ private final List<String> lineNames;
+ private final Map<String, List<String>> shortLineNames;
+ private final SortedMap<Comparable, SubDiagram> subDiagrams = new TreeMap<Comparable, SubDiagram>();
+ private final StateColorMap colorMap = new StateColorMap();
+ private final long minTime;
+ private final long maxTime;
+
+ private static int PADDING_BETWEEN_LINES = 100;
+ private static int Y_PADDING = 20;
+ private static final int STATE_WIDTH = 20;
+ private static final int LINE_LABEL_BOUNDARY = 5;
+ private static final int AXIS_SIZE=35;
+
+ private int lineStep;
+ private int lineWidth;
+ private Popup mouseover;
+ private LifelineState mouseoverState;
+ private LifelineState selectedState;
+
+ public SequenceDiagram(long minTime, long maxTime, List<String> lineNames, LineMapper lineMapper) {
+ this.lineNames = lineNames;
+ this.shortLineNames = parseShortNames(lineNames, lineMapper);
+ this.minTime = minTime;
+ this.maxTime = maxTime;
+ int width = getInitialWidth();
+ int height = 500;
+ super.setPreferredSize(new Dimension(width, height));
+ resizeMe(width, height);
+ addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentResized(ComponentEvent e) {
+ Component source = (Component) e.getSource();
+ resizeMe(source.getWidth(), source.getHeight());
+ }
+ });
+ setBackground(Color.WHITE);
+ }
+
+ private Map<String, List<String>> parseShortNames(List<String> lineNames, LineMapper lineMapper) {
+ Map<String, List<String>> shortNames = new LinkedHashMap<String, List<String>>(lineNames.size());
+ for(String name : lineNames) {
+ String shortName = lineMapper.getShortNameForLine(name);
+ List<String> list = shortNames.get(shortName);
+ if(list == null) {
+ list = new ArrayList<String>();
+ shortNames.put(shortName, list);
+ }
+ list.add(name);
+ }
+
+ return shortNames;
+ }
+
+ public List<Comparable> getSubDiagramsNames() {
+ return new ArrayList<Comparable>(subDiagrams.keySet());
+
+ }
+
+ public void addSubDiagram(Comparable name, Map<String, Lifeline> lines, List<Arrow> arrows) {
+ subDiagrams.put(name, new SubDiagram(name, lines, arrows));
+ }
+
+ public void removeSubDiagram(Comparable name) {
+ this.subDiagrams.remove(name);
+ }
+
+ private int getInitialWidth() {
+ return (this.shortLineNames.size()) * PADDING_BETWEEN_LINES;
+ }
+
+ public void resizeMe(int width, int height) {
+ this.setPreferredSize(new Dimension(width, height));
+ float xZoom = width / (float) getInitialWidth();
+
+
+ long elapsedTime = maxTime - minTime;
+ double yScale = height / (double) elapsedTime;
+// long yBase = (long) (minTime - ((long) Y_PADDING / yScale));
+ long yBase = minTime;
+ lineStep = (int) (PADDING_BETWEEN_LINES * xZoom);
+ lineWidth = (int) (STATE_WIDTH * xZoom);
+
+ if(subDiagrams.size() <= 0) {
+ return;
+ }
+
+ int sublineWidth = lineWidth / subDiagrams.size();
+ int sublineIndex = 0;
+ for(SubDiagram diagram : subDiagrams.values()) {
+ int lineIndex = 0;
+ for(List<String> fullNames : shortLineNames.values()) {
+ for(String name : fullNames) {
+ Lifeline line = diagram.lifelines.get(name);
+ if(line != null) {
+ int lineX = lineIndex * lineStep + sublineIndex * sublineWidth;
+ line.resize(lineX, sublineWidth, yBase, yScale);
+ }
+ }
+ lineIndex++;
+ }
+ sublineIndex++;
+ }
+ }
+
+ public void showPopupText(int x, int y, int xOnScreen, int yOnScreen) {
+ LifelineState state = getStateAt(x, y);
+ if(state == mouseoverState) {
+ return;
+ }
+ if(mouseover != null) {
+ mouseover.hide();
+ }
+ if(state == null) {
+ mouseover = null;
+ mouseoverState = null;
+ } else {
+ Component popupContents = state.getPopup();
+ mouseoverState = state;
+ mouseover = PopupFactory.getSharedInstance().getPopup(this, popupContents, xOnScreen + 20, yOnScreen);
+ mouseover.show();
+ }
+ }
+
+ public void selectState(int x, int y) {
+ LifelineState state = getStateAt(x, y);
+ if(state == selectedState) {
+ return;
+ }
+
+ if(selectedState != null) {
+ fireRepaintOfDependencies(selectedState);
+ }
+
+ selectedState = state;
+
+ if(state != null) {
+ fireRepaintOfDependencies(state);
+ }
+ }
+
+ private LifelineState getStateAt(int x, int y) {
+ //TODO - this needs some
+ //serious optimization to go straight to the right state
+ // I think we need a tree map of of lines, keyed by x offset
+ //and a keymap of states keyed by y offset.
+ //That could make painting faster as well.
+ List<String> reverseList = new ArrayList<String>(lineNames);
+ Collections.reverse(reverseList);
+ for(SubDiagram diagram : subDiagrams.values()) {
+ for(String name : reverseList) {
+ Lifeline line = diagram.lifelines.get(name);
+ if(line != null) {
+ if(line.getX() < x && line.getX() + line.getWidth() > x) {
+ LifelineState state = line.getStateAt(y);
+ if(state != null) {
+ return state;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ Graphics2D g2 = (Graphics2D) g.create();
+ //TODO - we should clip these to the visible lines
+ for(SubDiagram subDiagram : subDiagrams.values()) {
+ subDiagram.paintStates(g2, colorMap);
+ }
+
+ for(SubDiagram subDiagram : subDiagrams.values()) {
+ subDiagram.paintArrows(g2, colorMap);
+ }
+ paintHighlightedComponents(g2, selectedState, new HashSet<LifelineState>());
+ }
+
+ private void fireRepaintOfDependencies(LifelineState state) {
+ //TODO - it might be more efficient to repaint just the changed
+ //areas, but right now this will do.
+ repaint();
+ }
+
+ private void paintHighlightedComponents(Graphics2D g2, LifelineState endingState, Set<LifelineState> visited) {
+ if(!visited.add(endingState)) {
+ //Prevent cycles
+ return;
+ }
+ g2.setColor(HIGHLIGHT_COLOR);
+ if(endingState != null) {
+ endingState.highlight(g2);
+
+ for(Arrow arrow : endingState.getInboundArrows()) {
+ arrow.paint(g2);
+ paintHighlightedComponents(g2, arrow.getStartingState(), visited);
+ }
+ }
+
+
+ }
+
+ public long getMinTime() {
+ return minTime;
+ }
+
+ public long getMaxTime() {
+ return maxTime;
+ }
+
+ public JComponent createMemberAxis() {
+ return new MemberAxis();
+ }
+
+ private class MemberAxis extends JComponent {
+ public MemberAxis() {
+ setPreferredSize(new Dimension(getWidth(), AXIS_SIZE));
+ SequenceDiagram.this.addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentResized(ComponentEvent e) {
+ int newWidth = e.getComponent().getWidth();
+ setPreferredSize(new Dimension(newWidth, AXIS_SIZE));
+ revalidate();
+ }
+ });
+ }
+ @Override
+ protected void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ Rectangle bounds = g.getClipBounds();
+ int index = 0;
+ for(String name : shortLineNames.keySet()) {
+ int nameWidth = g.getFontMetrics().stringWidth(name);
+ int lineX = lineStep * index;
+ index++;
+ if(bounds.getMaxX() < lineX
+ || bounds.getMinX() > lineX + nameWidth) {
+ continue;
+ }
+ g.setClip(lineX + LINE_LABEL_BOUNDARY, 0, lineStep - + LINE_LABEL_BOUNDARY * 2, getHeight());
+ g.drawString(name, lineX + LINE_LABEL_BOUNDARY, AXIS_SIZE / 3);
+ g.setClip(null);
+ }
+ }
+ }
+
+ public static class SubDiagram {
+ private final Map<String, Lifeline> lifelines;
+ private final List<Arrow> arrows;
+ private final Comparable name;
+
+ public SubDiagram(Comparable name, Map<String, Lifeline> lines, List<Arrow> arrows) {
+ this.name = name;
+ this.lifelines = lines;
+ this.arrows = arrows;
+ }
+
+ public void paintStates(Graphics2D g2, StateColorMap colorMap) {
+ for(Lifeline line: lifelines.values()) {
+ line.paint(g2, colorMap);
+ }
+ }
+ public void paintArrows(Graphics2D g2, StateColorMap colorMap) {
+ Color lineColor = colorMap.getColor(name);
+ g2.setColor(lineColor);
+ for(Arrow arrow: arrows) {
+ arrow.paint(g2);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/geode/sequence/SequencePanel.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/sequence/SequencePanel.java b/geode-core/src/test/java/org/apache/geode/sequence/SequencePanel.java
new file mode 100644
index 0000000..daefc08
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/sequence/SequencePanel.java
@@ -0,0 +1,83 @@
+/*
+ * 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 org.apache.geode.sequence;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dan
+ * Date: Oct 28, 2010
+ * Time: 10:29:23 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SequencePanel extends JPanel {
+
+ public SequencePanel(SequenceDiagram sequenceDiagram) {
+ //Set up the drawing area.
+ ZoomingPanel drawingPane = new ZoomingPanel();
+ drawingPane.setBackground(Color.white);
+ drawingPane.setSequenceDiagram(sequenceDiagram);
+
+ //Put the drawing area in a scroll pane.
+ final JScrollPane scroller = new JScrollPane(drawingPane);
+ scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+ scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
+ final TimeAxis timeAxis = new TimeAxis(TimeAxis.VERTICAL,
+ sequenceDiagram.getMinTime(),
+ sequenceDiagram.getMaxTime());
+ timeAxis.setPreferredHeight(drawingPane.getHeight());
+ scroller.setRowHeaderView(timeAxis);
+ scroller.setColumnHeaderView(sequenceDiagram.createMemberAxis());
+ int preferredWidth = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - 100);
+ int preferredHeight = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 100);
+ scroller.setPreferredSize(new Dimension(preferredWidth, preferredHeight));
+ scroller.setAutoscrolls(true);
+// scroller.setPreferredSize(new Dimension(200,200));
+
+ sequenceDiagram.addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentResized(ComponentEvent e) {
+ int height = e.getComponent().getHeight();
+ timeAxis.setPreferredHeight(height);
+ timeAxis.revalidate();
+ }
+ });
+
+ BorderLayout layout = new BorderLayout();
+// layout.setHgap(0);
+// layout.setVgap(0);
+ setLayout(layout);
+ //Lay out this demo.
+// add(instructionPanel, BorderLayout.PAGE_START);
+ add(scroller, BorderLayout.CENTER);
+
+ addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentResized(ComponentEvent e) {
+ Component source =e.getComponent();
+ scroller.setSize(source.getSize());
+ scroller.revalidate();
+ }
+ });
+
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/geode/sequence/StateColorMap.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/sequence/StateColorMap.java b/geode-core/src/test/java/org/apache/geode/sequence/StateColorMap.java
new file mode 100644
index 0000000..0ef3ab7
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/sequence/StateColorMap.java
@@ -0,0 +1,66 @@
+/*
+ * 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 org.apache.geode.sequence;
+
+import java.awt.*;
+import java.util.HashMap;
+import java.util.Map;
+
+import static java.lang.Math.random;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dsmith
+ * Date: Nov 12, 2010
+ * Time: 5:05:49 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class StateColorMap {
+ private Map<Object, Color> colors = new HashMap<Object, Color>();
+ private static Color[] PREDEFINED_COLORS = new Color[] { Color.BLUE, Color.BLACK, Color.PINK, Color.CYAN, Color.ORANGE, Color.GREEN};
+
+ private ColorList colorList = new ColorList();
+
+ public StateColorMap() {
+ colors.put("created", Color.GREEN);
+ colors.put("destroyed", Color.WHITE);
+ colors.put("persisted", new Color(0, 150, 0));
+ }
+
+
+ public Color getColor(Object state) {
+ Color color = colors.get(state);
+ if(color == null) {
+ color = colorList.nextColor();
+ colors.put(state, color);
+ }
+
+ return color;
+ }
+
+ private static class ColorList {
+ int colorIndex;
+
+ public Color nextColor() {
+ if(colorIndex < PREDEFINED_COLORS.length) {
+ return PREDEFINED_COLORS[colorIndex++];
+ } else {
+ return Color.getHSBColor((float)random(), (float)random(), (float)random());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/geode/sequence/TimeAxis.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/sequence/TimeAxis.java b/geode-core/src/test/java/org/apache/geode/sequence/TimeAxis.java
new file mode 100644
index 0000000..39d14ff
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/sequence/TimeAxis.java
@@ -0,0 +1,122 @@
+/*
+ * 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 org.apache.geode.sequence;
+
+import javax.swing.*;
+import java.awt.*;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dsmith
+ * Date: Oct 29, 2010
+ * Time: 5:24:54 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TimeAxis extends JComponent {
+ public static final int HORIZONTAL = 0;
+ public static final int VERTICAL = 1;
+ public static final int SIZE = 100;
+ private static final DateFormat DATE_FORMAT = new SimpleDateFormat("HH:mm:ss.SSS");
+
+ public int orientation;
+ private long minTime;
+ private long maxTime;
+
+ public TimeAxis(int orientation, long minTime, long maxTime) {
+ this.orientation = orientation;
+ this.minTime = minTime;
+ this.maxTime = maxTime;
+ }
+
+ public void setPreferredHeight(int ph) {
+ setPreferredSize(new Dimension(SIZE, ph));
+ }
+
+ public void setPreferredWidth(int pw) {
+ setPreferredSize(new Dimension(pw, SIZE));
+ }
+
+ protected void paintComponent(Graphics g) {
+ Rectangle drawHere = g.getClipBounds();
+
+ int height = getHeight();
+
+ double scale = (maxTime - minTime) / height;
+ int increment = 30;
+ // Fill clipping area with dirty brown/orange.
+ g.setColor(new Color(230, 163, 4));
+ g.fillRect(drawHere.x, drawHere.y, drawHere.width, drawHere.height);
+
+ // Do the ruler labels in a small font that's black.
+ g.setFont(new Font("SansSerif", Font.PLAIN, 10));
+ g.setColor(Color.black);
+
+ // Some vars we need.
+ int end = 0;
+ int start = 0;
+ int tickLength = 0;
+ String text = null;
+
+ // Use clipping bounds to calculate first and last tick locations.
+ if (orientation == HORIZONTAL) {
+ start = (drawHere.x / increment) * increment;
+ end = (((drawHere.x + drawHere.width) / increment) + 1)
+ * increment;
+ } else {
+ start = (drawHere.y / increment) * increment;
+ end = (((drawHere.y + drawHere.height) / increment) + 1)
+ * increment;
+ }
+
+ // Make a special case of 0 to display the number
+ // within the rule and draw a units label.
+ if (start == 0) {
+ text = DATE_FORMAT.format(new Date(minTime));
+ tickLength = 10;
+ if (orientation == HORIZONTAL) {
+ g.drawLine(0, SIZE-1, 0, SIZE-tickLength-1);
+ g.drawString(text, 2, 21);
+ } else {
+ g.drawLine(SIZE-1, 0, SIZE-tickLength-1, 0);
+ g.drawString(text, 9, 10);
+ }
+ text = null;
+ start = increment;
+ }
+
+ // ticks and labels
+ for (int i = start; i < end; i += increment) {
+ tickLength = 10;
+ text = DATE_FORMAT.format(new Date((long) (minTime + i * scale)));
+
+ if (tickLength != 0) {
+ if (orientation == HORIZONTAL) {
+ g.drawLine(i, SIZE-1, i, SIZE-tickLength-1);
+ if (text != null)
+ g.drawString(text, i-3, 21);
+ } else {
+ g.drawLine(SIZE-1, i, SIZE-tickLength-1, i);
+ if (text != null)
+ g.drawString(text, 9, i+3);
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/geode/sequence/ZoomingPanel.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/sequence/ZoomingPanel.java b/geode-core/src/test/java/org/apache/geode/sequence/ZoomingPanel.java
new file mode 100644
index 0000000..09f6ef6
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/sequence/ZoomingPanel.java
@@ -0,0 +1,188 @@
+/*
+ * 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 org.apache.geode.sequence;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseMotionAdapter;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: dan
+ * Date: Oct 28, 2010
+ * Time: 10:30:40 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ZoomingPanel extends JPanel {
+ private int zoomBoxStartX;
+ private int zoomBoxStartY;
+ private int zoomBoxWidth;
+ private int zoomBoxHeight;
+ private SequenceDiagram child;
+
+
+ public ZoomingPanel() {
+ super();
+ addMouseListener(new MouseAdapter() {
+ @Override
+ public void mousePressed(MouseEvent e) {
+ startBox(e.getX(), e.getY());
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ endBox(e.getX(), e.getY());
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.getButton() != MouseEvent.BUTTON1) {
+ unzoom();
+ } else {
+ child.selectState(e.getX(), e.getY());
+ }
+
+ }
+ });
+
+ addMouseMotionListener(new MouseMotionAdapter() {
+ @Override
+ public void mouseDragged(MouseEvent e) {
+ Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1);
+ ((JPanel)e.getSource()).scrollRectToVisible(r);
+ showBox(e.getX(), e.getY());
+ }
+
+ @Override
+ public void mouseMoved(MouseEvent e) {
+ int popupX = ZoomingPanel.this.getLocationOnScreen().x + e.getX();
+ int popupY = ZoomingPanel.this.getLocationOnScreen().y + e.getY();
+ child.showPopupText(e.getX(), e.getY(), popupX, popupY);
+ }
+ });
+ BorderLayout layout = new BorderLayout();
+ layout.setHgap(0);
+ layout.setVgap(0);
+ this.setLayout(layout);
+ }
+
+ private void unzoom() {
+ resizeMe(0, 0, getWidth(), getHeight());
+ }
+
+ void resizeMe(int zoomBoxX, int zoomBoxY, int zoomBoxWidth, int zoomBoxHeight) {
+ Dimension viewSize = getParent().getSize();
+ double windowWidth = viewSize.getWidth();
+ double windowHeight = viewSize.getHeight();
+ double scaleX = getWidth() / ((double) zoomBoxWidth);
+ double scaleY = getHeight() / ((double) zoomBoxHeight);
+ int oldWidth = getWidth();
+ int oldHeight = getHeight();
+ int width = (int) (scaleX * windowWidth);
+ int height = (int) (scaleY * windowHeight);
+// this.setPreferredSize(new Dimension(width, height));
+ child.resizeMe(width, height);
+ //TODO not sure this one is needed
+ this.revalidate();
+
+ //scroll to the new rectangle
+// int scrollX = (int) (zoomBoxX * scaleX);
+// int scrollY = (int) (zoomBoxY * scaleY);
+// int scrollWidth= (int) (zoomBoxWidth * scaleX);
+// int scrollHeight = (int) (zoomBoxHeight * scaleY);
+ int scrollX = (int) (zoomBoxX * (width / (double) oldWidth));
+ int scrollY = (int) (zoomBoxY * (height / (double) oldHeight));
+ int scrollWidth= (int) (zoomBoxWidth * (width / (double) oldWidth));
+ int scrollHeight = (int) (zoomBoxHeight * (height / (double) oldHeight));
+ Rectangle r = new Rectangle(scrollX, scrollY, scrollWidth, scrollHeight);
+ ((JViewport)getParent()).scrollRectToVisible(r);
+ repaint();
+
+ }
+
+ public void setSequenceDiagram(SequenceDiagram diag) {
+ this.child = diag;
+ this.add(child, BorderLayout.CENTER);
+ }
+
+ private void showBox(int x, int y) {
+ if(zoomBoxWidth != -1) {
+ repaint(getBoxX(), getBoxY(), getBoxWidth(), getBoxHeight());
+ }
+
+ this.zoomBoxWidth = x - zoomBoxStartX;
+ this.zoomBoxHeight = y - zoomBoxStartY;
+
+ repaint(getBoxX(), getBoxY(), getBoxWidth(), getBoxHeight());
+ }
+
+ private void startBox(int x, int y) {
+ this.zoomBoxStartX = x;
+ this.zoomBoxStartY = y;
+ }
+
+ private void endBox(int x, int y) {
+ if(zoomBoxStartX != -1 && zoomBoxStartY != -1
+ && zoomBoxWidth != -1 && zoomBoxHeight != -1
+ && zoomBoxWidth != 0 && zoomBoxHeight != 0) {
+ resizeMe(getBoxX() , getBoxY(), getBoxWidth(), getBoxHeight());
+ repaint(getBoxX(), getBoxY(), getBoxWidth(), getBoxHeight());
+ this.zoomBoxStartX = -1;
+ this.zoomBoxStartY = -1;
+ this.zoomBoxWidth = -1;
+ this.zoomBoxHeight = -1;
+ }
+ }
+
+ public int getBoxX() {
+ return zoomBoxWidth >= 0 ? zoomBoxStartX : zoomBoxStartX + zoomBoxWidth;
+ }
+
+ public int getBoxY() {
+ return zoomBoxHeight >= 0 ? zoomBoxStartY : zoomBoxStartY + zoomBoxHeight;
+ }
+
+ public int getBoxHeight() {
+ return zoomBoxHeight >= 0 ? zoomBoxHeight : -zoomBoxHeight;
+ }
+
+ public int getBoxWidth() {
+ return zoomBoxWidth >= 0 ? zoomBoxWidth : -zoomBoxWidth;
+ }
+
+
+
+ @Override
+ public void paint(Graphics g) {
+ super.paint(g);
+
+ if(zoomBoxStartX != -1 && zoomBoxStartY != -1 && zoomBoxWidth != -1 && zoomBoxHeight != -1) {
+ Graphics2D g2 = (Graphics2D) g.create();
+
+ Composite old = g2.getComposite();
+ g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
+ g2.setColor(Color.BLUE);
+
+// g2.drawRect(zoomBoxStartX, zoomBoxStartY, zoomBoxWidth, zoomBoxHeight);
+// g2.setBackground(Color.BLUE);
+ g2.fillRect(getBoxX(), getBoxY(), getBoxWidth(), getBoxHeight());
+ g2.setComposite(old);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/sequence/Arrow.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/sequence/Arrow.java b/geode-core/src/test/java/org/apache/sequence/Arrow.java
deleted file mode 100644
index 4274aa9..0000000
--- a/geode-core/src/test/java/org/apache/sequence/Arrow.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sequence;
-
-import java.awt.*;
-import java.awt.geom.GeneralPath;
-
-/**
- * Created by IntelliJ IDEA.
- * User: dsmith
- * Date: Nov 12, 2010
- * Time: 12:02:20 PM
- * To change this template use File | Settings | File Templates.
- */
-public class Arrow {
- private static int ARROW_WIDTH=10;
- private static int CIRCLE_WIDTH=6;
- private static int LABEL_OFFSET=10;
-
- private final String label;
- private final LifelineState startingState;
- private final LifelineState endingState;
-
- public Arrow(String label, LifelineState startingState, LifelineState endingState) {
- this.label = label;
- this.startingState = startingState;
- this.endingState = endingState;
- }
-
-
- public void paint(Graphics2D g) {
- Rectangle boundary = g.getClipBounds();
- int y = endingState.getStartY();
-
- //don't paint if we're not in the clip area
- if(y + ARROW_WIDTH < boundary.getMinY() || y - ARROW_WIDTH > boundary.getMaxY()) {
- return;
- }
-
- //TODO - we need to clip by X coordinate as well.
-
- boolean isReflexsive = getStartingLine() == getEndingLine();
- if(isReflexsive) {
- paintReflexive(g);
- } else {
- paintNormal(g);
- }
- }
-
- private Lifeline getStartingLine() {
- return startingState.getLine();
- }
-
- private Lifeline getEndingLine() {
- return endingState.getLine();
- }
-
- private void paintReflexive(Graphics2D g) {
- Lifeline startingLine = getStartingLine();
- int x = startingLine.getX();
- int y = endingState.getStartY();
-
- g.drawArc(x + startingLine.getWidth() - ARROW_WIDTH / 2, y - ARROW_WIDTH, ARROW_WIDTH, ARROW_WIDTH, 90, -180);
- g.drawString(label, x + startingLine.getWidth() + LABEL_OFFSET, y);
-// GeneralPath path = new GeneralPath();
-// path.moveTo(x, y - ARROW_WIDTH);
-// path.quadTo(x, y - ARROW_WIDTH);
- }
-
- private void paintNormal(Graphics2D g) {
- Lifeline startingLine = getStartingLine();
- Lifeline endingLine = getEndingLine();
- int x1 = startingLine.getX();
- int x2 = endingLine.getX();
- int y = endingState.getStartY();
-
- if(x2 > x1) {
- int startX = x1 + startingLine.getWidth();
- int endX = x2;
-
- GeneralPath path = new GeneralPath();
- path.moveTo(startX, y);
- path.lineTo(endX, y);
- path.lineTo(endX - ARROW_WIDTH, y - ARROW_WIDTH);
- path.moveTo(endX, y);
- path.lineTo(endX - ARROW_WIDTH, y + ARROW_WIDTH);
- g.draw(path);
- g.fillArc(startX, y - CIRCLE_WIDTH/2, CIRCLE_WIDTH, CIRCLE_WIDTH, 0, 360);
- g.drawString(label, startX + LABEL_OFFSET, y - LABEL_OFFSET);
- } else {
- int startX = x1;
- int endX = x2 + endingLine.getWidth();
-
- GeneralPath path = new GeneralPath();
- path.moveTo(startX, y);
- path.lineTo(endX, y);
- path.lineTo(endX + ARROW_WIDTH, y - ARROW_WIDTH);
- path.moveTo(endX, y);
- path.lineTo(endX + ARROW_WIDTH, y + ARROW_WIDTH);
- g.draw(path);
- int labelWidth = g.getFontMetrics().stringWidth(label);
- g.fillArc(startX - CIRCLE_WIDTH/2, y - CIRCLE_WIDTH/2, CIRCLE_WIDTH, CIRCLE_WIDTH, 0, 360);
- g.drawString(label, startX - LABEL_OFFSET - labelWidth, y - LABEL_OFFSET);
- }
- }
-
- public LifelineState getStartingState() {
- return startingState;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/sequence/Lifeline.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/sequence/Lifeline.java b/geode-core/src/test/java/org/apache/sequence/Lifeline.java
deleted file mode 100644
index f5de6ac..0000000
--- a/geode-core/src/test/java/org/apache/sequence/Lifeline.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sequence;
-
-import java.awt.*;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Created by IntelliJ IDEA.
- * User: dsmith
- * Date: Oct 29, 2010
- * Time: 3:59:02 PM
- * To change this template use File | Settings | File Templates.
- */
-public class Lifeline {
- private List<LifelineState> states;
- private final String name;
- private final Comparable diagramName;
- private int x;
- private int width;
-
- public String getName() {
- return name;
- }
-
- public int getX() {
- return x;
- }
-
- public int getWidth() {
- return width;
- }
-
- public void addState(LifelineState state) {
- this.states.add(state);
- }
-
- public Lifeline(Comparable diagramName, String name) {
- this.name = name;
- this.states = new ArrayList<LifelineState>();
- this.diagramName = diagramName;
- }
-
- public void resize(int x, int lineWidth, long Ybase, double Yscale) {
- for(LifelineState state : states) {
- state.resize(Yscale, Ybase);
- }
-
- this.x = x;
- width = lineWidth;
- }
-
- public void paint(Graphics2D g, StateColorMap colorMap) {
- Rectangle boundary = g.getClipBounds();
- if(x > boundary.getMaxX() || x + width < boundary.getMinX()) {
- //no need to paint if this line isn't displayed
- return;
- }
- //TODO - we need to clip these to the visible states
- for(LifelineState state : states) {
- state.paint(g, colorMap);
- }
- }
-
- public List<LifelineState> getStates() {
- return states;
- }
-
- public LifelineState getStateAt(int y) {
- for(LifelineState state : states) {
- if(state.getStartY() < y && state.getStartY() + state.getHeight() > y) {
- return state;
- }
- }
- return null;
- }
-
- public Comparable getDiagramName() {
- return diagramName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/sequence/LifelineState.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/sequence/LifelineState.java b/geode-core/src/test/java/org/apache/sequence/LifelineState.java
deleted file mode 100644
index 2f39c46..0000000
--- a/geode-core/src/test/java/org/apache/sequence/LifelineState.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sequence;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Graphics2D;
-import java.awt.Rectangle;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.swing.JLabel;
-
-/**
- * Created by IntelliJ IDEA.
- * User: dsmith
- * Date: Oct 29, 2010
- * Time: 3:45:07 PM
- * To change this template use File | Settings | File Templates.
- */
-public class LifelineState {
- private final long startTime;
- private final long endTime;
- private final String stateName;
- private int startY;
- private int height;
- private final Lifeline line;
- private final Set<Arrow> inboundArrows = new HashSet<Arrow>();
- private static final int ARC_SIZE = 10;
-
- public int getStartY() {
- return startY;
- }
-
- public int getHeight() {
- return height;
- }
-
-
- public LifelineState(Lifeline line, String stateName, long startTime, long endTime) {
- this.line = line;
- this.stateName = stateName;
- this.startTime = startTime;
- this.endTime = endTime;
- }
-
- public void paint(Graphics2D g, StateColorMap colorMap) {
- Rectangle bounds = g.getClipBounds();
- if(startY > bounds.getMaxY() || startY+height <bounds.getMinY()) {
- return;
- }
-
- int x = line.getX();
- int width = line.getWidth();
-
- Color color = colorMap.getColor(stateName);
- g.setColor(color);
- g.fillRoundRect(x, startY, width, height, ARC_SIZE, ARC_SIZE);
- g.setColor(Color.BLACK);
- }
-
- public void highlight(Graphics2D g) {
- Rectangle bounds = g.getClipBounds();
- if(startY > bounds.getMaxY() || startY+height <bounds.getMinY()) {
- return;
- }
-
- int x = line.getX();
- int width = line.getWidth();
-
- g.drawRoundRect(x, startY, width, height, ARC_SIZE, ARC_SIZE);
- }
-
- public void resize(double scale, long base) {
- startY = (int) ((startTime - base) * scale);
- height = (int) ((endTime - startTime) * scale);
- }
-
- public Component getPopup() {
- return new JLabel("<html>Object: " + line.getDiagramName() + "<br>Member: " + line.getName() + "<br>State: " + stateName + "<br>Time:" + new Date(startTime) + "</html>");
- }
-
- public Lifeline getLine() {
- return line;
- }
-
- public void addInboundArrow(Arrow arrow) {
- inboundArrows.add(arrow);
- }
-
- public Set<Arrow> getInboundArrows() {
- return inboundArrows;
- }
-
- @Override
- public String toString() {
- return line.getName() + "@" + startTime + ":" + stateName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/sequence/LineMapper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/sequence/LineMapper.java b/geode-core/src/test/java/org/apache/sequence/LineMapper.java
deleted file mode 100644
index d9c7e08..0000000
--- a/geode-core/src/test/java/org/apache/sequence/LineMapper.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sequence;
-
-/**
- * An interface for mapping a lifeline name to a shorter version of the same
- * line. This could also consolodate multiple lifelines onto a single line.
- *
- * The most common case for this is that a lifeline represents a VM that is
- * restarted several times. Eg time, the line name changes, but we want to put
- * all of the states for that "logical" vm on the same line.
- *
- */
-public interface LineMapper {
-
- /**
- * Return the short name for this lifeline.
- */
- public String getShortNameForLine(String lineName);
-
-}
[04/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseBaseTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseBaseTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseBaseTest.java
new file mode 100644
index 0000000..a854a48
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseBaseTest.java
@@ -0,0 +1,693 @@
+/*
+ *
+ * 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.tests;
+
+import static com.vmware.geode.tools.pulse.tests.PulseAbstractTest.*;
+import static org.junit.Assert.*;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.TimeUnit;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+public class PulseBaseTest {
+
+ public static int maxWaitTime = 20;
+
+ WebElement element = null;
+
+ public WebElement findElementUsingId(String id) {
+ return driver.findElement(By.id(id));
+ }
+ public WebElement findElementUsingXpath(String xpath) {
+ return driver.findElement(By.xpath(xpath));
+ }
+
+ public void clickElementUsingId(String id) {
+ findElementUsingId(id).click();
+ }
+
+ public void clickElementUsingXpath(String xpath) {
+ findElementUsingXpath(xpath).click();
+ }
+
+ public void enterTextUsingId(String id, String textToEnter) {
+ findElementUsingId(id).sendKeys(textToEnter);
+
+ }
+
+ public void enterTextUsingXpath(String xpath, String textToEnter) {
+ findElementUsingXpath(xpath).sendKeys(textToEnter);
+ }
+
+ public String getValueFromPropertiesFile(String key) {
+ return JMXProperties.getInstance().getProperty(key);
+ }
+
+ public void sendKeysUsingId(String Id, String textToEnter){
+ findElementById(Id).sendKeys(textToEnter);
+ }
+
+ public void waitForElement(WebElement element) {
+ driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
+ WebDriverWait wait = new WebDriverWait(driver, 20);
+ wait.until(ExpectedConditions.visibilityOf(element));
+ }
+
+ public WebElement findElementById(String id) {
+ return driver.findElement(By.id(id));
+ }
+
+ public WebElement findElementByXpath(String xpath) {
+ return driver.findElement(By.xpath(xpath));
+ }
+
+ public String getTextUsingXpath(String xpath) {
+ return findElementByXpath(xpath).getText();
+ }
+
+ public String getTextUsingId(String id) {
+ return findElementById(id).getText();
+ }
+
+ public String getPersistanceEnabled(Region r) {
+ String persitance = null;
+
+ if (r.getPersistentEnabled()) {
+ persitance = "ON";
+ } else if (!r.getPersistentEnabled()) {
+ persitance = "OFF";
+ }
+ return persitance;
+ }
+
+ public String getPersistanceEnabled(String trueOrFalse) {
+ String persitance = null;
+
+ if (trueOrFalse.contains("true")) {
+ persitance = "ON";
+ } else if (trueOrFalse.contains("false")) {
+ persitance = "OFF";
+ }
+ return persitance;
+ }
+
+ public String HeapUsage(String valueInKB) {
+
+ return null;
+ }
+
+ // WIP - need to work on this --
+ public HashMap<String, HashMap<String, Region>> getRegionDetailsFromUI(String regionName) {
+
+ String[] regionNames = JMXProperties.getInstance().getProperty("regions").split(" ");
+ HashMap<String, HashMap<String, Region>> regionUiMap = new HashMap<String, HashMap<String, Region>>();
+
+ for (String region : regionNames) {
+ HashMap<String, Region> regionMap = regionUiMap.get(region);
+ }
+
+ return regionUiMap;
+ }
+
+ public void validateServerGroupGridData() {
+ List<WebElement> serverGridRows = driver.findElements(By.xpath("//table[@id='memberListSG']/tbody/tr"));
+ int rowsCount = serverGridRows.size();
+ String[][] gridDataFromUI = new String[rowsCount][7];
+
+ for (int j = 2, x = 0; j <= serverGridRows.size(); j++, x++) {
+ for (int i = 0; i <= 6; i++) {
+ gridDataFromUI[x][i] = driver.findElement(
+ By.xpath("//table[@id='memberListSG']/tbody/tr[" + j + "]/td[" + (i + 1) + "]")).getText();
+ }
+ }
+
+ String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
+ HashMap<String, HashMap<String, Member>> sgMap = new HashMap<String, HashMap<String, Member>>();
+
+ for (String member : memberNames) {
+ Member thisMember = new Member(member);
+ String[] sgs = thisMember.getGroups();
+
+ for (String sgName : sgs) {
+ HashMap<String, Member> sgMembers = sgMap.get(sgName);
+ if (sgMembers == null) {
+ sgMembers = new HashMap<String, Member>();
+ sgMap.put(sgName, sgMembers);
+ }
+ sgMembers.put(thisMember.getMember(), thisMember);
+ }
+ }
+
+ for (int i = 0; i < gridDataFromUI.length - 1; i++) {
+ String sgName = gridDataFromUI[i][0];
+ String memName = gridDataFromUI[i][1];
+ Member m = sgMap.get(sgName).get(memName);
+
+ assertEquals(sgName, gridDataFromUI[i][0]);
+ assertEquals(memName, gridDataFromUI[i][1]);
+ assertEquals(m.getMember(), gridDataFromUI[i][2]);
+ assertEquals(m.getHost(), gridDataFromUI[i][3]);
+ String cupUsage = String.valueOf(m.getCpuUsage());
+ assertEquals(cupUsage, gridDataFromUI[i][5]);
+ }
+
+ }
+
+ public void validateRedundancyZonesGridData() {
+ List<WebElement> rzGridRows = driver.findElements(By.xpath("//table[@id='memberListRZ']/tbody/tr"));
+ int rowsCount = rzGridRows.size();
+ String[][] gridDataFromUI = new String[rowsCount][7];
+
+ for (int j = 2, x = 0; j <= rzGridRows.size(); j++, x++) {
+ for (int i = 0; i <= 6; i++) {
+ gridDataFromUI[x][i] = driver.findElement(
+ By.xpath("//table[@id='memberListRZ']/tbody/tr[" + j + "]/td[" + (i + 1) + "]")).getText();
+ }
+ }
+
+ String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
+ HashMap<String, HashMap<String, Member>> rzMap = new HashMap<String, HashMap<String, Member>>();
+
+ for (String member : memberNames) {
+ Member thisMember = new Member(member);
+ //String[] rz = thisMember.getRedundancyZone();
+ String sgName = thisMember.getRedundancyZone();
+
+ //for (String sgName : rz) {
+ HashMap<String, Member> rzMembers = rzMap.get(sgName);
+
+ if (rzMembers == null) {
+ rzMembers = new HashMap<String, Member>();
+ rzMap.put(sgName, rzMembers);
+ }
+
+ rzMembers.put(thisMember.getMember(), thisMember);
+ //}
+ }
+
+ for (int i = 0; i < gridDataFromUI.length - 1; i++) {
+ String sgName = gridDataFromUI[i][0];
+ String memName = gridDataFromUI[i][1];
+ Member m = rzMap.get(sgName).get(memName);
+
+ assertEquals(sgName, gridDataFromUI[i][0]);
+ assertEquals(memName, gridDataFromUI[i][1]);
+ assertEquals(m.getMember(), gridDataFromUI[i][2]);
+ assertEquals(m.getHost(), gridDataFromUI[i][3]);
+ String cupUsage = String.valueOf(m.getCpuUsage());
+ assertEquals(cupUsage, gridDataFromUI[i][5]);
+ }
+
+ }
+
+ public void validateTopologyGridData() {
+ List<WebElement> rzGridRows = driver.findElements(By.xpath("//table[@id='memberList']/tbody/tr"));
+ int rowsCount = rzGridRows.size();
+ String[][] gridDataFromUI = new String[rowsCount][8];
+
+ for (int j = 2, x = 0; j <= rzGridRows.size(); j++, x++) {
+ for (int i = 0; i <= 7; i++) {
+ gridDataFromUI[x][i] = driver.findElement(
+ By.xpath("//table[@id='memberList']/tbody/tr[" + j + "]/td[" + (i + 1) + "]")).getText();
+ }
+ }
+
+ String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
+ HashMap<String, Member> tpMap = new HashMap<String, Member>();
+
+ for (String member : memberNames) {
+ Member thisMember = new Member(member);
+ tpMap.put(thisMember.getMember(), thisMember);
+
+ }
+
+ for (int i = 0; i < gridDataFromUI.length - 1; i++) {
+
+ String memName = gridDataFromUI[i][0];
+ Member m = tpMap.get(memName);
+
+ assertEquals(m.getMember(), gridDataFromUI[i][0]);
+ assertEquals(m.getMember(), gridDataFromUI[i][1]);
+ assertEquals(m.getHost(), gridDataFromUI[i][2]);
+ String cupUsage = String.valueOf(m.getCpuUsage());
+ assertEquals(cupUsage, gridDataFromUI[i][5]);
+ }
+ }
+
+ public void validateDataPrespectiveGridData() {
+ List<WebElement> serverGridRows = driver.findElements(By.xpath("//table[@id='regionsList']/tbody/tr"));
+ int rowsCount = serverGridRows.size();
+ String[][] gridDataFromUI = new String[rowsCount][7];
+
+ for (int j = 2, x = 0; j <= serverGridRows.size(); j++, x++) {
+ for (int i = 0; i <= 6; i++) {
+ if (i < 5) {
+ gridDataFromUI[x][i] = driver.findElement(
+ By.xpath("//table[@id='regionsList']/tbody/tr[" + j + "]/td[" + (i + 1) + "]")).getText();
+ } else if (i == 5) {
+ gridDataFromUI[x][i] = driver.findElement(
+ By.xpath("//table[@id='regionsList']/tbody/tr[" + j + "]/td[" + (i + 4) + "]")).getText();
+ }
+ }
+ }
+
+ String[] regionNames = JMXProperties.getInstance().getProperty("regions").split(" ");
+ HashMap<String, Region> dataMap = new HashMap<String, Region>();
+
+ for (String region : regionNames) {
+ Region thisRegion = new Region(region);
+ dataMap.put(thisRegion.getName(), thisRegion);
+
+ }
+
+ for (int i = 0; i < gridDataFromUI.length - 1; i++) {
+ String memName = gridDataFromUI[i][0];
+ Region r = dataMap.get(memName);
+
+ assertEquals(r.getName(), gridDataFromUI[i][0]);
+ assertEquals(r.getRegionType(), gridDataFromUI[i][1]);
+
+ assertEquals(String.valueOf(r.getSystemRegionEntryCount()), gridDataFromUI[i][2]);
+ assertEquals(r.getFullPath(), gridDataFromUI[i][4]);
+ assertEquals(getPersistanceEnabled(r), gridDataFromUI[i][5]);
+ }
+ }
+
+ public void validateRegionDetailsGridData() {
+ List<WebElement> serverGridRows = driver.findElements(By.xpath("//table[@id='memberList']/tbody/tr"));
+ int rowsCount = serverGridRows.size();
+ String[][] gridDataFromUI = new String[rowsCount][7];
+
+ for (int j = 2, x = 0; j <= serverGridRows.size(); j++, x++) {
+ for (int i = 0; i < 2; i++) {
+ gridDataFromUI[x][i] = driver.findElement(
+ By.xpath("//table[@id='memberList']/tbody/tr[" + j + "]/td[" + (i + 1) + "]")).getText();
+ }
+ }
+
+ String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
+ HashMap<String, Member> tpMap = new HashMap<String, Member>();
+
+ for (String member : memberNames) {
+ Member thisMember = new Member(member);
+ tpMap.put(thisMember.getMember(), thisMember);
+ }
+
+ for (int i = 0; i < gridDataFromUI.length - 1; i++) {
+
+ String memName = gridDataFromUI[i][0];
+ Member m = tpMap.get(memName);
+ assertEquals(m.getMember(), gridDataFromUI[i][0]);
+ }
+
+ }
+
+ public void navigateToToplogyView(){
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingXpath(PulseTestLocators.TopologyView.radioButtonXpath);
+ }
+
+ public void navigateToServerGroupGView(){
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.radioButtonXpath);
+ }
+
+ public void navigateToRedundancyZoneView(){
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingXpath(PulseTestLocators.RedundancyZone.radioButtonXpath);
+ }
+
+ // ------ Topology / Server Group / Redundancy Group - Tree View
+
+ public void navigateToTopologyTreeView(){
+ navigateToToplogyView();
+ clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
+ }
+
+ public void navigateToServerGroupTreeView() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.radioButtonXpath);
+ }
+
+ public void navigateToRedundancyZonesTreeView() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingXpath(PulseTestLocators.RedundancyZone.radioButtonXpath);
+ }
+
+ // ------ Topology / Server Group / Redundancy Group - Grid View
+
+ public void navigateToTopologyGridView() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingXpath(PulseTestLocators.TopologyView.radioButtonXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
+ }
+
+ public void navigateToServerGroupGridView() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.radioButtonXpath);
+ clickElementUsingId(PulseTestLocators.ServerGroups.gridButtonId);
+ }
+
+ public void navigateToRedundancyZonesGridView() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingXpath(PulseTestLocators.RedundancyZone.radioButtonXpath);
+ clickElementUsingId(PulseTestLocators.RedundancyZone.gridButtonId);
+ }
+
+ // ----- Data perspective / region details
+
+ public void navigateToDataPrespectiveGridView() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingXpath(PulseTestLocators.DataPerspectiveView.downarrowButtonXpath);
+ clickElementUsingXpath(PulseTestLocators.DataPerspectiveView.dataViewButtonXpath);
+ clickElementUsingId(PulseTestLocators.DataPerspectiveView.gridButtonId);
+ }
+
+ public void navigateToRegionDetailsView() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingXpath(PulseTestLocators.DataPerspectiveView.downarrowButtonXpath);
+ clickElementUsingXpath(PulseTestLocators.DataPerspectiveView.dataViewButtonXpath);
+ // clickElementUsingXpath(PulseTestLocators.RegionDetailsView.regionNameXpath);
+ // // WIP - region navigation defect needs to fixed
+ clickElementUsingXpath(PulseTestLocators.RegionDetailsView.treeMapCanvasXpath);
+ }
+
+ public void navigateToRegionDetailsGridView() {
+ navigateToRegionDetailsView();
+ clickElementUsingXpath(PulseTestLocators.RegionDetailsView.gridButtonXpath);
+ }
+
+ public String getPropertyValue(String propertyKey) {
+ String propertyValue = JMXProperties.getInstance().getProperty(propertyKey);
+ return propertyValue;
+ }
+
+ public void verifyElementPresentById(String id) {
+ WebDriverWait wait = new WebDriverWait(driver, maxWaitTime, 500);
+ wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id(id)));
+ }
+
+ public void verifyElementPresentByLinkText(String lnkText) {
+ WebDriverWait wait = new WebDriverWait(driver, maxWaitTime, 500);
+ wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.linkText(lnkText)));
+ }
+
+ public void verifyElementPresentByXpath(String xpath) {
+ WebDriverWait wait = new WebDriverWait(driver, maxWaitTime, 500);
+ wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(xpath)));
+ }
+
+ public void verifyTextPresrntById(String id, String text) {
+ WebDriverWait wait = new WebDriverWait(driver, maxWaitTime, 500);
+ wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id(id), text));
+ }
+
+ public void verifyTextPresrntByXpath(String xpath, String text) {
+ WebDriverWait wait = new WebDriverWait(driver, maxWaitTime, 500);
+ wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(xpath), text));
+ }
+
+ public void verifyElementAttributeById(String id, String attribute, String value) {
+ String actualValue = findElementById(id).getAttribute(attribute);
+ assertTrue(actualValue.equals(value) || actualValue.contains(value));
+ }
+
+
+ public void mouseReleaseById(String id){
+ verifyElementPresentById(id);
+ Actions action = new Actions(driver);
+ WebElement we = driver.findElement(By.id(id));
+ action.moveToElement(we).release().perform();
+ }
+ public void mouseClickAndHoldOverElementById(String id) {
+ verifyElementPresentById(id);
+ Actions action = new Actions(driver);
+ WebElement we = driver.findElement(By.id(id));
+ action.moveToElement(we).clickAndHold().perform();
+ }
+
+ public void mouseOverElementByXpath(String xpath) {
+ Actions action = new Actions(driver);
+ WebElement we = driver.findElement(By.xpath(xpath));
+ action.moveToElement(we).build().perform();
+ }
+
+
+ public float stringToFloat(String stringValue){
+ float floatNum = Float.parseFloat(stringValue);
+ return floatNum;
+ }
+
+ public String floatToString(float floatValue){
+ String stringValue = Float.toString(floatValue);
+ return stringValue;
+ }
+
+
+ public String[] splitString(String stringToSplit, String splitDelimiter){
+ String [] stringArray = stringToSplit.split(splitDelimiter);
+ return stringArray;
+ }
+
+ public void assertMemberSortingByCpuUsage(){
+ Map<Double, String> memberMap = new TreeMap<>(Collections.reverseOrder());
+ String [] membersNames = splitString(JMXProperties.getInstance().getProperty("members"), " ");
+ for (String member : membersNames) {
+ Member thisMember = new Member(member);
+ memberMap.put(thisMember.getCpuUsage(), thisMember.getMember());
+ }
+ for(Map.Entry<Double,String> entry : memberMap.entrySet()) {
+ //here matching painting style to validation that the members are painted according to their cpu usage
+ String refMemberCPUUsage = null;
+ if(entry.getValue().equalsIgnoreCase("M1")){
+ refMemberCPUUsage = PulseTestData.Topology.cpuUsagePaintStyleM1;
+ }else if(entry.getValue().equalsIgnoreCase("M2")){
+ refMemberCPUUsage = PulseTestData.Topology.cpuUsagePaintStyleM2;
+ }else{
+ refMemberCPUUsage = PulseTestData.Topology.cpuUsagePaintStyleM3;
+ }
+ assertTrue(findElementById(entry.getValue()).getAttribute("style").contains(refMemberCPUUsage));
+ }
+ }
+
+ public void assertMemberSortingByHeapUsage(){
+ Map<Long, String> memberMap = new TreeMap<Long,String>(Collections.reverseOrder());
+ String [] membersNames = splitString(JMXProperties.getInstance().getProperty("members"), " ");
+ for (String member : membersNames) {
+ Member thisMember = new Member(member);
+ memberMap.put(thisMember.getCurrentHeapSize(), thisMember.getMember());
+ }
+ for(Map.Entry<Long, String> entry : memberMap.entrySet()) {
+ //here matching painting style to validation that the members are painted according to their cpu usage
+ String refMemberHeapUsage = null;
+ if(entry.getValue().equalsIgnoreCase("M1")){
+ refMemberHeapUsage = PulseTestData.Topology.heapUsagePaintStyleM1;
+ }else if(entry.getValue().equalsIgnoreCase("M2")){
+ refMemberHeapUsage = PulseTestData.Topology.heapUsagePaintStyleM2;
+ }else{
+ refMemberHeapUsage = PulseTestData.Topology.heapUsagePaintStyleM3;
+ }
+ assertTrue(findElementById(entry.getValue()).getAttribute("style").contains(refMemberHeapUsage));
+ }
+ }
+
+ public void assertMemberSortingBySGCpuUsage(){
+ Map<Double, String> memberMap = new TreeMap<>(Collections.reverseOrder());
+ String [] membersNames = splitString(JMXProperties.getInstance().getProperty("members"), " ");
+ for (String member : membersNames) {
+ Member thisMember = new Member(member);
+ memberMap.put(thisMember.getCpuUsage(), thisMember.getMember());
+ }
+ for(Map.Entry<Double,String> entry : memberMap.entrySet()) {
+ //here matching painting style to validation that the members are painted according to their cpu usage
+ String refMemberCPUUsage = null;
+ if(entry.getValue().equalsIgnoreCase("M1")){
+ refMemberCPUUsage = PulseTestData.Topology.cpuUsagePaintStyleM1;
+ }else if(entry.getValue().equalsIgnoreCase("M2")){
+ refMemberCPUUsage = PulseTestData.Topology.cpuUsagePaintStyleM2;
+ }else{
+ refMemberCPUUsage = PulseTestData.Topology.cpuUsagePaintStyleM3;
+ }
+ assertTrue(findElementById(entry.getValue()).getAttribute("style").contains(refMemberCPUUsage));
+ }
+ }
+
+
+ public void assertMemberSortingBySgHeapUsage(){
+ String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
+ HashMap<String, HashMap<String, Member>> sgMap = new HashMap<String, HashMap<String, Member>>();
+ for (String member : memberNames) {
+ Member thisMember = new Member(member);
+ String[] sgs = thisMember.getGroups();
+
+ for (String sgName : sgs) {
+ HashMap<String, Member> sgMembers = sgMap.get(sgName);
+ if (sgMembers == null) {
+ sgMembers = new HashMap<String, Member>();
+ sgMap.put(sgName, sgMembers);
+ }
+ sgMembers.put(thisMember.getMember(), thisMember);
+ }
+ }
+ Map<Float, String> memberMap = new TreeMap<Float,String>(Collections.reverseOrder());
+
+ for(int sgId=1; sgId<=3; sgId++){
+ String sgName = "SG1";
+ String memName = "M" + sgId;
+ Member m = sgMap.get(sgName).get(memName);
+ memberMap.put((float) m.getCurrentHeapSize(), m.getMember());
+ }
+
+ for(Map.Entry<Float,String> entry : memberMap.entrySet()) {
+ //here matching painting style to validation that the members are painted according to their cpu usage
+ String refMemberCPUUsage = null;
+ if(entry.getValue().equalsIgnoreCase("M1")){
+ refMemberCPUUsage = PulseTestData.ServerGroups.heapUsagePaintStyleSG1M1;
+ }else if(entry.getValue().equalsIgnoreCase("M2")){
+ refMemberCPUUsage = PulseTestData.ServerGroups.heapUsagePaintStyleSG1M2;
+ }else{
+ refMemberCPUUsage = PulseTestData.ServerGroups.heapUsagePaintStyleSG1M3;
+ }
+ assertTrue(findElementById("SG1(!)"+entry.getValue()).getAttribute("style").contains(refMemberCPUUsage));
+ }
+ }
+
+
+
+ public void assertMemberSortingBySgCpuUsage(){
+ String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
+ HashMap<String, HashMap<String, Member>> sgMap = new HashMap<String, HashMap<String, Member>>();
+ for (String member : memberNames) {
+ Member thisMember = new Member(member);
+ String[] sgs = thisMember.getGroups();
+
+ for (String sgName : sgs) {
+ HashMap<String, Member> sgMembers = sgMap.get(sgName);
+ if (sgMembers == null) {
+ sgMembers = new HashMap<String, Member>();
+ sgMap.put(sgName, sgMembers);
+ }
+ sgMembers.put(thisMember.getMember(), thisMember);
+ }
+ }
+ Map<Double, String> memberMap = new TreeMap<>(Collections.reverseOrder());
+ //SG3(!)M3
+ for(int sgId=1; sgId<=3; sgId++){
+ String sgName = "SG1";
+ String memName = "M" + sgId;
+ Member m = sgMap.get(sgName).get(memName);
+ memberMap.put(m.getCpuUsage(), m.getMember());
+ }
+
+ for(Map.Entry<Double,String> entry : memberMap.entrySet()) {
+ //here matching painting style to validation that the members are painted according to their cpu usage
+ String refMemberCPUUsage = null;
+ if(entry.getValue().equalsIgnoreCase("M1")){
+ refMemberCPUUsage = PulseTestData.ServerGroups.cpuUsagePaintStyleSG1M1;
+ }else if(entry.getValue().equalsIgnoreCase("M2")){
+ refMemberCPUUsage = PulseTestData.ServerGroups.cpuUsagePaintStyleSG1M2;
+ }else{
+ refMemberCPUUsage = PulseTestData.ServerGroups.cpuUsagePaintStyleSG1M3;
+ }
+ assertTrue(findElementById("SG1(!)"+entry.getValue()).getAttribute("style").contains(refMemberCPUUsage));
+ }
+ }
+
+ public void assertMemberSortingByRzHeapUsage(){
+ String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
+ HashMap<String, HashMap<String, Member>> rzMap = new HashMap<String, HashMap<String, Member>>();
+ for (String member : memberNames) {
+ Member thisMember = new Member(member);
+ String sgName = thisMember.getRedundancyZone();
+ HashMap<String, Member> rzMembers = rzMap.get(sgName);
+
+ if (rzMembers == null) {
+ rzMembers = new HashMap<String, Member>();
+ rzMap.put(sgName, rzMembers);
+ }
+
+ rzMembers.put(thisMember.getMember(), thisMember);
+ }
+ Map<Float, String> memberMap = new TreeMap<Float,String>(Collections.reverseOrder());
+ String rzName = "RZ1 RZ2";
+ String memName = "M1" ;
+ Member m = rzMap.get(rzName).get(memName);
+ memberMap.put((float) m.getCurrentHeapSize(), m.getMember());
+
+ for(Map.Entry<Float,String> entry : memberMap.entrySet()) {
+ //here matching painting style to validation that the members are painted according to their cpu usage
+ String refMemberHeapUsage = null;
+ if(entry.getValue().equalsIgnoreCase("M1")){
+ refMemberHeapUsage = PulseTestData.RedundancyZone.heapUsagePaintStyleRZ1RZ2M1;
+ }else if(entry.getValue().equalsIgnoreCase("M2")){
+ refMemberHeapUsage = PulseTestData.RedundancyZone.heapUsagePaintStyleRZ1RZ2M2;
+ }else{
+ refMemberHeapUsage = PulseTestData.RedundancyZone.heapUsagePaintStyleRZ3M3;
+ }
+ assertTrue(findElementById("RZ1 RZ2(!)"+entry.getValue()).getAttribute("style").contains(refMemberHeapUsage));
+ }
+ }
+
+ public void assertMemeberSortingByRzCpuUsage(){
+ String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
+ HashMap<String, HashMap<String, Member>> rzMap = new HashMap<String, HashMap<String, Member>>();
+ for (String member : memberNames) {
+ Member thisMember = new Member(member);
+ String sgName = thisMember.getRedundancyZone();
+ HashMap<String, Member> rzMembers = rzMap.get(sgName);
+
+ if (rzMembers == null) {
+ rzMembers = new HashMap<String, Member>();
+ rzMap.put(sgName, rzMembers);
+ }
+
+ rzMembers.put(thisMember.getMember(), thisMember);
+ }
+ Map<Double, String> memberMap = new TreeMap<>(Collections.reverseOrder());
+ String rzName = "RZ1 RZ2";
+ String memName = "M1" ;
+ Member m = rzMap.get(rzName).get(memName);
+ memberMap.put(m.getCpuUsage(), m.getMember());
+
+ for(Map.Entry<Double,String> entry : memberMap.entrySet()) {
+ //here matching painting style to validation that the members are painted according to their cpu usage
+ String refMemberCPUUsage = null;
+ if(entry.getValue().equalsIgnoreCase("M1")){
+ refMemberCPUUsage = PulseTestData.RedundancyZone.cpuUsagePaintStyleRZ1RZ2M1;
+ }else if(entry.getValue().equalsIgnoreCase("M2")){
+ refMemberCPUUsage = PulseTestData.RedundancyZone.cpuUsagePaintStyleRZ1RZ2M2;
+ }
+ assertTrue(findElementById("RZ1 RZ2(!)"+entry.getValue()).getAttribute("style").contains(refMemberCPUUsage));
+ }
+ }
+
+ public List<WebElement> getRegionsFromDataBrowser(){
+ List<WebElement> regionList = driver.findElements(By.xpath("//span[starts-with(@ID,'treeDemo_')][contains(@id,'_span')]"));
+ return regionList;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseNoAuthTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseNoAuthTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseNoAuthTest.java
new file mode 100644
index 0000000..e9765c5
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseNoAuthTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.tests;
+
+import org.apache.geode.test.junit.categories.UITest;
+import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
+import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
+
+@Category(UITest.class)
+@FixMethodOrder(MethodSorters.JVM)
+public class PulseNoAuthTest extends PulseAbstractTest {
+
+ @BeforeClass
+ public static void beforeClassSetup() throws Exception {
+ setUpServer("admin", "admin", null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestData.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestData.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestData.java
new file mode 100644
index 0000000..ca716fa
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestData.java
@@ -0,0 +1,106 @@
+/*
+ *
+ * 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.tests;
+
+public class PulseTestData {
+
+ public static class TopNavigation{
+
+ }
+
+ public static class ClusterStatus {
+
+ public static final String membersProperty = "members";
+ }
+ public static class Topology{
+ public static final String hotSpotHeapLbl = "Heap Usage";
+ public static final String hotSpotCPULbl = "CPU Usage";
+
+ public static final String cpuUsagePaintStyleM1 = "left: 497px; top: 0px;";
+ public static final String cpuUsagePaintStyleM2 = "left: 0px; top: 0px;";
+ public static final String cpuUsagePaintStyleM3 = "left: 265px; top: 0px;";
+
+ public static final String heapUsagePaintStyleM1 = "left: 0px; top: 0px;";
+ public static final String heapUsagePaintStyleM2 = "left: 559px; top: 0px;";
+ public static final String heapUsagePaintStyleM3 = "left: 280px; top: 0px;";
+ }
+
+ public static class ServerGroups{
+ public static final String hotSpotHeapLbl = "Heap Usage";
+ public static final String hotSpotCPULbl = "CPU Usage";
+
+ //Cpu Usage sorting
+// public static final String cpuUsagePaintStyleM1 = "left: 497px; top: 0px;";
+// public static final String cpuUsagePaintStyleM2 = "left: 0px; top: 0px;";
+// public static final String cpuUsagePaintStyleM3 = "left: 265px; top: 0px;";
+
+ public static final String cpuUsagePaintStyleSG1M1 = "left: 0px; top: 295px;";
+ public static final String cpuUsagePaintStyleSG1M2 = "left: 0px; top: 30px;";
+ public static final String cpuUsagePaintStyleSG1M3 = "left: 0px; top: 171px;";
+
+ public static final String cpuUsagePaintStyleSG2M1 = "left: 240px; top: 239px;";
+ public static final String cpuUsagePaintStyleSG2M2 = "left: 240px; top: 30px;";
+
+ public static final String cpuUsagePaintStyleSG3M3 = "left: 479px; top: 30px;";
+
+ //heap usage sorting
+ public static final String heapUsagePaintStyleSG1M1 = "left: 0px; top: 30px;";
+ public static final String heapUsagePaintStyleSG1M2 = "left: 152px; top: 179px;";
+ public static final String heapUsagePaintStyleSG1M3 = "left: 0px; top: 179px;";
+
+ public static final String heapUsagePaintStyleSG2M1 = "left: 240px; top: 30px;";
+ public static final String heapUsagePaintStyleSG2M2 = "left: 240px; top: 274px;";
+
+ public static final String heapUsagePaintStyleSG3M3 = "left: 479px; top: 30px;";
+ }
+
+ public static class RedundancyZone{
+
+ public static final String hotSpotHeapLbl = "Heap Usage";
+ public static final String hotSpotCPULbl = "CPU Usage";
+
+ public static final String heapUsagePaintStyleRZ1RZ2M1 = "left: 0px; top: 30px;";
+ public static final String heapUsagePaintStyleRZ1RZ2M2 = "left: 0px; top: 274px;";
+
+ public static final String heapUsagePaintStyleRZ3M3 = "left: 360px; top: 30px;";
+
+ public static final String cpuUsagePaintStyleRZ1RZ2M1 ="left: 0px; top: 239px;";
+ public static final String cpuUsagePaintStyleRZ1RZ2M2 ="left: 0px; top: 30px;";
+
+
+ }
+
+ public static class DataPerspectiveView {
+
+ }
+
+ public static class DataBrowser {
+ public static final String partialRgnName = "R";
+ public static final String chkRgnClassName = "bttn chk checkbox_true_full";
+ public static final String notChkRgnClassName = "bttn chk checkbox_false_full";
+
+ public static final String regName = "R1";
+ public static final String query1Text = "select * from /R1";
+
+ public static final String datePattern = "EEE, MMM dd yyyy, HH:mm:ss z";
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestLocators.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestLocators.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestLocators.java
new file mode 100644
index 0000000..d5ff5d4
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseTestLocators.java
@@ -0,0 +1,225 @@
+/*
+ *
+ * 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.tests;
+
+public class PulseTestLocators {
+ public static class HtmlAttributes{
+ public static final String classAttribute = "class";
+ public static final String typeAttribute = "type";
+ public static final String idAttribute = "id";
+ public static final String nameAttribute = "name";
+ public static final String placeholderAttribute = "placeholder";
+ public static final String valueAttribute = "value";
+ public static final String styleAttribute ="style";
+ }
+
+ public static class TopNavigation {
+ public static final String clusterViewLinkXpath = "//a[text()='Cluster View']";
+ }
+
+ public static class ClusterStatus {
+
+ }
+
+ public static class MemberDetailsView {
+ public static final String gridButtonXpath = "//a[@id='btngridIcon']";
+ }
+
+ public static class TopologyView {
+
+ public static final String radioButtonId = "radio-default";
+ public static final String radioButtonXpath = "//label[text()='Topology']";
+ public static final String gridButtonId = "default_grid_button";
+ public static final String nodeH1Id = "h1";
+ public static final String nodeH2Id = "h2";
+ public static final String nodeH3Id = "h3";
+ public static final String memberM1Id = "M1";
+ public static final String memberM2Id = "M2";
+ public static final String memberM3Id = "M3";
+ public static final String treeMapButtonId = "default_treemap_button";
+
+ // Host tootips
+ public static final String hostNameTTXpath = ".//*[@id='_tooltip']/div/div/div[1]";
+ public static final String cpuUsageTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[1]/div[2]/div";
+ public static final String memoryUsageTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[2]/div[2]/div";
+ public static final String loadAvgTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[3]/div[2]/div";
+ public static final String soketsTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[4]/div[2]/div";
+
+ // Member tooltips
+ public static final String memNameTTXpath = ".//*[@id='_tooltip']/div/div/div[1]";
+ public static final String memCpuUsageTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[1]/div[2]/div";
+ public static final String threadsTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[2]/div[2]/div/text()";
+ public static final String jvmPausesTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[3]/div[2]/div";
+ public static final String regionsTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[4]/div[2]/div";
+ public static final String clientsTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[5]/div[2]/div";
+ public static final String gatewaySenderTtXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[6]/div[2]/div";
+ public static final String portTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[7]/div[2]/div";
+
+ // Grid view
+ public static final String idM1Xpath = ".//*[@id='M1&M1']/td[1]";
+ public static final String nameM1Xpath = ".//*[@id='M1&M1']/td[2]";
+ public static final String hostH1Xpath = ".//*[@id='M1&M1']/td[3]";
+ public static final String idM2Xpath = ".//*[@id='M2&M2']/td[1]";
+ public static final String nameM2Xpath = ".//*[@id='M2&M2']/td[2]";
+ public static final String hostH2Xpath = ".//*[@id='M2&M2']/td[3]";
+ public static final String idM3Xpath = ".//*[@id='M3&M3']/td[1]";
+ public static final String nameM3Xpath = ".//*[@id='M3&M3']/td[2]";
+ public static final String hostH3Xpath = ".//*[@id='M3&M3']/td[3]";
+
+ // HotSpot locators
+ public static final String hotSpotId = "currentHotSpot";
+ public static final String hotspotListDivId = "hotspotList";
+ public static final String heapUsageXpath = "//a[text()='Heap Usage']";
+ public static final String cpuUsageXpath = "//a[text()='CPU Usage']";
+ public static final String graphTreeMapLblId = "//div[@id='GraphTreeMap-label']/child::node()";
+
+ }
+
+ public static class ServerGroups {
+
+ public static final String radioButtonId = "radio-servergroups";
+ public static final String radioButtonXpath = "//label[text()='Server Groups']";
+ public static final String gridButtonId = "servergroups_grid_button";
+ public static final String gridBlockId = "servergroups_grid_block";
+
+ public static final String serverGrpsRadioId = "member_view_option_servergroups";
+
+ public static final String serverGrpsRadioXpath = "//label[@for='radio-servergroups']";
+
+ public static final String serverGrp1Id = "SG1";
+ public static final String serverGrp2Id = "SG2";
+ public static final String serverGrp3Id = "SG3";
+
+ public static final String serverGrp1Xpath = ".//*[@id='SG1']/div";
+ public static final String serverGrp2Xpath = ".//*[@id='SG2']/div";
+ public static final String serverGrp3Xpath = ".//*[@id='SG3']/div";
+
+ public static final String sg1M1Id = "SG1(!)M1";
+ public static final String sg1M2Id = "SG1(!)M2";
+ public static final String sg1M3Id = "SG1(!)M3";
+ public static final String sg2M1Id = "SG2(!)M1";
+ public static final String sg2M2Id = "SG2(!)M2";
+ public static final String sg3M3Id = "SG3(!)M3";
+
+ // Grid view
+ public static final String idSG1M3Xpath = ".//*[@id='M3&M3']/td[2]";
+ public static final String idSG1M2Xpath = ".//*[@id='M2&M2']/td[2]";
+ public static final String idSG1M1Xpath = ".//*[@id='M1&M1']/td[2]";
+ public static final String nameM3Xpath = ".//*[@id='M3&M3']/td[3]";
+ public static final String nameM2Xpath = ".//*[@id='M2&M2']/td[3]";
+ public static final String nameM1Xpath = ".//*[@id='M1&M1']/td[3]";
+
+ //HotSpot locators
+ public static final String hotSpotId = "currentHotSpot";
+ public static final String hotspotListDivId= "hotspotList";
+ public static final String heapUsageXpath= "//a[text()='Heap Usage']";
+ public static final String cpuUsageXpath= "//a[text()='CPU Usage']";
+ public static final String graphTreeMapLblId = "//div[@id='GraphTreeMap-label']/child::node()";
+
+ }
+
+ public static class RedundancyZone {
+
+ public static final String radioButtonId = "radio-redundancyzones";
+ public static final String radioButtonXpathAlt = "//label[text()='Redundancy Zones']";
+ public static final String radioButtonXpath = "//label[@for='radio-redundancyzones']";
+
+ public static final String gridButtonId = "redundancyzones_grid_button";
+
+ public static final String zoneRZ1Id = "RZ1 RZ2";
+ public static final String zoneRZ2Id = "RZ2";
+
+
+ public static final String zoneRZ1RZ2Xpath = ".//*[@id='RZ1 RZ2']/div";
+ public static final String zoneRZ2Xpath = ".//*[@id='RZ2']/div";
+
+ public static final String m1RZ1RZ2Id = "RZ1 RZ2(!)M1";
+ public static final String m2RZ1Id = "RZ1 RZ2(!)M2";
+ public static final String m3RZ2Id = "RZ2(!)M3";
+// public static final String m3RZ2Id = "RZ2(!)M3";
+// public static final String m2RZ2Id = "RZ2(!)M2";
+ // Grid
+ public static final String idM2Xpath = ".//*[@id='M2&M2']/td[2]";
+ public static final String idM1Xpath = ".//*[@id='M1&M1']/td[2]";
+ public static final String idM3Xpath = ".//*[@id='M3&M3']/td[2]";
+
+ //HotSpot locators
+ public static final String hotSpotId = "currentHotSpot";
+ public static final String hotspotListDivId= "hotspotList";
+ public static final String heapUsageXpath= "//a[text()='Heap Usage']";
+ public static final String cpuUsageXpath= "//a[text()='CPU Usage']";
+ public static final String graphTreeMapLblId = "//div[@id='GraphTreeMap-label']/child::node()";
+ }
+
+ public static class DataPerspectiveView {
+ public static final String downarrowButtonXpath = "//a[text()='Members']";
+ public static final String dataViewButtonXpath = "//a[text()='Data']";
+ public static final String gridButtonId = "data_grid_button";
+ }
+
+ public static class RegionDetailsView {
+
+ public static final String regionNameDivId = "regionNameText";
+ public static final String regionPathId = "regionPath";
+ public static final String treeMapCanvasXpath = "//canvas[@id='GraphTreeMapClusterData-canvas']";
+ public static final String regionTypeId = "regionType";
+ public static final String regionMembersTextId = "regionMembersText";
+ public static final String regionEmptyNodesId = "regionEmptyNodes";
+ public static final String regionEntryCountTextId = "regionEntryCountText";
+ public static final String regionDiskUsageId = "regionDiskUsage";
+ public static final String regionPersistenceId = "regionPersistence";
+
+ public static final String gridButtonXpath = "//a[@id='btngridIcon']";
+ public static final String memoryUsedId = "memoryUsed";
+ public static final String totalMemoryId = "totalMemory";
+
+ public static final String inMemoryReadsId = "currentReadsPerSec";
+ public static final String inMemoryWritesId = "currentWritesPerSec";
+ public static final String diskReadsId = "currentDiskReadsPerSec";
+ public static final String diskWritesId = "currentDiskWritesPerSec";
+
+ public static final String memberNameId = "memberName";
+
+ }
+
+ public static class DataBrowser {
+ public static final String rgnFilterTxtBoxId = "filterTextRegion";
+ public static final String rgnNameSpanXpath = "//span[starts-with(@ID,'treeDemo_')][contains(@id,'_span')]";
+ public static final String rgnNameTxtBoxXpath = "//span[starts-with(@ID,'treeDemo_')][contains(@id,'_span')]";
+ public static final String rgnSpanFirstPart = "//span[@id='treeDemo_";
+ public static final String rgnSpanSecondPart = "_span']";
+ public static final String rgn1ChkBoxId = "treeDemo_1_check";
+ public static final String queryEditorTxtBoxId = "dataBrowserQueryText";
+ public static final String btnExecuteQueryId = "btnExecuteQuery";
+
+ public static final String divDataRegions = "//div/ul[@id='treeDemo']/li";
+
+ // History section
+ public static final String historyIcon = "historyIcon";
+ public static final String historyLst = "//div[@id='detailsHistoryList']/div/div";
+ public static final String queryText = ".wrapHistoryContent";
+ public static final String historyDateTime = ".dateTimeHistory";
+
+ //Clear button
+
+ public static final String btnClearXpath = "//input[@value='Clear']";
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Region.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Region.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Region.java
new file mode 100644
index 0000000..fd835c7
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Region.java
@@ -0,0 +1,187 @@
+/*
+ *
+ * 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.tests;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+
+public class Region extends JMXBaseBean implements RegionMBean {
+ private String name = null;
+
+ private static String[] regAttItemNames = { "compressionCodec",
+ "enableOffHeapMemory", "scope", "diskStoreName",
+ "diskSynchronous" };
+ private static String[] regAttItemDescriptions = { "compressionCodec",
+ "enableOffHeapMemory", "scope", "diskStoreName",
+ "diskSynchronous" };
+ private static OpenType[] regAttItemTypes = { SimpleType.STRING,
+ SimpleType.BOOLEAN, SimpleType.STRING,
+ SimpleType.STRING, SimpleType.BOOLEAN };
+ private static CompositeType listRegionAttributesCompData = null;
+
+ static {
+ try {
+ listRegionAttributesCompData = new CompositeType("listRegionAttributes",
+ "Regions attributes", regAttItemNames, regAttItemDescriptions,
+ regAttItemTypes);
+
+ } catch (OpenDataException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Region(String name) {
+ this.name = name;
+ }
+
+ protected String getKey(String propName) {
+ return "region." + name + "." + propName;
+ }
+
+ @Override
+ public String[] getMembers() {
+ return getStringArray("members");
+ }
+
+ @Override
+ public String getFullPath() {
+ return getString("fullPath");
+ }
+
+ @Override
+ public double getDiskReadsRate() {
+ return getDouble("diskReadsRate");
+ }
+
+ @Override
+ public double getDiskWritesRate() {
+ return getDouble("diskWritesRate");
+ }
+
+ @Override
+ public int getEmptyNodes() {
+ return getInt("emptyNodes");
+ }
+
+ @Override
+ public double getGetsRate() {
+ return getDouble("getsRate");
+ }
+
+ @Override
+ public double getLruEvictionRate() {
+ return getDouble("lruEvictionRate");
+ }
+
+ @Override
+ public double getPutsRate() {
+ return getDouble("putsRate");
+ }
+
+ @Override
+ public String getRegionType() {
+ return getString("regionType");
+ }
+
+ @Override
+ public long getEntrySize() {
+ return getLong("entrySize");
+ }
+
+ @Override
+ public long getSystemRegionEntryCount() {
+ return getLong("systemRegionEntryCount");
+ }
+
+ @Override
+ public int getMemberCount() {
+ return getInt("memberCount");
+ }
+
+ @Override
+ public boolean getPersistentEnabled() {
+ return getBoolean("persistentEnabled");
+ }
+
+ @Override
+ public String getName() {
+ return getString("name");
+ }
+
+ @Override
+ public boolean getGatewayEnabled() {
+ return getBoolean("gatewayEnabled");
+ }
+
+ @Override
+ public long getDiskUsage() {
+ return getLong("diskUsage");
+ }
+
+ @Override
+ public CompositeData listRegionAttributes() {
+ String value = JMXProperties.getInstance().getProperty(
+ getKey("listRegionAttributes"), "");
+ String[] itemValues = value.split(",");
+ Map<String, Object> itemValuesHM = new HashMap<String, Object>();
+
+ // compressionCodec
+ if (null != itemValues[0]) {
+ itemValuesHM.put(regAttItemNames[0], itemValues[0]);
+ }
+
+ // enableOffHeapMemory
+ if (null != itemValues[1]) {
+ itemValuesHM.put(regAttItemNames[1], Boolean.parseBoolean(itemValues[1]));
+ }
+
+ // scope
+ if (null != itemValues[3]) {
+ itemValuesHM.put(regAttItemNames[3], itemValues[3]);
+ }
+
+ // diskStoreName
+ if (null != itemValues[4]) {
+ itemValuesHM.put(regAttItemNames[4], itemValues[4]);
+ }
+
+ // diskSynchronous
+ if (null != itemValues[5]) {
+ itemValuesHM.put(regAttItemNames[5], Boolean.parseBoolean(itemValues[5]));
+ }
+
+ CompositeData lraCompData;
+ try {
+ lraCompData = new CompositeDataSupport(listRegionAttributesCompData,
+ itemValuesHM);
+ } catch (OpenDataException e) {
+ e.printStackTrace();
+ lraCompData = null;
+ }
+ return lraCompData;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionMBean.java
new file mode 100644
index 0000000..0ee8201
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionMBean.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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.tests;
+
+import javax.management.openmbean.CompositeData;
+
+public interface RegionMBean {
+ String OBJECT_NAME = "GemFire:service=Region,type=Distributed";
+
+ String[] getMembers();
+
+ String getFullPath();
+
+ double getDiskReadsRate();
+
+ double getDiskWritesRate();
+
+ int getEmptyNodes();
+
+ double getGetsRate();
+
+ double getLruEvictionRate();
+
+ double getPutsRate();
+
+ String getRegionType();
+
+ long getEntrySize();
+
+ long getSystemRegionEntryCount();
+
+ int getMemberCount();
+
+ boolean getPersistentEnabled();
+
+ String getName();
+
+ boolean getGatewayEnabled();
+
+ long getDiskUsage();
+
+ CompositeData listRegionAttributes();
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMember.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMember.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMember.java
new file mode 100644
index 0000000..86ba550
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMember.java
@@ -0,0 +1,95 @@
+/*
+ *
+ * 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.tests;
+
+/**
+ * Region on member mbean
+ *
+ *
+ *
+ */
+public class RegionOnMember extends JMXBaseBean implements RegionOnMemberMBean {
+ private String fullPath = null;
+ private String member = null;
+
+ public RegionOnMember(String fullPath, String member) {
+ this.fullPath = fullPath;
+ this.member = member;
+ }
+
+ @Override
+ protected String getKey(String propName) {
+ return "regionOnMember." + fullPath + "." + member + "." + propName;
+ }
+
+ @Override
+ public String getFullPath(){
+ return this.fullPath;
+ }
+
+ @Override
+ public String getMember(){
+ return this.member;
+ }
+
+ @Override
+ public String getName(){
+ return getString("name");
+ }
+
+ @Override
+ public String getRegionType(){
+ return getString("regionType");
+ }
+
+ @Override
+ public long getEntrySize(){
+ return getLong("entrySize");
+ }
+
+ @Override
+ public long getEntryCount(){
+ return getLong("entryCount");
+ }
+
+ @Override
+ public double getGetsRate(){
+ return getDouble("getsRate");
+ }
+
+ @Override
+ public double getPutsRate(){
+ return getDouble("putsRate");
+ }
+
+ @Override
+ public double getDiskReadsRate(){
+ return getDouble("diskGetsRate");
+ }
+
+ @Override
+ public double getDiskWritesRate(){
+ return getDouble("diskPutsRate");
+ }
+
+ @Override
+ public int getLocalMaxMemory(){
+ return getInt("localMaxMemory");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMemberMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMemberMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMemberMBean.java
new file mode 100644
index 0000000..5fac9da
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/RegionOnMemberMBean.java
@@ -0,0 +1,49 @@
+/*
+ *
+ * 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.tests;
+
+/**
+ * Region on members mbean
+ *
+ *
+ */
+public interface RegionOnMemberMBean {
+
+ String getName();
+
+ String getRegionType(); // Ideally should be an Enum
+
+ String getFullPath();
+
+ String getMember();
+
+ long getEntrySize();
+
+ long getEntryCount();
+
+ double getGetsRate();
+
+ double getPutsRate();
+
+ double getDiskReadsRate();
+
+ double getDiskWritesRate();
+
+ int getLocalMaxMemory();
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
new file mode 100644
index 0000000..20f5312
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Server.java
@@ -0,0 +1,247 @@
+/*
+ *
+ * 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.tests;
+
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnectorServer;
+import javax.management.remote.JMXConnectorServerFactory;
+import javax.management.remote.JMXServiceURL;
+
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.security.templates.SampleSecurityManager;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.mgt.DefaultSecurityManager;
+import org.apache.shiro.mgt.SecurityManager;
+import org.apache.shiro.realm.Realm;
+
+import org.apache.geode.internal.security.shiro.CustomAuthRealm;
+import org.apache.geode.internal.security.shiro.JMXShiroAuthenticator;
+import org.apache.geode.management.internal.security.AccessControlMBean;
+import org.apache.geode.management.internal.security.MBeanServerWrapper;
+import org.apache.geode.management.internal.security.ResourceConstants;
+
+public class Server {
+
+ private static final String DEFAULT_HOST = "127.0.0.1"; //"localhost"
+ private static final int DEFAULT_PORT = 9999;
+ private final JMXServiceURL url;
+ private MBeanServer mbs;
+ private JMXConnectorServer cs;
+ private String propFile = null;
+
+ public Server(int port, String properties, String jsonAuthFile) throws Exception {
+ this.propFile = properties;
+ mbs = ManagementFactory.getPlatformMBeanServer();
+ url = new JMXServiceURL(formJMXServiceURLString(DEFAULT_HOST, port));
+
+ // Load the beans first, otherwise we get access denied
+ loadMBeans();
+
+ if (jsonAuthFile != null) {
+ System.setProperty("spring.profiles.active", "pulse.authentication.gemfire");
+
+ Map<String, Object> env = new HashMap<String, Object>();
+
+ // set up Shiro Security Manager
+ Properties securityProperties = new Properties();
+ securityProperties.setProperty(SampleSecurityManager.SECURITY_JSON, jsonAuthFile);
+ Realm realm = new CustomAuthRealm(SampleSecurityManager.class.getName(), securityProperties);
+ SecurityManager securityManager = new DefaultSecurityManager(realm);
+ SecurityUtils.setSecurityManager(securityManager);
+
+ // register the AccessControll bean
+ AccessControlMBean acc = new AccessControlMBean();
+ ObjectName accessControlMBeanON = new ObjectName(ResourceConstants.OBJECT_NAME_ACCESSCONTROL);
+ MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
+ platformMBeanServer.registerMBean(acc, accessControlMBeanON);
+
+ // wire in the authenticator and authorizaton
+ JMXShiroAuthenticator interceptor = new JMXShiroAuthenticator();
+ env.put(JMXConnectorServer.AUTHENTICATOR, interceptor);
+ cs = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
+ cs.setMBeanServerForwarder(new MBeanServerWrapper());
+
+ //set up the AccessControlMXBean
+
+ } else {
+ System.setProperty("spring.profiles.active", "pulse.authentication.default");
+ cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
+ }
+
+ try {
+ java.rmi.registry.LocateRegistry.createRegistry(port);
+ System.out.println("RMI registry ready.");
+ } catch (Exception e) {
+ System.out.println("Exception starting RMI registry:");
+ e.printStackTrace();
+ }
+
+ cs.start();
+ }
+
+ private String formJMXServiceURLString(String host, int port) throws UnknownHostException {
+ String jmxSerURL = "";
+
+ InetAddress inetAddr = InetAddress.getByName(host);
+ if (inetAddr instanceof Inet4Address) {
+ // Create jmx service url for IPv4 address
+ jmxSerURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + port + "/jmxrmi";
+ } else if (inetAddr instanceof Inet6Address) {
+ // Create jmx service url for IPv6 address
+ jmxSerURL = "service:jmx:rmi://[" + host + "]/jndi/rmi://[" + host + "]:" + port + "/jmxrmi";
+ }
+
+ return jmxSerURL;
+ }
+
+ public void stop() {
+ try {
+ cs.stop();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private synchronized void loadMBeans() {
+ JMXProperties props = JMXProperties.getInstance();
+ try {
+ props.load(propFile);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ // Add servers
+ String[] servers = getArrayProperty(props, "servers");
+ for (String server : servers) {
+ try {
+ addServerMBean(server);
+ } catch (InstanceAlreadyExistsException e) {
+ e.printStackTrace();
+ } catch (MBeanRegistrationException e) {
+ e.printStackTrace();
+ } catch (NotCompliantMBeanException e) {
+ e.printStackTrace();
+ } catch (MalformedObjectNameException e) {
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ }
+ }
+
+ // Add members
+ String[] members = getArrayProperty(props, "members");
+ for (String m : members) {
+ try {
+ addMemberMBean(m);
+ } catch (InstanceAlreadyExistsException e) {
+ e.printStackTrace();
+ } catch (MBeanRegistrationException e) {
+ e.printStackTrace();
+ } catch (NotCompliantMBeanException e) {
+ e.printStackTrace();
+ } catch (MalformedObjectNameException e) {
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ }
+ }
+
+ // Add regions
+ String[] regions = getArrayProperty(props, "regions");
+ for (String reg : regions) {
+ try {
+ addRegionMBean(reg);
+ } catch (InstanceAlreadyExistsException e) {
+ e.printStackTrace();
+ } catch (MBeanRegistrationException e) {
+ e.printStackTrace();
+ } catch (NotCompliantMBeanException e) {
+ e.printStackTrace();
+ } catch (MalformedObjectNameException e) {
+ e.printStackTrace();
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private void addMemberMBean(
+ String m) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException, NullPointerException {
+ Member m1 = new Member(m);
+ mbs.registerMBean(m1, new ObjectName(Member.OBJECT_NAME + ",member=" + m));
+ }
+
+ // For GemFire XD
+ private void addGemFireXDMemberMBean(
+ String xdm) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException, NullPointerException {
+ GemFireXDMember xdmo = new GemFireXDMember(xdm);
+ mbs.registerMBean(xdmo, new ObjectName(GemFireXDMember.OBJECT_NAME + ",member=" + xdm));
+ }
+
+ private void addRegionMBean(
+ String reg) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException, NullPointerException {
+ Region regionObject = new Region(reg);
+ mbs.registerMBean(regionObject, new ObjectName(Region.OBJECT_NAME + ",name=/" + reg));
+
+ for (String member : regionObject.getMembers()) {
+ RegionOnMember regionOnMemberObject = new RegionOnMember(regionObject.getFullPath(), member);
+ mbs.registerMBean(regionOnMemberObject, new ObjectName(
+ PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_REGION + regionObject.getFullPath() + PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_MEMBER + member));
+ }
+ }
+
+ private void addServerMBean(
+ String server) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException, NullPointerException {
+ ServerObject so = new ServerObject(server);
+ mbs.registerMBean(so, new ObjectName(ServerObject.OBJECT_NAME));
+ }
+
+ private String[] getArrayProperty(JMXProperties props, String propName) {
+ String propVal = props.getProperty(propName, "");
+ return propVal.split(" ");
+ }
+
+ public static Server createServer(int port, String properties, String jsonAuthFile)
+ throws MalformedObjectNameException {
+ Server s = null;
+ try {
+ s = new Server(port, properties, jsonAuthFile);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ return s;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObject.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObject.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObject.java
new file mode 100644
index 0000000..adc1361
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObject.java
@@ -0,0 +1,267 @@
+/*
+ *
+ * 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.tests;
+
+import java.io.IOException;
+
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+public class ServerObject extends NotificationBroadcasterSupport implements
+ ServerObjectMBean {
+ private String name = null;
+
+ private TabularDataSupport wanInfo;
+ private static String[] itemNames = { "key", "value" };
+ private static String[] itemDescriptions = { "Key", "Value" };
+ private static OpenType[] itemTypes = { SimpleType.STRING, SimpleType.BOOLEAN };
+ private static CompositeType wanInfoType = null;
+
+ private static String[] indexNames = { "key" };
+ private static TabularType wanType = null;
+
+ static {
+ try {
+ wanInfoType = new CompositeType("wanInfo", "WAN Information", itemNames,
+ itemDescriptions, itemTypes);
+
+ wanType = new TabularType("wanInfo", "WAN Information", wanInfoType,
+ indexNames);
+
+ } catch (OpenDataException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public ServerObject(String name) {
+ this.name = name;
+ this.wanInfo = new TabularDataSupport(wanType);
+ }
+
+ private String getKey(String propName) {
+ return "server." + name + "." + propName;
+ }
+
+ @Override
+ public String[] listCacheServers() {
+ return JMXProperties.getInstance()
+ .getProperty(getKey("listCacheServers"), "").split(" ");
+ }
+
+ @Override
+ public String[] listServers() {
+ return JMXProperties.getInstance()
+ .getProperty(getKey("listServers"), "").split(" ");
+ }
+
+ @Override
+ public TabularData viewRemoteClusterStatus() {
+ wanInfo.clear();
+ String[] wan = JMXProperties.getInstance()
+ .getProperty(getKey("wanInfo"), "").split(" ");
+ int cnt = 0;
+ while (wan.length >= (cnt + 2)) {
+ try {
+ wanInfo.put(buildWanInfoType(new String(wan[cnt]),
+ Boolean.parseBoolean(wan[cnt + 1])));
+ } catch (OpenDataException e) {
+ e.printStackTrace();
+ }
+ cnt += 2;
+ }
+
+ return (TabularData) wanInfo.clone();
+ }
+
+ @Override
+ public int getMemberCount() {
+ return Integer.parseInt(JMXProperties.getInstance().getProperty(
+ getKey("memberCount")));
+ }
+
+ @Override
+ public int getNumClients() {
+ return Integer.parseInt(JMXProperties.getInstance().getProperty(
+ getKey("numClients")));
+ }
+
+ @Override
+ public int getDistributedSystemId() {
+ return Integer.parseInt(JMXProperties.getInstance().getProperty(
+ getKey("distributedSystemId")));
+ }
+
+ @Override
+ public int getLocatorCount() {
+ return Integer.parseInt(JMXProperties.getInstance().getProperty(
+ getKey("locatorCount")));
+ }
+
+ @Override
+ public int getTotalRegionCount() {
+ return Integer.parseInt(JMXProperties.getInstance().getProperty(
+ getKey("totalRegionCount")));
+ }
+
+ @Override
+ public int getNumRunningFunctions() {
+ return Integer.parseInt(JMXProperties.getInstance().getProperty(
+ getKey("numRunningFunctions")));
+ }
+
+ @Override
+ public long getRegisteredCQCount() {
+ return Long.parseLong(JMXProperties.getInstance().getProperty(
+ getKey("registeredCQCount")));
+ }
+
+ @Override
+ public int getNumSubscriptions() {
+ return Integer.parseInt(JMXProperties.getInstance().getProperty(
+ getKey("numSubscriptions")));
+ }
+
+ // For SQLFire/GemFireXD
+ @Override
+ public int getTransactionCommitted() {
+ return Integer.parseInt(JMXProperties.getInstance().getProperty(
+ getKey("TransactionCommitted")));
+ }
+
+ // For SQLFire/GemFireXD
+ @Override
+ public int getTransactionRolledBack() {
+ return Integer.parseInt(JMXProperties.getInstance().getProperty(
+ getKey("TransactionRolledBack")));
+ }
+
+ @Override
+ public long getTotalHeapSize() {
+ return Long.parseLong(JMXProperties.getInstance().getProperty(
+ getKey("totalHeapSize")));
+ }
+
+ @Override
+ public long getUsedHeapSize() {
+ return Long.parseLong(JMXProperties.getInstance().getProperty(
+ getKey("usedHeapSize")));
+ }
+
+ @Override
+ public long getMaxMemory() {
+ return Long.parseLong(JMXProperties.getInstance().getProperty(
+ getKey("MaxMemory")));
+ }
+
+ @Override
+ public long getUsedMemory() {
+ return Long.parseLong(JMXProperties.getInstance().getProperty(
+ getKey("UsedMemory")));
+ }
+
+ @Override
+ public long getTotalRegionEntryCount() {
+ return Long.parseLong(JMXProperties.getInstance().getProperty(
+ getKey("totalRegionEntryCount")));
+ }
+
+ @Override
+ public int getCurrentQueryCount() {
+ return Integer.parseInt(JMXProperties.getInstance().getProperty(
+ getKey("currentQueryCount")));
+ }
+
+ @Override
+ public long getTotalDiskUsage() {
+ return Long.parseLong(JMXProperties.getInstance().getProperty(
+ getKey("totalDiskUsage")));
+ }
+
+ @Override
+ public double getDiskWritesRate() {
+ return Double.parseDouble(JMXProperties.getInstance().getProperty(
+ getKey("diskWritesRate")));
+ }
+
+ @Override
+ public double getAverageWrites() {
+ String val = JMXProperties.getInstance().getProperty(getKey("averageWrites"), "");
+ double ret = Double.parseDouble(val);
+ return ret;
+// return Double.parseDouble(JMXProperties.getInstance().getProperty(
+// getKey("averageWrites"), ""));
+ }
+
+ @Override
+ public double getAverageReads() {
+ return Double.parseDouble(JMXProperties.getInstance().getProperty(
+ getKey("averageReads"), ""));
+ }
+
+ @Override
+ public double getQueryRequestRate() {
+ return Double.parseDouble(JMXProperties.getInstance().getProperty(
+ getKey("queryRequestRate"), ""));
+ }
+
+ @Override
+ public double getDiskReadsRate() {
+ return Double.parseDouble(JMXProperties.getInstance().getProperty(
+ getKey("diskReadsRate"), ""));
+ }
+
+ @Override
+ public long getJVMPauses() {
+ return Long.parseLong(JMXProperties.getInstance().getProperty(
+ getKey("jvmPauses"), ""));
+ }
+
+ private CompositeData buildWanInfoType(String key, Boolean state)
+ throws OpenDataException {
+ Object[] itemValues = { key, state };
+ CompositeData result = new CompositeDataSupport(wanInfoType, itemNames,
+ itemValues);
+
+ return result;
+ }
+
+ @Override
+ public String queryData(String p0, String p1, int p2) {
+ // p0 : query
+ // p1 : comma separated members
+ // p2 : limit
+
+ DataBrowserResultLoader dbrLoader = DataBrowserResultLoader.getInstance();
+
+ try {
+ return dbrLoader.load(p0);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return e.getMessage();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObjectMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObjectMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObjectMBean.java
new file mode 100644
index 0000000..8f1bc54
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/ServerObjectMBean.java
@@ -0,0 +1,79 @@
+/*
+ *
+ * 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.tests;
+
+import javax.management.openmbean.TabularData;
+
+public interface ServerObjectMBean {
+ String OBJECT_NAME = "GemFire:service=System,type=Distributed";
+
+ TabularData viewRemoteClusterStatus();
+
+ int getMemberCount();
+
+ int getNumClients();
+
+ int getDistributedSystemId();
+
+ int getLocatorCount();
+
+ int getTotalRegionCount();
+
+ int getNumRunningFunctions();
+
+ long getRegisteredCQCount();
+
+ int getNumSubscriptions();
+
+ int getTransactionCommitted();
+
+ int getTransactionRolledBack();
+
+ long getTotalHeapSize();
+
+ long getUsedHeapSize();
+
+ long getMaxMemory();
+
+ long getUsedMemory();
+
+ long getTotalRegionEntryCount();
+
+ int getCurrentQueryCount();
+
+ long getTotalDiskUsage();
+
+ double getDiskWritesRate();
+
+ double getAverageWrites();
+
+ double getAverageReads();
+
+ double getQueryRequestRate();
+
+ double getDiskReadsRate();
+
+ long getJVMPauses();
+
+ String[] listCacheServers();
+
+ String[] listServers();
+
+ String queryData(String p0, String p1, int p2);
+}
[19/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JMXDataUpdater.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JMXDataUpdater.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JMXDataUpdater.java
new file mode 100644
index 0000000..41374d8
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JMXDataUpdater.java
@@ -0,0 +1,2392 @@
+/*
+ *
+ * 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.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
+import com.vmware.geode.tools.pulse.internal.data.JmxManagerFinder.JmxManagerInfo;
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
+import javax.management.InvalidAttributeValueException;
+import javax.management.MBeanException;
+import javax.management.MBeanServerConnection;
+import javax.management.MalformedObjectNameException;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+import javax.rmi.ssl.SslRMIClientSocketFactory;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.management.ManagementFactory;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+/**
+ * Class JMXDataUpdater Class used for creating JMX connection and getting all
+ * the required MBeans
+ *
+ *
+ * @since GemFire version 7.0.Beta 2012-09-23
+ */
+public class JMXDataUpdater implements IClusterUpdater, NotificationListener {
+
+ private final PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+ private final ResourceBundle resourceBundle = Repository.get()
+ .getResourceBundle();
+
+ private JMXConnector conn = null;
+ private MBeanServerConnection mbs;
+ private final String serverName;
+ private final String port;
+ private final String userName;
+ private final String userPassword;
+ private Boolean isAddedNotiListner = false;
+ private final Cluster cluster;
+
+ // MBean object names
+ private ObjectName MBEAN_OBJECT_NAME_SYSTEM_DISTRIBUTED;
+ private ObjectName MBEAN_OBJECT_NAME_REGION_DISTRIBUTED;
+ private ObjectName MBEAN_OBJECT_NAME_MEMBER;
+ private ObjectName MBEAN_OBJECT_NAME_MEMBER_MANAGER;
+ private ObjectName MBEAN_OBJECT_NAME_STATEMENT_DISTRIBUTED;
+ private ObjectName MBEAN_OBJECT_NAME_TABLE_AGGREGATE;
+
+ private Set<ObjectName> systemMBeans = null;
+
+ private final String opSignature[] = { String.class.getName(),
+ String.class.getName(), int.class.getName() };
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ /**
+ * constructor used for creating JMX connection
+ */
+ public JMXDataUpdater(String server, String port, Cluster cluster) {
+ this.serverName = server;
+ this.port = port;
+ this.userName = cluster.getJmxUserName();
+ this.userPassword = cluster.getJmxUserPassword();
+ this.cluster = cluster;
+
+ try {
+ // Initialize MBean object names
+ this.MBEAN_OBJECT_NAME_SYSTEM_DISTRIBUTED = new ObjectName(
+ PulseConstants.OBJECT_NAME_SYSTEM_DISTRIBUTED);
+ this.MBEAN_OBJECT_NAME_REGION_DISTRIBUTED = new ObjectName(
+ PulseConstants.OBJECT_NAME_REGION_DISTRIBUTED);
+ this.MBEAN_OBJECT_NAME_MEMBER_MANAGER = new ObjectName(
+ PulseConstants.OBJECT_NAME_MEMBER_MANAGER);
+ this.MBEAN_OBJECT_NAME_MEMBER = new ObjectName(
+ PulseConstants.OBJECT_NAME_MEMBER);
+ this.MBEAN_OBJECT_NAME_STATEMENT_DISTRIBUTED = new ObjectName(
+ PulseConstants.OBJECT_NAME_STATEMENT_DISTRIBUTED);
+
+ // For SQLFire
+ if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController
+ .getPulseProductSupport())) {
+ this.MBEAN_OBJECT_NAME_TABLE_AGGREGATE = new ObjectName(
+ PulseConstants.OBJECT_NAME_TABLE_AGGREGATE);
+ }
+
+ } catch (MalformedObjectNameException e) {
+ if (LOGGER.severeEnabled()) {
+ LOGGER.severe(e.getMessage(), e);
+ }
+ } catch (NullPointerException e) {
+ if (LOGGER.severeEnabled()) {
+ LOGGER.severe(e.getMessage(), e);
+ }
+ }
+
+ }
+
+ private JmxManagerInfo getManagerInfoFromLocator(Repository repository) {
+
+ try {
+ String locatorHost = repository.getJmxHost();
+ int locatorPort = Integer.parseInt(repository.getJmxPort());
+
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_HOST") + " : " + locatorHost + " & "
+ + resourceBundle.getString("LOG_MSG_PORT") + " : " + locatorPort);
+ }
+
+ InetAddress inetAddr = InetAddress.getByName(locatorHost);
+
+ if ((inetAddr instanceof Inet4Address) || (inetAddr instanceof Inet6Address)) {
+
+ if (inetAddr instanceof Inet4Address) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_LOCATOR_IPV4_ADDRESS") + " - " + inetAddr.toString());
+ }
+ } else {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_LOCATOR_IPV6_ADDRESS") + " - " + inetAddr.toString());
+ }
+ }
+
+ JmxManagerInfo jmxManagerInfo = JmxManagerFinder.askLocatorForJmxManager(inetAddr, locatorPort, 15000,
+ repository.isUseSSLLocator());
+
+ if (jmxManagerInfo.port == 0) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_LOCATOR_COULD_NOT_FIND_MANAGER"));
+ }
+ }
+ return jmxManagerInfo;
+ } else {
+ // Locator has Invalid locator Address
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_LOCATOR_BAD_ADDRESS"));
+ }
+ cluster.setConnectionErrorMsg(resourceBundle.getString("LOG_MSG_JMX_CONNECTION_BAD_ADDRESS"));
+ // update message to display on UI
+ cluster.setConnectionErrorMsg(resourceBundle
+ .getString("LOG_MSG_JMX_CONNECTION_BAD_ADDRESS"));
+ return null;
+ }
+ } catch (IOException e) {
+ StringWriter swBuffer = new StringWriter();
+ PrintWriter prtWriter = new PrintWriter(swBuffer);
+ e.printStackTrace(prtWriter);
+ LOGGER.severe("Exception Details : " + swBuffer.toString() + "\n");
+ }
+ return null;
+ }
+
+ /**
+ * Default connection is Pulse which uses configured userName and password
+ */
+ public JMXConnector getJMXConnection() {
+ return getJMXConnection(true);
+ }
+
+ /**
+ * Get connection for given userName and password. This is used for DataBrowser
+ * queries which has to be fired using credentials provided at pulse login page
+ */
+ public JMXConnector getJMXConnection(final boolean registerURL) {
+ JMXConnector connection = null;
+ // Reference to repository
+ Repository repository = Repository.get();
+ try {
+
+ String jmxSerURL = "";
+
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_USE_LOCATOR_VALUE") + ":"
+ + repository.getJmxUseLocator());
+ }
+
+ if (repository.getJmxUseLocator()) {
+ JmxManagerInfo jmxManagerInfo = getManagerInfoFromLocator(repository);
+
+ if (jmxManagerInfo.port == 0) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_LOCATOR_COULD_NOT_FIND_MANAGER"));
+ }
+ } else {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_LOCATOR_FOUND_MANAGER")
+ + " : "
+ + resourceBundle.getString("LOG_MSG_HOST")
+ + " : "
+ + jmxManagerInfo.host
+ + " & "
+ + resourceBundle.getString("LOG_MSG_PORT")
+ + " : "
+ + jmxManagerInfo.port
+ + (jmxManagerInfo.ssl ? resourceBundle
+ .getString("LOG_MSG_WITH_SSL") : resourceBundle
+ .getString("LOG_MSG_WITHOUT_SSL")));
+ }
+
+ jmxSerURL = formJMXServiceURLString(jmxManagerInfo.host,
+ String.valueOf(jmxManagerInfo.port));
+ }
+ } else {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_HOST") + " : "
+ + this.serverName + " & "
+ + resourceBundle.getString("LOG_MSG_PORT") + " : " + this.port);
+ }
+ jmxSerURL = formJMXServiceURLString(this.serverName, this.port);
+ }
+
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(jmxSerURL)) {
+ JMXServiceURL url = new JMXServiceURL(jmxSerURL);
+ String[] creds = { this.userName, this.userPassword };
+ Map<String, Object> env = new HashMap<String, Object>();
+ env.put(JMXConnector.CREDENTIALS, creds);
+
+ if (repository.isUseSSLManager()) {
+ // use ssl to connect
+ env.put("com.sun.jndi.rmi.factory.socket",
+ new SslRMIClientSocketFactory());
+ }
+ LOGGER.info("Connecting to jmxURL : " + jmxSerURL);
+ connection = JMXConnectorFactory.connect(url, env);
+
+ // Register Pulse URL if not already present in the JMX Manager
+ if(registerURL)
+ registerPulseUrlToManager(connection);
+ }
+ } catch (Exception e) {
+ if (e instanceof UnknownHostException) {
+ cluster.setConnectionErrorMsg(resourceBundle
+ .getString("LOG_MSG_JMX_CONNECTION_UNKNOWN_HOST"));
+ }
+
+ StringWriter swBuffer = new StringWriter();
+ PrintWriter prtWriter = new PrintWriter(swBuffer);
+ e.printStackTrace(prtWriter);
+ LOGGER.severe("Exception Details : " + swBuffer.toString() + "\n");
+ if (this.conn != null) {
+ try {
+ this.conn.close();
+ } catch (Exception e1) {
+ LOGGER.severe("Error closing JMX connection " + swBuffer.toString()
+ + "\n");
+ }
+ this.conn = null;
+ }
+ }
+ return connection;
+ }
+
+ private String formJMXServiceURLString(String host, String port)
+ throws UnknownHostException {
+ /*
+ * String jmxSerURL = "service:jmx:rmi://" + serverName + "/jndi/rmi://" +
+ * serverName + ":" + port + "/jmxrmi";
+ */
+ String jmxSerURL = "";
+ if (host.equalsIgnoreCase("localhost")) {
+ // Create jmx service url for 'localhost'
+ jmxSerURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":"
+ + port + "/jmxrmi";
+ } else {
+ InetAddress inetAddr = InetAddress.getByName(host);
+ if (inetAddr instanceof Inet4Address) {
+ // Create jmx service url for IPv4 address
+ jmxSerURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":"
+ + port + "/jmxrmi";
+ } else if (inetAddr instanceof Inet6Address) {
+ // Create jmx service url for IPv6 address
+ jmxSerURL = "service:jmx:rmi://[" + host + "]/jndi/rmi://[" + host + "]:"
+ + port + "/jmxrmi";
+ }
+ }
+
+ return jmxSerURL;
+ }
+
+ // Method registers Pulse URL if not already present in the JMX Manager
+ private void registerPulseUrlToManager(JMXConnector connection)
+ throws IOException, AttributeNotFoundException,
+ InstanceNotFoundException, MBeanException, ReflectionException,
+ MalformedObjectNameException, InvalidAttributeValueException {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_REGISTERING_APP_URL_TO_MANAGER"));
+ }
+
+ // Reference to repository
+ Repository repository = Repository.get();
+
+ // Register Pulse URL if not already present in the JMX Manager
+ if (connection != null) {
+ MBeanServerConnection mbsc = connection.getMBeanServerConnection();
+
+ Set<ObjectName> mbeans = mbsc.queryNames(
+ this.MBEAN_OBJECT_NAME_MEMBER_MANAGER, null);
+
+ for (ObjectName mbeanName : mbeans) {
+ String presentUrl = (String) mbsc.getAttribute(mbeanName,
+ PulseConstants.MBEAN_MANAGER_ATTRIBUTE_PULSEURL);
+ String pulseWebAppUrl = repository.getPulseWebAppUrl();
+ if (pulseWebAppUrl != null
+ && (presentUrl == null || !pulseWebAppUrl.equals(presentUrl))) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine(resourceBundle
+ .getString("LOG_MSG_SETTING_APP_URL_TO_MANAGER"));
+ }
+ Attribute pulseUrlAttr = new Attribute(
+ PulseConstants.MBEAN_MANAGER_ATTRIBUTE_PULSEURL, pulseWebAppUrl);
+ mbsc.setAttribute(mbeanName, pulseUrlAttr);
+ } else {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine(resourceBundle
+ .getString("LOG_MSG_APP_URL_ALREADY_PRESENT_IN_MANAGER"));
+ }
+ }
+ }
+ }
+ }
+
+ private boolean isConnected() {
+ // Reference to repository
+ Repository repository = Repository.get();
+ if (repository.getIsEmbeddedMode()) {
+ if (this.mbs == null) {
+ this.mbs = ManagementFactory.getPlatformMBeanServer();
+ cluster.setConnectedFlag(true);
+ }
+ } else {
+ try {
+ if (this.conn == null) {
+ cluster.setConnectedFlag(false);
+ cluster.setConnectionErrorMsg(resourceBundle
+ .getString("LOG_MSG_JMX_CONNECTION_NOT_FOUND")
+ + " "
+ + resourceBundle.getString("LOG_MSG_JMX_GETTING_NEW_CONNECTION"));
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine(resourceBundle
+ .getString("LOG_MSG_JMX_CONNECTION_NOT_FOUND")
+ + " "
+ + resourceBundle.getString("LOG_MSG_JMX_GET_NEW_CONNECTION"));
+ }
+ this.conn = getJMXConnection();
+ if (this.conn != null) {
+ this.mbs = this.conn.getMBeanServerConnection();
+ cluster.setConnectedFlag(true);
+ } else {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_JMX_CONNECTION_NOT_FOUND"));
+ }
+ return false;
+ }
+ } else {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine(resourceBundle
+ .getString("LOG_MSG_JMX_CONNECTION_IS_AVAILABLE"));
+ }
+ cluster.setConnectedFlag(true);
+ if (this.mbs == null) {
+ this.mbs = this.conn.getMBeanServerConnection();
+ }
+ }
+ } catch (Exception e) {
+ this.mbs = null;
+ if (this.conn != null) {
+ try {
+ this.conn.close();
+ } catch (Exception e1) {
+ LOGGER.severe(e);
+ }
+ }
+ this.conn = null;
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * function used for updating Cluster Data.
+ */
+ @Override
+ public boolean updateData() {
+ try {
+ if (!this.isConnected()) {
+ return false;
+ }
+
+ // deleted Members
+ cluster.getDeletedMembers().clear();
+ for (Entry<String, Cluster.Member> memberSet : cluster.getMembersHMap()
+ .entrySet()) {
+ cluster.getDeletedMembers().add(memberSet.getKey());
+ }
+
+ // Deleted Regions
+ cluster.getDeletedRegions().clear();
+ for (Cluster.Region region : cluster.getClusterRegions().values()) {
+ cluster.getDeletedRegions().add(region.getFullPath());
+ }
+
+ // try {
+
+ // Cluster
+ this.systemMBeans = this.mbs.queryNames(
+ this.MBEAN_OBJECT_NAME_SYSTEM_DISTRIBUTED, null);
+ for (ObjectName sysMBean : this.systemMBeans) {
+ updateClusterSystem(sysMBean);
+ }
+
+ // Cluster Regions/Tables
+ Set<ObjectName> regionMBeans = this.mbs.queryNames(
+ this.MBEAN_OBJECT_NAME_REGION_DISTRIBUTED, null);
+
+ Set<ObjectName> tableMBeans = this.mbs.queryNames(
+ this.MBEAN_OBJECT_NAME_TABLE_AGGREGATE, null);
+
+ if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController
+ .getPulseProductSupport())) {
+ // For SQLfire
+ for (ObjectName tableMBean : tableMBeans) {
+ String regNameFromTable = StringUtils
+ .getRegionNameFromTableName(tableMBean.getKeyProperty("table"));
+ for (ObjectName regionMBean : regionMBeans) {
+ String regionName = regionMBean.getKeyProperty("name");
+ if (regNameFromTable.equals(regionName)) {
+ updateClusterRegion(regionMBean);
+ // Increment cluster region count
+ cluster.setTotalRegionCount(cluster.getTotalRegionCount() + 1);
+ break;
+ }
+ }
+ }
+ } else {
+ // For Gemfire
+ for (ObjectName regMBean : regionMBeans) {
+ updateClusterRegion(regMBean);
+ }
+ }
+
+ // Remove deleted regions from cluster's regions list
+ for (Iterator<String> it = cluster.getDeletedRegions().iterator(); it
+ .hasNext();) {
+ cluster.removeClusterRegion(it.next());
+ }
+
+ // Cluster Members
+ Set<ObjectName> memberMBeans = this.mbs.queryNames(
+ this.MBEAN_OBJECT_NAME_MEMBER, null);
+ for (ObjectName memMBean : memberMBeans) {
+ String service = memMBean.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_SERVICE);
+ if(service==null){
+ // Cluster Member
+ updateClusterMember(memMBean);
+ }
+ else {
+ switch (service) {
+ case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_REGION:
+ if (PulseConstants.PRODUCT_NAME_SQLFIRE
+ .equalsIgnoreCase(PulseController.getPulseProductSupport())) {
+ // For SQLfire
+ for (ObjectName tableMBean : tableMBeans) {
+ String regNameFromTable = StringUtils
+ .getRegionNameFromTableName(tableMBean
+ .getKeyProperty("table"));
+ String regionName = memMBean.getKeyProperty("name");
+ if (regNameFromTable.equals(regionName)) {
+ updateMemberRegion(memMBean);
+ break;
+ }
+ }
+ } else {
+ // For Gemfire
+ updateMemberRegion(memMBean);
+ }
+ break;
+ case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_CACHESERVER:
+ updateMemberClient(memMBean);
+ break;
+ case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_GATEWAYRECEIVER:
+ updateGatewayReceiver(memMBean);
+ break;
+ case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_GATEWAYSENDER:
+ updateGatewaySender(memMBean);
+ break;
+ case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_ASYNCEVENTQUEUE:
+ updateAsyncEventQueue(memMBean);
+ break;
+ case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_LOCATOR:
+ updateClusterMember(memMBean);
+ break;
+ }
+ }
+ }
+
+ // Cluster Query Statistics
+ Set<ObjectName> statementObjectNames = this.mbs.queryNames(
+ this.MBEAN_OBJECT_NAME_STATEMENT_DISTRIBUTED, null);
+ //LOGGER.info("statementObjectNames = " + statementObjectNames);
+ for (ObjectName stmtObjectName : statementObjectNames) {
+ //LOGGER.info("stmtObjectName = " + stmtObjectName);
+ updateClusterStatement(stmtObjectName);
+ }
+ } catch (IOException ioe) {
+
+ // write errors
+ StringWriter swBuffer = new StringWriter();
+ PrintWriter prtWriter = new PrintWriter(swBuffer);
+ ioe.printStackTrace(prtWriter);
+ LOGGER.severe("IOException Details : " + swBuffer.toString() + "\n");
+ this.mbs = null;
+ if (this.conn != null) {
+ try {
+ this.conn.close();
+ } catch (IOException e1) {
+ LOGGER.severe("Error closing JMX connection " + swBuffer.toString()
+ + "\n");
+ }
+ }
+
+ return false;
+ }
+
+ // If there were members deleted, remove them from the membersList &
+ // physicalToMember.
+ Iterator<String> iterator = cluster.getDeletedMembers().iterator();
+ while (iterator.hasNext()) {
+ String memberKey = iterator.next();
+ if (cluster.getMembersHMap().containsKey(memberKey)) {
+ Cluster.Member member = cluster.getMembersHMap().get(memberKey);
+ List<Cluster.Member> memberArrList = cluster.getPhysicalToMember().get(
+ member.getHost());
+ if (memberArrList != null) {
+ if (memberArrList.contains(member)) {
+ String host = member.getHost();
+ cluster.getPhysicalToMember().get(member.getHost()).remove(member);
+
+ if (cluster.getPhysicalToMember().get(member.getHost()).size() == 0) {
+ cluster.getPhysicalToMember().remove(host);
+ }
+ }
+ }
+ cluster.getMembersHMap().remove(memberKey);
+ }
+
+ }
+
+ return true;
+ }
+
+ /**
+ * function used to get attribute values of Cluster System and map them to
+ * cluster vo
+ *
+ * @param mbeanName
+ * Cluster System MBean
+ * @throws IOException
+ *
+ */
+ private void updateClusterSystem(ObjectName mbeanName) throws IOException {
+ try {
+ if (!this.isAddedNotiListner) {
+ this.mbs.addNotificationListener(mbeanName, this, null, new Object());
+ this.isAddedNotiListner = true;
+ }
+
+ if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController
+ .getPulseProductSupport())) {
+ // Reset to zero
+ cluster.setServerCount(0);
+ cluster.setTotalRegionCount(0);
+ } else {
+ String[] serverCnt = (String[]) (this.mbs.invoke(mbeanName,
+ PulseConstants.MBEAN_OPERATION_LISTSERVERS, null, null));
+ cluster.setServerCount(serverCnt.length);
+ }
+
+ TabularData table = (TabularData) (this.mbs.invoke(mbeanName,
+ PulseConstants.MBEAN_OPERATION_VIEWREMOTECLUSTERSTATUS, null, null));
+
+ Collection<CompositeData> rows = (Collection<CompositeData>) table
+ .values();
+ cluster.getWanInformationObject().clear();
+ for (CompositeData row : rows) {
+ final Object key = row.get("key");
+ final Object value = row.get("value");
+ cluster.getWanInformationObject().put((String) key, (Boolean) value);
+ }
+
+ AttributeList attributeList = this.mbs.getAttributes(mbeanName,
+ PulseConstants.CLUSTER_MBEAN_ATTRIBUTES);
+
+ for (int i = 0; i < attributeList.size(); i++) {
+
+ Attribute attribute = (Attribute) attributeList.get(i);
+ String name = attribute.getName();
+ switch (name){
+ case PulseConstants.MBEAN_ATTRIBUTE_MEMBERCOUNT:
+ cluster.setMemberCount(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_NUMCLIENTS:
+ cluster.setClientConnectionCount(getIntegerAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISTRIBUTEDSYSTEMID:
+ cluster.setClusterId(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_LOCATORCOUNT:
+ cluster.setLocatorCount(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_NUMRUNNIGFUNCTION:
+ try {
+ cluster.setRunningFunctionCount(getIntegerAttribute(
+ attribute.getValue(), attribute.getName()));
+ } catch (Exception e) {
+ cluster.setRunningFunctionCount(0);
+ continue;
+ }
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_REGISTEREDCQCOUNT:
+ cluster.setRegisteredCQCount(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_NUMSUBSCRIPTIONS:
+ cluster.setSubscriptionCount(getIntegerAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_NUMTXNCOMMITTED:
+ cluster.setTxnCommittedCount(getIntegerAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_NUMTXNROLLBACK:
+ cluster.setTxnRollbackCount(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_TOTALHEAPSIZE:
+ cluster.setTotalHeapSize(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_USEDHEAPSIZE:
+ try {
+ cluster.setUsedHeapSize(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ } catch (Exception e) {
+ cluster.setUsedHeapSize((long) 0);
+ continue;
+ }
+ cluster.getMemoryUsageTrend().add(cluster.getUsedHeapSize());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_TOTALREGIONENTRYCOUNT:
+ cluster.setTotalRegionEntryCount(getLongAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_CURRENTENTRYCOUNT:
+ cluster.setCurrentQueryCount(getIntegerAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_TOTALDISKUSAGE:
+ try {
+ cluster.setTotalBytesOnDisk(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ } catch (Exception e) {
+ cluster.setTotalBytesOnDisk((long) 0);
+ continue;
+ }
+ cluster.getTotalBytesOnDiskTrend().add(cluster.getTotalBytesOnDisk());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
+ cluster.setDiskWritesRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ cluster.getThroughoutWritesTrend().add(cluster.getDiskWritesRate());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEWRITES:
+ try {
+ cluster.setWritePerSec(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ } catch (Exception e) {
+ cluster.setWritePerSec(0);
+ continue;
+ }
+ cluster.getWritePerSecTrend().add(cluster.getWritePerSec());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEREADS:
+ try {
+ cluster.setReadPerSec(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ } catch (Exception e) {
+ cluster.setReadPerSec(0);
+ continue;
+ }
+ cluster.getReadPerSecTrend().add(cluster.getReadPerSec());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_QUERYREQUESTRATE:
+ cluster.setQueriesPerSec(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ cluster.getQueriesPerSecTrend().add(cluster.getQueriesPerSec());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
+ cluster.setDiskReadsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ cluster.getThroughoutReadsTrend().add(cluster.getDiskReadsRate());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_JVMPAUSES:
+ long trendVal = determineCurrentJVMPauses(
+ PulseConstants.JVM_PAUSES_TYPE_CLUSTER, "",
+ getLongAttribute(attribute.getValue(), attribute.getName()));
+ cluster.setGarbageCollectionCount(trendVal);
+ cluster.getGarbageCollectionTrend().add(
+ cluster.getGarbageCollectionCount());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_TOTALREGIONCOUNT:
+ if (!PulseConstants.PRODUCT_NAME_SQLFIRE
+ .equalsIgnoreCase(PulseController.getPulseProductSupport())){
+ // for Gemfire
+ cluster.setTotalRegionCount(getIntegerAttribute(
+ attribute.getValue(), attribute.getName()));
+ }
+ break;
+ }
+ }
+
+ // SQLFIRE attributes
+ if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController
+ .getPulseProductSupport())) {
+
+ try { // get sqlfire cluster mbean
+
+ ObjectName sfMemberMbeansObjectName = new ObjectName(
+ PulseConstants.OBJECT_NAME_SF_CLUSTER);
+
+ Set<ObjectName> sfCluserMBeans = this.mbs.queryNames(
+ sfMemberMbeansObjectName, null);
+
+ for (ObjectName sfCluserMBean : sfCluserMBeans) {
+
+ AttributeList attrList = this.mbs.getAttributes(sfCluserMBean,
+ PulseConstants.SF_CLUSTER_MBEAN_ATTRIBUTES);
+
+ for (int i = 0; i < attrList.size(); i++) {
+
+ Attribute attribute = (Attribute) attrList.get(i);
+
+ if (attribute.getName().equals(
+ PulseConstants.MBEAN_ATTRIBUTE_PROCEDURECALLSINPROGRESS)) {
+ try {
+ cluster.setRunningFunctionCount(getIntegerAttribute(
+ attribute.getValue(), attribute.getName()));
+ } catch (Exception e) {
+ cluster.setRunningFunctionCount(0);
+ continue;
+ }
+ } else if (attribute
+ .getName()
+ .equals(
+ PulseConstants.MBEAN_ATTRIBUTE_NETWORKSERVERCLIENTCONNECTIONSTATS)) {
+ // set number of cluster's clients
+ CompositeData nscConnStats = (CompositeData) attribute
+ .getValue();
+
+ cluster.setClientConnectionCount(getLongAttribute(nscConnStats
+ .get(PulseConstants.COMPOSITE_DATA_KEY_CONNECTIONSACTIVE),
+ PulseConstants.COMPOSITE_DATA_KEY_CONNECTIONSACTIVE));
+ }
+ }
+ break;
+ }
+
+ } catch (MalformedObjectNameException e) {
+ LOGGER.warning(e);
+ } catch (NullPointerException e) {
+ LOGGER.warning(e);
+ }
+
+ }
+
+ } catch (InstanceNotFoundException infe) {
+ LOGGER.warning(infe);
+ } catch (ReflectionException re) {
+ LOGGER.warning(re);
+ } catch (MBeanException anfe) {
+ LOGGER.warning(anfe);
+ }
+ }
+
+ /**
+ * function used to get attribute values of Gateway Receiver and map them to
+ * GatewayReceiver inner class object
+ *
+ * @param mbeanName
+ * @return GatewayReceiver object
+ * @throws InstanceNotFoundException
+ * @throws IntrospectionException
+ * @throws ReflectionException
+ * @throws IOException
+ * @throws AttributeNotFoundException
+ * @throws MBeanException
+ *
+ *
+ */
+ private Cluster.GatewayReceiver initGatewayReceiver(ObjectName mbeanName)
+ throws InstanceNotFoundException, IntrospectionException,
+ ReflectionException, IOException, AttributeNotFoundException,
+ MBeanException {
+
+ Cluster.GatewayReceiver gatewayReceiver = new Cluster.GatewayReceiver();
+
+ AttributeList attributeList = this.mbs.getAttributes(mbeanName,
+ PulseConstants.GATEWAY_MBEAN_ATTRIBUTES);
+
+ for (int i = 0; i < attributeList.size(); i++) {
+ Attribute attribute = (Attribute) attributeList.get(i);
+
+ if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_PORT)) {
+ gatewayReceiver.setListeningPort(getIntegerAttribute(
+ attribute.getValue(), attribute.getName()));
+ } else if (attribute.getName().equals(
+ PulseConstants.MBEAN_ATTRIBUTE_EVENTRECEIVEDDATE)) {
+ gatewayReceiver.setLinkThroughput(getDoubleAttribute(
+ attribute.getValue(), attribute.getName()));
+ } else if (attribute.getName().equals(
+ PulseConstants.MBEAN_ATTRIBUTE_AVEARGEBATCHPROCESSINGTIME)) {
+ gatewayReceiver.setAvgBatchProcessingTime(getLongAttribute(
+ attribute.getValue(), attribute.getName()));
+ } else if (attribute.getName().equals(
+ PulseConstants.MBEAN_ATTRIBUTE_RUNNING)) {
+ gatewayReceiver.setStatus(getBooleanAttribute(attribute.getValue(),
+ attribute.getName()));
+ }
+ }
+ return gatewayReceiver;
+ }
+
+ /**
+ * function used to get attribute values of Gateway Sender and map them to
+ * GatewaySender inner class object
+ *
+ * @param mbeanName
+ * @return
+ * @throws InstanceNotFoundException
+ * @throws IntrospectionException
+ * @throws ReflectionException
+ * @throws IOException
+ * @throws AttributeNotFoundException
+ * @throws MBeanException
+ */
+ private Cluster.GatewaySender initGatewaySender(ObjectName mbeanName)
+ throws InstanceNotFoundException, IntrospectionException,
+ ReflectionException, IOException, AttributeNotFoundException,
+ MBeanException {
+
+ Cluster.GatewaySender gatewaySender = new Cluster.GatewaySender();
+ AttributeList attributeList = this.mbs.getAttributes(mbeanName,
+ PulseConstants.GATEWAYSENDER_MBEAN_ATTRIBUTES);
+
+ for (int i = 0; i < attributeList.size(); i++) {
+ Attribute attribute = (Attribute) attributeList.get(i);
+ String name = attribute.getName();
+ switch (name){
+ case PulseConstants.MBEAN_ATTRIBUTE_EVENTRECEIVEDDATE:
+ gatewaySender.setLinkThroughput(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_BATCHSIZE:
+ gatewaySender.setBatchSize(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_SENDERID:
+ gatewaySender.setId(getStringAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_EVENTQUEUESIZE:
+ gatewaySender.setQueueSize(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_RUNNING:
+ gatewaySender.setStatus(getBooleanAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_PRIMARY:
+ gatewaySender.setPrimary(getBooleanAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_PERSISTENCEENABLED:
+ gatewaySender.setPersistenceEnabled(getBooleanAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_PARALLEL:
+ gatewaySender.setSenderType(getBooleanAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_REMOTE_DS_ID:
+ gatewaySender.setRemoteDSId(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_EVENTS_EXCEEDING_ALERT_THRESHOLD:
+ gatewaySender.setEventsExceedingAlertThreshold(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ }
+ }
+ return gatewaySender;
+ }
+
+ /**
+ * function used for getting list of Gateway Senders from mBean for giving
+ * member and update the list of gateway senders for respective member object
+ */
+ private void updateGatewaySender(ObjectName mbeanName) throws IOException {
+
+ try {
+ String memberName = mbeanName
+ .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
+
+ if (cluster.getMembersHMap().containsKey(memberName)) {
+ Cluster.Member existingMember = cluster.getMembersHMap()
+ .get(memberName);
+ Cluster.GatewaySender gatewaySender = initGatewaySender(mbeanName);
+ for (Iterator<Cluster.GatewaySender> it = existingMember
+ .getGatewaySenderList().iterator(); it.hasNext();) {
+ Cluster.GatewaySender exisGatewaySender = it.next();
+ if ((exisGatewaySender.getId()).equals(gatewaySender.getId())) {
+ it.remove();
+ break;
+ }
+ }
+
+ // Add gateway sender
+ existingMember.getGatewaySenderList().add(gatewaySender);
+
+ } else {
+ Cluster.Member member = new Cluster.Member();
+ member.setName(memberName);
+ member.setId(memberName);
+ Cluster.GatewaySender gatewaySender = initGatewaySender(mbeanName);
+ member.getGatewaySenderList().add(gatewaySender);
+ cluster.getMembersHMap().put(memberName, member);
+ }
+ } catch (InstanceNotFoundException infe) {
+ LOGGER.warning(infe);
+ } catch (ReflectionException re) {
+ LOGGER.warning(re);
+ } catch (MBeanException me) {
+ LOGGER.warning(me);
+ } catch (AttributeNotFoundException anfe) {
+ LOGGER.warning(anfe);
+ } catch (IntrospectionException ire) {
+ LOGGER.warning(ire);
+ }
+ }
+
+ /**
+ * function used to get attribute values of Async Event Queue and map them to
+ * Async Event Queue inner class object
+ *
+ * @param mbeanName
+ * @return
+ * @throws InstanceNotFoundException
+ * @throws IntrospectionException
+ * @throws ReflectionException
+ * @throws IOException
+ * @throws AttributeNotFoundException
+ * @throws MBeanException
+ */
+ private Cluster.AsyncEventQueue initAsyncEventQueue(ObjectName mbeanName)
+ throws InstanceNotFoundException, IntrospectionException,
+ ReflectionException, IOException, AttributeNotFoundException,
+ MBeanException {
+
+ Cluster.AsyncEventQueue asyncEventQueue = new Cluster.AsyncEventQueue();
+ AttributeList attributeList = this.mbs.getAttributes(mbeanName,
+ PulseConstants.ASYNC_EVENT_QUEUE_MBEAN_ATTRIBUTES);
+
+ for (int i = 0; i < attributeList.size(); i++) {
+ Attribute attribute = (Attribute) attributeList.get(i);
+ String name = attribute.getName();
+ switch (name){
+ case PulseConstants.MBEAN_ATTRIBUTE_AEQ_ASYNCEVENTID:
+ asyncEventQueue.setId(getStringAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_AEQ_ASYNC_EVENT_LISTENER:
+ asyncEventQueue.setAsyncEventListener(getStringAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_AEQ_BATCH_CONFLATION_ENABLED:
+ asyncEventQueue.setBatchConflationEnabled(getBooleanAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_AEQ_BATCH_TIME_INTERVAL:
+ asyncEventQueue.setBatchTimeInterval(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_AEQ_BATCH_SIZE:
+ asyncEventQueue.setBatchSize(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_AEQ_EVENT_QUEUE_SIZE:
+ asyncEventQueue.setEventQueueSize(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_AEQ_PARALLEL:
+ asyncEventQueue.setParallel(getBooleanAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_AEQ_PRIMARY:
+ asyncEventQueue.setPrimary(getBooleanAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ }
+ }
+ return asyncEventQueue;
+ }
+
+ /**
+ * function used for getting list of Gateway Senders from mBean for giving
+ * member and update the list of gateway senders for respective member object
+ */
+ private void updateAsyncEventQueue(ObjectName mbeanName) throws IOException {
+ try {
+ String memberName = mbeanName
+ .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
+
+ if (cluster.getMembersHMap().containsKey(memberName)) {
+ Cluster.Member existingMember = cluster.getMembersHMap()
+ .get(memberName);
+ Cluster.AsyncEventQueue asyncQ = initAsyncEventQueue(mbeanName);
+ for (Iterator<Cluster.AsyncEventQueue> it = existingMember.getAsyncEventQueueList().iterator(); it.hasNext();) {
+ Cluster.AsyncEventQueue exisAsyncEventQueue = it.next();
+ if ((exisAsyncEventQueue.getId()).equals(asyncQ.getId())) {
+ it.remove();
+ break;
+ }
+ }
+
+ // Add async event queue
+ existingMember.getAsyncEventQueueList().add(asyncQ);
+ } else {
+ Cluster.Member member = new Cluster.Member();
+ member.setName(memberName);
+ member.setId(memberName);
+
+ Cluster.AsyncEventQueue asyncQ = initAsyncEventQueue(mbeanName);
+ member.getAsyncEventQueueList().add(asyncQ);
+
+ cluster.getMembersHMap().put(memberName, member);
+ }
+ } catch (InstanceNotFoundException infe) {
+ LOGGER.warning(infe);
+ } catch (ReflectionException re) {
+ LOGGER.warning(re);
+ } catch (MBeanException me) {
+ LOGGER.warning(me);
+ } catch (AttributeNotFoundException anfe) {
+ LOGGER.warning(anfe);
+ } catch (IntrospectionException ire) {
+ LOGGER.warning(ire);
+ }
+ }
+
+ /**
+ * function used for getting a Gateway Receiver from mBean for giving member
+ * and update the gateway receiver for respective member object
+ */
+ private void updateGatewayReceiver(ObjectName mbeanName) throws IOException {
+
+ try {
+ String memberName = mbeanName
+ .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
+
+ if (cluster.getMembersHMap().containsKey(memberName)) {
+ Cluster.Member existingMember = cluster.getMembersHMap()
+ .get(memberName);
+ Cluster.GatewayReceiver gatewayReceiver = initGatewayReceiver(mbeanName);
+ existingMember.setGatewayReceiver(gatewayReceiver);
+ } else {
+ Cluster.Member member = new Cluster.Member();
+ member.setName(memberName);
+ member.setId(memberName);
+ Cluster.GatewayReceiver gatewayReceiver = initGatewayReceiver(mbeanName);
+ member.setGatewayReceiver(gatewayReceiver);
+ cluster.getMembersHMap().put(memberName, member);
+ }
+ } catch (InstanceNotFoundException infe) {
+ LOGGER.warning(infe);
+ } catch (ReflectionException re) {
+ LOGGER.warning(re);
+ } catch (MBeanException me) {
+ LOGGER.warning(me);
+ } catch (AttributeNotFoundException anfe) {
+ LOGGER.warning(anfe);
+ } catch (IntrospectionException ire) {
+ LOGGER.warning(ire);
+ }
+ }
+
+ /**
+ * function used for getting member clients from mbean and update the clients
+ * information in member object's client arraylist
+ */
+ private void updateMemberClient(ObjectName mbeanName) throws IOException {
+
+ try {
+ String memberName = mbeanName
+ .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
+
+ if (cluster.getMembersHMap().containsKey(memberName)) {
+ Cluster.Member existingMember = cluster.getMembersHMap()
+ .get(memberName);
+ HashMap<String, Cluster.Client> memberClientsHM = new HashMap<String, Cluster.Client>();
+
+ existingMember.setMemberPort(""
+ + this.mbs.getAttribute(mbeanName,
+ PulseConstants.MBEAN_ATTRIBUTE_PORT));
+
+ this.mbs.getAttribute(mbeanName, PulseConstants.MBEAN_ATTRIBUTE_HOSTNAMEFORCLIENTS_ALT);
+ existingMember.setHostnameForClients((String)this.mbs.getAttribute(mbeanName, PulseConstants.MBEAN_ATTRIBUTE_HOSTNAMEFORCLIENTS_ALT));
+ existingMember.setBindAddress((String)this.mbs.getAttribute(mbeanName, PulseConstants.MBEAN_ATTRIBUTE_BINDADDRESS));
+
+ CompositeData[] compositeData = (CompositeData[]) (this.mbs.invoke(
+ mbeanName, PulseConstants.MBEAN_OPERATION_SHOWALLCLIENTS, null,
+ null));
+ for (CompositeData cmd : compositeData) {
+ Cluster.Client client = new Cluster.Client();
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CLIENTID)) {
+ client.setId((String) cmd
+ .get(PulseConstants.COMPOSITE_DATA_KEY_CLIENTID));
+ }
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NAME)) {
+ client.setName((String) cmd
+ .get(PulseConstants.COMPOSITE_DATA_KEY_NAME));
+ }
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_HOSTNAME)) {
+ client.setHost((String) cmd
+ .get(PulseConstants.COMPOSITE_DATA_KEY_HOSTNAME));
+ }
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_QUEUESIZE)) {
+ client.setQueueSize((Integer) cmd
+ .get(PulseConstants.COMPOSITE_DATA_KEY_QUEUESIZE));
+ }
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_PROCESSCPUTIME)) {
+ client.setProcessCpuTime((Long) cmd
+ .get(PulseConstants.COMPOSITE_DATA_KEY_PROCESSCPUTIME));
+ }
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_UPTIME)) {
+ client.setUptime((Long) cmd
+ .get(PulseConstants.COMPOSITE_DATA_KEY_UPTIME));
+ }
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NUMOFTHREADS)) {
+ client.setThreads((Integer) cmd
+ .get(PulseConstants.COMPOSITE_DATA_KEY_NUMOFTHREADS));
+ }
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NUMOFGETS)) {
+ client.setGets((Integer) cmd
+ .get(PulseConstants.COMPOSITE_DATA_KEY_NUMOFGETS));
+ }
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NUMOFPUTS)) {
+ client.setPuts((Integer) cmd
+ .get(PulseConstants.COMPOSITE_DATA_KEY_NUMOFPUTS));
+ }
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CPUS)) {
+ client.setCpus((Integer) cmd
+ .get(PulseConstants.COMPOSITE_DATA_KEY_CPUS));
+ }
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CPUS)) {
+ client.setCpuUsage(0);
+ }
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CONNECTED)){
+ client.setConnected((Boolean) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_CONNECTED));
+ }
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CLIENTCQCOUNT)){
+ client.setClientCQCount((Integer) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_CLIENTCQCOUNT));
+ }
+ if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_SUBSCRIPTIONENABLED)){
+ client.setSubscriptionEnabled((Boolean) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_SUBSCRIPTIONENABLED));
+ }
+ memberClientsHM.put(client.getId(), client);
+ }
+ existingMember.updateMemberClientsHMap(memberClientsHM);
+ }
+ } catch (InstanceNotFoundException infe) {
+ LOGGER.warning(infe);
+ } catch (ReflectionException re) {
+ LOGGER.warning(re);
+ } catch (MBeanException me) {
+ LOGGER.warning(me);
+ } catch (AttributeNotFoundException anfe) {
+ LOGGER.warning(anfe);
+ }
+ }
+
+ /**
+ * Add member specific region information on the region
+ *
+ * @param regionObjectName: used to construct the jmx objectname. For region name that has special characters in, it will have double quotes around it.
+ * @param region
+ */
+ private void updateRegionOnMembers(String regionObjectName, String regionFullPath, Cluster.Region region) throws IOException {
+
+ try{
+ List<String> memberNamesTemp = region.getMemberName();
+ ArrayList<String> memberNames = new ArrayList<String>(memberNamesTemp);
+
+ List<Cluster.RegionOnMember> regionOnMemberList = new ArrayList<Cluster.RegionOnMember>();
+ List<Cluster.RegionOnMember> regionOnMemberListNew = new ArrayList<Cluster.RegionOnMember>();
+ Cluster.RegionOnMember[] regionOnMemberNames = region.getRegionOnMembers();
+
+ if ((regionOnMemberNames != null) && (regionOnMemberNames.length > 0)) {
+ regionOnMemberList = new ArrayList<Cluster.RegionOnMember>(Arrays.asList(regionOnMemberNames));
+ }
+ LOGGER.fine("updateRegionOnMembers : # regionOnMembers objects in region = " + regionOnMemberList.size());
+
+ for(Cluster.RegionOnMember anRom : regionOnMemberList) {
+
+ for(String memberName : memberNames){
+ if(anRom.getMemberName().equals(memberName)){
+ // Add regionOnMember object in new list
+ regionOnMemberListNew.add(anRom);
+
+ LOGGER.fine("updateRegionOnMembers : Processing existing Member name = " + anRom.getMemberName());
+ String objectNameROM = PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_REGION + regionObjectName + PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_MEMBER + anRom.getMemberName();
+ ObjectName regionOnMemberMBean = new ObjectName(objectNameROM);
+ LOGGER.fine("updateRegionOnMembers : Object name = " + regionOnMemberMBean.getCanonicalName());
+
+ AttributeList attributeList = this.mbs.getAttributes(regionOnMemberMBean, PulseConstants.REGION_ON_MEMBER_MBEAN_ATTRIBUTES);
+ for (int i = 0; i < attributeList.size(); i++) {
+ Attribute attribute = (Attribute) attributeList.get(i);
+ String name = attribute.getName();
+ switch(name){
+ case PulseConstants.MBEAN_ATTRIBUTE_ENTRYSIZE:
+ anRom.setEntrySize(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ LOGGER.fine("updateRegionOnMembers : anRom.getEntrySize() = " + anRom.getEntrySize());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_ENTRYCOUNT:
+ anRom.setEntryCount(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ LOGGER.fine("updateRegionOnMembers : anRom.getEntryCount() = " + anRom.getEntryCount());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_PUTSRATE:
+ anRom.setPutsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ LOGGER.fine("updateRegionOnMembers : anRom.getPutsRate() = " + anRom.getPutsRate());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_GETSRATE:
+ anRom.setGetsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ LOGGER.fine("updateRegionOnMembers : anRom.getGetsRate() = " + anRom.getGetsRate());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
+ anRom.setDiskGetsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ LOGGER.fine("updateRegionOnMembers : anRom.getDiskGetsRate() = " + anRom.getDiskGetsRate());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
+ anRom.setDiskPutsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ LOGGER.fine("updateRegionOnMembers : anRom.getDiskPutsRate() = " + anRom.getDiskPutsRate());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_LOCALMAXMEMORY:
+ anRom.setLocalMaxMemory(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ LOGGER.fine("updateRegionOnMembers : anRom.getLocalMaxMemory() = " + anRom.getLocalMaxMemory());
+ break;
+ }
+ }
+
+ anRom.getGetsPerSecTrend().add(anRom.getGetsRate());
+ anRom.getPutsPerSecTrend().add(anRom.getPutsRate());
+ anRom.getDiskReadsPerSecTrend().add(anRom.getDiskGetsRate());
+ anRom.getDiskWritesPerSecTrend().add(anRom.getDiskPutsRate());
+ LOGGER.fine("updateRegionOnMembers : Existing member on region : getGetsRate() = " + anRom.getGetsPerSecTrend().size() + ", getPutsRate() = "
+ + anRom.getPutsPerSecTrend().size() + ", getDiskGetsRate() = " + anRom.getDiskReadsPerSecTrend().size() + ", getDiskPutsRate() = "
+ + anRom.getDiskWritesPerSecTrend().size());
+
+ //remove existing member names from list so only new ones will remain
+ memberNames.remove(anRom.getMemberName());
+
+ break;
+ }
+ }
+ }
+
+ LOGGER.fine("updateRegionOnMembers : Loop over remaining member names and adding new member in region. Existing count = " + regionOnMemberList.size());
+ LOGGER.fine("updateRegionOnMembers : Remaining new members in this region = " + memberNames.size());
+ //loop over the remaining regions members and add new members for this region
+ for(String memberName : memberNames) {
+ String objectNameROM = PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_REGION + regionObjectName + PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_MEMBER + memberName;
+ ObjectName regionOnMemberMBean = new ObjectName(objectNameROM);
+ Cluster.RegionOnMember regionOnMember = new Cluster.RegionOnMember();
+ regionOnMember.setMemberName(memberName);
+ regionOnMember.setRegionFullPath(regionFullPath);
+ AttributeList attributeList = this.mbs.getAttributes(regionOnMemberMBean, PulseConstants.REGION_ON_MEMBER_MBEAN_ATTRIBUTES);
+ for (int i = 0; i < attributeList.size(); i++) {
+ Attribute attribute = (Attribute) attributeList.get(i);
+ String name=attribute.getName();
+ switch (name){
+ case PulseConstants.MBEAN_ATTRIBUTE_ENTRYSIZE:
+ regionOnMember.setEntrySize(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_ENTRYCOUNT:
+ regionOnMember.setEntryCount(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_PUTSRATE:
+ regionOnMember.setPutsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_GETSRATE:
+ regionOnMember.setGetsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
+ regionOnMember.setDiskGetsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
+ regionOnMember.setDiskPutsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_LOCALMAXMEMORY:
+ regionOnMember.setLocalMaxMemory(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ }
+ }
+
+ regionOnMember.getGetsPerSecTrend().add(regionOnMember.getGetsRate());
+ regionOnMember.getPutsPerSecTrend().add(regionOnMember.getPutsRate());
+ regionOnMember.getDiskReadsPerSecTrend().add(regionOnMember.getDiskGetsRate());
+ regionOnMember.getDiskWritesPerSecTrend().add(regionOnMember.getDiskPutsRate());
+
+ LOGGER.fine("updateRegionOnMembers : Adding New member on region : getGetsRate() = " + regionOnMember.getGetsRate() + ", getPutsRate() = "
+ + regionOnMember.getPutsRate() + ", getDiskGetsRate() = " + regionOnMember.getDiskGetsRate() + ", getDiskPutsRate() = "
+ + regionOnMember.getDiskPutsRate());
+
+ regionOnMemberListNew.add(regionOnMember);
+ }
+
+ //set region on member
+ region.setRegionOnMembers(regionOnMemberListNew);
+ LOGGER.fine("updateRegionOnMembers : Total regions on member in region " + region.getFullPath() + " after update = " + region.getRegionOnMembers().length);
+ } catch (MalformedObjectNameException e) {
+ LOGGER.warning(e);
+ } catch (InstanceNotFoundException infe) {
+ LOGGER.warning(infe);
+ } catch (ReflectionException re) {
+ LOGGER.warning(re);
+ }
+ }
+
+ /**
+ * function used to get attribute values of Cluster Region and map them to
+ * cluster region vo
+ *
+ * @param mbeanName
+ * Cluster Region MBean
+ */
+ private void updateClusterRegion(ObjectName mbeanName) throws IOException {
+
+ try {
+
+ AttributeList attributeList = this.mbs.getAttributes(mbeanName,
+ PulseConstants.REGION_MBEAN_ATTRIBUTES);
+
+ // retrieve the full path of the region
+ String regionObjectName = mbeanName.getKeyProperty("name");
+ String regionFullPath = null;
+ for (int i = 0; i < attributeList.size(); i++) {
+ Attribute attribute = (Attribute) attributeList.get(i);
+
+ if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_FULLPATH)) {
+ regionFullPath = getStringAttribute(attribute.getValue(),
+ attribute.getName());
+ break;
+ }
+ }
+
+ Cluster.Region region = cluster.getClusterRegions().get(regionFullPath);
+
+ if (null == region) {
+ region = new Cluster.Region();
+ }
+
+ for (int i = 0; i < attributeList.size(); i++) {
+
+ Attribute attribute = (Attribute) attributeList.get(i);
+
+ String name = attribute.getName();
+ switch (name){
+ case PulseConstants.MBEAN_ATTRIBUTE_MEMBERS:
+ String memName[] = (String[]) attribute.getValue();
+ region.getMemberName().clear();
+ for (int k = 0; k < memName.length; k++) {
+ region.getMemberName().add(memName[k]);
+ }
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_FULLPATH:
+ region.setFullPath(getStringAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
+ region.setDiskReadsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
+ region.setDiskWritesRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_EMPTYNODES:
+ region.setEmptyNode(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_GETSRATE:
+ region.setGetsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_LRUEVICTIONRATE:
+ region.setLruEvictionRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_PUTSRATE:
+ region.setPutsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_REGIONTYPE:
+ region.setRegionType(getStringAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_ENTRYSIZE:
+ region.setEntrySize(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_SYSTEMREGIONENTRYCOUNT:
+ region.setSystemRegionEntryCount(getLongAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_MEMBERCOUNT:
+ region.setMemberCount(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_PERSISTENTENABLED:
+ region.setPersistentEnabled(getBooleanAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_NAME:
+ region.setName(getStringAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_GATEWAYENABLED:
+ region.setWanEnabled(getBooleanAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISKUSAGE:
+ region.setDiskUsage(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ }
+ }
+
+ //add for each member
+ updateRegionOnMembers(regionObjectName, regionFullPath, region);
+
+ cluster.addClusterRegion(regionFullPath, region);
+ cluster.getDeletedRegions().remove(region.getFullPath());
+ // Memory Reads and writes
+ region.getPutsPerSecTrend().add(region.getPutsRate());
+ region.getGetsPerSecTrend().add(region.getGetsRate());
+ // Disk Reads and Writes
+ region.getDiskReadsPerSecTrend().add(region.getDiskReadsRate());
+ region.getDiskWritesPerSecTrend().add(region.getDiskWritesRate());
+
+ } catch (InstanceNotFoundException infe) {
+ LOGGER.warning(infe);
+ } catch (ReflectionException re) {
+ LOGGER.warning(re);
+ }
+ }
+
+ private static boolean isQuoted(String value) {
+ final int len = value.length();
+ if (len < 2 || value.charAt(0) != '"' || value.charAt(len - 1) != '"') {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ private void updateClusterStatement(ObjectName mbeanName) throws IOException {
+
+ try {
+
+ AttributeList attributeList = this.mbs.getAttributes(mbeanName,
+ PulseConstants.STATEMENT_MBEAN_ATTRIBUTES);
+ // retrieve the full path of the region
+ String statementDefinition = mbeanName.getKeyProperty("name");
+
+ if (isQuoted(statementDefinition)) {
+ statementDefinition = ObjectName.unquote(statementDefinition);
+ }
+
+ Cluster.Statement statement = cluster.getClusterStatements().get(
+ statementDefinition);
+
+ if (null == statement) {
+ statement = new Cluster.Statement();
+ statement.setQueryDefinition(statementDefinition);
+ }
+
+ for (int i = 0; i < attributeList.size(); i++) {
+ Attribute attribute = (Attribute) attributeList.get(i);
+ String name = attribute.getName();
+ switch (name){
+ case PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESCOMPILED:
+ statement.setNumTimesCompiled(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTION:
+ statement.setNumExecution(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTIONSINPROGRESS:
+ statement.setNumExecutionsInProgress(getLongAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESGLOBALINDEXLOOKUP:
+ statement.setNumTimesGlobalIndexLookup(getLongAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_NUMROWSMODIFIED:
+ statement.setNumRowsModified(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_PARSETIME:
+ statement.setParseTime(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_BINDTIME:
+ statement.setBindTime(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_OPTIMIZETIME:
+ statement.setOptimizeTime(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_ROUTINGINFOTIME:
+ statement.setRoutingInfoTime(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_GENERATETIME:
+ statement.setGenerateTime(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_TOTALCOMPILATIONTIME:
+ statement.setTotalCompilationTime(getLongAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_EXECUTIONTIME:
+ statement.setExecutionTime(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_PROJECTIONTIME:
+ statement.setProjectionTime(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_TOTALEXECUTIONTIME:
+ statement.setTotalExecutionTime(getLongAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_ROWSMODIFICATIONTIME:
+ statement.setRowsModificationTime(getLongAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_QNNUMROWSSEEN:
+ statement.setqNNumRowsSeen(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_QNMSGSENDTIME:
+ statement.setqNMsgSendTime(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_QNMSGSERTIME:
+ statement.setqNMsgSerTime(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_QNRESPDESERTIME:
+ statement.setqNRespDeSerTime(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ }
+ }
+
+ cluster.addClusterStatement(statementDefinition, statement);
+ // TODO : to store data for sparklines later
+ /*
+ * region.getPutsPerSecTrend().add(region.getPutsRate());
+ * region.getGetsPerSecTrend().add(region.getGetsRate());
+ */
+ } catch (InstanceNotFoundException infe) {
+ LOGGER.warning(infe);
+ } catch (ReflectionException re) {
+ LOGGER.warning(re);
+ }
+ }
+
+ /**
+ * function used to iterate through all member attributes and return the
+ * updated member
+ */
+ private Cluster.Member initializeMember(ObjectName mbeanName,
+ Cluster.Member member) throws InstanceNotFoundException,
+ ReflectionException, IOException {
+
+ AttributeList attributeList = this.mbs.getAttributes(mbeanName,
+ PulseConstants.MEMBER_MBEAN_ATTRIBUTES);
+
+ for (int i = 0; i < attributeList.size(); i++) {
+
+ Attribute attribute = (Attribute) attributeList.get(i);
+ String name = attribute.getName();
+ switch (name) {
+ case PulseConstants.MBEAN_ATTRIBUTE_GEMFIREVERSION:
+ if (member.getGemfireVersion() == null) {
+ // Set Member's GemFire Version if not set already
+ String gemfireVersion = obtainGemfireVersion(getStringAttribute(
+ attribute.getValue(), attribute.getName()));
+ member.setGemfireVersion(gemfireVersion);
+ }
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_MANAGER:
+ member.setManager(getBooleanAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_TOTALREGIONCOUNT:
+ member.setTotalRegionCount(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_LOCATOR:
+ member.setLocator(getBooleanAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_TOTALDISKUSAGE:
+ member.setTotalDiskUsage(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_SERVER:
+ member.setServer(getBooleanAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_TOTALFILEDESCRIPTOROPEN:
+ member.setTotalFileDescriptorOpen(getLongAttribute(
+ attribute.getValue(), attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_LOADAVERAGE:
+ member.setLoadAverage(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
+ member.setThroughputWrites(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ member.getThroughputWritesTrend().add(member.getThroughputWrites());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
+ member.setThroughputReads(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ member.getThroughputReadsTrend().add(member.getThroughputReads());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_JVMPAUSES:
+ long trendVal = determineCurrentJVMPauses(
+ PulseConstants.JVM_PAUSES_TYPE_MEMBER, member.getName(),
+ getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ member.setGarbageCollectionCount(trendVal);
+ member.getGarbageCollectionSamples().add(
+ member.getGarbageCollectionCount());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_USEDMEMORY:
+ member.setCurrentHeapSize(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ member.getHeapUsageSamples().add(member.getCurrentHeapSize());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_MAXMEMORY:
+ member.setMaxHeapSize(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_NUMTHREADS:
+ member.setNumThreads(getIntegerAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_MEMBERUPTIME:
+ member.setUptime(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_HOST:
+ member.setHost(getStringAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_HOSTNAMEFORCLIENTS:
+ member.setHostnameForClients(getStringAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_BINDADDRESS:
+ member.setBindAddress(getStringAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_TOTALBYTESONDISK:
+ member.setTotalBytesOnDisk(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ member.getTotalBytesOnDiskSamples().add(member.getTotalBytesOnDisk());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_CPUUSAGE:
+ member.setCpuUsage(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ member.getCpuUsageSamples().add(member.getCpuUsage());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_HOSTCPUUSAGE:
+ // Float value is expected for host cpu usage.
+ // TODO Remove Float.valueOf() when float value is provided in mbean
+ member.setHostCpuUsage(Double.valueOf(getIntegerAttribute(
+ attribute.getValue(), attribute.getName())));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_MEMBER:
+ member.setName(getStringAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_ID:
+ member.setId(getStringAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEREADS:
+ member.setGetsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ member.getGetsPerSecond().add(member.getGetsRate());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEWRITES:
+ member.setPutsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ member.getPutsPerSecond().add(member.getPutsRate());
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_OFFHEAPFREESIZE:
+ member.setOffHeapFreeSize(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_OFFHEAPUSEDSIZE:
+ member.setOffHeapUsedSize(getLongAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_SERVERGROUPS:
+ String sgValues[] = (String[]) attribute.getValue();
+ member.getServerGroups().clear();
+ for (int k = 0; k < sgValues.length; k++) {
+ member.getServerGroups().add(sgValues[k]);
+ }
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_REDUNDANCYZONES:
+ String rzValue = "";
+ if(null != attribute.getValue()){
+ rzValue = getStringAttribute(attribute.getValue(),
+ attribute.getName());
+ }
+ member.getRedundancyZones().clear();
+ if(!rzValue.isEmpty()){
+ member.getRedundancyZones().add(rzValue);
+ }
+ break;
+ }
+ }
+
+ // SQLFire specific attributes
+ if (PulseController.getPulseProductSupport().equalsIgnoreCase(
+ PulseConstants.PRODUCT_NAME_SQLFIRE)) {
+
+ try {
+ // get sqlfire mbeans
+ String memberName = mbeanName
+ .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
+
+ ObjectName sfMemberMbeansObjectName = new ObjectName(
+ PulseConstants.OBJECT_NAME_SF_MEMBER_PATTERN + memberName);
+
+ Set<ObjectName> sfMemberMBeans = this.mbs.queryNames(
+ sfMemberMbeansObjectName, null);
+ for (ObjectName sfMemberMBean : sfMemberMBeans) {
+
+ AttributeList attrList = this.mbs.getAttributes(sfMemberMBean,
+ PulseConstants.SF_MEMBER_MBEAN_ATTRIBUTES);
+ for (int i = 0; i < attrList.size(); i++) {
+
+ Attribute attribute = (Attribute) attrList.get(i);
+
+ if (attribute.getName().equals(
+ PulseConstants.MBEAN_ATTRIBUTE_DATASTORE)) {
+ member.setServer(getBooleanAttribute(attribute.getValue(),
+ attribute.getName()));
+
+ // Update Server count
+ if (member.isServer()) {
+ cluster.setServerCount(cluster.getServerCount() + 1);
+ }
+ } else if (attribute.getName().equals(
+ PulseConstants.MBEAN_ATTRIBUTE_NETWORKSERVERCLIENTCONNECTIONSTATS)) {
+
+ CompositeData nscConnStats = (CompositeData) attribute.getValue();
+
+ // Update sqlfire client count
+ member.setNumSqlfireClients(getLongAttribute(nscConnStats
+ .get(PulseConstants.COMPOSITE_DATA_KEY_CONNECTIONSACTIVE),
+ PulseConstants.COMPOSITE_DATA_KEY_CONNECTIONSACTIVE));
+ }
+ }
+ break;
+ }
+
+ } catch (MalformedObjectNameException e) {
+ LOGGER.warning(e);
+ } catch (NullPointerException e) {
+ LOGGER.warning(e);
+ }
+
+ }
+
+ return member;
+ }
+
+ /**
+ * function used to get attribute values of Cluster Member and map them to
+ * cluster member vo
+ *
+ * @param mbeanName
+ * Cluster Member MBean
+ */
+ private void updateClusterMember(ObjectName mbeanName) throws IOException {
+
+ try {
+ String memberName = mbeanName
+ .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
+
+ Cluster.Member clusterMember = cluster.getMembersHMap().get(memberName);
+
+ if (clusterMember != null) // checking if member exists or not
+ {
+ cluster.getDeletedMembers().remove(memberName);
+ } else {
+ clusterMember = new Cluster.Member();
+ cluster.getMembersHMap().put(memberName, clusterMember);
+ }
+
+ // initialize member and add to cluster's member list
+ clusterMember = initializeMember(mbeanName, clusterMember);
+ ArrayList<Cluster.Member> memberArrList = (ArrayList<Cluster.Member>) cluster
+ .getPhysicalToMember().get(clusterMember.getHost());
+ if (memberArrList != null) {
+ if (!memberArrList.contains(clusterMember)) {
+ memberArrList.add(clusterMember);
+ }
+ } else {
+ ArrayList<Cluster.Member> memberList = new ArrayList<Cluster.Member>();
+ memberList.add(clusterMember);
+ cluster.getPhysicalToMember().put(clusterMember.getHost(), memberList);
+ }
+ } catch (InstanceNotFoundException infe) {
+ LOGGER.warning(infe);
+ } catch (ReflectionException re) {
+ LOGGER.warning(re);
+ }
+ }
+
+ /**
+ * function used to handle Float data type if the value for mbean for an
+ * attribute is null then return 0.0 as default value else return the
+ * attribute value
+ */
+ private Float getFloatAttribute(Object object, String name) {
+ if (object == null) {
+ return Float.valueOf(0.0f);
+ }
+
+ try {
+ if (!(object.getClass().equals(Float.class))) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("************************Unexpected type for attribute: "
+ + name + " Expected type: " + Float.class.getName()
+ + " Received type: " + object.getClass().getName()
+ + "************************");
+ }
+ return Float.valueOf(0.0f);
+ } else {
+ return (Float) object;
+ }
+ } catch (Exception e) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("Exception occurred: " + e.getMessage());
+ }
+ return Float.valueOf(0.0f);
+ }
+ }
+
+ /**
+ * function used to handle Integer data type if the value for mbean for an
+ * attribute is null then return 0 as default value else return the attribute
+ * value
+ */
+ private Integer getIntegerAttribute(Object object, String name) {
+ if (object == null) {
+ return Integer.valueOf(0);
+ }
+
+ try {
+ if (!(object.getClass().equals(Integer.class))) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("************************Unexpected type for attribute: "
+ + name + " Expected type: " + Integer.class.getName()
+ + " Received type: " + object.getClass().getName()
+ + "************************");
+ }
+ return Integer.valueOf(0);
+ } else {
+ return (Integer) object;
+ }
+ } catch (Exception e) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("Exception occurred: " + e.getMessage());
+ }
+ return Integer.valueOf(0);
+ }
+ }
+
+ /**
+ * function used to handle Long data type if the value for mbean for an
+ * attribute is null then return 0 as default value else return the attribute
+ * value
+ */
+ private Long getLongAttribute(Object object, String name) {
+ if (object == null) {
+ return Long.valueOf(0);
+ }
+
+ try {
+ if (!(object.getClass().equals(Long.class))) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("************************Unexpected type for attribute: "
+ + name + " Expected type: " + Long.class.getName()
+ + " Received type: " + object.getClass().getName()
+ + "************************");
+ }
+ return Long.valueOf(0);
+ } else {
+ return (Long) object;
+ }
+ } catch (Exception e) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("Exception occurred: " + e.getMessage());
+ }
+ return Long.valueOf(0);
+ }
+
+ }
+
+ /**
+ * function used to handle String data type if the value for mbean for an
+ * attribute is null then return the empty string as default value else return
+ * the attribute value
+ */
+ private String getStringAttribute(Object object, String name) {
+ if (object == null) {
+ return "";
+ }
+
+ try {
+ if (!(object.getClass().equals(String.class))) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("************************Unexpected type for attribute: "
+ + name + " Expected type: " + String.class.getName()
+ + " Received type: " + object.getClass().getName()
+ + "************************");
+ }
+ return "";
+ } else {
+ return (String) object;
+ }
+ } catch (Exception e) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("Exception occurred: " + e.getMessage());
+ }
+ return "";
+ }
+ }
+
+ /**
+ * function used to handle Boolean data type if the value for mbean for an
+ * attribute is null then return false as default value else return the
+ * attribute value
+ */
+ private Boolean getBooleanAttribute(Object object, String name) {
+ if (object == null) {
+ return Boolean.FALSE;
+ }
+
+ try {
+ if (!(object.getClass().equals(Boolean.class))) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("************************Unexpected type for attribute: "
+ + name + " Expected type: " + Boolean.class.getName()
+ + " Received type: " + object.getClass().getName()
+ + "************************");
+ }
+ return Boolean.FALSE;
+ } else {
+ return (Boolean) object;
+ }
+ } catch (Exception e) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("Exception Occured: " + e.getMessage());
+ }
+ return Boolean.FALSE;
+ }
+ }
+
+ /**
+ * function used to handle Double data type if the value for mbean for an
+ * attribute is null then return 0.0 as default value else return the
+ * attribute value
+ */
+ private Double getDoubleAttribute(Object object, String name) {
+ if (object == null) {
+ return Double.valueOf(0);
+ }
+
+ try {
+ if (!(object.getClass().equals(Double.class))) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("************************Unexpected type for attribute: "
+ + name + " Expected type: " + Double.class.getName()
+ + " Received type: " + object.getClass().getName()
+ + "************************");
+ }
+ return Double.valueOf(0);
+ } else {
+ return (Double) object;
+ }
+ } catch (Exception e) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("Exception occurred: " + e.getMessage());
+ }
+ return Double.valueOf(0);
+ }
+ }
+
+ /**
+ * function used to get attribute values of Member Region and map them to
+ * Member vo
+ *
+ * @param mbeanName
+ * Member Region MBean
+ */
+ private void updateMemberRegion(ObjectName mbeanName) throws IOException {
+
+ try {
+ String memberName = mbeanName
+ .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
+
+ Cluster.Member member = cluster.getMembersHMap().get(memberName);
+
+ //Following attributes are not present in 9.0
+ //"Members"
+ //"EmptyNodes"
+ //"SystemRegionEntryCount"
+ //"MemberCount"
+ AttributeList attributeList = this.mbs.getAttributes(mbeanName,
+ PulseConstants.REGION_MBEAN_ATTRIBUTES);
+
+ // retrieve the full path of the region
+ String regionFullPathKey = null;
+ for (int i = 0; i < attributeList.size(); i++) {
+ Attribute attribute = (Attribute) attributeList.get(i);
+
+ if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_FULLPATH)) {
+ regionFullPathKey = getStringAttribute(attribute.getValue(),
+ attribute.getName());
+ break;
+ }
+ }
+
+ // if member does not exists defined for this region then create a member
+ if (null == member) {
+ member = new Cluster.Member();
+ member.setName(memberName);
+ cluster.getMembersHMap().put(memberName, member);
+ }
+
+ // if region with given path exists then update same else add new region
+ Cluster.Region region = member.getMemberRegions().get(regionFullPathKey);
+ if (null == region) {
+ region = new Cluster.Region();
+ member.getMemberRegions().put(regionFullPathKey, region);
+ member.setTotalRegionCount(member.getTotalRegionCount() + 1);
+ }
+ region.setFullPath(regionFullPathKey); // use already retrieved values
+
+ // update the existing or new region
+ for (int i = 0; i < attributeList.size(); i++) {
+ Attribute attribute = (Attribute) attributeList.get(i);
+ String name = attribute.getName();
+ switch (name){
+ case PulseConstants.MBEAN_ATTRIBUTE_FULLPATH:
+ region.setFullPath(getStringAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
+ region.setDiskReadsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
+ region.setDiskWritesRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN_ATTRIBUTE_GETSRATE:
+ region.setGetsRate(getDoubleAttribute(attribute.getValue(),
+ attribute.getName()));
+ break;
+ case PulseConstants.MBEAN
<TRUNCATED>
[25/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/README
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/README b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/README
deleted file mode 100644
index 2d7cdcf..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/README
+++ /dev/null
@@ -1,68 +0,0 @@
-JSON in Java [package com.vmware.gemfire.tools.pulse.internal.json]
-
-Douglas Crockford
-douglas@crockford.com
-
-2011-02-02
-
-
-JSON is a light-weight, language independent, data interchange format.
-See http://www.JSON.org/
-
-The files in this package implement JSON encoders/decoders in Java.
-It also includes the capability to convert between JSON and XML, HTTP
-headers, Cookies, and CDL.
-
-This is a reference implementation. There is a large number of JSON packages
-in Java. Perhaps someday the Java community will standardize on one. Until
-then, choose carefully.
-
-The license includes this restriction: "The software shall be used for good,
-not evil." If your conscience cannot live with that, then choose a different
-package.
-
-The package compiles on Java 1.2 thru Java 1.4.
-
-
-JSONObject.java: The JSONObject can parse text from a String or a JSONTokener
-to produce a map-like object. The object provides methods for manipulating its
-contents, and for producing a JSON compliant object serialization.
-
-JSONArray.java: The JSONObject can parse text from a String or a JSONTokener
-to produce a vector-like object. The object provides methods for manipulating
-its contents, and for producing a JSON compliant array serialization.
-
-JSONTokener.java: The JSONTokener breaks a text into a sequence of individual
-tokens. It can be constructed from a String, Reader, or InputStream.
-
-JSONException.java: The JSONException is the standard exception type thrown
-by this package.
-
-
-JSONString.java: The JSONString interface requires a toJSONString method,
-allowing an object to provide its own serialization.
-
-JSONStringer.java: The JSONStringer provides a convenient facility for
-building JSON strings.
-
-JSONWriter.java: The JSONWriter provides a convenient facility for building
-JSON text through a writer.
-
-
-CDL.java: CDL provides support for converting between JSON and comma
-delimited lists.
-
-Cookie.java: Cookie provides support for converting between JSON and cookies.
-
-CookieList.java: CookieList provides support for converting between JSON and
-cookie lists.
-
-HTTP.java: HTTP provides support for converting between JSON and HTTP headers.
-
-HTTPTokener.java: HTTPTokener extends JSONTokener for parsing HTTP headers.
-
-XML.java: XML provides support for converting between JSON and XML.
-
-JSONML.java: JSONML provides support for converting between JSONML and XML.
-
-XMLTokener.java: XMLTokener extends JSONTokener for parsing XML text.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/XML.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/XML.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/XML.java
deleted file mode 100644
index 2c91414..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/XML.java
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.json;
-
-import java.util.Iterator;
-
-
-/**
- * This provides static methods to convert an XML text into a JSONObject,
- * and to covert a JSONObject into an XML text.
- * @author JSON.org
- * @version 2011-02-11
- */
-public class XML {
-
- /** The Character '&'. */
- public static final Character AMP = new Character('&');
-
- /** The Character '''. */
- public static final Character APOS = new Character('\'');
-
- /** The Character '!'. */
- public static final Character BANG = new Character('!');
-
- /** The Character '='. */
- public static final Character EQ = new Character('=');
-
- /** The Character '>'. */
- public static final Character GT = new Character('>');
-
- /** The Character '<'. */
- public static final Character LT = new Character('<');
-
- /** The Character '?'. */
- public static final Character QUEST = new Character('?');
-
- /** The Character '"'. */
- public static final Character QUOT = new Character('"');
-
- /** The Character '/'. */
- public static final Character SLASH = new Character('/');
-
- /**
- * Replace special characters with XML escapes:
- * <pre>
- * & <small>(ampersand)</small> is replaced by &amp;
- * < <small>(less than)</small> is replaced by &lt;
- * > <small>(greater than)</small> is replaced by &gt;
- * " <small>(double quote)</small> is replaced by &quot;
- * </pre>
- * @param string The string to be escaped.
- * @return The escaped string.
- */
- public static String escape(String string) {
- StringBuffer sb = new StringBuffer();
- for (int i = 0, length = string.length(); i < length; i++) {
- char c = string.charAt(i);
- switch (c) {
- case '&':
- sb.append("&");
- break;
- case '<':
- sb.append("<");
- break;
- case '>':
- sb.append(">");
- break;
- case '"':
- sb.append(""");
- break;
- case '\'':
- sb.append("'");
- break;
- default:
- sb.append(c);
- }
- }
- return sb.toString();
- }
-
- /**
- * Throw an exception if the string contains whitespace.
- * Whitespace is not allowed in tagNames and attributes.
- * @param string
- * @throws JSONException
- */
- public static void noSpace(String string) throws JSONException {
- int i, length = string.length();
- if (length == 0) {
- throw new JSONException("Empty string.");
- }
- for (i = 0; i < length; i += 1) {
- if (Character.isWhitespace(string.charAt(i))) {
- throw new JSONException("'" + string +
- "' contains a space character.");
- }
- }
- }
-
- /**
- * Scan the content following the named tag, attaching it to the context.
- * @param x The XMLTokener containing the source string.
- * @param context The JSONObject that will include the new material.
- * @param name The tag name.
- * @return true if the close tag is processed.
- * @throws JSONException
- */
- private static boolean parse(XMLTokener x, JSONObject context,
- String name) throws JSONException {
- char c;
- int i;
- JSONObject jsonobject = null;
- String string;
- String tagName;
- Object token;
-
-// Test for and skip past these forms:
-// <!-- ... -->
-// <! ... >
-// <![ ... ]]>
-// <? ... ?>
-// Report errors for these forms:
-// <>
-// <=
-// <<
-
- token = x.nextToken();
-
-// <!
-
- if (token == BANG) {
- c = x.next();
- if (c == '-') {
- if (x.next() == '-') {
- x.skipPast("-->");
- return false;
- }
- x.back();
- } else if (c == '[') {
- token = x.nextToken();
- if ("CDATA".equals(token)) {
- if (x.next() == '[') {
- string = x.nextCDATA();
- if (string.length() > 0) {
- context.accumulate("content", string);
- }
- return false;
- }
- }
- throw x.syntaxError("Expected 'CDATA['");
- }
- i = 1;
- do {
- token = x.nextMeta();
- if (token == null) {
- throw x.syntaxError("Missing '>' after '<!'.");
- } else if (token == LT) {
- i += 1;
- } else if (token == GT) {
- i -= 1;
- }
- } while (i > 0);
- return false;
- } else if (token == QUEST) {
-
-// <?
-
- x.skipPast("?>");
- return false;
- } else if (token == SLASH) {
-
-// Close tag </
-
- token = x.nextToken();
- if (name == null) {
- throw x.syntaxError("Mismatched close tag " + token);
- }
- if (!token.equals(name)) {
- throw x.syntaxError("Mismatched " + name + " and " + token);
- }
- if (x.nextToken() != GT) {
- throw x.syntaxError("Misshaped close tag");
- }
- return true;
-
- } else if (token instanceof Character) {
- throw x.syntaxError("Misshaped tag");
-
-// Open tag <
-
- } else {
- tagName = (String)token;
- token = null;
- jsonobject = new JSONObject();
- for (;;) {
- if (token == null) {
- token = x.nextToken();
- }
-
-// attribute = value
-
- if (token instanceof String) {
- string = (String)token;
- token = x.nextToken();
- if (token == EQ) {
- token = x.nextToken();
- if (!(token instanceof String)) {
- throw x.syntaxError("Missing value");
- }
- jsonobject.accumulate(string,
- XML.stringToValue((String)token));
- token = null;
- } else {
- jsonobject.accumulate(string, "");
- }
-
-// Empty tag <.../>
-
- } else if (token == SLASH) {
- if (x.nextToken() != GT) {
- throw x.syntaxError("Misshaped tag");
- }
- if (jsonobject.length() > 0) {
- context.accumulate(tagName, jsonobject);
- } else {
- context.accumulate(tagName, "");
- }
- return false;
-
-// Content, between <...> and </...>
-
- } else if (token == GT) {
- for (;;) {
- token = x.nextContent();
- if (token == null) {
- if (tagName != null) {
- throw x.syntaxError("Unclosed tag " + tagName);
- }
- return false;
- } else if (token instanceof String) {
- string = (String)token;
- if (string.length() > 0) {
- jsonobject.accumulate("content",
- XML.stringToValue(string));
- }
-
-// Nested element
-
- } else if (token == LT) {
- if (parse(x, jsonobject, tagName)) {
- if (jsonobject.length() == 0) {
- context.accumulate(tagName, "");
- } else if (jsonobject.length() == 1 &&
- jsonobject.opt("content") != null) {
- context.accumulate(tagName,
- jsonobject.opt("content"));
- } else {
- context.accumulate(tagName, jsonobject);
- }
- return false;
- }
- }
- }
- } else {
- throw x.syntaxError("Misshaped tag");
- }
- }
- }
- }
-
-
- /**
- * Try to convert a string into a number, boolean, or null. If the string
- * can't be converted, return the string. This is much less ambitious than
- * JSONObject.stringToValue, especially because it does not attempt to
- * convert plus forms, octal forms, hex forms, or E forms lacking decimal
- * points.
- * @param string A String.
- * @return A simple JSON value.
- */
- public static Object stringToValue(String string) {
- if ("".equals(string)) {
- return string;
- }
- if ("true".equalsIgnoreCase(string)) {
- return Boolean.TRUE;
- }
- if ("false".equalsIgnoreCase(string)) {
- return Boolean.FALSE;
- }
- if ("null".equalsIgnoreCase(string)) {
- return JSONObject.NULL;
- }
- if ("0".equals(string)) {
- return new Integer(0);
- }
-
-// If it might be a number, try converting it. If that doesn't work,
-// return the string.
-
- try {
- char initial = string.charAt(0);
- boolean negative = false;
- if (initial == '-') {
- initial = string.charAt(1);
- negative = true;
- }
- if (initial == '0' && string.charAt(negative ? 2 : 1) == '0') {
- return string;
- }
- if ((initial >= '0' && initial <= '9')) {
- if (string.indexOf('.') >= 0) {
- return Double.valueOf(string);
- } else if (string.indexOf('e') < 0 && string.indexOf('E') < 0) {
- Long myLong = new Long(string);
- if (myLong.longValue() == myLong.intValue()) {
- return new Integer(myLong.intValue());
- } else {
- return myLong;
- }
- }
- }
- } catch (Exception ignore) {
- }
- return string;
- }
-
-
- /**
- * Convert a well-formed (but not necessarily valid) XML string into a
- * JSONObject. Some information may be lost in this transformation
- * because JSON is a data format and XML is a document format. XML uses
- * elements, attributes, and content text, while JSON uses unordered
- * collections of name/value pairs and arrays of values. JSON does not
- * does not like to distinguish between elements and attributes.
- * Sequences of similar elements are represented as JSONArrays. Content
- * text may be placed in a "content" member. Comments, prologs, DTDs, and
- * <code><[ [ ]]></code> are ignored.
- * @param string The source string.
- * @return A JSONObject containing the structured data from the XML string.
- * @throws JSONException
- */
- public static JSONObject toJSONObject(String string) throws JSONException {
- JSONObject jo = new JSONObject();
- XMLTokener x = new XMLTokener(string);
- while (x.more() && x.skipPast("<")) {
- parse(x, jo, null);
- }
- return jo;
- }
-
-
- /**
- * Convert a JSONObject into a well-formed, element-normal XML string.
- * @param object A JSONObject.
- * @return A string.
- * @throws JSONException
- */
- public static String toString(Object object) throws JSONException {
- return toString(object, null);
- }
-
-
- /**
- * Convert a JSONObject into a well-formed, element-normal XML string.
- * @param object A JSONObject.
- * @param tagName The optional name of the enclosing tag.
- * @return A string.
- * @throws JSONException
- */
- public static String toString(Object object, String tagName)
- throws JSONException {
- StringBuffer sb = new StringBuffer();
- int i;
- JSONArray ja;
- JSONObject jo;
- String key;
- Iterator keys;
- int length;
- String string;
- Object value;
- if (object instanceof JSONObject) {
-
-// Emit <tagName>
-
- if (tagName != null) {
- sb.append('<');
- sb.append(tagName);
- sb.append('>');
- }
-
-// Loop thru the keys.
-
- jo = (JSONObject)object;
- keys = jo.keys();
- while (keys.hasNext()) {
- key = keys.next().toString();
- value = jo.opt(key);
- if (value == null) {
- value = "";
- }
- if (value instanceof String) {
- string = (String)value;
- } else {
- string = null;
- }
-
-// Emit content in body
-
- if ("content".equals(key)) {
- if (value instanceof JSONArray) {
- ja = (JSONArray)value;
- length = ja.length();
- for (i = 0; i < length; i += 1) {
- if (i > 0) {
- sb.append('\n');
- }
- sb.append(escape(ja.get(i).toString()));
- }
- } else {
- sb.append(escape(value.toString()));
- }
-
-// Emit an array of similar keys
-
- } else if (value instanceof JSONArray) {
- ja = (JSONArray)value;
- length = ja.length();
- for (i = 0; i < length; i += 1) {
- value = ja.get(i);
- if (value instanceof JSONArray) {
- sb.append('<');
- sb.append(key);
- sb.append('>');
- sb.append(toString(value));
- sb.append("</");
- sb.append(key);
- sb.append('>');
- } else {
- sb.append(toString(value, key));
- }
- }
- } else if ("".equals(value)) {
- sb.append('<');
- sb.append(key);
- sb.append("/>");
-
-// Emit a new tag <k>
-
- } else {
- sb.append(toString(value, key));
- }
- }
- if (tagName != null) {
-
-// Emit the </tagname> close tag
-
- sb.append("</");
- sb.append(tagName);
- sb.append('>');
- }
- return sb.toString();
-
-// XML does not have good support for arrays. If an array appears in a place
-// where XML is lacking, synthesize an <array> element.
-
- } else {
- if (object.getClass().isArray()) {
- object = new JSONArray(object);
- }
- if (object instanceof JSONArray) {
- ja = (JSONArray)object;
- length = ja.length();
- for (i = 0; i < length; i += 1) {
- sb.append(toString(ja.opt(i), tagName == null ? "array" : tagName));
- }
- return sb.toString();
- } else {
- string = (object == null) ? "null" : escape(object.toString());
- return (tagName == null) ? "\"" + string + "\"" :
- (string.length() == 0) ? "<" + tagName + "/>" :
- "<" + tagName + ">" + string + "</" + tagName + ">";
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/XMLTokener.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/XMLTokener.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/XMLTokener.java
deleted file mode 100644
index c9f9154..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/XMLTokener.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.json;
-
-/**
- * The XMLTokener extends the JSONTokener to provide additional methods
- * for the parsing of XML texts.
- * @author JSON.org
- * @version 2010-12-24
- */
-public class XMLTokener extends JSONTokener {
-
-
- /** The table of entity values. It initially contains Character values for
- * amp, apos, gt, lt, quot.
- */
- public static final java.util.HashMap entity;
-
- static {
- entity = new java.util.HashMap(8);
- entity.put("amp", XML.AMP);
- entity.put("apos", XML.APOS);
- entity.put("gt", XML.GT);
- entity.put("lt", XML.LT);
- entity.put("quot", XML.QUOT);
- }
-
- /**
- * Construct an XMLTokener from a string.
- * @param s A source string.
- */
- public XMLTokener(String s) {
- super(s);
- }
-
- /**
- * Get the text in the CDATA block.
- * @return The string up to the <code>]]></code>.
- * @throws JSONException If the <code>]]></code> is not found.
- */
- public String nextCDATA() throws JSONException {
- char c;
- int i;
- StringBuffer sb = new StringBuffer();
- for (;;) {
- c = next();
- if (end()) {
- throw syntaxError("Unclosed CDATA");
- }
- sb.append(c);
- i = sb.length() - 3;
- if (i >= 0 && sb.charAt(i) == ']' &&
- sb.charAt(i + 1) == ']' && sb.charAt(i + 2) == '>') {
- sb.setLength(i);
- return sb.toString();
- }
- }
- }
-
-
- /**
- * Get the next XML outer token, trimming whitespace. There are two kinds
- * of tokens: the '<' character which begins a markup tag, and the content
- * text between markup tags.
- *
- * @return A string, or a '<' Character, or null if there is no more
- * source text.
- * @throws JSONException
- */
- public Object nextContent() throws JSONException {
- char c;
- StringBuffer sb;
- do {
- c = next();
- } while (Character.isWhitespace(c));
- if (c == 0) {
- return null;
- }
- if (c == '<') {
- return XML.LT;
- }
- sb = new StringBuffer();
- for (;;) {
- if (c == '<' || c == 0) {
- back();
- return sb.toString().trim();
- }
- if (c == '&') {
- sb.append(nextEntity(c));
- } else {
- sb.append(c);
- }
- c = next();
- }
- }
-
-
- /**
- * Return the next entity. These entities are translated to Characters:
- * <code>& ' > < "</code>.
- * @param ampersand An ampersand character.
- * @return A Character or an entity String if the entity is not recognized.
- * @throws JSONException If missing ';' in XML entity.
- */
- public Object nextEntity(char ampersand) throws JSONException {
- StringBuffer sb = new StringBuffer();
- for (;;) {
- char c = next();
- if (Character.isLetterOrDigit(c) || c == '#') {
- sb.append(Character.toLowerCase(c));
- } else if (c == ';') {
- break;
- } else {
- throw syntaxError("Missing ';' in XML entity: &" + sb);
- }
- }
- String string = sb.toString();
- Object object = entity.get(string);
- return object != null ? object : ampersand + string + ";";
- }
-
-
- /**
- * Returns the next XML meta token. This is used for skipping over <!...>
- * and <?...?> structures.
- * @return Syntax characters (<code>< > / = ! ?</code>) are returned as
- * Character, and strings and names are returned as Boolean. We don't care
- * what the values actually are.
- * @throws JSONException If a string is not properly closed or if the XML
- * is badly structured.
- */
- public Object nextMeta() throws JSONException {
- char c;
- char q;
- do {
- c = next();
- } while (Character.isWhitespace(c));
- switch (c) {
- case 0:
- throw syntaxError("Misshaped meta tag");
- case '<':
- return XML.LT;
- case '>':
- return XML.GT;
- case '/':
- return XML.SLASH;
- case '=':
- return XML.EQ;
- case '!':
- return XML.BANG;
- case '?':
- return XML.QUEST;
- case '"':
- case '\'':
- q = c;
- for (;;) {
- c = next();
- if (c == 0) {
- throw syntaxError("Unterminated string");
- }
- if (c == q) {
- return Boolean.TRUE;
- }
- }
- default:
- for (;;) {
- c = next();
- if (Character.isWhitespace(c)) {
- return Boolean.TRUE;
- }
- switch (c) {
- case 0:
- case '<':
- case '>':
- case '/':
- case '=':
- case '!':
- case '?':
- case '"':
- case '\'':
- back();
- return Boolean.TRUE;
- }
- }
- }
- }
-
-
- /**
- * Get the next XML Token. These tokens are found inside of angle
- * brackets. It may be one of these characters: <code>/ > = ! ?</code> or it
- * may be a string wrapped in single quotes or double quotes, or it may be a
- * name.
- * @return a String or a Character.
- * @throws JSONException If the XML is not well formed.
- */
- public Object nextToken() throws JSONException {
- char c;
- char q;
- StringBuffer sb;
- do {
- c = next();
- } while (Character.isWhitespace(c));
- switch (c) {
- case 0:
- throw syntaxError("Misshaped element");
- case '<':
- throw syntaxError("Misplaced '<'");
- case '>':
- return XML.GT;
- case '/':
- return XML.SLASH;
- case '=':
- return XML.EQ;
- case '!':
- return XML.BANG;
- case '?':
- return XML.QUEST;
-
-// Quoted string
-
- case '"':
- case '\'':
- q = c;
- sb = new StringBuffer();
- for (;;) {
- c = next();
- if (c == 0) {
- throw syntaxError("Unterminated string");
- }
- if (c == q) {
- return sb.toString();
- }
- if (c == '&') {
- sb.append(nextEntity(c));
- } else {
- sb.append(c);
- }
- }
- default:
-
-// Name
-
- sb = new StringBuffer();
- for (;;) {
- sb.append(c);
- c = next();
- if (Character.isWhitespace(c)) {
- return sb.toString();
- }
- switch (c) {
- case 0:
- return sb.toString();
- case '>':
- case '/':
- case '=':
- case '!':
- case '?':
- case '[':
- case ']':
- back();
- return sb.toString();
- case '<':
- case '"':
- case '\'':
- throw syntaxError("Bad character in a name");
- }
- }
- }
- }
-
-
- /**
- * Skip characters until past the requested string.
- * If it is not found, we are left at the end of the source with a result of false.
- * @param to A string to skip past.
- * @throws JSONException
- */
- public boolean skipPast(String to) throws JSONException {
- boolean b;
- char c;
- int i;
- int j;
- int offset = 0;
- int length = to.length();
- char[] circle = new char[length];
-
- /*
- * First fill the circle buffer with as many characters as are in the
- * to string. If we reach an early end, bail.
- */
-
- for (i = 0; i < length; i += 1) {
- c = next();
- if (c == 0) {
- return false;
- }
- circle[i] = c;
- }
- /*
- * We will loop, possibly for all of the remaining characters.
- */
- for (;;) {
- j = offset;
- b = true;
- /*
- * Compare the circle buffer with the to string.
- */
- for (i = 0; i < length; i += 1) {
- if (circle[j] != to.charAt(i)) {
- b = false;
- break;
- }
- j += 1;
- if (j >= length) {
- j -= length;
- }
- }
- /*
- * If we exit the loop with b intact, then victory is ours.
- */
- if (b) {
- return true;
- }
- /*
- * Get the next character. If there isn't one, then defeat is ours.
- */
- c = next();
- if (c == 0) {
- return false;
- }
- /*
- * Shove the character in the circle buffer and advance the
- * circle offset. The offset is mod n.
- */
- circle[offset] = c;
- offset += 1;
- if (offset >= length) {
- offset -= length;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/LogWriter.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/LogWriter.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/LogWriter.java
deleted file mode 100644
index c0bb013..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/LogWriter.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.log;
-
-/**
- * interface LogWriter
- *
- * LogWriter interface for Pulse Logging.
- *
- * @since GemFire 7.0.1
- *
- */
-public interface LogWriter {
- /**
- * Returns true if "severe" log messages are enabled. Returns false if
- * "severe" log messages are disabled.
- */
- public boolean severeEnabled();
-
- /**
- * Writes both a message and exception to this writer. The message level is
- * "severe".
- */
- public void severe(String msg, Throwable ex);
-
- /**
- * Writes a message to this writer. The message level is "severe".
- */
- public void severe(String msg);
-
- /**
- * Writes an exception to this writer. The exception level is "severe".
- */
- public void severe(Throwable ex);
-
- /**
- * Returns true if "error" log messages are enabled. Returns false if "error"
- * log messages are disabled.
- */
- // public boolean errorEnabled();
- /**
- * Writes both a message and exception to this writer. The message level is
- * "error".
- */
- // public void error(String msg, Throwable ex);
- /**
- * Writes a message to this writer. The message level is "error".
- */
- // public void error(String msg);
- /**
- * Writes an exception to this writer. The exception level is "error".
- */
- // public void error(Throwable ex);
- /**
- * Returns true if "warning" log messages are enabled. Returns false if
- * "warning" log messages are disabled.
- */
- public boolean warningEnabled();
-
- /**
- * Writes both a message and exception to this writer. The message level is
- * "warning".
- */
- public void warning(String msg, Throwable ex);
-
- /**
- * Writes a message to this writer. The message level is "warning".
- */
- public void warning(String msg);
-
- /**
- * Writes an exception to this writer. The exception level is "warning".
- */
- public void warning(Throwable ex);
-
- /**
- * Returns true if "info" log messages are enabled. Returns false if "info"
- * log messages are disabled.
- */
- public boolean infoEnabled();
-
- /**
- * Writes both a message and exception to this writer. The message level is
- * "information".
- */
- public void info(String msg, Throwable ex);
-
- /**
- * Writes a message to this writer. The message level is "information".
- */
- public void info(String msg);
-
- /**
- * Writes an exception to this writer. The exception level is "information".
- */
- public void info(Throwable ex);
-
- /**
- * Returns true if "config" log messages are enabled. Returns false if
- * "config" log messages are disabled.
- */
- public boolean configEnabled();
-
- /**
- * Writes both a message and exception to this writer. The message level is
- * "config".
- */
- public void config(String msg, Throwable ex);
-
- /**
- * Writes a message to this writer. The message level is "config".
- */
- public void config(String msg);
-
- /**
- * Writes an exception to this writer. The exception level is "config".
- */
- public void config(Throwable ex);
-
- /**
- * Returns true if "fine" log messages are enabled. Returns false if "fine"
- * log messages are disabled.
- */
- public boolean fineEnabled();
-
- /**
- * Writes both a message and exception to this writer. The message level is
- * "fine".
- */
- public void fine(String msg, Throwable ex);
-
- /**
- * Writes a message to this writer. The message level is "fine".
- */
- public void fine(String msg);
-
- /**
- * Writes an exception to this writer. The exception level is "fine".
- */
- public void fine(Throwable ex);
-
- /**
- * Returns true if "finer" log messages are enabled. Returns false if "finer"
- * log messages are disabled.
- */
- public boolean finerEnabled();
-
- /**
- * Writes both a message and exception to this writer. The message level is
- * "finer".
- */
- public void finer(String msg, Throwable ex);
-
- /**
- * Writes a message to this writer. The message level is "finer".
- */
- public void finer(String msg);
-
- /**
- * Writes an exception to this writer. The exception level is "finer".
- */
- public void finer(Throwable ex);
-
- /**
- * Log a method entry.
- * <p>
- * The logging is done using the <code>finer</code> level. The string message
- * will start with <code>"ENTRY"</code> and include the class and method
- * names.
- *
- * @param sourceClass
- * Name of class that issued the logging request.
- * @param sourceMethod
- * Name of the method that issued the logging request.
- */
- public void entering(String sourceClass, String sourceMethod);
-
- /**
- * Log a method return.
- * <p>
- * The logging is done using the <code>finer</code> level. The string message
- * will start with <code>"RETURN"</code> and include the class and method
- * names.
- *
- * @param sourceClass
- * Name of class that issued the logging request.
- * @param sourceMethod
- * Name of the method that issued the logging request.
- */
- public void exiting(String sourceClass, String sourceMethod);
-
- /**
- * Log throwing an exception.
- * <p>
- * Use to log that a method is terminating by throwing an exception. The
- * logging is done using the <code>finer</code> level.
- * <p>
- * This is a convenience method that could be done instead by calling
- * {@link #finer(String, Throwable)}. The string message will start with
- * <code>"THROW"</code> and include the class and method names.
- *
- * @param sourceClass
- * Name of class that issued the logging request.
- * @param sourceMethod
- * Name of the method that issued the logging request.
- * @param thrown
- * The Throwable that is being thrown.
- */
- public void throwing(String sourceClass, String sourceMethod, Throwable thrown);
-
- /**
- * Returns true if "finest" log messages are enabled. Returns false if
- * "finest" log messages are disabled.
- */
- public boolean finestEnabled();
-
- /**
- * Writes both a message and exception to this writer. The message level is
- * "finest".
- */
- public void finest(String msg, Throwable ex);
-
- /**
- * Writes a message to this writer. The message level is "finest".
- */
- public void finest(String msg);
-
- /**
- * Writes an exception to this writer. The exception level is "finest".
- */
- public void finest(Throwable ex);
-
- /**
- * Returns a 1.4 logging handler that can be used to direct application output
- * to this GemFire logger using the standard JDK logger APIs. Each time this
- * method is called it creates a new instance of a Handler so care should be
- * taken to not call this method too often.
- */
- // public Handler getHandler();
-
- /**
- * A mechanism for accessing the abstraction layer used for
- * internationalization.
- *
- * @return LogWriterI18n
- */
- // public LogWriterI18n convertToLogWriterI18n();
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/MessageFormatter.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/MessageFormatter.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/MessageFormatter.java
deleted file mode 100644
index cc57670..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/MessageFormatter.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.log;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.logging.Formatter;
-import java.util.logging.Handler;
-import java.util.logging.LogRecord;
-
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-
-/**
- * Class MessageFormatter
- *
- * MessageFormatter is the custom formatter class for formatting the log
- * messages.
- *
- * @since GemFire version 7.0.1
- */
-public class MessageFormatter extends Formatter {
-
- public MessageFormatter() {
- super();
- }
-
- @Override
- public String format(LogRecord record) {
- DateFormat df = new SimpleDateFormat(Repository.get().getPulseConfig()
- .getLogDatePattern());
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
-
- pw.println();
- pw.print("[");
- pw.print(record.getLevel().getName());
- pw.print(" ");
- pw.print(df.format(new Date(record.getMillis())));
- String threadName = Thread.currentThread().getName();
- if (threadName != null) {
- pw.print(" ");
- pw.print(threadName);
- }
- pw.print(" tid=0x");
- pw.print(Long.toHexString(Thread.currentThread().getId()));
- pw.print("] ");
- pw.print("(msgTID=");
- pw.print(record.getThreadID());
-
- pw.print(" msgSN=");
- pw.print(record.getSequenceNumber());
-
- pw.print(") ");
-
- pw.println("[" + PulseConstants.APP_NAME + "]");
-
- pw.println("[" + record.getLoggerName() + "]");
-
- pw.println(record.getMessage());
-
- if (record.getThrown() != null) {
- record.getThrown().printStackTrace(pw);
- }
- pw.close();
- try {
- sw.close();
- } catch (IOException ignore) {
- }
- String result = sw.toString();
- return result;
- }
-
- public String getHead(Handler h) {
- return super.getHead(h);
- }
-
- public String getTail(Handler h) {
- return super.getTail(h);
- }
-} // End of Class MessageFormatter
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/PulseLogWriter.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/PulseLogWriter.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/PulseLogWriter.java
deleted file mode 100644
index a2fb327..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/PulseLogWriter.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.log;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.logging.FileHandler;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConfig;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-
-/**
- * Class PulseLogWriter
- *
- * PulseLogWriter is the implementation of LogWriter.
- *
- * @since GemFire 7.0.1
- *
- */
-public class PulseLogWriter implements LogWriter {
-
- // Log File handle Object
- private FileHandler fileHandler;
-
- // Message Formatter Object
- private static MessageFormatter messageformatter;
-
- // pulse log writer
- private static PulseLogWriter pulseLogger = null;
-
- // Logger Object
- private Logger logger;
-
- private PulseLogWriter() {
- PulseConfig pulseConfig = Repository.get().getPulseConfig();
- // Create Logger
- logger = Logger.getLogger(this.getClass().getName());
-
- // Set minimum log level to level passed
- logger.setLevel(pulseConfig.getLogLevel());
-
- try {
- // Get file handler to log messages into log file.
- if (fileHandler == null) {
- fileHandler = new FileHandler(
- pulseConfig.getLogFileFullName(),
- pulseConfig.getLogFileSize(),
- pulseConfig.getLogFileCount(),
- pulseConfig.getLogAppend());
-
- // Log Message Formatter
- messageformatter = new MessageFormatter();
- fileHandler.setFormatter(messageformatter);
- }
-
- // Add File Handler to logger object
- logger.addHandler(fileHandler);
- } catch (SecurityException e) {
- logger.setUseParentHandlers(true);
- e.printStackTrace();
- } catch (IOException e) {
- logger.setUseParentHandlers(true);
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * @param jsonErr
- * @param errorData
- */
- public void logJSONError(Exception jsonErr, Object errorData) {
-
- // print details of thrown exception and data that couldn't be converted to
- // json
- if (this.fineEnabled()) {
-
- // write errors
- StringWriter swBuffer = new StringWriter();
- PrintWriter prtWriter = new PrintWriter(swBuffer);
- jsonErr.printStackTrace(prtWriter);
- this.fine("JSON Error Details : " + swBuffer.toString() + "\n");
-
- this.fine("Erroneous Data : "
- + ((errorData != null) ? errorData.toString()
- : "Not Available for output") + "\n");
- }
- }
-
- public static synchronized PulseLogWriter getLogger() {
- if (null == pulseLogger) {
- pulseLogger = new PulseLogWriter();
- }
- return pulseLogger;
- }
-
- @Override
- public boolean severeEnabled() {
- return logger.isLoggable(Level.SEVERE);
- }
-
- @Override
- public void severe(String msg, Throwable ex) {
- logger.logp(Level.SEVERE, "", "", msg, ex);
- }
-
- @Override
- public void severe(String msg) {
- logger.severe(msg);
- }
-
- @Override
- public void severe(Throwable ex) {
- logger.logp(Level.SEVERE, "", "", "", ex);
- }
-
- /*
- @Override
- public boolean errorEnabled() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public void error(String msg, Throwable ex) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void error(String msg) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void error(Throwable ex) {
- // TODO Auto-generated method stub
-
- }
- */
-
- @Override
- public boolean warningEnabled() {
- return logger.isLoggable(Level.WARNING);
- }
-
- @Override
- public void warning(String msg, Throwable ex) {
- logger.logp(Level.WARNING, "", "", msg, ex);
- }
-
- @Override
- public void warning(String msg) {
- logger.warning(msg);
- }
-
- @Override
- public void warning(Throwable ex) {
- logger.logp(Level.WARNING, "", "", "", ex);
- }
-
- @Override
- public boolean infoEnabled() {
- return logger.isLoggable(Level.INFO);
- }
-
- @Override
- public void info(String msg, Throwable ex) {
- logger.logp(Level.INFO, "", "", msg, ex);
- }
-
- @Override
- public void info(String msg) {
- logger.info(msg);
- }
-
- @Override
- public void info(Throwable ex) {
- logger.logp(Level.WARNING, "", "", "", ex);
- }
-
- @Override
- public boolean configEnabled() {
- return logger.isLoggable(Level.CONFIG);
- }
-
- @Override
- public void config(String msg, Throwable ex) {
- logger.logp(Level.CONFIG, "", "", msg, ex);
- }
-
- @Override
- public void config(String msg) {
- logger.config(msg);
- }
-
- @Override
- public void config(Throwable ex) {
- logger.logp(Level.CONFIG, "", "", "", ex);
- }
-
- @Override
- public boolean fineEnabled() {
- return logger.isLoggable(Level.FINE);
- }
-
- @Override
- public void fine(String msg, Throwable ex) {
- logger.logp(Level.FINE, "", "", msg, ex);
- }
-
- @Override
- public void fine(String msg) {
- logger.fine(msg);
- }
-
- @Override
- public void fine(Throwable ex) {
- logger.logp(Level.FINE, "", "", "", ex);
- }
-
- @Override
- public boolean finerEnabled() {
- return logger.isLoggable(Level.FINER);
- }
-
- @Override
- public void finer(String msg, Throwable ex) {
- logger.logp(Level.FINER, "", "", msg, ex);
- }
-
- @Override
- public void finer(String msg) {
- logger.finer(msg);
- }
-
- @Override
- public void finer(Throwable ex) {
- logger.logp(Level.FINER, "", "", "", ex);
- }
-
- @Override
- public void entering(String sourceClass, String sourceMethod) {
- logger.entering(sourceClass, sourceMethod);
- }
-
- @Override
- public void exiting(String sourceClass, String sourceMethod) {
- logger.exiting(sourceClass, sourceMethod);
- }
-
- @Override
- public void throwing(String sourceClass, String sourceMethod, Throwable thrown) {
- logger.throwing(sourceClass, sourceMethod, thrown);
- }
-
- @Override
- public boolean finestEnabled() {
- return logger.isLoggable(Level.FINEST);
- }
-
- @Override
- public void finest(String msg, Throwable ex) {
- logger.logp(Level.FINEST, "", "", msg, ex);
- }
-
- @Override
- public void finest(String msg) {
- logger.finest(msg);
- }
-
- @Override
- public void finest(Throwable ex) {
- logger.logp(Level.FINEST, "", "", "", ex);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/PulseLogger.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/PulseLogger.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/PulseLogger.java
deleted file mode 100644
index ab25c9f..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/log/PulseLogger.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.log;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.logging.FileHandler;
-import java.util.logging.Formatter;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-
-/**
- * Class PulseLogger
- *
- * PulseLogger is the custom logger class for Pulse Web Application. It logs
- * messages to the file in custom format.
- *
- * @since GemFire version 7.0.Beta
- */
-public class PulseLogger {
-
- // Pulse Application Log File
- private static final String LOG_FILE_NAME = PulseConstants.PULSE_LOG_FILE_LOCATION
- + "/" + PulseConstants.PULSE_LOG_FILE;
-
- // Date pattern to be used in log messages
- public static final String LOG_MESSAGE_DATE_PATTERN = "dd/MM/yyyy hh:mm:ss.SSS";
-
- // The log file size is set to 1MB.
- public static final int FILE_SIZE = 1024 * 1024;
-
- // The log file count set to 1 files.
- public static final int FILE_COUNT = 5;
-
- // Append logs is set to true.
- public static final boolean FLAG_APPEND = true;
-
- // Log File handle Object
- private static FileHandler fileHandler;
-
- // Message Formatter Object
- private static MessageFormatter messageformatter;
-
- // Logger Object
- private static Logger logger;
-
- public static Logger getLogger(String name) {
- // Create Logger
- logger = Logger.getLogger(name);
-
- // Set minimum log level to inform
- logger.setLevel(Level.INFO);
-
- // Get file handler to log messages into log file.
- try {
- // fileHandler = new FileHandler(LOG_FILE_NAME, FILE_SIZE, FILE_COUNT,
- // FLAG_APPEND);
- fileHandler = new FileHandler(LOG_FILE_NAME, FLAG_APPEND);
-
- // Log Message Formatter
- messageformatter = new MessageFormatter();
-
- fileHandler.setFormatter(messageformatter);
-
- // Add File Handler to logger object
- logger.addHandler(fileHandler);
-
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return logger;
- }
-
- /**
- * Class MessageFormatter
- *
- * MessageFormatter is the custom formatter class for formatting the log
- * messages.
- *
- * @since GemFire version 7.0.Beta 2012-09-23
- */
- private static class MessageFormatter extends Formatter {
-
- public MessageFormatter() {
- super();
- }
-
- @Override
- public String format(LogRecord record) {
- // Set DateFormat
- DateFormat df = new SimpleDateFormat(PulseLogger.LOG_MESSAGE_DATE_PATTERN);
- StringBuilder builder = new StringBuilder(1000);
-
- // Format Log Message
- builder.append(df.format(new Date(record.getMillis()))).append(" - ");
- builder.append("[ " + PulseConstants.APP_NAME + " ] - ");
- builder.append("[").append(record.getSourceClassName()).append(".");
- builder.append(record.getSourceMethodName()).append("] - ");
- builder.append("[").append(record.getLevel()).append("] - ");
- builder.append(formatMessage(record));
- builder.append(System.getProperty("line.separator"));
-
- return builder.toString();
- }
-
- public String getHead(Handler h) {
- return super.getHead(h);
- }
-
- public String getTail(Handler h) {
- return super.getTail(h);
- }
- } // End of Class MessageFormatter
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/security/GemFireAuthentication.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/security/GemFireAuthentication.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/security/GemFireAuthentication.java
deleted file mode 100644
index 391ad39..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/security/GemFireAuthentication.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.vmware.gemfire.tools.pulse.internal.security;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.management.remote.JMXConnector;
-
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.log.PulseLogWriter;
-
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.SpringSecurityCoreVersion;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
-
-/**
- * Spring security authentication object for GemFire
- * <p>
- * To use GemFire Integrated Security Model set Spring Application Profile to pulse.authentication.gemfire
- * <p>
- * 1. Authentication :
- * 1.a GemFire profile creates JMX connection with given credentials at the login time.
- * 1.b Successful connect is considered as Successful Authentication for Pulse WebApp
- * <p>
- * <p>
- * 2. Authorization :
- * 2.a Using newly created authenticated connection AccessControlMXBean is called to get authentication
- * levels. See @See {@link #populateAuthorities(JMXConnector)}. This sets Spring Security Authorities
- * 2.b DataBrowser end-points are required to be authorized against Spring Granted Authority
- * @since GemFire version 9.0
- */
-public class GemFireAuthentication extends UsernamePasswordAuthenticationToken {
-
- private final static PulseLogWriter logger = PulseLogWriter.getLogger();
-
- private JMXConnector jmxc = null;
-
- public GemFireAuthentication(Object principal, Object credentials, Collection<GrantedAuthority> list, JMXConnector jmxc) {
- super(principal, credentials, list);
- this.jmxc = jmxc;
- }
-
- private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
-
- public static ArrayList<GrantedAuthority> populateAuthorities(JMXConnector jmxc) {
- ObjectName name;
- ArrayList<GrantedAuthority> authorities = new ArrayList<>();
- try {
- name = new ObjectName(PulseConstants.OBJECT_NAME_ACCESSCONTROL_MBEAN);
- MBeanServerConnection mbeanServer = jmxc.getMBeanServerConnection();
-
- for (String role : PulseConstants.PULSE_ROLES) {
- Object[] params = role.split(":");
- String[] signature = new String[] { String.class.getCanonicalName(), String.class.getCanonicalName() };
- boolean result = (Boolean) mbeanServer.invoke(name, "authorize", params, signature);
- if (result) {
- authorities.add(new SimpleGrantedAuthority(role));
- }
- }
- }
- catch (Exception e) {
- throw new RuntimeException(e.getMessage(), e);
- }
-
- return authorities;
-
- }
-
- public JMXConnector getJmxc() {
- return jmxc;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/security/GemFireAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/security/GemFireAuthenticationProvider.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/security/GemFireAuthenticationProvider.java
deleted file mode 100644
index 2d7d606..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/security/GemFireAuthenticationProvider.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.vmware.gemfire.tools.pulse.internal.security;
-
-import java.util.Collection;
-import javax.management.remote.JMXConnector;
-
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.log.PulseLogWriter;
-
-import org.springframework.security.authentication.AuthenticationProvider;
-import org.springframework.security.authentication.AuthenticationServiceException;
-import org.springframework.security.authentication.BadCredentialsException;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.AuthenticationException;
-import org.springframework.security.core.GrantedAuthority;
-
-/**
- * Spring security AuthenticationProvider for GemFire. It connects to gemfire manager using given credentials.
- * Successful connect is treated as successful authentication and web user is authenticated
- * @since GemFire version 9.0
- */
-public class GemFireAuthenticationProvider implements AuthenticationProvider {
-
- private final static PulseLogWriter LOGGER = PulseLogWriter.getLogger();
-
- public GemFireAuthenticationProvider() {
- System.out.println("here");
- }
-
- @Override
- public Authentication authenticate(Authentication authentication) throws AuthenticationException {
-
- if (authentication instanceof GemFireAuthentication) {
- GemFireAuthentication gemAuth = (GemFireAuthentication) authentication;
- LOGGER.fine("GemAuthentication is connected? = " + gemAuth.getJmxc());
- if (gemAuth.getJmxc() != null && gemAuth.isAuthenticated()) return gemAuth;
- }
-
- String name = authentication.getName();
- String password = authentication.getCredentials().toString();
-
- try {
- LOGGER.fine("Connecting to GemFire with user=" + name);
- JMXConnector jmxc = Repository.get().getCluster(name, password).connectToGemFire();
- if (jmxc != null) {
- Collection<GrantedAuthority> list = GemFireAuthentication.populateAuthorities(jmxc);
- GemFireAuthentication auth = new GemFireAuthentication(authentication.getPrincipal(),
- authentication.getCredentials(), list, jmxc);
- LOGGER.fine("For user " + name + " authList=" + list);
- return auth;
- } else {
- throw new AuthenticationServiceException("JMX Connection unavailable");
- }
- } catch (Exception e) {
- throw new BadCredentialsException("Error connecting to GemFire JMX Server", e);
- }
- }
-
- @Override
- public boolean supports(Class<?> authentication) {
- return authentication.equals(UsernamePasswordAuthenticationToken.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/security/LogoutHandler.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/security/LogoutHandler.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/security/LogoutHandler.java
deleted file mode 100644
index 7309f90..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/security/LogoutHandler.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.vmware.gemfire.tools.pulse.internal.security;
-
-import java.io.IOException;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.log.PulseLogWriter;
-
-import org.springframework.security.core.Authentication;
-import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
-import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler;
-
-/**
- * Handler is used to close jmx connection maintained at user-level
- *
- */
-public class LogoutHandler extends SimpleUrlLogoutSuccessHandler implements LogoutSuccessHandler {
-
- public LogoutHandler(String defaultTargetURL) {
- this.setDefaultTargetUrl(defaultTargetURL);
- }
-
- public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
- throws IOException, ServletException {
- PulseLogWriter LOGGER = PulseLogWriter.getLogger();
- LOGGER.fine("Invoked #LogoutHandler ...");
- if (Repository.get().isUseGemFireCredentials()) {
- GemFireAuthentication gemauthentication = (GemFireAuthentication) authentication;
- if(gemauthentication!=null) {
- gemauthentication.getJmxc().close();
- LOGGER.info("#LogoutHandler : Closing GemFireAuthentication JMX Connection...");
- }
- }
- super.onLogoutSuccess(request, response, authentication);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterDetailsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterDetailsService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterDetailsService.java
deleted file mode 100644
index 9ae228d..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterDetailsService.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.text.DecimalFormat;
-
-/**
- * Class ClusterDetailsService
- *
- * This service class has implementation for providing cluster's basic
- * statistical data.
- *
- * @since GemFire version 7.5
- */
-
-@Component
-@Service("ClusterDetails")
-@Scope("singleton")
-public class ClusterDetailsService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- String userName = request.getUserPrincipal().getName();
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- Cluster.Alert[] alertsList = cluster.getAlertsList();
- int severeAlertCount = 0;
- int errorAlertCount = 0;
- int warningAlertCount = 0;
- int infoAlertCount = 0;
-
- for (Cluster.Alert alertObj : alertsList) {
- if (alertObj.getSeverity() == Cluster.Alert.SEVERE) {
- severeAlertCount++;
- } else if (alertObj.getSeverity() == Cluster.Alert.ERROR) {
- errorAlertCount++;
- } else if (alertObj.getSeverity() == Cluster.Alert.WARNING) {
- warningAlertCount++;
- } else {
- infoAlertCount++;
- }
- }
- // getting basic details of Cluster
- responseJSON.put("clusterName", cluster.getServerName());
- responseJSON.put("severeAlertCount", severeAlertCount);
- responseJSON.put("errorAlertCount", errorAlertCount);
- responseJSON.put("warningAlertCount", warningAlertCount);
- responseJSON.put("infoAlertCount", infoAlertCount);
-
- responseJSON.put("totalMembers", cluster.getMemberCount());
- responseJSON.put("servers", cluster.getServerCount());
- responseJSON.put("clients", cluster.getClientConnectionCount());
- responseJSON.put("locators", cluster.getLocatorCount());
- responseJSON.put("totalRegions", cluster.getTotalRegionCount());
- Long heapSize = cluster.getTotalHeapSize();
-
- DecimalFormat df2 = new DecimalFormat(
- PulseConstants.DECIMAL_FORMAT_PATTERN);
- Double heapS = heapSize.doubleValue() / 1024;
- responseJSON.put("totalHeap", Double.valueOf(df2.format(heapS)));
- responseJSON.put("functions", cluster.getRunningFunctionCount());
- responseJSON.put("uniqueCQs", cluster.getRegisteredCQCount());
- responseJSON.put("subscriptions", cluster.getSubscriptionCount());
- responseJSON.put("txnCommitted", cluster.getTxnCommittedCount());
- responseJSON.put("txnRollback", cluster.getTxnRollbackCount());
- responseJSON.put("userName", userName);
-
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterDiskThroughputService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterDiskThroughputService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterDiskThroughputService.java
deleted file mode 100644
index 62de9a4..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterDiskThroughputService.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class ClusterDiskThroughput This class contains implementations for getting
- * cluster's current disk throughput details and its trend over time
- *
- * @since GemFire version 7.0.Beta
- */
-
-@Component
-@Service("ClusterDiskThroughput")
-@Scope("singleton")
-public class ClusterDiskThroughputService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // cluster's Throughout Writes trend added to json response object
- // CircularFifoBuffer throughoutWritesTrend =
- // cluster.getThroughoutWritesTrend();
- double currentThroughputWrites = cluster.getDiskWritesRate();
- double currentThroughputReads = cluster.getDiskReadsRate();
-
- responseJSON.put("currentThroughputReads", currentThroughputReads);
- responseJSON.put("throughputReads",
- mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_THROUGHPUT_READS)));
-
- responseJSON.put("currentThroughputWrites", currentThroughputWrites);
- responseJSON.put("throughputWrites",
- mapper.valueToTree( cluster.getStatisticTrend(Cluster.CLUSTER_STAT_THROUGHPUT_WRITES)));
-
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterGCPausesService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterGCPausesService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterGCPausesService.java
deleted file mode 100644
index c76fce0..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterGCPausesService.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class ClusterGCPausesService
- *
- * This class contains implementations of getting Cluster's GC Pauses (JVM
- * Pauses) Details and its trend over the time.
- *
- * @since GemFire version 7.5
- */
-
-@Component
-@Service("ClusterJVMPauses")
-@Scope("singleton")
-public class ClusterGCPausesService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
- // cluster's GC Pauses trend added to json response object
-
- ArrayNode pauses = mapper.createArrayNode();
- for (Object obj : cluster.getStatisticTrend(Cluster.CLUSTER_STAT_GARBAGE_COLLECTION)) {
- if (obj instanceof Number) {
- pauses.add(((Number) obj).longValue());
- }
- }
- responseJSON.put("currentGCPauses", cluster.getGarbageCollectionCount());
- responseJSON.put("gCPausesTrend", pauses);
- // Send json response
- return responseJSON;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterKeyStatisticsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterKeyStatisticsService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterKeyStatisticsService.java
deleted file mode 100644
index c8a6837..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterKeyStatisticsService.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class ClusterKeyStatisticsService
- *
- * This class contains implementations of getting Cluster's current Reads,
- * Writes and queries details and their trends over the time.
- *
- * @since GemFire version 7.5
- */
-
-@Component
-@Service("ClusterKeyStatistics")
-@Scope("singleton")
-public class ClusterKeyStatisticsService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- responseJSON.put("writePerSecTrend",
- mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_WRITES_PER_SECOND)));
-
- responseJSON.put("readPerSecTrend",
- mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_READ_PER_SECOND)));
-
- responseJSON.put("queriesPerSecTrend",
- mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_QUERIES_PER_SECOND)));
-
- // Send json response
- return responseJSON;
-
- }
-}
[28/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/JmxManagerFinder.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/JmxManagerFinder.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/JmxManagerFinder.java
deleted file mode 100644
index b593062..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/JmxManagerFinder.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.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.gemfire.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.gemfire.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/com/vmware/gemfire/tools/pulse/internal/data/PulseConfig.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/PulseConfig.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/PulseConfig.java
deleted file mode 100644
index c54554a..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/PulseConfig.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.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/com/vmware/gemfire/tools/pulse/internal/data/PulseConstants.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/PulseConstants.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/PulseConstants.java
deleted file mode 100644
index 56bc373..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/PulseConstants.java
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.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/com/vmware/gemfire/tools/pulse/internal/data/PulseVersion.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/PulseVersion.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/PulseVersion.java
deleted file mode 100644
index 7057a41..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/PulseVersion.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.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/com/vmware/gemfire/tools/pulse/internal/data/Repository.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/Repository.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/Repository.java
deleted file mode 100644
index 004d76b..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/Repository.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.data;
-
-import com.vmware.gemfire.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/com/vmware/gemfire/tools/pulse/internal/json/CDL.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/CDL.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/CDL.java
deleted file mode 100644
index b6729d4..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/CDL.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.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/com/vmware/gemfire/tools/pulse/internal/json/Cookie.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/Cookie.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/Cookie.java
deleted file mode 100644
index 5030dba..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/Cookie.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.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/com/vmware/gemfire/tools/pulse/internal/json/CookieList.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/CookieList.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/CookieList.java
deleted file mode 100644
index 4276b19..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/CookieList.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.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/com/vmware/gemfire/tools/pulse/internal/json/HTTP.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/HTTP.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/HTTP.java
deleted file mode 100644
index 5d9effe..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/HTTP.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.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/com/vmware/gemfire/tools/pulse/internal/json/HTTPTokener.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/HTTPTokener.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/HTTPTokener.java
deleted file mode 100644
index 1d8e98f..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/HTTPTokener.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.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();
- }
- }
-}
[23/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberGatewayHubService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberGatewayHubService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberGatewayHubService.java
deleted file mode 100644
index dd84b75..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberGatewayHubService.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Class MemberGatewayHubService
- *
- * This class contains implementations of getting Gateway Receivers and Senders
- * details of Cluster Member.
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("MemberGatewayHub")
-@Scope("singleton")
-public class MemberGatewayHubService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- String memberName = requestDataJSON.get("MemberGatewayHub").get("memberName").textValue();
-
- Cluster.Member clusterMember = cluster.getMember(StringUtils
- .makeCompliantName(memberName));
-
- if (clusterMember != null) {
- // response
- // get gateway receiver
- Cluster.GatewayReceiver gatewayReceiver = clusterMember.getGatewayReceiver();
-
- Boolean isGateway = false;
-
- if (gatewayReceiver != null) {
- responseJSON.put("isGatewayReceiver", true);
- responseJSON.put("listeningPort", gatewayReceiver.getListeningPort());
- responseJSON.put("linkTroughput", gatewayReceiver.getLinkThroughput());
- responseJSON.put("avgBatchLatency", gatewayReceiver.getAvgBatchProcessingTime());
- } else {
- responseJSON.put("isGatewayReceiver", false);
- }
-
- // get gateway senders
- Cluster.GatewaySender[] gatewaySenders = clusterMember.getMemberGatewaySenders();
-
- if (gatewaySenders.length > 0) {
- isGateway = true;
- }
- responseJSON.put("isGatewaySender", isGateway);
- // Senders
- ArrayNode gatewaySendersJsonList = mapper.createArrayNode();
-
- for (Cluster.GatewaySender gatewaySender : gatewaySenders) {
- ObjectNode gatewaySenderJSON = mapper.createObjectNode();
- gatewaySenderJSON.put("id", gatewaySender.getId());
- gatewaySenderJSON.put("queueSize", gatewaySender.getQueueSize());
- gatewaySenderJSON.put("status", gatewaySender.getStatus());
- gatewaySenderJSON.put("primary", gatewaySender.getPrimary());
- gatewaySenderJSON.put("senderType", gatewaySender.getSenderType());
- gatewaySenderJSON.put("batchSize", gatewaySender.getBatchSize());
- gatewaySenderJSON.put("PersistenceEnabled", gatewaySender.getPersistenceEnabled());
- gatewaySenderJSON.put("remoteDSId", gatewaySender.getRemoteDSId());
- gatewaySenderJSON.put("eventsExceedingAlertThreshold", gatewaySender.getEventsExceedingAlertThreshold());
-
- gatewaySendersJsonList.add(gatewaySenderJSON);
- }
- // senders response
- responseJSON.put("gatewaySenders", gatewaySendersJsonList);
-
- // async event queues
- Cluster.AsyncEventQueue[] asyncEventQueues = clusterMember.getMemberAsyncEventQueueList();
- ArrayNode asyncEventQueueJsonList = mapper.createArrayNode();
-
- for (Cluster.AsyncEventQueue asyncEventQueue : asyncEventQueues) {
- ObjectNode asyncEventQueueJSON = mapper.createObjectNode();
- asyncEventQueueJSON.put("id", asyncEventQueue.getId());
- asyncEventQueueJSON.put("primary", asyncEventQueue.getPrimary());
- asyncEventQueueJSON.put("senderType", asyncEventQueue.isParallel());
- asyncEventQueueJSON.put("batchSize", asyncEventQueue.getBatchSize());
- asyncEventQueueJSON.put("batchTimeInterval", asyncEventQueue.getBatchTimeInterval());
- asyncEventQueueJSON.put("batchConflationEnabled", asyncEventQueue.isBatchConflationEnabled());
- asyncEventQueueJSON.put("asyncEventListener", asyncEventQueue.getAsyncEventListener());
- asyncEventQueueJSON.put("queueSize", asyncEventQueue.getEventQueueSize());
-
- asyncEventQueueJsonList.add(asyncEventQueueJSON);
- }
- responseJSON.put("asyncEventQueues", asyncEventQueueJsonList);
-
- Map<String,Cluster.Region> clusterRegions = cluster.getClusterRegions();
-
- List<Cluster.Region> clusterRegionsList = new ArrayList<Cluster.Region>();
- clusterRegionsList.addAll(clusterRegions.values());
-
- ArrayNode regionsList = mapper.createArrayNode();
-
- for (Cluster.Region region : clusterRegionsList) {
- if (region.getWanEnabled()) {
- ObjectNode regionJSON = mapper.createObjectNode();
- regionJSON.put("name", region.getName());
- regionsList.add(regionJSON);
- }
- }
- responseJSON.put("regionsInvolved", regionsList);
- }
-
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberHeapUsageService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberHeapUsageService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberHeapUsageService.java
deleted file mode 100644
index 3a64161..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberHeapUsageService.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class MemberHeapUsageService
- *
- * This class contains implementations of getting Memeber's current Heap Usage
- * and its trend over the time.
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("MemberHeapUsage")
-@Scope("singleton")
-public class MemberHeapUsageService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // members list
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- String memberName = requestDataJSON.get("MemberHeapUsage").get("memberName").textValue();
-
- Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
-
- if (clusterMember != null) {
- // response
- responseJSON.put("heapUsageTrend",
- mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_HEAP_USAGE_SAMPLE)));
- responseJSON.put("currentHeapUsage", clusterMember.getCurrentHeapSize());
- }
-
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberKeyStatisticsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberKeyStatisticsService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberKeyStatisticsService.java
deleted file mode 100644
index de69ca0..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberKeyStatisticsService.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class MemberKeyStatisticsService
- *
- * This class contains implementations of getting Member's CPU, Memory and Read
- * Write details
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("MemberKeyStatistics")
-@Scope("singleton")
-public class MemberKeyStatisticsService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- String memberName = requestDataJSON.get("MemberKeyStatistics").get("memberName").textValue();
-
- Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
-
- if (clusterMember != null) {
- // response
- responseJSON.put("cpuUsageTrend",
- mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_CPU_USAGE_SAMPLE)));
- responseJSON.put("memoryUsageTrend",
- mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_HEAP_USAGE_SAMPLE)));
- responseJSON.put("readPerSecTrend",
- mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_GETS_PER_SECOND)));
- responseJSON.put("writePerSecTrend",
- mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_PUTS_PER_SECOND)));
- }
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberRegionsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberRegionsService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberRegionsService.java
deleted file mode 100644
index a1000df..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberRegionsService.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.text.DecimalFormat;
-
-/**
- * Class MemberRegionsService
- *
- * This class contains implementations of getting Memeber's Regions details.
- *
- * @since GemFire version 7.5
- */
-
-@Component
-@Service("MemberRegions")
-@Scope("singleton")
-public class MemberRegionsService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- // String constants used for forming a json response
- private final String NAME = "name";
- private final String ENTRY_SIZE = "entrySize";
- private final String DISC_STORE_NAME = "diskStoreName";
- private final String DISC_SYNCHRONOUS = "diskSynchronous";
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- String memberName = requestDataJSON.get("MemberRegions").get("memberName").textValue();
-
- Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
-
- if (clusterMember != null) {
- responseJSON.put("memberId", clusterMember.getId());
- responseJSON.put(this.NAME, clusterMember.getName());
- responseJSON.put("host", clusterMember.getHost());
-
- // member's regions
- Cluster.Region[] memberRegions = clusterMember.getMemberRegionsList();
- ArrayNode regionsListJson = mapper.createArrayNode();
- for (Cluster.Region memberRegion : memberRegions) {
- ObjectNode regionJSON = mapper.createObjectNode();
- regionJSON.put(this.NAME, memberRegion.getName());
-
- if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController.getPulseProductSupport())) {
- // Convert region path to dot separated region path
- regionJSON.put("fullPath", StringUtils.getTableNameFromRegionName(memberRegion.getFullPath()));
- } else {
- regionJSON.put("fullPath", memberRegion.getFullPath());
- }
-
- regionJSON.put("type", memberRegion.getRegionType());
- regionJSON.put("entryCount", memberRegion.getSystemRegionEntryCount());
- Long entrySize = memberRegion.getEntrySize();
-
- DecimalFormat form = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN_2);
- String entrySizeInMB = form.format(entrySize / (1024f * 1024f));
-
- if (entrySize < 0) {
- regionJSON.put(this.ENTRY_SIZE, this.VALUE_NA);
- } else {
- regionJSON.put(this.ENTRY_SIZE, entrySizeInMB);
- }
- regionJSON.put("scope", memberRegion.getScope());
- String diskStoreName = memberRegion.getDiskStoreName();
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(diskStoreName)) {
- regionJSON.put(this.DISC_STORE_NAME, diskStoreName);
- regionJSON.put(this.DISC_SYNCHRONOUS,
- memberRegion.isDiskSynchronous());
- } else {
- regionJSON.put(this.DISC_SYNCHRONOUS, this.VALUE_NA);
- regionJSON.put(this.DISC_STORE_NAME, "");
- }
- regionJSON.put("gatewayEnabled", memberRegion.getWanEnabled());
-
- regionsListJson.add(regionJSON);
- }
- responseJSON.put("memberRegions", regionsListJson);
-
- // response
- responseJSON.put("status", "Normal");
-
- }
-
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MembersListService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MembersListService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MembersListService.java
deleted file mode 100644
index c89f3d0..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MembersListService.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class MembersListService
- *
- * This class contains implementations of getting list of Cluster Members.
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("MembersList")
-@Scope("singleton")
-public class MembersListService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // members list
- ArrayNode memberListJson = mapper.createArrayNode();
- Cluster.Member[] memberSet = cluster.getMembers();
-
- for (Cluster.Member member : memberSet) {
- ObjectNode memberJSON = mapper.createObjectNode();
- memberJSON.put("memberId", member.getId());
- memberJSON.put("name", member.getName());
- memberJSON.put("host", member.getHost());
-
- memberListJson.add(memberJSON);
- }
-
- // Response JSON
- responseJSON.put("clusterMembers", memberListJson);
- responseJSON.put("clusterName", cluster.getServerName());
-
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseService.java
deleted file mode 100644
index 9fbfa1b..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseService.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import javax.servlet.http.HttpServletRequest;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Abstract class PulseService
- *
- * This is a base class for all services in pulse.
- *
- * @since GemFire version 7.5
- */
-public interface PulseService {
-
- String VALUE_NA = "NA";
- String VALUE_ON = "ON";
- String VALUE_OFF = "OFF";
-
- ObjectNode execute(HttpServletRequest httpServletRequest) throws Exception;
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseServiceFactory.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseServiceFactory.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseServiceFactory.java
deleted file mode 100644
index 48a1cc0..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseServiceFactory.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-/**
- * Class PulseServiceFactory
- *
- * @since GemFire version 7.5
- */
-@Component
-@Scope("singleton")
-public class PulseServiceFactory implements ApplicationContextAware {
-
- static final long serialVersionUID = 02L;
- ApplicationContext applicationContext = null;
-
- public PulseService getPulseServiceInstance(final String servicename) {
-
- if (applicationContext != null
- && applicationContext.containsBean(servicename)) {
- return (PulseService) applicationContext.getBean(servicename);
- }
- return null;
- }
-
- @Override
- public void setApplicationContext(final ApplicationContext applicationContext)
- throws BeansException {
-
- this.applicationContext = applicationContext;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseVersionService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseVersionService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseVersionService.java
deleted file mode 100644
index a04b9bb..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseVersionService.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class PulseVersionService
- *
- * This class contains implementations of getting Pulse Applications Version's
- * details (like version details, build details, source details, etc) from
- * properties file
- *
- * @since GemFire version 7.0.Beta
- */
-
-@Component
-@Service("PulseVersion")
-@Scope("singleton")
-public class PulseVersionService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // Response
- responseJSON.put("pulseVersion", PulseController.pulseVersion.getPulseVersion());
- responseJSON.put("buildId", PulseController.pulseVersion.getPulseBuildId());
- responseJSON.put("buildDate", PulseController.pulseVersion.getPulseBuildDate());
- responseJSON.put("sourceDate", PulseController.pulseVersion.getPulseSourceDate());
- responseJSON.put("sourceRevision", PulseController.pulseVersion.getPulseSourceRevision());
- responseJSON.put("sourceRepository", PulseController.pulseVersion.getPulseSourceRepository());
-
- // Send json response
- return responseJSON;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/QueryStatisticsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/QueryStatisticsService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/QueryStatisticsService.java
deleted file mode 100644
index 699e9be..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/QueryStatisticsService.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import javax.servlet.http.HttpServletRequest;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-
-/**
- * Class QueryStatisticsService
- *
- * This class returns top N queries based on pagination and filtering criteria
- * if any
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("QueryStatistics")
-@Scope("singleton")
-public class QueryStatisticsService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- @Override
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- Cluster.Statement[] stmts = cluster.getStatements();
-
- ArrayNode queryListJson = mapper.createArrayNode();
- for (int i = 0; i < stmts.length; ++i) {
- ObjectNode queryJSON = mapper.createObjectNode();
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QUERYDEFINITION, stmts[i].getQueryDefinition());
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESCOMPILED,
- mapper.valueToTree(stmts[i].getNumTimesCompiled() < 0 ? this.VALUE_NA : stmts[i].getNumTimesCompiled()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTION,
- mapper.valueToTree(stmts[i].getNumExecution() < 0 ? this.VALUE_NA : stmts[i].getNumExecution()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTIONSINPROGRESS,
- mapper.valueToTree(stmts[i].getNumExecutionsInProgress() < 0 ? this.VALUE_NA : stmts[i].getNumExecutionsInProgress()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESGLOBALINDEXLOOKUP,
- mapper.valueToTree(stmts[i].getNumTimesGlobalIndexLookup() < 0 ? this.VALUE_NA : stmts[i].getNumTimesGlobalIndexLookup()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMROWSMODIFIED,
- mapper.valueToTree(stmts[i].getNumRowsModified() < 0 ? this.VALUE_NA : stmts[i].getNumRowsModified()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_PARSETIME,
- mapper.valueToTree(stmts[i].getParseTime() < 0 ? this.VALUE_NA : stmts[i].getParseTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_BINDTIME,
- mapper.valueToTree(stmts[i].getBindTime() < 0 ? this.VALUE_NA : stmts[i].getBindTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_OPTIMIZETIME,
- mapper.valueToTree(stmts[i].getOptimizeTime() < 0 ? this.VALUE_NA : stmts[i].getOptimizeTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_ROUTINGINFOTIME,
- mapper.valueToTree(stmts[i].getRoutingInfoTime() < 0 ? this.VALUE_NA : stmts[i].getRoutingInfoTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_GENERATETIME,
- mapper.valueToTree(stmts[i].getGenerateTime() < 1 ? this.VALUE_NA : stmts[i].getGenerateTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_TOTALCOMPILATIONTIME,
- mapper.valueToTree(stmts[i].getTotalCompilationTime() < 0 ? this.VALUE_NA : stmts[i].getTotalCompilationTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_EXECUTIONTIME,
- mapper.valueToTree(stmts[i].getExecutionTime() < 0 ? this.VALUE_NA : stmts[i].getExecutionTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_PROJECTIONTIME,
- mapper.valueToTree(stmts[i].getProjectionTime() < 0 ? this.VALUE_NA : stmts[i].getProjectionTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_TOTALEXECUTIONTIME,
- mapper.valueToTree(stmts[i].getTotalExecutionTime() < 0 ? this.VALUE_NA : stmts[i].getTotalExecutionTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_ROWSMODIFICATIONTIME,
- mapper.valueToTree(stmts[i].getRowsModificationTime() < 0 ? this.VALUE_NA : stmts[i].getRowsModificationTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNNUMROWSSEEN,
- mapper.valueToTree(stmts[i].getqNNumRowsSeen() < 0 ? this.VALUE_NA : stmts[i].getqNNumRowsSeen()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNMSGSENDTIME,
- mapper.valueToTree(stmts[i].getqNMsgSendTime() < 0 ? this.VALUE_NA : stmts[i].getqNMsgSendTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNMSGSERTIME,
- mapper.valueToTree(stmts[i].getqNMsgSerTime() < 0 ? this.VALUE_NA : stmts[i].getqNMsgSerTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNRESPDESERTIME,
- mapper.valueToTree(stmts[i].getqNRespDeSerTime() < 0 ? this.VALUE_NA : stmts[i].getqNRespDeSerTime()));
- queryListJson.add(queryJSON);
- }
- responseJSON.put("queriesList", queryListJson);
-
- // return jmx status
- responseJSON.put("connectedFlag", cluster.isConnectedFlag());
- responseJSON.put("connectedErrorMsg", cluster.getConnectionErrorMsg());
-
- // Send json response
- return responseJSON;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/SystemAlertsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/SystemAlertsService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/SystemAlertsService.java
deleted file mode 100644
index d1c61c4..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/SystemAlertsService.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class SystemAlertsService
- *
- * This class contains implementations of getting system's alerts details (like
- * errors, warnings and severe errors).
- *
- * @since GemFire version 7.5
- */
-
-@Component
-@Service("SystemAlerts")
-@Scope("singleton")
-public class SystemAlertsService implements PulseService {
-
- private static final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- int pageNumber = 1; // Default
- String strPageNumber = requestDataJSON.get("SystemAlerts").get("pageNumber").textValue();
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(strPageNumber)) {
- try {
- pageNumber = Integer.valueOf(strPageNumber);
- } catch (NumberFormatException e) {
- }
- }
-
- // cluster's Members
- responseJSON.put("systemAlerts", getAlertsJson(cluster, pageNumber));
- responseJSON.put("pageNumber", cluster.getNotificationPageNumber());
- responseJSON.put("connectedFlag", cluster.isConnectedFlag());
- responseJSON.put("connectedErrorMsg", cluster.getConnectionErrorMsg());
-
- // Send json response
- return responseJSON;
- }
-
- /**
- * function used for getting all members details in format of JSON Object
- * array defined under a cluster
- *
- * @param cluster
- * @return JSONObject Array list
- */
- public static ObjectNode getAlertsJson(Cluster cluster, int pageNumber) {
- // getting list of all types of alerts
- Cluster.Alert[] alertsList = cluster.getAlertsList();
-
- // create alerts json
- ObjectNode alertsJsonObject = mapper.createObjectNode();
-
- if ((alertsList != null) && (alertsList.length > 0)) {
- ArrayNode errorJsonArray = mapper.createArrayNode();
- ArrayNode severeJsonArray = mapper.createArrayNode();
- ArrayNode warningJsonArray = mapper.createArrayNode();
- ArrayNode infoJsonArray = mapper.createArrayNode();
-
- cluster.setNotificationPageNumber(pageNumber);
- for (Cluster.Alert alert : alertsList) {
- ObjectNode objAlertJson = mapper.createObjectNode();
- objAlertJson.put("description", alert.getDescription());
- objAlertJson.put("memberName", alert.getMemberName());
- objAlertJson.put("severity", alert.getSeverity());
- objAlertJson.put("isAcknowledged", alert.isAcknowledged());
- objAlertJson.put("timestamp", alert.getTimestamp().toString());
- objAlertJson.put("iso8601Ts", alert.getIso8601Ts());
- objAlertJson.put("id", alert.getId());
-
- if (alert.getSeverity() == Cluster.Alert.SEVERE) {
- severeJsonArray.add(objAlertJson);
- } else if (alert.getSeverity() == Cluster.Alert.ERROR) {
- errorJsonArray.add(objAlertJson);
- } else if (alert.getSeverity() == Cluster.Alert.WARNING) {
- warningJsonArray.add(objAlertJson);
- } else {
- infoJsonArray.add(objAlertJson);
- }
- }
- alertsJsonObject.put("info", infoJsonArray);
- alertsJsonObject.put("warnings", warningJsonArray);
- alertsJsonObject.put("errors", errorJsonArray);
- alertsJsonObject.put("severe", severeJsonArray);
- }
- return alertsJsonObject;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/ConnectionUtil.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/ConnectionUtil.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/ConnectionUtil.java
deleted file mode 100644
index 99e62e2..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/ConnectionUtil.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.internal.util;
-
-import java.io.IOException;
-
-import javax.net.SocketFactory;
-import javax.net.ssl.SSLSocketFactory;
-
-
-/**
- *
- *
- */
-public class ConnectionUtil {
-
-
-
- public static SocketFactory getSocketFactory(boolean usessl)
- throws IOException
- {
- if(usessl){
- return (SSLSocketFactory)SSLSocketFactory.getDefault();
- }else{
- return SocketFactory.getDefault();
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/IPAddressUtil.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/IPAddressUtil.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/IPAddressUtil.java
deleted file mode 100644
index 1158251..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/IPAddressUtil.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.util;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-/* [ NOTE:
- * This class supposed to be removed, if required, after discussing with
- * VMware team ]
- */
-/**
- * Class IPAddressUtil This is utility class for checking whether ip address is
- * versions i.e. IPv4 or IPv6 address
- *
- *
- * @since GemFire version 7.0.1
- */
-public class IPAddressUtil {
-
- private static Pattern VALID_IPV4_PATTERN = null;
- private static Pattern VALID_IPV6_PATTERN = null;
- private static final String ipv4Pattern = "(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])";
- private static final String ipv6Pattern = "([0-9a-f]{1,4}:){7}([0-9a-f]){1,4}";
-
- static {
- try {
- VALID_IPV4_PATTERN = Pattern.compile(ipv4Pattern,
- Pattern.CASE_INSENSITIVE);
- VALID_IPV6_PATTERN = Pattern.compile(ipv6Pattern,
- Pattern.CASE_INSENSITIVE);
- } catch (PatternSyntaxException e) {
-
- }
- }
-
- public static Boolean isIPv4LiteralAddress(String IPAddress) {
- Matcher matcher = IPAddressUtil.VALID_IPV4_PATTERN.matcher(IPAddress);
- return matcher.matches();
- }
-
- public static Boolean isIPv6LiteralAddress(String IPAddress) {
-
- Matcher matcher = IPAddressUtil.VALID_IPV6_PATTERN.matcher(IPAddress);
- return matcher.matches();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/StringUtils.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/StringUtils.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/StringUtils.java
deleted file mode 100644
index 56cbf1b..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/StringUtils.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.util;
-
-/**
- * Class StringUtils This is utility class for string.
- *
- *
- * @since GemFire version 7.0.1
- */
-public class StringUtils {
- /**
- * Checks the string if it is not null, not empty, and not white space only
- * using standard Java classes.
- *
- * @param string
- * String to be checked.
- * @return {@code true} if provided String is not null, is not empty, and has
- * at least one character that is not considered white space.
- */
- public static boolean isNotNullNotEmptyNotWhiteSpace(final String string) {
- return string != null && !string.isEmpty() && !string.trim().isEmpty();
- }
-
- /**
- * Checking for String that is not null, not empty, and not white space only
- * using standard Java classes.
- *
- * @param value
- * String to be made compliant.
- * @return string compliant string.
- */
- public static String makeCompliantName(String value) {
- value = value.replace(':', '-');
- value = value.replace(',', '-');
- value = value.replace('=', '-');
- value = value.replace('*', '-');
- value = value.replace('?', '-');
- if (value.length() < 1) {
- value = "nothing";
- }
- return value;
- }
-
- /**
- * Function to get table name derived from region name/full path
- *
- * @param regionName
- * String to be made compliant.
- * @return string compliant string.
- */
- public static String getTableNameFromRegionName(String regionName) {
- String tableName = regionName.replaceFirst("/", "").replace('/', '.');
- return tableName;
- }
-
- /**
- * Function to get region name/full path derived from table name
- *
- * @param tableName
- * String to be made compliant.
- * @return string compliant string.
- */
- public static String getRegionNameFromTableName(String tableName) {
- String regionName = "/" + tableName.replace('.', '/');
- return regionName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/TimeUtils.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/TimeUtils.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/TimeUtils.java
deleted file mode 100644
index 73ce389..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/TimeUtils.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.util;
-
-/**
- * Class TimeUtils
- *
- * This is utility class used for conversions of time.
- *
- *
- * @since GemFire version 7.0.1
- */
-public class TimeUtils {
-
- /**
- * Method to converts time given in milliseconds to string representation in
- * days, hours, minutes and seconds
- *
- * @param longMilliSecs
- * Time in milliseconds.
- * @return String
- */
- public static String convertTimeMillisecondsToHMS(long longMilliSecs) {
-
- long days = longMilliSecs / (1000 * 60 * 60 * 24);
- long remainder = longMilliSecs % (1000 * 60 * 60 * 24);
-
- long hours = remainder / (1000 * 60 * 60);
- remainder = remainder % (1000 * 60 * 60);
-
- long mins = remainder / (1000 * 60);
- remainder = remainder % (1000 * 60);
-
- long secs = remainder / 1000;
-
- String strDaysHrsMinsSecs = "";
-
- if (days > 0) {
- strDaysHrsMinsSecs += days + " Days ";
- }
-
- if (hours > 0) {
- strDaysHrsMinsSecs += hours + " Hours ";
- } else {
- strDaysHrsMinsSecs += "0 Hours ";
- }
-
- if (mins > 0) {
- strDaysHrsMinsSecs += mins + " Mins ";
- } else {
- strDaysHrsMinsSecs += "0 Mins ";
- }
-
- strDaysHrsMinsSecs += secs + " Secs";
-
- return strDaysHrsMinsSecs;
- }
-
- /**
- * Method to converts time given in seconds to string representation in days,
- * hours, minutes and seconds
- *
- * @param longSecs
- * Time in seconds.
- * @return String
- */
- public static String convertTimeSecondsToHMS(long longSecs) {
-
- long days = longSecs / (60 * 60 * 24);
- long remainder = longSecs % (60 * 60 * 24);
-
- long hours = remainder / (60 * 60);
- remainder = remainder % (60 * 60);
-
- long mins = remainder / (60);
- remainder = remainder % (60);
-
- long secs = remainder;
-
- String strDaysHrsMinsSecs = "";
-
- if (days > 0) {
- strDaysHrsMinsSecs += days + " Days ";
- }
-
- if (hours > 0) {
- strDaysHrsMinsSecs += hours + " Hours ";
- } else {
- strDaysHrsMinsSecs += "0 Hours ";
- }
-
- if (mins > 0) {
- strDaysHrsMinsSecs += mins + " Mins ";
- } else {
- strDaysHrsMinsSecs += "0 Mins ";
- }
-
- strDaysHrsMinsSecs += secs + " Secs";
-
- return strDaysHrsMinsSecs;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java
new file mode 100644
index 0000000..408eed3
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java
@@ -0,0 +1,742 @@
+/*
+ *
+ * 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;
+
+import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
+import com.vmware.geode.tools.pulse.internal.data.PulseConfig;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.logging.Level;
+
+/**
+ * This class is used for checking the application running mode i.e. Embedded or
+ * not
+ *
+ * @since GemFire version 7.0.Beta 2012-09-23
+ *
+ */
+// @WebListener
+public class PulseAppListener implements ServletContextListener {
+ private PulseLogWriter LOGGER;
+ private final ResourceBundle resourceBundle = Repository.get()
+ .getResourceBundle();
+
+ // String object to store all messages which needs to be logged into the log
+ // file before logger gets initialized
+ private String messagesToBeLogged = "";
+
+ private Properties pulseProperties;
+ private Properties pulseSecurityProperties;
+ private Boolean sysPulseUseLocator;
+ private String sysPulseHost;
+ private String sysPulsePort;
+ private String jmxUserName;
+ private String jmxUserPassword;
+
+ private boolean sysPulseUseSSLLocator;
+ private boolean sysPulseUseSSLManager;
+
+ //This property determines if pulse webApp login is authenticated against
+ //GemFire integrated security or custom spring-security config provided
+ //in pulse-authentication-custom.xml
+ private boolean useGemFireCredentials;
+
+ @Override
+ public void contextDestroyed(ServletContextEvent event) {
+
+ // Stop all running threads those are created in Pulse
+ // Stop cluster threads
+ Repository.get().removeAllClusters();
+
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_CONTEXT_DESTROYED")
+ + event.getServletContext().getContextPath());
+ }
+ }
+
+ @Override
+ public void contextInitialized(ServletContextEvent event) {
+
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_CONTEXT_INITIALIZED")));
+
+ // Load Pulse version details
+ loadPulseVersionDetails();
+
+ // Load Pulse Properties
+ pulseProperties = loadProperties(PulseConstants.PULSE_PROPERTIES_FILE);
+
+ if (pulseProperties.isEmpty()) {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_PROPERTIES_NOT_FOUND")));
+ } else {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_PROPERTIES_FOUND")));
+
+ // set Pulse product support into the Pulse controller for access from
+ // client side
+ // to display the appropriate ui depending on which product is supported
+ // in present deployment
+ String pulseProduct = pulseProperties.getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_PRODUCTSUPPORT);
+ // default is gemfire
+
+ if ((pulseProduct != null) && (pulseProduct.trim().equalsIgnoreCase(PulseConstants.PRODUCT_NAME_SQLFIRE))) {
+ PulseController.setPulseProductSupport(PulseConstants.PRODUCT_NAME_SQLFIRE);
+ }
+ }
+
+ pulseSecurityProperties = loadProperties(PulseConstants.PULSE_SECURITY_PROPERTIES_FILE);
+
+ // Initialize logger
+ initializeLogger();
+
+ // Reference to repository
+ Repository repository = Repository.get();
+
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_CHECK_APP_RUNNING_MODE"));
+ }
+
+ boolean sysIsEmbedded = Boolean
+ .getBoolean(PulseConstants.SYSTEM_PROPERTY_PULSE_EMBEDDED);
+
+ if (sysIsEmbedded) {
+ // Application Pulse is running in Embedded Mode
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_APP_RUNNING_EMBEDDED_MODE"));
+ }
+ repository.setIsEmbeddedMode(true);
+
+ sysPulseUseLocator = Boolean.FALSE;
+ try{
+ // Get host name of machine running pulse in embedded mode
+ sysPulseHost = InetAddress.getLocalHost().getCanonicalHostName();
+ } catch (UnknownHostException e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine(resourceBundle
+ .getString("LOG_MSG_JMX_CONNECTION_UNKNOWN_HOST")
+ + e.getMessage());
+ }
+ // Set default host name
+ sysPulseHost = PulseConstants.GEMFIRE_DEFAULT_HOST;
+ } catch (Exception e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine(resourceBundle
+ .getString("LOG_MSG_JMX_CONNECTION_UNKNOWN_HOST")
+ + e.getMessage());
+ }
+ // Set default host name
+ sysPulseHost = PulseConstants.GEMFIRE_DEFAULT_HOST;
+ }
+ sysPulsePort = PulseConstants.GEMFIRE_DEFAULT_PORT;
+
+ boolean pulseEmbededSqlf = Boolean.getBoolean(PulseConstants.SYSTEM_PROPERTY_PULSE_EMBEDDED_SQLF);
+ if(pulseEmbededSqlf){
+ PulseController.setPulseProductSupport(PulseConstants.PRODUCT_NAME_SQLFIRE);
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_APP_RUNNING_EMBEDDED_SQLF_MODE"));
+ }
+ }
+
+ } else {
+ // Application Pulse is running in Non-Embedded Mode
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_APP_RUNNING_NONEMBEDDED_MODE"));
+ }
+ repository.setIsEmbeddedMode(false);
+
+ // Load JMX User Details
+ loadJMXUserDetails();
+ // Load locator and/or manager details
+ loadLocatorManagerDetails();
+
+ useGemFireCredentials = areWeUsingGemFireSecurityProfile(event);
+ }
+
+ // Set user details in repository
+ repository.setJmxUserName(jmxUserName);
+ repository.setJmxUserPassword(jmxUserPassword);
+
+ // Set locator/Manager details in repository
+ repository.setJmxUseLocator(sysPulseUseLocator);
+ repository.setJmxHost(sysPulseHost);
+ repository.setJmxPort(sysPulsePort);
+
+ //set SSL info
+ initializeSSL();
+ repository.setUseSSLLocator(sysPulseUseSSLLocator);
+ repository.setUseSSLManager(sysPulseUseSSLManager);
+
+ repository.setUseGemFireCredentials(useGemFireCredentials);
+
+ }
+
+ /**
+ * Return true if pulse is configure to authenticate using gemfire
+ * integrated security
+ *
+ * @param event
+ * @return
+ */
+ private boolean areWeUsingGemFireSecurityProfile(ServletContextEvent event) {
+ String profile = null;
+ WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
+ if (ctx.getEnvironment() != null) {
+ String[] profiles = ctx.getEnvironment().getActiveProfiles();
+ if (profiles != null && profiles.length > 0) {
+ StringBuilder sb = new StringBuilder();
+ for (String p : profiles)
+ sb.append(p).append(",");
+ LOGGER.info("#SpringProfilesConfigured : " + sb.toString());
+ profile = ctx.getEnvironment().getActiveProfiles()[0];
+ LOGGER.info("#First Profile : " + profile);
+ } else {
+ LOGGER.info("No SpringProfileConfigured using default spring profile");
+ return false;
+ }
+ }
+ if (PulseConstants.APPLICATION_PROPERTY_PULSE_SEC_PROFILE_GEMFIRE.equals(profile)) {
+ LOGGER.info("Using gemfire integrated security profile");
+ return true;
+ }
+ return false;
+ }
+
+ // Function to load pulse version details from properties file
+ private void loadPulseVersionDetails() {
+
+ // Read version details from version property file
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ InputStream inputStream = classLoader
+ .getResourceAsStream(PulseConstants.PULSE_VERSION_PROPERTIES_FILE);
+
+ if (inputStream != null) {
+ Properties properties = new Properties();
+ try {
+ properties.load(inputStream);
+ } catch (IOException e) {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_EXCEPTION_LOADING_PROPERTIES_FILE")));
+ } finally {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_EXCEPTION_CLOSING_INPUT_STREAM")));
+ }
+ }
+ // Set pulse version details in common object
+ PulseController.pulseVersion.setPulseVersion(properties.getProperty(
+ PulseConstants.PROPERTY_PULSE_VERSION, ""));
+ PulseController.pulseVersion.setPulseBuildId(properties.getProperty(
+ PulseConstants.PROPERTY_BUILD_ID, ""));
+ PulseController.pulseVersion.setPulseBuildDate(properties.getProperty(
+ PulseConstants.PROPERTY_BUILD_DATE, ""));
+ PulseController.pulseVersion.setPulseSourceDate(properties.getProperty(
+ PulseConstants.PROPERTY_SOURCE_DATE, ""));
+ PulseController.pulseVersion.setPulseSourceRevision(properties
+ .getProperty(PulseConstants.PROPERTY_SOURCE_REVISION, ""));
+ PulseController.pulseVersion.setPulseSourceRepository(properties
+ .getProperty(PulseConstants.PROPERTY_SOURCE_REPOSITORY, ""));
+ }
+
+ // Log Pulse Version details into log file
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(PulseController.pulseVersion
+ .getPulseVersionLogMessage()));
+ }
+
+ private void initializeLogger() {
+
+ // Override default log configuration by properties which are provided in
+ // properties file.
+ loadLogDetailsFromPropertyFile();
+
+ // Override log configuration by properties which are provided in
+ // through system properties.
+ loadLogDetailsFromSystemProperties();
+
+ // Initialize logger object
+ LOGGER = PulseLogWriter.getLogger();
+
+ // Log messages stored in messagesToBeLogged
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(messagesToBeLogged);
+ messagesToBeLogged = "";
+ }
+ }
+
+ // Function to load pulse properties from pulse.properties file
+ private Properties loadProperties(String propertyFile) {
+
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ InputStream inputStream = classLoader.getResourceAsStream(propertyFile);
+ Properties properties = new Properties();
+
+ if (inputStream != null) {
+ messagesToBeLogged = messagesToBeLogged.concat(formatLogString(propertyFile + " "
+ + resourceBundle.getString("LOG_MSG_FILE_FOUND")));
+
+ try {
+ // Load properties from input stream
+ properties.load(inputStream);
+ } catch (IOException e1) {
+ messagesToBeLogged = messagesToBeLogged.concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_EXCEPTION_LOADING_PROPERTIES_FILE")
+ + " " + propertyFile));
+ } finally {
+ // Close input stream
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ messagesToBeLogged = messagesToBeLogged.concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_EXCEPTION_CLOSING_INPUT_STREAM")
+ + " " + propertyFile));
+ }
+ }
+
+ } else {
+ messagesToBeLogged = messagesToBeLogged.concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_COULD_NOT_READ_FILE")
+ + " " + propertyFile));
+ }
+ return properties;
+ }
+
+ // Function to load Logging details from properties file
+ private void loadLogDetailsFromPropertyFile() {
+
+ // return, if Pulse Properties are not provided
+ if (pulseProperties.size() == 0) {
+ return;
+ }
+
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_CHECK_LOG_PROPERTIES_IN_FILE")));
+
+ HashMap<String, String> logPropertiesHM = new HashMap<String, String>();
+
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME, ""));
+
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION, ""));
+
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE, ""));
+
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT, ""));
+
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN, ""));
+
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL, ""));
+
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND, ""));
+
+ if (logPropertiesHM.size() == 0) {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_LOG_PROPERTIES_NOT_FOUND_IN_FILE")));
+ } else {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_LOG_PROPERTIES_FOUND_IN_FILE")));
+ }
+
+ setLogConfigurations(logPropertiesHM);
+ }
+
+ // Function to load Logging details from system properties
+ private void loadLogDetailsFromSystemProperties() {
+
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_CHECK_LOG_PROPERTIES_IN_SYSTEM_PROPERTIES")));
+
+ HashMap<String, String> logPropertiesHM = new HashMap<String, String>();
+
+ String sysLogFileName = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME);
+ String sysLogFileLocation = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION);
+ String sysLogFileSize = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE);
+ String sysLogFileCount = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT);
+ String sysLogDatePattern = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN);
+ String sysLogLevel = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL);
+ String sysLogAppend = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND);
+
+ if (sysLogFileName == null || sysLogFileName.isEmpty()) {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME, "");
+ } else {
+ logPropertiesHM
+ .put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME,
+ sysLogFileName);
+ }
+
+ if (sysLogFileLocation == null || sysLogFileLocation.isEmpty()) {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION, "");
+ } else {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION,
+ sysLogFileLocation);
+ }
+
+ if (sysLogFileSize == null || sysLogFileSize.isEmpty()) {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE, "");
+ } else {
+ logPropertiesHM
+ .put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE,
+ sysLogFileSize);
+ }
+
+ if (sysLogFileCount == null || sysLogFileCount.isEmpty()) {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT, "");
+ } else {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT,
+ sysLogFileCount);
+ }
+
+ if (sysLogDatePattern == null || sysLogDatePattern.isEmpty()) {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN, "");
+ } else {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN,
+ sysLogDatePattern);
+ }
+
+ if (sysLogLevel == null || sysLogLevel.isEmpty()) {
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL,
+ "");
+ } else {
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL,
+ sysLogLevel);
+ }
+
+ if (sysLogAppend == null || sysLogAppend.isEmpty()) {
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND,
+ "");
+ } else {
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND,
+ sysLogAppend);
+ }
+
+ if (logPropertiesHM.size() == 0) {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_LOG_PROPERTIES_NOT_FOUND_IN_SYSTEM_PROPERTIES")));
+ } else {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_LOG_PROPERTIES_FOUND_IN_SYSTEM_PROPERTIES")));
+ }
+
+ setLogConfigurations(logPropertiesHM);
+ }
+
+ private void setLogConfigurations(HashMap<String, String> logPropertiesHM) {
+
+ PulseConfig pulseConfig = Repository.get().getPulseConfig();
+
+ // log file name
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME))) {
+ pulseConfig.setLogFileName(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME));
+ }
+
+ // log file location
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION))) {
+ pulseConfig.setLogFileLocation(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION));
+ }
+
+ // log file size
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE))) {
+ pulseConfig.setLogFileSize(Integer.parseInt(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE)));
+ }
+
+ // log file count
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT))) {
+ pulseConfig.setLogFileCount(Integer.parseInt(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT)));
+ }
+
+ // log message date pattern
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN))) {
+ pulseConfig.setLogDatePattern(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN));
+ }
+
+ // log level
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL))) {
+ pulseConfig.setLogLevel(Level.parse(logPropertiesHM.get(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL).toUpperCase()));
+ }
+
+ // log append
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND))) {
+ pulseConfig.setLogAppend(Boolean.valueOf(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND)));
+ }
+
+ }
+
+ // Function to load JMX User details from properties
+ private void loadJMXUserDetails() {
+
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_GET_JMX_USER_DETAILS"));
+ }
+
+ if (pulseProperties.isEmpty()) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER
+ .info(resourceBundle
+ .getString("LOG_MSG_JMX_USER_DETAILS_NOT_FOUND")
+ + resourceBundle
+ .getString("LOG_MSG_REASON_USER_DETAILS_NOT_FOUND"));
+ }
+ } else {
+ jmxUserName = pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_JMXUSERNAME, "");
+ jmxUserPassword = pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_JMXPASSWORD, "");
+
+ if (jmxUserName.isEmpty() || jmxUserPassword.isEmpty()) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_JMX_USER_DETAILS_NOT_FOUND")
+ + resourceBundle
+ .getString("LOG_MSG_REASON_USER_DETAILS_NOT_FOUND"));
+ }
+ } else {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_JMX_USER_DETAILS_FOUND"));
+ }
+ }
+ }
+ }
+
+//Function to set SSL VM arguments
+ private void initializeSSL() {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_GET_SSL_DETAILS"));
+ }
+
+
+ this.sysPulseUseSSLLocator = Boolean.valueOf(pulseProperties.getProperty(
+ PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_LOCATOR, "false"));
+
+ this.sysPulseUseSSLManager = Boolean.valueOf(pulseProperties.getProperty(
+ PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_MANAGER, "false"));
+
+
+ if ((sysPulseUseSSLLocator || sysPulseUseSSLManager)) {
+ Properties sslProperties = new Properties();
+ if (!pulseSecurityProperties.isEmpty()) {
+ Set entrySet = pulseSecurityProperties.entrySet();
+ for (Iterator it = entrySet.iterator(); it.hasNext();) {
+ Entry<String, String> entry = (Entry<String, String>) it.next();
+ String key = entry.getKey();
+ if (key.startsWith("javax.net.ssl.")) {
+
+ String val = entry.getValue();
+ System.setProperty(key, val);
+ sslProperties.setProperty(key, val);
+ }
+ }
+ }
+ if (sslProperties.isEmpty()) {
+ if (LOGGER.warningEnabled()) {
+ LOGGER.warning(resourceBundle.getString("LOG_MSG_SSL_NOT_SET"));
+ }
+ }
+ }
+
+ }
+
+ // Function to load locator and/or manager details
+ private void loadLocatorManagerDetails() {
+
+ // Get locator details through System Properties
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_GET_LOCATOR_DETAILS_1"));
+ }
+
+ // Required System properties are
+ // -Dpulse.embedded="false" -Dpulse.useLocator="false"
+ // -Dpulse.host="192.168.2.11" -Dpulse.port="2099"
+ sysPulseUseLocator = Boolean
+ .getBoolean(PulseConstants.SYSTEM_PROPERTY_PULSE_USELOCATOR);
+ sysPulseHost = System
+ .getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_HOST);
+ sysPulsePort = System
+ .getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_PORT);
+
+ if (sysPulseHost == null || sysPulseHost.isEmpty() || sysPulsePort == null
+ || sysPulsePort.isEmpty()) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_LOCATOR_DETAILS_NOT_FOUND")
+ + resourceBundle
+ .getString("LOG_MSG_REASON_LOCATOR_DETAILS_NOT_FOUND_1"));
+ LOGGER.info(resourceBundle.getString("LOG_MSG_GET_LOCATOR_DETAILS_2"));
+ }
+
+ if (pulseProperties.isEmpty()) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_LOCATOR_DETAILS_NOT_FOUND")
+ + resourceBundle
+ .getString("LOG_MSG_REASON_LOCATOR_DETAILS_NOT_FOUND_2"));
+ }
+
+ sysPulseHost = "";
+ sysPulsePort = "";
+ } else {
+ if (LOGGER.infoEnabled()) {
+ LOGGER
+ .info(resourceBundle.getString("LOG_MSG_LOCATOR_DETAILS_FOUND"));
+ }
+
+ sysPulseUseLocator = Boolean.valueOf(pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_USELOCATOR, ""));
+ sysPulseHost = pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_HOST, "");
+ sysPulsePort = pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_PORT, "");
+ }
+ } else {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_LOCATOR_DETAILS_FOUND"));
+ }
+ }
+ }
+
+ private String formatLogString(String logMessage) {
+
+ DateFormat df = new SimpleDateFormat(
+ PulseConstants.LOG_MESSAGE_DATE_PATTERN);
+ // DateFormat df = new
+ // SimpleDateFormat(Repository.get().getPulseConfig().getLogDatePattern());
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+
+ pw.println();
+ pw.print("[");
+ pw.print("INFO");
+ pw.print(" ");
+ pw.print(df.format(new Date(System.currentTimeMillis())));
+ String threadName = Thread.currentThread().getName();
+ if (threadName != null) {
+ pw.print(" ");
+ pw.print(threadName);
+ }
+ pw.print(" tid=0x");
+ pw.print(Long.toHexString(Thread.currentThread().getId()));
+ pw.print("] ");
+ pw.print("(msgTID=");
+ pw.print("");
+
+ pw.print(" msgSN=");
+ pw.print("");
+
+ pw.print(") ");
+
+ pw.println("[" + PulseConstants.APP_NAME + "]");
+
+ pw.println(PulseLogWriter.class.getName());
+
+ pw.println(logMessage);
+
+ pw.close();
+ try {
+ sw.close();
+ } catch (IOException ignore) {
+ }
+ String result = sw.toString();
+ return result;
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java
new file mode 100644
index 0000000..9e86637
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * 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.controllers;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+
+/**
+ * For handling IO exception in our controllers
+ *
+ *
+ */
+@ControllerAdvice
+public class ExceptionHandlingAdvice {
+
+ @ExceptionHandler(IOException.class)
+ @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
+ public void handleExc(IOException ext) {
+ PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+ // write errors
+ StringWriter swBuffer = new StringWriter();
+ PrintWriter prtWriter = new PrintWriter(swBuffer);
+ ext.printStackTrace(prtWriter);
+ LOGGER.severe("IOException Details : " + swBuffer.toString() + "\n");
+ }
+}
[24/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMemberService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMemberService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMemberService.java
deleted file mode 100644
index b5443de..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMemberService.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.TimeUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Class ClusterMemberService
- *
- * This class contains implementations of getting Cluster Member's details
- *
- * @since GemFire version 7.5
- */
-@Component
-// @Service("ClusterMember")
-@Service("ClusterMembers")
-@Scope("singleton")
-public class ClusterMemberService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- private final String HEAP_USAGE = "heapUsage";
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- Cluster.Member[] clusterMembersList = cluster.getMembers();
-
- // create members json
- ArrayNode memberListJson = mapper.createArrayNode();
- for (Cluster.Member clusterMember : clusterMembersList) {
- ObjectNode memberJSON = mapper.createObjectNode();
- // getting members detail
- memberJSON.put("gemfireVersion", clusterMember.getGemfireVersion());
- memberJSON.put("memberId", clusterMember.getId());
- memberJSON.put("name", clusterMember.getName());
- memberJSON.put("host", clusterMember.getHost());
-
- List<String> serverGroups = clusterMember.getServerGroups();
- if(serverGroups.size() == 0){
- serverGroups = new ArrayList<>();
- serverGroups.add(PulseConstants.DEFAULT_SERVER_GROUP);
- }
-
- memberJSON.put("serverGroups", mapper.valueToTree(serverGroups));
-
- List<String> redundancyZones = clusterMember.getRedundancyZones();
- if(redundancyZones.size() == 0){
- redundancyZones = new ArrayList<String>();
- redundancyZones.add(PulseConstants.DEFAULT_REDUNDANCY_ZONE);
- }
- memberJSON.put("redundancyZones", mapper.valueToTree(redundancyZones));
-
- long usedHeapSize = cluster.getUsedHeapSize();
- long currentHeap = clusterMember.getCurrentHeapSize();
- if (usedHeapSize > 0) {
- double heapUsage = ((double) currentHeap / (double) usedHeapSize) * 100;
- memberJSON.put(this.HEAP_USAGE, truncate(heapUsage, 2));
- } else {
- memberJSON.put(this.HEAP_USAGE, 0);
- }
- double currentCPUUsage = clusterMember.getCpuUsage();
- double loadAvg = clusterMember.getLoadAverage();
-
- memberJSON.put("cpuUsage", truncate(currentCPUUsage, 2));
- memberJSON.put("currentHeapUsage", clusterMember.getCurrentHeapSize());
- memberJSON.put("isManager", clusterMember.isManager());
- memberJSON.put("uptime", TimeUtils.convertTimeSecondsToHMS(clusterMember.getUptime()));
- memberJSON.put("loadAvg", truncate(loadAvg, 2));
- memberJSON.put("sockets", clusterMember.getTotalFileDescriptorOpen());
- memberJSON.put("threads", clusterMember.getNumThreads());
-
- // Number of member clients
- if (PulseController.getPulseProductSupport().equalsIgnoreCase(
- PulseConstants.PRODUCT_NAME_SQLFIRE)){
- memberJSON.put("clients", clusterMember.getNumSqlfireClients());
- }else{
- memberJSON.put("clients", clusterMember.getMemberClientsHMap().size());
- }
- memberJSON.put("queues", clusterMember.getQueueBacklog());
-
- memberListJson.add(memberJSON);
- }
- // cluster's Members
- responseJSON.put("members", memberListJson);
- // Send json response
- return responseJSON;
- }
-
- private double truncate(double value, int places) {
- return new BigDecimal(value).setScale(places, RoundingMode.HALF_UP).doubleValue();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMembersRGraphService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMembersRGraphService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMembersRGraphService.java
deleted file mode 100644
index de8efd8..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMembersRGraphService.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-
-/**
- * Class ClusterMembersRGraphService
- *
- * This class contains implementations of getting List of Cluster members and
- * their details
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("ClusterMembersRGraph")
-@Scope("singleton")
-public class ClusterMembersRGraphService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- // String constants used for forming a json response
- private final String CLUSTER = "clustor";
- private final String MEMBER_COUNT = "memberCount";
- private final String ID = "id";
- private final String NAME = "name";
- private final String DATA = "data";
- private final String MEMORY_USAGE = "memoryUsage";
- private final String CPU_USAGE = "cpuUsage";
- private final String REGIONS = "regions";
- private final String HOST = "host";
- private final String PORT = "port";
- private final String CLIENTS = "clients";
- private final String GC_PAUSES = "gcPauses";
- private final String GATEWAY_SENDER = "gatewaySender";
- private final String GATEWAY_RECEIVER = "gatewayReceiver";
- private final String LOAD_AVG = "loadAvg";
- private final String SOCKETS = "sockets";
- private final String THREADS = "threads";
- private final String NUM_THREADS = "numThreads";
-
- private final String MEMBER_NODE_TYPE_NORMAL = "Normal";
- private final String MEMBER_NODE_TYPE_WARNING = "Warning";
- private final String MEMBER_NODE_TYPE_ERROR = "Error";
- private final String MEMBER_NODE_TYPE_SEVERE = "Severe";
- private final String CHILDREN = "children";
-
- // traversing the alert array list and members which have severe, error or
- // warnings
- // alerts saving them in three different arraylists
- private List<String> severeAlertList;
- private List<String> errorAlertsList;
- private List<String> warningAlertsList;
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // Reference to repository
- Repository repository = Repository.get();
-
- // get cluster object
- Cluster cluster = repository.getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // cluster's Members
- responseJSON.put(this.CLUSTER,
- getPhysicalServerJson(cluster, repository.getJmxHost(), repository.getJmxPort()));
- responseJSON.put(this.MEMBER_COUNT, cluster.getMemberCount());
-
- // Send json response
- return responseJSON;
- }
-
- /**
- * function used for getting all members details in format of JSON Object
- * array defined under a cluster. This function create json based on the
- * relation of physical host and members related to it.
- *
- * @param cluster
- * @param host
- * @param port
- * @return Array list of JSON objects for required fields of members in
- * cluster
- */
- private ObjectNode getPhysicalServerJson(Cluster cluster, String host, String port) {
- Map<String, List<Cluster.Member>> physicalToMember = cluster.getPhysicalToMember();
-
- ObjectNode clusterTopologyJSON = mapper.createObjectNode();
-
- clusterTopologyJSON.put(this.ID, cluster.getClusterId());
- clusterTopologyJSON.put(this.NAME, cluster.getClusterId());
- ObjectNode data1 = mapper.createObjectNode();
- clusterTopologyJSON.put(this.DATA, data1);
- ArrayNode childHostArray = mapper.createArrayNode();
- DecimalFormat df2 = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN);
-
- updateAlertLists(cluster);
-
- for (Map.Entry<String, List<Cluster.Member>> physicalToMem : physicalToMember.entrySet()) {
- String hostName = physicalToMem.getKey();
- double hostCpuUsage = 0.0;
- long hostMemoryUsage = 0;
- double hostLoadAvg = 0.0;
- int hostNumThreads = 0;
- long hostSockets = 0;
- boolean hostSevere = false;
- boolean hostError = false;
- boolean hostWarning = false;
- String hostStatus;
- ObjectNode childHostObject = mapper.createObjectNode();
- childHostObject.put(this.ID, hostName);
- childHostObject.put(this.NAME, hostName);
-
- ArrayNode membersArray = mapper.createArrayNode();
-
- List<Cluster.Member> memberList = physicalToMem.getValue();
- for (Cluster.Member member : memberList) {
- ObjectNode memberJSONObj = mapper.createObjectNode();
-
- memberJSONObj.put(this.ID, member.getId());
- memberJSONObj.put(this.NAME, member.getName());
-
- ObjectNode memberData = mapper.createObjectNode();
-
- memberData.put("gemfireVersion", member.getGemfireVersion());
-
- Long currentHeap = member.getCurrentHeapSize();
- Long usedHeapSize = cluster.getUsedHeapSize();
-
- if (usedHeapSize > 0) {
- double heapUsage = (currentHeap.doubleValue() / usedHeapSize.doubleValue()) * 100;
-
- memberData.put(this.MEMORY_USAGE,
- Double.valueOf(df2.format(heapUsage)));
- } else
- memberData.put(this.MEMORY_USAGE, 0);
-
- double currentCPUUsage = member.getCpuUsage();
-
- memberData.put(this.CPU_USAGE,
- Double.valueOf(df2.format(currentCPUUsage)));
- memberData.put(this.REGIONS, member.getMemberRegions().size());
- memberData.put(this.HOST, member.getHost());
- if ((member.getMemberPort() == null)
- || (member.getMemberPort().equals(""))) {
- memberData.put(this.PORT, "-");
- } else {
- memberData.put(this.PORT, member.getMemberPort());
- }
- memberData.put(this.CLIENTS, member.getMemberClientsHMap().size());
- memberData.put(this.GC_PAUSES, member.getGarbageCollectionCount());
- memberData.put(this.NUM_THREADS, member.getNumThreads());
-
- // Host CPU Usage is aggregate of all members cpu usage
- // hostCpuUsage = hostCpuUsage + currentCPUUsage;
- hostCpuUsage = member.getHostCpuUsage();
- hostMemoryUsage = hostMemoryUsage + member.getCurrentHeapSize();
- hostLoadAvg = member.getLoadAverage();
- hostNumThreads = member.getNumThreads();
- hostSockets = member.getTotalFileDescriptorOpen();
-
- // defining the status of Member Icons for R Graph based on the alerts
- // created for that member
- String memberNodeType = "";
- // for severe alert
- if (severeAlertList.contains(member.getName())) {
- memberNodeType = getMemberNodeType(member, this.MEMBER_NODE_TYPE_SEVERE);
- if (!hostSevere) {
- hostSevere = true;
- }
- } else if (errorAlertsList.contains(member.getName())) {
- // for error alerts
- memberNodeType = getMemberNodeType(member,
- this.MEMBER_NODE_TYPE_ERROR);
- if (!hostError) {
- hostError = true;
- }
- }
- // for warning alerts
- else if (warningAlertsList.contains(member.getName())) {
- memberNodeType = getMemberNodeType(member, this.MEMBER_NODE_TYPE_WARNING);
- if (!hostWarning) {
- hostWarning = true;
- }
- } else {
- memberNodeType = getMemberNodeType(member, this.MEMBER_NODE_TYPE_NORMAL);
- }
-
- memberData.put("nodeType", memberNodeType);
- memberData.put("$type", memberNodeType);
- memberData.put(this.GATEWAY_SENDER, member.getGatewaySenderList().size());
- if (member.getGatewayReceiver() != null) {
- memberData.put(this.GATEWAY_RECEIVER, 1);
- } else {
- memberData.put(this.GATEWAY_RECEIVER, 0);
- }
- memberJSONObj.put(this.DATA, memberData);
- memberJSONObj.put(this.CHILDREN, mapper.createArrayNode());
- membersArray.add(memberJSONObj);
- }
- ObjectNode data = mapper.createObjectNode();
-
- data.put(this.LOAD_AVG, Double.valueOf(df2.format(hostLoadAvg)));
- data.put(this.SOCKETS, hostSockets);
- data.put(this.THREADS, hostNumThreads);
- data.put(this.CPU_USAGE, Double.valueOf(df2.format(hostCpuUsage)));
- data.put(this.MEMORY_USAGE, hostMemoryUsage);
-
- String hostNodeType;
- // setting physical host status
- if (hostSevere) {
- hostStatus = this.MEMBER_NODE_TYPE_SEVERE;
- hostNodeType = "hostSevereNode";
- } else if (hostError) {
- hostStatus = this.MEMBER_NODE_TYPE_ERROR;
- hostNodeType = "hostErrorNode";
- } else if (hostWarning) {
- hostStatus = this.MEMBER_NODE_TYPE_WARNING;
- hostNodeType = "hostWarningNode";
- } else {
- hostStatus = this.MEMBER_NODE_TYPE_NORMAL;
- hostNodeType = "hostNormalNode";
- }
- data.put("hostStatus", hostStatus);
- data.put("$type", hostNodeType);
-
- childHostObject.put(this.DATA, data);
-
- childHostObject.put(this.CHILDREN, membersArray);
- childHostArray.add(childHostObject);
- }
- clusterTopologyJSON.put(this.CHILDREN, childHostArray);
-
- return clusterTopologyJSON;
- }
-
- /**
- * used for getting member node type based on member's current state
- *
- * @param member
- * Member
- * @param memberState
- * i.e Severe, Error, Warning or Normal
- * @return
- */
- private String getMemberNodeType(Cluster.Member member, String memberState) {
- String memberNodeType = "";
-
- if ((member.isLocator()) && (member.isServer()) && (member.isManager())) {
- memberNodeType = "memberLocatorManagerServer" + memberState + "Node";
- } else if ((member.isLocator()) && (member.isServer())
- && !(member.isManager())) {
- memberNodeType = "memberLocatorServer" + memberState + "Node";
- } else if ((member.isLocator()) && !(member.isServer())
- && (member.isManager())) {
- memberNodeType = "memberLocatorManager" + memberState + "Node";
- } else if ((member.isLocator()) && !(member.isServer())
- && !(member.isManager())) {
- memberNodeType = "memberLocator" + memberState + "Node";
- } else if (!(member.isLocator()) && (member.isServer())
- && (member.isManager())) {
- memberNodeType = "memberManagerServer" + memberState + "Node";
- } else if (!(member.isLocator()) && (member.isServer())
- && !(member.isManager())) {
- memberNodeType = "memberServer" + memberState + "Node";
- } else if (!(member.isLocator()) && !(member.isServer())
- && (member.isManager())) {
- memberNodeType = "memberManager" + memberState + "Node";
- } else if (!(member.isLocator()) && !(member.isServer())
- && !(member.isManager())) {
- memberNodeType = "member" + memberState + "Node";
- }
- return memberNodeType;
- }
-
- /**
- * function used for getting list of all the alerts and save the member names
- * in respective error, warning and severe alert lists
- *
- * @param cluster
- */
- private void updateAlertLists(Cluster cluster) {
-
- severeAlertList = new ArrayList<String>();
- errorAlertsList = new ArrayList<String>();
- warningAlertsList = new ArrayList<String>();
-
- Cluster.Alert[] alertsList = cluster.getAlertsList();
-
- for (Cluster.Alert alert : alertsList) {
- // if alert is severe
- if (alert.getSeverity() == Cluster.Alert.SEVERE) {
- if (errorAlertsList.contains(alert.getMemberName())) {
- errorAlertsList.remove(alert.getMemberName());
- } else if (warningAlertsList.contains(alert.getMemberName())) {
- warningAlertsList.remove(alert.getMemberName());
- }
- if (!severeAlertList.contains(alert.getMemberName())) {
- severeAlertList.add(alert.getMemberName());
- }
- }
- // if alert is error
- else if (alert.getSeverity() == Cluster.Alert.ERROR) {
- if (!severeAlertList.contains(alert.getMemberName())) {
- if (warningAlertsList.contains(alert.getMemberName())) {
- warningAlertsList.remove(alert.getMemberName());
- }
- if (!errorAlertsList.contains(alert.getMemberName())) {
- errorAlertsList.add(alert.getMemberName());
- }
- }
- }
- // if alert is warning
- else if (alert.getSeverity() == Cluster.Alert.WARNING) {
- if (!severeAlertList.contains(alert.getMemberName())) {
- if (!errorAlertsList.contains(alert.getMemberName())) {
- if (!warningAlertsList.contains(alert.getMemberName())) {
- warningAlertsList.add(alert.getMemberName());
- }
- }
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMemoryUsageService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMemoryUsageService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMemoryUsageService.java
deleted file mode 100644
index 384507e..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMemoryUsageService.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class ClusterMemoryUsageService
- *
- * This class contains implementations of getting Cluster's overall current
- * memory usage details and its trend over the time.
- *
- * @since GemFire version 7.5
- */
-
-@Component
-@Service("ClusterMemoryUsage")
-@Scope("singleton")
-public class ClusterMemoryUsageService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // cluster's Memory Usage trend added to json response object
-
- responseJSON.put("currentMemoryUsage", cluster.getUsedHeapSize());
- responseJSON.put("memoryUsageTrend",
- mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_MEMORY_USAGE)));
-
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterRegionService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterRegionService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterRegionService.java
deleted file mode 100644
index c15e613..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterRegionService.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Class ClusterRegionService
- *
- * This class contains implementations of getting Cluster's regions details
- *
- * @since GemFire version 7.5
- */
-
-@Component
-@Service("ClusterRegion")
-@Scope("singleton")
-public class ClusterRegionService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- // String constants used for forming a json response
- private final String ENTRY_SIZE = "entrySize";
-
- // Comparator based upon regions entry count
- private static Comparator<Cluster.Region> regionEntryCountComparator = (r1, r2) -> {
- long r1Cnt = r1.getSystemRegionEntryCount();
- long r2Cnt = r2.getSystemRegionEntryCount();
- if (r1Cnt < r2Cnt) {
- return -1;
- } else if (r1Cnt > r2Cnt) {
- return 1;
- } else {
- return 0;
- }
- };
-
- @Override
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- String userName = request.getUserPrincipal().getName();
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // getting cluster's Regions
- responseJSON.put("clusterName", cluster.getServerName());
- responseJSON.put("userName", userName);
- responseJSON.put("region", getRegionJson(cluster));
-
- // Send json response
- return responseJSON;
- }
-
- /**
- * This method is used to get various regions associated with the given
- * cluster and create json for each region fields and returns Array List for
- * all the regions associated with given cluster
- *
- * @param cluster
- * @return ArrayNode Array List
- */
- private ArrayNode getRegionJson(Cluster cluster) {
-
- Long totalHeapSize = cluster.getTotalHeapSize();
- Long totalDiskUsage = cluster.getTotalBytesOnDisk();
-
- Map<String, Cluster.Region> clusterRegions = cluster.getClusterRegions();
-
- List<Cluster.Region> clusterRegionsList = new ArrayList<Cluster.Region>();
- clusterRegionsList.addAll(clusterRegions.values());
-
- Collections.sort(clusterRegionsList, regionEntryCountComparator);
-
- ArrayNode regionListJson = mapper.createArrayNode();
- for (int count = 0; count < clusterRegionsList.size(); count++) {
- Cluster.Region reg = clusterRegionsList.get(count);
- ObjectNode regionJSON = mapper.createObjectNode();
-
- regionJSON.put("name", reg.getName());
- regionJSON.put("totalMemory", totalHeapSize);
- regionJSON.put("systemRegionEntryCount", reg.getSystemRegionEntryCount());
- regionJSON.put("memberCount", reg.getMemberCount());
-
- final String regionType = reg.getRegionType();
- regionJSON.put("type", regionType);
- regionJSON.put("getsRate", reg.getGetsRate());
- regionJSON.put("putsRate", reg.getPutsRate());
-
- Cluster.Member[] clusterMembersList = cluster.getMembers();
-
- ArrayNode memberNameArray = mapper.createArrayNode();
- for (String memberName : reg.getMemberName()) {
- for (Cluster.Member member : clusterMembersList) {
- String name = member.getName();
- name = name.replace(":", "-");
- String id = member.getId();
- id = id.replace(":", "-");
-
- if ((memberName.equals(id)) || (memberName.equals(name))) {
- ObjectNode regionMember = mapper.createObjectNode();
- regionMember.put("id", member.getId());
- regionMember.put("name", member.getName());
- memberNameArray.add(regionMember);
- break;
- }
- }
- }
-
- regionJSON.put("memberNames", memberNameArray);
- regionJSON.put("entryCount", reg.getSystemRegionEntryCount());
-
- Boolean persistent = reg.getPersistentEnabled();
- if (persistent) {
- regionJSON.put("persistence", VALUE_ON);
- } else {
- regionJSON.put("persistence", VALUE_OFF);
- }
-
- Boolean isEnableOffHeapMemory = reg.isEnableOffHeapMemory();
- if (isEnableOffHeapMemory) {
- regionJSON.put("isEnableOffHeapMemory", VALUE_ON);
- } else {
- regionJSON.put("isEnableOffHeapMemory", VALUE_OFF);
- }
-
- String regCompCodec = reg.getCompressionCodec();
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(regCompCodec)) {
- regionJSON.put("compressionCodec", reg.getCompressionCodec());
- } else {
- regionJSON.put("compressionCodec", VALUE_NA);
- }
-
- if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController
- .getPulseProductSupport())) {
- // Convert region path to dot separated region path
- regionJSON.put("regionPath",
- StringUtils.getTableNameFromRegionName(reg.getFullPath()));
- } else {
- regionJSON.put("regionPath", reg.getFullPath());
- }
-
- regionJSON.put("memoryReadsTrend",
- mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_GETS_PER_SEC_TREND)));
- regionJSON.put("memoryWritesTrend",
- mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_PUTS_PER_SEC_TREND)));
- regionJSON.put("diskReadsTrend",
- mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_READS_PER_SEC_TREND)));
- regionJSON.put("diskWritesTrend",
- mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_WRITES_PER_SEC_TREND)));
- regionJSON.put("emptyNodes", reg.getEmptyNode());
- Long entrySize = reg.getEntrySize();
- DecimalFormat form = new DecimalFormat(
- PulseConstants.DECIMAL_FORMAT_PATTERN_2);
- String entrySizeInMB = form.format(entrySize / (1024f * 1024f));
-
- if (entrySize < 0) {
- regionJSON.put(this.ENTRY_SIZE, VALUE_NA);
- } else {
- regionJSON.put(this.ENTRY_SIZE, entrySizeInMB);
- }
- regionJSON.put("dataUsage", reg.getDiskUsage());
- regionJSON.put("wanEnabled", reg.getWanEnabled());
- regionJSON.put("totalDataUsage", totalDiskUsage);
-
- regionJSON.put("memoryUsage", entrySizeInMB);
-
- regionListJson.add(regionJSON);
- }
-
- return regionListJson;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterRegionsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterRegionsService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterRegionsService.java
deleted file mode 100644
index 2f50089..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterRegionsService.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Class ClusterRegionsService
- *
- * This class contains implementations of getting Cluster's regions details
- *
- * @since GemFire version 7.5
- */
-
-@Component
-@Service("ClusterRegions")
-@Scope("singleton")
-public class ClusterRegionsService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- // String constants used for forming a json response
- private final String ENTRY_SIZE = "entrySize";
-
- // Comparator based upon regions entry count
- private static Comparator<Cluster.Region> regionEntryCountComparator = (r1, r2) -> {
- long r1Cnt = r1.getSystemRegionEntryCount();
- long r2Cnt = r2.getSystemRegionEntryCount();
- if (r1Cnt < r2Cnt) {
- return -1;
- } else if (r1Cnt > r2Cnt) {
- return 1;
- } else {
- return 0;
- }
- };
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // getting cluster's Regions
- responseJSON.put("regions", getRegionJson(cluster));
-
- // Send json response
- return responseJSON;
- }
-
- /**
- * This method is used to get various regions associated with the given
- * cluster and create json for each region fields and returns Array List for
- * all the regions associated with given cluster
- *
- * @param cluster
- * @return JSONObject Array List
- */
- private ArrayNode getRegionJson(Cluster cluster) {
-
- Long totalHeapSize = cluster.getTotalHeapSize();
- Long totalDiskUsage = cluster.getTotalBytesOnDisk();
-
- Map<String, Cluster.Region> clusterRegions = cluster.getClusterRegions();
-
- List<Cluster.Region> clusterRegionsList = new ArrayList<Cluster.Region>();
- clusterRegionsList.addAll(clusterRegions.values());
-
- Collections.sort(clusterRegionsList, regionEntryCountComparator);
-
- ArrayNode regionListJson = mapper.createArrayNode();
- for (int count = 0; count < clusterRegionsList.size(); count++) {
- Cluster.Region reg = clusterRegionsList.get(count);
- ObjectNode regionJSON = mapper.createObjectNode();
-
- regionJSON.put("name", reg.getName());
- regionJSON.put("totalMemory", totalHeapSize);
- regionJSON.put("systemRegionEntryCount", reg.getSystemRegionEntryCount());
- regionJSON.put("memberCount", reg.getMemberCount());
-
- final String regionType = reg.getRegionType();
- regionJSON.put("type", regionType);
- regionJSON.put("getsRate", reg.getGetsRate());
- regionJSON.put("putsRate", reg.getPutsRate());
-
- Cluster.Member[] clusterMembersList = cluster.getMembers();
-
- ArrayNode memberNameArray = mapper.createArrayNode();
- for (String memberName : reg.getMemberName()) {
- for (Cluster.Member member : clusterMembersList) {
- String name = member.getName();
- name = name.replace(":", "-");
- String id = member.getId();
- id = id.replace(":", "-");
-
- if ((memberName.equals(id)) || (memberName.equals(name))) {
- ObjectNode regionMember = mapper.createObjectNode();
- regionMember.put("id", member.getId());
- regionMember.put("name", member.getName());
- memberNameArray.add(regionMember);
- break;
- }
- }
- }
-
- regionJSON.put("memberNames", memberNameArray);
- regionJSON.put("entryCount", reg.getSystemRegionEntryCount());
-
- Boolean persistent = reg.getPersistentEnabled();
- if (persistent) {
- regionJSON.put("persistence", this.VALUE_ON);
- } else {
- regionJSON.put("persistence", this.VALUE_OFF);
- }
-
- Boolean isEnableOffHeapMemory = reg.isEnableOffHeapMemory();
- if (isEnableOffHeapMemory) {
- regionJSON.put("isEnableOffHeapMemory", this.VALUE_ON);
- } else {
- regionJSON.put("isEnableOffHeapMemory", this.VALUE_OFF);
- }
-
- String regCompCodec = reg.getCompressionCodec();
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(regCompCodec)) {
- regionJSON.put("compressionCodec", reg.getCompressionCodec());
- } else {
- regionJSON.put("compressionCodec", this.VALUE_NA);
- }
-
- if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController.getPulseProductSupport())) {
- // Convert region path to dot separated region path
- regionJSON.put("regionPath",
- StringUtils.getTableNameFromRegionName(reg.getFullPath()));
- regionJSON.put("id",
- StringUtils.getTableNameFromRegionName(reg.getFullPath()));
- } else {
- regionJSON.put("regionPath", reg.getFullPath());
- regionJSON.put("id", reg.getFullPath());
- }
-
- regionJSON.put("memoryReadsTrend",
- mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_GETS_PER_SEC_TREND)));
- regionJSON.put("memoryWritesTrend",
- mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_PUTS_PER_SEC_TREND)));
- regionJSON.put("diskReadsTrend",
- mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_READS_PER_SEC_TREND)));
- regionJSON.put("diskWritesTrend",
- mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_WRITES_PER_SEC_TREND)));
- regionJSON.put("emptyNodes", reg.getEmptyNode());
- Long entrySize = reg.getEntrySize();
- DecimalFormat form = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN_2);
- String entrySizeInMB = form.format(entrySize / (1024f * 1024f));
-
- if (entrySize < 0) {
- regionJSON.put(this.ENTRY_SIZE, this.VALUE_NA);
- } else {
- regionJSON.put(this.ENTRY_SIZE, entrySizeInMB);
- }
- regionJSON.put("dataUsage", reg.getDiskUsage());
- regionJSON.put("wanEnabled", reg.getWanEnabled());
- regionJSON.put("totalDataUsage", totalDiskUsage);
-
- regionJSON.put("memoryUsage", entrySizeInMB);
-
- regionListJson.add(regionJSON);
- }
-
- return regionListJson;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterSelectedRegionService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterSelectedRegionService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterSelectedRegionService.java
deleted file mode 100644
index 3051581..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterSelectedRegionService.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import com.vmware.gemfire.tools.pulse.internal.util.TimeUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * Class ClusterSelectedRegionService
- *
- * This class contains implementations of getting Cluster's selected region details
- *
- * @since GemFire version 7.5 cedar 2014-03-01
- */
-
-@Component
-@Service("ClusterSelectedRegion")
-@Scope("singleton")
-public class ClusterSelectedRegionService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- // String constants used for forming a json response
- private final String ENTRY_SIZE = "entrySize";
-
- // Comparator based upon regions entry count
- private static Comparator<Cluster.Member> memberCurrentHeapUsageComparator = (m1, m2) -> {
- long m1HeapUsage = m1.getCurrentHeapSize();
- long m2HeapUsage = m2.getCurrentHeapSize();
- if (m1HeapUsage < m2HeapUsage) {
- return -1;
- } else if (m1HeapUsage > m2HeapUsage) {
- return 1;
- } else {
- return 0;
- }
- };
-
- @Override
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- String userName = request.getUserPrincipal().getName();
- String pulseData = request.getParameter("pulseData");
- JsonNode parameterMap = mapper.readTree(pulseData);
- String selectedRegionFullPath = parameterMap.get("ClusterSelectedRegion").get("regionFullPath").textValue();
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // getting cluster's Regions
- responseJSON.put("clusterName", cluster.getServerName());
- responseJSON.put("userName", userName);
- responseJSON.put("selectedRegion", getSelectedRegionJson(cluster, selectedRegionFullPath));
-
- // Send json response
- return responseJSON;
- }
-
- /**
- * Create JSON for selected cluster region
- *
- * @param cluster
- * @return ObjectNode Array List
- */
- private ObjectNode getSelectedRegionJson(Cluster cluster, String selectedRegionFullPath) {
- PulseLogWriter LOGGER = PulseLogWriter.getLogger();
- Long totalHeapSize = cluster.getTotalHeapSize();
- Long totalDiskUsage = cluster.getTotalBytesOnDisk();
-
- Cluster.Region reg = cluster.getClusterRegion(selectedRegionFullPath);
- if (reg != null){
- ObjectNode regionJSON = mapper.createObjectNode();
-
- regionJSON.put("name", reg.getName());
- regionJSON.put("path", reg.getFullPath());
- regionJSON.put("totalMemory", totalHeapSize);
- regionJSON.put("systemRegionEntryCount", reg.getSystemRegionEntryCount());
- regionJSON.put("memberCount", reg.getMemberCount());
-
- final String regionType = reg.getRegionType();
- regionJSON.put("type", regionType);
- regionJSON.put("getsRate", reg.getGetsRate());
- regionJSON.put("putsRate", reg.getPutsRate());
- regionJSON.put("lruEvictionRate", reg.getLruEvictionRate());
-
- DecimalFormat df2 = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN);
- Cluster.Member[] clusterMembersList = cluster.getMembers();
-
- // collect members of this region
- List<Cluster.Member> clusterMembersL = new ArrayList<Cluster.Member>();
- for (String memberName : reg.getMemberName()) {
- for (Cluster.Member member : clusterMembersList) {
- String name = member.getName();
- name = name.replace(":", "-");
- String id = member.getId();
- id = id.replace(":", "-");
-
- if ((memberName.equals(id)) || (memberName.equals(name))) {
- clusterMembersL.add(member);
- }
- }
- }
-
- // sort members of this region
- Collections.sort(clusterMembersL, memberCurrentHeapUsageComparator);
-
- // return sorted member list by heap usage
- ArrayNode memberArray = mapper.createArrayNode();
- for (Cluster.Member member : clusterMembersL) {
- ObjectNode regionMember = mapper.createObjectNode();
- regionMember.put("memberId", member.getId());
- regionMember.put("name", member.getName());
- regionMember.put("host", member.getHost());
-
- long usedHeapSize = cluster.getUsedHeapSize();
- long currentHeap = member.getCurrentHeapSize();
- if (usedHeapSize > 0) {
- double heapUsage = ((double) currentHeap / (double) usedHeapSize) * 100;
- regionMember.put("heapUsage", Double.valueOf(df2.format(heapUsage)));
- } else {
- regionMember.put("heapUsage", 0);
- }
- double currentCPUUsage = member.getCpuUsage();
- double loadAvg = member.getLoadAverage();
-
- regionMember.put("cpuUsage", Double.valueOf(df2.format(currentCPUUsage)));
- regionMember.put("currentHeapUsage", member.getCurrentHeapSize());
- regionMember.put("isManager", member.isManager());
- regionMember.put("uptime", TimeUtils.convertTimeSecondsToHMS(member.getUptime()));
-
- regionMember.put("loadAvg", Double.valueOf(df2.format(loadAvg)));
- regionMember.put("sockets", member.getTotalFileDescriptorOpen());
- regionMember.put("threads", member.getNumThreads());
-
- if (PulseController.getPulseProductSupport().equalsIgnoreCase(
- PulseConstants.PRODUCT_NAME_SQLFIRE)){
- regionMember.put("clients", member.getNumSqlfireClients());
- }else{
- regionMember.put("clients", member.getMemberClientsHMap().size());
- }
- regionMember.put("queues", member.getQueueBacklog());
- memberArray.add(regionMember);
- }
-
- regionJSON.put("members", memberArray);
- regionJSON.put("entryCount", reg.getSystemRegionEntryCount());
-
- regionJSON.put("persistence", reg.getPersistentEnabled() ? PulseService.VALUE_ON : PulseService.VALUE_OFF);
-
- regionJSON.put("isEnableOffHeapMemory", reg.isEnableOffHeapMemory() ? PulseService.VALUE_ON : PulseService.VALUE_OFF);
-
- String regCompCodec = reg.getCompressionCodec();
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(regCompCodec)) {
- regionJSON.put("compressionCodec", reg.getCompressionCodec());
- } else {
- regionJSON.put("compressionCodec", PulseService.VALUE_NA);
- }
-
- if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController.getPulseProductSupport())) {
- // Convert region path to dot separated region path
- regionJSON.put("regionPath", StringUtils.getTableNameFromRegionName(reg.getFullPath()));
- } else {
- regionJSON.put("regionPath", reg.getFullPath());
- }
-
- regionJSON.put("memoryReadsTrend",
- mapper.<JsonNode>valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_GETS_PER_SEC_TREND)));
- regionJSON.put("memoryWritesTrend",
- mapper.<JsonNode>valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_PUTS_PER_SEC_TREND)));
- regionJSON.put("diskReadsTrend",
- mapper.<JsonNode>valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_READS_PER_SEC_TREND)));
- regionJSON.put("diskWritesTrend",
- mapper.<JsonNode>valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_WRITES_PER_SEC_TREND)));
-
- regionJSON.put("emptyNodes", reg.getEmptyNode());
- Long entrySize = reg.getEntrySize();
- DecimalFormat form = new DecimalFormat(
- PulseConstants.DECIMAL_FORMAT_PATTERN_2);
- String entrySizeInMB = form.format(entrySize / (1024f * 1024f));
- if (entrySize < 0) {
- regionJSON.put(this.ENTRY_SIZE, PulseService.VALUE_NA);
- } else {
- regionJSON.put(this.ENTRY_SIZE, entrySizeInMB);
- }
- regionJSON.put("dataUsage", reg.getDiskUsage());
- regionJSON.put("wanEnabled", reg.getWanEnabled());
- regionJSON.put("totalDataUsage", totalDiskUsage);
- regionJSON.put("memoryUsage", entrySizeInMB);
-
- LOGGER.fine("calling getSelectedRegionJson :: regionJSON = " + regionJSON);
- return regionJSON;
- } else {
- ObjectNode responseJSON = mapper.createObjectNode();
- responseJSON.put("errorOnRegion", "Region [" + selectedRegionFullPath + "] is not available");
- return responseJSON;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
deleted file mode 100644
index 01bedf2..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster.RegionOnMember;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.log.PulseLogWriter;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * Class ClusterSelectedRegionsMemberService
- *
- * This class contains implementations of getting Cluster's selected region's member specific details
- * for all members in that region
- *
- * @since GemFire version 7.5 cedar 2014-03-01
- */
-
-@Component
-@Service("ClusterSelectedRegionsMember")
-@Scope("singleton")
-public class ClusterSelectedRegionsMemberService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- //Comparator based upon regions entry count
- private static Comparator<Cluster.RegionOnMember> romEntryCountComparator = (m1, m2) -> {
- long m1EntryCount = m1.getEntryCount();
- long m2EntryCount = m2.getEntryCount();
- if (m1EntryCount < m2EntryCount) {
- return -1;
- } else if (m1EntryCount > m2EntryCount) {
- return 1;
- } else {
- return 0;
- }
- };
-
- @Override
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
- PulseLogWriter LOGGER = PulseLogWriter.getLogger();
- String userName = request.getUserPrincipal().getName();
- String pulseData = request.getParameter("pulseData");
- JsonNode parameterMap = mapper.readTree(pulseData);
- String selectedRegionFullPath = parameterMap.get("ClusterSelectedRegionsMember").get("regionFullPath").textValue();
- LOGGER.finest("ClusterSelectedRegionsMemberService selectedRegionFullPath = " + selectedRegionFullPath);
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // getting cluster's Regions
- responseJSON.put("clusterName", cluster.getServerName());
- responseJSON.put("userName", userName);
- responseJSON.put("selectedRegionsMembers", getSelectedRegionsMembersJson(cluster, selectedRegionFullPath));
- // Send json response
- return responseJSON;
- }
-
- /**
- * Create JSON for selected cluster region's all members
- */
- private ObjectNode getSelectedRegionsMembersJson(Cluster cluster, String selectedRegionFullPath) {
- PulseLogWriter LOGGER = PulseLogWriter.getLogger();
- Cluster.Region reg = cluster.getClusterRegion(selectedRegionFullPath);
-
- if (reg != null){
- ObjectNode regionMemberJSON = mapper.createObjectNode();
- RegionOnMember[] regionOnMembers = reg.getRegionOnMembers();
-
- //sort on entry count
- List<RegionOnMember> romList = Arrays.asList(regionOnMembers);
- Collections.sort(romList, romEntryCountComparator);
-
- for(RegionOnMember rom : romList) {
- ObjectNode memberJSON = mapper.createObjectNode();
- memberJSON.put("memberName", rom.getMemberName());
- memberJSON.put("regionFullPath", rom.getRegionFullPath());
- memberJSON.put("entryCount", rom.getEntryCount());
- memberJSON.put("entrySize", rom.getEntrySize());
-
- memberJSON.put("accessor", ((rom.getLocalMaxMemory() == 0) ? "True" : "False"));
- LOGGER.finest("calling getSelectedRegionsMembersJson :: rom.getLocalMaxMemory() = " + rom.getLocalMaxMemory());
-
- memberJSON.put("memoryReadsTrend",
- mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_GETS_PER_SEC_TREND)));
- LOGGER.finest("memoryReadsTrend = " + rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_GETS_PER_SEC_TREND).length);
-
- memberJSON.put("memoryWritesTrend",
- mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_PUTS_PER_SEC_TREND)));
- LOGGER.finest("memoryWritesTrend = " + rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_PUTS_PER_SEC_TREND).length);
-
- memberJSON.put("diskReadsTrend",
- mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_DISK_READS_PER_SEC_TREND)));
- LOGGER.finest("diskReadsTrend = " + rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_DISK_READS_PER_SEC_TREND).length);
-
- memberJSON.put("diskWritesTrend",
- mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_DISK_WRITES_PER_SEC_TREND)));
- LOGGER.finest("diskWritesTrend = " + rom.getRegionOnMemberStatisticTrend(RegionOnMember.REGION_ON_MEMBER_STAT_DISK_WRITES_PER_SEC_TREND).length);
-
- regionMemberJSON.put(rom.getMemberName(), memberJSON);
- }
-
- LOGGER.fine("calling getSelectedRegionsMembersJson :: regionJSON = " + regionMemberJSON);
- return regionMemberJSON;
- } else {
- ObjectNode responseJSON = mapper.createObjectNode();
- responseJSON.put("errorOnRegion", "Region [" + selectedRegionFullPath + "] is not available");
- return responseJSON;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterWANInfoService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterWANInfoService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterWANInfoService.java
deleted file mode 100644
index 3a3dbe3..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterWANInfoService.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.Map;
-
-/**
- * Class ClusterWANInfoService
- *
- * This class contains implementations of getting Cluster's WAN Informations
- * (connected clusters)
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("ClusterWANInfo")
-@Scope("singleton")
-public class ClusterWANInfoService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // members list
- ArrayNode connectedClusterListJson = mapper.createArrayNode();
-
- for (Map.Entry<String, Boolean> entry : cluster.getWanInformation()
- .entrySet()) {
- ObjectNode clusterJSON = mapper.createObjectNode();
- clusterJSON.put("clusterId", entry.getKey());
- clusterJSON.put("name", entry.getKey());
- clusterJSON.put("status", entry.getValue());
-
- connectedClusterListJson.add(clusterJSON);
- }
- // Response JSON
- responseJSON.put("connectedClusters", connectedClusterListJson);
- // Send json response
- return responseJSON;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberAsynchEventQueuesService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberAsynchEventQueuesService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberAsynchEventQueuesService.java
deleted file mode 100644
index 849dfe0..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberAsynchEventQueuesService.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class MemberAsynchEventQueuesService
- *
- * This class contains implementations of getting Asynchronous Event Queues
- * details of Cluster Member.
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("MemberAsynchEventQueues")
-@Scope("singleton")
-public class MemberAsynchEventQueuesService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- String memberName = requestDataJSON.get("MemberAsynchEventQueues").get("memberName").textValue();
-
- Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
-
- if (clusterMember != null) {
- // response
- Cluster.AsyncEventQueue[] asyncEventQueues = clusterMember
- .getMemberAsyncEventQueueList();
- ArrayNode asyncEventQueueJsonList = mapper.createArrayNode();
-
- if (asyncEventQueues != null && asyncEventQueues.length > 0) {
- responseJSON.put("isAsyncEventQueuesPresent", true);
-
- for (Cluster.AsyncEventQueue asyncEventQueue : asyncEventQueues) {
- ObjectNode asyncEventQueueJSON = mapper.createObjectNode();
- asyncEventQueueJSON.put("id", asyncEventQueue.getId());
- asyncEventQueueJSON.put("primary", asyncEventQueue.getPrimary());
- asyncEventQueueJSON.put("senderType", asyncEventQueue.isParallel());
- asyncEventQueueJSON
- .put("batchSize", asyncEventQueue.getBatchSize());
- asyncEventQueueJSON.put("batchTimeInterval",
- asyncEventQueue.getBatchTimeInterval());
- asyncEventQueueJSON.put("batchConflationEnabled",
- asyncEventQueue.isBatchConflationEnabled());
- asyncEventQueueJSON.put("asyncEventListener",
- asyncEventQueue.getAsyncEventListener());
- asyncEventQueueJSON.put("queueSize",
- asyncEventQueue.getEventQueueSize());
-
- asyncEventQueueJsonList.add(asyncEventQueueJSON);
- }
- responseJSON.put("asyncEventQueues", asyncEventQueueJsonList);
- } else {
- responseJSON.put("isAsyncEventQueuesPresent", false);
- }
-
- }
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberClientsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberClientsService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberClientsService.java
deleted file mode 100644
index 695f038..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberClientsService.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import com.vmware.gemfire.tools.pulse.internal.util.TimeUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class MemberClientsService
- *
- * This class contains implementations of getting Memeber's Clients.
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("MemberClients")
-@Scope("singleton")
-public class MemberClientsService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- // String constants used for forming a json response
- private final String NAME = "name";
- private final String HOST = "host";
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- String memberName = requestDataJSON.get("MemberClients").get("memberName").textValue();
-
- ArrayNode clientListJson = mapper.createArrayNode();
-
- Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
- if (clusterMember != null) {
- responseJSON.put("memberId", clusterMember.getId());
- responseJSON.put(this.NAME, clusterMember.getName());
- responseJSON.put(this.HOST, clusterMember.getHost());
-
- // member's clients
-
- Cluster.Client[] memberClients = clusterMember.getMemberClients();
- for (Cluster.Client memberClient : memberClients) {
- ObjectNode regionJSON = mapper.createObjectNode();
- regionJSON.put("clientId", memberClient.getId());
- regionJSON.put(this.NAME, memberClient.getName());
- regionJSON.put(this.HOST, memberClient.getHost());
- regionJSON.put("queueSize", memberClient.getQueueSize());
- regionJSON.put("clientCQCount", memberClient.getClientCQCount());
- regionJSON.put("isConnected", memberClient.isConnected() ? "Yes" : "No");
- regionJSON.put("isSubscriptionEnabled", memberClient.isSubscriptionEnabled() ? "Yes" : "No");
- regionJSON.put("uptime", TimeUtils.convertTimeSecondsToHMS(memberClient.getUptime()));
-
- regionJSON.put("cpuUsage", String.format("%.4f", memberClient.getCpuUsage()).toString());
- // regionJSON.put("cpuUsage", memberClient.getCpuUsage());
- regionJSON.put("threads", memberClient.getThreads());
- regionJSON.put("gets", memberClient.getGets());
- regionJSON.put("puts", memberClient.getPuts());
-
- clientListJson.add(regionJSON);
- }
- responseJSON.put("memberClients", clientListJson);
- }
- // Send json response
- return responseJSON;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberDetailsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberDetailsService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberDetailsService.java
deleted file mode 100644
index a37edc1..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberDetailsService.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.text.DecimalFormat;
-
-/**
- * Class MemberDetailsService
- *
- * This class contains implementations of getting Memeber's Statistics.
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("MemberDetails")
-@Scope("singleton")
-public class MemberDetailsService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- String userName = request.getUserPrincipal().getName();
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- String memberName = requestDataJSON.get("MemberDetails").get("memberName").textValue();
- DecimalFormat df2 = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN);
-
- Cluster.Member clusterMember = cluster.getMember(StringUtils
- .makeCompliantName(memberName));
- if (clusterMember != null) {
- responseJSON.put("memberId", clusterMember.getId());
- responseJSON.put("name", clusterMember.getName());
- responseJSON.put("host", clusterMember.getHost());
- responseJSON.put("clusterId", cluster.getId());
- responseJSON.put("clusterName", cluster.getServerName());
- responseJSON.put("userName", userName);
- double loadAvg = clusterMember.getLoadAverage();
- responseJSON.put("loadAverage", Double.valueOf(df2.format(loadAvg)));
- responseJSON.put("sockets", clusterMember.getTotalFileDescriptorOpen());
- responseJSON.put("threads", clusterMember.getNumThreads());
- responseJSON.put("offHeapFreeSize", clusterMember.getOffHeapFreeSize());
- responseJSON.put("offHeapUsedSize", clusterMember.getOffHeapUsedSize());
- responseJSON.put("regionsCount", clusterMember.getMemberRegionsList().length);
-
- // Number of member clients
- if (PulseController.getPulseProductSupport().equalsIgnoreCase(
- PulseConstants.PRODUCT_NAME_SQLFIRE)){
- responseJSON.put("numClients", clusterMember.getNumSqlfireClients());
- } else {
- responseJSON.put("numClients", clusterMember.getMemberClientsHMap().size());
- }
-
- Long diskUsageVal = clusterMember.getTotalDiskUsage();
- Double diskUsage = diskUsageVal.doubleValue() / 1024;
-
- responseJSON.put("diskStorageUsed", Double.valueOf(df2.format(diskUsage)));
-
- Cluster.Alert[] alertsList = cluster.getAlertsList();
-
- String status = "Normal";
-
- for (Cluster.Alert alert : alertsList) {
- if (clusterMember.getName().equals(alert.getMemberName())) {
- if (alert.getSeverity() == Cluster.Alert.SEVERE) {
- status = "Severe";
- break;
- } else if (alert.getSeverity() == Cluster.Alert.ERROR) {
- status = "Error";
- } else if (alert.getSeverity() == Cluster.Alert.WARNING) {
- status = "Warning";
- }
- }
- }
-
- responseJSON.put("status", status);
-
- } else {
- responseJSON.put("errorOnMember", "Member [" + memberName
- + "] is not available");
- }
-
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberDiskThroughputService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberDiskThroughputService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberDiskThroughputService.java
deleted file mode 100644
index fdc2ae0..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberDiskThroughputService.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class MemberDiskThroughputService
- *
- * This class contains implementations for getting Memeber's current Disk
- * Throughput trends over the time.
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("MemberDiskThroughput")
-@Scope("singleton")
-public class MemberDiskThroughputService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // members list
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- String memberName = requestDataJSON.get("MemberDiskThroughput").get("memberName").textValue();
-
- Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
-
- if (clusterMember != null) {
- // response
- responseJSON.put("throughputWrites", clusterMember.getThroughputWrites());
- responseJSON.put("throughputWritesTrend",
- mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_THROUGHPUT_WRITES)));
- responseJSON.put("throughputReads", clusterMember.getThroughputWrites());
- responseJSON.put("throughputReadsTrend",
- mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_THROUGHPUT_READS)));
- }
-
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberGCPausesService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberGCPausesService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberGCPausesService.java
deleted file mode 100644
index 7488ab2..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberGCPausesService.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class MemberGCPausesService
- *
- * This class contains implementations of getting Memeber's GC Pauses (JVM
- * Pauses) details and its trend over the time.
- *
- * @since GemFire version 7.5
- */
-
-@Component
-@Service("MemberGCPauses")
-@Scope("singleton")
-public class MemberGCPausesService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // members list
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- String memberName = requestDataJSON.get("MemberGCPauses").get("memberName").textValue();
- Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
-
- if (clusterMember != null) {
- // response
- responseJSON.put("gcPausesTrend",
- mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_GARBAGE_COLLECTION)));
- responseJSON.put("gcPausesCount", clusterMember.getGarbageCollectionCount());
- }
-
- // Send json response
- return responseJSON;
- }
-}
[21/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
new file mode 100644
index 0000000..e15d282
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
@@ -0,0 +1,3815 @@
+/*
+ *
+ * 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.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.commons.collections.buffer.CircularFifoBuffer;
+
+import javax.management.remote.JMXConnector;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.net.ConnectException;
+import java.net.URL;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.TimeZone;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+/**
+ * Class Cluster This class is the Data Model for the data used for the Pulse
+ * Web UI.
+ *
+ * @since GemFire version 7.0.Beta 2012-09-23
+ */
+public class Cluster extends Thread {
+ private static final int POLL_INTERVAL = 5000;
+ public static final int MAX_SAMPLE_SIZE = 180;
+ public static final int ALERTS_MAX_SIZE = 1000;
+ public static final int PAGE_ALERTS_MAX_SIZE = 100;
+
+ private final PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+ private final ResourceBundle resourceBundle = Repository.get()
+ .getResourceBundle();
+
+ private String jmxUserName;
+ private String jmxUserPassword;
+ private String serverName;
+ private String port;
+ private int stale = 0;
+ private double loadPerSec;
+
+ // start: fields defined in System MBean
+ private IClusterUpdater updater = null;
+ private DataBrowser dataBrowser = null;
+ private int memberCount;
+ private long clientConnectionCount;
+ private int locatorCount;
+ private int totalRegionCount;
+ private long totalHeapSize = 0L;
+ private long totalRegionEntryCount;
+ private int currentQueryCount;
+ private long totalBytesOnDisk;
+ private double diskReadsRate;
+ private double diskWritesRate;
+ private double writePerSec;
+ private double readPerSec;
+ private double queriesPerSec;
+ private int avgDiskStorage;
+ private int avgDiskWritesRate;
+ private int runningFunctionCount;
+ private long registeredCQCount;
+ private int subscriptionCount;
+ private int serverCount;
+ private int txnCommittedCount;
+ private int txnRollbackCount;
+ private long usedHeapSize = 0L;
+ private long garbageCollectionCount = 0L;
+ private int clusterId;
+ private int notificationPageNumber = 1;
+ private boolean connectedFlag;
+ private String connectionErrorMsg = "";
+
+ private Set<String> deletedMembers = new HashSet<String>();
+
+ private Map<String, List<Cluster.Member>> physicalToMember = new HashMap<String, List<Cluster.Member>>();
+
+ private Map<String, Cluster.Member> membersHMap = new HashMap<String, Cluster.Member>();
+
+ private Set<String> deletedRegions = new HashSet<String>();
+
+ private Map<String, Cluster.Region> clusterRegionMap = new ConcurrentHashMap<String, Cluster.Region>();
+ private List<Cluster.Alert> alertsList = new ArrayList<Cluster.Alert>();
+
+ private CircularFifoBuffer totalBytesOnDiskTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer throughoutWritesTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer throughoutReadsTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer writePerSecTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer readPerSecTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer queriesPerSecTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer memoryUsageTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer garbageCollectionTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private long previousJVMPauseCount = 0L;
+
+ private HashMap<String, Boolean> wanInformation = new HashMap<String, Boolean>();
+ private Map<String, Cluster.Statement> clusterStatementMap = new ConcurrentHashMap<String, Cluster.Statement>();
+
+ public static final int CLUSTER_STAT_TOTAL_BYTES_ON_DISK = 0;
+ public static final int CLUSTER_STAT_THROUGHPUT_WRITES = 1;
+ public static final int CLUSTER_STAT_THROUGHPUT_READS = 2;
+ public static final int CLUSTER_STAT_WRITES_PER_SECOND = 3;
+ public static final int CLUSTER_STAT_READ_PER_SECOND = 4;
+ public static final int CLUSTER_STAT_QUERIES_PER_SECOND = 5;
+ public static final int CLUSTER_STAT_MEMORY_USAGE = 6;
+ public static final int CLUSTER_STAT_GARBAGE_COLLECTION = 7;
+
+ // end: fields defined in System MBean
+
+ // used for updating member's client data
+ public static long LAST_UPDATE_TIME = 0;
+
+ public int getStaleStatus() {
+ return this.stale;
+ }
+
+ private boolean stopUpdates = false;
+
+ private static final int MAX_HOSTS = 40;
+
+ private final List<String> hostNames = new ArrayList<String>();
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public Object[] getStatisticTrend(int trendId) {
+
+ Object[] returnArray = null;
+ switch (trendId) {
+ case CLUSTER_STAT_TOTAL_BYTES_ON_DISK:
+ synchronized (this.totalBytesOnDiskTrend) {
+ returnArray = this.totalBytesOnDiskTrend.toArray();
+ }
+
+ break;
+
+ case CLUSTER_STAT_THROUGHPUT_READS:
+ synchronized (this.throughoutReadsTrend) {
+ returnArray = this.throughoutReadsTrend.toArray();
+ }
+ break;
+
+ case CLUSTER_STAT_THROUGHPUT_WRITES:
+ synchronized (this.throughoutWritesTrend) {
+ returnArray = this.throughoutWritesTrend.toArray();
+ }
+ break;
+
+ case CLUSTER_STAT_WRITES_PER_SECOND:
+ synchronized (this.writePerSecTrend) {
+ returnArray = this.writePerSecTrend.toArray();
+ }
+ break;
+
+ case CLUSTER_STAT_READ_PER_SECOND:
+ synchronized (this.readPerSecTrend) {
+ returnArray = this.readPerSecTrend.toArray();
+ }
+ break;
+
+ case CLUSTER_STAT_QUERIES_PER_SECOND:
+ synchronized (this.queriesPerSecTrend) {
+ returnArray = this.queriesPerSecTrend.toArray();
+ }
+ break;
+
+ case CLUSTER_STAT_MEMORY_USAGE:
+ synchronized (this.memoryUsageTrend) {
+ returnArray = this.memoryUsageTrend.toArray();
+ }
+ break;
+
+ case CLUSTER_STAT_GARBAGE_COLLECTION:
+ synchronized (this.garbageCollectionTrend) {
+ returnArray = this.garbageCollectionTrend.toArray();
+ }
+ break;
+ }
+
+ return returnArray;
+ }
+
+ /**
+ * Member Inner Class
+ *
+ *
+ */
+ public static class Member {
+
+ // start: fields defined in MBean
+ private String gemfireVersion;
+ private boolean manager;
+ private int totalRegionCount;
+ private String host;
+ private String hostnameForClients;
+ private String bindAddress;
+ private long currentHeapSize;
+ private long maxHeapSize;
+ private int avgHeapUsage;
+ private long OffHeapFreeSize;
+ private long OffHeapUsedSize;
+ private long totalBytesOnDisk;
+ private String memberPort;
+
+ private double cpuUsage = 0.0d;
+ private double hostCpuUsage = 0.0d;
+ private long uptime;
+ private String name;
+ private double getsRate;
+ private double putsRate;
+ private boolean isCache;
+ private boolean isGateway;
+ private boolean isLocator;
+ private boolean isServer;
+ private double loadAverage;
+ private int numThreads;
+ private long totalFileDescriptorOpen;
+ private long garbageCollectionCount = 0L;
+ private double throughputWrites;
+ private double throughputReads;
+ private long totalDiskUsage;
+ private String queueBacklog;
+ private String id;
+ private long numSqlfireClients = 0;
+
+ private List<String> serverGroups = new ArrayList<String>();
+ private List<String> redundancyZones = new ArrayList<String>();
+
+ private CircularFifoBuffer cpuUsageSamples = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer heapUsageSamples = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private HashMap<String, Cluster.Region> memberRegions = new HashMap<String, Cluster.Region>();
+ private HashMap<String, Cluster.Client> memberClientsHMap = new HashMap<String, Cluster.Client>();
+ private CircularFifoBuffer totalBytesOnDiskSamples = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer getsPerSecond = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer putsPerSecond = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer throughputWritesTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer throughputReadsTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer garbageCollectionSamples = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private long previousJVMPauseCount = 0L;
+
+ private Cluster.GatewayReceiver gatewayReceiver = null;
+ private List<Cluster.GatewaySender> gatewaySenderList = new ArrayList<Cluster.GatewaySender>();
+ private List<Cluster.AsyncEventQueue> asyncEventQueueList = new ArrayList<Cluster.AsyncEventQueue>();
+ // end: fields defined in MBean
+
+ public static final int MEMBER_STAT_GARBAGE_COLLECTION = 0;
+ public static final int MEMBER_STAT_HEAP_USAGE_SAMPLE = 1;
+ public static final int MEMBER_STAT_CPU_USAGE_SAMPLE = 2;
+ public static final int MEMBER_STAT_GETS_PER_SECOND = 3;
+ public static final int MEMBER_STAT_PUTS_PER_SECOND = 4;
+ public static final int MEMBER_STAT_THROUGHPUT_WRITES = 5;
+ public static final int MEMBER_STAT_THROUGHPUT_READS = 6;
+
+ public Cluster.Region[] getMemberRegionsList() {
+ Cluster.Region[] memberReg = null;
+ synchronized (memberRegions) {
+ memberReg = new Cluster.Region[memberRegions.size()];
+ memberReg = memberRegions.values().toArray(memberReg);
+ }
+
+ return memberReg;
+ }
+
+ public Cluster.Client[] getMemberClients() {
+ Cluster.Client[] memberClients = null;
+ synchronized (memberClientsHMap) {
+ memberClients = new Cluster.Client[memberClientsHMap.size()];
+ memberClients = memberClientsHMap.values().toArray(memberClients);
+ }
+
+ return memberClients;
+ }
+
+ public Cluster.GatewaySender[] getMemberGatewaySenders() {
+ Cluster.GatewaySender[] memberGWS = null;
+ synchronized (gatewaySenderList) {
+ memberGWS = new Cluster.GatewaySender[gatewaySenderList.size()];
+ memberGWS = gatewaySenderList.toArray(memberGWS);
+ }
+ return memberGWS;
+ }
+
+ public Cluster.AsyncEventQueue[] getMemberAsyncEventQueueList() {
+ Cluster.AsyncEventQueue[] memberAEQ = null;
+ synchronized (asyncEventQueueList) {
+ memberAEQ = new Cluster.AsyncEventQueue[asyncEventQueueList.size()];
+ memberAEQ = asyncEventQueueList.toArray(memberAEQ);
+ }
+ return memberAEQ;
+ }
+
+ public Object[] getMemberStatisticTrend(int trendId) {
+ Object[] returnArray = null;
+ switch (trendId) {
+ case MEMBER_STAT_GARBAGE_COLLECTION:
+ synchronized (this.garbageCollectionSamples) {
+ returnArray = this.garbageCollectionSamples.toArray();
+ }
+
+ break;
+
+ case MEMBER_STAT_HEAP_USAGE_SAMPLE:
+ synchronized (this.heapUsageSamples) {
+ returnArray = this.heapUsageSamples.toArray();
+ }
+ break;
+
+ case MEMBER_STAT_CPU_USAGE_SAMPLE:
+ synchronized (this.cpuUsageSamples) {
+ returnArray = this.cpuUsageSamples.toArray();
+ }
+ break;
+
+ case MEMBER_STAT_GETS_PER_SECOND:
+ synchronized (this.getsPerSecond) {
+ returnArray = this.getsPerSecond.toArray();
+ }
+ break;
+
+ case MEMBER_STAT_PUTS_PER_SECOND:
+ synchronized (this.putsPerSecond) {
+ returnArray = this.putsPerSecond.toArray();
+ }
+ break;
+
+ case MEMBER_STAT_THROUGHPUT_WRITES:
+ synchronized (this.throughputWritesTrend) {
+ returnArray = this.throughputWritesTrend.toArray();
+ }
+ break;
+
+ case MEMBER_STAT_THROUGHPUT_READS:
+ synchronized (this.throughputReadsTrend) {
+ returnArray = this.throughputReadsTrend.toArray();
+ }
+ break;
+ }
+
+ return returnArray;
+ }
+
+ public String getGemfireVersion() {
+ return gemfireVersion;
+ }
+
+ public void setGemfireVersion(String gemfireVersion) {
+ this.gemfireVersion = gemfireVersion;
+ }
+
+ public String getMemberPort() {
+ return this.memberPort;
+ }
+
+ public void setMemberPort(String memberPort) {
+ this.memberPort = memberPort;
+ }
+
+ public double getThroughputWrites() {
+ return this.throughputWrites;
+ }
+
+ public void setThroughputWrites(double throughputWrites) {
+ this.throughputWrites = throughputWrites;
+ }
+
+ public double getThroughputReads() {
+ return this.throughputReads;
+ }
+
+ public void setThroughputReads(double throughputReads) {
+ this.throughputReads = throughputReads;
+ }
+
+ public long getTotalDiskUsage() {
+ return this.totalDiskUsage;
+ }
+
+ public void setTotalDiskUsage(long totalDiskUsage) {
+ this.totalDiskUsage = totalDiskUsage;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public double getLoadAverage() {
+ return this.loadAverage;
+ }
+
+ public void setLoadAverage(Double loadAverage) {
+ this.loadAverage = loadAverage;
+ }
+
+ public String getHost() {
+ return this.host;
+ }
+
+ public String getHostnameForClients() {
+ if(StringUtils.isNotNullNotEmptyNotWhiteSpace(hostnameForClients))
+ return this.hostnameForClients;
+ else if(StringUtils.isNotNullNotEmptyNotWhiteSpace(bindAddress))
+ return this.bindAddress;
+ return null;
+ }
+
+ public long getUptime() {
+ return this.uptime;
+ }
+
+ public String getQueueBacklog() {
+ return this.queueBacklog;
+ }
+
+ public HashMap<String, Cluster.Region> getMemberRegions() {
+ return this.memberRegions;
+ }
+
+ public void setMemberRegions(HashMap<String, Cluster.Region> memberRegions) {
+ this.memberRegions = memberRegions;
+ }
+
+ public long getCurrentHeapSize() {
+ return this.currentHeapSize;
+ }
+
+ public void setCurrentHeapSize(long currentHeapSize) {
+ this.currentHeapSize = currentHeapSize;
+ }
+
+ public long getMaxHeapSize() {
+ return this.maxHeapSize;
+ }
+
+ public void setMaxHeapSize(long maxHeapSize) {
+ this.maxHeapSize = maxHeapSize;
+ }
+
+ public boolean isManager() {
+ return this.manager;
+ }
+
+ public void setManager(boolean manager) {
+ this.manager = manager;
+ }
+
+ public int getAvgHeapUsage() {
+ return this.avgHeapUsage;
+ }
+
+ public void setAvgHeapUsage(int avgHeapUsage) {
+ this.avgHeapUsage = avgHeapUsage;
+ }
+
+ public long getOffHeapFreeSize() {
+ return OffHeapFreeSize;
+ }
+
+ public void setOffHeapFreeSize(long offHeapFreeSize) {
+ this.OffHeapFreeSize = offHeapFreeSize;
+ }
+
+ public long getOffHeapUsedSize() {
+ return OffHeapUsedSize;
+ }
+
+ public void setOffHeapUsedSize(long offHeapUsedSize) {
+ this.OffHeapUsedSize = offHeapUsedSize;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public void setHostnameForClients(String hostnameForClients) {
+ this.hostnameForClients = hostnameForClients;
+ }
+
+ public void setBindAddress(String bindAddress){
+ this.bindAddress = bindAddress;
+ }
+
+ public void setUptime(long uptime) {
+ this.uptime = uptime;
+ }
+
+ public void setQueueBacklog(String queueBacklog) {
+ this.queueBacklog = queueBacklog;
+ }
+
+ public int getTotalRegionCount() {
+ return this.totalRegionCount;
+ }
+
+ public void setTotalRegionCount(int totalRegionCount) {
+ this.totalRegionCount = totalRegionCount;
+ }
+
+ public long getTotalBytesOnDisk() {
+ return this.totalBytesOnDisk;
+ }
+
+ public void setTotalBytesOnDisk(long totalBytesOnDisk) {
+ this.totalBytesOnDisk = totalBytesOnDisk;
+ }
+
+ public double getCpuUsage() {
+ return this.cpuUsage;
+ }
+
+ public void setCpuUsage(double cpuUsage) {
+ this.cpuUsage = cpuUsage;
+ }
+
+ public double getHostCpuUsage() {
+ return this.hostCpuUsage;
+ }
+
+ public void setHostCpuUsage(double hostCpuUsage) {
+ this.hostCpuUsage = hostCpuUsage;
+ }
+
+ public double getGetsRate() {
+ return this.getsRate;
+ }
+
+ public void setGetsRate(double getsRate) {
+ this.getsRate = getsRate;
+ }
+
+ public double getPutsRate() {
+ return this.putsRate;
+ }
+
+ public void setPutsRate(double putsRate) {
+ this.putsRate = putsRate;
+ }
+
+ public HashMap<String, Cluster.Client> getMemberClientsHMap() {
+ return this.memberClientsHMap;
+ }
+
+ public void setMemberClientsHMap(
+ HashMap<String, Cluster.Client> memberClientsHMap) {
+ this.memberClientsHMap = memberClientsHMap;
+ }
+
+ public boolean isCache() {
+ return this.isCache;
+ }
+
+ public void setCache(boolean isCache) {
+ this.isCache = isCache;
+ }
+
+ public boolean isGateway() {
+ return this.isGateway;
+ }
+
+ public void setGateway(boolean isGateway) {
+ this.isGateway = isGateway;
+ }
+
+ public int getNumThreads() {
+ return this.numThreads;
+ }
+
+ public void setNumThreads(int numThreads) {
+ this.numThreads = numThreads;
+ }
+
+ public long getTotalFileDescriptorOpen() {
+ return this.totalFileDescriptorOpen;
+ }
+
+ public void setTotalFileDescriptorOpen(long totalFileDescriptorOpen) {
+ this.totalFileDescriptorOpen = totalFileDescriptorOpen;
+ }
+
+ public long getGarbageCollectionCount() {
+ return this.garbageCollectionCount;
+ }
+
+ public void setGarbageCollectionCount(long garbageCollectionCount) {
+ this.garbageCollectionCount = garbageCollectionCount;
+ }
+
+ public boolean isLocator() {
+ return this.isLocator;
+ }
+
+ public void setLocator(boolean isLocator) {
+ this.isLocator = isLocator;
+ }
+
+ public Cluster.GatewayReceiver getGatewayReceiver() {
+ return this.gatewayReceiver;
+ }
+
+ public void setGatewayReceiver(Cluster.GatewayReceiver gatewayReceiver) {
+ this.gatewayReceiver = gatewayReceiver;
+ }
+
+ public List<Cluster.GatewaySender> getGatewaySenderList() {
+ return this.gatewaySenderList;
+ }
+
+ public void setGatewaySenderList(
+ List<Cluster.GatewaySender> gatewaySenderList) {
+ this.gatewaySenderList = gatewaySenderList;
+ }
+
+ public List<Cluster.AsyncEventQueue> getAsyncEventQueueList() {
+ return this.asyncEventQueueList;
+ }
+
+ public void setAsyncEventQueueList(
+ List<Cluster.AsyncEventQueue> asyncEventQueueList) {
+ this.asyncEventQueueList = asyncEventQueueList;
+ }
+
+ public boolean isServer() {
+ return this.isServer;
+ }
+
+ public void setServer(boolean isServer) {
+ this.isServer = isServer;
+ }
+
+ public List<String> getServerGroups() {
+ return this.serverGroups;
+ }
+
+ public void setServerGroups(List<String> serverGroups) {
+ this.serverGroups = serverGroups;
+ }
+
+ public List<String> getRedundancyZones() {
+ return this.redundancyZones;
+ }
+
+ public void setRedundancyZones(List<String> redundancyZones) {
+ this.redundancyZones = redundancyZones;
+ }
+
+ public CircularFifoBuffer getCpuUsageSamples() {
+ return this.cpuUsageSamples;
+ }
+
+ public void setCpuUsageSamples(CircularFifoBuffer cpuUsageSamples) {
+ this.cpuUsageSamples = cpuUsageSamples;
+ }
+
+ public CircularFifoBuffer getHeapUsageSamples() {
+ return this.heapUsageSamples;
+ }
+
+ public void setHeapUsageSamples(CircularFifoBuffer heapUsageSamples) {
+ this.heapUsageSamples = heapUsageSamples;
+ }
+
+ public CircularFifoBuffer getTotalBytesOnDiskSamples() {
+ return this.totalBytesOnDiskSamples;
+ }
+
+ public void setTotalBytesOnDiskSamples(
+ CircularFifoBuffer totalBytesOnDiskSamples) {
+ this.totalBytesOnDiskSamples = totalBytesOnDiskSamples;
+ }
+
+ public CircularFifoBuffer getGetsPerSecond() {
+ return this.getsPerSecond;
+ }
+
+ public void setGetsPerSecond(CircularFifoBuffer getsPerSecond) {
+ this.getsPerSecond = getsPerSecond;
+ }
+
+ public CircularFifoBuffer getPutsPerSecond() {
+ return this.putsPerSecond;
+ }
+
+ public void setPutsPerSecond(CircularFifoBuffer putsPerSecond) {
+ this.putsPerSecond = putsPerSecond;
+ }
+
+ public CircularFifoBuffer getThroughputWritesTrend() {
+ return this.throughputWritesTrend;
+ }
+
+ public void setThroughputWritesTrend(
+ CircularFifoBuffer throughputWritesTrend) {
+ this.throughputWritesTrend = throughputWritesTrend;
+ }
+
+ public CircularFifoBuffer getThroughputReadsTrend() {
+ return this.throughputReadsTrend;
+ }
+
+ public void setThroughputReadsTrend(CircularFifoBuffer throughputReadsTrend) {
+ this.throughputReadsTrend = throughputReadsTrend;
+ }
+
+ public CircularFifoBuffer getGarbageCollectionSamples() {
+ return this.garbageCollectionSamples;
+ }
+
+ public void setGarbageCollectionSamples(
+ CircularFifoBuffer garbageCollectionSamples) {
+ this.garbageCollectionSamples = garbageCollectionSamples;
+ }
+
+ public long getPreviousJVMPauseCount() {
+ return this.previousJVMPauseCount;
+ }
+
+ public void setPreviousJVMPauseCount(long previousJVMPauseCount) {
+ this.previousJVMPauseCount = previousJVMPauseCount;
+ }
+
+ public long getNumSqlfireClients() {
+ return numSqlfireClients;
+ }
+
+ public void setNumSqlfireClients(long numSqlfireClients) {
+ this.numSqlfireClients = numSqlfireClients;
+ }
+
+ public void updateMemberClientsHMap(
+ HashMap<String, Cluster.Client> memberClientsHM) {
+
+ if (Cluster.LAST_UPDATE_TIME == 0) {
+ Cluster.LAST_UPDATE_TIME = System.nanoTime();
+ }
+
+ long systemNanoTime = System.nanoTime();
+
+ for (Map.Entry<String, Cluster.Client> entry : memberClientsHM.entrySet()) {
+ String clientId = entry.getKey();
+ Cluster.Client client = entry.getValue();
+
+ if (memberClientsHMap.get(clientId) != null) {
+ Client existingClient = memberClientsHMap.get(clientId);
+ Client updatedClient = memberClientsHM.get(clientId);
+
+ existingClient.setConnected(updatedClient.isConnected());
+ existingClient.setGets(updatedClient.getGets());
+ existingClient.setPuts(updatedClient.getPuts());
+ existingClient.setCpus(updatedClient.getCpus());
+ existingClient.setQueueSize(updatedClient.getQueueSize());
+ existingClient.setStatus(updatedClient.getStatus());
+ existingClient.setThreads(updatedClient.getThreads());
+ existingClient.setClientCQCount(updatedClient.getClientCQCount());
+ existingClient.setSubscriptionEnabled(updatedClient.isSubscriptionEnabled());
+ long elapsedTime = updatedClient.getUptime()
+ - existingClient.getUptime();
+ existingClient.setUptime(updatedClient.getUptime());
+
+ // set cpu usage
+ long lastCPUTime = 0;
+ lastCPUTime = existingClient.getProcessCpuTime();
+ long currCPUTime = 0;
+ currCPUTime = updatedClient.getProcessCpuTime();
+
+ double newCPUTime = (double) (currCPUTime - lastCPUTime)
+ / (elapsedTime * 1000000000);
+
+ double newCPUUsage = 0;
+ int availableCpus = updatedClient.getCpus();
+ if (availableCpus > 0) {
+ newCPUUsage = newCPUTime / availableCpus;
+ }
+
+ existingClient.setCpuUsage(newCPUUsage);
+ existingClient.setProcessCpuTime(currCPUTime);
+
+ } else {
+ // Add client to clients list
+ memberClientsHMap.put(clientId, client);
+ }
+
+ }
+
+ // Remove unwanted entries from clients list
+ HashMap<String, Cluster.Client> memberClientsHMapNew = new HashMap<String, Cluster.Client>();
+ for (Map.Entry<String, Cluster.Client> entry : memberClientsHMap
+ .entrySet()) {
+ String clientId = entry.getKey();
+ if (memberClientsHM.get(clientId) != null) {
+ memberClientsHMapNew.put(clientId, memberClientsHMap.get(clientId));
+ }
+ }
+ // replace existing memberClientsHMap by memberClientsHMapNew
+ this.setMemberClientsHMap(memberClientsHMapNew);
+
+ // update last update time
+ Cluster.LAST_UPDATE_TIME = systemNanoTime;
+
+ }
+
+ }
+
+ /**
+ * Member Inner Class
+ *
+ *
+ */
+ public static class Statement {
+
+ private String queryDefn;
+ private long numTimesCompiled;
+ private long numExecution;
+ private long numExecutionsInProgress;
+ private long numTimesGlobalIndexLookup;
+ private long numRowsModified;
+ private long parseTime;
+ private long bindTime;
+ private long optimizeTime;
+ private long routingInfoTime;
+ private long generateTime;
+ private long totalCompilationTime;
+ private long executionTime;
+ private long projectionTime;
+ private long totalExecutionTime;
+ private long rowsModificationTime;
+ private long qNNumRowsSeen;
+ private long qNMsgSendTime;
+ private long qNMsgSerTime;
+ private long qNRespDeSerTime;
+
+ public static String[] getGridColumnNames() {
+ String[] colNames = new String[] {
+ PulseConstants.MBEAN_COLNAME_QUERYDEFINITION,
+ PulseConstants.MBEAN_COLNAME_NUMEXECUTION,
+ PulseConstants.MBEAN_COLNAME_TOTALEXECUTIONTIME,
+ PulseConstants.MBEAN_COLNAME_NUMEXECUTIONSINPROGRESS,
+ PulseConstants.MBEAN_COLNAME_NUMTIMESCOMPILED,
+ PulseConstants.MBEAN_COLNAME_NUMTIMESGLOBALINDEXLOOKUP,
+ PulseConstants.MBEAN_COLNAME_NUMROWSMODIFIED,
+ PulseConstants.MBEAN_COLNAME_PARSETIME,
+ PulseConstants.MBEAN_COLNAME_BINDTIME,
+ PulseConstants.MBEAN_COLNAME_OPTIMIZETIME,
+ PulseConstants.MBEAN_COLNAME_ROUTINGINFOTIME,
+ PulseConstants.MBEAN_COLNAME_GENERATETIME,
+ PulseConstants.MBEAN_COLNAME_TOTALCOMPILATIONTIME,
+ PulseConstants.MBEAN_COLNAME_EXECUTIONTIME,
+ PulseConstants.MBEAN_COLNAME_PROJECTIONTIME,
+ PulseConstants.MBEAN_COLNAME_ROWSMODIFICATIONTIME,
+ PulseConstants.MBEAN_COLNAME_QNNUMROWSSEEN,
+ PulseConstants.MBEAN_COLNAME_QNMSGSENDTIME,
+ PulseConstants.MBEAN_COLNAME_QNMSGSERTIME,
+ PulseConstants.MBEAN_COLNAME_QNRESPDESERTIME };
+ return colNames;
+ }
+
+ public static String[] getGridColumnAttributes() {
+ String[] colAttributes = new String[] {
+ PulseConstants.MBEAN_ATTRIBUTE_QUERYDEFINITION,
+ PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTION,
+ PulseConstants.MBEAN_ATTRIBUTE_TOTALEXECUTIONTIME,
+ PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTIONSINPROGRESS,
+ PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESCOMPILED,
+ PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESGLOBALINDEXLOOKUP,
+ PulseConstants.MBEAN_ATTRIBUTE_NUMROWSMODIFIED,
+ PulseConstants.MBEAN_ATTRIBUTE_PARSETIME,
+ PulseConstants.MBEAN_ATTRIBUTE_BINDTIME,
+ PulseConstants.MBEAN_ATTRIBUTE_OPTIMIZETIME,
+ PulseConstants.MBEAN_ATTRIBUTE_ROUTINGINFOTIME,
+ PulseConstants.MBEAN_ATTRIBUTE_GENERATETIME,
+ PulseConstants.MBEAN_ATTRIBUTE_TOTALCOMPILATIONTIME,
+ PulseConstants.MBEAN_ATTRIBUTE_EXECUTIONTIME,
+ PulseConstants.MBEAN_ATTRIBUTE_PROJECTIONTIME,
+
+ PulseConstants.MBEAN_ATTRIBUTE_ROWSMODIFICATIONTIME,
+ PulseConstants.MBEAN_ATTRIBUTE_QNNUMROWSSEEN,
+ PulseConstants.MBEAN_ATTRIBUTE_QNMSGSENDTIME,
+ PulseConstants.MBEAN_ATTRIBUTE_QNMSGSERTIME,
+ PulseConstants.MBEAN_ATTRIBUTE_QNRESPDESERTIME };
+ return colAttributes;
+ }
+
+ public static int[] getGridColumnWidths() {
+ int[] colWidths = new int[] { 300, 150, 160, 180, 150, 200, 150, 130, 130,
+ 160, 140, 180, 170, 160, 130, 190, 170, 170, 170, 200 };
+ return colWidths;
+ }
+
+ /**
+ * @return the numTimesCompiled
+ */
+ public String getQueryDefinition() {
+ return queryDefn;
+ }
+
+ /**
+ * @param queryDefn
+ * the query to set
+ */
+ public void setQueryDefinition(String queryDefn) {
+ this.queryDefn = queryDefn;
+ }
+
+ /**
+ * @return the numTimesCompiled
+ */
+ public long getNumTimesCompiled() {
+ return numTimesCompiled;
+ }
+
+ /**
+ * @param numTimesCompiled
+ * the numTimesCompiled to set
+ */
+ public void setNumTimesCompiled(long numTimesCompiled) {
+ this.numTimesCompiled = numTimesCompiled;
+ }
+
+ /**
+ * @return the numExecution
+ */
+ public long getNumExecution() {
+ return numExecution;
+ }
+
+ /**
+ * @param numExecution
+ * the numExecution to set
+ */
+ public void setNumExecution(long numExecution) {
+ this.numExecution = numExecution;
+ }
+
+ /**
+ * @return the numExecutionsInProgress
+ */
+ public long getNumExecutionsInProgress() {
+ return numExecutionsInProgress;
+ }
+
+ /**
+ * @param numExecutionsInProgress
+ * the numExecutionsInProgress to set
+ */
+ public void setNumExecutionsInProgress(long numExecutionsInProgress) {
+ this.numExecutionsInProgress = numExecutionsInProgress;
+ }
+
+ /**
+ * @return the numTimesGlobalIndexLookup
+ */
+ public long getNumTimesGlobalIndexLookup() {
+ return numTimesGlobalIndexLookup;
+ }
+
+ /**
+ * @param numTimesGlobalIndexLookup
+ * the numTimesGlobalIndexLookup to set
+ */
+ public void setNumTimesGlobalIndexLookup(long numTimesGlobalIndexLookup) {
+ this.numTimesGlobalIndexLookup = numTimesGlobalIndexLookup;
+ }
+
+ /**
+ * @return the numRowsModified
+ */
+ public long getNumRowsModified() {
+ return numRowsModified;
+ }
+
+ /**
+ * @param numRowsModified
+ * the numRowsModified to set
+ */
+ public void setNumRowsModified(long numRowsModified) {
+ this.numRowsModified = numRowsModified;
+ }
+
+ /**
+ * @return the parseTime
+ */
+ public long getParseTime() {
+ return parseTime;
+ }
+
+ /**
+ * @param parseTime
+ * the parseTime to set
+ */
+ public void setParseTime(long parseTime) {
+ this.parseTime = parseTime;
+ }
+
+ /**
+ * @return the bindTime
+ */
+ public long getBindTime() {
+ return bindTime;
+ }
+
+ /**
+ * @param bindTime
+ * the bindTime to set
+ */
+ public void setBindTime(long bindTime) {
+ this.bindTime = bindTime;
+ }
+
+ /**
+ * @return the optimizeTime
+ */
+ public long getOptimizeTime() {
+ return optimizeTime;
+ }
+
+ /**
+ * @param optimizeTime
+ * the optimizeTime to set
+ */
+ public void setOptimizeTime(long optimizeTime) {
+ this.optimizeTime = optimizeTime;
+ }
+
+ /**
+ * @return the routingInfoTime
+ */
+ public long getRoutingInfoTime() {
+ return routingInfoTime;
+ }
+
+ /**
+ * @param routingInfoTime
+ * the routingInfoTime to set
+ */
+ public void setRoutingInfoTime(long routingInfoTime) {
+ this.routingInfoTime = routingInfoTime;
+ }
+
+ /**
+ * @return the generateTime
+ */
+ public long getGenerateTime() {
+ return generateTime;
+ }
+
+ /**
+ * @param generateTime
+ * the generateTime to set
+ */
+ public void setGenerateTime(long generateTime) {
+ this.generateTime = generateTime;
+ }
+
+ /**
+ * @return the totalCompilationTime
+ */
+ public long getTotalCompilationTime() {
+ return totalCompilationTime;
+ }
+
+ /**
+ * @param totalCompilationTime
+ * the totalCompilationTime to set
+ */
+ public void setTotalCompilationTime(long totalCompilationTime) {
+ this.totalCompilationTime = totalCompilationTime;
+ }
+
+ /**
+ * @return the executionTime
+ */
+ public long getExecutionTime() {
+ return executionTime;
+ }
+
+ /**
+ * @param executionTime
+ * the executionTime to set
+ */
+ public void setExecutionTime(long executionTime) {
+ this.executionTime = executionTime;
+ }
+
+ /**
+ * @return the projectionTime
+ */
+ public long getProjectionTime() {
+ return projectionTime;
+ }
+
+ /**
+ * @param projectionTime
+ * the projectionTime to set
+ */
+ public void setProjectionTime(long projectionTime) {
+ this.projectionTime = projectionTime;
+ }
+
+ /**
+ * @return the totalExecutionTime
+ */
+ public long getTotalExecutionTime() {
+ return totalExecutionTime;
+ }
+
+ /**
+ * @param totalExecutionTime
+ * the totalExecutionTime to set
+ */
+ public void setTotalExecutionTime(long totalExecutionTime) {
+ this.totalExecutionTime = totalExecutionTime;
+ }
+
+ /**
+ * @return the rowsModificationTime
+ */
+ public long getRowsModificationTime() {
+ return rowsModificationTime;
+ }
+
+ /**
+ * @param rowsModificationTime
+ * the rowsModificationTime to set
+ */
+ public void setRowsModificationTime(long rowsModificationTime) {
+ this.rowsModificationTime = rowsModificationTime;
+ }
+
+ /**
+ * @return the qNNumRowsSeen
+ */
+ public long getqNNumRowsSeen() {
+ return qNNumRowsSeen;
+ }
+
+ /**
+ * @param qNNumRowsSeen
+ * the qNNumRowsSeen to set
+ */
+ public void setqNNumRowsSeen(long qNNumRowsSeen) {
+ this.qNNumRowsSeen = qNNumRowsSeen;
+ }
+
+ /**
+ * @return the qNMsgSendTime
+ */
+ public long getqNMsgSendTime() {
+ return qNMsgSendTime;
+ }
+
+ /**
+ * @param qNMsgSendTime
+ * the qNMsgSendTime to set
+ */
+ public void setqNMsgSendTime(long qNMsgSendTime) {
+ this.qNMsgSendTime = qNMsgSendTime;
+ }
+
+ /**
+ * @return the qNMsgSerTime
+ */
+ public long getqNMsgSerTime() {
+ return qNMsgSerTime;
+ }
+
+ /**
+ * @param qNMsgSerTime
+ * the qNMsgSerTime to set
+ */
+ public void setqNMsgSerTime(long qNMsgSerTime) {
+ this.qNMsgSerTime = qNMsgSerTime;
+ }
+
+ /**
+ * @return the qNRespDeSerTime
+ */
+ public long getqNRespDeSerTime() {
+ return qNRespDeSerTime;
+ }
+
+ /**
+ * @param qNRespDeSerTime
+ * the qNRespDeSerTime to set
+ */
+ public void setqNRespDeSerTime(long qNRespDeSerTime) {
+ this.qNRespDeSerTime = qNRespDeSerTime;
+ }
+ }
+
+ public static class RegionOnMember {
+
+ public static final int REGION_ON_MEMBER_STAT_GETS_PER_SEC_TREND = 0;
+ public static final int REGION_ON_MEMBER_STAT_PUTS_PER_SEC_TREND = 1;
+ public static final int REGION_ON_MEMBER_STAT_DISK_READS_PER_SEC_TREND = 3;
+ public static final int REGION_ON_MEMBER_STAT_DISK_WRITES_PER_SEC_TREND = 4;
+
+ private String regionFullPath;
+ private String memberName;
+ private long entrySize;
+ private long entryCount;
+ private double getsRate;
+ private double putsRate;
+ private double diskGetsRate;
+ private double diskPutsRate;
+ private int localMaxMemory;
+
+ private CircularFifoBuffer getsPerSecTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer putsPerSecTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer diskReadsPerSecTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer diskWritesPerSecTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+
+ /**
+ * @return the entrySize
+ */
+ public long getEntrySize() {
+ return entrySize;
+ }
+
+ /**
+ * @param entrySize the entrySize to set
+ */
+ public void setEntrySize(long entrySize) {
+ this.entrySize = entrySize;
+ }
+
+ /**
+ * @return the entryCount
+ */
+ public long getEntryCount() {
+ return entryCount;
+ }
+
+ /**
+ * @param entryCount the entryCount to set
+ */
+ public void setEntryCount(long entryCount) {
+ this.entryCount = entryCount;
+ }
+
+ /**
+ * @return the putsRate
+ */
+ public double getPutsRate() {
+ return putsRate;
+ }
+
+ /**
+ * @param putsRate the putsRate to set
+ */
+ public void setPutsRate(double putsRate) {
+ this.putsRate = putsRate;
+ }
+
+ /**
+ * @return the getsRate
+ */
+ public double getGetsRate() {
+ return getsRate;
+ }
+
+ /**
+ * @param getsRate the getsRate to set
+ */
+ public void setGetsRate(double getsRate) {
+ this.getsRate = getsRate;
+ }
+
+ /**
+ * @return the diskGetsRate
+ */
+ public double getDiskGetsRate() {
+ return diskGetsRate;
+ }
+
+ /**
+ * @param diskGetsRate the diskGetsRate to set
+ */
+ public void setDiskGetsRate(double diskGetsRate) {
+ this.diskGetsRate = diskGetsRate;
+ }
+
+ /**
+ * @return the diskPutsRate
+ */
+ public double getDiskPutsRate() {
+ return diskPutsRate;
+ }
+
+ /**
+ * @param diskPutsRate the diskPutsRate to set
+ */
+ public void setDiskPutsRate(double diskPutsRate) {
+ this.diskPutsRate = diskPutsRate;
+ }
+
+ /**
+ * @return the local maximum memory
+ */
+ public int getLocalMaxMemory() {
+ return this.localMaxMemory;
+ }
+
+ /**
+ * @param localMaxMemory
+ */
+ public void setLocalMaxMemory(int localMaxMemory) {
+ this.localMaxMemory = localMaxMemory;
+ }
+
+ /**
+ * @return the getsPerSecTrend
+ */
+ public CircularFifoBuffer getGetsPerSecTrend() {
+ return getsPerSecTrend;
+ }
+
+ /**
+ * @param getsPerSecTrend the getsPerSecTrend to set
+ */
+ public void setGetsPerSecTrend(CircularFifoBuffer getsPerSecTrend) {
+ this.getsPerSecTrend = getsPerSecTrend;
+ }
+
+ /**
+ * @return the putsPerSecTrend
+ */
+ public CircularFifoBuffer getPutsPerSecTrend() {
+ return putsPerSecTrend;
+ }
+
+ /**
+ * @param putsPerSecTrend the putsPerSecTrend to set
+ */
+ public void setPutsPerSecTrend(CircularFifoBuffer putsPerSecTrend) {
+ this.putsPerSecTrend = putsPerSecTrend;
+ }
+
+ /**
+ * @return the diskReadsPerSecTrend
+ */
+ public CircularFifoBuffer getDiskReadsPerSecTrend() {
+ return diskReadsPerSecTrend;
+ }
+
+ /**
+ * @param diskReadsPerSecTrend the diskReadsPerSecTrend to set
+ */
+ public void setDiskReadsPerSecTrend(CircularFifoBuffer diskReadsPerSecTrend) {
+ this.diskReadsPerSecTrend = diskReadsPerSecTrend;
+ }
+
+ /**
+ * @return the diskWritesPerSecTrend
+ */
+ public CircularFifoBuffer getDiskWritesPerSecTrend() {
+ return diskWritesPerSecTrend;
+ }
+
+ /**
+ * @param diskWritesPerSecTrend the diskWritesPerSecTrend to set
+ */
+ public void setDiskWritesPerSecTrend(CircularFifoBuffer diskWritesPerSecTrend) {
+ this.diskWritesPerSecTrend = diskWritesPerSecTrend;
+ }
+
+ public Object[] getRegionOnMemberStatisticTrend(int trendId) {
+
+ Object[] returnArray = null;
+ switch (trendId) {
+ case REGION_ON_MEMBER_STAT_GETS_PER_SEC_TREND:
+ synchronized (this.getsPerSecTrend) {
+ returnArray = this.getsPerSecTrend.toArray();
+ }
+ break;
+
+ case REGION_ON_MEMBER_STAT_PUTS_PER_SEC_TREND:
+ synchronized (this.putsPerSecTrend) {
+ returnArray = this.putsPerSecTrend.toArray();
+ }
+ break;
+
+ case REGION_ON_MEMBER_STAT_DISK_READS_PER_SEC_TREND:
+ synchronized (this.diskReadsPerSecTrend) {
+ returnArray = this.diskReadsPerSecTrend.toArray();
+ }
+ break;
+
+ case REGION_ON_MEMBER_STAT_DISK_WRITES_PER_SEC_TREND:
+ synchronized (this.diskWritesPerSecTrend) {
+ returnArray = this.diskWritesPerSecTrend.toArray();
+ }
+ break;
+ }
+
+ return returnArray;
+ }
+
+ /**
+ * @return the regionFullPath
+ */
+ public String getRegionFullPath() {
+ return regionFullPath;
+ }
+
+ /**
+ * @param regionFullPath the regionFullPath to set
+ */
+ public void setRegionFullPath(String regionFullPath) {
+ this.regionFullPath = regionFullPath;
+ }
+
+ /**
+ * @return the memberName
+ */
+ public String getMemberName() {
+ return memberName;
+ }
+
+ /**
+ * @param memberName the memberName to set
+ */
+ public void setMemberName(String memberName) {
+ this.memberName = memberName;
+ }
+ }
+
+ /**
+ * Region Inner Class
+ *
+ *
+ */
+ public static class Region {
+ // start: fields defined in MBean
+ private String fullPath;
+ private double diskReadsRate;
+ private double diskWritesRate;
+ private double getsRate;
+ private double putsRate;
+ private double lruEvictionRate;
+ private String regionType;
+ private long systemRegionEntryCount;
+ private int memberCount;
+ private String name;
+ private boolean persistentEnabled;
+ private long entrySize;
+ private boolean wanEnabled;
+ private int emptyNode;
+ private long diskUsage;
+ private String scope;
+ private String diskStoreName;
+ private boolean diskSynchronous;
+ private boolean enableOffHeapMemory;
+ private String compressionCodec = "";
+
+ private List<String> memberName = new ArrayList<String>();
+ private List<RegionOnMember> regionOnMembers = new ArrayList<RegionOnMember>();
+ private CircularFifoBuffer getsPerSecTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer putsPerSecTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer diskReadsPerSecTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+ private CircularFifoBuffer diskWritesPerSecTrend = new CircularFifoBuffer(
+ MAX_SAMPLE_SIZE);
+
+ public static final int REGION_STAT_GETS_PER_SEC_TREND = 0;
+ public static final int REGION_STAT_PUTS_PER_SEC_TREND = 1;
+ public static final int REGION_STAT_DISK_READS_PER_SEC_TREND = 3;
+ public static final int REGION_STAT_DISK_WRITES_PER_SEC_TREND = 4;
+
+ // end: fields defined in MBean
+
+ public Object[] getRegionStatisticTrend(int trendId) {
+
+ Object[] returnArray = null;
+ switch (trendId) {
+ case REGION_STAT_GETS_PER_SEC_TREND:
+ synchronized (this.getsPerSecTrend) {
+ returnArray = this.getsPerSecTrend.toArray();
+ }
+ break;
+
+ case REGION_STAT_PUTS_PER_SEC_TREND:
+ synchronized (this.putsPerSecTrend) {
+ returnArray = this.putsPerSecTrend.toArray();
+ }
+ break;
+
+ case REGION_STAT_DISK_READS_PER_SEC_TREND:
+ synchronized (this.diskReadsPerSecTrend) {
+ returnArray = this.diskReadsPerSecTrend.toArray();
+ }
+ break;
+
+ case REGION_STAT_DISK_WRITES_PER_SEC_TREND:
+ synchronized (this.diskWritesPerSecTrend) {
+ returnArray = this.diskWritesPerSecTrend.toArray();
+ }
+ break;
+ }
+
+ return returnArray;
+ }
+
+ public boolean isDiskSynchronous() {
+ return this.diskSynchronous;
+ }
+
+ public void setDiskSynchronous(boolean diskSynchronous) {
+ this.diskSynchronous = diskSynchronous;
+ }
+
+ public String getDiskStoreName() {
+ return this.diskStoreName;
+ }
+
+ public void setDiskStoreName(String diskStoreName) {
+ this.diskStoreName = diskStoreName;
+ }
+
+ public String getScope() {
+ return this.scope;
+ }
+
+ public void setScope(String scope) {
+ this.scope = scope;
+ }
+
+ public int getEmptyNode() {
+ return this.emptyNode;
+ }
+
+ public void setEmptyNode(int emptyNode) {
+ this.emptyNode = emptyNode;
+ }
+
+ public long getDiskUsage() {
+ return this.diskUsage;
+ }
+
+ public void setDiskUsage(long diskUsage) {
+ this.diskUsage = diskUsage;
+ }
+
+ public void setEntrySize(long entrySize) {
+ this.entrySize = entrySize;
+ }
+
+ public boolean getWanEnabled() {
+ return this.wanEnabled;
+ }
+
+ public void setWanEnabled(boolean wanEnabled) {
+ this.wanEnabled = wanEnabled;
+ }
+
+ public boolean getPersistentEnabled() {
+ return this.persistentEnabled;
+ }
+
+ public void setPersistentEnabled(boolean persistentEnabled) {
+ this.persistentEnabled = persistentEnabled;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public long getEntrySize() {
+ return this.entrySize;
+ }
+
+ public List<String> getMemberName() {
+ return this.memberName;
+ }
+
+ public void setMemberName(List<String> memberName) {
+ this.memberName = memberName;
+ }
+
+ public String getFullPath() {
+ return this.fullPath;
+ }
+
+ public void setFullPath(String fullPath) {
+ this.fullPath = fullPath;
+ }
+
+ public double getDiskReadsRate() {
+ return this.diskReadsRate;
+ }
+
+ public void setDiskReadsRate(double diskReadsRate) {
+ this.diskReadsRate = diskReadsRate;
+ }
+
+ public double getDiskWritesRate() {
+ return this.diskWritesRate;
+ }
+
+ public void setDiskWritesRate(double diskWritesRate) {
+ this.diskWritesRate = diskWritesRate;
+ }
+
+ public CircularFifoBuffer getDiskReadsPerSecTrend() {
+ return this.diskReadsPerSecTrend;
+ }
+
+ public void setDiskReadsPerSecTrend(CircularFifoBuffer diskReadsPerSecTrend) {
+ this.diskReadsPerSecTrend = diskReadsPerSecTrend;
+ }
+
+ public CircularFifoBuffer getDiskWritesPerSecTrend() {
+ return this.diskWritesPerSecTrend;
+ }
+
+ public void setDiskWritesPerSecTrend(
+ CircularFifoBuffer diskWritesPerSecTrend) {
+ this.diskWritesPerSecTrend = diskWritesPerSecTrend;
+ }
+
+ public double getGetsRate() {
+ return this.getsRate;
+ }
+
+ public void setGetsRate(double getsRate) {
+ this.getsRate = getsRate;
+ }
+
+ public double getLruEvictionRate() {
+ return this.lruEvictionRate;
+ }
+
+ public void setLruEvictionRate(double lruEvictionRate) {
+ this.lruEvictionRate = lruEvictionRate;
+ }
+
+ public String getRegionType() {
+ return this.regionType;
+ }
+
+ public void setRegionType(String regionType) {
+ this.regionType = regionType;
+ }
+
+ public long getSystemRegionEntryCount() {
+ return this.systemRegionEntryCount;
+ }
+
+ public void setSystemRegionEntryCount(long systemRegionEntryCount) {
+ this.systemRegionEntryCount = systemRegionEntryCount;
+ }
+
+ public int getMemberCount() {
+ return this.memberCount;
+ }
+
+ public void setMemberCount(int memberCount) {
+ this.memberCount = memberCount;
+ }
+
+ public double getPutsRate() {
+ return this.putsRate;
+ }
+
+ public void setPutsRate(double putsRate) {
+ this.putsRate = putsRate;
+ }
+
+ public CircularFifoBuffer getGetsPerSecTrend() {
+ return this.getsPerSecTrend;
+ }
+
+ public void setGetsPerSecTrend(CircularFifoBuffer getsPerSecTrend) {
+ this.getsPerSecTrend = getsPerSecTrend;
+ }
+
+ public CircularFifoBuffer getPutsPerSecTrend() {
+ return this.putsPerSecTrend;
+ }
+
+ public void setPutsPerSecTrend(CircularFifoBuffer putsPerSecTrend) {
+ this.putsPerSecTrend = putsPerSecTrend;
+ }
+
+ public boolean isEnableOffHeapMemory() {
+ return this.enableOffHeapMemory;
+ }
+
+ public void setEnableOffHeapMemory(boolean enableOffHeapMemory) {
+ this.enableOffHeapMemory = enableOffHeapMemory;
+ }
+
+ public String getCompressionCodec() {
+ return this.compressionCodec;
+ }
+
+ public void setCompressionCodec(String compressionCodec) {
+ this.compressionCodec = compressionCodec;
+ }
+
+ public Cluster.RegionOnMember[] getRegionOnMembers() {
+ Cluster.RegionOnMember[] regionOnMembers = null;
+ synchronized (this.regionOnMembers) {
+ regionOnMembers = new Cluster.RegionOnMember[this.regionOnMembers.size()];
+ regionOnMembers = this.regionOnMembers.toArray(regionOnMembers);
+ }
+
+ return regionOnMembers;
+ }
+
+ /**
+ * @param regionOnMembers the regionOnMembers to set
+ */
+ public void setRegionOnMembers(List<RegionOnMember> regionOnMembers) {
+ this.regionOnMembers = regionOnMembers;
+ }
+ }
+
+ /**
+ * Alert Inner Class
+ *
+ *
+ */
+ public static class Alert {
+ public static final int SEVERE = 0;
+ public static final int ERROR = 1;
+ public static final int WARNING = 2;
+ public static final int INFO = 3;
+
+ public static AtomicInteger ALERT_ID_CTR = new AtomicInteger();
+
+ private int id;
+ private Date timestamp;
+ private int severity;
+ private String memberName;
+ private String description;
+ private boolean isAcknowledged;
+ private String iso8601Ts;
+
+ public String getIso8601Ts() {
+ return iso8601Ts;
+ }
+
+ public void setIso8601Ts(String iso8601Ts) {
+ this.iso8601Ts = iso8601Ts;
+ }
+
+ public boolean isAcknowledged() {
+ return this.isAcknowledged;
+ }
+
+ public void setAcknowledged(boolean isAcknowledged) {
+ this.isAcknowledged = isAcknowledged;
+ }
+
+ public Date getTimestamp() {
+ return this.timestamp;
+ }
+
+ public void setTimestamp(Date timestamp) {
+ this.timestamp = timestamp;
+ this.iso8601Ts = formatToISOTimestamp(timestamp);
+ }
+
+ public int getSeverity() {
+ return this.severity;
+ }
+
+ public void setSeverity(int severity) {
+ this.severity = severity;
+ }
+
+ public String getMemberName() {
+ return this.memberName;
+ }
+
+ public void setMemberName(String memberName) {
+ this.memberName = memberName;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public static int nextID() {
+ /*
+ * int id = -1; synchronized (Alert.class) { ALERT_ID_CTR = ALERT_ID_CTR +
+ * 1; id = ALERT_ID_CTR; }
+ */
+ return ALERT_ID_CTR.incrementAndGet();
+ }
+
+ private static DateFormat df = new SimpleDateFormat(PulseConstants.PULSE_NOTIFICATION_ALERT_DATE_PATTERN);
+
+ public static String formatToISOTimestamp(Date date) {
+ TimeZone tz = TimeZone.getTimeZone("UTC");
+ df.setTimeZone(tz);
+ return df.format(date);
+ }
+
+ }
+
+ /**
+ * Client Inner Class
+ *
+ *
+ */
+ public static class Client {
+
+ private String id;
+ private String name;
+ private String host;
+ private int queueSize;
+ private double cpuUsage;
+ private long uptime;
+ private int threads;
+ private int gets;
+ private int puts;
+ private int cpus;
+ private int clientCQCount;
+ private long processCpuTime;
+ private String status;
+ private boolean isConnected = false;
+ private boolean isSubscriptionEnabled = false;
+
+ public String getId() {
+ return this.id;
+ }
+
+ public int getGets() {
+ return this.gets;
+ }
+
+ public int getPuts() {
+ return this.puts;
+ }
+
+ public int getClientCQCount() {
+ return clientCQCount;
+ }
+
+ public void setClientCQCount(int clientCQCount) {
+ this.clientCQCount = clientCQCount;
+ }
+
+ public boolean isSubscriptionEnabled() {
+ return isSubscriptionEnabled;
+ }
+
+ public void setSubscriptionEnabled(boolean isSubscriptionEnabled) {
+ this.isSubscriptionEnabled = isSubscriptionEnabled;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getHost() {
+ return this.host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getQueueSize() {
+ return this.queueSize;
+ }
+
+ public void setQueueSize(int queueSize) {
+ this.queueSize = queueSize;
+ }
+
+ public double getCpuUsage() {
+ return this.cpuUsage;
+ }
+
+ public void setCpuUsage(double cpuUsage) {
+ this.cpuUsage = cpuUsage;
+ }
+
+ public void setGets(int gets) {
+ this.gets = gets;
+ }
+
+ public void setPuts(int puts) {
+ this.puts = puts;
+ }
+
+ public long getUptime() {
+ return this.uptime;
+ }
+
+ public void setUptime(long uptime) {
+ this.uptime = uptime;
+ }
+
+ public int getThreads() {
+ return this.threads;
+ }
+
+ public void setThreads(int threads) {
+ this.threads = threads;
+ }
+
+ public String getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public int getCpus() {
+ return this.cpus;
+ }
+
+ public void setCpus(int cpus) {
+ this.cpus = cpus;
+ }
+
+ public long getProcessCpuTime() {
+ return this.processCpuTime;
+ }
+
+ public void setProcessCpuTime(long processCpuTime) {
+ this.processCpuTime = processCpuTime;
+ }
+
+ public boolean isConnected() {
+ return isConnected;
+ }
+
+ public void setConnected(boolean isConnected) {
+ this.isConnected = isConnected;
+ }
+
+ }
+
+ /**
+ * Gateway Receiver Inner Class
+ *
+ *
+ */
+ public static class GatewayReceiver {
+
+ private int listeningPort;
+ private double linkThroughput;
+ private long avgBatchProcessingTime;
+ private String id;
+ private int queueSize;
+ private Boolean status;
+ private int batchSize;
+
+ public int getListeningPort() {
+ return this.listeningPort;
+ }
+
+ public void setListeningPort(int listeningPort) {
+ this.listeningPort = listeningPort;
+ }
+
+ public double getLinkThroughput() {
+ return this.linkThroughput;
+ }
+
+ public void setLinkThroughput(double linkThroughput) {
+ this.linkThroughput = linkThroughput;
+ }
+
+ public long getAvgBatchProcessingTime() {
+ return this.avgBatchProcessingTime;
+ }
+
+ public void setAvgBatchProcessingTime(long avgBatchProcessingTime) {
+ this.avgBatchProcessingTime = avgBatchProcessingTime;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public int getQueueSize() {
+ return this.queueSize;
+ }
+
+ public void setQueueSize(int queueSize) {
+ this.queueSize = queueSize;
+ }
+
+ public Boolean getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(Boolean status) {
+ this.status = status;
+ }
+
+ public int getBatchSize() {
+ return this.batchSize;
+ }
+
+ public void setBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ }
+ }
+
+ /**
+ * Gateway Sender Inner class
+ *
+ *
+ */
+ public static class GatewaySender {
+
+ private double linkThroughput;
+ private String id;
+ private int queueSize;
+ private Boolean status;
+ private boolean primary;
+ private boolean senderType;
+ private int batchSize;
+ private boolean persistenceEnabled;
+ private int remoteDSId;
+ private int eventsExceedingAlertThreshold;
+
+ public double getLinkThroughput() {
+ return this.linkThroughput;
+ }
+
+ public void setLinkThroughput(double linkThroughput) {
+ this.linkThroughput = linkThroughput;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public int getQueueSize() {
+ return this.queueSize;
+ }
+
+ public void setQueueSize(int queueSize) {
+ this.queueSize = queueSize;
+ }
+
+ public Boolean getStatus() {
+ return this.status;
+ }
+
+ public void setStatus(Boolean status) {
+ this.status = status;
+ }
+
+ public boolean getPrimary() {
+ return this.primary;
+ }
+
+ public void setPrimary(boolean primary) {
+ this.primary = primary;
+ }
+
+ public boolean getSenderType() {
+ return this.senderType;
+ }
+
+ public void setSenderType(boolean senderType) {
+ this.senderType = senderType;
+ }
+
+ public int getBatchSize() {
+ return this.batchSize;
+ }
+
+ public void setBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ public boolean getPersistenceEnabled() {
+ return this.persistenceEnabled;
+ }
+
+ public void setPersistenceEnabled(boolean persistenceEnabled) {
+ this.persistenceEnabled = persistenceEnabled;
+ }
+
+ /**
+ * @return the remoteDSId
+ */
+ public int getRemoteDSId() {
+ return remoteDSId;
+ }
+
+ /**
+ * @param remoteDSId the remoteDSId to set
+ */
+ public void setRemoteDSId(int remoteDSId) {
+ this.remoteDSId = remoteDSId;
+ }
+
+ /**
+ * @return the eventsExceedingAlertThreshold
+ */
+ public int getEventsExceedingAlertThreshold() {
+ return eventsExceedingAlertThreshold;
+ }
+
+ /**
+ * @param eventsExceedingAlertThreshold the eventsExceedingAlertThreshold to set
+ */
+ public void setEventsExceedingAlertThreshold(int eventsExceedingAlertThreshold) {
+ this.eventsExceedingAlertThreshold = eventsExceedingAlertThreshold;
+ }
+ }
+
+ /**
+ * Async Event Queue Inner class
+ *
+ *
+ */
+ public static class AsyncEventQueue {
+
+ private String id;
+ private boolean primary;
+ private boolean parallel;
+ private int batchSize;
+ private long batchTimeInterval;
+ private boolean batchConflationEnabled;
+ private String asyncEventListener;
+ private int eventQueueSize;
+
+ public String getId() {
+ return this.id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public boolean getPrimary() {
+ return this.primary;
+ }
+
+ public void setPrimary(boolean primary) {
+ this.primary = primary;
+ }
+
+ /**
+ * @return the parallel
+ */
+ public boolean isParallel() {
+ return parallel;
+ }
+
+ /**
+ * @param parallel the parallel to set
+ */
+ public void setParallel(boolean parallel) {
+ this.parallel = parallel;
+ }
+
+ public int getBatchSize() {
+ return this.batchSize;
+ }
+
+ public void setBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ /**
+ * @return the batchTimeInterval
+ */
+ public long getBatchTimeInterval() {
+ return batchTimeInterval;
+ }
+
+ /**
+ * @param batchTimeInterval the batchTimeInterval to set
+ */
+ public void setBatchTimeInterval(long batchTimeInterval) {
+ this.batchTimeInterval = batchTimeInterval;
+ }
+
+ /**
+ * @return the batchConflationEnabled
+ */
+ public boolean isBatchConflationEnabled() {
+ return batchConflationEnabled;
+ }
+
+ /**
+ * @param batchConflationEnabled the batchConflationEnabled to set
+ */
+ public void setBatchConflationEnabled(boolean batchConflationEnabled) {
+ this.batchConflationEnabled = batchConflationEnabled;
+ }
+
+ /**
+ * @return the asyncEventListener
+ */
+ public String getAsyncEventListener() {
+ return asyncEventListener;
+ }
+
+ /**
+ * @param asyncEventListener the asyncEventListener to set
+ */
+ public void setAsyncEventListener(String asyncEventListener) {
+ this.asyncEventListener = asyncEventListener;
+ }
+
+ /**
+ * @return the eventQueueSize
+ */
+ public int getEventQueueSize() {
+ return eventQueueSize;
+ }
+
+ /**
+ * @param eventQueueSize the eventQueueSize to set
+ */
+ public void setEventQueueSize(int eventQueueSize) {
+ this.eventQueueSize = eventQueueSize;
+ }
+ }
+
+ /**
+ * Default constructor only used for testing
+ */
+ public Cluster() {
+ }
+
+
+ /**
+ * This function is used for calling getUpdator function of ClusterDataFactory
+ * and starting the thread for updating the Cluster details.
+ *
+ * @param host
+ * host name
+ * @param port
+ * port
+ * @param userName
+ * pulse user name
+ * @param userPassword
+ * pulse user password
+ * @throws ConnectException
+ */
+ public Cluster(String host, String port, String userName, String userPassword)
+ throws ConnectException {
+ this.serverName = host;
+ this.port = port;
+ this.jmxUserName = userName;
+ this.jmxUserPassword = userPassword;
+
+ this.updater = ClusterDataFactory.getUpdater(this, host, port);
+ // start();
+ }
+
+ /**
+ * thread run method for updating the cluster data
+ */
+ @Override
+ public void run() {
+ while (!this.stopUpdates) {
+ try {
+ if (!this.updateData()) {
+ this.stale++;
+ } else {
+ this.stale = 0;
+ }
+ } catch (Exception e) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("Exception Occurred while updating cluster data : " + e.getMessage());
+ }
+ }
+
+ try {
+ Thread.sleep(POLL_INTERVAL);
+ } catch (InterruptedException e) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("InterruptedException Occurred : " + e.getMessage());
+ }
+ }
+ }
+
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_STOP_THREAD_UPDATES")
+ + " :: " + this.serverName + ":" + this.port);
+ }
+ }
+
+ /**
+ * calling updateData
+ *
+ * @return true if update was successful. false if it failed.
+ */
+ private boolean updateData() {
+ // This will eventually call JMX. Currently we will update this with
+ // some dummy data.
+ // Connect if required or hold a connection. If unable to connect,
+ // return false
+ if (LOGGER.finerEnabled()) {
+ LOGGER.finer(resourceBundle.getString("LOG_MSG_CLUSTER_DATA_IS_UPDATING")
+ + "::" + this.serverName + ":" + this.port);
+ }
+ return this.updater.updateData();
+ }
+
+ /**
+ * for stopping the update thread
+ */
+ public void stopThread() {
+ this.stopUpdates = true;
+
+ try {
+ join();
+ } catch (InterruptedException e) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info("InterruptedException occured while stoping cluster thread : " + e.getMessage());
+ }
+ }
+ }
+
+ public Map<String, Cluster.Member> getMembersHMap() {
+ return this.membersHMap;
+ }
+
+ public void setMembersHMap(HashMap<String, Cluster.Member> membersHMap) {
+ this.membersHMap = membersHMap;
+ }
+
+ public Map<String, Boolean> getWanInformation() {
+ Map<String, Boolean> wanMap = null;
+ synchronized (this.wanInformation) {
+ wanMap = (Map<String, Boolean>) this.wanInformation.clone();
+ }
+
+ return wanMap;
+ }
+
+ // Returns actual wanInformation object reference
+ public Map<String, Boolean> getWanInformationObject() {
+ return this.wanInformation;
+ }
+
+ public void setWanInformation(HashMap<String, Boolean> wanInformation) {
+ this.wanInformation = wanInformation;
+ }
+
+ 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 String getConnectionErrorMsg() {
+ return this.connectionErrorMsg;
+ }
+
+ public void setConnectionErrorMsg(String connectionErrorMsg) {
+ this.connectionErrorMsg = connectionErrorMsg;
+ }
+
+ public String getServerName() {
+ return this.serverName;
+ }
+
+ public boolean isConnectedFlag() {
+ return this.connectedFlag;
+ }
+
+ public void setConnectedFlag(boolean connectedFlag) {
+ this.connectedFlag = connectedFlag;
+ }
+
+ public String getPort() {
+ return this.port;
+ }
+
+ public int getStale() {
+ return this.stale;
+ }
+
+ public double getWritePerSec() {
+ return this.writePerSec;
+ }
+
+ public void setWritePerSec(double writePerSec) {
+ this.writePerSec = writePerSec;
+ }
+
+ public double getReadPerSec() {
+ return this.readPerSec;
+ }
+
+ public void setReadPerSec(double readPerSec) {
+ this.readPerSec = readPerSec;
+ }
+
+ public double getQueriesPerSec() {
+ return this.queriesPerSec;
+ }
+
+ public void setQueriesPerSec(double queriesPerSec) {
+ this.queriesPerSec = queriesPerSec;
+ }
+
+ public double getLoadPerSec() {
+ return this.loadPerSec;
+ }
+
+ public void setLoadPerSec(double loadPerSec) {
+ this.loadPerSec = loadPerSec;
+ }
+
+ public int getNotificationPageNumber() {
+ return this.notificationPageNumber;
+ }
+
+ public void setNotificationPageNumber(int notificationPageNumber) {
+ this.notificationPageNumber = notificationPageNumber;
+ }
+
+ public void setStale(int stale) {
+ this.stale = stale;
+ }
+
+ public boolean isStopUpdates() {
+ return this.stopUpdates;
+ }
+
+ public void setStopUpdates(boolean stopUpdates) {
+ this.stopUpdates = stopUpdates;
+ }
+
+ public long getUsedHeapSize() {
+ return this.usedHeapSize;
+ }
+
+ public void setUsedHeapSize(long usedHeapSize) {
+ this.usedHeapSize = usedHeapSize;
+ }
+
+ public int getServerCount() {
+ return this.serverCount;
+ }
+
+ public void setServerCount(int serverCount) {
+ this.serverCount = serverCount;
+ }
+
+ public int getTxnCommittedCount() {
+ return txnCommittedCount;
+ }
+
+ public void setTxnCommittedCount(int txnCommittedCount) {
+ this.txnCommittedCount = txnCommittedCount;
+ }
+
+ public int getTxnRollbackCount() {
+ return txnRollbackCount;
+ }
+
+ public void setTxnRollbackCount(int txnRollbackCount) {
+ this.txnRollbackCount = txnRollbackCount;
+ }
+
+ public int getRunningFunctionCount() {
+ return this.runningFunctionCount;
+ }
+
+ public long getRegisteredCQCount() {
+ return this.registeredCQCount;
+ }
+
+ public int getSubscriptionCount() {
+ return this.subscriptionCount;
+ }
+
+ public void setSubscriptionCount(int subscriptionCount) {
+ this.subscriptionCount = subscriptionCount;
+ }
+
+ public void setRegisteredCQCount(long registeredCQCount) {
+ this.registeredCQCount = registeredCQCount;
+ }
+
+ public void setRunningFunctionCount(int runningFunctionCount) {
+ this.runningFunctionCount = runningFunctionCount;
+ }
+
+ public Map<String, Cluster.Region> getClusterRegions() {
+ return this.clusterRegionMap;
+ }
+
+ public Cluster.Region getClusterRegion(String regionFullPath) {
+ return this.clusterRegionMap.get(regionFullPath);
+ }
+
+ public void setClusterRegions(Map<String, Region> clusterRegionMap) {
+ this.clusterRegionMap = clusterRegionMap;
+ }
+
+ public Map<String, Cluster.Statement> getClusterStatements() {
+ return this.clusterStatementMap;
+ }
+
+ public void setClusterStatements(Map<String, Statement> clusterStatementMap) {
+ this.clusterStatementMap = clusterStatementMap;
+ }
+
+ public Alert[] getAlertsList() {
+ Alert[] list = null;
+ synchronized (this.alertsList) {
+ list = new Alert[this.alertsList.size()];
+ list = this.alertsList.toArray(list);
+ }
+
+ return list;
+ }
+
+ public void setAlertsList(List<Alert> alertsList) {
+ this.alertsList = alertsList;
+ }
+
+ public void setServerName(String serverName) {
+ this.serverName = serverName;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ public Set<String> getDeletedMembers() {
+ return this.deletedMembers;
+ }
+
+ public void setDeletedMembers(Set<String> deletedMembers) {
+ this.deletedMembers = deletedMembers;
+ }
+
+ public Set<String> getDeletedRegions() {
+ return this.deletedRegions;
+ }
+
+ public void setDeletedRegions(Set<String> deletedRegions) {
+ this.deletedRegions = deletedRegions;
+ }
+
+ public Map<String, List<Member>> getPhysicalToMember() {
+ Map<String, List<Member>> ptom = null;
+ // synchronized (physicalToMember) {
+ ptom = this.physicalToMember;
+ // }
+ return ptom;
+ }
+
+ public void setPhysicalToMember(HashMap<String, List<Member>> physicalToMember) {
+ // synchronized (this.physicalToMember) {
+ this.physicalToMember = physicalToMember;
+ // }
+ }
+
+ public int getMemberCount() {
+ return this.memberCount;
+ }
+
+ public void setMemberCount(int memberCount) {
+ this.memberCount = memberCount;
+ }
+
+ public long getClientConnectionCount() {
+ return this.clientConnectionCount;
+ }
+
+ public void setClientConnectionCount(long clientConnectionCount) {
+ this.clientConnectionCount = clientConnectionCount;
+ }
+
+ public int getClusterId() {
+ return this.clusterId;
+ }
+
+ public void setClusterId(int clusterId) {
+ this.clusterId = clusterId;
+ }
+
+ public int getLocatorCount() {
+ return this.locatorCount;
+ }
+
+ public void setLocatorCount(int locatorCount) {
+ this.locatorCount = locatorCount;
+ }
+
+ public int getTotalRegionCount() {
+ return this.totalRegionCount;
+ }
+
+ public void setTotalRegionCount(int totalRegionCount) {
+ this.totalRegionCount = totalRegionCount;
+ }
+
+ public long getTotalHeapSize() {
+ return this.totalHeapSize;
+ }
+
+ public void setTotalHeapSize(long totalHeapSize) {
+ this.totalHeapSize = totalHeapSize;
+ }
+
+ public long getTotalRegionEntryCount() {
+ return this.totalRegionEntryCount;
+ }
+
+ public void setTotalRegionEntryCount(long totalRegionEntryCount) {
+ this.totalRegionEntryCount = totalRegionEntryCount;
+ }
+
+ public int getCurrentQueryCount() {
+ return this.currentQueryCount;
+ }
+
+ public void setCurrentQueryCount(int currentQueryCount) {
+ this.currentQueryCount = currentQueryCount;
+ }
+
+ public long getTotalBytesOnDisk() {
+ return this.totalBytesOnDisk;
+ }
+
+ public void setTotalBytesOnDisk(long totalBytesOnDisk) {
+ this.totalBytesOnDisk = totalBytesOnDisk;
+ }
+
+ public double getDiskReadsRate() {
+ return this.diskReadsRate;
+ }
+
+ public void setDiskReadsRate(double diskReadsRate) {
+ this.diskReadsRate = diskReadsRate;
+ }
+
+ public double getDiskWritesRate() {
+ return this.diskWritesRate;
+ }
+
+ public void setDiskWritesRate(double diskWritesRate) {
+ this.diskWritesRate = diskWritesRate;
+ }
+
+ public int getAvgDiskStorage() {
+ return this.avgDiskStorage;
+ }
+
+ public void setAvgDiskStorage(int avgDiskStorage) {
+ this.avgDiskStorage = avgDiskStorage;
+ }
+
+ public int getAvgDiskWritesRate() {
+ return this.avgDiskWritesRate;
+ }
+
+ public void setAvgDiskWritesRate(int avgDiskWritesRate) {
+ this.avgDiskWritesRate = avgDiskWritesRate;
+ }
+
+ public CircularFifoBuffer getWritePerSecTrend() {
+ return this.writePerSecTrend;
+ }
+
+ public void setWritePerSecTrend(CircularFifoBuffer writePerSecTrend) {
+ this.writePerSecTrend = writePerSecTrend;
+ }
+
+ public long getGarbageCollectionCount() {
+ return this.garbageCollectionCount;
+ }
+
+ public void setGarbageCollectionCount(long garbageCollectionCount) {
+ this.garbageCollectionCount = garbageCollectionCount;
+ }
+
+ public CircularFifoBuffer getTotalBytesOnDiskTrend() {
+ return this.totalBytesOnDiskTrend;
+ }
+
+ public void setTotalBytesOnDiskTrend(CircularFifoBuffer totalBytesOnDiskTrend) {
+ this.totalBytesOnDiskTrend = totalBytesOnDiskTrend;
+ }
+
+ public CircularFifoBuffer getThroughoutWritesTrend() {
+ return this.throughoutWritesTrend;
+ }
+
+ public void setThroughoutWritesTrend(CircularFifoBuffer throughoutWritesTrend) {
+ this.throughoutWritesTrend = throughoutWritesTrend;
+ }
+
+ public CircularFifoBuffer getThroughoutReadsTrend() {
+ return this.throughoutReadsTrend;
+ }
+
+ public void setThroughoutReadsTrend(CircularFifoBuffer throughoutReadsTrend) {
+ this.throughoutReadsTrend = throughoutReadsTrend;
+ }
+
+ public CircularFifoBuffer getReadPerSecTrend() {
+ return this.readPerSecTrend;
+ }
+
+ public void setReadPerSecTrend(CircularFifoBuffer readPerSecTrend) {
+ this.readPerSecTrend = readPerSecTrend;
+ }
+
+ public CircularFifoBuffer getQueriesPerSecTrend() {
+ return this.queriesPerSecTrend;
+ }
+
+ public void setQueriesPerSecTrend(CircularFifoBuffer queriesPerSecTrend) {
+ this.queriesPerSecTrend = queriesPerSecTrend;
+ }
+
+ public CircularFifoBuffer getMemoryUsageTrend() {
+ return this.memoryUsageTrend;
+ }
+
+ public void setMemoryUsageTrend(CircularFifoBuffer memoryUsageTrend) {
+ this.memoryUsageTrend = memoryUsageTrend;
+ }
+
+ public CircularFifoBuffer getGarbageCollectionTrend() {
+ return this.garbageCollectionTrend;
+ }
+
+ public void setGarbageCollectionTrend(
+ CircularFifoBuffer garbageCollectionSamples) {
+ this.garbageCollectionTrend = garbageCollectionSamples;
+ }
+
+ public long getPreviousJVMPauseCount() {
+ return this.previousJVMPauseCount;
+ }
+
+ public void setPreviousJVMPauseCount(long previousJVMPauseCount) {
+ this.previousJVMPauseCount = previousJVMPauseCount;
+ }
+
+ public DataBrowser getDataBrowser() {
+ // Initialize dataBrowser if null
+ if (this.dataBrowser == null) {
+ this.dataBrowser = new DataBrowser();
+ }
+ return this.dataBrowser;
+ }
+
+ public void setDataBrowser(DataBrowser dataBrowser) {
+ this.dataBrowser = dataBrowser;
+ }
+
+ public ObjectNode executeQuery(String queryText, String members, int limit) {
+ // Execute data browser query
+ return this.updater.executeQuery(queryText, members, limit);
+ }
+
+ public ArrayNode getQueryHistoryByUserId(String userId) {
+ return this.getDataBrowser().getQueryHistoryByUserId(userId);
+ }
+
+ public boolean addQueryInHistory(String queryText, String userName) {
+ return this.getDataBrowser().addQueryInHistory(queryText, userName);
+ }
+
+ public boolean deleteQueryById(String userId, String queryId) {
+ return this.getDataBrowser().deleteQueryById(userId, queryId);
+ }
+
+ public JMXConnector connectToGemFire() {
+ if(this.updater instanceof JMXDataUpdater) {
+ return ((JMXDataUpdater) this.updater).getJMXConnection(false);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * inner class for creating Mock Data
+ *
+ *
+ */
+ public class MockDataUpdater implements IClusterUpdater {
+ public MockDataUpdater() {
+ }
+
+ /**
+ * function used for updating Cluster data for Mock
+ */
+ @Override
+ public boolean updateData() {
+ setConnectedFlag(true);
+ Random r = new Random(System.currentTimeMillis());
+ totalHeapSize = (long) Math.abs(r.nextInt(3200 - 2048) + 2048);
+ usedHeapSize = (long) Math.abs(r.nextInt(2048));
+ writePerSec = Math.abs(r.nextInt(100));
+ subscriptionCount = Math.abs(r.nextInt(100));
+ registeredCQCount = (long) Math.abs(r.nextInt(100));
+ txnCommittedCount = Math.abs(r.nextInt(100));
+ txnRollbackCount = Math.abs(r.nextInt(100));
+ runningFunctionCount = Math.abs(r.nextInt(100));
+ clusterId = Math.abs(r.nextInt(100));
+ writePerSecTrend.add(writePerSec);
+ diskWritesRate = writePerSec;
+ garbageCollectionCount = (long) Math.abs(r.nextInt(100));
+ garbageCollectionTrend.add(garbageCollectionCount);
+
+ readPerSec = Math.abs(r.nextInt(100));
+ readPerSecTrend.add(readPerSec);
+
+ diskReadsRate = readPerSec;
+ queriesPerSec = Math.abs(r.nextInt(100));
+ queriesPerSecTrend.add(queriesPerSec);
+
+ loadPerSec = Math.abs(r.nextInt(100));
+ totalHeapSize = totalHeapSize;
+ totalBytesOnDisk = totalHeapSize;
+
+ totalBytesOnDiskTrend.add(totalBytesOnDisk);
+
+ memoryUsageTrend.add(usedHeapSize);
+ throughoutWritesTrend.add(writePerSec);
+ throughoutReadsTrend.add(readPerSec);
+
+ memberCount = 0;
+
+ // Create 3 members first time around
+ if (membersHMap.size() == 0) {
+
+ membersHMap.put(
+ "pnq-visitor1",
+ initializeMember(
+ "pnq-visitor1(Launcher_Manager-1099-13-40-24-5368)-24357",
+ "pnq-visitor1", true, true, true, true));
+
+ for (int i = 2; i <= 8; i++) {
+ if ((i % 2) == 0) {
+ membersHMap.put(
+ "pnq-visitor" + i,
+ initializeMember("pnq-visitor" + i
+ + "(Launcher_Server-1099-13-40-24-5368)-24357",
+ "pnq-visitor" + i, false, false, true, false));
+ } else {
+ if ((i % 3) == 0) {
+ membersHMap.put(
+ "pnq-visitor" + i,
+ initializeMember("pnq-visitor" + i
+ + "(Launcher_Server-1099-13-40-24-5368)-24357",
+ "pnq-visitor" + i, false, false, false, false));
+ } else {
+ membersHMap.put(
+ "pnq-visitor" + i,
+ initializeMember("pnq-visitor" + i
+ + "(Launcher_Server-1099-13-40-24-5368)-24357",
+ "pnq-visitor" + i, false, true, true, true));
+ }
+ }
+ }
+
+ for (Entry<String, Member> memberSet : membersHMap.entrySet()) {
+ HashMap<String, Cluster.Region> memberRegions = new HashMap<String, Cluster.Region>();
+ HashMap<String, Cluster.Client> memberClientsHM = new HashMap<String, Cluster.Client>();
+
+ Random randomGenerator = new Random();
+ int randomInt = (randomGenerator.nextInt(15)) + 10;
+ int regionExists = 0;
+ for (int y = 0; y < randomInt; y++) {
+ Region region = initMemberRegion(y, memberSet.getValue().getName());
+ if (clusterRegionMap.entrySet().size() > 0) {
+ for (Region clusterRegion : clusterRegionMap.values()) {
+ if ((region.name).equals(clusterRegion.name)) {
+ clusterRegion.memberName.add(memberSet.getValue().getName());
+ clusterRegion.memberCount = clusterRegion.memberCount + 1;
+ regionExists = 1;
+ break;
+ }
+ }
+ if (regionExists == 0) {
+ addClusterRegion(region.getFullPath(), region);
+ }
+ } else {
+ addClusterRegion(region.getFullPath(), region);
+ }
+ memberRegions.put(region.getFullPath(), region);
+ totalRegionCount = clusterRegionMap.values().size();
+ }
+ membersHMap.get(memberSet.getKey()).setMemberRegions(memberRegions);
+
+ if (memberSet.getValue().isCache) {
+ Client client = initMemberClient(0, memberSet.getValue().getHost());
+ memberClientsHM.put(client.getId(), client);
+ randomInt = randomGenerator.nextInt(10);
+ for (int y = 1; y < randomInt; y++) {
+ Client newClient = initMemberClient(y, memberSet.getValue()
+ .getHost());
+ memberClientsHM.put(newClient.getId(), newClient);
+ }
+ membersHMap.get(memberSet.getKey()).updateMemberClientsHMap(
+ memberClientsHM);
+ clientConnectionCount = clientConnectionCount
+ + membersHMap.get(memberSet.getKey()).getMemberClientsHMap()
+ .size();
+ }
+
+ }
+ }
+
+ // add additional regions to members
+ for (Entry<String, Member> memberSet : membersHMap.entrySet()) {
+ HashMap<String, Cluster.Region> memberRegions = new HashMap<String, Cluster.Region>();
+
+ Random randomGenerator = new Random();
+ int randomInt = (randomGenerator.nextInt(5)) + 5;
+ int regionExists = 0;
+ for (int y = 0; y < randomInt; y++) {
+ Region region = initMemberRegion(y, memberSet.getValue().getName());
+ if (clusterRegionMap.entrySet().size() > 0) {
+ for (Region clusterRegion : clusterRegionMap.values()) {
+ if ((region.name).equals(clusterRegion.name)) {
+ clusterRegion.memberName.add(memberSet.getValue().getName());
+ clusterRegion.memberCount = clusterRegion.memberCount + 1;
+ regionExists = 1;
+ break;
+ }
+ }
+ if (regionExists == 0) {
+ addClusterRegion(region.getFullPath(), region);
+ }
+ } else {
+ addClusterRegion(region.getFullPath(), region);
+ }
+ memberRegions.put(region.getFullPath(), region);
+ totalRegionCount = clusterRegionMap.values().size();
+ }
+ membersHMap.get(memberSet.getKey()).setMemberRegions(memberRegions);
+
+ }
+
+ wanInformation.clear();
+ int wanInfoSize = Math.abs(r.nextInt(10));
+ wanInfoSize++;
+ for (int i = 0; i < wanInfoSize; i++) {
+ String name = "Mock Cluster" + i;
+ Boolean value = false;
+ if (i % 2 == 0) {
+ value = true;
+ }
+ wanInformation.put(name, value);
+ }
+ memberCount = membersHMap.size();
+
+ totalHeapSize = (long) 0;
+ for (Entry<String, Member> memberSet : membersHMap.entrySet()) {
+ refresh(membersHMap.get(memberSet.getKey()));
+ Member member = membersHMap.get(memberSet.getKey());
+ totalHeapSize += member.currentHeapSize;
+ }
+
+ for (Region region : clusterRegionMap.values()) {
+ // Memory reads and writes
+ region.getsRate = (Math.abs(r.nextInt(100))) + 1;
+ region.putsRate = (Math.abs(r.nextInt(100))) + 1;
+ region.getsPerSecTrend.add(region.getsRate);
+ region.putsPerSecTrend.add(region.putsRate);
+
+ // Disk reads and writes
+ region.diskReadsRate = (Math.abs(r.nextInt(100))) + 1;
+ region.diskWritesRate = (Math.abs(r.nextInt(100))) + 1;
+ region.diskReadsPerSecTrend.add(region.diskReadsRate);
+ region.diskWritesPerSecTrend.add(region.diskWritesRate);
+ }
+
+ if(clusterStatementMap.size() < 500){
+ for(int i = 1; i <= 500; ++i) {
+
<TRUNCATED>
[33/35] incubator-geode git commit: GEODE-37 changed package name in
comment
Posted by hi...@apache.org.
GEODE-37 changed package name in comment
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/46307d00
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/46307d00
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/46307d00
Branch: refs/heads/develop
Commit: 46307d00886391fc56572aebaa4dc452f2f168cd
Parents: 9a2b5d7
Author: Hitesh Khamesra <hk...@pivotal.io>
Authored: Mon Sep 19 15:16:30 2016 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Tue Sep 20 14:29:51 2016 -0700
----------------------------------------------------------------------
.../org/apache/geode/internal/cache/DistPeerTXStateStub.java | 4 ++--
.../apache/geode/internal/cache/DistTXStateOnCoordinator.java | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46307d00/geode-core/src/main/java/org/apache/geode/internal/cache/DistPeerTXStateStub.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistPeerTXStateStub.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DistPeerTXStateStub.java
index 5cdbc45..4e107fb 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistPeerTXStateStub.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistPeerTXStateStub.java
@@ -176,8 +176,8 @@ public final class DistPeerTXStateStub extends PeerTXStateStub implements
* (non-Javadoc)
*
* @see
- * org.apache.geode.internal.cache.InternalDataView#putEntryOnRemote(com
- * .gemstone.gemfire.internal.cache.EntryEventImpl, boolean, boolean,
+ * org.apache.geode.internal.cache.InternalDataView#putEntryOnRemote(org
+ * .apache.geode.internal.cache.EntryEventImpl, boolean, boolean,
* java.lang.Object, boolean, long, boolean)
*/
@Override
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/46307d00/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXStateOnCoordinator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXStateOnCoordinator.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXStateOnCoordinator.java
index eb028b3..28a19d8 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXStateOnCoordinator.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistTXStateOnCoordinator.java
@@ -138,8 +138,8 @@ public final class DistTXStateOnCoordinator extends DistTXState implements
* (non-Javadoc)
*
* @see
- * org.apache.geode.internal.cache.InternalDataView#putEntryOnRemote(com
- * .gemstone.gemfire.internal.cache.EntryEventImpl, boolean, boolean,
+ * org.apache.geode.internal.cache.InternalDataView#putEntryOnRemote(org
+ * .apache.geode.internal.cache.EntryEventImpl, boolean, boolean,
* java.lang.Object, boolean, long, boolean)
*/
@Override
[08/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/BaseServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/BaseServiceTest.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/BaseServiceTest.java
deleted file mode 100644
index 334a9e1..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/BaseServiceTest.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests.junit;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.geode.test.junit.categories.UITest;
-import com.google.gson.JsonObject;
-import com.vmware.gemfire.tools.pulse.internal.json.JSONObject;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.methods.RequestBuilder;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.impl.client.BasicCookieStore;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URI;
-import java.util.List;
-import java.util.Properties;
-
-
-/**
- * Base class to be extended by other JUnit test classes. This class defines and automatically invokes test for testing server login-logout so no need to add
- * this test in each sub-class. It also provides doLogin(), doLogout() and print error functionality as protected
- * functions.
- *
- * <b>Sub-classes should ensure that they call doLogin() in @BeforeClass and doLogout() in @AfterClass otherwise tests will fail.</b>
- *
- *
- */
-@Ignore
-@Category(UITest.class)
-public abstract class BaseServiceTest {
-
- protected static Properties propsForJUnit = new Properties();
- protected static String strHost = null;
- protected static String strPort = null;
- protected static String LOGIN_URL;
- protected static String LOGOUT_URL;
- protected static String IS_AUTHENTICATED_USER_URL;
- protected static String PULSE_UPDATE_URL;
-
- protected static final String PULSE_UPDATE_PARAM = "pulseData";
- protected static final String PULSE_UPDATE_1_VALUE = "{'ClusterSelectedRegion':{'regionFullPath':'/GlobalVilage_2/GlobalVilage_9'}}";
- protected static final String PULSE_UPDATE_2_VALUE = "{'ClusterSelectedRegion':{'regionFullPath':'/Rubbish'}}";
-
- protected static final String PULSE_UPDATE_3_VALUE = "{'ClusterSelectedRegionsMember':{'regionFullPath':'/GlobalVilage_2/GlobalVilage_9'}}";
- protected static final String PULSE_UPDATE_4_VALUE = "{'ClusterSelectedRegionsMember':{'regionFullPath':'/Rubbish'}}";
-
- protected static final String PULSE_UPDATE_5_VALUE = "{'MemberGatewayHub':{'memberName':'pnq-visitor1'}}";
- protected static final String PULSE_UPDATE_6_VALUE = "{'MemberGatewayHub':{'memberName':'pnq-visitor2'}}";
- protected static CloseableHttpClient httpclient = null;
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- InputStream stream = BaseServiceTest.class.getClassLoader().getResourceAsStream("pulse.properties");
-
- try {
- propsForJUnit.load(stream);
- } catch (Exception exProps) {
- System.out.println("BaseServiceTest :: Error loading properties from pulse.properties in classpath");
- }
- strHost = propsForJUnit.getProperty("pulse.host");
- strPort = propsForJUnit.getProperty("pulse.port");
- System.out.println(
- "BaseServiceTest :: Loaded properties from classpath. Checking properties for hostname. Hostname found = " + strHost);
- LOGIN_URL = "http://" + strHost + ":" + strPort + "/pulse/j_spring_security_check";
- LOGOUT_URL = "http://" + strHost + ":" + strPort + "/pulse/clusterLogout";
- IS_AUTHENTICATED_USER_URL = "http://" + strHost + ":" + strPort + "/pulse/authenticateUser";
- PULSE_UPDATE_URL = "http://" + strHost + ":" + strPort + "/pulse/pulseUpdate";
-
- }
- /**
- *
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- doLogout();
- System.out.println("BaseServiceTest :: Setup done");
- }
-
- /**
- *
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- doLogin();
- System.out.println("BaseServiceTest :: Teardown done");
- }
-
- /**
- * Login to pulse server and setup httpClient for tests
- * To be called from setupBeforeClass in each test class
- */
- protected static void doLogin() throws Exception {
- System.out.println("BaseServiceTest :: Executing doLogin with user : admin, password : admin.");
-
- CloseableHttpResponse loginResponse = null;
- try{
- BasicCookieStore cookieStore = new BasicCookieStore();
- httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
- HttpUriRequest login = RequestBuilder.post().setUri(new URI(LOGIN_URL))
- .addParameter("j_username", "admin").addParameter("j_password", "admin")
- .build();
- loginResponse = httpclient.execute(login);
- try {
- HttpEntity entity = loginResponse.getEntity();
- EntityUtils.consume(entity);
- System.out.println("BaseServiceTest :: HTTP request status : " + loginResponse.getStatusLine());
-
- List<Cookie> cookies = cookieStore.getCookies();
- if (cookies.isEmpty()) {
- } else {
- for (int i = 0; i < cookies.size(); i++) {
- }
- }
- } finally {
- if(loginResponse != null)
- loginResponse.close();
- }
- } catch(Exception failed) {
- logException(failed);
- throw failed;
- }
-
- System.out.println("BaseServiceTest :: Executed doLogin");
- }
-
- /**
- * Logout to pulse server and close httpClient
- * To be called from setupAfterClass in each test class
- */
- protected static void doLogout() throws Exception {
- System.out.println("BaseServiceTest :: Executing doLogout with user : admin, password : admin.");
- if(httpclient != null){
- CloseableHttpResponse logoutResponse = null;
- try{
- HttpUriRequest logout = RequestBuilder.get().setUri(new URI(LOGOUT_URL))
- .build();
- logoutResponse = httpclient.execute(logout);
- try {
- HttpEntity entity = logoutResponse.getEntity();
- EntityUtils.consume(entity);
- } finally {
- if(logoutResponse != null)
- logoutResponse.close();
- httpclient.close();
- httpclient = null;
- }
- } catch(Exception failed) {
- logException(failed);
- throw failed;
- }
- System.out.println("BaseServiceTest :: Executed doLogout");
- } else{
- System.out.println("BaseServiceTest :: User NOT logged-in");
- }
- }
-
- /**
- * Print exception string to system.out
- *
- * @param failed
- */
- protected static void logException(Exception failed){
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- failed.printStackTrace(pw);
- System.out.println("BaseServiceTest :: Logging exception details : " + sw.getBuffer().toString());
- }
-
- /**
- *
- * Tests that service returns json object
- *
- * Test method for {@link com.vmware.gemfire.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
- */
- @Test
- public void testServerLoginLogout() {
- System.out.println("BaseServiceTest :: ------TESTCASE BEGIN : SERVER LOGIN-LOGOUT------");
- try{
- doLogin();
-
- HttpUriRequest pulseupdate = RequestBuilder.get()
- .setUri(new URI(IS_AUTHENTICATED_USER_URL))
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("BaseServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("BaseServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JsonNode jsonObj = mapper.readTree(jsonResp);
- boolean isUserLoggedIn = jsonObj.get("isUserLoggedIn").booleanValue();
- Assert.assertNotNull("BaseServiceTest :: Server returned null response in 'isUserLoggedIn'", isUserLoggedIn);
- Assert.assertTrue("BaseServiceTest :: User login failed for this username, password", (isUserLoggedIn == true));
- } finally {
- response.close();
- }
-
- doLogout();
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- System.out.println("BaseServiceTest :: ------TESTCASE END : SERVER LOGIN-LOGOUT------");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java
deleted file mode 100644
index 380bf3e..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests.junit;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URI;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.methods.RequestBuilder;
-import org.apache.http.util.EntityUtils;
-import org.junit.*;
-
-import com.vmware.gemfire.tools.pulse.internal.json.JSONArray;
-import com.vmware.gemfire.tools.pulse.internal.json.JSONObject;
-
-/**
- * JUnit Tests for ClusterSelectedRegionService in the back-end server for region detail page
- *
- *
- */
-@Ignore
-public class ClusterSelectedRegionServiceTest extends BaseServiceTest {
-
- /**
- *
- * @throws java.lang.Exception
- */
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- doLogin();
- System.out.println("\n\nClusterSelectedRegionServiceTest :: Setup done");
- }
-
- /**
- *
- * @throws java.lang.Exception
- */
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- doLogout();
- System.out.println("ClusterSelectedRegionServiceTest :: Teardown done");
- }
-
- /**
- *
- * @throws java.lang.Exception
- */
- @Override
- @Before
- public void setUp() throws Exception {
- }
-
- /**
- *
- * @throws java.lang.Exception
- */
- @Override
- @After
- public void tearDown() throws Exception {
- }
-
- /**
- * Tests that service returns json object
- *
- */
- @Test
- public void testResponseNotNull() {
- System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE BEGIN : NULL RESPONSE CHECK FOR CLUSTER REGIONS------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_1_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for ClusterSelectedRegion", jsonObj.getJSONObject("ClusterSelectedRegion"));
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
- }
- System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE END : NULL RESPONSE CHECK FOR CLUSTER REGIONS------\n");
- }
-
- /**
- *
- * Tests that response is for same logged in user
- *
- */
- @Test
- public void testResponseUsername() {
- System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE BEGIN : NULL USERNAME IN RESPONSE CHECK FOR CLUSTER REGIONS------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_1_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegion");
- Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for ClusterSelectedRegion", clusterSelectedRegionObj);
- String szUser = clusterSelectedRegionObj.getString("userName");
- Assert.assertEquals("ClusterSelectedRegionServiceTest :: Server returned wrong user name. Expected was admin. Server returned = " + szUser, szUser, "admin");
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
- }
- System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE END : NULL USERNAME IN RESPONSE CHECK FOR CLUSTER REGIONS------\n");
- }
-
- /**
- *
- * Tests that response is for same region
- *
- * Test method for {@link com.vmware.gemfire.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
- *
- */
- @Test
- public void testResponseRegionPathMatches() {
- System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE BEGIN : REGION PATH IN RESPONSE CHECK FOR CLUSTER REGIONS------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_1_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegion");
- Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for ClusterSelectedRegion",clusterSelectedRegionObj);
- JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegion");
- Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for selectedRegion",jsonObjRegion);
- Assert.assertTrue("ClusterSelectedRegionServiceTest :: Server did not return 'path' of region",jsonObjRegion.has("path"));
- String szPath = jsonObjRegion.getString("path");
- Assert.assertEquals("ClusterSelectedRegionServiceTest :: Server returned wrong region path. Expected region path = /GlobalVilage_2/GlobalVilage_9 , actual region path = " + szPath, szPath, "/GlobalVilage_2/GlobalVilage_9");
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
- }
- System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE END : REGION PATH IN RESPONSE CHECK FOR CLUSTER REGIONS------\n");
- }
-
- /**
- *
- * Tests that response is for same region
- *
- * Test method for {@link com.vmware.gemfire.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
- *
- */
- @Test
- public void testResponseNonExistentRegion() {
- System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE BEGIN : NON-EXISTENT REGION CHECK FOR CLUSTER REGIONS------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_2_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegion");
- Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for ClusterSelectedRegion",clusterSelectedRegionObj);
- JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegion");
- Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for selectedRegion",jsonObjRegion);
- Assert.assertTrue("ClusterSelectedRegionServiceTest :: Server did not return error on non-existent region",jsonObjRegion.has("errorOnRegion"));
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
- }
- System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE END : NON-EXISTENT REGION CHECK FOR CLUSTER REGIONS------\n");
- }
-
- /**
- *
- * Tests that service returns json object
- *
- * Test method for {@link com.vmware.gemfire.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
- *
- */
- @Test
- public void testResponseMemerberCount() {
- System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE BEGIN : MISMATCHED MEMBERCOUNT FOR REGION CHECK FOR CLUSTER REGIONS------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_1_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegion");
- Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null ClusterSelectedRegion",clusterSelectedRegionObj);
- JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegion");
- Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null for selectedRegion",jsonObjRegion);
- Assert.assertTrue("ClusterSelectedRegionServiceTest :: Server did not return 'memberCount' of region",jsonObjRegion.has("memberCount"));
- int memberCount = jsonObjRegion.getInt("memberCount");
- Assert.assertTrue("ClusterSelectedRegionServiceTest :: Server did not return 'members' of region",jsonObjRegion.has("members"));
- JSONArray arrMembers = jsonObjRegion.getJSONArray("members");
- Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response in selectedRegion",arrMembers);
- int members = arrMembers.length();
- Assert.assertEquals("ClusterSelectedRegionServiceTest :: Server returned mismatched member count and region members", members, memberCount);
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
- }
- System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE END : MISMATCHED MEMBERCOUNT FOR REGION CHECK FOR CLUSTER REGIONS------\n");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java
deleted file mode 100644
index c1caf90..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests.junit;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URI;
-import java.util.Iterator;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.methods.RequestBuilder;
-import org.apache.http.util.EntityUtils;
-import org.junit.*;
-
-import com.vmware.gemfire.tools.pulse.internal.json.JSONObject;
-
-/**
- * JUnit Tests for ClusterSelectedRegionsMemberService in the back-end server for region detail page
- *
- *
- */
-@Ignore
-public class ClusterSelectedRegionsMemberServiceTest extends BaseServiceTest {
-
- /**
- * @throws java.lang.Exception
- *
- */
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- doLogin();
- System.out.println("\n\nClusterSelectedRegionsMemberServiceTest :: Setup done");
- }
-
- /**
- * @throws java.lang.Exception
- *
- */
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- doLogout();
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: Teardown done");
- }
-
- /**
- * @throws java.lang.Exception
- */
- @Override
- @Before
- public void setUp() throws Exception {
- System.out.println("running setup -- ClusterSelectedRegionsMemberServiceTest");
- }
-
- /**
- * @throws java.lang.Exception
- */
- @Override
- @After
- public void tearDown() throws Exception {
- System.out.println("running teardown -- ClusterSelectedRegionsMemberServiceTest");
- }
-
- /**
- * Tests that service returns json object
- *
- */
- @Test
- public void testResponseNotNull() {
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE BEGIN : NULL RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_3_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for ClusterSelectedRegionsMember", jsonObj.getJSONObject("ClusterSelectedRegionsMember"));
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
- }
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE END : NULL RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
- }
-
- /**
- *
- * Tests that response is for same logged in user
- *
- */
- @Test
- public void testResponseUsername() {
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE BEGIN : NULL USERNAME IN RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_3_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegionsMember");
- Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for ClusterSelectedRegionsMember", clusterSelectedRegionObj);
- Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server did not return 'userName' in request",clusterSelectedRegionObj.has("userName"));
- String szUser = clusterSelectedRegionObj.getString("userName");
- Assert.assertEquals("ClusterSelectedRegionsMemberServiceTest :: Server returned wrong user name. Expected was admin. Server returned = " + szUser, szUser, "admin");
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
- }
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE END : NULL USERNAME IN RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
- }
-
- /**
- *
- * Tests that response is for same region
- *
- *
- */
- @Test
- public void testResponseRegionOnMemberInfoMatches() {
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE BEGIN : MEMBER INFO RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_3_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegionsMember");
- Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for ClusterSelectedRegionsMember",clusterSelectedRegionObj);
- JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegionsMembers");
- Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for selectedRegionsMembers",jsonObjRegion);
- Iterator<String> itrMemberNames = jsonObjRegion.keys();
- Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null region on member info", itrMemberNames);
- while(itrMemberNames.hasNext()){
- String szMemberName = itrMemberNames.next();
- Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null member name", szMemberName);
- Assert.assertTrue("Server did not return member details",jsonObjRegion.has(szMemberName));
- JSONObject jsonMemberObj = jsonObjRegion.getJSONObject(szMemberName);
-
- Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server did not return 'regionFullPath' of region on member",jsonMemberObj.has("regionFullPath"));
- String szPath = jsonMemberObj.getString("regionFullPath");
- Assert.assertEquals("ClusterSelectedRegionsMemberServiceTest :: Server returned wrong region path for region on member", szPath, "/GlobalVilage_2/GlobalVilage_9");
- }
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
- }
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE END : MEMBER INFO RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
- }
-
- /**
- *
- * Tests that response is for same region
- *
- *
- */
- @Test
- public void testResponseNonExistentRegion() {
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE BEGIN : NON-EXISTENT REGION CHECK FOR CLUSTER REGION MEMBERS------");
- if(httpclient != null){
- try{
- System.out.println("Test for non-existent region : /Rubbish");
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_4_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegionsMember");
- Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null for ClusterSelectedRegionsMember",clusterSelectedRegionObj);
- JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegionsMembers");
- Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null for selectedRegionsMembers",jsonObjRegion);
- Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server did not return error on non-existent region",jsonObjRegion.has("errorOnRegion"));
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
- }
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE END : NON-EXISTENT REGION CHECK FOR CLUSTER REGION MEMBERS------");
- }
-
- /**
- *
- * Tests that response is for same region
- *
- *
- */
- @Test
- public void testResponseRegionOnMemberAccessor() {
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE BEGIN : ACCESSOR RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_3_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegionsMember");
- Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for ClusterSelectedRegionsMember",clusterSelectedRegionObj);
- JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegionsMembers");
- Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for selectedRegionsMembers",jsonObjRegion);
- Iterator<String> itrMemberNames = jsonObjRegion.keys();
- Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null region on member info", itrMemberNames);
- while(itrMemberNames.hasNext()){
- String szMemberName = itrMemberNames.next();
- Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null member name", szMemberName);
- Assert.assertTrue("Server did not return member details",jsonObjRegion.has(szMemberName));
- JSONObject jsonMemberObj = jsonObjRegion.getJSONObject(szMemberName);
-
- Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server did not return 'accessor' of region on member",jsonMemberObj.has("accessor"));
- String szAccessor = jsonMemberObj.getString("accessor");
- Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server returned non-boolean value for accessor attribute", ((szAccessor.equalsIgnoreCase("True"))
- || (szAccessor.equalsIgnoreCase("False"))) );
- }
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
- }
- System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE END : ACCESSOR RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java
deleted file mode 100644
index 8669b53..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests.junit;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URI;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.methods.RequestBuilder;
-import org.apache.http.util.EntityUtils;
-import org.junit.*;
-
-import com.vmware.gemfire.tools.pulse.internal.json.JSONArray;
-import com.vmware.gemfire.tools.pulse.internal.json.JSONObject;
-
-/**
- * JUnit Tests for MemberGatewayHubService in the back-end server for region detail page
- *
- *
- */
-@Ignore
-public class MemberGatewayHubServiceTest extends BaseServiceTest {
-
- /**
- *
- * @throws java.lang.Exception
- */
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- doLogin();
- System.out.println("\n\nMemberGatewayHubServiceTest :: Setup done");
- }
-
- /**
- *
- * @throws java.lang.Exception
- */
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- doLogout();
- System.out.println("MemberGatewayHubServiceTest :: Teardown done");
- }
-
- /**
- *
- * @throws java.lang.Exception
- */
- @Override
- @Before
- public void setUp() throws Exception {
- }
-
- /**
- *
- * @throws java.lang.Exception
- */
- @Override
- @After
- public void tearDown() throws Exception {
- }
-
- /**
- * Tests that service returns json object
- *
- */
- @Test
- public void testResponseNotNull() {
- System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE BEGIN : NULL RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE --------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", jsonObj.getJSONObject("MemberGatewayHub"));
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
- }
- System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE END : NULL RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
- }
-
- /**
- *
- * Tests that response is for same region
- *
- * Test method for {@link com.vmware.gemfire.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
- *
- */
- @Test
- public void testResponseIsGatewaySender() {
- System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE BEGIN : IS GATEWAY SENDER IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
- Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'isGatewaySender' for member", memberGatewayHubObj.has("isGatewaySender"));
- Boolean boolIsGatewaySender = memberGatewayHubObj.getBoolean("isGatewaySender");
- Assert.assertEquals("MemberGatewayHubServiceTest :: Server returned wrong value for 'isGatewaySender'. Expected 'isGatewaySender' = true, actual 'isGatewaySender' = " + boolIsGatewaySender, boolIsGatewaySender, true);
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
- }
- System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE END : IS GATEWAY SENDER IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
- }
-
-
- /**
- *
- * Tests that response is for same region
- *
- * Test method for {@link com.vmware.gemfire.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
- *
- */
- @Test
- public void testResponseGatewaySenderCount() {
- System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE BEGIN : GATEWAY SENDER COUNT IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
- Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'isGatewaySender' for member", memberGatewayHubObj.has("isGatewaySender"));
- Boolean boolIsGatewaySender = memberGatewayHubObj.getBoolean("isGatewaySender");
-
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'gatewaySenders' for member", memberGatewayHubObj.has("gatewaySenders"));
- JSONArray arrGatewaySender = memberGatewayHubObj.getJSONArray("gatewaySenders");
- Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for 'gatewaySenders'", arrGatewaySender);
- Assert.assertTrue( "MemberGatewayHubServiceTest :: Server returned mis-matched values for 'isGatewaySender' and gateway senders array count", ((boolIsGatewaySender && (arrGatewaySender.length() > 0)) || ((! boolIsGatewaySender) && (arrGatewaySender.length() == 0))) );
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
- }
- System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE END : GATEWAY SENDER COUNT IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
- }
-
- /**
- *
- * Tests that response is for same region
- *
- * Test method for {@link com.vmware.gemfire.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
- *
- */
- @Test
- public void testResponseGatewaySenderProperties() {
- System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE BEGIN : GATEWAY SENDER PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
- Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'isGatewaySender' for member", memberGatewayHubObj.has("isGatewaySender"));
- Boolean boolIsGatewaySender = memberGatewayHubObj.getBoolean("isGatewaySender");
-
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'gatewaySenders' for member", memberGatewayHubObj.has("gatewaySenders"));
- JSONArray arrGatewaySender = memberGatewayHubObj.getJSONArray("gatewaySenders");
- Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for 'gatewaySenders'", arrGatewaySender);
- Assert.assertTrue( "MemberGatewayHubServiceTest :: Server returned mis-matched values for 'isGatewaySender' and gateway senders array count", ((boolIsGatewaySender && (arrGatewaySender.length() > 0)) || ((! boolIsGatewaySender) && (arrGatewaySender.length() == 0))) );
-
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'remoteDSId' for member", ((JSONObject)arrGatewaySender.get(0)).has("remoteDSId"));
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'eventsExceedingAlertThreshold' for member", ((JSONObject)arrGatewaySender.get(0)).has("eventsExceedingAlertThreshold"));
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
- }
- System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE END : GATEWAY SENDER PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
- }
-
- /**
- *
- * Tests that response is for same region
- *
- * Test method for {@link com.vmware.gemfire.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
- *
- */
- @Test
- public void testResponseAsyncEventQueueProperties() {
- System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE BEGIN : ASYNC EVENT QUEUE PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
- Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
-
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'asyncEventQueues' for member", memberGatewayHubObj.has("asyncEventQueues"));
- JSONArray arrAsyncEventQueues = memberGatewayHubObj.getJSONArray("asyncEventQueues");
- Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for 'asyncEventQueues'", arrAsyncEventQueues);
-
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'id' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("id"));
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'primary' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("primary"));
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'senderType' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("senderType"));
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'batchSize' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("batchSize"));
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'batchTimeInterval' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("batchTimeInterval"));
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'batchConflationEnabled' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("batchConflationEnabled"));
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'asyncEventListener' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("asyncEventListener"));
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'queueSize' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("queueSize"));
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
- }
- System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE END : ASYNC EVENT QUEUE PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
- }
-
- /**
- *
- * Tests that response is for same region
- *
- * Test method for {@link com.vmware.gemfire.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
- *
- */
- @Test
- public void testResponseNoAsyncEventQueues() {
- System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE BEGIN : NO ASYNC EVENT QUEUES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
- if(httpclient != null){
- try{
- HttpUriRequest pulseupdate = RequestBuilder.post()
- .setUri(new URI(PULSE_UPDATE_URL))
- .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_6_VALUE)
- .build();
- CloseableHttpResponse response = httpclient.execute(pulseupdate);
- try {
- HttpEntity entity = response.getEntity();
-
- System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
-
- BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- String sz = null;
- while((sz = respReader.readLine()) != null){
- pw.print(sz);
- }
- String jsonResp = sw.getBuffer().toString();
- System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
- EntityUtils.consume(entity);
-
- JSONObject jsonObj = new JSONObject(jsonResp);
- JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
- Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
-
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'asyncEventQueues' for member", memberGatewayHubObj.has("asyncEventQueues"));
- JSONArray arrAsyncEventQueues = memberGatewayHubObj.getJSONArray("asyncEventQueues");
- Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for 'asyncEventQueues'", arrAsyncEventQueues);
- Assert.assertTrue("MemberGatewayHubServiceTest :: Server returned non-empty array for member 'pnq-visitor2' which has no event queues", (arrAsyncEventQueues.length() == 0));
- } finally {
- response.close();
- }
- } catch(Exception failed) {
- logException(failed);
- Assert.fail("Exception ! ");
- }
- } else {
- Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
- }
- System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE END : NO ASYNC EVENT QUEUES PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
- }
-
-
-}
[13/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGatewayHubService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGatewayHubService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGatewayHubService.java
new file mode 100644
index 0000000..932ec41
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGatewayHubService.java
@@ -0,0 +1,149 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Class MemberGatewayHubService
+ *
+ * This class contains implementations of getting Gateway Receivers and Senders
+ * details of Cluster Member.
+ *
+ * @since GemFire version 7.5
+ */
+@Component
+@Service("MemberGatewayHub")
+@Scope("singleton")
+public class MemberGatewayHubService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
+ String memberName = requestDataJSON.get("MemberGatewayHub").get("memberName").textValue();
+
+ Cluster.Member clusterMember = cluster.getMember(StringUtils
+ .makeCompliantName(memberName));
+
+ if (clusterMember != null) {
+ // response
+ // get gateway receiver
+ Cluster.GatewayReceiver gatewayReceiver = clusterMember.getGatewayReceiver();
+
+ Boolean isGateway = false;
+
+ if (gatewayReceiver != null) {
+ responseJSON.put("isGatewayReceiver", true);
+ responseJSON.put("listeningPort", gatewayReceiver.getListeningPort());
+ responseJSON.put("linkTroughput", gatewayReceiver.getLinkThroughput());
+ responseJSON.put("avgBatchLatency", gatewayReceiver.getAvgBatchProcessingTime());
+ } else {
+ responseJSON.put("isGatewayReceiver", false);
+ }
+
+ // get gateway senders
+ Cluster.GatewaySender[] gatewaySenders = clusterMember.getMemberGatewaySenders();
+
+ if (gatewaySenders.length > 0) {
+ isGateway = true;
+ }
+ responseJSON.put("isGatewaySender", isGateway);
+ // Senders
+ ArrayNode gatewaySendersJsonList = mapper.createArrayNode();
+
+ for (Cluster.GatewaySender gatewaySender : gatewaySenders) {
+ ObjectNode gatewaySenderJSON = mapper.createObjectNode();
+ gatewaySenderJSON.put("id", gatewaySender.getId());
+ gatewaySenderJSON.put("queueSize", gatewaySender.getQueueSize());
+ gatewaySenderJSON.put("status", gatewaySender.getStatus());
+ gatewaySenderJSON.put("primary", gatewaySender.getPrimary());
+ gatewaySenderJSON.put("senderType", gatewaySender.getSenderType());
+ gatewaySenderJSON.put("batchSize", gatewaySender.getBatchSize());
+ gatewaySenderJSON.put("PersistenceEnabled", gatewaySender.getPersistenceEnabled());
+ gatewaySenderJSON.put("remoteDSId", gatewaySender.getRemoteDSId());
+ gatewaySenderJSON.put("eventsExceedingAlertThreshold", gatewaySender.getEventsExceedingAlertThreshold());
+
+ gatewaySendersJsonList.add(gatewaySenderJSON);
+ }
+ // senders response
+ responseJSON.put("gatewaySenders", gatewaySendersJsonList);
+
+ // async event queues
+ Cluster.AsyncEventQueue[] asyncEventQueues = clusterMember.getMemberAsyncEventQueueList();
+ ArrayNode asyncEventQueueJsonList = mapper.createArrayNode();
+
+ for (Cluster.AsyncEventQueue asyncEventQueue : asyncEventQueues) {
+ ObjectNode asyncEventQueueJSON = mapper.createObjectNode();
+ asyncEventQueueJSON.put("id", asyncEventQueue.getId());
+ asyncEventQueueJSON.put("primary", asyncEventQueue.getPrimary());
+ asyncEventQueueJSON.put("senderType", asyncEventQueue.isParallel());
+ asyncEventQueueJSON.put("batchSize", asyncEventQueue.getBatchSize());
+ asyncEventQueueJSON.put("batchTimeInterval", asyncEventQueue.getBatchTimeInterval());
+ asyncEventQueueJSON.put("batchConflationEnabled", asyncEventQueue.isBatchConflationEnabled());
+ asyncEventQueueJSON.put("asyncEventListener", asyncEventQueue.getAsyncEventListener());
+ asyncEventQueueJSON.put("queueSize", asyncEventQueue.getEventQueueSize());
+
+ asyncEventQueueJsonList.add(asyncEventQueueJSON);
+ }
+ responseJSON.put("asyncEventQueues", asyncEventQueueJsonList);
+
+ Map<String,Cluster.Region> clusterRegions = cluster.getClusterRegions();
+
+ List<Cluster.Region> clusterRegionsList = new ArrayList<Cluster.Region>();
+ clusterRegionsList.addAll(clusterRegions.values());
+
+ ArrayNode regionsList = mapper.createArrayNode();
+
+ for (Cluster.Region region : clusterRegionsList) {
+ if (region.getWanEnabled()) {
+ ObjectNode regionJSON = mapper.createObjectNode();
+ regionJSON.put("name", region.getName());
+ regionsList.add(regionJSON);
+ }
+ }
+ responseJSON.put("regionsInvolved", regionsList);
+ }
+
+ // Send json response
+ return responseJSON;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberHeapUsageService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberHeapUsageService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberHeapUsageService.java
new file mode 100644
index 0000000..966b346
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberHeapUsageService.java
@@ -0,0 +1,73 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Class MemberHeapUsageService
+ *
+ * This class contains implementations of getting Memeber's current Heap Usage
+ * and its trend over the time.
+ *
+ * @since GemFire version 7.5
+ */
+@Component
+@Service("MemberHeapUsage")
+@Scope("singleton")
+public class MemberHeapUsageService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ // members list
+ JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
+ String memberName = requestDataJSON.get("MemberHeapUsage").get("memberName").textValue();
+
+ Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
+
+ if (clusterMember != null) {
+ // response
+ responseJSON.put("heapUsageTrend",
+ mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_HEAP_USAGE_SAMPLE)));
+ responseJSON.put("currentHeapUsage", clusterMember.getCurrentHeapSize());
+ }
+
+ // Send json response
+ return responseJSON;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberKeyStatisticsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberKeyStatisticsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberKeyStatisticsService.java
new file mode 100644
index 0000000..8519ad4
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberKeyStatisticsService.java
@@ -0,0 +1,76 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Class MemberKeyStatisticsService
+ *
+ * This class contains implementations of getting Member's CPU, Memory and Read
+ * Write details
+ *
+ * @since GemFire version 7.5
+ */
+@Component
+@Service("MemberKeyStatistics")
+@Scope("singleton")
+public class MemberKeyStatisticsService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
+ String memberName = requestDataJSON.get("MemberKeyStatistics").get("memberName").textValue();
+
+ Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
+
+ if (clusterMember != null) {
+ // response
+ responseJSON.put("cpuUsageTrend",
+ mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_CPU_USAGE_SAMPLE)));
+ responseJSON.put("memoryUsageTrend",
+ mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_HEAP_USAGE_SAMPLE)));
+ responseJSON.put("readPerSecTrend",
+ mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_GETS_PER_SECOND)));
+ responseJSON.put("writePerSecTrend",
+ mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_PUTS_PER_SECOND)));
+ }
+ // Send json response
+ return responseJSON;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberRegionsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberRegionsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberRegionsService.java
new file mode 100644
index 0000000..ffd24d0
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberRegionsService.java
@@ -0,0 +1,127 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.DecimalFormat;
+
+/**
+ * Class MemberRegionsService
+ *
+ * This class contains implementations of getting Memeber's Regions details.
+ *
+ * @since GemFire version 7.5
+ */
+
+@Component
+@Service("MemberRegions")
+@Scope("singleton")
+public class MemberRegionsService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ // String constants used for forming a json response
+ private final String NAME = "name";
+ private final String ENTRY_SIZE = "entrySize";
+ private final String DISC_STORE_NAME = "diskStoreName";
+ private final String DISC_SYNCHRONOUS = "diskSynchronous";
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
+ String memberName = requestDataJSON.get("MemberRegions").get("memberName").textValue();
+
+ Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
+
+ if (clusterMember != null) {
+ responseJSON.put("memberId", clusterMember.getId());
+ responseJSON.put(this.NAME, clusterMember.getName());
+ responseJSON.put("host", clusterMember.getHost());
+
+ // member's regions
+ Cluster.Region[] memberRegions = clusterMember.getMemberRegionsList();
+ ArrayNode regionsListJson = mapper.createArrayNode();
+ for (Cluster.Region memberRegion : memberRegions) {
+ ObjectNode regionJSON = mapper.createObjectNode();
+ regionJSON.put(this.NAME, memberRegion.getName());
+
+ if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController.getPulseProductSupport())) {
+ // Convert region path to dot separated region path
+ regionJSON.put("fullPath", StringUtils.getTableNameFromRegionName(memberRegion.getFullPath()));
+ } else {
+ regionJSON.put("fullPath", memberRegion.getFullPath());
+ }
+
+ regionJSON.put("type", memberRegion.getRegionType());
+ regionJSON.put("entryCount", memberRegion.getSystemRegionEntryCount());
+ Long entrySize = memberRegion.getEntrySize();
+
+ DecimalFormat form = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN_2);
+ String entrySizeInMB = form.format(entrySize / (1024f * 1024f));
+
+ if (entrySize < 0) {
+ regionJSON.put(this.ENTRY_SIZE, this.VALUE_NA);
+ } else {
+ regionJSON.put(this.ENTRY_SIZE, entrySizeInMB);
+ }
+ regionJSON.put("scope", memberRegion.getScope());
+ String diskStoreName = memberRegion.getDiskStoreName();
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(diskStoreName)) {
+ regionJSON.put(this.DISC_STORE_NAME, diskStoreName);
+ regionJSON.put(this.DISC_SYNCHRONOUS,
+ memberRegion.isDiskSynchronous());
+ } else {
+ regionJSON.put(this.DISC_SYNCHRONOUS, this.VALUE_NA);
+ regionJSON.put(this.DISC_STORE_NAME, "");
+ }
+ regionJSON.put("gatewayEnabled", memberRegion.getWanEnabled());
+
+ regionsListJson.add(regionJSON);
+ }
+ responseJSON.put("memberRegions", regionsListJson);
+
+ // response
+ responseJSON.put("status", "Normal");
+
+ }
+
+ // Send json response
+ return responseJSON;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MembersListService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MembersListService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MembersListService.java
new file mode 100644
index 0000000..467d8c0
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MembersListService.java
@@ -0,0 +1,75 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Class MembersListService
+ *
+ * This class contains implementations of getting list of Cluster Members.
+ *
+ * @since GemFire version 7.5
+ */
+@Component
+@Service("MembersList")
+@Scope("singleton")
+public class MembersListService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ // members list
+ ArrayNode memberListJson = mapper.createArrayNode();
+ Cluster.Member[] memberSet = cluster.getMembers();
+
+ for (Cluster.Member member : memberSet) {
+ ObjectNode memberJSON = mapper.createObjectNode();
+ memberJSON.put("memberId", member.getId());
+ memberJSON.put("name", member.getName());
+ memberJSON.put("host", member.getHost());
+
+ memberListJson.add(memberJSON);
+ }
+
+ // Response JSON
+ responseJSON.put("clusterMembers", memberListJson);
+ responseJSON.put("clusterName", cluster.getServerName());
+
+ // Send json response
+ return responseJSON;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseService.java
new file mode 100644
index 0000000..58d9dbf
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseService.java
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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.service;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Abstract class PulseService
+ *
+ * This is a base class for all services in pulse.
+ *
+ * @since GemFire version 7.5
+ */
+public interface PulseService {
+
+ String VALUE_NA = "NA";
+ String VALUE_ON = "ON";
+ String VALUE_OFF = "OFF";
+
+ ObjectNode execute(HttpServletRequest httpServletRequest) throws Exception;
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseServiceFactory.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseServiceFactory.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseServiceFactory.java
new file mode 100644
index 0000000..ead5200
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseServiceFactory.java
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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.service;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+/**
+ * Class PulseServiceFactory
+ *
+ * @since GemFire version 7.5
+ */
+@Component
+@Scope("singleton")
+public class PulseServiceFactory implements ApplicationContextAware {
+
+ static final long serialVersionUID = 02L;
+ ApplicationContext applicationContext = null;
+
+ public PulseService getPulseServiceInstance(final String servicename) {
+
+ if (applicationContext != null
+ && applicationContext.containsBean(servicename)) {
+ return (PulseService) applicationContext.getBean(servicename);
+ }
+ return null;
+ }
+
+ @Override
+ public void setApplicationContext(final ApplicationContext applicationContext)
+ throws BeansException {
+
+ this.applicationContext = applicationContext;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseVersionService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseVersionService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseVersionService.java
new file mode 100644
index 0000000..7b84404
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseVersionService.java
@@ -0,0 +1,65 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Class PulseVersionService
+ *
+ * This class contains implementations of getting Pulse Applications Version's
+ * details (like version details, build details, source details, etc) from
+ * properties file
+ *
+ * @since GemFire version 7.0.Beta
+ */
+
+@Component
+@Service("PulseVersion")
+@Scope("singleton")
+public class PulseVersionService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ // Response
+ responseJSON.put("pulseVersion", PulseController.pulseVersion.getPulseVersion());
+ responseJSON.put("buildId", PulseController.pulseVersion.getPulseBuildId());
+ responseJSON.put("buildDate", PulseController.pulseVersion.getPulseBuildDate());
+ responseJSON.put("sourceDate", PulseController.pulseVersion.getPulseSourceDate());
+ responseJSON.put("sourceRevision", PulseController.pulseVersion.getPulseSourceRevision());
+ responseJSON.put("sourceRepository", PulseController.pulseVersion.getPulseSourceRepository());
+
+ // Send json response
+ return responseJSON;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/QueryStatisticsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/QueryStatisticsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/QueryStatisticsService.java
new file mode 100644
index 0000000..87f65df
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/QueryStatisticsService.java
@@ -0,0 +1,115 @@
+/*
+ *
+ * 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.service;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+
+/**
+ * Class QueryStatisticsService
+ *
+ * This class returns top N queries based on pagination and filtering criteria
+ * if any
+ *
+ * @since GemFire version 7.5
+ */
+@Component
+@Service("QueryStatistics")
+@Scope("singleton")
+public class QueryStatisticsService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ @Override
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ Cluster.Statement[] stmts = cluster.getStatements();
+
+ ArrayNode queryListJson = mapper.createArrayNode();
+ for (int i = 0; i < stmts.length; ++i) {
+ ObjectNode queryJSON = mapper.createObjectNode();
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QUERYDEFINITION, stmts[i].getQueryDefinition());
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESCOMPILED,
+ mapper.valueToTree(stmts[i].getNumTimesCompiled() < 0 ? this.VALUE_NA : stmts[i].getNumTimesCompiled()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTION,
+ mapper.valueToTree(stmts[i].getNumExecution() < 0 ? this.VALUE_NA : stmts[i].getNumExecution()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTIONSINPROGRESS,
+ mapper.valueToTree(stmts[i].getNumExecutionsInProgress() < 0 ? this.VALUE_NA : stmts[i].getNumExecutionsInProgress()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESGLOBALINDEXLOOKUP,
+ mapper.valueToTree(stmts[i].getNumTimesGlobalIndexLookup() < 0 ? this.VALUE_NA : stmts[i].getNumTimesGlobalIndexLookup()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMROWSMODIFIED,
+ mapper.valueToTree(stmts[i].getNumRowsModified() < 0 ? this.VALUE_NA : stmts[i].getNumRowsModified()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_PARSETIME,
+ mapper.valueToTree(stmts[i].getParseTime() < 0 ? this.VALUE_NA : stmts[i].getParseTime()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_BINDTIME,
+ mapper.valueToTree(stmts[i].getBindTime() < 0 ? this.VALUE_NA : stmts[i].getBindTime()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_OPTIMIZETIME,
+ mapper.valueToTree(stmts[i].getOptimizeTime() < 0 ? this.VALUE_NA : stmts[i].getOptimizeTime()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_ROUTINGINFOTIME,
+ mapper.valueToTree(stmts[i].getRoutingInfoTime() < 0 ? this.VALUE_NA : stmts[i].getRoutingInfoTime()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_GENERATETIME,
+ mapper.valueToTree(stmts[i].getGenerateTime() < 1 ? this.VALUE_NA : stmts[i].getGenerateTime()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_TOTALCOMPILATIONTIME,
+ mapper.valueToTree(stmts[i].getTotalCompilationTime() < 0 ? this.VALUE_NA : stmts[i].getTotalCompilationTime()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_EXECUTIONTIME,
+ mapper.valueToTree(stmts[i].getExecutionTime() < 0 ? this.VALUE_NA : stmts[i].getExecutionTime()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_PROJECTIONTIME,
+ mapper.valueToTree(stmts[i].getProjectionTime() < 0 ? this.VALUE_NA : stmts[i].getProjectionTime()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_TOTALEXECUTIONTIME,
+ mapper.valueToTree(stmts[i].getTotalExecutionTime() < 0 ? this.VALUE_NA : stmts[i].getTotalExecutionTime()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_ROWSMODIFICATIONTIME,
+ mapper.valueToTree(stmts[i].getRowsModificationTime() < 0 ? this.VALUE_NA : stmts[i].getRowsModificationTime()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNNUMROWSSEEN,
+ mapper.valueToTree(stmts[i].getqNNumRowsSeen() < 0 ? this.VALUE_NA : stmts[i].getqNNumRowsSeen()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNMSGSENDTIME,
+ mapper.valueToTree(stmts[i].getqNMsgSendTime() < 0 ? this.VALUE_NA : stmts[i].getqNMsgSendTime()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNMSGSERTIME,
+ mapper.valueToTree(stmts[i].getqNMsgSerTime() < 0 ? this.VALUE_NA : stmts[i].getqNMsgSerTime()));
+ queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNRESPDESERTIME,
+ mapper.valueToTree(stmts[i].getqNRespDeSerTime() < 0 ? this.VALUE_NA : stmts[i].getqNRespDeSerTime()));
+ queryListJson.add(queryJSON);
+ }
+ responseJSON.put("queriesList", queryListJson);
+
+ // return jmx status
+ responseJSON.put("connectedFlag", cluster.isConnectedFlag());
+ responseJSON.put("connectedErrorMsg", cluster.getConnectionErrorMsg());
+
+ // Send json response
+ return responseJSON;
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/SystemAlertsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/SystemAlertsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/SystemAlertsService.java
new file mode 100644
index 0000000..d21f47a
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/SystemAlertsService.java
@@ -0,0 +1,127 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Class SystemAlertsService
+ *
+ * This class contains implementations of getting system's alerts details (like
+ * errors, warnings and severe errors).
+ *
+ * @since GemFire version 7.5
+ */
+
+@Component
+@Service("SystemAlerts")
+@Scope("singleton")
+public class SystemAlertsService implements PulseService {
+
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
+ int pageNumber = 1; // Default
+ String strPageNumber = requestDataJSON.get("SystemAlerts").get("pageNumber").textValue();
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(strPageNumber)) {
+ try {
+ pageNumber = Integer.valueOf(strPageNumber);
+ } catch (NumberFormatException e) {
+ }
+ }
+
+ // cluster's Members
+ responseJSON.put("systemAlerts", getAlertsJson(cluster, pageNumber));
+ responseJSON.put("pageNumber", cluster.getNotificationPageNumber());
+ responseJSON.put("connectedFlag", cluster.isConnectedFlag());
+ responseJSON.put("connectedErrorMsg", cluster.getConnectionErrorMsg());
+
+ // Send json response
+ return responseJSON;
+ }
+
+ /**
+ * function used for getting all members details in format of JSON Object
+ * array defined under a cluster
+ *
+ * @param cluster
+ * @return JSONObject Array list
+ */
+ public static ObjectNode getAlertsJson(Cluster cluster, int pageNumber) {
+ // getting list of all types of alerts
+ Cluster.Alert[] alertsList = cluster.getAlertsList();
+
+ // create alerts json
+ ObjectNode alertsJsonObject = mapper.createObjectNode();
+
+ if ((alertsList != null) && (alertsList.length > 0)) {
+ ArrayNode errorJsonArray = mapper.createArrayNode();
+ ArrayNode severeJsonArray = mapper.createArrayNode();
+ ArrayNode warningJsonArray = mapper.createArrayNode();
+ ArrayNode infoJsonArray = mapper.createArrayNode();
+
+ cluster.setNotificationPageNumber(pageNumber);
+ for (Cluster.Alert alert : alertsList) {
+ ObjectNode objAlertJson = mapper.createObjectNode();
+ objAlertJson.put("description", alert.getDescription());
+ objAlertJson.put("memberName", alert.getMemberName());
+ objAlertJson.put("severity", alert.getSeverity());
+ objAlertJson.put("isAcknowledged", alert.isAcknowledged());
+ objAlertJson.put("timestamp", alert.getTimestamp().toString());
+ objAlertJson.put("iso8601Ts", alert.getIso8601Ts());
+ objAlertJson.put("id", alert.getId());
+
+ if (alert.getSeverity() == Cluster.Alert.SEVERE) {
+ severeJsonArray.add(objAlertJson);
+ } else if (alert.getSeverity() == Cluster.Alert.ERROR) {
+ errorJsonArray.add(objAlertJson);
+ } else if (alert.getSeverity() == Cluster.Alert.WARNING) {
+ warningJsonArray.add(objAlertJson);
+ } else {
+ infoJsonArray.add(objAlertJson);
+ }
+ }
+ alertsJsonObject.put("info", infoJsonArray);
+ alertsJsonObject.put("warnings", warningJsonArray);
+ alertsJsonObject.put("errors", errorJsonArray);
+ alertsJsonObject.put("severe", severeJsonArray);
+ }
+ return alertsJsonObject;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/ConnectionUtil.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/ConnectionUtil.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/ConnectionUtil.java
new file mode 100644
index 0000000..9bbed8a
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/ConnectionUtil.java
@@ -0,0 +1,46 @@
+/*
+ *
+ * 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.util;
+
+import java.io.IOException;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+
+
+/**
+ *
+ *
+ */
+public class ConnectionUtil {
+
+
+
+ public static SocketFactory getSocketFactory(boolean usessl)
+ throws IOException
+ {
+ if(usessl){
+ return (SSLSocketFactory)SSLSocketFactory.getDefault();
+ }else{
+ return SocketFactory.getDefault();
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/IPAddressUtil.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/IPAddressUtil.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/IPAddressUtil.java
new file mode 100644
index 0000000..8cb6036
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/IPAddressUtil.java
@@ -0,0 +1,65 @@
+/*
+ *
+ * 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.util;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+/* [ NOTE:
+ * This class supposed to be removed, if required, after discussing with
+ * VMware team ]
+ */
+/**
+ * Class IPAddressUtil This is utility class for checking whether ip address is
+ * versions i.e. IPv4 or IPv6 address
+ *
+ *
+ * @since GemFire version 7.0.1
+ */
+public class IPAddressUtil {
+
+ private static Pattern VALID_IPV4_PATTERN = null;
+ private static Pattern VALID_IPV6_PATTERN = null;
+ private static final String ipv4Pattern = "(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])";
+ private static final String ipv6Pattern = "([0-9a-f]{1,4}:){7}([0-9a-f]){1,4}";
+
+ static {
+ try {
+ VALID_IPV4_PATTERN = Pattern.compile(ipv4Pattern,
+ Pattern.CASE_INSENSITIVE);
+ VALID_IPV6_PATTERN = Pattern.compile(ipv6Pattern,
+ Pattern.CASE_INSENSITIVE);
+ } catch (PatternSyntaxException e) {
+
+ }
+ }
+
+ public static Boolean isIPv4LiteralAddress(String IPAddress) {
+ Matcher matcher = IPAddressUtil.VALID_IPV4_PATTERN.matcher(IPAddress);
+ return matcher.matches();
+ }
+
+ public static Boolean isIPv6LiteralAddress(String IPAddress) {
+
+ Matcher matcher = IPAddressUtil.VALID_IPV6_PATTERN.matcher(IPAddress);
+ return matcher.matches();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/StringUtils.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/StringUtils.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/StringUtils.java
new file mode 100644
index 0000000..64f2731
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/StringUtils.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.util;
+
+/**
+ * Class StringUtils This is utility class for string.
+ *
+ *
+ * @since GemFire version 7.0.1
+ */
+public class StringUtils {
+ /**
+ * Checks the string if it is not null, not empty, and not white space only
+ * using standard Java classes.
+ *
+ * @param string
+ * String to be checked.
+ * @return {@code true} if provided String is not null, is not empty, and has
+ * at least one character that is not considered white space.
+ */
+ public static boolean isNotNullNotEmptyNotWhiteSpace(final String string) {
+ return string != null && !string.isEmpty() && !string.trim().isEmpty();
+ }
+
+ /**
+ * Checking for String that is not null, not empty, and not white space only
+ * using standard Java classes.
+ *
+ * @param value
+ * String to be made compliant.
+ * @return string compliant string.
+ */
+ public static String makeCompliantName(String value) {
+ value = value.replace(':', '-');
+ value = value.replace(',', '-');
+ value = value.replace('=', '-');
+ value = value.replace('*', '-');
+ value = value.replace('?', '-');
+ if (value.length() < 1) {
+ value = "nothing";
+ }
+ return value;
+ }
+
+ /**
+ * Function to get table name derived from region name/full path
+ *
+ * @param regionName
+ * String to be made compliant.
+ * @return string compliant string.
+ */
+ public static String getTableNameFromRegionName(String regionName) {
+ String tableName = regionName.replaceFirst("/", "").replace('/', '.');
+ return tableName;
+ }
+
+ /**
+ * Function to get region name/full path derived from table name
+ *
+ * @param tableName
+ * String to be made compliant.
+ * @return string compliant string.
+ */
+ public static String getRegionNameFromTableName(String tableName) {
+ String regionName = "/" + tableName.replace('.', '/');
+ return regionName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/TimeUtils.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/TimeUtils.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/TimeUtils.java
new file mode 100644
index 0000000..21f9116
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/TimeUtils.java
@@ -0,0 +1,120 @@
+/*
+ *
+ * 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.util;
+
+/**
+ * Class TimeUtils
+ *
+ * This is utility class used for conversions of time.
+ *
+ *
+ * @since GemFire version 7.0.1
+ */
+public class TimeUtils {
+
+ /**
+ * Method to converts time given in milliseconds to string representation in
+ * days, hours, minutes and seconds
+ *
+ * @param longMilliSecs
+ * Time in milliseconds.
+ * @return String
+ */
+ public static String convertTimeMillisecondsToHMS(long longMilliSecs) {
+
+ long days = longMilliSecs / (1000 * 60 * 60 * 24);
+ long remainder = longMilliSecs % (1000 * 60 * 60 * 24);
+
+ long hours = remainder / (1000 * 60 * 60);
+ remainder = remainder % (1000 * 60 * 60);
+
+ long mins = remainder / (1000 * 60);
+ remainder = remainder % (1000 * 60);
+
+ long secs = remainder / 1000;
+
+ String strDaysHrsMinsSecs = "";
+
+ if (days > 0) {
+ strDaysHrsMinsSecs += days + " Days ";
+ }
+
+ if (hours > 0) {
+ strDaysHrsMinsSecs += hours + " Hours ";
+ } else {
+ strDaysHrsMinsSecs += "0 Hours ";
+ }
+
+ if (mins > 0) {
+ strDaysHrsMinsSecs += mins + " Mins ";
+ } else {
+ strDaysHrsMinsSecs += "0 Mins ";
+ }
+
+ strDaysHrsMinsSecs += secs + " Secs";
+
+ return strDaysHrsMinsSecs;
+ }
+
+ /**
+ * Method to converts time given in seconds to string representation in days,
+ * hours, minutes and seconds
+ *
+ * @param longSecs
+ * Time in seconds.
+ * @return String
+ */
+ public static String convertTimeSecondsToHMS(long longSecs) {
+
+ long days = longSecs / (60 * 60 * 24);
+ long remainder = longSecs % (60 * 60 * 24);
+
+ long hours = remainder / (60 * 60);
+ remainder = remainder % (60 * 60);
+
+ long mins = remainder / (60);
+ remainder = remainder % (60);
+
+ long secs = remainder;
+
+ String strDaysHrsMinsSecs = "";
+
+ if (days > 0) {
+ strDaysHrsMinsSecs += days + " Days ";
+ }
+
+ if (hours > 0) {
+ strDaysHrsMinsSecs += hours + " Hours ";
+ } else {
+ strDaysHrsMinsSecs += "0 Hours ";
+ }
+
+ if (mins > 0) {
+ strDaysHrsMinsSecs += mins + " Mins ";
+ } else {
+ strDaysHrsMinsSecs += "0 Mins ";
+ }
+
+ strDaysHrsMinsSecs += secs + " Secs";
+
+ return strDaysHrsMinsSecs;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml b/geode-pulse/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml
index 60edb18..cb7181d 100644
--- a/geode-pulse/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml
+++ b/geode-pulse/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml
@@ -28,7 +28,7 @@
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
- <context:component-scan base-package="com.vmware.gemfire.tools.pulse.internal" />
+ <context:component-scan base-package="org.apache.geode.tools.pulse.internal" />
<mvc:annotation-driven />
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml b/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml
index b14d03d..3756df7 100644
--- a/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml
+++ b/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml
@@ -56,7 +56,7 @@
</http>
<beans:bean name="customLogoutSuccessHandler"
- class="com.vmware.gemfire.tools.pulse.internal.security.LogoutHandler">
+ class="org.apache.geode.tools.pulse.internal.security.LogoutHandler">
<beans:constructor-arg value="/Login.html"/>
</beans:bean>
@@ -73,7 +73,7 @@
</beans:bean>
<beans:bean id="gemAuthenticationProvider"
- class="com.vmware.gemfire.tools.pulse.internal.security.GemFireAuthenticationProvider">
+ class="org.apache.geode.tools.pulse.internal.security.GemFireAuthenticationProvider">
</beans:bean>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/webapp/WEB-INF/web.xml b/geode-pulse/src/main/webapp/WEB-INF/web.xml
index bd02158..ff8b101 100644
--- a/geode-pulse/src/main/webapp/WEB-INF/web.xml
+++ b/geode-pulse/src/main/webapp/WEB-INF/web.xml
@@ -57,6 +57,6 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
- <listener-class>com.vmware.gemfire.tools.pulse.internal.PulseAppListener</listener-class>
+ <listener-class>org.apache.geode.tools.pulse.internal.PulseAppListener</listener-class>
</listener>
</web-app>
\ No newline at end of file
[09/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseBaseTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseBaseTest.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseBaseTest.java
deleted file mode 100644
index 380d086..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseBaseTest.java
+++ /dev/null
@@ -1,693 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import static com.vmware.gemfire.tools.pulse.tests.PulseAbstractTest.*;
-import static org.junit.Assert.*;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.concurrent.TimeUnit;
-
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Actions;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-public class PulseBaseTest {
-
- public static int maxWaitTime = 20;
-
- WebElement element = null;
-
- public WebElement findElementUsingId(String id) {
- return driver.findElement(By.id(id));
- }
- public WebElement findElementUsingXpath(String xpath) {
- return driver.findElement(By.xpath(xpath));
- }
-
- public void clickElementUsingId(String id) {
- findElementUsingId(id).click();
- }
-
- public void clickElementUsingXpath(String xpath) {
- findElementUsingXpath(xpath).click();
- }
-
- public void enterTextUsingId(String id, String textToEnter) {
- findElementUsingId(id).sendKeys(textToEnter);
-
- }
-
- public void enterTextUsingXpath(String xpath, String textToEnter) {
- findElementUsingXpath(xpath).sendKeys(textToEnter);
- }
-
- public String getValueFromPropertiesFile(String key) {
- return JMXProperties.getInstance().getProperty(key);
- }
-
- public void sendKeysUsingId(String Id, String textToEnter){
- findElementById(Id).sendKeys(textToEnter);
- }
-
- public void waitForElement(WebElement element) {
- driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
- WebDriverWait wait = new WebDriverWait(driver, 20);
- wait.until(ExpectedConditions.visibilityOf(element));
- }
-
- public WebElement findElementById(String id) {
- return driver.findElement(By.id(id));
- }
-
- public WebElement findElementByXpath(String xpath) {
- return driver.findElement(By.xpath(xpath));
- }
-
- public String getTextUsingXpath(String xpath) {
- return findElementByXpath(xpath).getText();
- }
-
- public String getTextUsingId(String id) {
- return findElementById(id).getText();
- }
-
- public String getPersistanceEnabled(Region r) {
- String persitance = null;
-
- if (r.getPersistentEnabled()) {
- persitance = "ON";
- } else if (!r.getPersistentEnabled()) {
- persitance = "OFF";
- }
- return persitance;
- }
-
- public String getPersistanceEnabled(String trueOrFalse) {
- String persitance = null;
-
- if (trueOrFalse.contains("true")) {
- persitance = "ON";
- } else if (trueOrFalse.contains("false")) {
- persitance = "OFF";
- }
- return persitance;
- }
-
- public String HeapUsage(String valueInKB) {
-
- return null;
- }
-
- // WIP - need to work on this --
- public HashMap<String, HashMap<String, Region>> getRegionDetailsFromUI(String regionName) {
-
- String[] regionNames = JMXProperties.getInstance().getProperty("regions").split(" ");
- HashMap<String, HashMap<String, Region>> regionUiMap = new HashMap<String, HashMap<String, Region>>();
-
- for (String region : regionNames) {
- HashMap<String, Region> regionMap = regionUiMap.get(region);
- }
-
- return regionUiMap;
- }
-
- public void validateServerGroupGridData() {
- List<WebElement> serverGridRows = driver.findElements(By.xpath("//table[@id='memberListSG']/tbody/tr"));
- int rowsCount = serverGridRows.size();
- String[][] gridDataFromUI = new String[rowsCount][7];
-
- for (int j = 2, x = 0; j <= serverGridRows.size(); j++, x++) {
- for (int i = 0; i <= 6; i++) {
- gridDataFromUI[x][i] = driver.findElement(
- By.xpath("//table[@id='memberListSG']/tbody/tr[" + j + "]/td[" + (i + 1) + "]")).getText();
- }
- }
-
- String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
- HashMap<String, HashMap<String, Member>> sgMap = new HashMap<String, HashMap<String, Member>>();
-
- for (String member : memberNames) {
- Member thisMember = new Member(member);
- String[] sgs = thisMember.getGroups();
-
- for (String sgName : sgs) {
- HashMap<String, Member> sgMembers = sgMap.get(sgName);
- if (sgMembers == null) {
- sgMembers = new HashMap<String, Member>();
- sgMap.put(sgName, sgMembers);
- }
- sgMembers.put(thisMember.getMember(), thisMember);
- }
- }
-
- for (int i = 0; i < gridDataFromUI.length - 1; i++) {
- String sgName = gridDataFromUI[i][0];
- String memName = gridDataFromUI[i][1];
- Member m = sgMap.get(sgName).get(memName);
-
- assertEquals(sgName, gridDataFromUI[i][0]);
- assertEquals(memName, gridDataFromUI[i][1]);
- assertEquals(m.getMember(), gridDataFromUI[i][2]);
- assertEquals(m.getHost(), gridDataFromUI[i][3]);
- String cupUsage = String.valueOf(m.getCpuUsage());
- assertEquals(cupUsage, gridDataFromUI[i][5]);
- }
-
- }
-
- public void validateRedundancyZonesGridData() {
- List<WebElement> rzGridRows = driver.findElements(By.xpath("//table[@id='memberListRZ']/tbody/tr"));
- int rowsCount = rzGridRows.size();
- String[][] gridDataFromUI = new String[rowsCount][7];
-
- for (int j = 2, x = 0; j <= rzGridRows.size(); j++, x++) {
- for (int i = 0; i <= 6; i++) {
- gridDataFromUI[x][i] = driver.findElement(
- By.xpath("//table[@id='memberListRZ']/tbody/tr[" + j + "]/td[" + (i + 1) + "]")).getText();
- }
- }
-
- String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
- HashMap<String, HashMap<String, Member>> rzMap = new HashMap<String, HashMap<String, Member>>();
-
- for (String member : memberNames) {
- Member thisMember = new Member(member);
- //String[] rz = thisMember.getRedundancyZone();
- String sgName = thisMember.getRedundancyZone();
-
- //for (String sgName : rz) {
- HashMap<String, Member> rzMembers = rzMap.get(sgName);
-
- if (rzMembers == null) {
- rzMembers = new HashMap<String, Member>();
- rzMap.put(sgName, rzMembers);
- }
-
- rzMembers.put(thisMember.getMember(), thisMember);
- //}
- }
-
- for (int i = 0; i < gridDataFromUI.length - 1; i++) {
- String sgName = gridDataFromUI[i][0];
- String memName = gridDataFromUI[i][1];
- Member m = rzMap.get(sgName).get(memName);
-
- assertEquals(sgName, gridDataFromUI[i][0]);
- assertEquals(memName, gridDataFromUI[i][1]);
- assertEquals(m.getMember(), gridDataFromUI[i][2]);
- assertEquals(m.getHost(), gridDataFromUI[i][3]);
- String cupUsage = String.valueOf(m.getCpuUsage());
- assertEquals(cupUsage, gridDataFromUI[i][5]);
- }
-
- }
-
- public void validateTopologyGridData() {
- List<WebElement> rzGridRows = driver.findElements(By.xpath("//table[@id='memberList']/tbody/tr"));
- int rowsCount = rzGridRows.size();
- String[][] gridDataFromUI = new String[rowsCount][8];
-
- for (int j = 2, x = 0; j <= rzGridRows.size(); j++, x++) {
- for (int i = 0; i <= 7; i++) {
- gridDataFromUI[x][i] = driver.findElement(
- By.xpath("//table[@id='memberList']/tbody/tr[" + j + "]/td[" + (i + 1) + "]")).getText();
- }
- }
-
- String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
- HashMap<String, Member> tpMap = new HashMap<String, Member>();
-
- for (String member : memberNames) {
- Member thisMember = new Member(member);
- tpMap.put(thisMember.getMember(), thisMember);
-
- }
-
- for (int i = 0; i < gridDataFromUI.length - 1; i++) {
-
- String memName = gridDataFromUI[i][0];
- Member m = tpMap.get(memName);
-
- assertEquals(m.getMember(), gridDataFromUI[i][0]);
- assertEquals(m.getMember(), gridDataFromUI[i][1]);
- assertEquals(m.getHost(), gridDataFromUI[i][2]);
- String cupUsage = String.valueOf(m.getCpuUsage());
- assertEquals(cupUsage, gridDataFromUI[i][5]);
- }
- }
-
- public void validateDataPrespectiveGridData() {
- List<WebElement> serverGridRows = driver.findElements(By.xpath("//table[@id='regionsList']/tbody/tr"));
- int rowsCount = serverGridRows.size();
- String[][] gridDataFromUI = new String[rowsCount][7];
-
- for (int j = 2, x = 0; j <= serverGridRows.size(); j++, x++) {
- for (int i = 0; i <= 6; i++) {
- if (i < 5) {
- gridDataFromUI[x][i] = driver.findElement(
- By.xpath("//table[@id='regionsList']/tbody/tr[" + j + "]/td[" + (i + 1) + "]")).getText();
- } else if (i == 5) {
- gridDataFromUI[x][i] = driver.findElement(
- By.xpath("//table[@id='regionsList']/tbody/tr[" + j + "]/td[" + (i + 4) + "]")).getText();
- }
- }
- }
-
- String[] regionNames = JMXProperties.getInstance().getProperty("regions").split(" ");
- HashMap<String, Region> dataMap = new HashMap<String, Region>();
-
- for (String region : regionNames) {
- Region thisRegion = new Region(region);
- dataMap.put(thisRegion.getName(), thisRegion);
-
- }
-
- for (int i = 0; i < gridDataFromUI.length - 1; i++) {
- String memName = gridDataFromUI[i][0];
- Region r = dataMap.get(memName);
-
- assertEquals(r.getName(), gridDataFromUI[i][0]);
- assertEquals(r.getRegionType(), gridDataFromUI[i][1]);
-
- assertEquals(String.valueOf(r.getSystemRegionEntryCount()), gridDataFromUI[i][2]);
- assertEquals(r.getFullPath(), gridDataFromUI[i][4]);
- assertEquals(getPersistanceEnabled(r), gridDataFromUI[i][5]);
- }
- }
-
- public void validateRegionDetailsGridData() {
- List<WebElement> serverGridRows = driver.findElements(By.xpath("//table[@id='memberList']/tbody/tr"));
- int rowsCount = serverGridRows.size();
- String[][] gridDataFromUI = new String[rowsCount][7];
-
- for (int j = 2, x = 0; j <= serverGridRows.size(); j++, x++) {
- for (int i = 0; i < 2; i++) {
- gridDataFromUI[x][i] = driver.findElement(
- By.xpath("//table[@id='memberList']/tbody/tr[" + j + "]/td[" + (i + 1) + "]")).getText();
- }
- }
-
- String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
- HashMap<String, Member> tpMap = new HashMap<String, Member>();
-
- for (String member : memberNames) {
- Member thisMember = new Member(member);
- tpMap.put(thisMember.getMember(), thisMember);
- }
-
- for (int i = 0; i < gridDataFromUI.length - 1; i++) {
-
- String memName = gridDataFromUI[i][0];
- Member m = tpMap.get(memName);
- assertEquals(m.getMember(), gridDataFromUI[i][0]);
- }
-
- }
-
- public void navigateToToplogyView(){
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingXpath(PulseTestLocators.TopologyView.radioButtonXpath);
- }
-
- public void navigateToServerGroupGView(){
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingXpath(PulseTestLocators.ServerGroups.radioButtonXpath);
- }
-
- public void navigateToRedundancyZoneView(){
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingXpath(PulseTestLocators.RedundancyZone.radioButtonXpath);
- }
-
- // ------ Topology / Server Group / Redundancy Group - Tree View
-
- public void navigateToTopologyTreeView(){
- navigateToToplogyView();
- clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
- }
-
- public void navigateToServerGroupTreeView() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingXpath(PulseTestLocators.ServerGroups.radioButtonXpath);
- }
-
- public void navigateToRedundancyZonesTreeView() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingXpath(PulseTestLocators.RedundancyZone.radioButtonXpath);
- }
-
- // ------ Topology / Server Group / Redundancy Group - Grid View
-
- public void navigateToTopologyGridView() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingXpath(PulseTestLocators.TopologyView.radioButtonXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
- }
-
- public void navigateToServerGroupGridView() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingXpath(PulseTestLocators.ServerGroups.radioButtonXpath);
- clickElementUsingId(PulseTestLocators.ServerGroups.gridButtonId);
- }
-
- public void navigateToRedundancyZonesGridView() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingXpath(PulseTestLocators.RedundancyZone.radioButtonXpath);
- clickElementUsingId(PulseTestLocators.RedundancyZone.gridButtonId);
- }
-
- // ----- Data perspective / region details
-
- public void navigateToDataPrespectiveGridView() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingXpath(PulseTestLocators.DataPerspectiveView.downarrowButtonXpath);
- clickElementUsingXpath(PulseTestLocators.DataPerspectiveView.dataViewButtonXpath);
- clickElementUsingId(PulseTestLocators.DataPerspectiveView.gridButtonId);
- }
-
- public void navigateToRegionDetailsView() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingXpath(PulseTestLocators.DataPerspectiveView.downarrowButtonXpath);
- clickElementUsingXpath(PulseTestLocators.DataPerspectiveView.dataViewButtonXpath);
- // clickElementUsingXpath(PulseTestLocators.RegionDetailsView.regionNameXpath);
- // // WIP - region navigation defect needs to fixed
- clickElementUsingXpath(PulseTestLocators.RegionDetailsView.treeMapCanvasXpath);
- }
-
- public void navigateToRegionDetailsGridView() {
- navigateToRegionDetailsView();
- clickElementUsingXpath(PulseTestLocators.RegionDetailsView.gridButtonXpath);
- }
-
- public String getPropertyValue(String propertyKey) {
- String propertyValue = JMXProperties.getInstance().getProperty(propertyKey);
- return propertyValue;
- }
-
- public void verifyElementPresentById(String id) {
- WebDriverWait wait = new WebDriverWait(driver, maxWaitTime, 500);
- wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id(id)));
- }
-
- public void verifyElementPresentByLinkText(String lnkText) {
- WebDriverWait wait = new WebDriverWait(driver, maxWaitTime, 500);
- wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.linkText(lnkText)));
- }
-
- public void verifyElementPresentByXpath(String xpath) {
- WebDriverWait wait = new WebDriverWait(driver, maxWaitTime, 500);
- wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(xpath)));
- }
-
- public void verifyTextPresrntById(String id, String text) {
- WebDriverWait wait = new WebDriverWait(driver, maxWaitTime, 500);
- wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id(id), text));
- }
-
- public void verifyTextPresrntByXpath(String xpath, String text) {
- WebDriverWait wait = new WebDriverWait(driver, maxWaitTime, 500);
- wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath(xpath), text));
- }
-
- public void verifyElementAttributeById(String id, String attribute, String value) {
- String actualValue = findElementById(id).getAttribute(attribute);
- assertTrue(actualValue.equals(value) || actualValue.contains(value));
- }
-
-
- public void mouseReleaseById(String id){
- verifyElementPresentById(id);
- Actions action = new Actions(driver);
- WebElement we = driver.findElement(By.id(id));
- action.moveToElement(we).release().perform();
- }
- public void mouseClickAndHoldOverElementById(String id) {
- verifyElementPresentById(id);
- Actions action = new Actions(driver);
- WebElement we = driver.findElement(By.id(id));
- action.moveToElement(we).clickAndHold().perform();
- }
-
- public void mouseOverElementByXpath(String xpath) {
- Actions action = new Actions(driver);
- WebElement we = driver.findElement(By.xpath(xpath));
- action.moveToElement(we).build().perform();
- }
-
-
- public float stringToFloat(String stringValue){
- float floatNum = Float.parseFloat(stringValue);
- return floatNum;
- }
-
- public String floatToString(float floatValue){
- String stringValue = Float.toString(floatValue);
- return stringValue;
- }
-
-
- public String[] splitString(String stringToSplit, String splitDelimiter){
- String [] stringArray = stringToSplit.split(splitDelimiter);
- return stringArray;
- }
-
- public void assertMemberSortingByCpuUsage(){
- Map<Double, String> memberMap = new TreeMap<>(Collections.reverseOrder());
- String [] membersNames = splitString(JMXProperties.getInstance().getProperty("members"), " ");
- for (String member : membersNames) {
- Member thisMember = new Member(member);
- memberMap.put(thisMember.getCpuUsage(), thisMember.getMember());
- }
- for(Map.Entry<Double,String> entry : memberMap.entrySet()) {
- //here matching painting style to validation that the members are painted according to their cpu usage
- String refMemberCPUUsage = null;
- if(entry.getValue().equalsIgnoreCase("M1")){
- refMemberCPUUsage = PulseTestData.Topology.cpuUsagePaintStyleM1;
- }else if(entry.getValue().equalsIgnoreCase("M2")){
- refMemberCPUUsage = PulseTestData.Topology.cpuUsagePaintStyleM2;
- }else{
- refMemberCPUUsage = PulseTestData.Topology.cpuUsagePaintStyleM3;
- }
- assertTrue(findElementById(entry.getValue()).getAttribute("style").contains(refMemberCPUUsage));
- }
- }
-
- public void assertMemberSortingByHeapUsage(){
- Map<Long, String> memberMap = new TreeMap<Long,String>(Collections.reverseOrder());
- String [] membersNames = splitString(JMXProperties.getInstance().getProperty("members"), " ");
- for (String member : membersNames) {
- Member thisMember = new Member(member);
- memberMap.put(thisMember.getCurrentHeapSize(), thisMember.getMember());
- }
- for(Map.Entry<Long, String> entry : memberMap.entrySet()) {
- //here matching painting style to validation that the members are painted according to their cpu usage
- String refMemberHeapUsage = null;
- if(entry.getValue().equalsIgnoreCase("M1")){
- refMemberHeapUsage = PulseTestData.Topology.heapUsagePaintStyleM1;
- }else if(entry.getValue().equalsIgnoreCase("M2")){
- refMemberHeapUsage = PulseTestData.Topology.heapUsagePaintStyleM2;
- }else{
- refMemberHeapUsage = PulseTestData.Topology.heapUsagePaintStyleM3;
- }
- assertTrue(findElementById(entry.getValue()).getAttribute("style").contains(refMemberHeapUsage));
- }
- }
-
- public void assertMemberSortingBySGCpuUsage(){
- Map<Double, String> memberMap = new TreeMap<>(Collections.reverseOrder());
- String [] membersNames = splitString(JMXProperties.getInstance().getProperty("members"), " ");
- for (String member : membersNames) {
- Member thisMember = new Member(member);
- memberMap.put(thisMember.getCpuUsage(), thisMember.getMember());
- }
- for(Map.Entry<Double,String> entry : memberMap.entrySet()) {
- //here matching painting style to validation that the members are painted according to their cpu usage
- String refMemberCPUUsage = null;
- if(entry.getValue().equalsIgnoreCase("M1")){
- refMemberCPUUsage = PulseTestData.Topology.cpuUsagePaintStyleM1;
- }else if(entry.getValue().equalsIgnoreCase("M2")){
- refMemberCPUUsage = PulseTestData.Topology.cpuUsagePaintStyleM2;
- }else{
- refMemberCPUUsage = PulseTestData.Topology.cpuUsagePaintStyleM3;
- }
- assertTrue(findElementById(entry.getValue()).getAttribute("style").contains(refMemberCPUUsage));
- }
- }
-
-
- public void assertMemberSortingBySgHeapUsage(){
- String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
- HashMap<String, HashMap<String, Member>> sgMap = new HashMap<String, HashMap<String, Member>>();
- for (String member : memberNames) {
- Member thisMember = new Member(member);
- String[] sgs = thisMember.getGroups();
-
- for (String sgName : sgs) {
- HashMap<String, Member> sgMembers = sgMap.get(sgName);
- if (sgMembers == null) {
- sgMembers = new HashMap<String, Member>();
- sgMap.put(sgName, sgMembers);
- }
- sgMembers.put(thisMember.getMember(), thisMember);
- }
- }
- Map<Float, String> memberMap = new TreeMap<Float,String>(Collections.reverseOrder());
-
- for(int sgId=1; sgId<=3; sgId++){
- String sgName = "SG1";
- String memName = "M" + sgId;
- Member m = sgMap.get(sgName).get(memName);
- memberMap.put((float) m.getCurrentHeapSize(), m.getMember());
- }
-
- for(Map.Entry<Float,String> entry : memberMap.entrySet()) {
- //here matching painting style to validation that the members are painted according to their cpu usage
- String refMemberCPUUsage = null;
- if(entry.getValue().equalsIgnoreCase("M1")){
- refMemberCPUUsage = PulseTestData.ServerGroups.heapUsagePaintStyleSG1M1;
- }else if(entry.getValue().equalsIgnoreCase("M2")){
- refMemberCPUUsage = PulseTestData.ServerGroups.heapUsagePaintStyleSG1M2;
- }else{
- refMemberCPUUsage = PulseTestData.ServerGroups.heapUsagePaintStyleSG1M3;
- }
- assertTrue(findElementById("SG1(!)"+entry.getValue()).getAttribute("style").contains(refMemberCPUUsage));
- }
- }
-
-
-
- public void assertMemberSortingBySgCpuUsage(){
- String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
- HashMap<String, HashMap<String, Member>> sgMap = new HashMap<String, HashMap<String, Member>>();
- for (String member : memberNames) {
- Member thisMember = new Member(member);
- String[] sgs = thisMember.getGroups();
-
- for (String sgName : sgs) {
- HashMap<String, Member> sgMembers = sgMap.get(sgName);
- if (sgMembers == null) {
- sgMembers = new HashMap<String, Member>();
- sgMap.put(sgName, sgMembers);
- }
- sgMembers.put(thisMember.getMember(), thisMember);
- }
- }
- Map<Double, String> memberMap = new TreeMap<>(Collections.reverseOrder());
- //SG3(!)M3
- for(int sgId=1; sgId<=3; sgId++){
- String sgName = "SG1";
- String memName = "M" + sgId;
- Member m = sgMap.get(sgName).get(memName);
- memberMap.put(m.getCpuUsage(), m.getMember());
- }
-
- for(Map.Entry<Double,String> entry : memberMap.entrySet()) {
- //here matching painting style to validation that the members are painted according to their cpu usage
- String refMemberCPUUsage = null;
- if(entry.getValue().equalsIgnoreCase("M1")){
- refMemberCPUUsage = PulseTestData.ServerGroups.cpuUsagePaintStyleSG1M1;
- }else if(entry.getValue().equalsIgnoreCase("M2")){
- refMemberCPUUsage = PulseTestData.ServerGroups.cpuUsagePaintStyleSG1M2;
- }else{
- refMemberCPUUsage = PulseTestData.ServerGroups.cpuUsagePaintStyleSG1M3;
- }
- assertTrue(findElementById("SG1(!)"+entry.getValue()).getAttribute("style").contains(refMemberCPUUsage));
- }
- }
-
- public void assertMemberSortingByRzHeapUsage(){
- String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
- HashMap<String, HashMap<String, Member>> rzMap = new HashMap<String, HashMap<String, Member>>();
- for (String member : memberNames) {
- Member thisMember = new Member(member);
- String sgName = thisMember.getRedundancyZone();
- HashMap<String, Member> rzMembers = rzMap.get(sgName);
-
- if (rzMembers == null) {
- rzMembers = new HashMap<String, Member>();
- rzMap.put(sgName, rzMembers);
- }
-
- rzMembers.put(thisMember.getMember(), thisMember);
- }
- Map<Float, String> memberMap = new TreeMap<Float,String>(Collections.reverseOrder());
- String rzName = "RZ1 RZ2";
- String memName = "M1" ;
- Member m = rzMap.get(rzName).get(memName);
- memberMap.put((float) m.getCurrentHeapSize(), m.getMember());
-
- for(Map.Entry<Float,String> entry : memberMap.entrySet()) {
- //here matching painting style to validation that the members are painted according to their cpu usage
- String refMemberHeapUsage = null;
- if(entry.getValue().equalsIgnoreCase("M1")){
- refMemberHeapUsage = PulseTestData.RedundancyZone.heapUsagePaintStyleRZ1RZ2M1;
- }else if(entry.getValue().equalsIgnoreCase("M2")){
- refMemberHeapUsage = PulseTestData.RedundancyZone.heapUsagePaintStyleRZ1RZ2M2;
- }else{
- refMemberHeapUsage = PulseTestData.RedundancyZone.heapUsagePaintStyleRZ3M3;
- }
- assertTrue(findElementById("RZ1 RZ2(!)"+entry.getValue()).getAttribute("style").contains(refMemberHeapUsage));
- }
- }
-
- public void assertMemeberSortingByRzCpuUsage(){
- String[] memberNames = JMXProperties.getInstance().getProperty("members").split(" ");
- HashMap<String, HashMap<String, Member>> rzMap = new HashMap<String, HashMap<String, Member>>();
- for (String member : memberNames) {
- Member thisMember = new Member(member);
- String sgName = thisMember.getRedundancyZone();
- HashMap<String, Member> rzMembers = rzMap.get(sgName);
-
- if (rzMembers == null) {
- rzMembers = new HashMap<String, Member>();
- rzMap.put(sgName, rzMembers);
- }
-
- rzMembers.put(thisMember.getMember(), thisMember);
- }
- Map<Double, String> memberMap = new TreeMap<>(Collections.reverseOrder());
- String rzName = "RZ1 RZ2";
- String memName = "M1" ;
- Member m = rzMap.get(rzName).get(memName);
- memberMap.put(m.getCpuUsage(), m.getMember());
-
- for(Map.Entry<Double,String> entry : memberMap.entrySet()) {
- //here matching painting style to validation that the members are painted according to their cpu usage
- String refMemberCPUUsage = null;
- if(entry.getValue().equalsIgnoreCase("M1")){
- refMemberCPUUsage = PulseTestData.RedundancyZone.cpuUsagePaintStyleRZ1RZ2M1;
- }else if(entry.getValue().equalsIgnoreCase("M2")){
- refMemberCPUUsage = PulseTestData.RedundancyZone.cpuUsagePaintStyleRZ1RZ2M2;
- }
- assertTrue(findElementById("RZ1 RZ2(!)"+entry.getValue()).getAttribute("style").contains(refMemberCPUUsage));
- }
- }
-
- public List<WebElement> getRegionsFromDataBrowser(){
- List<WebElement> regionList = driver.findElements(By.xpath("//span[starts-with(@ID,'treeDemo_')][contains(@id,'_span')]"));
- return regionList;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseNoAuthTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseNoAuthTest.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseNoAuthTest.java
deleted file mode 100644
index 114d32b..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseNoAuthTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import org.apache.geode.test.junit.categories.UITest;
-import org.junit.BeforeClass;
-import org.junit.FixMethodOrder;
-import org.junit.experimental.categories.Category;
-import org.junit.runners.MethodSorters;
-
-@Category(UITest.class)
-@FixMethodOrder(MethodSorters.JVM)
-public class PulseNoAuthTest extends PulseAbstractTest {
-
- @BeforeClass
- public static void beforeClassSetup() throws Exception {
- setUpServer("admin", "admin", null);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseTestData.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseTestData.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseTestData.java
deleted file mode 100644
index 88cfa4e..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseTestData.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-public class PulseTestData {
-
- public static class TopNavigation{
-
- }
-
- public static class ClusterStatus {
-
- public static final String membersProperty = "members";
- }
- public static class Topology{
- public static final String hotSpotHeapLbl = "Heap Usage";
- public static final String hotSpotCPULbl = "CPU Usage";
-
- public static final String cpuUsagePaintStyleM1 = "left: 497px; top: 0px;";
- public static final String cpuUsagePaintStyleM2 = "left: 0px; top: 0px;";
- public static final String cpuUsagePaintStyleM3 = "left: 265px; top: 0px;";
-
- public static final String heapUsagePaintStyleM1 = "left: 0px; top: 0px;";
- public static final String heapUsagePaintStyleM2 = "left: 559px; top: 0px;";
- public static final String heapUsagePaintStyleM3 = "left: 280px; top: 0px;";
- }
-
- public static class ServerGroups{
- public static final String hotSpotHeapLbl = "Heap Usage";
- public static final String hotSpotCPULbl = "CPU Usage";
-
- //Cpu Usage sorting
-// public static final String cpuUsagePaintStyleM1 = "left: 497px; top: 0px;";
-// public static final String cpuUsagePaintStyleM2 = "left: 0px; top: 0px;";
-// public static final String cpuUsagePaintStyleM3 = "left: 265px; top: 0px;";
-
- public static final String cpuUsagePaintStyleSG1M1 = "left: 0px; top: 295px;";
- public static final String cpuUsagePaintStyleSG1M2 = "left: 0px; top: 30px;";
- public static final String cpuUsagePaintStyleSG1M3 = "left: 0px; top: 171px;";
-
- public static final String cpuUsagePaintStyleSG2M1 = "left: 240px; top: 239px;";
- public static final String cpuUsagePaintStyleSG2M2 = "left: 240px; top: 30px;";
-
- public static final String cpuUsagePaintStyleSG3M3 = "left: 479px; top: 30px;";
-
- //heap usage sorting
- public static final String heapUsagePaintStyleSG1M1 = "left: 0px; top: 30px;";
- public static final String heapUsagePaintStyleSG1M2 = "left: 152px; top: 179px;";
- public static final String heapUsagePaintStyleSG1M3 = "left: 0px; top: 179px;";
-
- public static final String heapUsagePaintStyleSG2M1 = "left: 240px; top: 30px;";
- public static final String heapUsagePaintStyleSG2M2 = "left: 240px; top: 274px;";
-
- public static final String heapUsagePaintStyleSG3M3 = "left: 479px; top: 30px;";
- }
-
- public static class RedundancyZone{
-
- public static final String hotSpotHeapLbl = "Heap Usage";
- public static final String hotSpotCPULbl = "CPU Usage";
-
- public static final String heapUsagePaintStyleRZ1RZ2M1 = "left: 0px; top: 30px;";
- public static final String heapUsagePaintStyleRZ1RZ2M2 = "left: 0px; top: 274px;";
-
- public static final String heapUsagePaintStyleRZ3M3 = "left: 360px; top: 30px;";
-
- public static final String cpuUsagePaintStyleRZ1RZ2M1 ="left: 0px; top: 239px;";
- public static final String cpuUsagePaintStyleRZ1RZ2M2 ="left: 0px; top: 30px;";
-
-
- }
-
- public static class DataPerspectiveView {
-
- }
-
- public static class DataBrowser {
- public static final String partialRgnName = "R";
- public static final String chkRgnClassName = "bttn chk checkbox_true_full";
- public static final String notChkRgnClassName = "bttn chk checkbox_false_full";
-
- public static final String regName = "R1";
- public static final String query1Text = "select * from /R1";
-
- public static final String datePattern = "EEE, MMM dd yyyy, HH:mm:ss z";
-
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseTestLocators.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseTestLocators.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseTestLocators.java
deleted file mode 100644
index ec6a6b4..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseTestLocators.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-public class PulseTestLocators {
- public static class HtmlAttributes{
- public static final String classAttribute = "class";
- public static final String typeAttribute = "type";
- public static final String idAttribute = "id";
- public static final String nameAttribute = "name";
- public static final String placeholderAttribute = "placeholder";
- public static final String valueAttribute = "value";
- public static final String styleAttribute ="style";
- }
-
- public static class TopNavigation {
- public static final String clusterViewLinkXpath = "//a[text()='Cluster View']";
- }
-
- public static class ClusterStatus {
-
- }
-
- public static class MemberDetailsView {
- public static final String gridButtonXpath = "//a[@id='btngridIcon']";
- }
-
- public static class TopologyView {
-
- public static final String radioButtonId = "radio-default";
- public static final String radioButtonXpath = "//label[text()='Topology']";
- public static final String gridButtonId = "default_grid_button";
- public static final String nodeH1Id = "h1";
- public static final String nodeH2Id = "h2";
- public static final String nodeH3Id = "h3";
- public static final String memberM1Id = "M1";
- public static final String memberM2Id = "M2";
- public static final String memberM3Id = "M3";
- public static final String treeMapButtonId = "default_treemap_button";
-
- // Host tootips
- public static final String hostNameTTXpath = ".//*[@id='_tooltip']/div/div/div[1]";
- public static final String cpuUsageTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[1]/div[2]/div";
- public static final String memoryUsageTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[2]/div[2]/div";
- public static final String loadAvgTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[3]/div[2]/div";
- public static final String soketsTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[4]/div[2]/div";
-
- // Member tooltips
- public static final String memNameTTXpath = ".//*[@id='_tooltip']/div/div/div[1]";
- public static final String memCpuUsageTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[1]/div[2]/div";
- public static final String threadsTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[2]/div[2]/div/text()";
- public static final String jvmPausesTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[3]/div[2]/div";
- public static final String regionsTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[4]/div[2]/div";
- public static final String clientsTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[5]/div[2]/div";
- public static final String gatewaySenderTtXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[6]/div[2]/div";
- public static final String portTTXpath = ".//*[@id='_tooltip']/div/div/div[2]/div[7]/div[2]/div";
-
- // Grid view
- public static final String idM1Xpath = ".//*[@id='M1&M1']/td[1]";
- public static final String nameM1Xpath = ".//*[@id='M1&M1']/td[2]";
- public static final String hostH1Xpath = ".//*[@id='M1&M1']/td[3]";
- public static final String idM2Xpath = ".//*[@id='M2&M2']/td[1]";
- public static final String nameM2Xpath = ".//*[@id='M2&M2']/td[2]";
- public static final String hostH2Xpath = ".//*[@id='M2&M2']/td[3]";
- public static final String idM3Xpath = ".//*[@id='M3&M3']/td[1]";
- public static final String nameM3Xpath = ".//*[@id='M3&M3']/td[2]";
- public static final String hostH3Xpath = ".//*[@id='M3&M3']/td[3]";
-
- // HotSpot locators
- public static final String hotSpotId = "currentHotSpot";
- public static final String hotspotListDivId = "hotspotList";
- public static final String heapUsageXpath = "//a[text()='Heap Usage']";
- public static final String cpuUsageXpath = "//a[text()='CPU Usage']";
- public static final String graphTreeMapLblId = "//div[@id='GraphTreeMap-label']/child::node()";
-
- }
-
- public static class ServerGroups {
-
- public static final String radioButtonId = "radio-servergroups";
- public static final String radioButtonXpath = "//label[text()='Server Groups']";
- public static final String gridButtonId = "servergroups_grid_button";
- public static final String gridBlockId = "servergroups_grid_block";
-
- public static final String serverGrpsRadioId = "member_view_option_servergroups";
-
- public static final String serverGrpsRadioXpath = "//label[@for='radio-servergroups']";
-
- public static final String serverGrp1Id = "SG1";
- public static final String serverGrp2Id = "SG2";
- public static final String serverGrp3Id = "SG3";
-
- public static final String serverGrp1Xpath = ".//*[@id='SG1']/div";
- public static final String serverGrp2Xpath = ".//*[@id='SG2']/div";
- public static final String serverGrp3Xpath = ".//*[@id='SG3']/div";
-
- public static final String sg1M1Id = "SG1(!)M1";
- public static final String sg1M2Id = "SG1(!)M2";
- public static final String sg1M3Id = "SG1(!)M3";
- public static final String sg2M1Id = "SG2(!)M1";
- public static final String sg2M2Id = "SG2(!)M2";
- public static final String sg3M3Id = "SG3(!)M3";
-
- // Grid view
- public static final String idSG1M3Xpath = ".//*[@id='M3&M3']/td[2]";
- public static final String idSG1M2Xpath = ".//*[@id='M2&M2']/td[2]";
- public static final String idSG1M1Xpath = ".//*[@id='M1&M1']/td[2]";
- public static final String nameM3Xpath = ".//*[@id='M3&M3']/td[3]";
- public static final String nameM2Xpath = ".//*[@id='M2&M2']/td[3]";
- public static final String nameM1Xpath = ".//*[@id='M1&M1']/td[3]";
-
- //HotSpot locators
- public static final String hotSpotId = "currentHotSpot";
- public static final String hotspotListDivId= "hotspotList";
- public static final String heapUsageXpath= "//a[text()='Heap Usage']";
- public static final String cpuUsageXpath= "//a[text()='CPU Usage']";
- public static final String graphTreeMapLblId = "//div[@id='GraphTreeMap-label']/child::node()";
-
- }
-
- public static class RedundancyZone {
-
- public static final String radioButtonId = "radio-redundancyzones";
- public static final String radioButtonXpathAlt = "//label[text()='Redundancy Zones']";
- public static final String radioButtonXpath = "//label[@for='radio-redundancyzones']";
-
- public static final String gridButtonId = "redundancyzones_grid_button";
-
- public static final String zoneRZ1Id = "RZ1 RZ2";
- public static final String zoneRZ2Id = "RZ2";
-
-
- public static final String zoneRZ1RZ2Xpath = ".//*[@id='RZ1 RZ2']/div";
- public static final String zoneRZ2Xpath = ".//*[@id='RZ2']/div";
-
- public static final String m1RZ1RZ2Id = "RZ1 RZ2(!)M1";
- public static final String m2RZ1Id = "RZ1 RZ2(!)M2";
- public static final String m3RZ2Id = "RZ2(!)M3";
-// public static final String m3RZ2Id = "RZ2(!)M3";
-// public static final String m2RZ2Id = "RZ2(!)M2";
- // Grid
- public static final String idM2Xpath = ".//*[@id='M2&M2']/td[2]";
- public static final String idM1Xpath = ".//*[@id='M1&M1']/td[2]";
- public static final String idM3Xpath = ".//*[@id='M3&M3']/td[2]";
-
- //HotSpot locators
- public static final String hotSpotId = "currentHotSpot";
- public static final String hotspotListDivId= "hotspotList";
- public static final String heapUsageXpath= "//a[text()='Heap Usage']";
- public static final String cpuUsageXpath= "//a[text()='CPU Usage']";
- public static final String graphTreeMapLblId = "//div[@id='GraphTreeMap-label']/child::node()";
- }
-
- public static class DataPerspectiveView {
- public static final String downarrowButtonXpath = "//a[text()='Members']";
- public static final String dataViewButtonXpath = "//a[text()='Data']";
- public static final String gridButtonId = "data_grid_button";
- }
-
- public static class RegionDetailsView {
-
- public static final String regionNameDivId = "regionNameText";
- public static final String regionPathId = "regionPath";
- public static final String treeMapCanvasXpath = "//canvas[@id='GraphTreeMapClusterData-canvas']";
- public static final String regionTypeId = "regionType";
- public static final String regionMembersTextId = "regionMembersText";
- public static final String regionEmptyNodesId = "regionEmptyNodes";
- public static final String regionEntryCountTextId = "regionEntryCountText";
- public static final String regionDiskUsageId = "regionDiskUsage";
- public static final String regionPersistenceId = "regionPersistence";
-
- public static final String gridButtonXpath = "//a[@id='btngridIcon']";
- public static final String memoryUsedId = "memoryUsed";
- public static final String totalMemoryId = "totalMemory";
-
- public static final String inMemoryReadsId = "currentReadsPerSec";
- public static final String inMemoryWritesId = "currentWritesPerSec";
- public static final String diskReadsId = "currentDiskReadsPerSec";
- public static final String diskWritesId = "currentDiskWritesPerSec";
-
- public static final String memberNameId = "memberName";
-
- }
-
- public static class DataBrowser {
- public static final String rgnFilterTxtBoxId = "filterTextRegion";
- public static final String rgnNameSpanXpath = "//span[starts-with(@ID,'treeDemo_')][contains(@id,'_span')]";
- public static final String rgnNameTxtBoxXpath = "//span[starts-with(@ID,'treeDemo_')][contains(@id,'_span')]";
- public static final String rgnSpanFirstPart = "//span[@id='treeDemo_";
- public static final String rgnSpanSecondPart = "_span']";
- public static final String rgn1ChkBoxId = "treeDemo_1_check";
- public static final String queryEditorTxtBoxId = "dataBrowserQueryText";
- public static final String btnExecuteQueryId = "btnExecuteQuery";
-
- public static final String divDataRegions = "//div/ul[@id='treeDemo']/li";
-
- // History section
- public static final String historyIcon = "historyIcon";
- public static final String historyLst = "//div[@id='detailsHistoryList']/div/div";
- public static final String queryText = ".wrapHistoryContent";
- public static final String historyDateTime = ".dateTimeHistory";
-
- //Clear button
-
- public static final String btnClearXpath = "//input[@value='Clear']";
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Region.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Region.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Region.java
deleted file mode 100644
index ae8cc92..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Region.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-
-public class Region extends JMXBaseBean implements RegionMBean {
- private String name = null;
-
- private static String[] regAttItemNames = { "compressionCodec",
- "enableOffHeapMemory", "scope", "diskStoreName",
- "diskSynchronous" };
- private static String[] regAttItemDescriptions = { "compressionCodec",
- "enableOffHeapMemory", "scope", "diskStoreName",
- "diskSynchronous" };
- private static OpenType[] regAttItemTypes = { SimpleType.STRING,
- SimpleType.BOOLEAN, SimpleType.STRING,
- SimpleType.STRING, SimpleType.BOOLEAN };
- private static CompositeType listRegionAttributesCompData = null;
-
- static {
- try {
- listRegionAttributesCompData = new CompositeType("listRegionAttributes",
- "Regions attributes", regAttItemNames, regAttItemDescriptions,
- regAttItemTypes);
-
- } catch (OpenDataException e) {
- e.printStackTrace();
- }
- }
-
- public Region(String name) {
- this.name = name;
- }
-
- protected String getKey(String propName) {
- return "region." + name + "." + propName;
- }
-
- @Override
- public String[] getMembers() {
- return getStringArray("members");
- }
-
- @Override
- public String getFullPath() {
- return getString("fullPath");
- }
-
- @Override
- public double getDiskReadsRate() {
- return getDouble("diskReadsRate");
- }
-
- @Override
- public double getDiskWritesRate() {
- return getDouble("diskWritesRate");
- }
-
- @Override
- public int getEmptyNodes() {
- return getInt("emptyNodes");
- }
-
- @Override
- public double getGetsRate() {
- return getDouble("getsRate");
- }
-
- @Override
- public double getLruEvictionRate() {
- return getDouble("lruEvictionRate");
- }
-
- @Override
- public double getPutsRate() {
- return getDouble("putsRate");
- }
-
- @Override
- public String getRegionType() {
- return getString("regionType");
- }
-
- @Override
- public long getEntrySize() {
- return getLong("entrySize");
- }
-
- @Override
- public long getSystemRegionEntryCount() {
- return getLong("systemRegionEntryCount");
- }
-
- @Override
- public int getMemberCount() {
- return getInt("memberCount");
- }
-
- @Override
- public boolean getPersistentEnabled() {
- return getBoolean("persistentEnabled");
- }
-
- @Override
- public String getName() {
- return getString("name");
- }
-
- @Override
- public boolean getGatewayEnabled() {
- return getBoolean("gatewayEnabled");
- }
-
- @Override
- public long getDiskUsage() {
- return getLong("diskUsage");
- }
-
- @Override
- public CompositeData listRegionAttributes() {
- String value = JMXProperties.getInstance().getProperty(
- getKey("listRegionAttributes"), "");
- String[] itemValues = value.split(",");
- Map<String, Object> itemValuesHM = new HashMap<String, Object>();
-
- // compressionCodec
- if (null != itemValues[0]) {
- itemValuesHM.put(regAttItemNames[0], itemValues[0]);
- }
-
- // enableOffHeapMemory
- if (null != itemValues[1]) {
- itemValuesHM.put(regAttItemNames[1], Boolean.parseBoolean(itemValues[1]));
- }
-
- // scope
- if (null != itemValues[3]) {
- itemValuesHM.put(regAttItemNames[3], itemValues[3]);
- }
-
- // diskStoreName
- if (null != itemValues[4]) {
- itemValuesHM.put(regAttItemNames[4], itemValues[4]);
- }
-
- // diskSynchronous
- if (null != itemValues[5]) {
- itemValuesHM.put(regAttItemNames[5], Boolean.parseBoolean(itemValues[5]));
- }
-
- CompositeData lraCompData;
- try {
- lraCompData = new CompositeDataSupport(listRegionAttributesCompData,
- itemValuesHM);
- } catch (OpenDataException e) {
- e.printStackTrace();
- lraCompData = null;
- }
- return lraCompData;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/RegionMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/RegionMBean.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/RegionMBean.java
deleted file mode 100644
index a408b94..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/RegionMBean.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import javax.management.openmbean.CompositeData;
-
-public interface RegionMBean {
- String OBJECT_NAME = "GemFire:service=Region,type=Distributed";
-
- String[] getMembers();
-
- String getFullPath();
-
- double getDiskReadsRate();
-
- double getDiskWritesRate();
-
- int getEmptyNodes();
-
- double getGetsRate();
-
- double getLruEvictionRate();
-
- double getPutsRate();
-
- String getRegionType();
-
- long getEntrySize();
-
- long getSystemRegionEntryCount();
-
- int getMemberCount();
-
- boolean getPersistentEnabled();
-
- String getName();
-
- boolean getGatewayEnabled();
-
- long getDiskUsage();
-
- CompositeData listRegionAttributes();
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/RegionOnMember.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/RegionOnMember.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/RegionOnMember.java
deleted file mode 100644
index fc62de3..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/RegionOnMember.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-/**
- * Region on member mbean
- *
- *
- *
- */
-public class RegionOnMember extends JMXBaseBean implements RegionOnMemberMBean {
- private String fullPath = null;
- private String member = null;
-
- public RegionOnMember(String fullPath, String member) {
- this.fullPath = fullPath;
- this.member = member;
- }
-
- @Override
- protected String getKey(String propName) {
- return "regionOnMember." + fullPath + "." + member + "." + propName;
- }
-
- @Override
- public String getFullPath(){
- return this.fullPath;
- }
-
- @Override
- public String getMember(){
- return this.member;
- }
-
- @Override
- public String getName(){
- return getString("name");
- }
-
- @Override
- public String getRegionType(){
- return getString("regionType");
- }
-
- @Override
- public long getEntrySize(){
- return getLong("entrySize");
- }
-
- @Override
- public long getEntryCount(){
- return getLong("entryCount");
- }
-
- @Override
- public double getGetsRate(){
- return getDouble("getsRate");
- }
-
- @Override
- public double getPutsRate(){
- return getDouble("putsRate");
- }
-
- @Override
- public double getDiskReadsRate(){
- return getDouble("diskGetsRate");
- }
-
- @Override
- public double getDiskWritesRate(){
- return getDouble("diskPutsRate");
- }
-
- @Override
- public int getLocalMaxMemory(){
- return getInt("localMaxMemory");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/RegionOnMemberMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/RegionOnMemberMBean.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/RegionOnMemberMBean.java
deleted file mode 100644
index 3191582..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/RegionOnMemberMBean.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-/**
- * Region on members mbean
- *
- *
- */
-public interface RegionOnMemberMBean {
-
- String getName();
-
- String getRegionType(); // Ideally should be an Enum
-
- String getFullPath();
-
- String getMember();
-
- long getEntrySize();
-
- long getEntryCount();
-
- double getGetsRate();
-
- double getPutsRate();
-
- double getDiskReadsRate();
-
- double getDiskWritesRate();
-
- int getLocalMaxMemory();
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java
deleted file mode 100644
index 042a9bf..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/Server.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import org.apache.geode.security.templates.SampleSecurityManager;
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.mgt.DefaultSecurityManager;
-import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.realm.Realm;
-
-import org.apache.geode.internal.security.shiro.CustomAuthRealm;
-import org.apache.geode.internal.security.shiro.JMXShiroAuthenticator;
-import org.apache.geode.management.internal.security.AccessControlMBean;
-import org.apache.geode.management.internal.security.MBeanServerWrapper;
-import org.apache.geode.management.internal.security.ResourceConstants;
-
-public class Server {
-
- private static final String DEFAULT_HOST = "127.0.0.1"; //"localhost"
- private static final int DEFAULT_PORT = 9999;
- private final JMXServiceURL url;
- private MBeanServer mbs;
- private JMXConnectorServer cs;
- private String propFile = null;
-
- public Server(int port, String properties, String jsonAuthFile) throws Exception {
- this.propFile = properties;
- mbs = ManagementFactory.getPlatformMBeanServer();
- url = new JMXServiceURL(formJMXServiceURLString(DEFAULT_HOST, port));
-
- // Load the beans first, otherwise we get access denied
- loadMBeans();
-
- if (jsonAuthFile != null) {
- System.setProperty("spring.profiles.active", "pulse.authentication.gemfire");
-
- Map<String, Object> env = new HashMap<String, Object>();
-
- // set up Shiro Security Manager
- Properties securityProperties = new Properties();
- securityProperties.setProperty(SampleSecurityManager.SECURITY_JSON, jsonAuthFile);
- Realm realm = new CustomAuthRealm(SampleSecurityManager.class.getName(), securityProperties);
- SecurityManager securityManager = new DefaultSecurityManager(realm);
- SecurityUtils.setSecurityManager(securityManager);
-
- // register the AccessControll bean
- AccessControlMBean acc = new AccessControlMBean();
- ObjectName accessControlMBeanON = new ObjectName(ResourceConstants.OBJECT_NAME_ACCESSCONTROL);
- MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
- platformMBeanServer.registerMBean(acc, accessControlMBeanON);
-
- // wire in the authenticator and authorizaton
- JMXShiroAuthenticator interceptor = new JMXShiroAuthenticator();
- env.put(JMXConnectorServer.AUTHENTICATOR, interceptor);
- cs = JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
- cs.setMBeanServerForwarder(new MBeanServerWrapper());
-
- //set up the AccessControlMXBean
-
- } else {
- System.setProperty("spring.profiles.active", "pulse.authentication.default");
- cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
- }
-
- try {
- java.rmi.registry.LocateRegistry.createRegistry(port);
- System.out.println("RMI registry ready.");
- } catch (Exception e) {
- System.out.println("Exception starting RMI registry:");
- e.printStackTrace();
- }
-
- cs.start();
- }
-
- private String formJMXServiceURLString(String host, int port) throws UnknownHostException {
- String jmxSerURL = "";
-
- InetAddress inetAddr = InetAddress.getByName(host);
- if (inetAddr instanceof Inet4Address) {
- // Create jmx service url for IPv4 address
- jmxSerURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + port + "/jmxrmi";
- } else if (inetAddr instanceof Inet6Address) {
- // Create jmx service url for IPv6 address
- jmxSerURL = "service:jmx:rmi://[" + host + "]/jndi/rmi://[" + host + "]:" + port + "/jmxrmi";
- }
-
- return jmxSerURL;
- }
-
- public void stop() {
- try {
- cs.stop();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- private synchronized void loadMBeans() {
- JMXProperties props = JMXProperties.getInstance();
- try {
- props.load(propFile);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // Add servers
- String[] servers = getArrayProperty(props, "servers");
- for (String server : servers) {
- try {
- addServerMBean(server);
- } catch (InstanceAlreadyExistsException e) {
- e.printStackTrace();
- } catch (MBeanRegistrationException e) {
- e.printStackTrace();
- } catch (NotCompliantMBeanException e) {
- e.printStackTrace();
- } catch (MalformedObjectNameException e) {
- e.printStackTrace();
- } catch (NullPointerException e) {
- e.printStackTrace();
- }
- }
-
- // Add members
- String[] members = getArrayProperty(props, "members");
- for (String m : members) {
- try {
- addMemberMBean(m);
- } catch (InstanceAlreadyExistsException e) {
- e.printStackTrace();
- } catch (MBeanRegistrationException e) {
- e.printStackTrace();
- } catch (NotCompliantMBeanException e) {
- e.printStackTrace();
- } catch (MalformedObjectNameException e) {
- e.printStackTrace();
- } catch (NullPointerException e) {
- e.printStackTrace();
- }
- }
-
- // Add regions
- String[] regions = getArrayProperty(props, "regions");
- for (String reg : regions) {
- try {
- addRegionMBean(reg);
- } catch (InstanceAlreadyExistsException e) {
- e.printStackTrace();
- } catch (MBeanRegistrationException e) {
- e.printStackTrace();
- } catch (NotCompliantMBeanException e) {
- e.printStackTrace();
- } catch (MalformedObjectNameException e) {
- e.printStackTrace();
- } catch (NullPointerException e) {
- e.printStackTrace();
- }
- }
- }
-
- private void addMemberMBean(
- String m) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException, NullPointerException {
- Member m1 = new Member(m);
- mbs.registerMBean(m1, new ObjectName(Member.OBJECT_NAME + ",member=" + m));
- }
-
- // For GemFire XD
- private void addGemFireXDMemberMBean(
- String xdm) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException, NullPointerException {
- GemFireXDMember xdmo = new GemFireXDMember(xdm);
- mbs.registerMBean(xdmo, new ObjectName(GemFireXDMember.OBJECT_NAME + ",member=" + xdm));
- }
-
- private void addRegionMBean(
- String reg) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException, NullPointerException {
- Region regionObject = new Region(reg);
- mbs.registerMBean(regionObject, new ObjectName(Region.OBJECT_NAME + ",name=/" + reg));
-
- for (String member : regionObject.getMembers()) {
- RegionOnMember regionOnMemberObject = new RegionOnMember(regionObject.getFullPath(), member);
- mbs.registerMBean(regionOnMemberObject, new ObjectName(
- PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_REGION + regionObject.getFullPath() + PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_MEMBER + member));
- }
- }
-
- private void addServerMBean(
- String server) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException, NullPointerException {
- ServerObject so = new ServerObject(server);
- mbs.registerMBean(so, new ObjectName(ServerObject.OBJECT_NAME));
- }
-
- private String[] getArrayProperty(JMXProperties props, String propName) {
- String propVal = props.getProperty(propName, "");
- return propVal.split(" ");
- }
-
- public static Server createServer(int port, String properties, String jsonAuthFile)
- throws MalformedObjectNameException {
- Server s = null;
- try {
- s = new Server(port, properties, jsonAuthFile);
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
-
- return s;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/ServerObject.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/ServerObject.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/ServerObject.java
deleted file mode 100644
index e663d4f..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/ServerObject.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import java.io.IOException;
-
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.TabularDataSupport;
-import javax.management.openmbean.TabularType;
-
-public class ServerObject extends NotificationBroadcasterSupport implements
- ServerObjectMBean {
- private String name = null;
-
- private TabularDataSupport wanInfo;
- private static String[] itemNames = { "key", "value" };
- private static String[] itemDescriptions = { "Key", "Value" };
- private static OpenType[] itemTypes = { SimpleType.STRING, SimpleType.BOOLEAN };
- private static CompositeType wanInfoType = null;
-
- private static String[] indexNames = { "key" };
- private static TabularType wanType = null;
-
- static {
- try {
- wanInfoType = new CompositeType("wanInfo", "WAN Information", itemNames,
- itemDescriptions, itemTypes);
-
- wanType = new TabularType("wanInfo", "WAN Information", wanInfoType,
- indexNames);
-
- } catch (OpenDataException e) {
- e.printStackTrace();
- }
- }
-
- public ServerObject(String name) {
- this.name = name;
- this.wanInfo = new TabularDataSupport(wanType);
- }
-
- private String getKey(String propName) {
- return "server." + name + "." + propName;
- }
-
- @Override
- public String[] listCacheServers() {
- return JMXProperties.getInstance()
- .getProperty(getKey("listCacheServers"), "").split(" ");
- }
-
- @Override
- public String[] listServers() {
- return JMXProperties.getInstance()
- .getProperty(getKey("listServers"), "").split(" ");
- }
-
- @Override
- public TabularData viewRemoteClusterStatus() {
- wanInfo.clear();
- String[] wan = JMXProperties.getInstance()
- .getProperty(getKey("wanInfo"), "").split(" ");
- int cnt = 0;
- while (wan.length >= (cnt + 2)) {
- try {
- wanInfo.put(buildWanInfoType(new String(wan[cnt]),
- Boolean.parseBoolean(wan[cnt + 1])));
- } catch (OpenDataException e) {
- e.printStackTrace();
- }
- cnt += 2;
- }
-
- return (TabularData) wanInfo.clone();
- }
-
- @Override
- public int getMemberCount() {
- return Integer.parseInt(JMXProperties.getInstance().getProperty(
- getKey("memberCount")));
- }
-
- @Override
- public int getNumClients() {
- return Integer.parseInt(JMXProperties.getInstance().getProperty(
- getKey("numClients")));
- }
-
- @Override
- public int getDistributedSystemId() {
- return Integer.parseInt(JMXProperties.getInstance().getProperty(
- getKey("distributedSystemId")));
- }
-
- @Override
- public int getLocatorCount() {
- return Integer.parseInt(JMXProperties.getInstance().getProperty(
- getKey("locatorCount")));
- }
-
- @Override
- public int getTotalRegionCount() {
- return Integer.parseInt(JMXProperties.getInstance().getProperty(
- getKey("totalRegionCount")));
- }
-
- @Override
- public int getNumRunningFunctions() {
- return Integer.parseInt(JMXProperties.getInstance().getProperty(
- getKey("numRunningFunctions")));
- }
-
- @Override
- public long getRegisteredCQCount() {
- return Long.parseLong(JMXProperties.getInstance().getProperty(
- getKey("registeredCQCount")));
- }
-
- @Override
- public int getNumSubscriptions() {
- return Integer.parseInt(JMXProperties.getInstance().getProperty(
- getKey("numSubscriptions")));
- }
-
- // For SQLFire/GemFireXD
- @Override
- public int getTransactionCommitted() {
- return Integer.parseInt(JMXProperties.getInstance().getProperty(
- getKey("TransactionCommitted")));
- }
-
- // For SQLFire/GemFireXD
- @Override
- public int getTransactionRolledBack() {
- return Integer.parseInt(JMXProperties.getInstance().getProperty(
- getKey("TransactionRolledBack")));
- }
-
- @Override
- public long getTotalHeapSize() {
- return Long.parseLong(JMXProperties.getInstance().getProperty(
- getKey("totalHeapSize")));
- }
-
- @Override
- public long getUsedHeapSize() {
- return Long.parseLong(JMXProperties.getInstance().getProperty(
- getKey("usedHeapSize")));
- }
-
- @Override
- public long getMaxMemory() {
- return Long.parseLong(JMXProperties.getInstance().getProperty(
- getKey("MaxMemory")));
- }
-
- @Override
- public long getUsedMemory() {
- return Long.parseLong(JMXProperties.getInstance().getProperty(
- getKey("UsedMemory")));
- }
-
- @Override
- public long getTotalRegionEntryCount() {
- return Long.parseLong(JMXProperties.getInstance().getProperty(
- getKey("totalRegionEntryCount")));
- }
-
- @Override
- public int getCurrentQueryCount() {
- return Integer.parseInt(JMXProperties.getInstance().getProperty(
- getKey("currentQueryCount")));
- }
-
- @Override
- public long getTotalDiskUsage() {
- return Long.parseLong(JMXProperties.getInstance().getProperty(
- getKey("totalDiskUsage")));
- }
-
- @Override
- public double getDiskWritesRate() {
- return Double.parseDouble(JMXProperties.getInstance().getProperty(
- getKey("diskWritesRate")));
- }
-
- @Override
- public double getAverageWrites() {
- String val = JMXProperties.getInstance().getProperty(getKey("averageWrites"), "");
- double ret = Double.parseDouble(val);
- return ret;
-// return Double.parseDouble(JMXProperties.getInstance().getProperty(
-// getKey("averageWrites"), ""));
- }
-
- @Override
- public double getAverageReads() {
- return Double.parseDouble(JMXProperties.getInstance().getProperty(
- getKey("averageReads"), ""));
- }
-
- @Override
- public double getQueryRequestRate() {
- return Double.parseDouble(JMXProperties.getInstance().getProperty(
- getKey("queryRequestRate"), ""));
- }
-
- @Override
- public double getDiskReadsRate() {
- return Double.parseDouble(JMXProperties.getInstance().getProperty(
- getKey("diskReadsRate"), ""));
- }
-
- @Override
- public long getJVMPauses() {
- return Long.parseLong(JMXProperties.getInstance().getProperty(
- getKey("jvmPauses"), ""));
- }
-
- private CompositeData buildWanInfoType(String key, Boolean state)
- throws OpenDataException {
- Object[] itemValues = { key, state };
- CompositeData result = new CompositeDataSupport(wanInfoType, itemNames,
- itemValues);
-
- return result;
- }
-
- @Override
- public String queryData(String p0, String p1, int p2) {
- // p0 : query
- // p1 : comma separated members
- // p2 : limit
-
- DataBrowserResultLoader dbrLoader = DataBrowserResultLoader.getInstance();
-
- try {
- return dbrLoader.load(p0);
- } catch (IOException e) {
- e.printStackTrace();
- return e.getMessage();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/ServerObjectMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/ServerObjectMBean.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/ServerObjectMBean.java
deleted file mode 100644
index f5048eb..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/ServerObjectMBean.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import javax.management.openmbean.TabularData;
-
-public interface ServerObjectMBean {
- String OBJECT_NAME = "GemFire:service=System,type=Distributed";
-
- TabularData viewRemoteClusterStatus();
-
- int getMemberCount();
-
- int getNumClients();
-
- int getDistributedSystemId();
-
- int getLocatorCount();
-
- int getTotalRegionCount();
-
- int getNumRunningFunctions();
-
- long getRegisteredCQCount();
-
- int getNumSubscriptions();
-
- int getTransactionCommitted();
-
- int getTransactionRolledBack();
-
- long getTotalHeapSize();
-
- long getUsedHeapSize();
-
- long getMaxMemory();
-
- long getUsedMemory();
-
- long getTotalRegionEntryCount();
-
- int getCurrentQueryCount();
-
- long getTotalDiskUsage();
-
- double getDiskWritesRate();
-
- double getAverageWrites();
-
- double getAverageReads();
-
- double getQueryRequestRate();
-
- double getDiskReadsRate();
-
- long getJVMPauses();
-
- String[] listCacheServers();
-
- String[] listServers();
-
- String queryData(String p0, String p1, int p2);
-}
[15/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/README
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/README b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/README
new file mode 100644
index 0000000..2d7cdcf
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/README
@@ -0,0 +1,68 @@
+JSON in Java [package com.vmware.gemfire.tools.pulse.internal.json]
+
+Douglas Crockford
+douglas@crockford.com
+
+2011-02-02
+
+
+JSON is a light-weight, language independent, data interchange format.
+See http://www.JSON.org/
+
+The files in this package implement JSON encoders/decoders in Java.
+It also includes the capability to convert between JSON and XML, HTTP
+headers, Cookies, and CDL.
+
+This is a reference implementation. There is a large number of JSON packages
+in Java. Perhaps someday the Java community will standardize on one. Until
+then, choose carefully.
+
+The license includes this restriction: "The software shall be used for good,
+not evil." If your conscience cannot live with that, then choose a different
+package.
+
+The package compiles on Java 1.2 thru Java 1.4.
+
+
+JSONObject.java: The JSONObject can parse text from a String or a JSONTokener
+to produce a map-like object. The object provides methods for manipulating its
+contents, and for producing a JSON compliant object serialization.
+
+JSONArray.java: The JSONObject can parse text from a String or a JSONTokener
+to produce a vector-like object. The object provides methods for manipulating
+its contents, and for producing a JSON compliant array serialization.
+
+JSONTokener.java: The JSONTokener breaks a text into a sequence of individual
+tokens. It can be constructed from a String, Reader, or InputStream.
+
+JSONException.java: The JSONException is the standard exception type thrown
+by this package.
+
+
+JSONString.java: The JSONString interface requires a toJSONString method,
+allowing an object to provide its own serialization.
+
+JSONStringer.java: The JSONStringer provides a convenient facility for
+building JSON strings.
+
+JSONWriter.java: The JSONWriter provides a convenient facility for building
+JSON text through a writer.
+
+
+CDL.java: CDL provides support for converting between JSON and comma
+delimited lists.
+
+Cookie.java: Cookie provides support for converting between JSON and cookies.
+
+CookieList.java: CookieList provides support for converting between JSON and
+cookie lists.
+
+HTTP.java: HTTP provides support for converting between JSON and HTTP headers.
+
+HTTPTokener.java: HTTPTokener extends JSONTokener for parsing HTTP headers.
+
+XML.java: XML provides support for converting between JSON and XML.
+
+JSONML.java: JSONML provides support for converting between JSONML and XML.
+
+XMLTokener.java: XMLTokener extends JSONTokener for parsing XML text.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XML.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XML.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XML.java
new file mode 100644
index 0000000..d43eb77
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XML.java
@@ -0,0 +1,503 @@
+/*
+ *
+ * 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;
+
+
+/**
+ * This provides static methods to convert an XML text into a JSONObject,
+ * and to covert a JSONObject into an XML text.
+ * @author JSON.org
+ * @version 2011-02-11
+ */
+public class XML {
+
+ /** The Character '&'. */
+ public static final Character AMP = new Character('&');
+
+ /** The Character '''. */
+ public static final Character APOS = new Character('\'');
+
+ /** The Character '!'. */
+ public static final Character BANG = new Character('!');
+
+ /** The Character '='. */
+ public static final Character EQ = new Character('=');
+
+ /** The Character '>'. */
+ public static final Character GT = new Character('>');
+
+ /** The Character '<'. */
+ public static final Character LT = new Character('<');
+
+ /** The Character '?'. */
+ public static final Character QUEST = new Character('?');
+
+ /** The Character '"'. */
+ public static final Character QUOT = new Character('"');
+
+ /** The Character '/'. */
+ public static final Character SLASH = new Character('/');
+
+ /**
+ * Replace special characters with XML escapes:
+ * <pre>
+ * & <small>(ampersand)</small> is replaced by &amp;
+ * < <small>(less than)</small> is replaced by &lt;
+ * > <small>(greater than)</small> is replaced by &gt;
+ * " <small>(double quote)</small> is replaced by &quot;
+ * </pre>
+ * @param string The string to be escaped.
+ * @return The escaped string.
+ */
+ public static String escape(String string) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0, length = string.length(); i < length; i++) {
+ char c = string.charAt(i);
+ switch (c) {
+ case '&':
+ sb.append("&");
+ break;
+ case '<':
+ sb.append("<");
+ break;
+ case '>':
+ sb.append(">");
+ break;
+ case '"':
+ sb.append(""");
+ break;
+ case '\'':
+ sb.append("'");
+ break;
+ default:
+ sb.append(c);
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Throw an exception if the string contains whitespace.
+ * Whitespace is not allowed in tagNames and attributes.
+ * @param string
+ * @throws JSONException
+ */
+ public static void noSpace(String string) throws JSONException {
+ int i, length = string.length();
+ if (length == 0) {
+ throw new JSONException("Empty string.");
+ }
+ for (i = 0; i < length; i += 1) {
+ if (Character.isWhitespace(string.charAt(i))) {
+ throw new JSONException("'" + string +
+ "' contains a space character.");
+ }
+ }
+ }
+
+ /**
+ * Scan the content following the named tag, attaching it to the context.
+ * @param x The XMLTokener containing the source string.
+ * @param context The JSONObject that will include the new material.
+ * @param name The tag name.
+ * @return true if the close tag is processed.
+ * @throws JSONException
+ */
+ private static boolean parse(XMLTokener x, JSONObject context,
+ String name) throws JSONException {
+ char c;
+ int i;
+ JSONObject jsonobject = null;
+ String string;
+ String tagName;
+ Object token;
+
+// Test for and skip past these forms:
+// <!-- ... -->
+// <! ... >
+// <![ ... ]]>
+// <? ... ?>
+// Report errors for these forms:
+// <>
+// <=
+// <<
+
+ token = x.nextToken();
+
+// <!
+
+ if (token == BANG) {
+ c = x.next();
+ if (c == '-') {
+ if (x.next() == '-') {
+ x.skipPast("-->");
+ return false;
+ }
+ x.back();
+ } else if (c == '[') {
+ token = x.nextToken();
+ if ("CDATA".equals(token)) {
+ if (x.next() == '[') {
+ string = x.nextCDATA();
+ if (string.length() > 0) {
+ context.accumulate("content", string);
+ }
+ return false;
+ }
+ }
+ throw x.syntaxError("Expected 'CDATA['");
+ }
+ i = 1;
+ do {
+ token = x.nextMeta();
+ if (token == null) {
+ throw x.syntaxError("Missing '>' after '<!'.");
+ } else if (token == LT) {
+ i += 1;
+ } else if (token == GT) {
+ i -= 1;
+ }
+ } while (i > 0);
+ return false;
+ } else if (token == QUEST) {
+
+// <?
+
+ x.skipPast("?>");
+ return false;
+ } else if (token == SLASH) {
+
+// Close tag </
+
+ token = x.nextToken();
+ if (name == null) {
+ throw x.syntaxError("Mismatched close tag " + token);
+ }
+ if (!token.equals(name)) {
+ throw x.syntaxError("Mismatched " + name + " and " + token);
+ }
+ if (x.nextToken() != GT) {
+ throw x.syntaxError("Misshaped close tag");
+ }
+ return true;
+
+ } else if (token instanceof Character) {
+ throw x.syntaxError("Misshaped tag");
+
+// Open tag <
+
+ } else {
+ tagName = (String)token;
+ token = null;
+ jsonobject = new JSONObject();
+ for (;;) {
+ if (token == null) {
+ token = x.nextToken();
+ }
+
+// attribute = value
+
+ if (token instanceof String) {
+ string = (String)token;
+ token = x.nextToken();
+ if (token == EQ) {
+ token = x.nextToken();
+ if (!(token instanceof String)) {
+ throw x.syntaxError("Missing value");
+ }
+ jsonobject.accumulate(string,
+ XML.stringToValue((String)token));
+ token = null;
+ } else {
+ jsonobject.accumulate(string, "");
+ }
+
+// Empty tag <.../>
+
+ } else if (token == SLASH) {
+ if (x.nextToken() != GT) {
+ throw x.syntaxError("Misshaped tag");
+ }
+ if (jsonobject.length() > 0) {
+ context.accumulate(tagName, jsonobject);
+ } else {
+ context.accumulate(tagName, "");
+ }
+ return false;
+
+// Content, between <...> and </...>
+
+ } else if (token == GT) {
+ for (;;) {
+ token = x.nextContent();
+ if (token == null) {
+ if (tagName != null) {
+ throw x.syntaxError("Unclosed tag " + tagName);
+ }
+ return false;
+ } else if (token instanceof String) {
+ string = (String)token;
+ if (string.length() > 0) {
+ jsonobject.accumulate("content",
+ XML.stringToValue(string));
+ }
+
+// Nested element
+
+ } else if (token == LT) {
+ if (parse(x, jsonobject, tagName)) {
+ if (jsonobject.length() == 0) {
+ context.accumulate(tagName, "");
+ } else if (jsonobject.length() == 1 &&
+ jsonobject.opt("content") != null) {
+ context.accumulate(tagName,
+ jsonobject.opt("content"));
+ } else {
+ context.accumulate(tagName, jsonobject);
+ }
+ return false;
+ }
+ }
+ }
+ } else {
+ throw x.syntaxError("Misshaped tag");
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Try to convert a string into a number, boolean, or null. If the string
+ * can't be converted, return the string. This is much less ambitious than
+ * JSONObject.stringToValue, especially because it does not attempt to
+ * convert plus forms, octal forms, hex forms, or E forms lacking decimal
+ * points.
+ * @param string A String.
+ * @return A simple JSON value.
+ */
+ public static Object stringToValue(String string) {
+ if ("".equals(string)) {
+ return string;
+ }
+ if ("true".equalsIgnoreCase(string)) {
+ return Boolean.TRUE;
+ }
+ if ("false".equalsIgnoreCase(string)) {
+ return Boolean.FALSE;
+ }
+ if ("null".equalsIgnoreCase(string)) {
+ return JSONObject.NULL;
+ }
+ if ("0".equals(string)) {
+ return new Integer(0);
+ }
+
+// If it might be a number, try converting it. If that doesn't work,
+// return the string.
+
+ try {
+ char initial = string.charAt(0);
+ boolean negative = false;
+ if (initial == '-') {
+ initial = string.charAt(1);
+ negative = true;
+ }
+ if (initial == '0' && string.charAt(negative ? 2 : 1) == '0') {
+ return string;
+ }
+ if ((initial >= '0' && initial <= '9')) {
+ if (string.indexOf('.') >= 0) {
+ return Double.valueOf(string);
+ } else if (string.indexOf('e') < 0 && string.indexOf('E') < 0) {
+ Long myLong = new Long(string);
+ if (myLong.longValue() == myLong.intValue()) {
+ return new Integer(myLong.intValue());
+ } else {
+ return myLong;
+ }
+ }
+ }
+ } catch (Exception ignore) {
+ }
+ return string;
+ }
+
+
+ /**
+ * Convert a well-formed (but not necessarily valid) XML string into a
+ * JSONObject. Some information may be lost in this transformation
+ * because JSON is a data format and XML is a document format. XML uses
+ * elements, attributes, and content text, while JSON uses unordered
+ * collections of name/value pairs and arrays of values. JSON does not
+ * does not like to distinguish between elements and attributes.
+ * Sequences of similar elements are represented as JSONArrays. Content
+ * text may be placed in a "content" member. Comments, prologs, DTDs, and
+ * <code><[ [ ]]></code> are ignored.
+ * @param string The source string.
+ * @return A JSONObject containing the structured data from the XML string.
+ * @throws JSONException
+ */
+ public static JSONObject toJSONObject(String string) throws JSONException {
+ JSONObject jo = new JSONObject();
+ XMLTokener x = new XMLTokener(string);
+ while (x.more() && x.skipPast("<")) {
+ parse(x, jo, null);
+ }
+ return jo;
+ }
+
+
+ /**
+ * Convert a JSONObject into a well-formed, element-normal XML string.
+ * @param object A JSONObject.
+ * @return A string.
+ * @throws JSONException
+ */
+ public static String toString(Object object) throws JSONException {
+ return toString(object, null);
+ }
+
+
+ /**
+ * Convert a JSONObject into a well-formed, element-normal XML string.
+ * @param object A JSONObject.
+ * @param tagName The optional name of the enclosing tag.
+ * @return A string.
+ * @throws JSONException
+ */
+ public static String toString(Object object, String tagName)
+ throws JSONException {
+ StringBuffer sb = new StringBuffer();
+ int i;
+ JSONArray ja;
+ JSONObject jo;
+ String key;
+ Iterator keys;
+ int length;
+ String string;
+ Object value;
+ if (object instanceof JSONObject) {
+
+// Emit <tagName>
+
+ if (tagName != null) {
+ sb.append('<');
+ sb.append(tagName);
+ sb.append('>');
+ }
+
+// Loop thru the keys.
+
+ jo = (JSONObject)object;
+ keys = jo.keys();
+ while (keys.hasNext()) {
+ key = keys.next().toString();
+ value = jo.opt(key);
+ if (value == null) {
+ value = "";
+ }
+ if (value instanceof String) {
+ string = (String)value;
+ } else {
+ string = null;
+ }
+
+// Emit content in body
+
+ if ("content".equals(key)) {
+ if (value instanceof JSONArray) {
+ ja = (JSONArray)value;
+ length = ja.length();
+ for (i = 0; i < length; i += 1) {
+ if (i > 0) {
+ sb.append('\n');
+ }
+ sb.append(escape(ja.get(i).toString()));
+ }
+ } else {
+ sb.append(escape(value.toString()));
+ }
+
+// Emit an array of similar keys
+
+ } else if (value instanceof JSONArray) {
+ ja = (JSONArray)value;
+ length = ja.length();
+ for (i = 0; i < length; i += 1) {
+ value = ja.get(i);
+ if (value instanceof JSONArray) {
+ sb.append('<');
+ sb.append(key);
+ sb.append('>');
+ sb.append(toString(value));
+ sb.append("</");
+ sb.append(key);
+ sb.append('>');
+ } else {
+ sb.append(toString(value, key));
+ }
+ }
+ } else if ("".equals(value)) {
+ sb.append('<');
+ sb.append(key);
+ sb.append("/>");
+
+// Emit a new tag <k>
+
+ } else {
+ sb.append(toString(value, key));
+ }
+ }
+ if (tagName != null) {
+
+// Emit the </tagname> close tag
+
+ sb.append("</");
+ sb.append(tagName);
+ sb.append('>');
+ }
+ return sb.toString();
+
+// XML does not have good support for arrays. If an array appears in a place
+// where XML is lacking, synthesize an <array> element.
+
+ } else {
+ if (object.getClass().isArray()) {
+ object = new JSONArray(object);
+ }
+ if (object instanceof JSONArray) {
+ ja = (JSONArray)object;
+ length = ja.length();
+ for (i = 0; i < length; i += 1) {
+ sb.append(toString(ja.opt(i), tagName == null ? "array" : tagName));
+ }
+ return sb.toString();
+ } else {
+ string = (object == null) ? "null" : escape(object.toString());
+ return (tagName == null) ? "\"" + string + "\"" :
+ (string.length() == 0) ? "<" + tagName + "/>" :
+ "<" + tagName + ">" + string + "</" + tagName + ">";
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XMLTokener.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XMLTokener.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XMLTokener.java
new file mode 100644
index 0000000..aa18c85
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XMLTokener.java
@@ -0,0 +1,360 @@
+/*
+ *
+ * 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 XMLTokener extends the JSONTokener to provide additional methods
+ * for the parsing of XML texts.
+ * @author JSON.org
+ * @version 2010-12-24
+ */
+public class XMLTokener extends JSONTokener {
+
+
+ /** The table of entity values. It initially contains Character values for
+ * amp, apos, gt, lt, quot.
+ */
+ public static final java.util.HashMap entity;
+
+ static {
+ entity = new java.util.HashMap(8);
+ entity.put("amp", XML.AMP);
+ entity.put("apos", XML.APOS);
+ entity.put("gt", XML.GT);
+ entity.put("lt", XML.LT);
+ entity.put("quot", XML.QUOT);
+ }
+
+ /**
+ * Construct an XMLTokener from a string.
+ * @param s A source string.
+ */
+ public XMLTokener(String s) {
+ super(s);
+ }
+
+ /**
+ * Get the text in the CDATA block.
+ * @return The string up to the <code>]]></code>.
+ * @throws JSONException If the <code>]]></code> is not found.
+ */
+ public String nextCDATA() throws JSONException {
+ char c;
+ int i;
+ StringBuffer sb = new StringBuffer();
+ for (;;) {
+ c = next();
+ if (end()) {
+ throw syntaxError("Unclosed CDATA");
+ }
+ sb.append(c);
+ i = sb.length() - 3;
+ if (i >= 0 && sb.charAt(i) == ']' &&
+ sb.charAt(i + 1) == ']' && sb.charAt(i + 2) == '>') {
+ sb.setLength(i);
+ return sb.toString();
+ }
+ }
+ }
+
+
+ /**
+ * Get the next XML outer token, trimming whitespace. There are two kinds
+ * of tokens: the '<' character which begins a markup tag, and the content
+ * text between markup tags.
+ *
+ * @return A string, or a '<' Character, or null if there is no more
+ * source text.
+ * @throws JSONException
+ */
+ public Object nextContent() throws JSONException {
+ char c;
+ StringBuffer sb;
+ do {
+ c = next();
+ } while (Character.isWhitespace(c));
+ if (c == 0) {
+ return null;
+ }
+ if (c == '<') {
+ return XML.LT;
+ }
+ sb = new StringBuffer();
+ for (;;) {
+ if (c == '<' || c == 0) {
+ back();
+ return sb.toString().trim();
+ }
+ if (c == '&') {
+ sb.append(nextEntity(c));
+ } else {
+ sb.append(c);
+ }
+ c = next();
+ }
+ }
+
+
+ /**
+ * Return the next entity. These entities are translated to Characters:
+ * <code>& ' > < "</code>.
+ * @param ampersand An ampersand character.
+ * @return A Character or an entity String if the entity is not recognized.
+ * @throws JSONException If missing ';' in XML entity.
+ */
+ public Object nextEntity(char ampersand) throws JSONException {
+ StringBuffer sb = new StringBuffer();
+ for (;;) {
+ char c = next();
+ if (Character.isLetterOrDigit(c) || c == '#') {
+ sb.append(Character.toLowerCase(c));
+ } else if (c == ';') {
+ break;
+ } else {
+ throw syntaxError("Missing ';' in XML entity: &" + sb);
+ }
+ }
+ String string = sb.toString();
+ Object object = entity.get(string);
+ return object != null ? object : ampersand + string + ";";
+ }
+
+
+ /**
+ * Returns the next XML meta token. This is used for skipping over <!...>
+ * and <?...?> structures.
+ * @return Syntax characters (<code>< > / = ! ?</code>) are returned as
+ * Character, and strings and names are returned as Boolean. We don't care
+ * what the values actually are.
+ * @throws JSONException If a string is not properly closed or if the XML
+ * is badly structured.
+ */
+ public Object nextMeta() throws JSONException {
+ char c;
+ char q;
+ do {
+ c = next();
+ } while (Character.isWhitespace(c));
+ switch (c) {
+ case 0:
+ throw syntaxError("Misshaped meta tag");
+ case '<':
+ return XML.LT;
+ case '>':
+ return XML.GT;
+ case '/':
+ return XML.SLASH;
+ case '=':
+ return XML.EQ;
+ case '!':
+ return XML.BANG;
+ case '?':
+ return XML.QUEST;
+ case '"':
+ case '\'':
+ q = c;
+ for (;;) {
+ c = next();
+ if (c == 0) {
+ throw syntaxError("Unterminated string");
+ }
+ if (c == q) {
+ return Boolean.TRUE;
+ }
+ }
+ default:
+ for (;;) {
+ c = next();
+ if (Character.isWhitespace(c)) {
+ return Boolean.TRUE;
+ }
+ switch (c) {
+ case 0:
+ case '<':
+ case '>':
+ case '/':
+ case '=':
+ case '!':
+ case '?':
+ case '"':
+ case '\'':
+ back();
+ return Boolean.TRUE;
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Get the next XML Token. These tokens are found inside of angle
+ * brackets. It may be one of these characters: <code>/ > = ! ?</code> or it
+ * may be a string wrapped in single quotes or double quotes, or it may be a
+ * name.
+ * @return a String or a Character.
+ * @throws JSONException If the XML is not well formed.
+ */
+ public Object nextToken() throws JSONException {
+ char c;
+ char q;
+ StringBuffer sb;
+ do {
+ c = next();
+ } while (Character.isWhitespace(c));
+ switch (c) {
+ case 0:
+ throw syntaxError("Misshaped element");
+ case '<':
+ throw syntaxError("Misplaced '<'");
+ case '>':
+ return XML.GT;
+ case '/':
+ return XML.SLASH;
+ case '=':
+ return XML.EQ;
+ case '!':
+ return XML.BANG;
+ case '?':
+ return XML.QUEST;
+
+// Quoted string
+
+ case '"':
+ case '\'':
+ q = c;
+ sb = new StringBuffer();
+ for (;;) {
+ c = next();
+ if (c == 0) {
+ throw syntaxError("Unterminated string");
+ }
+ if (c == q) {
+ return sb.toString();
+ }
+ if (c == '&') {
+ sb.append(nextEntity(c));
+ } else {
+ sb.append(c);
+ }
+ }
+ default:
+
+// Name
+
+ sb = new StringBuffer();
+ for (;;) {
+ sb.append(c);
+ c = next();
+ if (Character.isWhitespace(c)) {
+ return sb.toString();
+ }
+ switch (c) {
+ case 0:
+ return sb.toString();
+ case '>':
+ case '/':
+ case '=':
+ case '!':
+ case '?':
+ case '[':
+ case ']':
+ back();
+ return sb.toString();
+ case '<':
+ case '"':
+ case '\'':
+ throw syntaxError("Bad character in a name");
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Skip characters until past the requested string.
+ * If it is not found, we are left at the end of the source with a result of false.
+ * @param to A string to skip past.
+ * @throws JSONException
+ */
+ public boolean skipPast(String to) throws JSONException {
+ boolean b;
+ char c;
+ int i;
+ int j;
+ int offset = 0;
+ int length = to.length();
+ char[] circle = new char[length];
+
+ /*
+ * First fill the circle buffer with as many characters as are in the
+ * to string. If we reach an early end, bail.
+ */
+
+ for (i = 0; i < length; i += 1) {
+ c = next();
+ if (c == 0) {
+ return false;
+ }
+ circle[i] = c;
+ }
+ /*
+ * We will loop, possibly for all of the remaining characters.
+ */
+ for (;;) {
+ j = offset;
+ b = true;
+ /*
+ * Compare the circle buffer with the to string.
+ */
+ for (i = 0; i < length; i += 1) {
+ if (circle[j] != to.charAt(i)) {
+ b = false;
+ break;
+ }
+ j += 1;
+ if (j >= length) {
+ j -= length;
+ }
+ }
+ /*
+ * If we exit the loop with b intact, then victory is ours.
+ */
+ if (b) {
+ return true;
+ }
+ /*
+ * Get the next character. If there isn't one, then defeat is ours.
+ */
+ c = next();
+ if (c == 0) {
+ return false;
+ }
+ /*
+ * Shove the character in the circle buffer and advance the
+ * circle offset. The offset is mod n.
+ */
+ circle[offset] = c;
+ offset += 1;
+ if (offset >= length) {
+ offset -= length;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/LogWriter.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/LogWriter.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/LogWriter.java
new file mode 100644
index 0000000..662c561
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/LogWriter.java
@@ -0,0 +1,265 @@
+/*
+ *
+ * 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.log;
+
+/**
+ * interface LogWriter
+ *
+ * LogWriter interface for Pulse Logging.
+ *
+ * @since GemFire 7.0.1
+ *
+ */
+public interface LogWriter {
+ /**
+ * Returns true if "severe" log messages are enabled. Returns false if
+ * "severe" log messages are disabled.
+ */
+ public boolean severeEnabled();
+
+ /**
+ * Writes both a message and exception to this writer. The message level is
+ * "severe".
+ */
+ public void severe(String msg, Throwable ex);
+
+ /**
+ * Writes a message to this writer. The message level is "severe".
+ */
+ public void severe(String msg);
+
+ /**
+ * Writes an exception to this writer. The exception level is "severe".
+ */
+ public void severe(Throwable ex);
+
+ /**
+ * Returns true if "error" log messages are enabled. Returns false if "error"
+ * log messages are disabled.
+ */
+ // public boolean errorEnabled();
+ /**
+ * Writes both a message and exception to this writer. The message level is
+ * "error".
+ */
+ // public void error(String msg, Throwable ex);
+ /**
+ * Writes a message to this writer. The message level is "error".
+ */
+ // public void error(String msg);
+ /**
+ * Writes an exception to this writer. The exception level is "error".
+ */
+ // public void error(Throwable ex);
+ /**
+ * Returns true if "warning" log messages are enabled. Returns false if
+ * "warning" log messages are disabled.
+ */
+ public boolean warningEnabled();
+
+ /**
+ * Writes both a message and exception to this writer. The message level is
+ * "warning".
+ */
+ public void warning(String msg, Throwable ex);
+
+ /**
+ * Writes a message to this writer. The message level is "warning".
+ */
+ public void warning(String msg);
+
+ /**
+ * Writes an exception to this writer. The exception level is "warning".
+ */
+ public void warning(Throwable ex);
+
+ /**
+ * Returns true if "info" log messages are enabled. Returns false if "info"
+ * log messages are disabled.
+ */
+ public boolean infoEnabled();
+
+ /**
+ * Writes both a message and exception to this writer. The message level is
+ * "information".
+ */
+ public void info(String msg, Throwable ex);
+
+ /**
+ * Writes a message to this writer. The message level is "information".
+ */
+ public void info(String msg);
+
+ /**
+ * Writes an exception to this writer. The exception level is "information".
+ */
+ public void info(Throwable ex);
+
+ /**
+ * Returns true if "config" log messages are enabled. Returns false if
+ * "config" log messages are disabled.
+ */
+ public boolean configEnabled();
+
+ /**
+ * Writes both a message and exception to this writer. The message level is
+ * "config".
+ */
+ public void config(String msg, Throwable ex);
+
+ /**
+ * Writes a message to this writer. The message level is "config".
+ */
+ public void config(String msg);
+
+ /**
+ * Writes an exception to this writer. The exception level is "config".
+ */
+ public void config(Throwable ex);
+
+ /**
+ * Returns true if "fine" log messages are enabled. Returns false if "fine"
+ * log messages are disabled.
+ */
+ public boolean fineEnabled();
+
+ /**
+ * Writes both a message and exception to this writer. The message level is
+ * "fine".
+ */
+ public void fine(String msg, Throwable ex);
+
+ /**
+ * Writes a message to this writer. The message level is "fine".
+ */
+ public void fine(String msg);
+
+ /**
+ * Writes an exception to this writer. The exception level is "fine".
+ */
+ public void fine(Throwable ex);
+
+ /**
+ * Returns true if "finer" log messages are enabled. Returns false if "finer"
+ * log messages are disabled.
+ */
+ public boolean finerEnabled();
+
+ /**
+ * Writes both a message and exception to this writer. The message level is
+ * "finer".
+ */
+ public void finer(String msg, Throwable ex);
+
+ /**
+ * Writes a message to this writer. The message level is "finer".
+ */
+ public void finer(String msg);
+
+ /**
+ * Writes an exception to this writer. The exception level is "finer".
+ */
+ public void finer(Throwable ex);
+
+ /**
+ * Log a method entry.
+ * <p>
+ * The logging is done using the <code>finer</code> level. The string message
+ * will start with <code>"ENTRY"</code> and include the class and method
+ * names.
+ *
+ * @param sourceClass
+ * Name of class that issued the logging request.
+ * @param sourceMethod
+ * Name of the method that issued the logging request.
+ */
+ public void entering(String sourceClass, String sourceMethod);
+
+ /**
+ * Log a method return.
+ * <p>
+ * The logging is done using the <code>finer</code> level. The string message
+ * will start with <code>"RETURN"</code> and include the class and method
+ * names.
+ *
+ * @param sourceClass
+ * Name of class that issued the logging request.
+ * @param sourceMethod
+ * Name of the method that issued the logging request.
+ */
+ public void exiting(String sourceClass, String sourceMethod);
+
+ /**
+ * Log throwing an exception.
+ * <p>
+ * Use to log that a method is terminating by throwing an exception. The
+ * logging is done using the <code>finer</code> level.
+ * <p>
+ * This is a convenience method that could be done instead by calling
+ * {@link #finer(String, Throwable)}. The string message will start with
+ * <code>"THROW"</code> and include the class and method names.
+ *
+ * @param sourceClass
+ * Name of class that issued the logging request.
+ * @param sourceMethod
+ * Name of the method that issued the logging request.
+ * @param thrown
+ * The Throwable that is being thrown.
+ */
+ public void throwing(String sourceClass, String sourceMethod, Throwable thrown);
+
+ /**
+ * Returns true if "finest" log messages are enabled. Returns false if
+ * "finest" log messages are disabled.
+ */
+ public boolean finestEnabled();
+
+ /**
+ * Writes both a message and exception to this writer. The message level is
+ * "finest".
+ */
+ public void finest(String msg, Throwable ex);
+
+ /**
+ * Writes a message to this writer. The message level is "finest".
+ */
+ public void finest(String msg);
+
+ /**
+ * Writes an exception to this writer. The exception level is "finest".
+ */
+ public void finest(Throwable ex);
+
+ /**
+ * Returns a 1.4 logging handler that can be used to direct application output
+ * to this GemFire logger using the standard JDK logger APIs. Each time this
+ * method is called it creates a new instance of a Handler so care should be
+ * taken to not call this method too often.
+ */
+ // public Handler getHandler();
+
+ /**
+ * A mechanism for accessing the abstraction layer used for
+ * internationalization.
+ *
+ * @return LogWriterI18n
+ */
+ // public LogWriterI18n convertToLogWriterI18n();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/MessageFormatter.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/MessageFormatter.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/MessageFormatter.java
new file mode 100644
index 0000000..11fe290
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/MessageFormatter.java
@@ -0,0 +1,102 @@
+/*
+ *
+ * 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.log;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.logging.Formatter;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+
+/**
+ * Class MessageFormatter
+ *
+ * MessageFormatter is the custom formatter class for formatting the log
+ * messages.
+ *
+ * @since GemFire version 7.0.1
+ */
+public class MessageFormatter extends Formatter {
+
+ public MessageFormatter() {
+ super();
+ }
+
+ @Override
+ public String format(LogRecord record) {
+ DateFormat df = new SimpleDateFormat(Repository.get().getPulseConfig()
+ .getLogDatePattern());
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+
+ pw.println();
+ pw.print("[");
+ pw.print(record.getLevel().getName());
+ pw.print(" ");
+ pw.print(df.format(new Date(record.getMillis())));
+ String threadName = Thread.currentThread().getName();
+ if (threadName != null) {
+ pw.print(" ");
+ pw.print(threadName);
+ }
+ pw.print(" tid=0x");
+ pw.print(Long.toHexString(Thread.currentThread().getId()));
+ pw.print("] ");
+ pw.print("(msgTID=");
+ pw.print(record.getThreadID());
+
+ pw.print(" msgSN=");
+ pw.print(record.getSequenceNumber());
+
+ pw.print(") ");
+
+ pw.println("[" + PulseConstants.APP_NAME + "]");
+
+ pw.println("[" + record.getLoggerName() + "]");
+
+ pw.println(record.getMessage());
+
+ if (record.getThrown() != null) {
+ record.getThrown().printStackTrace(pw);
+ }
+ pw.close();
+ try {
+ sw.close();
+ } catch (IOException ignore) {
+ }
+ String result = sw.toString();
+ return result;
+ }
+
+ public String getHead(Handler h) {
+ return super.getHead(h);
+ }
+
+ public String getTail(Handler h) {
+ return super.getTail(h);
+ }
+} // End of Class MessageFormatter
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogWriter.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogWriter.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogWriter.java
new file mode 100644
index 0000000..fe4e88b
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogWriter.java
@@ -0,0 +1,299 @@
+/*
+ *
+ * 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.log;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.logging.FileHandler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.vmware.geode.tools.pulse.internal.data.PulseConfig;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+
+/**
+ * Class PulseLogWriter
+ *
+ * PulseLogWriter is the implementation of LogWriter.
+ *
+ * @since GemFire 7.0.1
+ *
+ */
+public class PulseLogWriter implements LogWriter {
+
+ // Log File handle Object
+ private FileHandler fileHandler;
+
+ // Message Formatter Object
+ private static MessageFormatter messageformatter;
+
+ // pulse log writer
+ private static PulseLogWriter pulseLogger = null;
+
+ // Logger Object
+ private Logger logger;
+
+ private PulseLogWriter() {
+ PulseConfig pulseConfig = Repository.get().getPulseConfig();
+ // Create Logger
+ logger = Logger.getLogger(this.getClass().getName());
+
+ // Set minimum log level to level passed
+ logger.setLevel(pulseConfig.getLogLevel());
+
+ try {
+ // Get file handler to log messages into log file.
+ if (fileHandler == null) {
+ fileHandler = new FileHandler(
+ pulseConfig.getLogFileFullName(),
+ pulseConfig.getLogFileSize(),
+ pulseConfig.getLogFileCount(),
+ pulseConfig.getLogAppend());
+
+ // Log Message Formatter
+ messageformatter = new MessageFormatter();
+ fileHandler.setFormatter(messageformatter);
+ }
+
+ // Add File Handler to logger object
+ logger.addHandler(fileHandler);
+ } catch (SecurityException e) {
+ logger.setUseParentHandlers(true);
+ e.printStackTrace();
+ } catch (IOException e) {
+ logger.setUseParentHandlers(true);
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @param jsonErr
+ * @param errorData
+ */
+ public void logJSONError(Exception jsonErr, Object errorData) {
+
+ // print details of thrown exception and data that couldn't be converted to
+ // json
+ if (this.fineEnabled()) {
+
+ // write errors
+ StringWriter swBuffer = new StringWriter();
+ PrintWriter prtWriter = new PrintWriter(swBuffer);
+ jsonErr.printStackTrace(prtWriter);
+ this.fine("JSON Error Details : " + swBuffer.toString() + "\n");
+
+ this.fine("Erroneous Data : "
+ + ((errorData != null) ? errorData.toString()
+ : "Not Available for output") + "\n");
+ }
+ }
+
+ public static synchronized PulseLogWriter getLogger() {
+ if (null == pulseLogger) {
+ pulseLogger = new PulseLogWriter();
+ }
+ return pulseLogger;
+ }
+
+ @Override
+ public boolean severeEnabled() {
+ return logger.isLoggable(Level.SEVERE);
+ }
+
+ @Override
+ public void severe(String msg, Throwable ex) {
+ logger.logp(Level.SEVERE, "", "", msg, ex);
+ }
+
+ @Override
+ public void severe(String msg) {
+ logger.severe(msg);
+ }
+
+ @Override
+ public void severe(Throwable ex) {
+ logger.logp(Level.SEVERE, "", "", "", ex);
+ }
+
+ /*
+ @Override
+ public boolean errorEnabled() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void error(String msg, Throwable ex) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void error(String msg) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void error(Throwable ex) {
+ // TODO Auto-generated method stub
+
+ }
+ */
+
+ @Override
+ public boolean warningEnabled() {
+ return logger.isLoggable(Level.WARNING);
+ }
+
+ @Override
+ public void warning(String msg, Throwable ex) {
+ logger.logp(Level.WARNING, "", "", msg, ex);
+ }
+
+ @Override
+ public void warning(String msg) {
+ logger.warning(msg);
+ }
+
+ @Override
+ public void warning(Throwable ex) {
+ logger.logp(Level.WARNING, "", "", "", ex);
+ }
+
+ @Override
+ public boolean infoEnabled() {
+ return logger.isLoggable(Level.INFO);
+ }
+
+ @Override
+ public void info(String msg, Throwable ex) {
+ logger.logp(Level.INFO, "", "", msg, ex);
+ }
+
+ @Override
+ public void info(String msg) {
+ logger.info(msg);
+ }
+
+ @Override
+ public void info(Throwable ex) {
+ logger.logp(Level.WARNING, "", "", "", ex);
+ }
+
+ @Override
+ public boolean configEnabled() {
+ return logger.isLoggable(Level.CONFIG);
+ }
+
+ @Override
+ public void config(String msg, Throwable ex) {
+ logger.logp(Level.CONFIG, "", "", msg, ex);
+ }
+
+ @Override
+ public void config(String msg) {
+ logger.config(msg);
+ }
+
+ @Override
+ public void config(Throwable ex) {
+ logger.logp(Level.CONFIG, "", "", "", ex);
+ }
+
+ @Override
+ public boolean fineEnabled() {
+ return logger.isLoggable(Level.FINE);
+ }
+
+ @Override
+ public void fine(String msg, Throwable ex) {
+ logger.logp(Level.FINE, "", "", msg, ex);
+ }
+
+ @Override
+ public void fine(String msg) {
+ logger.fine(msg);
+ }
+
+ @Override
+ public void fine(Throwable ex) {
+ logger.logp(Level.FINE, "", "", "", ex);
+ }
+
+ @Override
+ public boolean finerEnabled() {
+ return logger.isLoggable(Level.FINER);
+ }
+
+ @Override
+ public void finer(String msg, Throwable ex) {
+ logger.logp(Level.FINER, "", "", msg, ex);
+ }
+
+ @Override
+ public void finer(String msg) {
+ logger.finer(msg);
+ }
+
+ @Override
+ public void finer(Throwable ex) {
+ logger.logp(Level.FINER, "", "", "", ex);
+ }
+
+ @Override
+ public void entering(String sourceClass, String sourceMethod) {
+ logger.entering(sourceClass, sourceMethod);
+ }
+
+ @Override
+ public void exiting(String sourceClass, String sourceMethod) {
+ logger.exiting(sourceClass, sourceMethod);
+ }
+
+ @Override
+ public void throwing(String sourceClass, String sourceMethod, Throwable thrown) {
+ logger.throwing(sourceClass, sourceMethod, thrown);
+ }
+
+ @Override
+ public boolean finestEnabled() {
+ return logger.isLoggable(Level.FINEST);
+ }
+
+ @Override
+ public void finest(String msg, Throwable ex) {
+ logger.logp(Level.FINEST, "", "", msg, ex);
+ }
+
+ @Override
+ public void finest(String msg) {
+ logger.finest(msg);
+ }
+
+ @Override
+ public void finest(Throwable ex) {
+ logger.logp(Level.FINEST, "", "", "", ex);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogger.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogger.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogger.java
new file mode 100644
index 0000000..2de81bd
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogger.java
@@ -0,0 +1,142 @@
+/*
+ *
+ * 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.log;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.logging.FileHandler;
+import java.util.logging.Formatter;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+
+/**
+ * Class PulseLogger
+ *
+ * PulseLogger is the custom logger class for Pulse Web Application. It logs
+ * messages to the file in custom format.
+ *
+ * @since GemFire version 7.0.Beta
+ */
+public class PulseLogger {
+
+ // Pulse Application Log File
+ private static final String LOG_FILE_NAME = PulseConstants.PULSE_LOG_FILE_LOCATION
+ + "/" + PulseConstants.PULSE_LOG_FILE;
+
+ // Date pattern to be used in log messages
+ public static final String LOG_MESSAGE_DATE_PATTERN = "dd/MM/yyyy hh:mm:ss.SSS";
+
+ // The log file size is set to 1MB.
+ public static final int FILE_SIZE = 1024 * 1024;
+
+ // The log file count set to 1 files.
+ public static final int FILE_COUNT = 5;
+
+ // Append logs is set to true.
+ public static final boolean FLAG_APPEND = true;
+
+ // Log File handle Object
+ private static FileHandler fileHandler;
+
+ // Message Formatter Object
+ private static MessageFormatter messageformatter;
+
+ // Logger Object
+ private static Logger logger;
+
+ public static Logger getLogger(String name) {
+ // Create Logger
+ logger = Logger.getLogger(name);
+
+ // Set minimum log level to inform
+ logger.setLevel(Level.INFO);
+
+ // Get file handler to log messages into log file.
+ try {
+ // fileHandler = new FileHandler(LOG_FILE_NAME, FILE_SIZE, FILE_COUNT,
+ // FLAG_APPEND);
+ fileHandler = new FileHandler(LOG_FILE_NAME, FLAG_APPEND);
+
+ // Log Message Formatter
+ messageformatter = new MessageFormatter();
+
+ fileHandler.setFormatter(messageformatter);
+
+ // Add File Handler to logger object
+ logger.addHandler(fileHandler);
+
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return logger;
+ }
+
+ /**
+ * Class MessageFormatter
+ *
+ * MessageFormatter is the custom formatter class for formatting the log
+ * messages.
+ *
+ * @since GemFire version 7.0.Beta 2012-09-23
+ */
+ private static class MessageFormatter extends Formatter {
+
+ public MessageFormatter() {
+ super();
+ }
+
+ @Override
+ public String format(LogRecord record) {
+ // Set DateFormat
+ DateFormat df = new SimpleDateFormat(PulseLogger.LOG_MESSAGE_DATE_PATTERN);
+ StringBuilder builder = new StringBuilder(1000);
+
+ // Format Log Message
+ builder.append(df.format(new Date(record.getMillis()))).append(" - ");
+ builder.append("[ " + PulseConstants.APP_NAME + " ] - ");
+ builder.append("[").append(record.getSourceClassName()).append(".");
+ builder.append(record.getSourceMethodName()).append("] - ");
+ builder.append("[").append(record.getLevel()).append("] - ");
+ builder.append(formatMessage(record));
+ builder.append(System.getProperty("line.separator"));
+
+ return builder.toString();
+ }
+
+ public String getHead(Handler h) {
+ return super.getHead(h);
+ }
+
+ public String getTail(Handler h) {
+ return super.getTail(h);
+ }
+ } // End of Class MessageFormatter
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
new file mode 100644
index 0000000..6506667
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
@@ -0,0 +1,91 @@
+/*
+ * 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.security;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
+
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.SpringSecurityCoreVersion;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+
+/**
+ * Spring security authentication object for GemFire
+ * <p>
+ * To use GemFire Integrated Security Model set Spring Application Profile to pulse.authentication.gemfire
+ * <p>
+ * 1. Authentication :
+ * 1.a GemFire profile creates JMX connection with given credentials at the login time.
+ * 1.b Successful connect is considered as Successful Authentication for Pulse WebApp
+ * <p>
+ * <p>
+ * 2. Authorization :
+ * 2.a Using newly created authenticated connection AccessControlMXBean is called to get authentication
+ * levels. See @See {@link #populateAuthorities(JMXConnector)}. This sets Spring Security Authorities
+ * 2.b DataBrowser end-points are required to be authorized against Spring Granted Authority
+ * @since GemFire version 9.0
+ */
+public class GemFireAuthentication extends UsernamePasswordAuthenticationToken {
+
+ private final static PulseLogWriter logger = PulseLogWriter.getLogger();
+
+ private JMXConnector jmxc = null;
+
+ public GemFireAuthentication(Object principal, Object credentials, Collection<GrantedAuthority> list, JMXConnector jmxc) {
+ super(principal, credentials, list);
+ this.jmxc = jmxc;
+ }
+
+ private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
+
+ public static ArrayList<GrantedAuthority> populateAuthorities(JMXConnector jmxc) {
+ ObjectName name;
+ ArrayList<GrantedAuthority> authorities = new ArrayList<>();
+ try {
+ name = new ObjectName(PulseConstants.OBJECT_NAME_ACCESSCONTROL_MBEAN);
+ MBeanServerConnection mbeanServer = jmxc.getMBeanServerConnection();
+
+ for (String role : PulseConstants.PULSE_ROLES) {
+ Object[] params = role.split(":");
+ String[] signature = new String[] { String.class.getCanonicalName(), String.class.getCanonicalName() };
+ boolean result = (Boolean) mbeanServer.invoke(name, "authorize", params, signature);
+ if (result) {
+ authorities.add(new SimpleGrantedAuthority(role));
+ }
+ }
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+
+ return authorities;
+
+ }
+
+ public JMXConnector getJmxc() {
+ return jmxc;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
new file mode 100644
index 0000000..cd37aea
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
@@ -0,0 +1,80 @@
+/*
+ * 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.security;
+
+import java.util.Collection;
+import javax.management.remote.JMXConnector;
+
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+
+import org.springframework.security.authentication.AuthenticationProvider;
+import org.springframework.security.authentication.AuthenticationServiceException;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.core.GrantedAuthority;
+
+/**
+ * Spring security AuthenticationProvider for GemFire. It connects to gemfire manager using given credentials.
+ * Successful connect is treated as successful authentication and web user is authenticated
+ * @since GemFire version 9.0
+ */
+public class GemFireAuthenticationProvider implements AuthenticationProvider {
+
+ private final static PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+
+ public GemFireAuthenticationProvider() {
+ System.out.println("here");
+ }
+
+ @Override
+ public Authentication authenticate(Authentication authentication) throws AuthenticationException {
+
+ if (authentication instanceof GemFireAuthentication) {
+ GemFireAuthentication gemAuth = (GemFireAuthentication) authentication;
+ LOGGER.fine("GemAuthentication is connected? = " + gemAuth.getJmxc());
+ if (gemAuth.getJmxc() != null && gemAuth.isAuthenticated()) return gemAuth;
+ }
+
+ String name = authentication.getName();
+ String password = authentication.getCredentials().toString();
+
+ try {
+ LOGGER.fine("Connecting to GemFire with user=" + name);
+ JMXConnector jmxc = Repository.get().getCluster(name, password).connectToGemFire();
+ if (jmxc != null) {
+ Collection<GrantedAuthority> list = GemFireAuthentication.populateAuthorities(jmxc);
+ GemFireAuthentication auth = new GemFireAuthentication(authentication.getPrincipal(),
+ authentication.getCredentials(), list, jmxc);
+ LOGGER.fine("For user " + name + " authList=" + list);
+ return auth;
+ } else {
+ throw new AuthenticationServiceException("JMX Connection unavailable");
+ }
+ } catch (Exception e) {
+ throw new BadCredentialsException("Error connecting to GemFire JMX Server", e);
+ }
+ }
+
+ @Override
+ public boolean supports(Class<?> authentication) {
+ return authentication.equals(UsernamePasswordAuthenticationToken.class);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
new file mode 100644
index 0000000..5056ce2
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
@@ -0,0 +1,55 @@
+/*
+ * 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.security;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+
+import org.springframework.security.core.Authentication;
+import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
+import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler;
+
+/**
+ * Handler is used to close jmx connection maintained at user-level
+ *
+ */
+public class LogoutHandler extends SimpleUrlLogoutSuccessHandler implements LogoutSuccessHandler {
+
+ public LogoutHandler(String defaultTargetURL) {
+ this.setDefaultTargetUrl(defaultTargetURL);
+ }
+
+ public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
+ throws IOException, ServletException {
+ PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+ LOGGER.fine("Invoked #LogoutHandler ...");
+ if (Repository.get().isUseGemFireCredentials()) {
+ GemFireAuthentication gemauthentication = (GemFireAuthentication) authentication;
+ if(gemauthentication!=null) {
+ gemauthentication.getJmxc().close();
+ LOGGER.info("#LogoutHandler : Closing GemFireAuthentication JMX Connection...");
+ }
+ }
+ super.onLogoutSuccess(request, response, authentication);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDetailsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDetailsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDetailsService.java
new file mode 100644
index 0000000..8b5e409
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDetailsService.java
@@ -0,0 +1,104 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.DecimalFormat;
+
+/**
+ * Class ClusterDetailsService
+ *
+ * This service class has implementation for providing cluster's basic
+ * statistical data.
+ *
+ * @since GemFire version 7.5
+ */
+
+@Component
+@Service("ClusterDetails")
+@Scope("singleton")
+public class ClusterDetailsService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ String userName = request.getUserPrincipal().getName();
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ Cluster.Alert[] alertsList = cluster.getAlertsList();
+ int severeAlertCount = 0;
+ int errorAlertCount = 0;
+ int warningAlertCount = 0;
+ int infoAlertCount = 0;
+
+ for (Cluster.Alert alertObj : alertsList) {
+ if (alertObj.getSeverity() == Cluster.Alert.SEVERE) {
+ severeAlertCount++;
+ } else if (alertObj.getSeverity() == Cluster.Alert.ERROR) {
+ errorAlertCount++;
+ } else if (alertObj.getSeverity() == Cluster.Alert.WARNING) {
+ warningAlertCount++;
+ } else {
+ infoAlertCount++;
+ }
+ }
+ // getting basic details of Cluster
+ responseJSON.put("clusterName", cluster.getServerName());
+ responseJSON.put("severeAlertCount", severeAlertCount);
+ responseJSON.put("errorAlertCount", errorAlertCount);
+ responseJSON.put("warningAlertCount", warningAlertCount);
+ responseJSON.put("infoAlertCount", infoAlertCount);
+
+ responseJSON.put("totalMembers", cluster.getMemberCount());
+ responseJSON.put("servers", cluster.getServerCount());
+ responseJSON.put("clients", cluster.getClientConnectionCount());
+ responseJSON.put("locators", cluster.getLocatorCount());
+ responseJSON.put("totalRegions", cluster.getTotalRegionCount());
+ Long heapSize = cluster.getTotalHeapSize();
+
+ DecimalFormat df2 = new DecimalFormat(
+ PulseConstants.DECIMAL_FORMAT_PATTERN);
+ Double heapS = heapSize.doubleValue() / 1024;
+ responseJSON.put("totalHeap", Double.valueOf(df2.format(heapS)));
+ responseJSON.put("functions", cluster.getRunningFunctionCount());
+ responseJSON.put("uniqueCQs", cluster.getRegisteredCQCount());
+ responseJSON.put("subscriptions", cluster.getSubscriptionCount());
+ responseJSON.put("txnCommitted", cluster.getTxnCommittedCount());
+ responseJSON.put("txnRollback", cluster.getTxnRollbackCount());
+ responseJSON.put("userName", userName);
+
+ return responseJSON;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDiskThroughputService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDiskThroughputService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDiskThroughputService.java
new file mode 100644
index 0000000..11247bc
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDiskThroughputService.java
@@ -0,0 +1,71 @@
+/*
+ *
+ * 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.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Class ClusterDiskThroughput This class contains implementations for getting
+ * cluster's current disk throughput details and its trend over time
+ *
+ * @since GemFire version 7.0.Beta
+ */
+
+@Component
+@Service("ClusterDiskThroughput")
+@Scope("singleton")
+public class ClusterDiskThroughputService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ // cluster's Throughout Writes trend added to json response object
+ // CircularFifoBuffer throughoutWritesTrend =
+ // cluster.getThroughoutWritesTrend();
+ double currentThroughputWrites = cluster.getDiskWritesRate();
+ double currentThroughputReads = cluster.getDiskReadsRate();
+
+ responseJSON.put("currentThroughputReads", currentThroughputReads);
+ responseJSON.put("throughputReads",
+ mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_THROUGHPUT_READS)));
+
+ responseJSON.put("currentThroughputWrites", currentThroughputWrites);
+ responseJSON.put("throughputWrites",
+ mapper.valueToTree( cluster.getStatisticTrend(Cluster.CLUSTER_STAT_THROUGHPUT_WRITES)));
+
+ // Send json response
+ return responseJSON;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterGCPausesService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterGCPausesService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterGCPausesService.java
new file mode 100644
index 0000000..52ba79c
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterGCPausesService.java
@@ -0,0 +1,69 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Class ClusterGCPausesService
+ *
+ * This class contains implementations of getting Cluster's GC Pauses (JVM
+ * Pauses) Details and its trend over the time.
+ *
+ * @since GemFire version 7.5
+ */
+
+@Component
+@Service("ClusterJVMPauses")
+@Scope("singleton")
+public class ClusterGCPausesService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+ // cluster's GC Pauses trend added to json response object
+
+ ArrayNode pauses = mapper.createArrayNode();
+ for (Object obj : cluster.getStatisticTrend(Cluster.CLUSTER_STAT_GARBAGE_COLLECTION)) {
+ if (obj instanceof Number) {
+ pauses.add(((Number) obj).longValue());
+ }
+ }
+ responseJSON.put("currentGCPauses", cluster.getGarbageCollectionCount());
+ responseJSON.put("gCPausesTrend", pauses);
+ // Send json response
+ return responseJSON;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterKeyStatisticsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterKeyStatisticsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterKeyStatisticsService.java
new file mode 100644
index 0000000..8c15ccc
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterKeyStatisticsService.java
@@ -0,0 +1,69 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Class ClusterKeyStatisticsService
+ *
+ * This class contains implementations of getting Cluster's current Reads,
+ * Writes and queries details and their trends over the time.
+ *
+ * @since GemFire version 7.5
+ */
+
+@Component
+@Service("ClusterKeyStatistics")
+@Scope("singleton")
+public class ClusterKeyStatisticsService implements PulseService {
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public ObjectNode execute(final HttpServletRequest request) throws Exception {
+
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ responseJSON.put("writePerSecTrend",
+ mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_WRITES_PER_SECOND)));
+
+ responseJSON.put("readPerSecTrend",
+ mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_READ_PER_SECOND)));
+
+ responseJSON.put("queriesPerSecTrend",
+ mapper.valueToTree(cluster.getStatisticTrend(Cluster.CLUSTER_STAT_QUERIES_PER_SECOND)));
+
+ // Send json response
+ return responseJSON;
+
+ }
+}
[26/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONObject.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONObject.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONObject.java
deleted file mode 100644
index d04b1f4..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONObject.java
+++ /dev/null
@@ -1,1585 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.json;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-/**
- * A JSONObject is an unordered collection of name/value pairs. Its external
- * form is a string wrapped in curly braces with colons between the names and
- * values, and commas between the values and names. The internal form is an
- * object having <code>get</code> and <code>opt</code> methods for accessing the
- * values by name, and <code>put</code> methods for adding or replacing values
- * by name. The values can be any of these types: <code>Boolean</code>,
- * <code>JSONArray</code>, <code>JSONObject</code>, <code>Number</code>,
- * <code>String</code>, or the <code>JSONObject.NULL</code> object. A JSONObject
- * constructor can be used to convert an external form JSON text into an
- * internal form whose values can be retrieved with the <code>get</code> and
- * <code>opt</code> methods, or to convert values into a JSON text using the
- * <code>put</code> and <code>toString</code> methods. A <code>get</code> method
- * returns a value if one can be found, and throws an exception if one cannot be
- * found. An <code>opt</code> method returns a default value instead of throwing
- * an exception, and so is useful for obtaining optional values.
- * <p>
- * The generic <code>get()</code> and <code>opt()</code> methods return an
- * object, which you can cast or query for type. There are also typed
- * <code>get</code> and <code>opt</code> methods that do type checking and type
- * coercion for you. The opt methods differ from the get methods in that they do
- * not throw. Instead, they return a specified value, such as null.
- * <p>
- * The <code>put</code> methods add or replace values in an object. For example,
- *
- * <pre>
- * myString = new JSONObject().put("JSON", "Hello, World!").toString();
- * </pre>
- *
- * produces the string <code>{"JSON": "Hello, World"}</code>.
- * <p>
- * The texts produced by the <code>toString</code> methods strictly conform to
- * the JSON syntax rules. The constructors are more forgiving in the texts they
- * will accept:
- * <ul>
- * <li>An extra <code>,</code> <small>(comma)</small> may appear just
- * before the closing brace.</li>
- * <li>Strings may be quoted with <code>'</code> <small>(single
- * quote)</small>.</li>
- * <li>Strings do not need to be quoted at all if they do not begin with a quote
- * or single quote, and if they do not contain leading or trailing spaces, and
- * if they do not contain any of these characters:
- * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers and
- * if they are not the reserved words <code>true</code>, <code>false</code>, or
- * <code>null</code>.</li>
- * <li>Keys can be followed by <code>=</code> or <code>=></code> as well as by
- * <code>:</code>.</li>
- * <li>Values can be followed by <code>;</code> <small>(semicolon)</small> as
- * well as by <code>,</code> <small>(comma)</small>.</li>
- * </ul>
- *
- * @author JSON.org
- * @version 2012-07-02
- */
-public class JSONObject {
-
- /**
- * JSONObject.NULL is equivalent to the value that JavaScript calls null,
- * whilst Java's null is equivalent to the value that JavaScript calls
- * undefined.
- */
- private static final class Null {
-
- /**
- * There is only intended to be a single instance of the NULL object,
- * so the clone method returns itself.
- * @return NULL.
- */
- protected final Object clone() {
- return this;
- }
-
- /**
- * A Null object is equal to the null value and to itself.
- * @param object An object to test for nullness.
- * @return true if the object parameter is the JSONObject.NULL object
- * or null.
- */
- public boolean equals(Object object) {
- return object == null || object == this;
- }
-
- /**
- * Get the "null" string value.
- * @return The string "null".
- */
- public String toString() {
- return "null";
- }
- }
-
-
- /**
- * The map where the JSONObject's properties are kept.
- */
- private final Map map;
-
-
- /**
- * It is sometimes more convenient and less ambiguous to have a
- * <code>NULL</code> object than to use Java's <code>null</code> value.
- * <code>JSONObject.NULL.equals(null)</code> returns <code>true</code>.
- * <code>JSONObject.NULL.toString()</code> returns <code>"null"</code>.
- */
- public static final Object NULL = new Null();
-
-
- /**
- * Construct an empty JSONObject.
- */
- public JSONObject() {
- this.map = new HashMap();
- }
-
-
- /**
- * Construct a JSONObject from a subset of another JSONObject.
- * An array of strings is used to identify the keys that should be copied.
- * Missing keys are ignored.
- * @param jo A JSONObject.
- * @param names An array of strings.
- */
- public JSONObject(JSONObject jo, String[] names) {
- this();
- for (int i = 0; i < names.length; i += 1) {
- try {
- this.putOnce(names[i], jo.opt(names[i]));
- } catch (Exception ignore) {
- }
- }
- }
-
-
- /**
- * Construct a JSONObject from a JSONTokener.
- * @param x A JSONTokener object containing the source string.
- * @throws JSONException If there is a syntax error in the source string
- * or a duplicated key.
- */
- public JSONObject(JSONTokener x) throws JSONException {
- this();
- char c;
- String key;
-
- if (x.nextClean() != '{') {
- throw x.syntaxError("A JSONObject text must begin with '{'");
- }
- for (;;) {
- c = x.nextClean();
- switch (c) {
- case 0:
- throw x.syntaxError("A JSONObject text must end with '}'");
- case '}':
- return;
- default:
- x.back();
- key = x.nextValue().toString();
- }
-
-// The key is followed by ':'. We will also tolerate '=' or '=>'.
-
- c = x.nextClean();
- if (c == '=') {
- if (x.next() != '>') {
- x.back();
- }
- } else if (c != ':') {
- throw x.syntaxError("Expected a ':' after a key");
- }
- this.putOnce(key, x.nextValue());
-
-// Pairs are separated by ','. We will also tolerate ';'.
-
- switch (x.nextClean()) {
- case ';':
- case ',':
- if (x.nextClean() == '}') {
- return;
- }
- x.back();
- break;
- case '}':
- return;
- default:
- throw x.syntaxError("Expected a ',' or '}'");
- }
- }
- }
-
-
- /**
- * Construct a JSONObject from a Map.
- *
- * @param map A map object that can be used to initialize the contents of
- * the JSONObject.
- */
- public JSONObject(Map map) {
- this.map = new HashMap();
- if (map != null) {
- Iterator i = map.entrySet().iterator();
- while (i.hasNext()) {
- Map.Entry e = (Map.Entry)i.next();
- Object value = e.getValue();
- if (value != null) {
- this.map.put(e.getKey(), wrap(value));
- }
- }
- }
- }
-
-
- /**
- * Construct a JSONObject from an Object using bean getters.
- * It reflects on all of the public methods of the object.
- * For each of the methods with no parameters and a name starting
- * with <code>"get"</code> or <code>"is"</code> followed by an uppercase letter,
- * the method is invoked, and a key and the value returned from the getter method
- * are put into the new JSONObject.
- *
- * The key is formed by removing the <code>"get"</code> or <code>"is"</code> prefix.
- * If the second remaining character is not upper case, then the first
- * character is converted to lower case.
- *
- * For example, if an object has a method named <code>"getName"</code>, and
- * if the result of calling <code>object.getName()</code> is <code>"Larry Fine"</code>,
- * then the JSONObject will contain <code>"name": "Larry Fine"</code>.
- *
- * @param bean An object that has getter methods that should be used
- * to make a JSONObject.
- */
- public JSONObject(Object bean) {
- this();
- this.populateMap(bean);
- }
-
-
- /**
- * Construct a JSONObject from an Object, using reflection to find the
- * public members. The resulting JSONObject's keys will be the strings
- * from the names array, and the values will be the field values associated
- * with those keys in the object. If a key is not found or not visible,
- * then it will not be copied into the new JSONObject.
- * @param object An object that has fields that should be used to make a
- * JSONObject.
- * @param names An array of strings, the names of the fields to be obtained
- * from the object.
- */
- public JSONObject(Object object, String names[]) {
- this();
- Class c = object.getClass();
- for (int i = 0; i < names.length; i += 1) {
- String name = names[i];
- try {
- this.putOpt(name, c.getField(name).get(object));
- } catch (Exception ignore) {
- }
- }
- }
-
-
- /**
- * Construct a JSONObject from a source JSON text string.
- * This is the most commonly used JSONObject constructor.
- * @param source A string beginning
- * with <code>{</code> <small>(left brace)</small> and ending
- * with <code>}</code> <small>(right brace)</small>.
- * @exception JSONException If there is a syntax error in the source
- * string or a duplicated key.
- */
- public JSONObject(String source) throws JSONException {
- this(new JSONTokener(source));
- }
-
-
- /**
- * Construct a JSONObject from a ResourceBundle.
- * @param baseName The ResourceBundle base name.
- * @param locale The Locale to load the ResourceBundle for.
- * @throws JSONException If any JSONExceptions are detected.
- */
- public JSONObject(String baseName, Locale locale) throws JSONException {
- this();
- ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale,
- Thread.currentThread().getContextClassLoader());
-
-// Iterate through the keys in the bundle.
-
- Enumeration keys = bundle.getKeys();
- while (keys.hasMoreElements()) {
- Object key = keys.nextElement();
- if (key instanceof String) {
-
-// Go through the path, ensuring that there is a nested JSONObject for each
-// segment except the last. Add the value using the last segment's name into
-// the deepest nested JSONObject.
-
- String[] path = ((String)key).split("\\.");
- int last = path.length - 1;
- JSONObject target = this;
- for (int i = 0; i < last; i += 1) {
- String segment = path[i];
- JSONObject nextTarget = target.optJSONObject(segment);
- if (nextTarget == null) {
- nextTarget = new JSONObject();
- target.put(segment, nextTarget);
- }
- target = nextTarget;
- }
- target.put(path[last], bundle.getString((String)key));
- }
- }
- }
-
-
- /**
- * Accumulate values under a key. It is similar to the put method except
- * that if there is already an object stored under the key then a
- * JSONArray is stored under the key to hold all of the accumulated values.
- * If there is already a JSONArray, then the new value is appended to it.
- * In contrast, the put method replaces the previous value.
- *
- * If only one value is accumulated that is not a JSONArray, then the
- * result will be the same as using put. But if multiple values are
- * accumulated, then the result will be like append.
- * @param key A key string.
- * @param value An object to be accumulated under the key.
- * @return this.
- * @throws JSONException If the value is an invalid number
- * or if the key is null.
- */
- public JSONObject accumulate(
- String key,
- Object value
- ) throws JSONException {
- testValidity(value);
- Object object = this.opt(key);
- if (object == null) {
- this.put(key, value instanceof JSONArray
- ? new JSONArray().put(value)
- : value);
- } else if (object instanceof JSONArray) {
- ((JSONArray)object).put(value);
- } else {
- this.put(key, new JSONArray().put(object).put(value));
- }
- return this;
- }
-
-
- /**
- * Append values to the array under a key. If the key does not exist in the
- * JSONObject, then the key is put in the JSONObject with its value being a
- * JSONArray containing the value parameter. If the key was already
- * associated with a JSONArray, then the value parameter is appended to it.
- * @param key A key string.
- * @param value An object to be accumulated under the key.
- * @return this.
- * @throws JSONException If the key is null or if the current value
- * associated with the key is not a JSONArray.
- */
- public JSONObject append(String key, Object value) throws JSONException {
- testValidity(value);
- Object object = this.opt(key);
- if (object == null) {
- this.put(key, new JSONArray().put(value));
- } else if (object instanceof JSONArray) {
- this.put(key, ((JSONArray)object).put(value));
- } else {
- throw new JSONException("JSONObject[" + key +
- "] is not a JSONArray.");
- }
- return this;
- }
-
-
- /**
- * Produce a string from a double. The string "null" will be returned if
- * the number is not finite.
- * @param d A double.
- * @return A String.
- */
- public static String doubleToString(double d) {
- if (Double.isInfinite(d) || Double.isNaN(d)) {
- return "null";
- }
-
-// Shave off trailing zeros and decimal point, if possible.
-
- String string = Double.toString(d);
- if (string.indexOf('.') > 0 && string.indexOf('e') < 0 &&
- string.indexOf('E') < 0) {
- while (string.endsWith("0")) {
- string = string.substring(0, string.length() - 1);
- }
- if (string.endsWith(".")) {
- string = string.substring(0, string.length() - 1);
- }
- }
- return string;
- }
-
-
- /**
- * Get the value object associated with a key.
- *
- * @param key A key string.
- * @return The object associated with the key.
- * @throws JSONException if the key is not found.
- */
- public Object get(String key) throws JSONException {
- if (key == null) {
- throw new JSONException("Null key.");
- }
- Object object = this.opt(key);
- if (object == null) {
- throw new JSONException("JSONObject[" + quote(key) +
- "] not found.");
- }
- return object;
- }
-
-
- /**
- * Get the boolean value associated with a key.
- *
- * @param key A key string.
- * @return The truth.
- * @throws JSONException
- * if the value is not a Boolean or the String "true" or "false".
- */
- public boolean getBoolean(String key) throws JSONException {
- Object object = this.get(key);
- if (object.equals(Boolean.FALSE) ||
- (object instanceof String &&
- ((String)object).equalsIgnoreCase("false"))) {
- return false;
- } else if (object.equals(Boolean.TRUE) ||
- (object instanceof String &&
- ((String)object).equalsIgnoreCase("true"))) {
- return true;
- }
- throw new JSONException("JSONObject[" + quote(key) +
- "] is not a Boolean.");
- }
-
-
- /**
- * Get the double value associated with a key.
- * @param key A key string.
- * @return The numeric value.
- * @throws JSONException if the key is not found or
- * if the value is not a Number object and cannot be converted to a number.
- */
- public double getDouble(String key) throws JSONException {
- Object object = this.get(key);
- try {
- return object instanceof Number
- ? ((Number)object).doubleValue()
- : Double.parseDouble((String)object);
- } catch (Exception e) {
- throw new JSONException("JSONObject[" + quote(key) +
- "] is not a number.");
- }
- }
-
-
- /**
- * Get the int value associated with a key.
- *
- * @param key A key string.
- * @return The integer value.
- * @throws JSONException if the key is not found or if the value cannot
- * be converted to an integer.
- */
- public int getInt(String key) throws JSONException {
- Object object = this.get(key);
- try {
- return object instanceof Number
- ? ((Number)object).intValue()
- : Integer.parseInt((String)object);
- } catch (Exception e) {
- throw new JSONException("JSONObject[" + quote(key) +
- "] is not an int.");
- }
- }
-
-
- /**
- * Get the JSONArray value associated with a key.
- *
- * @param key A key string.
- * @return A JSONArray which is the value.
- * @throws JSONException if the key is not found or
- * if the value is not a JSONArray.
- */
- public JSONArray getJSONArray(String key) throws JSONException {
- Object object = this.get(key);
- if (object instanceof JSONArray) {
- return (JSONArray)object;
- }
- throw new JSONException("JSONObject[" + quote(key) +
- "] is not a JSONArray.");
- }
-
-
- /**
- * Get the JSONObject value associated with a key.
- *
- * @param key A key string.
- * @return A JSONObject which is the value.
- * @throws JSONException if the key is not found or
- * if the value is not a JSONObject.
- */
- public JSONObject getJSONObject(String key) throws JSONException {
- Object object = this.get(key);
- if (object instanceof JSONObject) {
- return (JSONObject)object;
- }
- throw new JSONException("JSONObject[" + quote(key) +
- "] is not a JSONObject.");
- }
-
-
- /**
- * Get the long value associated with a key.
- *
- * @param key A key string.
- * @return The long value.
- * @throws JSONException if the key is not found or if the value cannot
- * be converted to a long.
- */
- public long getLong(String key) throws JSONException {
- Object object = this.get(key);
- try {
- return object instanceof Number
- ? ((Number)object).longValue()
- : Long.parseLong((String)object);
- } catch (Exception e) {
- throw new JSONException("JSONObject[" + quote(key) +
- "] is not a long.");
- }
- }
-
-
- /**
- * Get an array of field names from a JSONObject.
- *
- * @return An array of field names, or null if there are no names.
- */
- public static String[] getNames(JSONObject jo) {
- int length = jo.length();
- if (length == 0) {
- return null;
- }
- Iterator iterator = jo.keys();
- String[] names = new String[length];
- int i = 0;
- while (iterator.hasNext()) {
- names[i] = (String)iterator.next();
- i += 1;
- }
- return names;
- }
-
-
- /**
- * Get an array of field names from an Object.
- *
- * @return An array of field names, or null if there are no names.
- */
- public static String[] getNames(Object object) {
- if (object == null) {
- return null;
- }
- Class klass = object.getClass();
- Field[] fields = klass.getFields();
- int length = fields.length;
- if (length == 0) {
- return null;
- }
- String[] names = new String[length];
- for (int i = 0; i < length; i += 1) {
- names[i] = fields[i].getName();
- }
- return names;
- }
-
-
- /**
- * Get the string associated with a key.
- *
- * @param key A key string.
- * @return A string which is the value.
- * @throws JSONException if there is no string value for the key.
- */
- public String getString(String key) throws JSONException {
- Object object = this.get(key);
- if (object instanceof String) {
- return (String)object;
- }
- throw new JSONException("JSONObject[" + quote(key) +
- "] not a string.");
- }
-
-
- /**
- * Determine if the JSONObject contains a specific key.
- * @param key A key string.
- * @return true if the key exists in the JSONObject.
- */
- public boolean has(String key) {
- return this.map.containsKey(key);
- }
-
-
- /**
- * Increment a property of a JSONObject. If there is no such property,
- * create one with a value of 1. If there is such a property, and if
- * it is an Integer, Long, Double, or Float, then add one to it.
- * @param key A key string.
- * @return this.
- * @throws JSONException If there is already a property with this name
- * that is not an Integer, Long, Double, or Float.
- */
- public JSONObject increment(String key) throws JSONException {
- Object value = this.opt(key);
- if (value == null) {
- this.put(key, 1);
- } else if (value instanceof Integer) {
- this.put(key, ((Integer)value).intValue() + 1);
- } else if (value instanceof Long) {
- this.put(key, ((Long)value).longValue() + 1);
- } else if (value instanceof Double) {
- this.put(key, ((Double)value).doubleValue() + 1);
- } else if (value instanceof Float) {
- this.put(key, ((Float)value).floatValue() + 1);
- } else {
- throw new JSONException("Unable to increment [" + quote(key) + "].");
- }
- return this;
- }
-
-
- /**
- * Determine if the value associated with the key is null or if there is
- * no value.
- * @param key A key string.
- * @return true if there is no value associated with the key or if
- * the value is the JSONObject.NULL object.
- */
- public boolean isNull(String key) {
- return JSONObject.NULL.equals(this.opt(key));
- }
-
-
- /**
- * Get an enumeration of the keys of the JSONObject.
- *
- * @return An iterator of the keys.
- */
- public Iterator keys() {
- return this.map.keySet().iterator();
- }
-
-
- /**
- * Get the number of keys stored in the JSONObject.
- *
- * @return The number of keys in the JSONObject.
- */
- public int length() {
- return this.map.size();
- }
-
-
- /**
- * Produce a JSONArray containing the names of the elements of this
- * JSONObject.
- * @return A JSONArray containing the key strings, or null if the JSONObject
- * is empty.
- */
- public JSONArray names() {
- JSONArray ja = new JSONArray();
- Iterator keys = this.keys();
- while (keys.hasNext()) {
- ja.put(keys.next());
- }
- return ja.length() == 0 ? null : ja;
- }
-
- /**
- * Produce a string from a Number.
- * @param number A Number
- * @return A String.
- * @throws JSONException If n is a non-finite number.
- */
- public static String numberToString(Number number)
- throws JSONException {
- if (number == null) {
- throw new JSONException("Null pointer");
- }
- testValidity(number);
-
-// Shave off trailing zeros and decimal point, if possible.
-
- String string = number.toString();
- if (string.indexOf('.') > 0 && string.indexOf('e') < 0 &&
- string.indexOf('E') < 0) {
- while (string.endsWith("0")) {
- string = string.substring(0, string.length() - 1);
- }
- if (string.endsWith(".")) {
- string = string.substring(0, string.length() - 1);
- }
- }
- return string;
- }
-
-
- /**
- * Get an optional value associated with a key.
- * @param key A key string.
- * @return An object which is the value, or null if there is no value.
- */
- public Object opt(String key) {
- return key == null ? null : this.map.get(key);
- }
-
-
- /**
- * Get an optional boolean associated with a key.
- * It returns false if there is no such key, or if the value is not
- * Boolean.TRUE or the String "true".
- *
- * @param key A key string.
- * @return The truth.
- */
- public boolean optBoolean(String key) {
- return this.optBoolean(key, false);
- }
-
-
- /**
- * Get an optional boolean associated with a key.
- * It returns the defaultValue if there is no such key, or if it is not
- * a Boolean or the String "true" or "false" (case insensitive).
- *
- * @param key A key string.
- * @param defaultValue The default.
- * @return The truth.
- */
- public boolean optBoolean(String key, boolean defaultValue) {
- try {
- return this.getBoolean(key);
- } catch (Exception e) {
- return defaultValue;
- }
- }
-
-
- /**
- * Get an optional double associated with a key,
- * or NaN if there is no such key or if its value is not a number.
- * If the value is a string, an attempt will be made to evaluate it as
- * a number.
- *
- * @param key A string which is the key.
- * @return An object which is the value.
- */
- public double optDouble(String key) {
- return this.optDouble(key, Double.NaN);
- }
-
-
- /**
- * Get an optional double associated with a key, or the
- * defaultValue if there is no such key or if its value is not a number.
- * If the value is a string, an attempt will be made to evaluate it as
- * a number.
- *
- * @param key A key string.
- * @param defaultValue The default.
- * @return An object which is the value.
- */
- public double optDouble(String key, double defaultValue) {
- try {
- return this.getDouble(key);
- } catch (Exception e) {
- return defaultValue;
- }
- }
-
-
- /**
- * Get an optional int value associated with a key,
- * or zero if there is no such key or if the value is not a number.
- * If the value is a string, an attempt will be made to evaluate it as
- * a number.
- *
- * @param key A key string.
- * @return An object which is the value.
- */
- public int optInt(String key) {
- return this.optInt(key, 0);
- }
-
-
- /**
- * Get an optional int value associated with a key,
- * or the default if there is no such key or if the value is not a number.
- * If the value is a string, an attempt will be made to evaluate it as
- * a number.
- *
- * @param key A key string.
- * @param defaultValue The default.
- * @return An object which is the value.
- */
- public int optInt(String key, int defaultValue) {
- try {
- return this.getInt(key);
- } catch (Exception e) {
- return defaultValue;
- }
- }
-
-
- /**
- * Get an optional JSONArray associated with a key.
- * It returns null if there is no such key, or if its value is not a
- * JSONArray.
- *
- * @param key A key string.
- * @return A JSONArray which is the value.
- */
- public JSONArray optJSONArray(String key) {
- Object o = this.opt(key);
- return o instanceof JSONArray ? (JSONArray)o : null;
- }
-
-
- /**
- * Get an optional JSONObject associated with a key.
- * It returns null if there is no such key, or if its value is not a
- * JSONObject.
- *
- * @param key A key string.
- * @return A JSONObject which is the value.
- */
- public JSONObject optJSONObject(String key) {
- Object object = this.opt(key);
- return object instanceof JSONObject ? (JSONObject)object : null;
- }
-
-
- /**
- * Get an optional long value associated with a key,
- * or zero if there is no such key or if the value is not a number.
- * If the value is a string, an attempt will be made to evaluate it as
- * a number.
- *
- * @param key A key string.
- * @return An object which is the value.
- */
- public long optLong(String key) {
- return this.optLong(key, 0);
- }
-
-
- /**
- * Get an optional long value associated with a key,
- * or the default if there is no such key or if the value is not a number.
- * If the value is a string, an attempt will be made to evaluate it as
- * a number.
- *
- * @param key A key string.
- * @param defaultValue The default.
- * @return An object which is the value.
- */
- public long optLong(String key, long defaultValue) {
- try {
- return this.getLong(key);
- } catch (Exception e) {
- return defaultValue;
- }
- }
-
-
- /**
- * Get an optional string associated with a key.
- * It returns an empty string if there is no such key. If the value is not
- * a string and is not null, then it is converted to a string.
- *
- * @param key A key string.
- * @return A string which is the value.
- */
- public String optString(String key) {
- return this.optString(key, "");
- }
-
-
- /**
- * Get an optional string associated with a key.
- * It returns the defaultValue if there is no such key.
- *
- * @param key A key string.
- * @param defaultValue The default.
- * @return A string which is the value.
- */
- public String optString(String key, String defaultValue) {
- Object object = this.opt(key);
- return NULL.equals(object) ? defaultValue : object.toString();
- }
-
-
- private void populateMap(Object bean) {
- Class klass = bean.getClass();
-
-// If klass is a System class then set includeSuperClass to false.
-
- boolean includeSuperClass = klass.getClassLoader() != null;
-
- Method[] methods = includeSuperClass
- ? klass.getMethods()
- : klass.getDeclaredMethods();
- for (int i = 0; i < methods.length; i += 1) {
- try {
- Method method = methods[i];
- if (Modifier.isPublic(method.getModifiers())) {
- String name = method.getName();
- String key = "";
- if (name.startsWith("get")) {
- if ("getClass".equals(name) ||
- "getDeclaringClass".equals(name)) {
- key = "";
- } else {
- key = name.substring(3);
- }
- } else if (name.startsWith("is")) {
- key = name.substring(2);
- }
- if (key.length() > 0 &&
- Character.isUpperCase(key.charAt(0)) &&
- method.getParameterTypes().length == 0) {
- if (key.length() == 1) {
- key = key.toLowerCase();
- } else if (!Character.isUpperCase(key.charAt(1))) {
- key = key.substring(0, 1).toLowerCase() +
- key.substring(1);
- }
-
- Object result = method.invoke(bean, (Object[])null);
- if (result != null) {
- this.map.put(key, wrap(result));
- }
- }
- }
- } catch (Exception ignore) {
- }
- }
- }
-
-
- /**
- * Put a key/boolean pair in the JSONObject.
- *
- * @param key A key string.
- * @param value A boolean which is the value.
- * @return this.
- * @throws JSONException If the key is null.
- */
- public JSONObject put(String key, boolean value) throws JSONException {
- this.put(key, value ? Boolean.TRUE : Boolean.FALSE);
- return this;
- }
-
-
- /**
- * Put a key/value pair in the JSONObject, where the value will be a
- * JSONArray which is produced from a Collection.
- * @param key A key string.
- * @param value A Collection value.
- * @return this.
- * @throws JSONException
- */
- public JSONObject put(String key, Collection value) throws JSONException {
- this.put(key, new JSONArray(value));
- return this;
- }
-
-
- /**
- * Put a key/double pair in the JSONObject.
- *
- * @param key A key string.
- * @param value A double which is the value.
- * @return this.
- * @throws JSONException If the key is null or if the number is invalid.
- */
- public JSONObject put(String key, double value) throws JSONException {
- this.put(key, new Double(value));
- return this;
- }
-
-
- /**
- * Put a key/int pair in the JSONObject.
- *
- * @param key A key string.
- * @param value An int which is the value.
- * @return this.
- * @throws JSONException If the key is null.
- */
- public JSONObject put(String key, int value) throws JSONException {
- this.put(key, new Integer(value));
- return this;
- }
-
-
- /**
- * Put a key/long pair in the JSONObject.
- *
- * @param key A key string.
- * @param value A long which is the value.
- * @return this.
- * @throws JSONException If the key is null.
- */
- public JSONObject put(String key, long value) throws JSONException {
- this.put(key, new Long(value));
- return this;
- }
-
-
- /**
- * Put a key/value pair in the JSONObject, where the value will be a
- * JSONObject which is produced from a Map.
- * @param key A key string.
- * @param value A Map value.
- * @return this.
- * @throws JSONException
- */
- public JSONObject put(String key, Map value) throws JSONException {
- this.put(key, new JSONObject(value));
- return this;
- }
-
-
- /**
- * Put a key/value pair in the JSONObject. If the value is null,
- * then the key will be removed from the JSONObject if it is present.
- * @param key A key string.
- * @param value An object which is the value. It should be of one of these
- * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
- * or the JSONObject.NULL object.
- * @return this.
- * @throws JSONException If the value is non-finite number
- * or if the key is null.
- */
- public JSONObject put(String key, Object value) throws JSONException {
- if (key == null) {
- throw new JSONException("Null key.");
- }
- if (value != null) {
- testValidity(value);
- this.map.put(key, value);
- } else {
- this.remove(key);
- }
- return this;
- }
-
-
- /**
- * Put a key/value pair in the JSONObject, but only if the key and the
- * value are both non-null, and only if there is not already a member
- * with that name.
- * @param key
- * @param value
- * @return his.
- * @throws JSONException if the key is a duplicate
- */
- public JSONObject putOnce(String key, Object value) throws JSONException {
- if (key != null && value != null) {
- if (this.opt(key) != null) {
- throw new JSONException("Duplicate key \"" + key + "\"");
- }
- this.put(key, value);
- }
- return this;
- }
-
-
- /**
- * Put a key/value pair in the JSONObject, but only if the
- * key and the value are both non-null.
- * @param key A key string.
- * @param value An object which is the value. It should be of one of these
- * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
- * or the JSONObject.NULL object.
- * @return this.
- * @throws JSONException If the value is a non-finite number.
- */
- public JSONObject putOpt(String key, Object value) throws JSONException {
- if (key != null && value != null) {
- this.put(key, value);
- }
- return this;
- }
-
-
- /**
- * Produce a string in double quotes with backslash sequences in all the
- * right places. A backslash will be inserted within </, producing <\/,
- * allowing JSON text to be delivered in HTML. In JSON text, a string
- * cannot contain a control character or an unescaped quote or backslash.
- * @param string A String
- * @return A String correctly formatted for insertion in a JSON text.
- */
- public static String quote(String string) {
- StringWriter sw = new StringWriter();
- synchronized (sw.getBuffer()) {
- try {
- return quote(string, sw).toString();
- } catch (IOException ignored) {
- // will never happen - we are writing to a string writer
- return "";
- }
- }
- }
-
- public static Writer quote(String string, Writer w) throws IOException {
- if (string == null || string.length() == 0) {
- w.write("\"\"");
- return w;
- }
-
- char b;
- char c = 0;
- String hhhh;
- int i;
- int len = string.length();
-
- w.write('"');
- for (i = 0; i < len; i += 1) {
- b = c;
- c = string.charAt(i);
- switch (c) {
- case '\\':
- case '"':
- w.write('\\');
- w.write(c);
- break;
- case '/':
- if (b == '<') {
- w.write('\\');
- }
- w.write(c);
- break;
- case '\b':
- w.write("\\b");
- break;
- case '\t':
- w.write("\\t");
- break;
- case '\n':
- w.write("\\n");
- break;
- case '\f':
- w.write("\\f");
- break;
- case '\r':
- w.write("\\r");
- break;
- default:
- if (c < ' ' || (c >= '\u0080' && c < '\u00a0')
- || (c >= '\u2000' && c < '\u2100')) {
- hhhh = "000" + Integer.toHexString(c);
- w.write("\\u" + hhhh.substring(hhhh.length() - 4));
- } else {
- w.write(c);
- }
- }
- }
- w.write('"');
- return w;
- }
-
- /**
- * Remove a name and its value, if present.
- * @param key The name to be removed.
- * @return The value that was associated with the name,
- * or null if there was no value.
- */
- public Object remove(String key) {
- return this.map.remove(key);
- }
-
- /**
- * Try to convert a string into a number, boolean, or null. If the string
- * can't be converted, return the string.
- * @param string A String.
- * @return A simple JSON value.
- */
- public static Object stringToValue(String string) {
- Double d;
- if (string.equals("")) {
- return string;
- }
- if (string.equalsIgnoreCase("true")) {
- return Boolean.TRUE;
- }
- if (string.equalsIgnoreCase("false")) {
- return Boolean.FALSE;
- }
- if (string.equalsIgnoreCase("null")) {
- return JSONObject.NULL;
- }
-
- /*
- * If it might be a number, try converting it.
- * If a number cannot be produced, then the value will just
- * be a string. Note that the plus and implied string
- * conventions are non-standard. A JSON parser may accept
- * non-JSON forms as long as it accepts all correct JSON forms.
- */
-
- char b = string.charAt(0);
- if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') {
- try {
- if (string.indexOf('.') > -1 ||
- string.indexOf('e') > -1 || string.indexOf('E') > -1) {
- d = Double.valueOf(string);
- if (!d.isInfinite() && !d.isNaN()) {
- return d;
- }
- } else {
- Long myLong = new Long(string);
- if (myLong.longValue() == myLong.intValue()) {
- return new Integer(myLong.intValue());
- } else {
- return myLong;
- }
- }
- } catch (Exception ignore) {
- }
- }
- return string;
- }
-
-
- /**
- * Throw an exception if the object is a NaN or infinite number.
- * @param o The object to test.
- * @throws JSONException If o is a non-finite number.
- */
- public static void testValidity(Object o) throws JSONException {
- if (o != null) {
- if (o instanceof Double) {
- if (((Double)o).isInfinite() || ((Double)o).isNaN()) {
- throw new JSONException(
- "JSON does not allow non-finite numbers.");
- }
- } else if (o instanceof Float) {
- if (((Float)o).isInfinite() || ((Float)o).isNaN()) {
- throw new JSONException(
- "JSON does not allow non-finite numbers.");
- }
- }
- }
- }
-
-
- /**
- * Produce a JSONArray containing the values of the members of this
- * JSONObject.
- * @param names A JSONArray containing a list of key strings. This
- * determines the sequence of the values in the result.
- * @return A JSONArray of values.
- * @throws JSONException If any of the values are non-finite numbers.
- */
- public JSONArray toJSONArray(JSONArray names) throws JSONException {
- if (names == null || names.length() == 0) {
- return null;
- }
- JSONArray ja = new JSONArray();
- for (int i = 0; i < names.length(); i += 1) {
- ja.put(this.opt(names.getString(i)));
- }
- return ja;
- }
-
- /**
- * Make a JSON text of this JSONObject. For compactness, no whitespace
- * is added. If this would not result in a syntactically correct JSON text,
- * then null will be returned instead.
- * <p>
- * Warning: This method assumes that the data structure is acyclical.
- *
- * @return a printable, displayable, portable, transmittable
- * representation of the object, beginning
- * with <code>{</code> <small>(left brace)</small> and ending
- * with <code>}</code> <small>(right brace)</small>.
- */
- public String toString() {
- try {
- return this.toString(0);
- } catch (Exception e) {
- return null;
- }
- }
-
-
- /**
- * Make a prettyprinted JSON text of this JSONObject.
- * <p>
- * Warning: This method assumes that the data structure is acyclical.
- * @param indentFactor The number of spaces to add to each level of
- * indentation.
- * @return a printable, displayable, portable, transmittable
- * representation of the object, beginning
- * with <code>{</code> <small>(left brace)</small> and ending
- * with <code>}</code> <small>(right brace)</small>.
- * @throws JSONException If the object contains an invalid number.
- */
- public String toString(int indentFactor) throws JSONException {
- StringWriter w = new StringWriter();
- synchronized (w.getBuffer()) {
- return this.write(w, indentFactor, 0).toString();
- }
- }
-
- /**
- * Make a JSON text of an Object value. If the object has an
- * value.toJSONString() method, then that method will be used to produce
- * the JSON text. The method is required to produce a strictly
- * conforming text. If the object does not contain a toJSONString
- * method (which is the most common case), then a text will be
- * produced by other means. If the value is an array or Collection,
- * then a JSONArray will be made from it and its toJSONString method
- * will be called. If the value is a MAP, then a JSONObject will be made
- * from it and its toJSONString method will be called. Otherwise, the
- * value's toString method will be called, and the result will be quoted.
- *
- * <p>
- * Warning: This method assumes that the data structure is acyclical.
- * @param value The value to be serialized.
- * @return a printable, displayable, transmittable
- * representation of the object, beginning
- * with <code>{</code> <small>(left brace)</small> and ending
- * with <code>}</code> <small>(right brace)</small>.
- * @throws JSONException If the value is or contains an invalid number.
- */
- public static String valueToString(Object value) throws JSONException {
- if (value == null || value.equals(null)) {
- return "null";
- }
- if (value instanceof JSONString) {
- Object object;
- try {
- object = ((JSONString)value).toJSONString();
- } catch (Exception e) {
- throw new JSONException(e);
- }
- if (object instanceof String) {
- return (String)object;
- }
- throw new JSONException("Bad value from toJSONString: " + object);
- }
- if (value instanceof Number) {
- return numberToString((Number) value);
- }
- if (value instanceof Boolean || value instanceof JSONObject ||
- value instanceof JSONArray) {
- return value.toString();
- }
- if (value instanceof Map) {
- return new JSONObject((Map)value).toString();
- }
- if (value instanceof Collection) {
- return new JSONArray((Collection)value).toString();
- }
- if (value.getClass().isArray()) {
- return new JSONArray(value).toString();
- }
- return quote(value.toString());
- }
-
- /**
- * Wrap an object, if necessary. If the object is null, return the NULL
- * object. If it is an array or collection, wrap it in a JSONArray. If
- * it is a map, wrap it in a JSONObject. If it is a standard property
- * (Double, String, et al) then it is already wrapped. Otherwise, if it
- * comes from one of the java packages, turn it into a string. And if
- * it doesn't, try to wrap it in a JSONObject. If the wrapping fails,
- * then null is returned.
- *
- * @param object The object to wrap
- * @return The wrapped value
- */
- public static Object wrap(Object object) {
- try {
- if (object == null) {
- return NULL;
- }
- if (object instanceof JSONObject || object instanceof JSONArray ||
- NULL.equals(object) || object instanceof JSONString ||
- object instanceof Byte || object instanceof Character ||
- object instanceof Short || object instanceof Integer ||
- object instanceof Long || object instanceof Boolean ||
- object instanceof Float || object instanceof Double ||
- object instanceof String || object instanceof Enum) {
- return object;
- }
-
- if (object instanceof Collection) {
- return new JSONArray((Collection)object);
- }
- if (object.getClass().isArray()) {
- return new JSONArray(object);
- }
- if (object instanceof Map) {
- return new JSONObject((Map)object);
- }
- Package objectPackage = object.getClass().getPackage();
- String objectPackageName = objectPackage != null
- ? objectPackage.getName()
- : "";
- if (
- objectPackageName.startsWith("java.") ||
- objectPackageName.startsWith("javax.") ||
- object.getClass().getClassLoader() == null
- ) {
- return object.toString();
- }
- return new JSONObject(object);
- } catch(Exception exception) {
- return null;
- }
- }
-
-
- /**
- * Write the contents of the JSONObject as JSON text to a writer.
- * For compactness, no whitespace is added.
- * <p>
- * Warning: This method assumes that the data structure is acyclical.
- *
- * @return The writer.
- * @throws JSONException
- */
- public Writer write(Writer writer) throws JSONException {
- return this.write(writer, 0, 0);
- }
-
-
- static final Writer writeValue(Writer writer, Object value,
- int indentFactor, int indent) throws JSONException, IOException {
- if (value == null || value.equals(null)) {
- writer.write("null");
- } else if (value instanceof JSONObject) {
- ((JSONObject) value).write(writer, indentFactor, indent);
- } else if (value instanceof JSONArray) {
- ((JSONArray) value).write(writer, indentFactor, indent);
- } else if (value instanceof Map) {
- new JSONObject((Map) value).write(writer, indentFactor, indent);
- } else if (value instanceof Collection) {
- new JSONArray((Collection) value).write(writer, indentFactor,
- indent);
- } else if (value.getClass().isArray()) {
- new JSONArray(value).write(writer, indentFactor, indent);
- } else if (value instanceof Number) {
- writer.write(numberToString((Number) value));
- } else if (value instanceof Boolean) {
- writer.write(value.toString());
- } else if (value instanceof JSONString) {
- Object o;
- try {
- o = ((JSONString) value).toJSONString();
- } catch (Exception e) {
- throw new JSONException(e);
- }
- writer.write(o != null ? o.toString() : quote(value.toString()));
- } else {
- quote(value.toString(), writer);
- }
- return writer;
- }
-
- static final void indent(Writer writer, int indent) throws IOException {
- for (int i = 0; i < indent; i += 1) {
- writer.write(' ');
- }
- }
-
- /**
- * Write the contents of the JSONObject as JSON text to a writer. For
- * compactness, no whitespace is added.
- * <p>
- * Warning: This method assumes that the data structure is acyclical.
- *
- * @return The writer.
- * @throws JSONException
- */
- Writer write(Writer writer, int indentFactor, int indent)
- throws JSONException {
- try {
- boolean commanate = false;
- final int length = this.length();
- Iterator keys = this.keys();
- writer.write('{');
-
- if (length == 1) {
- Object key = keys.next();
- writer.write(quote(key.toString()));
- writer.write(':');
- if (indentFactor > 0) {
- writer.write(' ');
- }
- writeValue(writer, this.map.get(key), indentFactor, indent);
- } else if (length != 0) {
- final int newindent = indent + indentFactor;
- while (keys.hasNext()) {
- Object key = keys.next();
- if (commanate) {
- writer.write(',');
- }
- if (indentFactor > 0) {
- writer.write('\n');
- }
- indent(writer, newindent);
- writer.write(quote(key.toString()));
- writer.write(':');
- if (indentFactor > 0) {
- writer.write(' ');
- }
- writeValue(writer, this.map.get(key), indentFactor,
- newindent);
- commanate = true;
- }
- if (indentFactor > 0) {
- writer.write('\n');
- }
- indent(writer, indent);
- }
- writer.write('}');
- return writer;
- } catch (IOException exception) {
- throw new JSONException(exception);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONString.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONString.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONString.java
deleted file mode 100644
index f3c7745..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONString.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.json;
-/**
- * The <code>JSONString</code> interface allows a <code>toJSONString()</code>
- * method so that a class can change the behavior of
- * <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
- * and <code>JSONWriter.value(</code>Object<code>)</code>. The
- * <code>toJSONString</code> method will be used instead of the default behavior
- * of using the Object's <code>toString()</code> method and quoting the result.
- */
-public interface JSONString {
- /**
- * The <code>toJSONString</code> method allows a class to produce its own JSON
- * serialization.
- *
- * @return A strictly syntactically correct JSON text.
- */
- String toJSONString();
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONStringer.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONStringer.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONStringer.java
deleted file mode 100644
index 41c7065..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONStringer.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.json;
-
-import java.io.StringWriter;
-
-/**
- * JSONStringer provides a quick and convenient way of producing JSON text.
- * The texts produced strictly conform to JSON syntax rules. No whitespace is
- * added, so the results are ready for transmission or storage. Each instance of
- * JSONStringer can produce one JSON text.
- * <p>
- * A JSONStringer instance provides a <code>value</code> method for appending
- * values to the
- * text, and a <code>key</code>
- * method for adding keys before values in objects. There are <code>array</code>
- * and <code>endArray</code> methods that make and bound array values, and
- * <code>object</code> and <code>endObject</code> methods which make and bound
- * object values. All of these methods return the JSONWriter instance,
- * permitting cascade style. For example, <pre>
- * myString = new JSONStringer()
- * .object()
- * .key("JSON")
- * .value("Hello, World!")
- * .endObject()
- * .toString();</pre> which produces the string <pre>
- * {"JSON":"Hello, World!"}</pre>
- * <p>
- * The first method called must be <code>array</code> or <code>object</code>.
- * There are no methods for adding commas or colons. JSONStringer adds them for
- * you. Objects and arrays can be nested up to 20 levels deep.
- * <p>
- * This can sometimes be easier than using a JSONObject to build a string.
- * @author JSON.org
- * @version 2008-09-18
- */
-public class JSONStringer extends JSONWriter {
- /**
- * Make a fresh JSONStringer. It can be used to build one JSON text.
- */
- public JSONStringer() {
- super(new StringWriter());
- }
-
- /**
- * Return the JSON text. This method is used to obtain the product of the
- * JSONStringer instance. It will return <code>null</code> if there was a
- * problem in the construction of the JSON text (such as the calls to
- * <code>array</code> were not properly balanced with calls to
- * <code>endArray</code>).
- * @return The JSON text.
- */
- public String toString() {
- return this.mode == 'd' ? this.writer.toString() : null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONTokener.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONTokener.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONTokener.java
deleted file mode 100644
index 2006ee8..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONTokener.java
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.json;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-
-/**
- * A JSONTokener takes a source string and extracts characters and tokens from
- * it. It is used by the JSONObject and JSONArray constructors to parse
- * JSON source strings.
- * @author JSON.org
- * @version 2012-02-16
- */
-public class JSONTokener {
-
- private long character;
- private boolean eof;
- private long index;
- private long line;
- private char previous;
- private Reader reader;
- private boolean usePrevious;
-
-
- /**
- * Construct a JSONTokener from a Reader.
- *
- * @param reader A reader.
- */
- public JSONTokener(Reader reader) {
- this.reader = reader.markSupported()
- ? reader
- : new BufferedReader(reader);
- this.eof = false;
- this.usePrevious = false;
- this.previous = 0;
- this.index = 0;
- this.character = 1;
- this.line = 1;
- }
-
-
- /**
- * Construct a JSONTokener from an InputStream.
- */
- public JSONTokener(InputStream inputStream) throws JSONException {
- this(new InputStreamReader(inputStream));
- }
-
-
- /**
- * Construct a JSONTokener from a string.
- *
- * @param s A source string.
- */
- public JSONTokener(String s) {
- this(new StringReader(s));
- }
-
-
- /**
- * Back up one character. This provides a sort of lookahead capability,
- * so that you can test for a digit or letter before attempting to parse
- * the next number or identifier.
- */
- public void back() throws JSONException {
- if (this.usePrevious || this.index <= 0) {
- throw new JSONException("Stepping back two steps is not supported");
- }
- this.index -= 1;
- this.character -= 1;
- this.usePrevious = true;
- this.eof = false;
- }
-
-
- /**
- * Get the hex value of a character (base16).
- * @param c A character between '0' and '9' or between 'A' and 'F' or
- * between 'a' and 'f'.
- * @return An int between 0 and 15, or -1 if c was not a hex digit.
- */
- public static int dehexchar(char c) {
- if (c >= '0' && c <= '9') {
- return c - '0';
- }
- if (c >= 'A' && c <= 'F') {
- return c - ('A' - 10);
- }
- if (c >= 'a' && c <= 'f') {
- return c - ('a' - 10);
- }
- return -1;
- }
-
- public boolean end() {
- return this.eof && !this.usePrevious;
- }
-
-
- /**
- * Determine if the source string still contains characters that next()
- * can consume.
- * @return true if not yet at the end of the source.
- */
- public boolean more() throws JSONException {
- this.next();
- if (this.end()) {
- return false;
- }
- this.back();
- return true;
- }
-
-
- /**
- * Get the next character in the source string.
- *
- * @return The next character, or 0 if past the end of the source string.
- */
- public char next() throws JSONException {
- int c;
- if (this.usePrevious) {
- this.usePrevious = false;
- c = this.previous;
- } else {
- try {
- c = this.reader.read();
- } catch (IOException exception) {
- throw new JSONException(exception);
- }
-
- if (c <= 0) { // End of stream
- this.eof = true;
- c = 0;
- }
- }
- this.index += 1;
- if (this.previous == '\r') {
- this.line += 1;
- this.character = c == '\n' ? 0 : 1;
- } else if (c == '\n') {
- this.line += 1;
- this.character = 0;
- } else {
- this.character += 1;
- }
- this.previous = (char) c;
- return this.previous;
- }
-
-
- /**
- * Consume the next character, and check that it matches a specified
- * character.
- * @param c The character to match.
- * @return The character.
- * @throws JSONException if the character does not match.
- */
- public char next(char c) throws JSONException {
- char n = this.next();
- if (n != c) {
- throw this.syntaxError("Expected '" + c + "' and instead saw '" +
- n + "'");
- }
- return n;
- }
-
-
- /**
- * Get the next n characters.
- *
- * @param n The number of characters to take.
- * @return A string of n characters.
- * @throws JSONException
- * Substring bounds error if there are not
- * n characters remaining in the source string.
- */
- public String next(int n) throws JSONException {
- if (n == 0) {
- return "";
- }
-
- char[] chars = new char[n];
- int pos = 0;
-
- while (pos < n) {
- chars[pos] = this.next();
- if (this.end()) {
- throw this.syntaxError("Substring bounds error");
- }
- pos += 1;
- }
- return new String(chars);
- }
-
-
- /**
- * Get the next char in the string, skipping whitespace.
- * @throws JSONException
- * @return A character, or 0 if there are no more characters.
- */
- public char nextClean() throws JSONException {
- for (;;) {
- char c = this.next();
- if (c == 0 || c > ' ') {
- return c;
- }
- }
- }
-
-
- /**
- * Return the characters up to the next close quote character.
- * Backslash processing is done. The formal JSON format does not
- * allow strings in single quotes, but an implementation is allowed to
- * accept them.
- * @param quote The quoting character, either
- * <code>"</code> <small>(double quote)</small> or
- * <code>'</code> <small>(single quote)</small>.
- * @return A String.
- * @throws JSONException Unterminated string.
- */
- public String nextString(char quote) throws JSONException {
- char c;
- StringBuffer sb = new StringBuffer();
- for (;;) {
- c = this.next();
- switch (c) {
- case 0:
- case '\n':
- case '\r':
- throw this.syntaxError("Unterminated string");
- case '\\':
- c = this.next();
- switch (c) {
- case 'b':
- sb.append('\b');
- break;
- case 't':
- sb.append('\t');
- break;
- case 'n':
- sb.append('\n');
- break;
- case 'f':
- sb.append('\f');
- break;
- case 'r':
- sb.append('\r');
- break;
- case 'u':
- sb.append((char)Integer.parseInt(this.next(4), 16));
- break;
- case '"':
- case '\'':
- case '\\':
- case '/':
- sb.append(c);
- break;
- default:
- throw this.syntaxError("Illegal escape.");
- }
- break;
- default:
- if (c == quote) {
- return sb.toString();
- }
- sb.append(c);
- }
- }
- }
-
-
- /**
- * Get the text up but not including the specified character or the
- * end of line, whichever comes first.
- * @param delimiter A delimiter character.
- * @return A string.
- */
- public String nextTo(char delimiter) throws JSONException {
- StringBuffer sb = new StringBuffer();
- for (;;) {
- char c = this.next();
- if (c == delimiter || c == 0 || c == '\n' || c == '\r') {
- if (c != 0) {
- this.back();
- }
- return sb.toString().trim();
- }
- sb.append(c);
- }
- }
-
-
- /**
- * Get the text up but not including one of the specified delimiter
- * characters or the end of line, whichever comes first.
- * @param delimiters A set of delimiter characters.
- * @return A string, trimmed.
- */
- public String nextTo(String delimiters) throws JSONException {
- char c;
- StringBuffer sb = new StringBuffer();
- for (;;) {
- c = this.next();
- if (delimiters.indexOf(c) >= 0 || c == 0 ||
- c == '\n' || c == '\r') {
- if (c != 0) {
- this.back();
- }
- return sb.toString().trim();
- }
- sb.append(c);
- }
- }
-
-
- /**
- * Get the next value. The value can be a Boolean, Double, Integer,
- * JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
- * @throws JSONException If syntax error.
- *
- * @return An object.
- */
- public Object nextValue() throws JSONException {
- char c = this.nextClean();
- String string;
-
- switch (c) {
- case '"':
- case '\'':
- return this.nextString(c);
- case '{':
- this.back();
- return new JSONObject(this);
- case '[':
- this.back();
- return new JSONArray(this);
- }
-
- /*
- * Handle unquoted text. This could be the values true, false, or
- * null, or it can be a number. An implementation (such as this one)
- * is allowed to also accept non-standard forms.
- *
- * Accumulate characters until we reach the end of the text or a
- * formatting character.
- */
-
- StringBuffer sb = new StringBuffer();
- while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
- sb.append(c);
- c = this.next();
- }
- this.back();
-
- string = sb.toString().trim();
- if ("".equals(string)) {
- throw this.syntaxError("Missing value");
- }
- return JSONObject.stringToValue(string);
- }
-
-
- /**
- * Skip characters until the next character is the requested character.
- * If the requested character is not found, no characters are skipped.
- * @param to A character to skip to.
- * @return The requested character, or zero if the requested character
- * is not found.
- */
- public char skipTo(char to) throws JSONException {
- char c;
- try {
- long startIndex = this.index;
- long startCharacter = this.character;
- long startLine = this.line;
- this.reader.mark(1000000);
- do {
- c = this.next();
- if (c == 0) {
- this.reader.reset();
- this.index = startIndex;
- this.character = startCharacter;
- this.line = startLine;
- return c;
- }
- } while (c != to);
- } catch (IOException exc) {
- throw new JSONException(exc);
- }
-
- this.back();
- return c;
- }
-
-
- /**
- * Make a JSONException to signal a syntax error.
- *
- * @param message The error message.
- * @return A JSONException object, suitable for throwing
- */
- public JSONException syntaxError(String message) {
- return new JSONException(message + this.toString());
- }
-
-
- /**
- * Make a printable string of this JSONTokener.
- *
- * @return " at {index} [character {character} line {line}]"
- */
- public String toString() {
- return " at " + this.index + " [character " + this.character + " line " +
- this.line + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONWriter.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONWriter.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONWriter.java
deleted file mode 100644
index 7c1590e..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONWriter.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.json;
-
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * JSONWriter provides a quick and convenient way of producing JSON text.
- * The texts produced strictly conform to JSON syntax rules. No whitespace is
- * added, so the results are ready for transmission or storage. Each instance of
- * JSONWriter can produce one JSON text.
- * <p>
- * A JSONWriter instance provides a <code>value</code> method for appending
- * values to the
- * text, and a <code>key</code>
- * method for adding keys before values in objects. There are <code>array</code>
- * and <code>endArray</code> methods that make and bound array values, and
- * <code>object</code> and <code>endObject</code> methods which make and bound
- * object values. All of these methods return the JSONWriter instance,
- * permitting a cascade style. For example, <pre>
- * new JSONWriter(myWriter)
- * .object()
- * .key("JSON")
- * .value("Hello, World!")
- * .endObject();</pre> which writes <pre>
- * {"JSON":"Hello, World!"}</pre>
- * <p>
- * The first method called must be <code>array</code> or <code>object</code>.
- * There are no methods for adding commas or colons. JSONWriter adds them for
- * you. Objects and arrays can be nested up to 20 levels deep.
- * <p>
- * This can sometimes be easier than using a JSONObject to build a string.
- * @author JSON.org
- * @version 2011-11-24
- */
-public class JSONWriter {
- private static final int maxdepth = 200;
-
- /**
- * The comma flag determines if a comma should be output before the next
- * value.
- */
- private boolean comma;
-
- /**
- * The current mode. Values:
- * 'a' (array),
- * 'd' (done),
- * 'i' (initial),
- * 'k' (key),
- * 'o' (object).
- */
- protected char mode;
-
- /**
- * The object/array stack.
- */
- private final JSONObject stack[];
-
- /**
- * The stack top index. A value of 0 indicates that the stack is empty.
- */
- private int top;
-
- /**
- * The writer that will receive the output.
- */
- protected Writer writer;
-
- /**
- * Make a fresh JSONWriter. It can be used to build one JSON text.
- */
- public JSONWriter(Writer w) {
- this.comma = false;
- this.mode = 'i';
- this.stack = new JSONObject[maxdepth];
- this.top = 0;
- this.writer = w;
- }
-
- /**
- * Append a value.
- * @param string A string value.
- * @return this
- * @throws JSONException If the value is out of sequence.
- */
- private JSONWriter append(String string) throws JSONException {
- if (string == null) {
- throw new JSONException("Null pointer");
- }
- if (this.mode == 'o' || this.mode == 'a') {
- try {
- if (this.comma && this.mode == 'a') {
- this.writer.write(',');
- }
- this.writer.write(string);
- } catch (IOException e) {
- throw new JSONException(e);
- }
- if (this.mode == 'o') {
- this.mode = 'k';
- }
- this.comma = true;
- return this;
- }
- throw new JSONException("Value out of sequence.");
- }
-
- /**
- * Begin appending a new array. All values until the balancing
- * <code>endArray</code> will be appended to this array. The
- * <code>endArray</code> method must be called to mark the array's end.
- * @return this
- * @throws JSONException If the nesting is too deep, or if the object is
- * started in the wrong place (for example as a key or after the end of the
- * outermost array or object).
- */
- public JSONWriter array() throws JSONException {
- if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') {
- this.push(null);
- this.append("[");
- this.comma = false;
- return this;
- }
- throw new JSONException("Misplaced array.");
- }
-
- /**
- * End something.
- * @param mode Mode
- * @param c Closing character
- * @return this
- * @throws JSONException If unbalanced.
- */
- private JSONWriter end(char mode, char c) throws JSONException {
- if (this.mode != mode) {
- throw new JSONException(mode == 'a'
- ? "Misplaced endArray."
- : "Misplaced endObject.");
- }
- this.pop(mode);
- try {
- this.writer.write(c);
- } catch (IOException e) {
- throw new JSONException(e);
- }
- this.comma = true;
- return this;
- }
-
- /**
- * End an array. This method most be called to balance calls to
- * <code>array</code>.
- * @return this
- * @throws JSONException If incorrectly nested.
- */
- public JSONWriter endArray() throws JSONException {
- return this.end('a', ']');
- }
-
- /**
- * End an object. This method most be called to balance calls to
- * <code>object</code>.
- * @return this
- * @throws JSONException If incorrectly nested.
- */
- public JSONWriter endObject() throws JSONException {
- return this.end('k', '}');
- }
-
- /**
- * Append a key. The key will be associated with the next value. In an
- * object, every value must be preceded by a key.
- * @param string A key string.
- * @return this
- * @throws JSONException If the key is out of place. For example, keys
- * do not belong in arrays or if the key is null.
- */
- public JSONWriter key(String string) throws JSONException {
- if (string == null) {
- throw new JSONException("Null key.");
- }
- if (this.mode == 'k') {
- try {
- this.stack[this.top - 1].putOnce(string, Boolean.TRUE);
- if (this.comma) {
- this.writer.write(',');
- }
- this.writer.write(JSONObject.quote(string));
- this.writer.write(':');
- this.comma = false;
- this.mode = 'o';
- return this;
- } catch (IOException e) {
- throw new JSONException(e);
- }
- }
- throw new JSONException("Misplaced key.");
- }
-
-
- /**
- * Begin appending a new object. All keys and values until the balancing
- * <code>endObject</code> will be appended to this object. The
- * <code>endObject</code> method must be called to mark the object's end.
- * @return this
- * @throws JSONException If the nesting is too deep, or if the object is
- * started in the wrong place (for example as a key or after the end of the
- * outermost array or object).
- */
- public JSONWriter object() throws JSONException {
- if (this.mode == 'i') {
- this.mode = 'o';
- }
- if (this.mode == 'o' || this.mode == 'a') {
- this.append("{");
- this.push(new JSONObject());
- this.comma = false;
- return this;
- }
- throw new JSONException("Misplaced object.");
-
- }
-
-
- /**
- * Pop an array or object scope.
- * @param c The scope to close.
- * @throws JSONException If nesting is wrong.
- */
- private void pop(char c) throws JSONException {
- if (this.top <= 0) {
- throw new JSONException("Nesting error.");
- }
- char m = this.stack[this.top - 1] == null ? 'a' : 'k';
- if (m != c) {
- throw new JSONException("Nesting error.");
- }
- this.top -= 1;
- this.mode = this.top == 0
- ? 'd'
- : this.stack[this.top - 1] == null
- ? 'a'
- : 'k';
- }
-
- /**
- * Push an array or object scope.
- * @param jo The scope to open.
- * @throws JSONException If nesting is too deep.
- */
- private void push(JSONObject jo) throws JSONException {
- if (this.top >= maxdepth) {
- throw new JSONException("Nesting too deep.");
- }
- this.stack[this.top] = jo;
- this.mode = jo == null ? 'a' : 'k';
- this.top += 1;
- }
-
-
- /**
- * Append either the value <code>true</code> or the value
- * <code>false</code>.
- * @param b A boolean.
- * @return this
- * @throws JSONException
- */
- public JSONWriter value(boolean b) throws JSONException {
- return this.append(b ? "true" : "false");
- }
-
- /**
- * Append a double value.
- * @param d A double.
- * @return this
- * @throws JSONException If the number is not finite.
- */
- public JSONWriter value(double d) throws JSONException {
- return this.value(new Double(d));
- }
-
- /**
- * Append a long value.
- * @param l A long.
- * @return this
- * @throws JSONException
- */
- public JSONWriter value(long l) throws JSONException {
- return this.append(Long.toString(l));
- }
-
-
- /**
- * Append an object value.
- * @param object The object to append. It can be null, or a Boolean, Number,
- * String, JSONObject, or JSONArray, or an object that implements JSONString.
- * @return this
- * @throws JSONException If the value is out of sequence.
- */
- public JSONWriter value(Object object) throws JSONException {
- return this.append(JSONObject.valueToString(object));
- }
-}
[07/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/controllers/PulseControllerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/controllers/PulseControllerJUnitTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/controllers/PulseControllerJUnitTest.java
new file mode 100644
index 0000000..06d7f3d
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/controllers/PulseControllerJUnitTest.java
@@ -0,0 +1,816 @@
+/*
+ * 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.controllers;
+
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.powermock.api.mockito.PowerMockito.spy;
+import static org.powermock.api.mockito.PowerMockito.when;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+
+import java.io.File;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.UUID;
+import javax.servlet.ServletContextListener;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.vmware.geode.tools.pulse.internal.PulseAppListener;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.geode.test.junit.categories.UnitTest;
+import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.PulseConfig;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+
+import org.apache.commons.collections.buffer.CircularFifoBuffer;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+
+import org.apache.geode.test.junit.categories.IntegrationTest;
+
+@Category(IntegrationTest.class)
+@PrepareForTest(Repository.class)
+@RunWith(PowerMockRunner.class)
+@PowerMockRunnerDelegate(SpringJUnit4ClassRunner.class)
+@WebAppConfiguration
+@ContextConfiguration("classpath*:mvc-dispatcher-servlet.xml")
+@PowerMockIgnore("*.IntegrationTest")
+public class PulseControllerJUnitTest {
+
+ private static final String PRINCIPAL_USER = "test-user";
+
+ private static final String MEMBER_ID = "member1";
+ private static final String MEMBER_NAME = "localhost-server";
+ private static final String CLUSTER_NAME = "mock-cluster";
+ private static final String REGION_NAME = "mock-region";
+ private static final String REGION_PATH = "/" + REGION_NAME;
+ private static final String REGION_TYPE = "PARTITION";
+ private static final String AEQ_LISTENER = "async-event-listener";
+ private static final String CLIENT_NAME = "client-1";
+ private static final String PHYSICAL_HOST_NAME = "physical-host-1";
+ private static final String GEMFIRE_VERSION = "1.0.0";
+
+ private static final Principal principal;
+
+ static {
+ principal = () -> PRINCIPAL_USER;
+ }
+
+ @Rule
+ public TemporaryFolder tempFolder = new TemporaryFolder();
+
+ @Autowired
+ private WebApplicationContext wac;
+
+ private MockMvc mockMvc;
+
+ private Cluster cluster;
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ @Before
+ public void setup() throws Exception {
+ this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
+
+
+ cluster = Mockito.spy(Cluster.class);
+
+ Cluster.Region region = new Cluster.Region();
+ region.setName(REGION_NAME);
+ region.setFullPath(REGION_PATH);
+ region.setRegionType(REGION_TYPE);
+ region.setMemberCount(1);
+ region.setMemberName(new ArrayList<String>() {{
+ add(MEMBER_NAME);
+ }});
+ region.setPutsRate(12.31D);
+ region.setGetsRate(27.99D);
+ Cluster.RegionOnMember regionOnMember = new Cluster.RegionOnMember();
+ regionOnMember.setRegionFullPath(REGION_PATH);
+ regionOnMember.setMemberName(MEMBER_NAME);
+ region.setRegionOnMembers(new ArrayList<Cluster.RegionOnMember>() {{
+ add(regionOnMember);
+ }});
+ cluster.addClusterRegion(REGION_PATH, region);
+
+ Cluster.Member member = new Cluster.Member();
+ member.setId(MEMBER_ID);
+ member.setName(MEMBER_NAME);
+ member.setUptime(1L);
+ member.setHost(PHYSICAL_HOST_NAME);
+ member.setGemfireVersion(GEMFIRE_VERSION);
+ member.setCpuUsage(55.77123D);
+
+ member.setMemberRegions(new HashMap<String, Cluster.Region>() {{
+ put(REGION_NAME, region);
+ }});
+
+ Cluster.AsyncEventQueue aeq = new Cluster.AsyncEventQueue();
+ aeq.setAsyncEventListener(AEQ_LISTENER);
+ member.setAsyncEventQueueList(new ArrayList() {{
+ add(aeq);
+ }});
+
+ Cluster.Client client = new Cluster.Client();
+ client.setId("100");
+ client.setName(CLIENT_NAME);
+ client.setUptime(1L);
+ member.setMemberClientsHMap(new HashMap<String, Cluster.Client>() {{
+ put(CLIENT_NAME, client);
+ }});
+
+ cluster.setMembersHMap(new HashMap() {{
+ put(MEMBER_NAME, member);
+ }});
+ cluster.setPhysicalToMember(new HashMap() {{
+ put(PHYSICAL_HOST_NAME, new ArrayList() {{
+ add(member);
+ }});
+ }});
+ cluster.setServerName(CLUSTER_NAME);
+ cluster.setMemoryUsageTrend(new CircularFifoBuffer() {{
+ add(1);
+ add(2);
+ add(3);
+ }});
+ cluster.setWritePerSecTrend(new CircularFifoBuffer() {{
+ add(1.29);
+ add(2.3);
+ add(3.0);
+ }});
+ cluster.setThroughoutReadsTrend(new CircularFifoBuffer() {{
+ add(1);
+ add(2);
+ add(3);
+ }});
+ cluster.setThroughoutWritesTrend(new CircularFifoBuffer() {{
+ add(4);
+ add(5);
+ add(6);
+ }});
+
+ Repository repo = Mockito.spy(Repository.class);
+
+ // Set up a partial mock for some static methods
+ spy(Repository.class);
+ when(Repository.class, "get").thenReturn(repo);
+ doReturn(cluster).when(repo).getCluster();
+
+ PulseConfig config = new PulseConfig();
+ File tempQueryLog = tempFolder.newFile("query_history.log");
+ config.setQueryHistoryFileName(tempQueryLog.toString());
+ doReturn(config).when(repo).getPulseConfig();
+
+ PulseController.pulseVersion.setPulseVersion("not empty");
+ PulseController.pulseVersion.setPulseBuildId("not empty");
+ PulseController.pulseVersion.setPulseBuildDate("not empty");
+ PulseController.pulseVersion.setPulseSourceDate("not empty");
+ PulseController.pulseVersion.setPulseSourceRevision("not empty");
+ PulseController.pulseVersion.setPulseSourceRepository("not empty");
+ }
+
+ @Test
+ public void pulseUpdateForClusterDetails() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"ClusterDetails\":\"{}\"}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.ClusterDetails.userName").value(PRINCIPAL_USER))
+ .andExpect(jsonPath("$.ClusterDetails.totalHeap").value(0D))
+ .andExpect(jsonPath("$.ClusterDetails.clusterName").value(CLUSTER_NAME))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForClusterDiskThroughput() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"ClusterDiskThroughput\":\"{}\"}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.ClusterDiskThroughput.currentThroughputWrites").value(0D))
+ .andExpect(jsonPath("$.ClusterDiskThroughput.throughputReads", contains(1, 2, 3)))
+ .andExpect(jsonPath("$.ClusterDiskThroughput.currentThroughputReads").value(0D))
+ .andExpect(jsonPath("$.ClusterDiskThroughput.throughputWrites", contains(4, 5, 6)))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForClusterGCPauses() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"ClusterJVMPauses\":\"{}\"}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.ClusterJVMPauses.currentGCPauses").value(0))
+ .andExpect(jsonPath("$.ClusterJVMPauses.gCPausesTrend").isEmpty())
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForClusterKeyStatistics() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"ClusterKeyStatistics\":\"{}\"}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.ClusterKeyStatistics.readPerSecTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterKeyStatistics.queriesPerSecTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterKeyStatistics.writePerSecTrend", contains(1.29, 2.3, 3.0)))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForClusterMember() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"ClusterMembers\":\"{}\"}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.ClusterMembers.members[0].serverGroups[0]").value("Default"))
+ .andExpect(jsonPath("$.ClusterMembers.members[0].cpuUsage").value(55.77D))
+ .andExpect(jsonPath("$.ClusterMembers.members[0].clients").value(1))
+ .andExpect(jsonPath("$.ClusterMembers.members[0].heapUsage").value(0))
+ .andExpect(jsonPath("$.ClusterMembers.members[0].name").value(MEMBER_NAME))
+ .andExpect(jsonPath("$.ClusterMembers.members[0].currentHeapUsage").value(0))
+ .andExpect(jsonPath("$.ClusterMembers.members[0].isManager").value(false))
+ .andExpect(jsonPath("$.ClusterMembers.members[0].threads").value(0))
+ .andExpect(jsonPath("$.ClusterMembers.members[0].memberId").value(MEMBER_ID))
+ .andExpect(jsonPath("$.ClusterMembers.members[0].redundancyZones[0]").value("Default"))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForClusterMembersRGraph() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"ClusterMembersRGraph\":\"{}\"}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.ClusterMembersRGraph.memberCount").value(0))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.data").isEmpty())
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.name").value(0))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.id").value(0))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].id").value(PHYSICAL_HOST_NAME))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].name").value(PHYSICAL_HOST_NAME))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.loadAvg").value(0D))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.sockets").value(0))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.threads").value(0))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.cpuUsage").value(0D))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.memoryUsage").value(0))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.hostStatus").value("Normal"))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].data.$type").value("hostNormalNode"))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].id").value(MEMBER_ID))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].name").value(MEMBER_NAME))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.gemfireVersion").value(GEMFIRE_VERSION))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.memoryUsage").value(0))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.cpuUsage").value(55.77D))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.regions").value(1))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.host").value(PHYSICAL_HOST_NAME))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.port").value("-"))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.clients").value(1))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.gcPauses").value(0))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.numThreads").value(0))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.nodeType").value("memberNormalNode"))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.$type").value("memberNormalNode"))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.gatewaySender").value(0))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].data.gatewayReceiver").value(0))
+ .andExpect(jsonPath("$.ClusterMembersRGraph.clustor.children[0].children[0].children").isEmpty())
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForClusterMemoryUsage() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"ClusterMemoryUsage\":\"{}\"}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.ClusterMemoryUsage.currentMemoryUsage").value(0))
+ .andExpect(jsonPath("$.ClusterMemoryUsage.memoryUsageTrend", containsInAnyOrder(1, 2, 3)))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForClusterRegion() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"ClusterRegion\":\"{}\"}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.ClusterRegion.clusterName").value(CLUSTER_NAME))
+ .andExpect(jsonPath("$.ClusterRegion.userName").value(PRINCIPAL_USER))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].regionPath").value(REGION_PATH))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].diskReadsTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterRegion.region[0].memoryUsage").value("0.0000"))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].getsRate").value(27.99D))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].wanEnabled").value(false))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].memberCount").value(1))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].memberNames[0].name").value(MEMBER_NAME))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].memberNames[0].id").value(MEMBER_ID))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].emptyNodes").value(0))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].type").value(REGION_TYPE))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].isEnableOffHeapMemory").value("OFF"))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].putsRate").value(12.31D))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].totalMemory").value(0))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].entryCount").value(0))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].compressionCodec").value("NA"))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].name").value(REGION_NAME))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].systemRegionEntryCount").value(0))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].persistence").value("OFF"))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].memoryReadsTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterRegion.region[0].diskWritesTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterRegion.region[0].memoryWritesTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterRegion.region[0].dataUsage").value(0))
+ .andExpect(jsonPath("$.ClusterRegion.region[0].entrySize").value("0.0000"))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForClusterRegions() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"ClusterRegions\":\"{}\"}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].regionPath").value(REGION_PATH))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].diskReadsTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].memoryUsage").value("0.0000"))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].getsRate").value(27.99D))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].wanEnabled").value(false))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].memberCount").value(1))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].memberNames[0].name").value(MEMBER_NAME))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].memberNames[0].id").value(MEMBER_ID))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].emptyNodes").value(0))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].type").value(REGION_TYPE))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].isEnableOffHeapMemory").value("OFF"))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].putsRate").value(12.31D))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].totalMemory").value(0))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].entryCount").value(0))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].compressionCodec").value("NA"))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].name").value(REGION_NAME))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].systemRegionEntryCount").value(0))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].persistence").value("OFF"))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].memoryReadsTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].diskWritesTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].memoryWritesTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].dataUsage").value(0))
+ .andExpect(jsonPath("$.ClusterRegions.regions[0].entrySize").value("0.0000"))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForClusterSelectedRegion() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"ClusterSelectedRegion\":{\"regionFullPath\":\"" + REGION_PATH + "\"}}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.lruEvictionRate").value(0D))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.getsRate").value(27.99D))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.emptyNodes").value(0))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.type").value(REGION_TYPE))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.isEnableOffHeapMemory").value("OFF"))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.path").value(REGION_PATH))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].cpuUsage").value(55.77D))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].clients").value(1))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].heapUsage").value(0))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].name").value(MEMBER_NAME))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].currentHeapUsage").value(0))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].isManager").value(false))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].threads").value(0))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].memberId").value(MEMBER_ID))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.members[0].uptime").value("0 Hours 0 Mins 1 Secs"))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.memoryReadsTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.diskWritesTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.dataUsage").value(0))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.regionPath").value(REGION_PATH))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.diskReadsTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.memoryUsage").value("0.0000"))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.wanEnabled").value(false))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.memberCount").value(1))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.putsRate").value(12.31D))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.totalMemory").value(0))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.entryCount").value(0))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.compressionCodec").value("NA"))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.name").value(REGION_NAME))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.systemRegionEntryCount").value(0))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.persistence").value("OFF"))
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.memoryWritesTrend").isEmpty())
+ .andExpect(jsonPath("$.ClusterSelectedRegion.selectedRegion.entrySize").value("0.0000"))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForClusterSelectedRegionsMember() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"ClusterSelectedRegionsMember\":{\"regionFullPath\":\"" + REGION_PATH + "\"}}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.diskReadsTrend", MEMBER_NAME).isEmpty())
+ .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.regionFullPath", MEMBER_NAME).value(REGION_PATH))
+ .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.entryCount", MEMBER_NAME).value(0))
+ .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.accessor", MEMBER_NAME).value("True"))
+ .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.memberName", MEMBER_NAME).value(MEMBER_NAME))
+ .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.memoryReadsTrend", MEMBER_NAME).isEmpty())
+ .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.diskWritesTrend", MEMBER_NAME).isEmpty())
+ .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.memoryWritesTrend", MEMBER_NAME).isEmpty())
+ .andExpect(jsonPath("$.ClusterSelectedRegionsMember.selectedRegionsMembers.%s.entrySize", MEMBER_NAME).value(0))
+ .andExpect(jsonPath("$.ClusterSelectedRegionsMember.clusterName").value(CLUSTER_NAME))
+ .andExpect(jsonPath("$.ClusterSelectedRegionsMember.userName").value(PRINCIPAL_USER))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForClusterWANInfo() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"ClusterWANInfo\":\"{}\"}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.ClusterWANInfo.connectedClusters").isEmpty())
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForMemberAsynchEventQueues() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"MemberAsynchEventQueues\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.MemberAsynchEventQueues.isAsyncEventQueuesPresent").value(true))
+ .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].batchTimeInterval").value(0))
+ .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].batchConflationEnabled").value(false))
+ .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].queueSize").value(0))
+ .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].senderType").value(false))
+ .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].asyncEventListener").value(AEQ_LISTENER))
+ .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].batchSize").value(0))
+ .andExpect(jsonPath("$.MemberAsynchEventQueues.asyncEventQueues[0].primary").value(false))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForMemberClients() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"MemberClients\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.MemberClients.name").value(MEMBER_NAME))
+ .andExpect(jsonPath("$.MemberClients.memberClients[0].puts").value(0))
+ .andExpect(jsonPath("$.MemberClients.memberClients[0].cpuUsage").value("0.0000"))
+ .andExpect(jsonPath("$.MemberClients.memberClients[0].clientId").value("100"))
+ .andExpect(jsonPath("$.MemberClients.memberClients[0].queueSize").value(0))
+ .andExpect(jsonPath("$.MemberClients.memberClients[0].clientCQCount").value(0))
+ .andExpect(jsonPath("$.MemberClients.memberClients[0].name").value(CLIENT_NAME))
+ .andExpect(jsonPath("$.MemberClients.memberClients[0].isConnected").value("No"))
+ .andExpect(jsonPath("$.MemberClients.memberClients[0].threads").value(0))
+ .andExpect(jsonPath("$.MemberClients.memberClients[0].isSubscriptionEnabled").value("No"))
+ .andExpect(jsonPath("$.MemberClients.memberClients[0].gets").value(0))
+ .andExpect(jsonPath("$.MemberClients.memberClients[0].uptime").value("0 Hours 0 Mins 1 Secs"))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForMemberDetails() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"MemberDetails\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.MemberDetails.name").value(MEMBER_NAME))
+ .andExpect(jsonPath("$.MemberDetails.offHeapUsedSize").value(0))
+ .andExpect(jsonPath("$.MemberDetails.diskStorageUsed").value(0D))
+ .andExpect(jsonPath("$.MemberDetails.regionsCount").value(1))
+ .andExpect(jsonPath("$.MemberDetails.clusterName").value(CLUSTER_NAME))
+ .andExpect(jsonPath("$.MemberDetails.name").value(MEMBER_NAME))
+ .andExpect(jsonPath("$.MemberDetails.threads").value(0))
+ .andExpect(jsonPath("$.MemberDetails.clusterId").isNotEmpty())
+ .andExpect(jsonPath("$.MemberDetails.numClients").value(1))
+ .andExpect(jsonPath("$.MemberDetails.userName").value(PRINCIPAL_USER))
+ .andExpect(jsonPath("$.MemberDetails.offHeapFreeSize").value(0))
+ .andExpect(jsonPath("$.MemberDetails.memberId").value(MEMBER_ID))
+ .andExpect(jsonPath("$.MemberDetails.status").value("Normal"))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForMemberDiskThroughput() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"MemberDiskThroughput\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.MemberDiskThroughput.throughputWritesTrend").isEmpty())
+ .andExpect(jsonPath("$.MemberDiskThroughput.throughputReadsTrend").isEmpty())
+ .andExpect(jsonPath("$.MemberDiskThroughput.throughputWrites").value(0D))
+ .andExpect(jsonPath("$.MemberDiskThroughput.throughputReads").value(0D))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForMemberGatewayHub() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"MemberGatewayHub\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.MemberGatewayHub.isGatewayReceiver").value(false))
+ .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].batchTimeInterval").value(0))
+ .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].batchConflationEnabled").value(false))
+ .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].queueSize").value(0))
+ .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].senderType").value(false))
+ .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].asyncEventListener").value(AEQ_LISTENER))
+ .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].batchSize").value(0))
+ .andExpect(jsonPath("$.MemberGatewayHub.asyncEventQueues[0].primary").value(false))
+ .andExpect(jsonPath("$.MemberGatewayHub.isGatewaySender").value(false))
+ .andExpect(jsonPath("$.MemberGatewayHub.regionsInvolved").isEmpty())
+ .andExpect(jsonPath("$.MemberGatewayHub.gatewaySenders").isEmpty())
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForMemberGCPauses() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"MemberGCPauses\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.MemberGCPauses.gcPausesCount").value(0))
+ .andExpect(jsonPath("$.MemberGCPauses.gcPausesTrend").isEmpty())
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForMemberHeapUsage() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"MemberHeapUsage\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.MemberHeapUsage.heapUsageTrend").isEmpty())
+ .andExpect(jsonPath("$.MemberHeapUsage.currentHeapUsage").value(0))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForMemberKeyStatistics() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"MemberKeyStatistics\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.MemberKeyStatistics.readPerSecTrend").isEmpty())
+ .andExpect(jsonPath("$.MemberKeyStatistics.cpuUsageTrend").isEmpty())
+ .andExpect(jsonPath("$.MemberKeyStatistics.memoryUsageTrend").isEmpty())
+ .andExpect(jsonPath("$.MemberKeyStatistics.writePerSecTrend").isEmpty())
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForMemberRegions() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"MemberRegions\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.MemberRegions.name").value(MEMBER_NAME))
+ .andExpect(jsonPath("$.MemberRegions.memberRegions[0].fullPath").value(REGION_PATH))
+ .andExpect(jsonPath("$.MemberRegions.memberRegions[0].entryCount").value(0))
+ .andExpect(jsonPath("$.MemberRegions.memberRegions[0].name").value(REGION_NAME))
+ .andExpect(jsonPath("$.MemberRegions.memberRegions[0].diskStoreName").value(""))
+ .andExpect(jsonPath("$.MemberRegions.memberRegions[0].gatewayEnabled").value(false))
+ .andExpect(jsonPath("$.MemberRegions.memberRegions[0].entrySize").value("0.0000"))
+ .andExpect(jsonPath("$.MemberRegions.memberId").value(MEMBER_ID))
+ .andExpect(jsonPath("$.MemberRegions.status").value("Normal"))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForMembersList() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"MembersList\":{\"memberName\":\"" + MEMBER_NAME + "\"}}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.MembersList.clusterMembers[0].name").value(MEMBER_NAME))
+ .andExpect(jsonPath("$.MembersList.clusterMembers[0].memberId").value(MEMBER_ID))
+ .andExpect(jsonPath("$.MembersList.clusterName").value(CLUSTER_NAME))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForPulseVersion() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"PulseVersion\":\"{}\"}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.PulseVersion.sourceDate").value("not empty"))
+ .andExpect(jsonPath("$.PulseVersion.sourceRepository").value("not empty"))
+ .andExpect(jsonPath("$.PulseVersion.pulseVersion").value("not empty"))
+ .andExpect(jsonPath("$.PulseVersion.sourceRevision").value("not empty"))
+ .andExpect(jsonPath("$.PulseVersion.buildId").value("not empty"))
+ .andExpect(jsonPath("$.PulseVersion.buildDate").value("not empty"))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForQueryStatistics() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"QueryStatistics\":\"{}\"}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.QueryStatistics.queriesList").isEmpty())
+ .andExpect(jsonPath("$.QueryStatistics.connectedFlag").value(false))
+ .andExpect(jsonPath("$.QueryStatistics.connectedErrorMsg").value(""))
+ ;
+ }
+
+ @Test
+ public void pulseUpdateForSystemAlerts() throws Exception {
+ this.mockMvc.perform(post("/pulseUpdate")
+ .param("pulseData", "{\"SystemAlerts\":{\"pageNumber\":\"1\"}}")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.SystemAlerts.pageNumber").value(1))
+ .andExpect(jsonPath("$.SystemAlerts.connectedFlag").value(false))
+ .andExpect(jsonPath("$.SystemAlerts.connectedErrorMsg").value(""))
+ .andExpect(jsonPath("$.SystemAlerts.systemAlerts").isEmpty())
+ ;
+ }
+
+ @Test
+ public void authenticateUserNotLoggedIn() throws Exception {
+ this.mockMvc.perform(get("/authenticateUser")
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.isUserLoggedIn").value(false));
+ }
+
+ @Test
+ public void authenticateUserLoggedIn() throws Exception {
+ this.mockMvc.perform(get("/authenticateUser")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.isUserLoggedIn").value(true));
+ }
+
+ @Test
+ public void pulseVersion() throws Exception {
+ this.mockMvc.perform(get("/pulseVersion")
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.pulseVersion").isNotEmpty())
+ .andExpect(jsonPath("$.buildId").isNotEmpty())
+ .andExpect(jsonPath("$.buildDate").isNotEmpty())
+ .andExpect(jsonPath("$.sourceDate").isNotEmpty())
+ .andExpect(jsonPath("$.sourceRevision").isNotEmpty())
+ .andExpect(jsonPath("$.sourceRepository").isNotEmpty())
+ ;
+ }
+
+ @Test
+ public void clearAlerts() throws Exception {
+ this.mockMvc.perform(get("/clearAlerts")
+ .param("alertType", "1")
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.pageNumber").value(1))
+ .andExpect(jsonPath("$.systemAlerts").isEmpty())
+ .andExpect(jsonPath("$.connectedFlag").value(false))
+ .andExpect(jsonPath("$.status").value("deleted"))
+ ;
+ }
+
+ @Test
+ public void acknowledgeAlert() throws Exception {
+ this.mockMvc.perform(get("/acknowledgeAlert")
+ .param("alertId", "1")
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.status").value("deleted"));
+ }
+
+ @Test
+ public void dataBrowserRegions() throws Exception {
+ this.mockMvc.perform(get("/dataBrowserRegions")
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.clusterName").value(CLUSTER_NAME))
+ .andExpect(jsonPath("$.connectedFlag").value(false))
+ .andExpect(jsonPath("$.clusterRegions[0].fullPath").value(REGION_PATH))
+ .andExpect(jsonPath("$.clusterRegions[0].regionType").value(REGION_TYPE))
+ ;
+ }
+
+ @Test
+ public void dataBrowserQuery() throws Exception {
+ doReturn(mapper.createObjectNode().put("foo", "bar")).when(cluster).executeQuery(anyString(), anyString(), anyInt());
+
+ this.mockMvc.perform(get("/dataBrowserQuery")
+ .param("query", "SELECT * FROM " + REGION_PATH)
+ .param("members", MEMBER_NAME)
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.foo").value("bar"))
+ ;
+ }
+
+ @Test
+ public void dataBrowserQueryHistory() throws Exception {
+ dataBrowserQuery();
+
+ this.mockMvc.perform(get("/dataBrowserQueryHistory")
+ .param("action", "view")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.queryHistory[0].queryText").value("\"SELECT * FROM " + REGION_PATH + "\""))
+ ;
+ }
+
+ @Test
+ public void pulseProductSupport() throws Exception {
+ this.mockMvc.perform(get("/pulseProductSupport")
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.product").value("gemfire"))
+ ;
+ }
+
+ @Test
+ public void getQueryStatisticsGridModel() throws Exception {
+ this.mockMvc.perform(get("/getQueryStatisticsGridModel")
+ .principal(principal)
+ .accept(MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE)))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.columnNames", containsInAnyOrder("Query",
+ "NumExecution",
+ "TotalExecutionTime(ns)",
+ "NumExecutionsInProgress",
+ "NumTimesCompiled",
+ "NumTimesGlobalIndexLookup",
+ "NumRowsModified",
+ "ParseTime(ms)",
+ "BindTime(ms)",
+ "OptimizeTime(ms)",
+ "RoutingInfoTime(ms)",
+ "GenerateTime(ms)",
+ "TotalCompilationTime(ms)",
+ "ExecutionTime(ns)",
+ "ProjectionTime(ns)",
+ "RowsModificationTime(ns)",
+ "QNNumRowsSeen",
+ "QNMsgSendTime(ns)",
+ "QNMsgSerTime(ns)",
+ "QNRespDeSerTime(ns)")))
+ ;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemFireDistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemFireDistributedSystem.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemFireDistributedSystem.java
new file mode 100644
index 0000000..4b25a8d
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemFireDistributedSystem.java
@@ -0,0 +1,324 @@
+/*
+ *
+ * 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.testbed;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+
+
+/**
+ *
+ * TODO
+ * 0. SystemAlerts
+ * 1. Operations like member-up/down/crash, region create/destroy [7.5 scope]
+ * 2. Read events like member-up/down/crash, region create/destroy [7.5 scope]
+ * 3. PropFile Writing
+ * 4. Link to other remote systems, topology - multi-cluster [7.5]
+ *
+ *
+ */
+public class GemFireDistributedSystem {
+
+ private static final String SERVERS = "servers";
+ private static final String LOCATORS_NAME = LOCATORS;
+ private static final String PEERS = "peers";
+ private static final String HOSTS = "hosts";
+ private static final String REGIONS = "regions";
+ private static final String CLIENTS = "clients";
+ private static final String SEP = ".";
+ private static final String FUNCTIONS = null;
+ private static final String CQS = null;
+
+
+ List<Server> servers = new ArrayList<Server>();
+ List<Client> clients = new ArrayList<Client>();
+ List<Locator> locators = new ArrayList<Locator>();
+ List<Peer> peers = new ArrayList<Peer>();
+ List<Host> hosts = new ArrayList<Host>();
+ List<Region> regions = new ArrayList<Region>();
+ List<Function> functions = new ArrayList<Function>();
+ List<CQ> cqs = new ArrayList<CQ>();
+ String dsName = null;
+
+ public GemFireDistributedSystem(String name,Properties pr){
+ PropFileHelper propertiesFile = new PropFileHelper(pr);
+ this.dsName = name;
+ readGemfireDS(propertiesFile);
+ }
+
+ public GemFireDistributedSystem(String name,String fileName) throws IOException{
+ PropFileHelper propertiesFile = new PropFileHelper(fileName);
+ this.dsName = name;
+ readGemfireDS(propertiesFile);
+ }
+
+ private void readGemfireDS(PropFileHelper propertiesFile) {
+ String serverStrings[] = propertiesFile.readValues(dsName + SEP + SERVERS);
+ System.out.println("Servers = " + serverStrings.length);
+ for(String serverName : serverStrings){
+ Server server = new Server();
+ server.init(propertiesFile,dsName,serverName);
+ servers.add(server);
+ }
+
+ String clientStrings[] = propertiesFile.readValues(dsName + SEP + CLIENTS);
+ System.out.println("Clients = " + clientStrings.length);
+ for(String clientName : clientStrings){
+ Client client = new Client();
+ client.init(propertiesFile,dsName,clientName);
+ clients.add(client);
+ }
+
+ String locatorStrings[] = propertiesFile.readValues(dsName + SEP + LOCATORS);
+ System.out.println("Locators = " + locatorStrings.length);
+ for(String locatorName : locatorStrings){
+ Locator locator = new Locator();
+ locator.init(propertiesFile,dsName,locatorName);
+ locators.add(locator);
+ }
+
+ String peerStrings[] = propertiesFile.readValues(dsName + SEP + PEERS);
+ System.out.println("Peers = " + peerStrings.length);
+ for(String peerName : peerStrings){
+ Peer peer = new Peer();
+ peer.init(propertiesFile,dsName,peerName);
+ peers.add(peer);
+ }
+
+ String hostsStrings[] = propertiesFile.readValues(dsName + SEP + HOSTS);
+ for(String hostName : hostsStrings){
+ Host host = new Host();
+ host.init(propertiesFile,dsName,hostName);
+ hosts.add(host);
+ }
+
+ String regionsStrings[] = propertiesFile.readValues(dsName + SEP + REGIONS);
+ for(String regionName : regionsStrings){
+ Region region = new Region();
+ region.init(propertiesFile,dsName,regionName);
+ regions.add(region);
+ }
+
+ String functionStrings[] = propertiesFile.readValues(dsName + SEP + FUNCTIONS);
+ for(String functionName : functionStrings){
+ Function function = new Function();
+ function.init(propertiesFile,dsName,functionName);
+ functions.add(function);
+ }
+
+ String cqStrings[] = propertiesFile.readValues(dsName + SEP + CQS);
+ for(String cqName : cqStrings){
+ CQ cq = new CQ();
+ cq.init(propertiesFile,dsName,cqName);
+ cqs.add(cq);
+ }
+
+ }
+
+ public List<Region> getRegions(String memberName) {
+ List<Region> list = new ArrayList<Region>();
+ for(Region r : regions){
+ if(r.getMembers().contains(memberName))
+ list.add(r);
+ }
+ return list;
+ }
+
+ public Region getRegion(String regionName) {
+ Region r = null;
+ for (Region rn : getRegions()) {
+ if (rn.getName().equals(regionName)) {
+ r = rn;
+ break;
+ }
+ }
+ return r;
+ }
+
+ public List<Region> getRegions() {
+ return regions;
+ }
+
+ public List<Function> getFunction() {
+ return functions;
+ }
+
+ public List<CQ> getCQs() {
+ return cqs;
+ }
+
+ public List<Server> getServers(){
+ return servers;
+ }
+
+ public List<Client> getClients(){
+ return clients;
+ }
+
+ public List<Peer> getPeers(){
+ return peers;
+ }
+
+ public List<Locator> getLocators(){
+ return locators;
+ }
+
+ public List<Host> getPhysicalHosts(){
+ return hosts;
+ }
+
+ public static class Base{
+ protected Map<String,String> properties=null;
+ protected String name;
+
+ public void init(PropFileHelper propertiesFile, String dsName, String name) {
+ this.name = name;
+ String leadingkey = dsName + SEP + name;
+ Map<String,String> map = propertiesFile.readObject(leadingkey);
+ map.put("name",name);
+ this.properties = map;
+ }
+
+ public String getName(){
+ return properties.get("name");
+ }
+
+ public String key(String string) {
+ return properties.get(string);
+ }
+
+ public int keyInt(String string) {
+ String str = properties.get(string);
+ try{
+ int index = Integer.parseInt(str);
+ return index;
+ }catch(Exception e){
+ return -1;
+ }
+ }
+
+ public List<String> values(String string) {
+ String values= properties.get(string);
+ String array[] = values.split(",");
+ List<String> list = new ArrayList<String>();
+ for(String s:array)
+ list.add(s);
+ return list;
+ }
+
+ }
+
+ public static class Host extends Base{
+
+ }
+
+ public static class Server extends Base{
+ public String toString(){
+ return properties.get("name") + "[on host=" + properties.get("host");
+ }
+
+ public String getHost(){
+ return properties.get("host");
+ }
+ }
+
+ public static class Client extends Base{
+ public String toString(){
+ return properties.get("name") ;//+ "[on host=" + properties.get("host");
+ }
+
+ public String getHost(){
+ return properties.get("host");
+ }
+ }
+
+ public static class Locator extends Base{
+ public String getHost(){
+ return properties.get("host");
+ }
+ }
+
+ public static class Peer extends Base{
+
+ public String getHost(){
+ return properties.get("host");
+ }
+ }
+
+ public static class Region extends Base{
+ public String toString(){
+ return properties.get("name") + "[type=" + properties.get("type");
+ }
+
+ public String getType(){
+ return key("type");
+ }
+
+ public int getEntryCount(){
+ return keyInt("entryCount");
+ }
+
+ public List<String> getWanSenders(){
+ return values("wanSenders");
+ }
+
+ public List<String> getMembers(){
+ return values("members");
+ }
+
+ }
+
+ public static class WanSender extends Base{
+
+ }
+
+ public static class Function extends Base{
+ public String getMemberId(){
+ return key("memberId");
+ }
+ }
+
+ public static class CQ extends Base{
+ public String getQuery(){
+ return key("query");
+ }
+
+ public String getClient(){
+ return key("client");
+ }
+ }
+
+ public static class SystemAlert extends Base{
+ //TODO
+ }
+
+ public static void main(String[] args) throws IOException {
+
+ GemFireDistributedSystem ds = new GemFireDistributedSystem("t1", "config/testbed.properties");
+ System.out.println("Servers = " + ds.getServers());
+ System.out.println("Regions = " + ds.getRegions());
+ System.out.println("Clients = " + ds.getClients());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemfireTopology.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemfireTopology.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemfireTopology.java
new file mode 100644
index 0000000..6470195
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/GemfireTopology.java
@@ -0,0 +1,24 @@
+/*
+ *
+ * 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.testbed;
+
+public class GemfireTopology {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropFileHelper.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropFileHelper.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropFileHelper.java
new file mode 100644
index 0000000..1892292
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropFileHelper.java
@@ -0,0 +1,115 @@
+/*
+ *
+ * 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.testbed;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+public class PropFileHelper {
+
+ private String filePath=null;
+ private Properties pr=null;
+
+ public PropFileHelper(String filePath) throws FileNotFoundException, IOException{
+ this.filePath = filePath;
+ pr = new Properties();
+ pr.load(new FileInputStream(new File(this.filePath)));
+ }
+
+ public PropFileHelper(Properties pr2) {
+ this.pr =pr2;
+ }
+
+ public String[] readValues(String property){
+ return readValues(property,",");
+ }
+
+ public String[] readValues(String property, String separator){
+ String value = readKey(property);
+ if(value!=null){
+ String[] array = value.split(separator);
+ return array;
+ }else{
+ return new String[0];
+ }
+ }
+
+ public String readKey(String key){
+ String value = pr.getProperty(key);
+ if(value!=null)
+ return value.trim();
+ else return value;
+ }
+
+ public Map<String,String> readObject(String leadingkey){
+ Map<String,String> map = new HashMap<String,String>();
+ String leadingKeyString = leadingkey+".";
+ for(Object keyObject : pr.keySet()){
+ String key = (String)keyObject;
+ String value = readKey(key);
+ if(key.startsWith(leadingKeyString)){
+ String innerProp = key.substring(leadingKeyString.length());
+ /* inner object stuff
+ if(checkForMultipleValues){
+ if(innerProp.contains(separator)){
+ String array[] = readValues(key);
+ }
+ }else*/
+ {
+ //System.out.println("Adding prop with key " + innerProp + " k=" + leadingkey);
+ map.put(innerProp, value);
+ }
+ }
+ }
+ return map;
+ }
+
+ public static void main(String[] args) {
+
+ Properties pr = new Properties();
+ pr.put("topologies", "t1,t2");
+ pr.put("t1.id", "1");
+ pr.put("t2.id", "2");
+
+ pr.put("t1.prop1", "prop11");
+ pr.put("t1.prop2", "prop12");
+ pr.put("t1.prop3", "prop13");
+ pr.put("t2.prop1", "1");
+ pr.put("t2.prop2", "2");
+ pr.put("t2.prop3", "3");
+
+ PropFileHelper helper = new PropFileHelper(pr);
+ String topologies[] = helper.readValues("topologies");
+ for(String topology : topologies){
+ Map<String,String> topologyMap = helper.readObject(topology);
+ System.out.println(topologyMap);
+ }
+
+ }
+
+ public Properties getProperties() {
+ return pr;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
new file mode 100644
index 0000000..007be75
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
@@ -0,0 +1,513 @@
+/*
+ *
+ * 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.testbed;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.Cluster.Alert;
+import com.vmware.geode.tools.pulse.internal.data.Cluster.Client;
+import com.vmware.geode.tools.pulse.internal.data.Cluster.GatewayReceiver;
+import com.vmware.geode.tools.pulse.internal.data.Cluster.GatewaySender;
+import com.vmware.geode.tools.pulse.internal.data.Cluster.Member;
+import com.vmware.geode.tools.pulse.internal.data.Cluster.Region;
+import com.vmware.geode.tools.pulse.internal.data.IClusterUpdater;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Locator;
+import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Peer;
+import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Server;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.ResourceBundle;
+
+public class PropMockDataUpdater implements IClusterUpdater {
+ private static final int MAX_HOSTS = 40;
+ private static final PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+ private final ResourceBundle resourceBundle = Repository.get().getResourceBundle();
+ private static final int POLL_INTERVAL = 5000;
+ public static final int MAX_SAMPLE_SIZE = 180;
+ public static final int ALERTS_MAX_SIZE = 1000;
+ public static final int PAGE_ALERTS_MAX_SIZE = 100;
+
+ private Cluster cluster= null;
+ private TestBed testbed;
+ private final String testbedFile = System.getProperty("pulse.propMockDataUpdaterFile");;
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ public PropMockDataUpdater(Cluster cluster) {
+ this.cluster = cluster;
+ try {
+ loadPropertiesFile();
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void loadPropertiesFile() throws FileNotFoundException, IOException{
+ this.testbed = new TestBed(testbedFile,true);
+ }
+
+ /**
+ * function used for updating Cluster data
+ * for Mock
+ */
+ @Override
+ public boolean updateData() {
+ cluster.setConnectedFlag(true);
+ Random r = new Random(System.currentTimeMillis());
+ long totalHeapSize = Math.abs(r.nextInt(3200 - 2048) + 2048);
+ cluster.setTotalHeapSize(totalHeapSize);
+ long usedHeapSize = Math.abs(r.nextInt(2048));
+ cluster.setUsedHeapSize(usedHeapSize);
+ double writePerSec = Math.abs(r.nextInt(100));
+ cluster.setWritePerSec(writePerSec);
+
+ //propfile
+ cluster.setSubscriptionCount(testbed.getRootDs().getClients().size());
+ cluster.setRegisteredCQCount((long) testbed.getRootDs().getCQs().size());
+ cluster.setRunningFunctionCount(testbed.getRootDs().getFunction().size());
+
+
+ cluster.setClusterId( Math.abs(r.nextInt(100)));
+ cluster.getWritePerSecTrend().add(writePerSec);
+ cluster.setDiskWritesRate(writePerSec);
+
+ long garbageCollectionCount = Math.abs(r.nextInt(100));
+ cluster.setGarbageCollectionCount(garbageCollectionCount);
+ cluster.getGarbageCollectionTrend().add(garbageCollectionCount);
+
+ long readPerSec = Math.abs(r.nextInt(100));
+ cluster.setReadPerSec(readPerSec);
+ cluster.getReadPerSecTrend().add(readPerSec);
+
+ long diskReadsRate = readPerSec;cluster.setDiskReadsRate(diskReadsRate);
+ cluster.setDiskReadsRate(readPerSec);
+ long queriesPerSec = Math.abs(r.nextInt(100));
+ cluster.setQueriesPerSec(queriesPerSec);
+ cluster.getQueriesPerSecTrend().add(queriesPerSec);
+
+ long loadPerSec = Math.abs(r.nextInt(100));
+ cluster.setLoadPerSec(loadPerSec);
+ cluster.setTotalHeapSize(totalHeapSize);
+ long totalBytesOnDisk = totalHeapSize;
+ cluster.setTotalBytesOnDisk(totalBytesOnDisk);
+
+ cluster.getTotalBytesOnDiskTrend().add(totalBytesOnDisk);
+
+ cluster.getMemoryUsageTrend().add(usedHeapSize);
+ cluster.getThroughoutWritesTrend().add(writePerSec);
+
+ cluster.setMemberCount(0);
+
+ Map<String,Cluster.Member> membersHMap = cluster.getMembersHMap();
+ List<Cluster.Region> regionsList = (List<Cluster.Region>)cluster.getClusterRegions().values();
+ Map<String, Boolean> wanInformation = cluster.getWanInformation();
+
+ // Create 3 members first time around
+ int locatorCount=0;
+ if (membersHMap.size() == 0) {
+ for(Locator locator : testbed.getRootDs().getLocators()){
+ String id = "(Launcher_Locator-1099-13-40-24-5368)-"+locatorCount++;
+ String name = locator.getName();
+ membersHMap.put(id+name, initializeMember(id,name, true, true, true, false, locator.getHost()));
+ }
+ cluster.setLocatorCount(testbed.getRootDs().getLocators().size());
+
+ int serverCount=0;
+ for(Server server : testbed.getRootDs().getServers()){
+ String id = "(Launcher_Server-1099-13-40-24-5368)-"+serverCount++;
+ String name = server.getName();
+ membersHMap.put(id+name, initializeMember(id,name, false, true, false, true, server.getHost()));
+ }
+ cluster.setServerCount(testbed.getRootDs().getServers().size());
+
+ int peerCount=0;
+ for(Peer peer : testbed.getRootDs().getPeers()){
+ String id = "(Launcher_Peer-1099-13-40-24-5368)-"+peerCount++;
+ String name = peer.getName();
+ membersHMap.put( id+name, initializeMember(id,name, false, true, false, false, peer.getHost()));
+ }
+
+ for(Entry<String, Member> memberSet : membersHMap.entrySet())
+ {
+ HashMap<String,Cluster.Region> memberRegions = new HashMap<String,Cluster.Region>();
+ HashMap<String,Cluster.Client> memberClientsHM = new HashMap<String,Cluster.Client>();
+
+ Random randomGenerator = new Random();
+
+ //Read from property file
+ int randomInt = (randomGenerator.nextInt(5)) + 1;
+ List<com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Region> thisMemberRegions = testbed.getRootDs().getRegions(memberSet.getValue().getName());
+
+ int regionExists = 0;
+ int index=0;
+ for (com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Region thisMemberRegion : thisMemberRegions) {
+ Region region = initMemberRegion(index++,thisMemberRegion.getName(),memberSet.getValue().getName(),
+ thisMemberRegion.getEntryCount(),thisMemberRegion.getType(), thisMemberRegion.getMembers().size()); //read from property file
+ if (regionsList.size() > 0) {
+ for (Region clusterRegion : regionsList) {
+ if ((region.getName()).equals(clusterRegion.getName())) {
+ clusterRegion.getMemberName().add(memberSet.getValue().getName());
+ //clusterRegion.memberCount = clusterRegion.memberCount + 1;
+ //int mcount = clusterRegion.getMemberCount() + 1;
+ //clusterRegion.setMemberCount(mcount);
+ regionExists = 1;
+ break;
+ }
+ }
+ if (regionExists == 0){
+ regionsList.add(region);
+ }
+ } else{
+ regionsList.add(region);
+ }
+ memberRegions.put(region.getFullPath(),region);
+ //totalRegionCount = regionsList.size();
+ cluster.setTotalRegionCount(regionsList.size());
+ }
+ membersHMap.get(memberSet.getKey()).setMemberRegions(memberRegions);
+
+ if (memberSet.getValue().isCache()) {
+ Client client = initMemberClient(0, memberSet.getValue().getHost()); //read from prop File
+ memberClientsHM.put(client.getId(), client);
+ randomInt = randomGenerator.nextInt(10);
+ for (int y = 1; y < randomInt; y++) {
+ Client newClient = initMemberClient(y, memberSet.getValue()
+ .getHost());
+ memberClientsHM.put(newClient.getId(), newClient);
+ }
+ membersHMap.get(memberSet.getKey()).updateMemberClientsHMap(memberClientsHM);
+ /*clientConnectionCount = clientConnectionCount
+ + membersHMap.get(memberSet.getKey()).getMemberClientsHMap().size();*/
+ long clientConnectionCount = cluster.getClientConnectionCount() + membersHMap.get(memberSet.getKey()).getMemberClientsHMap().size();
+ cluster.setClientConnectionCount(clientConnectionCount);
+ }
+
+ }
+ }
+ wanInformation.clear(); //read from property file
+ int wanInfoSize = Math.abs(r.nextInt(10));
+ wanInfoSize++;
+ for (int i = 0; i < wanInfoSize; i++) {
+ String name = "Mock Cluster" + i;
+ Boolean value = false;
+ if (i % 2 == 0){
+ value = true;
+ }
+ wanInformation.put(name, value);
+ }
+ //memberCount = membersHMap.size();
+ cluster.setMemberCount(membersHMap.size());
+
+ totalHeapSize = 0;
+ for(Entry<String, Member> memberSet : membersHMap.entrySet())
+ {
+ refresh(membersHMap.get(memberSet.getKey()));
+ Member member = membersHMap.get(memberSet.getKey());
+ totalHeapSize += member.getCurrentHeapSize();
+ }
+
+ for (Region region : regionsList) {
+ region.setGetsRate((Math.abs(r.nextInt(100))) + 1);
+ region.setPutsRate((Math.abs(r.nextInt(100))) +1);
+ region.getGetsPerSecTrend().add(region.getGetsRate());
+ region.getPutsPerSecTrend().add(region.getPutsRate());
+ }
+
+ return true;
+ }
+
+
+ private Region initMemberRegion(int count, String regionName, String memName, int entryCount, String type, int memberCount) {
+ Region memberRegion = new Region();
+ memberRegion.setName(regionName);
+ memberRegion.setFullPath("/"+regionName);
+ Random randomGenerator = new Random();
+ memberRegion.setSystemRegionEntryCount(entryCount);
+ // memberRegion.setEntrySize("N/A");
+ memberRegion.setEntrySize(Math.abs(randomGenerator.nextInt(10)));
+ memberRegion.setDiskStoreName("ABC");
+ memberRegion.setScope("DISTRIBUTED_NO_ACK");
+ memberRegion.setDiskSynchronous(true);
+ memberRegion.setRegionType(type);
+ if(type.contains("PERSISTENT"))
+ memberRegion.setPersistentEnabled(true);
+ else
+ memberRegion.setPersistentEnabled(false);
+ if (count % 2 == 0){
+ memberRegion.setWanEnabled(true);
+ }
+ else{
+ memberRegion.setWanEnabled(false);
+ }
+ memberRegion.setWanEnabled(true);
+ /*memberRegion.setSystemRegionEntryCount(Long.valueOf(String.valueOf(Math
+ .abs(randomGenerator.nextInt(100)))));*/
+ memberRegion.getMemberName().add(memName);
+ memberRegion.setMemberCount(memberCount);
+ return memberRegion;
+ }
+
+
+ private Client initMemberClient(int count, String host) {
+
+ Client memberClient = new Client();
+ Random r = new Random(System.currentTimeMillis());
+ memberClient.setName("Name_" + count);
+ long processCpuTime = (long) (r.nextDouble() * 100);
+ memberClient.setProcessCpuTime(processCpuTime);
+ memberClient.setCpuUsage(0);
+ memberClient.setGets(Math.abs(r.nextInt(100)));
+ memberClient.setHost(host);
+ memberClient.setId(String.valueOf(1000 + count));
+ memberClient.setPuts(Math.abs(r.nextInt(100)));
+ memberClient.setCpus(Math.abs(r.nextInt(20)));
+ memberClient.setQueueSize(Math.abs(r.nextInt(100)));
+ if ((count % 2) == 0){
+ memberClient.setStatus("up");
+ }
+ else{
+ memberClient.setStatus("down");
+ }
+ memberClient.setThreads(Math.abs(r.nextInt(100)));
+ memberClient
+ .setUptime(Math.abs(System.currentTimeMillis() - r.nextLong()));
+
+ return memberClient;
+ }
+
+ private Member initializeMember(String id, String name, boolean manager,
+ boolean isCache, boolean isLocator, boolean isServer, String host) {
+ Member m = new Member();
+
+ m.setId(id);
+ m.setName(name);
+
+ //m.setHost(getHostName(System.currentTimeMillis()));
+ m.setHost(host);
+
+ m.setMaxHeapSize(247);
+
+ Random r = new Random(System.currentTimeMillis());
+
+ m.setCache(isCache);
+ m.setLocator(isLocator);
+ m.setServer(isServer);
+ m.setManager(manager);
+
+ m.setLoadAverage((double) Math.abs(r.nextInt(100)));
+ m.setNumThreads(Math.abs(r.nextInt(100)));
+ m.setGarbageCollectionCount((long) Math.abs(r.nextInt(100)));
+ m.getGarbageCollectionSamples().add(m.getGarbageCollectionCount());
+
+ m.setTotalFileDescriptorOpen((long) Math.abs(r.nextInt(100)));
+ m.setTotalDiskUsage(Math.abs(r.nextInt(100)));
+
+
+ m.setThroughputWrites(Math.abs(r.nextInt(10)));
+ m.getThroughputWritesTrend().add(m.getThroughputWrites());
+
+ GatewayReceiver gatewayReceiver = m.getGatewayReceiver();
+ String port = cluster.getPort();
+ if(port==null || "".equals(port))
+ port = "1099";
+ gatewayReceiver.setListeningPort(Integer.parseInt(port));
+ gatewayReceiver.setLinkThroughput(Math.abs(r.nextInt(10)));
+ gatewayReceiver.setAvgBatchProcessingTime((long) Math.abs(r.nextInt(10)));
+ gatewayReceiver.setId(String.valueOf(Math.abs(r.nextInt(10))));
+ gatewayReceiver.setQueueSize(Math.abs(r.nextInt(10)));
+ gatewayReceiver.setStatus(true);
+ gatewayReceiver.setBatchSize(Math.abs(r.nextInt(10)));
+
+ int gatewaySenderCount = Math.abs(r.nextInt(10));
+
+ List<GatewaySender> list = m.getGatewaySenderList();
+
+ for (int i = 0; i < gatewaySenderCount; i++) {
+ list.add(createGatewaySenderCount(r));
+ }
+
+ Map<String, List<Member>> physicalToMember = cluster.getPhysicalToMember();
+
+ List<Cluster.Member> memberArrList = physicalToMember.get(m.getHost());
+ if (memberArrList != null){
+ memberArrList.add(m);
+ }
+ else {
+ ArrayList<Cluster.Member> memberList = new ArrayList<Cluster.Member>();
+ memberList.add(m);
+ physicalToMember.put(m.getHost(), memberList);
+ }
+ int memberCount = cluster.getMemberCount();memberCount++;cluster.setMemberCount(memberCount);
+ return m;
+ }
+
+ private GatewaySender createGatewaySenderCount(Random r) {
+
+ GatewaySender gatewaySender = new GatewaySender();
+
+ gatewaySender.setBatchSize(Math.abs(r.nextInt(10)));
+ gatewaySender.setId(String.valueOf(Math.abs(r.nextInt(10))));
+ gatewaySender.setLinkThroughput(Math.abs(r.nextInt(10)));
+ gatewaySender.setPersistenceEnabled(true);
+ gatewaySender.setPrimary(true);
+ gatewaySender.setQueueSize(Math.abs(r.nextInt(10)));
+ gatewaySender.setSenderType(false);
+ gatewaySender.setStatus(true);
+
+ return gatewaySender;
+ }
+
+ /*
+ private String getHostName(long rndSeed) {
+ Random rnd = new Random(rndSeed);
+ String hName = null;
+
+ int index = Math.abs(rnd.nextInt(MAX_HOSTS));
+
+ ArrayList<String> hostNames = cluster.getHostNames();
+
+ if (hostNames.size() <= index) {
+ hName = "host" + hostNames.size();
+ hostNames.add(hName);
+ } else {
+ hName = hostNames.get(index);
+ }
+
+ Map<String, ArrayList<Member>> physicalToMember = cluster.getPhysicalToMember();
+
+ ArrayList<Member> memberArrList = physicalToMember.get(hName);
+ if (memberArrList != null) {
+ if (memberArrList.size() > 4){
+ hName = getHostName(rndSeed + rnd.nextLong());
+ }
+ }
+ return hName;
+ }*/
+
+ private void refresh(Member m) {
+ if(LOGGER.infoEnabled()){
+ LOGGER.info(resourceBundle.getString("LOG_MSG_REFRESHING_MEMBER_DATA")+" : " + m.getName());
+ }
+
+ Random r = new Random(System.currentTimeMillis());
+
+ m.setUptime(System.currentTimeMillis());
+ m.setQueueBacklog("" + Math.abs(r.nextInt(500)));
+ m.setCurrentHeapSize(Math.abs(r.nextInt(Math.abs((int) m.getMaxHeapSize()))));
+ m.setTotalDiskUsage(Math.abs(r.nextInt(100)));
+
+ double cpuUsage = r.nextDouble() * 100;
+ m.getCpuUsageSamples().add(cpuUsage);
+ m.setCpuUsage(cpuUsage);
+
+ m.getHeapUsageSamples().add(m.getCurrentHeapSize());
+ m.setLoadAverage((double) Math.abs(r.nextInt(100)));
+ m.setNumThreads(Math.abs(r.nextInt(100)));
+ m.setGarbageCollectionCount((long) Math.abs(r.nextInt(100)));
+ m.getGarbageCollectionSamples().add(m.getGarbageCollectionCount());
+
+ m.setTotalFileDescriptorOpen((long) Math.abs(r.nextInt(100)));
+
+ m.setThroughputWrites(Math.abs(r.nextInt(10)));
+ m.getThroughputWritesTrend().add(m.getThroughputWrites());
+
+ m.setGetsRate(Math.abs(r.nextInt(5000)));
+ m.getGetsPerSecond().add(m.getGetsRate());
+
+ m.setPutsRate(Math.abs(r.nextInt(5000)));
+ m.getPutsPerSecond().add(m.getPutsRate());
+
+ Alert[] alerts = cluster.getAlertsList();
+ List<Alert> alertsList = Arrays.asList(alerts);
+
+ if (r.nextBoolean()) {
+ // Generate alerts
+ if (r.nextBoolean()) {
+ if (r.nextInt(10) > 5) {
+ alertsList.add(createAlert(Alert.SEVERE, m.getName(), alertsList.size()));
+ if(alertsList.size() > ALERTS_MAX_SIZE){
+ alertsList.remove(0);
+ }
+ }
+ }
+
+ if (r.nextBoolean()) {
+ if (r.nextInt(10) > 5) {
+ alertsList.add(createAlert(Alert.ERROR, m.getName(), alertsList.size()));
+ if(alertsList.size() > ALERTS_MAX_SIZE){
+ alertsList.remove(0);
+ }
+ }
+ }
+
+ if (r.nextBoolean()) {
+ if (r.nextInt(10) > 5) {
+ alertsList.add(createAlert(Alert.WARNING, m.getName(), alertsList.size()));
+ if(alertsList.size() > ALERTS_MAX_SIZE){
+ alertsList.remove(0);
+ }
+ }
+ }
+ }
+ }
+
+ private Alert createAlert(int sev, String memberName, int index) {
+
+ Alert alert = new Alert();
+ alert.setSeverity(sev);
+ alert.setId(index);
+ alert.setMemberName(memberName);
+ alert.setTimestamp(new Date());
+
+ switch (sev) {
+ case Alert.SEVERE:
+ alert.setDescription(PulseConstants.ALERT_DESC_SEVERE);
+ break;
+ case Alert.ERROR:
+ alert.setDescription(PulseConstants.ALERT_DESC_ERROR);
+ break;
+ case Alert.WARNING:
+ alert.setDescription(PulseConstants.ALERT_DESC_WARNING);
+ break;
+ }
+ return alert;
+ }
+
+ @Override
+ public ObjectNode executeQuery(String queryText, String members, int limit) {
+ // TODO for Sushant/Sachin - Add implementation for MockUpdater for Automation
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/TestBed.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/TestBed.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/TestBed.java
new file mode 100644
index 0000000..ba04c32
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/TestBed.java
@@ -0,0 +1,84 @@
+/*
+ *
+ * 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.testbed;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public class TestBed {
+
+ private String fileName=null;
+ PropFileHelper propertiesFile =null;
+ GemFireDistributedSystem ds = null;
+
+ public TestBed(){
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ InputStream inputStream = classLoader.getResourceAsStream("testbed.properties");
+ Properties properties = new Properties();
+ try {
+ properties.load(inputStream);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ propertiesFile = new PropFileHelper(properties);
+ ds = new GemFireDistributedSystem("t1", propertiesFile.getProperties());
+ }
+
+ public TestBed(String fileName) throws FileNotFoundException, IOException{
+ this.fileName = fileName;
+ propertiesFile = new PropFileHelper(fileName);
+ ds = new GemFireDistributedSystem("t1", propertiesFile.getProperties());
+ }
+
+
+ public TestBed(String fileName,boolean flag) throws FileNotFoundException, IOException{
+// ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+// InputStream inputStream = classLoader.getResourceAsStream("testbed.properties");
+// System.out.println("Inputstream : " + inputStream);
+ Properties properties = new Properties();
+ try {
+ properties.load(new FileInputStream(new File(fileName)));
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ this.fileName = fileName;
+ propertiesFile = new PropFileHelper(properties);
+ ds = new GemFireDistributedSystem("t1", propertiesFile.getProperties());
+ }
+
+
+ public String getBrowserForDriver(){
+ return propertiesFile.readKey("browser");
+ }
+
+ public String getBrowserVersionForDriver(String browser){
+ return propertiesFile.readKey("browserVersion");
+ }
+
+ public GemFireDistributedSystem getRootDs(){
+ return ds;
+ }
+
+}
\ No newline at end of file
[31/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/Cluster.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/Cluster.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/Cluster.java
deleted file mode 100644
index 786861f..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/Cluster.java
+++ /dev/null
@@ -1,3815 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.data;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.apache.commons.collections.buffer.CircularFifoBuffer;
-
-import javax.management.remote.JMXConnector;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.net.ConnectException;
-import java.net.URL;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Random;
-import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.TimeZone;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-/**
- * Class Cluster This class is the Data Model for the data used for the Pulse
- * Web UI.
- *
- * @since GemFire version 7.0.Beta 2012-09-23
- */
-public class Cluster extends Thread {
- private static final int POLL_INTERVAL = 5000;
- public static final int MAX_SAMPLE_SIZE = 180;
- public static final int ALERTS_MAX_SIZE = 1000;
- public static final int PAGE_ALERTS_MAX_SIZE = 100;
-
- private final PulseLogWriter LOGGER = PulseLogWriter.getLogger();
- private final ResourceBundle resourceBundle = Repository.get()
- .getResourceBundle();
-
- private String jmxUserName;
- private String jmxUserPassword;
- private String serverName;
- private String port;
- private int stale = 0;
- private double loadPerSec;
-
- // start: fields defined in System MBean
- private IClusterUpdater updater = null;
- private DataBrowser dataBrowser = null;
- private int memberCount;
- private long clientConnectionCount;
- private int locatorCount;
- private int totalRegionCount;
- private long totalHeapSize = 0L;
- private long totalRegionEntryCount;
- private int currentQueryCount;
- private long totalBytesOnDisk;
- private double diskReadsRate;
- private double diskWritesRate;
- private double writePerSec;
- private double readPerSec;
- private double queriesPerSec;
- private int avgDiskStorage;
- private int avgDiskWritesRate;
- private int runningFunctionCount;
- private long registeredCQCount;
- private int subscriptionCount;
- private int serverCount;
- private int txnCommittedCount;
- private int txnRollbackCount;
- private long usedHeapSize = 0L;
- private long garbageCollectionCount = 0L;
- private int clusterId;
- private int notificationPageNumber = 1;
- private boolean connectedFlag;
- private String connectionErrorMsg = "";
-
- private Set<String> deletedMembers = new HashSet<String>();
-
- private Map<String, List<Cluster.Member>> physicalToMember = new HashMap<String, List<Cluster.Member>>();
-
- private Map<String, Cluster.Member> membersHMap = new HashMap<String, Cluster.Member>();
-
- private Set<String> deletedRegions = new HashSet<String>();
-
- private Map<String, Cluster.Region> clusterRegionMap = new ConcurrentHashMap<String, Cluster.Region>();
- private List<Cluster.Alert> alertsList = new ArrayList<Cluster.Alert>();
-
- private CircularFifoBuffer totalBytesOnDiskTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer throughoutWritesTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer throughoutReadsTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer writePerSecTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer readPerSecTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer queriesPerSecTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer memoryUsageTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer garbageCollectionTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private long previousJVMPauseCount = 0L;
-
- private HashMap<String, Boolean> wanInformation = new HashMap<String, Boolean>();
- private Map<String, Cluster.Statement> clusterStatementMap = new ConcurrentHashMap<String, Cluster.Statement>();
-
- public static final int CLUSTER_STAT_TOTAL_BYTES_ON_DISK = 0;
- public static final int CLUSTER_STAT_THROUGHPUT_WRITES = 1;
- public static final int CLUSTER_STAT_THROUGHPUT_READS = 2;
- public static final int CLUSTER_STAT_WRITES_PER_SECOND = 3;
- public static final int CLUSTER_STAT_READ_PER_SECOND = 4;
- public static final int CLUSTER_STAT_QUERIES_PER_SECOND = 5;
- public static final int CLUSTER_STAT_MEMORY_USAGE = 6;
- public static final int CLUSTER_STAT_GARBAGE_COLLECTION = 7;
-
- // end: fields defined in System MBean
-
- // used for updating member's client data
- public static long LAST_UPDATE_TIME = 0;
-
- public int getStaleStatus() {
- return this.stale;
- }
-
- private boolean stopUpdates = false;
-
- private static final int MAX_HOSTS = 40;
-
- private final List<String> hostNames = new ArrayList<String>();
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public Object[] getStatisticTrend(int trendId) {
-
- Object[] returnArray = null;
- switch (trendId) {
- case CLUSTER_STAT_TOTAL_BYTES_ON_DISK:
- synchronized (this.totalBytesOnDiskTrend) {
- returnArray = this.totalBytesOnDiskTrend.toArray();
- }
-
- break;
-
- case CLUSTER_STAT_THROUGHPUT_READS:
- synchronized (this.throughoutReadsTrend) {
- returnArray = this.throughoutReadsTrend.toArray();
- }
- break;
-
- case CLUSTER_STAT_THROUGHPUT_WRITES:
- synchronized (this.throughoutWritesTrend) {
- returnArray = this.throughoutWritesTrend.toArray();
- }
- break;
-
- case CLUSTER_STAT_WRITES_PER_SECOND:
- synchronized (this.writePerSecTrend) {
- returnArray = this.writePerSecTrend.toArray();
- }
- break;
-
- case CLUSTER_STAT_READ_PER_SECOND:
- synchronized (this.readPerSecTrend) {
- returnArray = this.readPerSecTrend.toArray();
- }
- break;
-
- case CLUSTER_STAT_QUERIES_PER_SECOND:
- synchronized (this.queriesPerSecTrend) {
- returnArray = this.queriesPerSecTrend.toArray();
- }
- break;
-
- case CLUSTER_STAT_MEMORY_USAGE:
- synchronized (this.memoryUsageTrend) {
- returnArray = this.memoryUsageTrend.toArray();
- }
- break;
-
- case CLUSTER_STAT_GARBAGE_COLLECTION:
- synchronized (this.garbageCollectionTrend) {
- returnArray = this.garbageCollectionTrend.toArray();
- }
- break;
- }
-
- return returnArray;
- }
-
- /**
- * Member Inner Class
- *
- *
- */
- public static class Member {
-
- // start: fields defined in MBean
- private String gemfireVersion;
- private boolean manager;
- private int totalRegionCount;
- private String host;
- private String hostnameForClients;
- private String bindAddress;
- private long currentHeapSize;
- private long maxHeapSize;
- private int avgHeapUsage;
- private long OffHeapFreeSize;
- private long OffHeapUsedSize;
- private long totalBytesOnDisk;
- private String memberPort;
-
- private double cpuUsage = 0.0d;
- private double hostCpuUsage = 0.0d;
- private long uptime;
- private String name;
- private double getsRate;
- private double putsRate;
- private boolean isCache;
- private boolean isGateway;
- private boolean isLocator;
- private boolean isServer;
- private double loadAverage;
- private int numThreads;
- private long totalFileDescriptorOpen;
- private long garbageCollectionCount = 0L;
- private double throughputWrites;
- private double throughputReads;
- private long totalDiskUsage;
- private String queueBacklog;
- private String id;
- private long numSqlfireClients = 0;
-
- private List<String> serverGroups = new ArrayList<String>();
- private List<String> redundancyZones = new ArrayList<String>();
-
- private CircularFifoBuffer cpuUsageSamples = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer heapUsageSamples = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private HashMap<String, Cluster.Region> memberRegions = new HashMap<String, Cluster.Region>();
- private HashMap<String, Cluster.Client> memberClientsHMap = new HashMap<String, Cluster.Client>();
- private CircularFifoBuffer totalBytesOnDiskSamples = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer getsPerSecond = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer putsPerSecond = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer throughputWritesTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer throughputReadsTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer garbageCollectionSamples = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private long previousJVMPauseCount = 0L;
-
- private Cluster.GatewayReceiver gatewayReceiver = null;
- private List<Cluster.GatewaySender> gatewaySenderList = new ArrayList<Cluster.GatewaySender>();
- private List<Cluster.AsyncEventQueue> asyncEventQueueList = new ArrayList<Cluster.AsyncEventQueue>();
- // end: fields defined in MBean
-
- public static final int MEMBER_STAT_GARBAGE_COLLECTION = 0;
- public static final int MEMBER_STAT_HEAP_USAGE_SAMPLE = 1;
- public static final int MEMBER_STAT_CPU_USAGE_SAMPLE = 2;
- public static final int MEMBER_STAT_GETS_PER_SECOND = 3;
- public static final int MEMBER_STAT_PUTS_PER_SECOND = 4;
- public static final int MEMBER_STAT_THROUGHPUT_WRITES = 5;
- public static final int MEMBER_STAT_THROUGHPUT_READS = 6;
-
- public Cluster.Region[] getMemberRegionsList() {
- Cluster.Region[] memberReg = null;
- synchronized (memberRegions) {
- memberReg = new Cluster.Region[memberRegions.size()];
- memberReg = memberRegions.values().toArray(memberReg);
- }
-
- return memberReg;
- }
-
- public Cluster.Client[] getMemberClients() {
- Cluster.Client[] memberClients = null;
- synchronized (memberClientsHMap) {
- memberClients = new Cluster.Client[memberClientsHMap.size()];
- memberClients = memberClientsHMap.values().toArray(memberClients);
- }
-
- return memberClients;
- }
-
- public Cluster.GatewaySender[] getMemberGatewaySenders() {
- Cluster.GatewaySender[] memberGWS = null;
- synchronized (gatewaySenderList) {
- memberGWS = new Cluster.GatewaySender[gatewaySenderList.size()];
- memberGWS = gatewaySenderList.toArray(memberGWS);
- }
- return memberGWS;
- }
-
- public Cluster.AsyncEventQueue[] getMemberAsyncEventQueueList() {
- Cluster.AsyncEventQueue[] memberAEQ = null;
- synchronized (asyncEventQueueList) {
- memberAEQ = new Cluster.AsyncEventQueue[asyncEventQueueList.size()];
- memberAEQ = asyncEventQueueList.toArray(memberAEQ);
- }
- return memberAEQ;
- }
-
- public Object[] getMemberStatisticTrend(int trendId) {
- Object[] returnArray = null;
- switch (trendId) {
- case MEMBER_STAT_GARBAGE_COLLECTION:
- synchronized (this.garbageCollectionSamples) {
- returnArray = this.garbageCollectionSamples.toArray();
- }
-
- break;
-
- case MEMBER_STAT_HEAP_USAGE_SAMPLE:
- synchronized (this.heapUsageSamples) {
- returnArray = this.heapUsageSamples.toArray();
- }
- break;
-
- case MEMBER_STAT_CPU_USAGE_SAMPLE:
- synchronized (this.cpuUsageSamples) {
- returnArray = this.cpuUsageSamples.toArray();
- }
- break;
-
- case MEMBER_STAT_GETS_PER_SECOND:
- synchronized (this.getsPerSecond) {
- returnArray = this.getsPerSecond.toArray();
- }
- break;
-
- case MEMBER_STAT_PUTS_PER_SECOND:
- synchronized (this.putsPerSecond) {
- returnArray = this.putsPerSecond.toArray();
- }
- break;
-
- case MEMBER_STAT_THROUGHPUT_WRITES:
- synchronized (this.throughputWritesTrend) {
- returnArray = this.throughputWritesTrend.toArray();
- }
- break;
-
- case MEMBER_STAT_THROUGHPUT_READS:
- synchronized (this.throughputReadsTrend) {
- returnArray = this.throughputReadsTrend.toArray();
- }
- break;
- }
-
- return returnArray;
- }
-
- public String getGemfireVersion() {
- return gemfireVersion;
- }
-
- public void setGemfireVersion(String gemfireVersion) {
- this.gemfireVersion = gemfireVersion;
- }
-
- public String getMemberPort() {
- return this.memberPort;
- }
-
- public void setMemberPort(String memberPort) {
- this.memberPort = memberPort;
- }
-
- public double getThroughputWrites() {
- return this.throughputWrites;
- }
-
- public void setThroughputWrites(double throughputWrites) {
- this.throughputWrites = throughputWrites;
- }
-
- public double getThroughputReads() {
- return this.throughputReads;
- }
-
- public void setThroughputReads(double throughputReads) {
- this.throughputReads = throughputReads;
- }
-
- public long getTotalDiskUsage() {
- return this.totalDiskUsage;
- }
-
- public void setTotalDiskUsage(long totalDiskUsage) {
- this.totalDiskUsage = totalDiskUsage;
- }
-
- public String getId() {
- return this.id;
- }
-
- public String getName() {
- return this.name;
- }
-
- public double getLoadAverage() {
- return this.loadAverage;
- }
-
- public void setLoadAverage(Double loadAverage) {
- this.loadAverage = loadAverage;
- }
-
- public String getHost() {
- return this.host;
- }
-
- public String getHostnameForClients() {
- if(StringUtils.isNotNullNotEmptyNotWhiteSpace(hostnameForClients))
- return this.hostnameForClients;
- else if(StringUtils.isNotNullNotEmptyNotWhiteSpace(bindAddress))
- return this.bindAddress;
- return null;
- }
-
- public long getUptime() {
- return this.uptime;
- }
-
- public String getQueueBacklog() {
- return this.queueBacklog;
- }
-
- public HashMap<String, Cluster.Region> getMemberRegions() {
- return this.memberRegions;
- }
-
- public void setMemberRegions(HashMap<String, Cluster.Region> memberRegions) {
- this.memberRegions = memberRegions;
- }
-
- public long getCurrentHeapSize() {
- return this.currentHeapSize;
- }
-
- public void setCurrentHeapSize(long currentHeapSize) {
- this.currentHeapSize = currentHeapSize;
- }
-
- public long getMaxHeapSize() {
- return this.maxHeapSize;
- }
-
- public void setMaxHeapSize(long maxHeapSize) {
- this.maxHeapSize = maxHeapSize;
- }
-
- public boolean isManager() {
- return this.manager;
- }
-
- public void setManager(boolean manager) {
- this.manager = manager;
- }
-
- public int getAvgHeapUsage() {
- return this.avgHeapUsage;
- }
-
- public void setAvgHeapUsage(int avgHeapUsage) {
- this.avgHeapUsage = avgHeapUsage;
- }
-
- public long getOffHeapFreeSize() {
- return OffHeapFreeSize;
- }
-
- public void setOffHeapFreeSize(long offHeapFreeSize) {
- this.OffHeapFreeSize = offHeapFreeSize;
- }
-
- public long getOffHeapUsedSize() {
- return OffHeapUsedSize;
- }
-
- public void setOffHeapUsedSize(long offHeapUsedSize) {
- this.OffHeapUsedSize = offHeapUsedSize;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public void setHostnameForClients(String hostnameForClients) {
- this.hostnameForClients = hostnameForClients;
- }
-
- public void setBindAddress(String bindAddress){
- this.bindAddress = bindAddress;
- }
-
- public void setUptime(long uptime) {
- this.uptime = uptime;
- }
-
- public void setQueueBacklog(String queueBacklog) {
- this.queueBacklog = queueBacklog;
- }
-
- public int getTotalRegionCount() {
- return this.totalRegionCount;
- }
-
- public void setTotalRegionCount(int totalRegionCount) {
- this.totalRegionCount = totalRegionCount;
- }
-
- public long getTotalBytesOnDisk() {
- return this.totalBytesOnDisk;
- }
-
- public void setTotalBytesOnDisk(long totalBytesOnDisk) {
- this.totalBytesOnDisk = totalBytesOnDisk;
- }
-
- public double getCpuUsage() {
- return this.cpuUsage;
- }
-
- public void setCpuUsage(double cpuUsage) {
- this.cpuUsage = cpuUsage;
- }
-
- public double getHostCpuUsage() {
- return this.hostCpuUsage;
- }
-
- public void setHostCpuUsage(double hostCpuUsage) {
- this.hostCpuUsage = hostCpuUsage;
- }
-
- public double getGetsRate() {
- return this.getsRate;
- }
-
- public void setGetsRate(double getsRate) {
- this.getsRate = getsRate;
- }
-
- public double getPutsRate() {
- return this.putsRate;
- }
-
- public void setPutsRate(double putsRate) {
- this.putsRate = putsRate;
- }
-
- public HashMap<String, Cluster.Client> getMemberClientsHMap() {
- return this.memberClientsHMap;
- }
-
- public void setMemberClientsHMap(
- HashMap<String, Cluster.Client> memberClientsHMap) {
- this.memberClientsHMap = memberClientsHMap;
- }
-
- public boolean isCache() {
- return this.isCache;
- }
-
- public void setCache(boolean isCache) {
- this.isCache = isCache;
- }
-
- public boolean isGateway() {
- return this.isGateway;
- }
-
- public void setGateway(boolean isGateway) {
- this.isGateway = isGateway;
- }
-
- public int getNumThreads() {
- return this.numThreads;
- }
-
- public void setNumThreads(int numThreads) {
- this.numThreads = numThreads;
- }
-
- public long getTotalFileDescriptorOpen() {
- return this.totalFileDescriptorOpen;
- }
-
- public void setTotalFileDescriptorOpen(long totalFileDescriptorOpen) {
- this.totalFileDescriptorOpen = totalFileDescriptorOpen;
- }
-
- public long getGarbageCollectionCount() {
- return this.garbageCollectionCount;
- }
-
- public void setGarbageCollectionCount(long garbageCollectionCount) {
- this.garbageCollectionCount = garbageCollectionCount;
- }
-
- public boolean isLocator() {
- return this.isLocator;
- }
-
- public void setLocator(boolean isLocator) {
- this.isLocator = isLocator;
- }
-
- public Cluster.GatewayReceiver getGatewayReceiver() {
- return this.gatewayReceiver;
- }
-
- public void setGatewayReceiver(Cluster.GatewayReceiver gatewayReceiver) {
- this.gatewayReceiver = gatewayReceiver;
- }
-
- public List<Cluster.GatewaySender> getGatewaySenderList() {
- return this.gatewaySenderList;
- }
-
- public void setGatewaySenderList(
- List<Cluster.GatewaySender> gatewaySenderList) {
- this.gatewaySenderList = gatewaySenderList;
- }
-
- public List<Cluster.AsyncEventQueue> getAsyncEventQueueList() {
- return this.asyncEventQueueList;
- }
-
- public void setAsyncEventQueueList(
- List<Cluster.AsyncEventQueue> asyncEventQueueList) {
- this.asyncEventQueueList = asyncEventQueueList;
- }
-
- public boolean isServer() {
- return this.isServer;
- }
-
- public void setServer(boolean isServer) {
- this.isServer = isServer;
- }
-
- public List<String> getServerGroups() {
- return this.serverGroups;
- }
-
- public void setServerGroups(List<String> serverGroups) {
- this.serverGroups = serverGroups;
- }
-
- public List<String> getRedundancyZones() {
- return this.redundancyZones;
- }
-
- public void setRedundancyZones(List<String> redundancyZones) {
- this.redundancyZones = redundancyZones;
- }
-
- public CircularFifoBuffer getCpuUsageSamples() {
- return this.cpuUsageSamples;
- }
-
- public void setCpuUsageSamples(CircularFifoBuffer cpuUsageSamples) {
- this.cpuUsageSamples = cpuUsageSamples;
- }
-
- public CircularFifoBuffer getHeapUsageSamples() {
- return this.heapUsageSamples;
- }
-
- public void setHeapUsageSamples(CircularFifoBuffer heapUsageSamples) {
- this.heapUsageSamples = heapUsageSamples;
- }
-
- public CircularFifoBuffer getTotalBytesOnDiskSamples() {
- return this.totalBytesOnDiskSamples;
- }
-
- public void setTotalBytesOnDiskSamples(
- CircularFifoBuffer totalBytesOnDiskSamples) {
- this.totalBytesOnDiskSamples = totalBytesOnDiskSamples;
- }
-
- public CircularFifoBuffer getGetsPerSecond() {
- return this.getsPerSecond;
- }
-
- public void setGetsPerSecond(CircularFifoBuffer getsPerSecond) {
- this.getsPerSecond = getsPerSecond;
- }
-
- public CircularFifoBuffer getPutsPerSecond() {
- return this.putsPerSecond;
- }
-
- public void setPutsPerSecond(CircularFifoBuffer putsPerSecond) {
- this.putsPerSecond = putsPerSecond;
- }
-
- public CircularFifoBuffer getThroughputWritesTrend() {
- return this.throughputWritesTrend;
- }
-
- public void setThroughputWritesTrend(
- CircularFifoBuffer throughputWritesTrend) {
- this.throughputWritesTrend = throughputWritesTrend;
- }
-
- public CircularFifoBuffer getThroughputReadsTrend() {
- return this.throughputReadsTrend;
- }
-
- public void setThroughputReadsTrend(CircularFifoBuffer throughputReadsTrend) {
- this.throughputReadsTrend = throughputReadsTrend;
- }
-
- public CircularFifoBuffer getGarbageCollectionSamples() {
- return this.garbageCollectionSamples;
- }
-
- public void setGarbageCollectionSamples(
- CircularFifoBuffer garbageCollectionSamples) {
- this.garbageCollectionSamples = garbageCollectionSamples;
- }
-
- public long getPreviousJVMPauseCount() {
- return this.previousJVMPauseCount;
- }
-
- public void setPreviousJVMPauseCount(long previousJVMPauseCount) {
- this.previousJVMPauseCount = previousJVMPauseCount;
- }
-
- public long getNumSqlfireClients() {
- return numSqlfireClients;
- }
-
- public void setNumSqlfireClients(long numSqlfireClients) {
- this.numSqlfireClients = numSqlfireClients;
- }
-
- public void updateMemberClientsHMap(
- HashMap<String, Cluster.Client> memberClientsHM) {
-
- if (Cluster.LAST_UPDATE_TIME == 0) {
- Cluster.LAST_UPDATE_TIME = System.nanoTime();
- }
-
- long systemNanoTime = System.nanoTime();
-
- for (Map.Entry<String, Cluster.Client> entry : memberClientsHM.entrySet()) {
- String clientId = entry.getKey();
- Cluster.Client client = entry.getValue();
-
- if (memberClientsHMap.get(clientId) != null) {
- Client existingClient = memberClientsHMap.get(clientId);
- Client updatedClient = memberClientsHM.get(clientId);
-
- existingClient.setConnected(updatedClient.isConnected());
- existingClient.setGets(updatedClient.getGets());
- existingClient.setPuts(updatedClient.getPuts());
- existingClient.setCpus(updatedClient.getCpus());
- existingClient.setQueueSize(updatedClient.getQueueSize());
- existingClient.setStatus(updatedClient.getStatus());
- existingClient.setThreads(updatedClient.getThreads());
- existingClient.setClientCQCount(updatedClient.getClientCQCount());
- existingClient.setSubscriptionEnabled(updatedClient.isSubscriptionEnabled());
- long elapsedTime = updatedClient.getUptime()
- - existingClient.getUptime();
- existingClient.setUptime(updatedClient.getUptime());
-
- // set cpu usage
- long lastCPUTime = 0;
- lastCPUTime = existingClient.getProcessCpuTime();
- long currCPUTime = 0;
- currCPUTime = updatedClient.getProcessCpuTime();
-
- double newCPUTime = (double) (currCPUTime - lastCPUTime)
- / (elapsedTime * 1000000000);
-
- double newCPUUsage = 0;
- int availableCpus = updatedClient.getCpus();
- if (availableCpus > 0) {
- newCPUUsage = newCPUTime / availableCpus;
- }
-
- existingClient.setCpuUsage(newCPUUsage);
- existingClient.setProcessCpuTime(currCPUTime);
-
- } else {
- // Add client to clients list
- memberClientsHMap.put(clientId, client);
- }
-
- }
-
- // Remove unwanted entries from clients list
- HashMap<String, Cluster.Client> memberClientsHMapNew = new HashMap<String, Cluster.Client>();
- for (Map.Entry<String, Cluster.Client> entry : memberClientsHMap
- .entrySet()) {
- String clientId = entry.getKey();
- if (memberClientsHM.get(clientId) != null) {
- memberClientsHMapNew.put(clientId, memberClientsHMap.get(clientId));
- }
- }
- // replace existing memberClientsHMap by memberClientsHMapNew
- this.setMemberClientsHMap(memberClientsHMapNew);
-
- // update last update time
- Cluster.LAST_UPDATE_TIME = systemNanoTime;
-
- }
-
- }
-
- /**
- * Member Inner Class
- *
- *
- */
- public static class Statement {
-
- private String queryDefn;
- private long numTimesCompiled;
- private long numExecution;
- private long numExecutionsInProgress;
- private long numTimesGlobalIndexLookup;
- private long numRowsModified;
- private long parseTime;
- private long bindTime;
- private long optimizeTime;
- private long routingInfoTime;
- private long generateTime;
- private long totalCompilationTime;
- private long executionTime;
- private long projectionTime;
- private long totalExecutionTime;
- private long rowsModificationTime;
- private long qNNumRowsSeen;
- private long qNMsgSendTime;
- private long qNMsgSerTime;
- private long qNRespDeSerTime;
-
- public static String[] getGridColumnNames() {
- String[] colNames = new String[] {
- PulseConstants.MBEAN_COLNAME_QUERYDEFINITION,
- PulseConstants.MBEAN_COLNAME_NUMEXECUTION,
- PulseConstants.MBEAN_COLNAME_TOTALEXECUTIONTIME,
- PulseConstants.MBEAN_COLNAME_NUMEXECUTIONSINPROGRESS,
- PulseConstants.MBEAN_COLNAME_NUMTIMESCOMPILED,
- PulseConstants.MBEAN_COLNAME_NUMTIMESGLOBALINDEXLOOKUP,
- PulseConstants.MBEAN_COLNAME_NUMROWSMODIFIED,
- PulseConstants.MBEAN_COLNAME_PARSETIME,
- PulseConstants.MBEAN_COLNAME_BINDTIME,
- PulseConstants.MBEAN_COLNAME_OPTIMIZETIME,
- PulseConstants.MBEAN_COLNAME_ROUTINGINFOTIME,
- PulseConstants.MBEAN_COLNAME_GENERATETIME,
- PulseConstants.MBEAN_COLNAME_TOTALCOMPILATIONTIME,
- PulseConstants.MBEAN_COLNAME_EXECUTIONTIME,
- PulseConstants.MBEAN_COLNAME_PROJECTIONTIME,
- PulseConstants.MBEAN_COLNAME_ROWSMODIFICATIONTIME,
- PulseConstants.MBEAN_COLNAME_QNNUMROWSSEEN,
- PulseConstants.MBEAN_COLNAME_QNMSGSENDTIME,
- PulseConstants.MBEAN_COLNAME_QNMSGSERTIME,
- PulseConstants.MBEAN_COLNAME_QNRESPDESERTIME };
- return colNames;
- }
-
- public static String[] getGridColumnAttributes() {
- String[] colAttributes = new String[] {
- PulseConstants.MBEAN_ATTRIBUTE_QUERYDEFINITION,
- PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTION,
- PulseConstants.MBEAN_ATTRIBUTE_TOTALEXECUTIONTIME,
- PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTIONSINPROGRESS,
- PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESCOMPILED,
- PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESGLOBALINDEXLOOKUP,
- PulseConstants.MBEAN_ATTRIBUTE_NUMROWSMODIFIED,
- PulseConstants.MBEAN_ATTRIBUTE_PARSETIME,
- PulseConstants.MBEAN_ATTRIBUTE_BINDTIME,
- PulseConstants.MBEAN_ATTRIBUTE_OPTIMIZETIME,
- PulseConstants.MBEAN_ATTRIBUTE_ROUTINGINFOTIME,
- PulseConstants.MBEAN_ATTRIBUTE_GENERATETIME,
- PulseConstants.MBEAN_ATTRIBUTE_TOTALCOMPILATIONTIME,
- PulseConstants.MBEAN_ATTRIBUTE_EXECUTIONTIME,
- PulseConstants.MBEAN_ATTRIBUTE_PROJECTIONTIME,
-
- PulseConstants.MBEAN_ATTRIBUTE_ROWSMODIFICATIONTIME,
- PulseConstants.MBEAN_ATTRIBUTE_QNNUMROWSSEEN,
- PulseConstants.MBEAN_ATTRIBUTE_QNMSGSENDTIME,
- PulseConstants.MBEAN_ATTRIBUTE_QNMSGSERTIME,
- PulseConstants.MBEAN_ATTRIBUTE_QNRESPDESERTIME };
- return colAttributes;
- }
-
- public static int[] getGridColumnWidths() {
- int[] colWidths = new int[] { 300, 150, 160, 180, 150, 200, 150, 130, 130,
- 160, 140, 180, 170, 160, 130, 190, 170, 170, 170, 200 };
- return colWidths;
- }
-
- /**
- * @return the numTimesCompiled
- */
- public String getQueryDefinition() {
- return queryDefn;
- }
-
- /**
- * @param queryDefn
- * the query to set
- */
- public void setQueryDefinition(String queryDefn) {
- this.queryDefn = queryDefn;
- }
-
- /**
- * @return the numTimesCompiled
- */
- public long getNumTimesCompiled() {
- return numTimesCompiled;
- }
-
- /**
- * @param numTimesCompiled
- * the numTimesCompiled to set
- */
- public void setNumTimesCompiled(long numTimesCompiled) {
- this.numTimesCompiled = numTimesCompiled;
- }
-
- /**
- * @return the numExecution
- */
- public long getNumExecution() {
- return numExecution;
- }
-
- /**
- * @param numExecution
- * the numExecution to set
- */
- public void setNumExecution(long numExecution) {
- this.numExecution = numExecution;
- }
-
- /**
- * @return the numExecutionsInProgress
- */
- public long getNumExecutionsInProgress() {
- return numExecutionsInProgress;
- }
-
- /**
- * @param numExecutionsInProgress
- * the numExecutionsInProgress to set
- */
- public void setNumExecutionsInProgress(long numExecutionsInProgress) {
- this.numExecutionsInProgress = numExecutionsInProgress;
- }
-
- /**
- * @return the numTimesGlobalIndexLookup
- */
- public long getNumTimesGlobalIndexLookup() {
- return numTimesGlobalIndexLookup;
- }
-
- /**
- * @param numTimesGlobalIndexLookup
- * the numTimesGlobalIndexLookup to set
- */
- public void setNumTimesGlobalIndexLookup(long numTimesGlobalIndexLookup) {
- this.numTimesGlobalIndexLookup = numTimesGlobalIndexLookup;
- }
-
- /**
- * @return the numRowsModified
- */
- public long getNumRowsModified() {
- return numRowsModified;
- }
-
- /**
- * @param numRowsModified
- * the numRowsModified to set
- */
- public void setNumRowsModified(long numRowsModified) {
- this.numRowsModified = numRowsModified;
- }
-
- /**
- * @return the parseTime
- */
- public long getParseTime() {
- return parseTime;
- }
-
- /**
- * @param parseTime
- * the parseTime to set
- */
- public void setParseTime(long parseTime) {
- this.parseTime = parseTime;
- }
-
- /**
- * @return the bindTime
- */
- public long getBindTime() {
- return bindTime;
- }
-
- /**
- * @param bindTime
- * the bindTime to set
- */
- public void setBindTime(long bindTime) {
- this.bindTime = bindTime;
- }
-
- /**
- * @return the optimizeTime
- */
- public long getOptimizeTime() {
- return optimizeTime;
- }
-
- /**
- * @param optimizeTime
- * the optimizeTime to set
- */
- public void setOptimizeTime(long optimizeTime) {
- this.optimizeTime = optimizeTime;
- }
-
- /**
- * @return the routingInfoTime
- */
- public long getRoutingInfoTime() {
- return routingInfoTime;
- }
-
- /**
- * @param routingInfoTime
- * the routingInfoTime to set
- */
- public void setRoutingInfoTime(long routingInfoTime) {
- this.routingInfoTime = routingInfoTime;
- }
-
- /**
- * @return the generateTime
- */
- public long getGenerateTime() {
- return generateTime;
- }
-
- /**
- * @param generateTime
- * the generateTime to set
- */
- public void setGenerateTime(long generateTime) {
- this.generateTime = generateTime;
- }
-
- /**
- * @return the totalCompilationTime
- */
- public long getTotalCompilationTime() {
- return totalCompilationTime;
- }
-
- /**
- * @param totalCompilationTime
- * the totalCompilationTime to set
- */
- public void setTotalCompilationTime(long totalCompilationTime) {
- this.totalCompilationTime = totalCompilationTime;
- }
-
- /**
- * @return the executionTime
- */
- public long getExecutionTime() {
- return executionTime;
- }
-
- /**
- * @param executionTime
- * the executionTime to set
- */
- public void setExecutionTime(long executionTime) {
- this.executionTime = executionTime;
- }
-
- /**
- * @return the projectionTime
- */
- public long getProjectionTime() {
- return projectionTime;
- }
-
- /**
- * @param projectionTime
- * the projectionTime to set
- */
- public void setProjectionTime(long projectionTime) {
- this.projectionTime = projectionTime;
- }
-
- /**
- * @return the totalExecutionTime
- */
- public long getTotalExecutionTime() {
- return totalExecutionTime;
- }
-
- /**
- * @param totalExecutionTime
- * the totalExecutionTime to set
- */
- public void setTotalExecutionTime(long totalExecutionTime) {
- this.totalExecutionTime = totalExecutionTime;
- }
-
- /**
- * @return the rowsModificationTime
- */
- public long getRowsModificationTime() {
- return rowsModificationTime;
- }
-
- /**
- * @param rowsModificationTime
- * the rowsModificationTime to set
- */
- public void setRowsModificationTime(long rowsModificationTime) {
- this.rowsModificationTime = rowsModificationTime;
- }
-
- /**
- * @return the qNNumRowsSeen
- */
- public long getqNNumRowsSeen() {
- return qNNumRowsSeen;
- }
-
- /**
- * @param qNNumRowsSeen
- * the qNNumRowsSeen to set
- */
- public void setqNNumRowsSeen(long qNNumRowsSeen) {
- this.qNNumRowsSeen = qNNumRowsSeen;
- }
-
- /**
- * @return the qNMsgSendTime
- */
- public long getqNMsgSendTime() {
- return qNMsgSendTime;
- }
-
- /**
- * @param qNMsgSendTime
- * the qNMsgSendTime to set
- */
- public void setqNMsgSendTime(long qNMsgSendTime) {
- this.qNMsgSendTime = qNMsgSendTime;
- }
-
- /**
- * @return the qNMsgSerTime
- */
- public long getqNMsgSerTime() {
- return qNMsgSerTime;
- }
-
- /**
- * @param qNMsgSerTime
- * the qNMsgSerTime to set
- */
- public void setqNMsgSerTime(long qNMsgSerTime) {
- this.qNMsgSerTime = qNMsgSerTime;
- }
-
- /**
- * @return the qNRespDeSerTime
- */
- public long getqNRespDeSerTime() {
- return qNRespDeSerTime;
- }
-
- /**
- * @param qNRespDeSerTime
- * the qNRespDeSerTime to set
- */
- public void setqNRespDeSerTime(long qNRespDeSerTime) {
- this.qNRespDeSerTime = qNRespDeSerTime;
- }
- }
-
- public static class RegionOnMember {
-
- public static final int REGION_ON_MEMBER_STAT_GETS_PER_SEC_TREND = 0;
- public static final int REGION_ON_MEMBER_STAT_PUTS_PER_SEC_TREND = 1;
- public static final int REGION_ON_MEMBER_STAT_DISK_READS_PER_SEC_TREND = 3;
- public static final int REGION_ON_MEMBER_STAT_DISK_WRITES_PER_SEC_TREND = 4;
-
- private String regionFullPath;
- private String memberName;
- private long entrySize;
- private long entryCount;
- private double getsRate;
- private double putsRate;
- private double diskGetsRate;
- private double diskPutsRate;
- private int localMaxMemory;
-
- private CircularFifoBuffer getsPerSecTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer putsPerSecTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer diskReadsPerSecTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer diskWritesPerSecTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
-
- /**
- * @return the entrySize
- */
- public long getEntrySize() {
- return entrySize;
- }
-
- /**
- * @param entrySize the entrySize to set
- */
- public void setEntrySize(long entrySize) {
- this.entrySize = entrySize;
- }
-
- /**
- * @return the entryCount
- */
- public long getEntryCount() {
- return entryCount;
- }
-
- /**
- * @param entryCount the entryCount to set
- */
- public void setEntryCount(long entryCount) {
- this.entryCount = entryCount;
- }
-
- /**
- * @return the putsRate
- */
- public double getPutsRate() {
- return putsRate;
- }
-
- /**
- * @param putsRate the putsRate to set
- */
- public void setPutsRate(double putsRate) {
- this.putsRate = putsRate;
- }
-
- /**
- * @return the getsRate
- */
- public double getGetsRate() {
- return getsRate;
- }
-
- /**
- * @param getsRate the getsRate to set
- */
- public void setGetsRate(double getsRate) {
- this.getsRate = getsRate;
- }
-
- /**
- * @return the diskGetsRate
- */
- public double getDiskGetsRate() {
- return diskGetsRate;
- }
-
- /**
- * @param diskGetsRate the diskGetsRate to set
- */
- public void setDiskGetsRate(double diskGetsRate) {
- this.diskGetsRate = diskGetsRate;
- }
-
- /**
- * @return the diskPutsRate
- */
- public double getDiskPutsRate() {
- return diskPutsRate;
- }
-
- /**
- * @param diskPutsRate the diskPutsRate to set
- */
- public void setDiskPutsRate(double diskPutsRate) {
- this.diskPutsRate = diskPutsRate;
- }
-
- /**
- * @return the local maximum memory
- */
- public int getLocalMaxMemory() {
- return this.localMaxMemory;
- }
-
- /**
- * @param localMaxMemory
- */
- public void setLocalMaxMemory(int localMaxMemory) {
- this.localMaxMemory = localMaxMemory;
- }
-
- /**
- * @return the getsPerSecTrend
- */
- public CircularFifoBuffer getGetsPerSecTrend() {
- return getsPerSecTrend;
- }
-
- /**
- * @param getsPerSecTrend the getsPerSecTrend to set
- */
- public void setGetsPerSecTrend(CircularFifoBuffer getsPerSecTrend) {
- this.getsPerSecTrend = getsPerSecTrend;
- }
-
- /**
- * @return the putsPerSecTrend
- */
- public CircularFifoBuffer getPutsPerSecTrend() {
- return putsPerSecTrend;
- }
-
- /**
- * @param putsPerSecTrend the putsPerSecTrend to set
- */
- public void setPutsPerSecTrend(CircularFifoBuffer putsPerSecTrend) {
- this.putsPerSecTrend = putsPerSecTrend;
- }
-
- /**
- * @return the diskReadsPerSecTrend
- */
- public CircularFifoBuffer getDiskReadsPerSecTrend() {
- return diskReadsPerSecTrend;
- }
-
- /**
- * @param diskReadsPerSecTrend the diskReadsPerSecTrend to set
- */
- public void setDiskReadsPerSecTrend(CircularFifoBuffer diskReadsPerSecTrend) {
- this.diskReadsPerSecTrend = diskReadsPerSecTrend;
- }
-
- /**
- * @return the diskWritesPerSecTrend
- */
- public CircularFifoBuffer getDiskWritesPerSecTrend() {
- return diskWritesPerSecTrend;
- }
-
- /**
- * @param diskWritesPerSecTrend the diskWritesPerSecTrend to set
- */
- public void setDiskWritesPerSecTrend(CircularFifoBuffer diskWritesPerSecTrend) {
- this.diskWritesPerSecTrend = diskWritesPerSecTrend;
- }
-
- public Object[] getRegionOnMemberStatisticTrend(int trendId) {
-
- Object[] returnArray = null;
- switch (trendId) {
- case REGION_ON_MEMBER_STAT_GETS_PER_SEC_TREND:
- synchronized (this.getsPerSecTrend) {
- returnArray = this.getsPerSecTrend.toArray();
- }
- break;
-
- case REGION_ON_MEMBER_STAT_PUTS_PER_SEC_TREND:
- synchronized (this.putsPerSecTrend) {
- returnArray = this.putsPerSecTrend.toArray();
- }
- break;
-
- case REGION_ON_MEMBER_STAT_DISK_READS_PER_SEC_TREND:
- synchronized (this.diskReadsPerSecTrend) {
- returnArray = this.diskReadsPerSecTrend.toArray();
- }
- break;
-
- case REGION_ON_MEMBER_STAT_DISK_WRITES_PER_SEC_TREND:
- synchronized (this.diskWritesPerSecTrend) {
- returnArray = this.diskWritesPerSecTrend.toArray();
- }
- break;
- }
-
- return returnArray;
- }
-
- /**
- * @return the regionFullPath
- */
- public String getRegionFullPath() {
- return regionFullPath;
- }
-
- /**
- * @param regionFullPath the regionFullPath to set
- */
- public void setRegionFullPath(String regionFullPath) {
- this.regionFullPath = regionFullPath;
- }
-
- /**
- * @return the memberName
- */
- public String getMemberName() {
- return memberName;
- }
-
- /**
- * @param memberName the memberName to set
- */
- public void setMemberName(String memberName) {
- this.memberName = memberName;
- }
- }
-
- /**
- * Region Inner Class
- *
- *
- */
- public static class Region {
- // start: fields defined in MBean
- private String fullPath;
- private double diskReadsRate;
- private double diskWritesRate;
- private double getsRate;
- private double putsRate;
- private double lruEvictionRate;
- private String regionType;
- private long systemRegionEntryCount;
- private int memberCount;
- private String name;
- private boolean persistentEnabled;
- private long entrySize;
- private boolean wanEnabled;
- private int emptyNode;
- private long diskUsage;
- private String scope;
- private String diskStoreName;
- private boolean diskSynchronous;
- private boolean enableOffHeapMemory;
- private String compressionCodec = "";
-
- private List<String> memberName = new ArrayList<String>();
- private List<RegionOnMember> regionOnMembers = new ArrayList<RegionOnMember>();
- private CircularFifoBuffer getsPerSecTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer putsPerSecTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer diskReadsPerSecTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
- private CircularFifoBuffer diskWritesPerSecTrend = new CircularFifoBuffer(
- MAX_SAMPLE_SIZE);
-
- public static final int REGION_STAT_GETS_PER_SEC_TREND = 0;
- public static final int REGION_STAT_PUTS_PER_SEC_TREND = 1;
- public static final int REGION_STAT_DISK_READS_PER_SEC_TREND = 3;
- public static final int REGION_STAT_DISK_WRITES_PER_SEC_TREND = 4;
-
- // end: fields defined in MBean
-
- public Object[] getRegionStatisticTrend(int trendId) {
-
- Object[] returnArray = null;
- switch (trendId) {
- case REGION_STAT_GETS_PER_SEC_TREND:
- synchronized (this.getsPerSecTrend) {
- returnArray = this.getsPerSecTrend.toArray();
- }
- break;
-
- case REGION_STAT_PUTS_PER_SEC_TREND:
- synchronized (this.putsPerSecTrend) {
- returnArray = this.putsPerSecTrend.toArray();
- }
- break;
-
- case REGION_STAT_DISK_READS_PER_SEC_TREND:
- synchronized (this.diskReadsPerSecTrend) {
- returnArray = this.diskReadsPerSecTrend.toArray();
- }
- break;
-
- case REGION_STAT_DISK_WRITES_PER_SEC_TREND:
- synchronized (this.diskWritesPerSecTrend) {
- returnArray = this.diskWritesPerSecTrend.toArray();
- }
- break;
- }
-
- return returnArray;
- }
-
- public boolean isDiskSynchronous() {
- return this.diskSynchronous;
- }
-
- public void setDiskSynchronous(boolean diskSynchronous) {
- this.diskSynchronous = diskSynchronous;
- }
-
- public String getDiskStoreName() {
- return this.diskStoreName;
- }
-
- public void setDiskStoreName(String diskStoreName) {
- this.diskStoreName = diskStoreName;
- }
-
- public String getScope() {
- return this.scope;
- }
-
- public void setScope(String scope) {
- this.scope = scope;
- }
-
- public int getEmptyNode() {
- return this.emptyNode;
- }
-
- public void setEmptyNode(int emptyNode) {
- this.emptyNode = emptyNode;
- }
-
- public long getDiskUsage() {
- return this.diskUsage;
- }
-
- public void setDiskUsage(long diskUsage) {
- this.diskUsage = diskUsage;
- }
-
- public void setEntrySize(long entrySize) {
- this.entrySize = entrySize;
- }
-
- public boolean getWanEnabled() {
- return this.wanEnabled;
- }
-
- public void setWanEnabled(boolean wanEnabled) {
- this.wanEnabled = wanEnabled;
- }
-
- public boolean getPersistentEnabled() {
- return this.persistentEnabled;
- }
-
- public void setPersistentEnabled(boolean persistentEnabled) {
- this.persistentEnabled = persistentEnabled;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public long getEntrySize() {
- return this.entrySize;
- }
-
- public List<String> getMemberName() {
- return this.memberName;
- }
-
- public void setMemberName(List<String> memberName) {
- this.memberName = memberName;
- }
-
- public String getFullPath() {
- return this.fullPath;
- }
-
- public void setFullPath(String fullPath) {
- this.fullPath = fullPath;
- }
-
- public double getDiskReadsRate() {
- return this.diskReadsRate;
- }
-
- public void setDiskReadsRate(double diskReadsRate) {
- this.diskReadsRate = diskReadsRate;
- }
-
- public double getDiskWritesRate() {
- return this.diskWritesRate;
- }
-
- public void setDiskWritesRate(double diskWritesRate) {
- this.diskWritesRate = diskWritesRate;
- }
-
- public CircularFifoBuffer getDiskReadsPerSecTrend() {
- return this.diskReadsPerSecTrend;
- }
-
- public void setDiskReadsPerSecTrend(CircularFifoBuffer diskReadsPerSecTrend) {
- this.diskReadsPerSecTrend = diskReadsPerSecTrend;
- }
-
- public CircularFifoBuffer getDiskWritesPerSecTrend() {
- return this.diskWritesPerSecTrend;
- }
-
- public void setDiskWritesPerSecTrend(
- CircularFifoBuffer diskWritesPerSecTrend) {
- this.diskWritesPerSecTrend = diskWritesPerSecTrend;
- }
-
- public double getGetsRate() {
- return this.getsRate;
- }
-
- public void setGetsRate(double getsRate) {
- this.getsRate = getsRate;
- }
-
- public double getLruEvictionRate() {
- return this.lruEvictionRate;
- }
-
- public void setLruEvictionRate(double lruEvictionRate) {
- this.lruEvictionRate = lruEvictionRate;
- }
-
- public String getRegionType() {
- return this.regionType;
- }
-
- public void setRegionType(String regionType) {
- this.regionType = regionType;
- }
-
- public long getSystemRegionEntryCount() {
- return this.systemRegionEntryCount;
- }
-
- public void setSystemRegionEntryCount(long systemRegionEntryCount) {
- this.systemRegionEntryCount = systemRegionEntryCount;
- }
-
- public int getMemberCount() {
- return this.memberCount;
- }
-
- public void setMemberCount(int memberCount) {
- this.memberCount = memberCount;
- }
-
- public double getPutsRate() {
- return this.putsRate;
- }
-
- public void setPutsRate(double putsRate) {
- this.putsRate = putsRate;
- }
-
- public CircularFifoBuffer getGetsPerSecTrend() {
- return this.getsPerSecTrend;
- }
-
- public void setGetsPerSecTrend(CircularFifoBuffer getsPerSecTrend) {
- this.getsPerSecTrend = getsPerSecTrend;
- }
-
- public CircularFifoBuffer getPutsPerSecTrend() {
- return this.putsPerSecTrend;
- }
-
- public void setPutsPerSecTrend(CircularFifoBuffer putsPerSecTrend) {
- this.putsPerSecTrend = putsPerSecTrend;
- }
-
- public boolean isEnableOffHeapMemory() {
- return this.enableOffHeapMemory;
- }
-
- public void setEnableOffHeapMemory(boolean enableOffHeapMemory) {
- this.enableOffHeapMemory = enableOffHeapMemory;
- }
-
- public String getCompressionCodec() {
- return this.compressionCodec;
- }
-
- public void setCompressionCodec(String compressionCodec) {
- this.compressionCodec = compressionCodec;
- }
-
- public Cluster.RegionOnMember[] getRegionOnMembers() {
- Cluster.RegionOnMember[] regionOnMembers = null;
- synchronized (this.regionOnMembers) {
- regionOnMembers = new Cluster.RegionOnMember[this.regionOnMembers.size()];
- regionOnMembers = this.regionOnMembers.toArray(regionOnMembers);
- }
-
- return regionOnMembers;
- }
-
- /**
- * @param regionOnMembers the regionOnMembers to set
- */
- public void setRegionOnMembers(List<RegionOnMember> regionOnMembers) {
- this.regionOnMembers = regionOnMembers;
- }
- }
-
- /**
- * Alert Inner Class
- *
- *
- */
- public static class Alert {
- public static final int SEVERE = 0;
- public static final int ERROR = 1;
- public static final int WARNING = 2;
- public static final int INFO = 3;
-
- public static AtomicInteger ALERT_ID_CTR = new AtomicInteger();
-
- private int id;
- private Date timestamp;
- private int severity;
- private String memberName;
- private String description;
- private boolean isAcknowledged;
- private String iso8601Ts;
-
- public String getIso8601Ts() {
- return iso8601Ts;
- }
-
- public void setIso8601Ts(String iso8601Ts) {
- this.iso8601Ts = iso8601Ts;
- }
-
- public boolean isAcknowledged() {
- return this.isAcknowledged;
- }
-
- public void setAcknowledged(boolean isAcknowledged) {
- this.isAcknowledged = isAcknowledged;
- }
-
- public Date getTimestamp() {
- return this.timestamp;
- }
-
- public void setTimestamp(Date timestamp) {
- this.timestamp = timestamp;
- this.iso8601Ts = formatToISOTimestamp(timestamp);
- }
-
- public int getSeverity() {
- return this.severity;
- }
-
- public void setSeverity(int severity) {
- this.severity = severity;
- }
-
- public String getMemberName() {
- return this.memberName;
- }
-
- public void setMemberName(String memberName) {
- this.memberName = memberName;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public static int nextID() {
- /*
- * int id = -1; synchronized (Alert.class) { ALERT_ID_CTR = ALERT_ID_CTR +
- * 1; id = ALERT_ID_CTR; }
- */
- return ALERT_ID_CTR.incrementAndGet();
- }
-
- private static DateFormat df = new SimpleDateFormat(PulseConstants.PULSE_NOTIFICATION_ALERT_DATE_PATTERN);
-
- public static String formatToISOTimestamp(Date date) {
- TimeZone tz = TimeZone.getTimeZone("UTC");
- df.setTimeZone(tz);
- return df.format(date);
- }
-
- }
-
- /**
- * Client Inner Class
- *
- *
- */
- public static class Client {
-
- private String id;
- private String name;
- private String host;
- private int queueSize;
- private double cpuUsage;
- private long uptime;
- private int threads;
- private int gets;
- private int puts;
- private int cpus;
- private int clientCQCount;
- private long processCpuTime;
- private String status;
- private boolean isConnected = false;
- private boolean isSubscriptionEnabled = false;
-
- public String getId() {
- return this.id;
- }
-
- public int getGets() {
- return this.gets;
- }
-
- public int getPuts() {
- return this.puts;
- }
-
- public int getClientCQCount() {
- return clientCQCount;
- }
-
- public void setClientCQCount(int clientCQCount) {
- this.clientCQCount = clientCQCount;
- }
-
- public boolean isSubscriptionEnabled() {
- return isSubscriptionEnabled;
- }
-
- public void setSubscriptionEnabled(boolean isSubscriptionEnabled) {
- this.isSubscriptionEnabled = isSubscriptionEnabled;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getHost() {
- return this.host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public int getQueueSize() {
- return this.queueSize;
- }
-
- public void setQueueSize(int queueSize) {
- this.queueSize = queueSize;
- }
-
- public double getCpuUsage() {
- return this.cpuUsage;
- }
-
- public void setCpuUsage(double cpuUsage) {
- this.cpuUsage = cpuUsage;
- }
-
- public void setGets(int gets) {
- this.gets = gets;
- }
-
- public void setPuts(int puts) {
- this.puts = puts;
- }
-
- public long getUptime() {
- return this.uptime;
- }
-
- public void setUptime(long uptime) {
- this.uptime = uptime;
- }
-
- public int getThreads() {
- return this.threads;
- }
-
- public void setThreads(int threads) {
- this.threads = threads;
- }
-
- public String getStatus() {
- return this.status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public int getCpus() {
- return this.cpus;
- }
-
- public void setCpus(int cpus) {
- this.cpus = cpus;
- }
-
- public long getProcessCpuTime() {
- return this.processCpuTime;
- }
-
- public void setProcessCpuTime(long processCpuTime) {
- this.processCpuTime = processCpuTime;
- }
-
- public boolean isConnected() {
- return isConnected;
- }
-
- public void setConnected(boolean isConnected) {
- this.isConnected = isConnected;
- }
-
- }
-
- /**
- * Gateway Receiver Inner Class
- *
- *
- */
- public static class GatewayReceiver {
-
- private int listeningPort;
- private double linkThroughput;
- private long avgBatchProcessingTime;
- private String id;
- private int queueSize;
- private Boolean status;
- private int batchSize;
-
- public int getListeningPort() {
- return this.listeningPort;
- }
-
- public void setListeningPort(int listeningPort) {
- this.listeningPort = listeningPort;
- }
-
- public double getLinkThroughput() {
- return this.linkThroughput;
- }
-
- public void setLinkThroughput(double linkThroughput) {
- this.linkThroughput = linkThroughput;
- }
-
- public long getAvgBatchProcessingTime() {
- return this.avgBatchProcessingTime;
- }
-
- public void setAvgBatchProcessingTime(long avgBatchProcessingTime) {
- this.avgBatchProcessingTime = avgBatchProcessingTime;
- }
-
- public String getId() {
- return this.id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public int getQueueSize() {
- return this.queueSize;
- }
-
- public void setQueueSize(int queueSize) {
- this.queueSize = queueSize;
- }
-
- public Boolean getStatus() {
- return this.status;
- }
-
- public void setStatus(Boolean status) {
- this.status = status;
- }
-
- public int getBatchSize() {
- return this.batchSize;
- }
-
- public void setBatchSize(int batchSize) {
- this.batchSize = batchSize;
- }
- }
-
- /**
- * Gateway Sender Inner class
- *
- *
- */
- public static class GatewaySender {
-
- private double linkThroughput;
- private String id;
- private int queueSize;
- private Boolean status;
- private boolean primary;
- private boolean senderType;
- private int batchSize;
- private boolean persistenceEnabled;
- private int remoteDSId;
- private int eventsExceedingAlertThreshold;
-
- public double getLinkThroughput() {
- return this.linkThroughput;
- }
-
- public void setLinkThroughput(double linkThroughput) {
- this.linkThroughput = linkThroughput;
- }
-
- public String getId() {
- return this.id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public int getQueueSize() {
- return this.queueSize;
- }
-
- public void setQueueSize(int queueSize) {
- this.queueSize = queueSize;
- }
-
- public Boolean getStatus() {
- return this.status;
- }
-
- public void setStatus(Boolean status) {
- this.status = status;
- }
-
- public boolean getPrimary() {
- return this.primary;
- }
-
- public void setPrimary(boolean primary) {
- this.primary = primary;
- }
-
- public boolean getSenderType() {
- return this.senderType;
- }
-
- public void setSenderType(boolean senderType) {
- this.senderType = senderType;
- }
-
- public int getBatchSize() {
- return this.batchSize;
- }
-
- public void setBatchSize(int batchSize) {
- this.batchSize = batchSize;
- }
-
- public boolean getPersistenceEnabled() {
- return this.persistenceEnabled;
- }
-
- public void setPersistenceEnabled(boolean persistenceEnabled) {
- this.persistenceEnabled = persistenceEnabled;
- }
-
- /**
- * @return the remoteDSId
- */
- public int getRemoteDSId() {
- return remoteDSId;
- }
-
- /**
- * @param remoteDSId the remoteDSId to set
- */
- public void setRemoteDSId(int remoteDSId) {
- this.remoteDSId = remoteDSId;
- }
-
- /**
- * @return the eventsExceedingAlertThreshold
- */
- public int getEventsExceedingAlertThreshold() {
- return eventsExceedingAlertThreshold;
- }
-
- /**
- * @param eventsExceedingAlertThreshold the eventsExceedingAlertThreshold to set
- */
- public void setEventsExceedingAlertThreshold(int eventsExceedingAlertThreshold) {
- this.eventsExceedingAlertThreshold = eventsExceedingAlertThreshold;
- }
- }
-
- /**
- * Async Event Queue Inner class
- *
- *
- */
- public static class AsyncEventQueue {
-
- private String id;
- private boolean primary;
- private boolean parallel;
- private int batchSize;
- private long batchTimeInterval;
- private boolean batchConflationEnabled;
- private String asyncEventListener;
- private int eventQueueSize;
-
- public String getId() {
- return this.id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public boolean getPrimary() {
- return this.primary;
- }
-
- public void setPrimary(boolean primary) {
- this.primary = primary;
- }
-
- /**
- * @return the parallel
- */
- public boolean isParallel() {
- return parallel;
- }
-
- /**
- * @param parallel the parallel to set
- */
- public void setParallel(boolean parallel) {
- this.parallel = parallel;
- }
-
- public int getBatchSize() {
- return this.batchSize;
- }
-
- public void setBatchSize(int batchSize) {
- this.batchSize = batchSize;
- }
-
- /**
- * @return the batchTimeInterval
- */
- public long getBatchTimeInterval() {
- return batchTimeInterval;
- }
-
- /**
- * @param batchTimeInterval the batchTimeInterval to set
- */
- public void setBatchTimeInterval(long batchTimeInterval) {
- this.batchTimeInterval = batchTimeInterval;
- }
-
- /**
- * @return the batchConflationEnabled
- */
- public boolean isBatchConflationEnabled() {
- return batchConflationEnabled;
- }
-
- /**
- * @param batchConflationEnabled the batchConflationEnabled to set
- */
- public void setBatchConflationEnabled(boolean batchConflationEnabled) {
- this.batchConflationEnabled = batchConflationEnabled;
- }
-
- /**
- * @return the asyncEventListener
- */
- public String getAsyncEventListener() {
- return asyncEventListener;
- }
-
- /**
- * @param asyncEventListener the asyncEventListener to set
- */
- public void setAsyncEventListener(String asyncEventListener) {
- this.asyncEventListener = asyncEventListener;
- }
-
- /**
- * @return the eventQueueSize
- */
- public int getEventQueueSize() {
- return eventQueueSize;
- }
-
- /**
- * @param eventQueueSize the eventQueueSize to set
- */
- public void setEventQueueSize(int eventQueueSize) {
- this.eventQueueSize = eventQueueSize;
- }
- }
-
- /**
- * Default constructor only used for testing
- */
- public Cluster() {
- }
-
-
- /**
- * This function is used for calling getUpdator function of ClusterDataFactory
- * and starting the thread for updating the Cluster details.
- *
- * @param host
- * host name
- * @param port
- * port
- * @param userName
- * pulse user name
- * @param userPassword
- * pulse user password
- * @throws ConnectException
- */
- public Cluster(String host, String port, String userName, String userPassword)
- throws ConnectException {
- this.serverName = host;
- this.port = port;
- this.jmxUserName = userName;
- this.jmxUserPassword = userPassword;
-
- this.updater = ClusterDataFactory.getUpdater(this, host, port);
- // start();
- }
-
- /**
- * thread run method for updating the cluster data
- */
- @Override
- public void run() {
- while (!this.stopUpdates) {
- try {
- if (!this.updateData()) {
- this.stale++;
- } else {
- this.stale = 0;
- }
- } catch (Exception e) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("Exception Occurred while updating cluster data : " + e.getMessage());
- }
- }
-
- try {
- Thread.sleep(POLL_INTERVAL);
- } catch (InterruptedException e) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("InterruptedException Occurred : " + e.getMessage());
- }
- }
- }
-
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_STOP_THREAD_UPDATES")
- + " :: " + this.serverName + ":" + this.port);
- }
- }
-
- /**
- * calling updateData
- *
- * @return true if update was successful. false if it failed.
- */
- private boolean updateData() {
- // This will eventually call JMX. Currently we will update this with
- // some dummy data.
- // Connect if required or hold a connection. If unable to connect,
- // return false
- if (LOGGER.finerEnabled()) {
- LOGGER.finer(resourceBundle.getString("LOG_MSG_CLUSTER_DATA_IS_UPDATING")
- + "::" + this.serverName + ":" + this.port);
- }
- return this.updater.updateData();
- }
-
- /**
- * for stopping the update thread
- */
- public void stopThread() {
- this.stopUpdates = true;
-
- try {
- join();
- } catch (InterruptedException e) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("InterruptedException occured while stoping cluster thread : " + e.getMessage());
- }
- }
- }
-
- public Map<String, Cluster.Member> getMembersHMap() {
- return this.membersHMap;
- }
-
- public void setMembersHMap(HashMap<String, Cluster.Member> membersHMap) {
- this.membersHMap = membersHMap;
- }
-
- public Map<String, Boolean> getWanInformation() {
- Map<String, Boolean> wanMap = null;
- synchronized (this.wanInformation) {
- wanMap = (Map<String, Boolean>) this.wanInformation.clone();
- }
-
- return wanMap;
- }
-
- // Returns actual wanInformation object reference
- public Map<String, Boolean> getWanInformationObject() {
- return this.wanInformation;
- }
-
- public void setWanInformation(HashMap<String, Boolean> wanInformation) {
- this.wanInformation = wanInformation;
- }
-
- 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 String getConnectionErrorMsg() {
- return this.connectionErrorMsg;
- }
-
- public void setConnectionErrorMsg(String connectionErrorMsg) {
- this.connectionErrorMsg = connectionErrorMsg;
- }
-
- public String getServerName() {
- return this.serverName;
- }
-
- public boolean isConnectedFlag() {
- return this.connectedFlag;
- }
-
- public void setConnectedFlag(boolean connectedFlag) {
- this.connectedFlag = connectedFlag;
- }
-
- public String getPort() {
- return this.port;
- }
-
- public int getStale() {
- return this.stale;
- }
-
- public double getWritePerSec() {
- return this.writePerSec;
- }
-
- public void setWritePerSec(double writePerSec) {
- this.writePerSec = writePerSec;
- }
-
- public double getReadPerSec() {
- return this.readPerSec;
- }
-
- public void setReadPerSec(double readPerSec) {
- this.readPerSec = readPerSec;
- }
-
- public double getQueriesPerSec() {
- return this.queriesPerSec;
- }
-
- public void setQueriesPerSec(double queriesPerSec) {
- this.queriesPerSec = queriesPerSec;
- }
-
- public double getLoadPerSec() {
- return this.loadPerSec;
- }
-
- public void setLoadPerSec(double loadPerSec) {
- this.loadPerSec = loadPerSec;
- }
-
- public int getNotificationPageNumber() {
- return this.notificationPageNumber;
- }
-
- public void setNotificationPageNumber(int notificationPageNumber) {
- this.notificationPageNumber = notificationPageNumber;
- }
-
- public void setStale(int stale) {
- this.stale = stale;
- }
-
- public boolean isStopUpdates() {
- return this.stopUpdates;
- }
-
- public void setStopUpdates(boolean stopUpdates) {
- this.stopUpdates = stopUpdates;
- }
-
- public long getUsedHeapSize() {
- return this.usedHeapSize;
- }
-
- public void setUsedHeapSize(long usedHeapSize) {
- this.usedHeapSize = usedHeapSize;
- }
-
- public int getServerCount() {
- return this.serverCount;
- }
-
- public void setServerCount(int serverCount) {
- this.serverCount = serverCount;
- }
-
- public int getTxnCommittedCount() {
- return txnCommittedCount;
- }
-
- public void setTxnCommittedCount(int txnCommittedCount) {
- this.txnCommittedCount = txnCommittedCount;
- }
-
- public int getTxnRollbackCount() {
- return txnRollbackCount;
- }
-
- public void setTxnRollbackCount(int txnRollbackCount) {
- this.txnRollbackCount = txnRollbackCount;
- }
-
- public int getRunningFunctionCount() {
- return this.runningFunctionCount;
- }
-
- public long getRegisteredCQCount() {
- return this.registeredCQCount;
- }
-
- public int getSubscriptionCount() {
- return this.subscriptionCount;
- }
-
- public void setSubscriptionCount(int subscriptionCount) {
- this.subscriptionCount = subscriptionCount;
- }
-
- public void setRegisteredCQCount(long registeredCQCount) {
- this.registeredCQCount = registeredCQCount;
- }
-
- public void setRunningFunctionCount(int runningFunctionCount) {
- this.runningFunctionCount = runningFunctionCount;
- }
-
- public Map<String, Cluster.Region> getClusterRegions() {
- return this.clusterRegionMap;
- }
-
- public Cluster.Region getClusterRegion(String regionFullPath) {
- return this.clusterRegionMap.get(regionFullPath);
- }
-
- public void setClusterRegions(Map<String, Region> clusterRegionMap) {
- this.clusterRegionMap = clusterRegionMap;
- }
-
- public Map<String, Cluster.Statement> getClusterStatements() {
- return this.clusterStatementMap;
- }
-
- public void setClusterStatements(Map<String, Statement> clusterStatementMap) {
- this.clusterStatementMap = clusterStatementMap;
- }
-
- public Alert[] getAlertsList() {
- Alert[] list = null;
- synchronized (this.alertsList) {
- list = new Alert[this.alertsList.size()];
- list = this.alertsList.toArray(list);
- }
-
- return list;
- }
-
- public void setAlertsList(List<Alert> alertsList) {
- this.alertsList = alertsList;
- }
-
- public void setServerName(String serverName) {
- this.serverName = serverName;
- }
-
- public void setPort(String port) {
- this.port = port;
- }
-
- public Set<String> getDeletedMembers() {
- return this.deletedMembers;
- }
-
- public void setDeletedMembers(Set<String> deletedMembers) {
- this.deletedMembers = deletedMembers;
- }
-
- public Set<String> getDeletedRegions() {
- return this.deletedRegions;
- }
-
- public void setDeletedRegions(Set<String> deletedRegions) {
- this.deletedRegions = deletedRegions;
- }
-
- public Map<String, List<Member>> getPhysicalToMember() {
- Map<String, List<Member>> ptom = null;
- // synchronized (physicalToMember) {
- ptom = this.physicalToMember;
- // }
- return ptom;
- }
-
- public void setPhysicalToMember(HashMap<String, List<Member>> physicalToMember) {
- // synchronized (this.physicalToMember) {
- this.physicalToMember = physicalToMember;
- // }
- }
-
- public int getMemberCount() {
- return this.memberCount;
- }
-
- public void setMemberCount(int memberCount) {
- this.memberCount = memberCount;
- }
-
- public long getClientConnectionCount() {
- return this.clientConnectionCount;
- }
-
- public void setClientConnectionCount(long clientConnectionCount) {
- this.clientConnectionCount = clientConnectionCount;
- }
-
- public int getClusterId() {
- return this.clusterId;
- }
-
- public void setClusterId(int clusterId) {
- this.clusterId = clusterId;
- }
-
- public int getLocatorCount() {
- return this.locatorCount;
- }
-
- public void setLocatorCount(int locatorCount) {
- this.locatorCount = locatorCount;
- }
-
- public int getTotalRegionCount() {
- return this.totalRegionCount;
- }
-
- public void setTotalRegionCount(int totalRegionCount) {
- this.totalRegionCount = totalRegionCount;
- }
-
- public long getTotalHeapSize() {
- return this.totalHeapSize;
- }
-
- public void setTotalHeapSize(long totalHeapSize) {
- this.totalHeapSize = totalHeapSize;
- }
-
- public long getTotalRegionEntryCount() {
- return this.totalRegionEntryCount;
- }
-
- public void setTotalRegionEntryCount(long totalRegionEntryCount) {
- this.totalRegionEntryCount = totalRegionEntryCount;
- }
-
- public int getCurrentQueryCount() {
- return this.currentQueryCount;
- }
-
- public void setCurrentQueryCount(int currentQueryCount) {
- this.currentQueryCount = currentQueryCount;
- }
-
- public long getTotalBytesOnDisk() {
- return this.totalBytesOnDisk;
- }
-
- public void setTotalBytesOnDisk(long totalBytesOnDisk) {
- this.totalBytesOnDisk = totalBytesOnDisk;
- }
-
- public double getDiskReadsRate() {
- return this.diskReadsRate;
- }
-
- public void setDiskReadsRate(double diskReadsRate) {
- this.diskReadsRate = diskReadsRate;
- }
-
- public double getDiskWritesRate() {
- return this.diskWritesRate;
- }
-
- public void setDiskWritesRate(double diskWritesRate) {
- this.diskWritesRate = diskWritesRate;
- }
-
- public int getAvgDiskStorage() {
- return this.avgDiskStorage;
- }
-
- public void setAvgDiskStorage(int avgDiskStorage) {
- this.avgDiskStorage = avgDiskStorage;
- }
-
- public int getAvgDiskWritesRate() {
- return this.avgDiskWritesRate;
- }
-
- public void setAvgDiskWritesRate(int avgDiskWritesRate) {
- this.avgDiskWritesRate = avgDiskWritesRate;
- }
-
- public CircularFifoBuffer getWritePerSecTrend() {
- return this.writePerSecTrend;
- }
-
- public void setWritePerSecTrend(CircularFifoBuffer writePerSecTrend) {
- this.writePerSecTrend = writePerSecTrend;
- }
-
- public long getGarbageCollectionCount() {
- return this.garbageCollectionCount;
- }
-
- public void setGarbageCollectionCount(long garbageCollectionCount) {
- this.garbageCollectionCount = garbageCollectionCount;
- }
-
- public CircularFifoBuffer getTotalBytesOnDiskTrend() {
- return this.totalBytesOnDiskTrend;
- }
-
- public void setTotalBytesOnDiskTrend(CircularFifoBuffer totalBytesOnDiskTrend) {
- this.totalBytesOnDiskTrend = totalBytesOnDiskTrend;
- }
-
- public CircularFifoBuffer getThroughoutWritesTrend() {
- return this.throughoutWritesTrend;
- }
-
- public void setThroughoutWritesTrend(CircularFifoBuffer throughoutWritesTrend) {
- this.throughoutWritesTrend = throughoutWritesTrend;
- }
-
- public CircularFifoBuffer getThroughoutReadsTrend() {
- return this.throughoutReadsTrend;
- }
-
- public void setThroughoutReadsTrend(CircularFifoBuffer throughoutReadsTrend) {
- this.throughoutReadsTrend = throughoutReadsTrend;
- }
-
- public CircularFifoBuffer getReadPerSecTrend() {
- return this.readPerSecTrend;
- }
-
- public void setReadPerSecTrend(CircularFifoBuffer readPerSecTrend) {
- this.readPerSecTrend = readPerSecTrend;
- }
-
- public CircularFifoBuffer getQueriesPerSecTrend() {
- return this.queriesPerSecTrend;
- }
-
- public void setQueriesPerSecTrend(CircularFifoBuffer queriesPerSecTrend) {
- this.queriesPerSecTrend = queriesPerSecTrend;
- }
-
- public CircularFifoBuffer getMemoryUsageTrend() {
- return this.memoryUsageTrend;
- }
-
- public void setMemoryUsageTrend(CircularFifoBuffer memoryUsageTrend) {
- this.memoryUsageTrend = memoryUsageTrend;
- }
-
- public CircularFifoBuffer getGarbageCollectionTrend() {
- return this.garbageCollectionTrend;
- }
-
- public void setGarbageCollectionTrend(
- CircularFifoBuffer garbageCollectionSamples) {
- this.garbageCollectionTrend = garbageCollectionSamples;
- }
-
- public long getPreviousJVMPauseCount() {
- return this.previousJVMPauseCount;
- }
-
- public void setPreviousJVMPauseCount(long previousJVMPauseCount) {
- this.previousJVMPauseCount = previousJVMPauseCount;
- }
-
- public DataBrowser getDataBrowser() {
- // Initialize dataBrowser if null
- if (this.dataBrowser == null) {
- this.dataBrowser = new DataBrowser();
- }
- return this.dataBrowser;
- }
-
- public void setDataBrowser(DataBrowser dataBrowser) {
- this.dataBrowser = dataBrowser;
- }
-
- public ObjectNode executeQuery(String queryText, String members, int limit) {
- // Execute data browser query
- return this.updater.executeQuery(queryText, members, limit);
- }
-
- public ArrayNode getQueryHistoryByUserId(String userId) {
- return this.getDataBrowser().getQueryHistoryByUserId(userId);
- }
-
- public boolean addQueryInHistory(String queryText, String userName) {
- return this.getDataBrowser().addQueryInHistory(queryText, userName);
- }
-
- public boolean deleteQueryById(String userId, String queryId) {
- return this.getDataBrowser().deleteQueryById(userId, queryId);
- }
-
- public JMXConnector connectToGemFire() {
- if(this.updater instanceof JMXDataUpdater) {
- return ((JMXDataUpdater) this.updater).getJMXConnection(false);
- } else {
- return null;
- }
- }
-
- /**
- * inner class for creating Mock Data
- *
- *
- */
- public class MockDataUpdater implements IClusterUpdater {
- public MockDataUpdater() {
- }
-
- /**
- * function used for updating Cluster data for Mock
- */
- @Override
- public boolean updateData() {
- setConnectedFlag(true);
- Random r = new Random(System.currentTimeMillis());
- totalHeapSize = (long) Math.abs(r.nextInt(3200 - 2048) + 2048);
- usedHeapSize = (long) Math.abs(r.nextInt(2048));
- writePerSec = Math.abs(r.nextInt(100));
- subscriptionCount = Math.abs(r.nextInt(100));
- registeredCQCount = (long) Math.abs(r.nextInt(100));
- txnCommittedCount = Math.abs(r.nextInt(100));
- txnRollbackCount = Math.abs(r.nextInt(100));
- runningFunctionCount = Math.abs(r.nextInt(100));
- clusterId = Math.abs(r.nextInt(100));
- writePerSecTrend.add(writePerSec);
- diskWritesRate = writePerSec;
- garbageCollectionCount = (long) Math.abs(r.nextInt(100));
- garbageCollectionTrend.add(garbageCollectionCount);
-
- readPerSec = Math.abs(r.nextInt(100));
- readPerSecTrend.add(readPerSec);
-
- diskReadsRate = readPerSec;
- queriesPerSec = Math.abs(r.nextInt(100));
- queriesPerSecTrend.add(queriesPerSec);
-
- loadPerSec = Math.abs(r.nextInt(100));
- totalHeapSize = totalHeapSize;
- totalBytesOnDisk = totalHeapSize;
-
- totalBytesOnDiskTrend.add(totalBytesOnDisk);
-
- memoryUsageTrend.add(usedHeapSize);
- throughoutWritesTrend.add(writePerSec);
- throughoutReadsTrend.add(readPerSec);
-
- memberCount = 0;
-
- // Create 3 members first time around
- if (membersHMap.size() == 0) {
-
- membersHMap.put(
- "pnq-visitor1",
- initializeMember(
- "pnq-visitor1(Launcher_Manager-1099-13-40-24-5368)-24357",
- "pnq-visitor1", true, true, true, true));
-
- for (int i = 2; i <= 8; i++) {
- if ((i % 2) == 0) {
- membersHMap.put(
- "pnq-visitor" + i,
- initializeMember("pnq-visitor" + i
- + "(Launcher_Server-1099-13-40-24-5368)-24357",
- "pnq-visitor" + i, false, false, true, false));
- } else {
- if ((i % 3) == 0) {
- membersHMap.put(
- "pnq-visitor" + i,
- initializeMember("pnq-visitor" + i
- + "(Launcher_Server-1099-13-40-24-5368)-24357",
- "pnq-visitor" + i, false, false, false, false));
- } else {
- membersHMap.put(
- "pnq-visitor" + i,
- initializeMember("pnq-visitor" + i
- + "(Launcher_Server-1099-13-40-24-5368)-24357",
- "pnq-visitor" + i, false, true, true, true));
- }
- }
- }
-
- for (Entry<String, Member> memberSet : membersHMap.entrySet()) {
- HashMap<String, Cluster.Region> memberRegions = new HashMap<String, Cluster.Region>();
- HashMap<String, Cluster.Client> memberClientsHM = new HashMap<String, Cluster.Client>();
-
- Random randomGenerator = new Random();
- int randomInt = (randomGenerator.nextInt(15)) + 10;
- int regionExists = 0;
- for (int y = 0; y < randomInt; y++) {
- Region region = initMemberRegion(y, memberSet.getValue().getName());
- if (clusterRegionMap.entrySet().size() > 0) {
- for (Region clusterRegion : clusterRegionMap.values()) {
- if ((region.name).equals(clusterRegion.name)) {
- clusterRegion.memberName.add(memberSet.getValue().getName());
- clusterRegion.memberCount = clusterRegion.memberCount + 1;
- regionExists = 1;
- break;
- }
- }
- if (regionExists == 0) {
- addClusterRegion(region.getFullPath(), region);
- }
- } else {
- addClusterRegion(region.getFullPath(), region);
- }
- memberRegions.put(region.getFullPath(), region);
- totalRegionCount = clusterRegionMap.values().size();
- }
- membersHMap.get(memberSet.getKey()).setMemberRegions(memberRegions);
-
- if (memberSet.getValue().isCache) {
- Client client = initMemberClient(0, memberSet.getValue().getHost());
- memberClientsHM.put(client.getId(), client);
- randomInt = randomGenerator.nextInt(10);
- for (int y = 1; y < randomInt; y++) {
- Client newClient = initMemberClient(y, memberSet.getValue()
- .getHost());
- memberClientsHM.put(newClient.getId(), newClient);
- }
- membersHMap.get(memberSet.getKey()).updateMemberClientsHMap(
- memberClientsHM);
- clientConnectionCount = clientConnectionCount
- + membersHMap.get(memberSet.getKey()).getMemberClientsHMap()
- .size();
- }
-
- }
- }
-
- // add additional regions to members
- for (Entry<String, Member> memberSet : membersHMap.entrySet()) {
- HashMap<String, Cluster.Region> memberRegions = new HashMap<String, Cluster.Region>();
-
- Random randomGenerator = new Random();
- int randomInt = (randomGenerator.nextInt(5)) + 5;
- int regionExists = 0;
- for (int y = 0; y < randomInt; y++) {
- Region region = initMemberRegion(y, memberSet.getValue().getName());
- if (clusterRegionMap.entrySet().size() > 0) {
- for (Region clusterRegion : clusterRegionMap.values()) {
- if ((region.name).equals(clusterRegion.name)) {
- clusterRegion.memberName.add(memberSet.getValue().getName());
- clusterRegion.memberCount = clusterRegion.memberCount + 1;
- regionExists = 1;
- break;
- }
- }
- if (regionExists == 0) {
- addClusterRegion(region.getFullPath(), region);
- }
- } else {
- addClusterRegion(region.getFullPath(), region);
- }
- memberRegions.put(region.getFullPath(), region);
- totalRegionCount = clusterRegionMap.values().size();
- }
- membersHMap.get(memberSet.getKey()).setMemberRegions(memberRegions);
-
- }
-
- wanInformation.clear();
- int wanInfoSize = Math.abs(r.nextInt(10));
- wanInfoSize++;
- for (int i = 0; i < wanInfoSize; i++) {
- String name = "Mock Cluster" + i;
- Boolean value = false;
- if (i % 2 == 0) {
- value = true;
- }
- wanInformation.put(name, value);
- }
- memberCount = membersHMap.size();
-
- totalHeapSize = (long) 0;
- for (Entry<String, Member> memberSet : membersHMap.entrySet()) {
- refresh(membersHMap.get(memberSet.getKey()));
- Member member = membersHMap.get(memberSet.getKey());
- totalHeapSize += member.currentHeapSize;
- }
-
- for (Region region : clusterRegionMap.values()) {
- // Memory reads and writes
- region.getsRate = (Math.abs(r.nextInt(100))) + 1;
- region.putsRate = (Math.abs(r.nextInt(100))) + 1;
- region.getsPerSecTrend.add(region.getsRate);
- region.putsPerSecTrend.add(region.putsRate);
-
- // Disk reads and writes
- region.diskReadsRate = (Math.abs(r.nextInt(100))) + 1;
- region.diskWritesRate = (Math.abs(r.nextInt(100))) + 1;
- region.diskReadsPerSecTrend.add(region.diskReadsRate);
- region.diskWritesPerSecTrend.add(region.diskWritesRate);
- }
-
- if(clusterStatementMap.size() < 500){
- for(int i = 1; i <= 500;
<TRUNCATED>
[05/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAbstractTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAbstractTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAbstractTest.java
new file mode 100644
index 0000000..e30b560
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAbstractTest.java
@@ -0,0 +1,1049 @@
+/*
+ *
+ * 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.tests;
+
+import static org.junit.Assert.*;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.DecimalFormat;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import com.jayway.awaitility.Awaitility;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import org.apache.geode.internal.net.SSLConfigurationFactory;
+import org.apache.geode.internal.security.SecurableCommunicationChannel;
+import org.apache.geode.management.internal.JettyHelper;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+
+@SuppressWarnings("deprecated")
+public abstract class PulseAbstractTest extends PulseBaseTest {
+
+ private static String jmxPropertiesFile;
+ private static String path;
+
+ private static org.eclipse.jetty.server.Server jetty = null;
+ private static Server server = null;
+ private static String pulseURL = null;
+ public static WebDriver driver;
+
+ /* Constants for executing Data Browser queries */
+ public static final String QUERY_TYPE_ONE = "query1";
+ public static final String QUERY_TYPE_TWO = "query2";
+ public static final String QUERY_TYPE_THREE = "query3";
+ public static final String QUERY_TYPE_FOUR = "query4";
+ public static final String QUERY_TYPE_FIVE = "query5";
+ public static final String QUERY_TYPE_SIX = "query6";
+ public static final String QUERY_TYPE_SEVENE = "query7";
+
+ private static final String DATA_VIEW_LABEL = "Data View";
+ private static final String CLUSTER_VIEW_MEMBERS_ID = "clusterTotalMembersText";
+ private static final String CLUSTER_VIEW_SERVERS_ID = "clusterServersText";
+ private static final String CLUSTER_VIEW_LOCATORS_ID = "clusterLocatorsText";
+ private static final String CLUSTER_VIEW_REGIONS_ID = "clusterTotalRegionsText";
+ private static final String CLUSTER_CLIENTS_ID = "clusterClientsText";
+ private static final String CLUSTER_FUNCTIONS_ID = "clusterFunctions";
+ private static final String CLUSTER_UNIQUECQS_ID = "clusterUniqueCQs";
+ private static final String CLUSTER_SUBSCRIPTION_ID = "clusterSubscriptionsText";
+ private static final String CLUSTER_MEMORY_USAGE_ID = "currentMemoryUsage";
+ private static final String CLUSTER_THROUGHPUT_WRITES_ID = "currentThroughputWrites";
+ private static final String CLUSTER_GCPAUSES_ID = "currentGCPauses";
+ private static final String CLUSTER_WRITEPERSEC_ID = "writePerSec";
+ private static final String CLUSTER_READPERSEC_ID = "readPerSec";
+ private static final String CLUSTER_QUERIESPERSEC_ID = "queriesPerSec";
+ private static final String CLUSTER_PROCEDURE_ID = "clusterTxnCommittedText";
+ private static final String CLUSTER_TXNCOMMITTED_ID = "clusterTxnCommittedText";
+ private static final String CLUSTER_TXNROLLBACK_ID = "clusterTxnRollbackText";
+ private static final String MEMBER_VIEW_MEMBERNAME_ID = "memberName";
+ private static final String MEMBER_VIEW_REGION_ID = "memberRegionsCount";
+ private static final String MEMBER_VIEW_THREAD_ID = "threads";
+ private static final String MEMBER_VIEW_SOCKETS_ID = "sockets";
+ private static final String MEMBER_VIEW_LOADAVG_ID = "loadAverage";
+ private static final String MEMBER_VIEW_LISTENINGPORT_ID = "receiverListeningPort";
+ private static final String MEMBER_VIEW_LINKTHROUGHPUT_ID = "receiverLinkThroughput";
+ private static final String MEMBER_VIEW_AVGBATCHLATENCY_ID = "receiverAvgBatchLatency";
+ private static final String MEMBER_VIEW_HEAPUSAGE_ID = "memberHeapUsageAvg";
+ private static final String MEMBER_VIEW_JVMPAUSES_ID = "memberGcPausesAvg";
+ private static final String MEMBER_VIEW_CPUUSAGE_ID = "memberCPUUsageValue";
+ private static final String MEMBER_VIEW_READPERSEC_ID = "memberGetsPerSecValue";
+ private static final String MEMBER_VIEW_WRITEPERSEC_ID = "memberPutsPerSecValue";
+ private static final String MEMBER_VIEW_OFFHEAPFREESIZE_ID = "offHeapFreeSize";
+ private static final String MEMBER_VIEW_OFFHEAPUSEDSIZE_ID = "offHeapUsedSize";
+ private static final String MEMBER_VIEW_CLIENTS_ID = "clusterClientsText";
+
+ private static final String REGION_NAME_LABEL = "regionName";
+ private static final String REGION_PATH_LABEL = "regionPath";
+ private static final String REGION_TYPE_LABEL = "regionType";
+ private static final String DATA_VIEW_WRITEPERSEC = "regionWrites";
+ private static final String DATA_VIEW_READPERSEC = "regionReads";
+ private static final String DATA_VIEW_EMPTYNODES = "regionEmptyNodes";
+ private static final String DATA_VIEW_ENTRYCOUNT = "regionEntryCount";
+ private static final String REGION_PERSISTENCE_LABEL = "regionPersistence";
+ private static final String DATA_VIEW_USEDMEMORY = "memoryUsed";
+ private static final String DATA_VIEW_TOTALMEMORY = "totalMemory";
+
+ private static final String DATA_BROWSER_LABEL = "Data Browser";
+ private static final String DATA_BROWSER_REGIONName1 = "treeDemo_1_span";
+ private static final String DATA_BROWSER_REGIONName2 = "treeDemo_2_span";
+ private static final String DATA_BROWSER_REGIONName3 = "treeDemo_3_span";
+ private static final String DATA_BROWSER_REGION1_CHECKBOX = "treeDemo_1_check";
+ private static final String DATA_BROWSER_REGION2_CHECKBOX = "treeDemo_2_check";
+ private static final String DATA_BROWSER_REGION3_CHECKBOX = "treeDemo_3_check";
+ private static final String DATA_BROWSER_COLOCATED_REGION = "Colocated Regions";
+ private static final String DATA_BROWSER_COLOCATED_REGION_NAME1 = "treeDemo_1_span";
+ private static final String DATA_BROWSER_COLOCATED_REGION_NAME2 = "treeDemo_2_span";
+ private static final String DATA_BROWSER_COLOCATED_REGION_NAME3 = "treeDemo_3_span";
+
+ private static final String QUERY_STATISTICS_LABEL = "Query Statistics";
+ private static final String CLUSTER_VIEW_LABEL = "Cluster View";
+ private static final String CLUSTER_VIEW_GRID_ID = "default_treemap_button";
+ private static final String SERVER_GROUP_GRID_ID = "servergroups_treemap_button";
+ private static final String REDUNDANCY_GRID_ID = "redundancyzones_treemap_button";
+ private static final String MEMBER_DROPDOWN_ID = "Members";
+ private static final String DATA_DROPDOWN_ID = "Data";
+
+ private static final DecimalFormat df2 = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN);
+
+ public static void setUpServer(String username, String password, String jsonAuthFile) throws Exception {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+ jmxPropertiesFile = classLoader.getResource("test.properties").getPath();
+ path = getPulseWarPath();
+ server = Server.createServer(9999, jmxPropertiesFile, jsonAuthFile);
+
+ String host = "localhost";
+ int port = 8080;
+ String context = "/pulse";
+
+ jetty = JettyHelper.initJetty(host, port, SSLConfigurationFactory.getSSLConfigForComponent(SecurableCommunicationChannel.WEB));
+ JettyHelper.addWebApplication(jetty, context, getPulseWarPath());
+ jetty.start();
+
+ pulseURL = "http://" + host + ":" + port + context;
+
+ Awaitility.await().until(()->jetty.isStarted());
+
+ driver = new FirefoxDriver();
+ driver.manage().window().maximize();
+ driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
+ driver.get(pulseURL);
+ WebElement userNameElement = driver.findElement(By.id("user_name"));
+ WebElement passwordElement = driver.findElement(By.id("user_password"));
+ userNameElement.sendKeys(username);
+ passwordElement.sendKeys(password);
+ passwordElement.submit();
+
+ Thread.sleep(3000);
+ WebElement userNameOnPulsePage = (new WebDriverWait(driver, 10))
+ .until(new ExpectedCondition<WebElement>() {
+ @Override
+ public WebElement apply(WebDriver d) {
+ return d.findElement(By.id("userName"));
+ }
+ });
+ assertNotNull(userNameOnPulsePage);
+ driver.navigate().refresh();
+ Thread.sleep(7000);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ driver.close();
+ jetty.stop();
+ }
+
+ @Before
+ public void setup() throws Exception {
+ // Make sure we go to the home page first
+ searchByXPathAndClick(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ }
+
+ public static String getPulseWarPath() throws Exception {
+ String warPath = null;
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ InputStream inputStream = classLoader.getResourceAsStream("GemFireVersion.properties");
+ Properties properties = new Properties();
+ properties.load(inputStream);
+ String version = properties.getProperty("Product-Version");
+ warPath = "geode-pulse-" + version + ".war";
+ String propFilePath = classLoader.getResource("GemFireVersion.properties").getPath();
+ warPath = propFilePath.substring(0, propFilePath.indexOf("generated-resources")) + "libs/" + warPath;
+ return warPath;
+ }
+
+ protected void searchByLinkAndClick(String linkText) {
+ WebElement element = By.linkText(linkText).findElement(driver);
+ assertNotNull(element);
+ element.click();
+ }
+
+ protected void searchByIdAndClick(String id) {
+ WebElement element = driver.findElement(By.id(id));
+ assertNotNull(element);
+ element.click();
+ }
+
+ protected void searchByClassAndClick(String Class) {
+ WebElement element = driver.findElement(By.className(Class));
+ assertNotNull(element);
+ element.click();
+ }
+
+ protected void searchByXPathAndClick(String xpath) {
+ WebElement element = driver.findElement(By.xpath(xpath));
+ assertNotNull(element);
+ element.click();
+ }
+
+ protected void waitForElementByClassName(final String className, int seconds) {
+ WebElement linkTextOnPulsePage1 = (new WebDriverWait(driver, seconds))
+ .until(new ExpectedCondition<WebElement>() {
+ @Override
+ public WebElement apply(WebDriver d) {
+ return d.findElement(By.className(className));
+ }
+ });
+ assertNotNull(linkTextOnPulsePage1);
+ }
+
+ protected void waitForElementById(final String id, int seconds) {
+ WebElement element = (new WebDriverWait(driver, 10))
+ .until(new ExpectedCondition<WebElement>() {
+ @Override
+ public WebElement apply(WebDriver d) {
+ return d.findElement(By.id(id));
+ }
+ });
+ assertNotNull(element);
+ }
+
+ protected void scrollbarVerticalDownScroll() {
+ JavascriptExecutor js = (JavascriptExecutor) driver;
+ js.executeScript("javascript:window.scrollBy(250,700)");
+ WebElement pickerScroll = driver.findElement(By.className("jspDrag"));
+ WebElement pickerScrollCorner = driver.findElement(By
+ .className("jspCorner"));
+ Actions builder = new Actions(driver);
+ Actions movePicker = builder.dragAndDrop(pickerScroll, pickerScrollCorner);
+ // pickerscroll is the web element
+ movePicker.perform();
+ }
+
+ protected void scrollbarHorizontalRightScroll() {
+ JavascriptExecutor js = (JavascriptExecutor) driver;
+ js.executeScript("javascript:window.scrollBy(250,700)");
+ WebElement pickerScroll = driver
+ .findElement(By
+ .xpath("//div[@id='gview_queryStatisticsList']/div[3]/div/div[3]/div[2]/div"));
+ WebElement pickerScrollCorner = driver.findElement(By
+ .className("jspCorner"));
+ Actions builder = new Actions(driver);
+ Actions movePicker = builder.dragAndDrop(pickerScroll, pickerScrollCorner);
+ // pickerscroll is the web element
+ movePicker.perform();
+ }
+
+
+ @Test
+ public void testClusterLocatorCount() throws IOException {
+ String clusterLocators = driver
+ .findElement(By.id(CLUSTER_VIEW_LOCATORS_ID)).getText();
+
+ String totallocators = JMXProperties.getInstance().getProperty("server.S1.locatorCount");
+ assertEquals(totallocators, clusterLocators);
+ }
+
+ @Test
+ public void testClusterRegionCount() {
+ String clusterRegions = driver.findElement(By.id(CLUSTER_VIEW_REGIONS_ID))
+ .getText();
+ String totalregions = JMXProperties.getInstance().getProperty(
+ "server.S1.totalRegionCount");
+ assertEquals(totalregions, clusterRegions);
+ }
+
+ @Test
+ public void testClusterMemberCount() {
+ String clusterMembers = driver.findElement(By.id(CLUSTER_VIEW_MEMBERS_ID)).getText();
+ String totalMembers = JMXProperties.getInstance().getProperty("server.S1.memberCount");
+ assertEquals(totalMembers, clusterMembers);
+ }
+
+ @Test
+ public void testClusterNumClient() {
+ String clusterClients = driver.findElement(By.id(CLUSTER_CLIENTS_ID))
+ .getText();
+ String totalclients = JMXProperties.getInstance().getProperty(
+ "server.S1.numClients");
+ assertEquals(totalclients, clusterClients);
+ }
+
+ @Test
+ public void testClusterNumRunningFunction() {
+ String clusterFunctions = driver.findElement(By.id(CLUSTER_FUNCTIONS_ID))
+ .getText();
+ String totalfunctions = JMXProperties.getInstance().getProperty(
+ "server.S1.numRunningFunctions");
+ assertEquals(totalfunctions, clusterFunctions);
+ }
+
+ @Test
+ public void testClusterRegisteredCQCount() {
+ String clusterUniqueCQs = driver.findElement(By.id(CLUSTER_UNIQUECQS_ID))
+ .getText();
+ String totaluniqueCQs = JMXProperties.getInstance().getProperty(
+ "server.S1.registeredCQCount");
+ assertEquals(totaluniqueCQs, clusterUniqueCQs);
+ }
+
+ @Test
+ public void testClusterNumSubscriptions() {
+ String clusterSubscriptions = driver.findElement(
+ By.id(CLUSTER_SUBSCRIPTION_ID)).getText();
+ String totalSubscriptions = JMXProperties.getInstance().getProperty(
+ "server.S1.numSubscriptions");
+ assertEquals(totalSubscriptions, clusterSubscriptions);
+ }
+
+ @Test
+ public void testClusterJVMPausesWidget() {
+ String clusterJVMPauses = driver.findElement(By.id(CLUSTER_GCPAUSES_ID))
+ .getText();
+ String totalgcpauses = JMXProperties.getInstance().getProperty(
+ "server.S1.jvmPauses");
+ assertEquals(totalgcpauses, clusterJVMPauses);
+ }
+
+ @Test
+ public void testClusterAverageWritesWidget() {
+ String clusterWritePerSec = driver.findElement(
+ By.id(CLUSTER_WRITEPERSEC_ID)).getText();
+ String totalwritepersec = JMXProperties.getInstance().getProperty(
+ "server.S1.averageWrites");
+ assertEquals(totalwritepersec, clusterWritePerSec);
+ }
+
+ @Test
+ public void testClusterAverageReadsWidget() {
+ String clusterReadPerSec = driver.findElement(By.id(CLUSTER_READPERSEC_ID))
+ .getText();
+ String totalreadpersec = JMXProperties.getInstance().getProperty(
+ "server.S1.averageReads");
+ assertEquals(totalreadpersec, clusterReadPerSec);
+ }
+
+ @Test
+ public void testClusterQuerRequestRateWidget() {
+ String clusterQueriesPerSec = driver.findElement(
+ By.id(CLUSTER_QUERIESPERSEC_ID)).getText();
+ String totalqueriespersec = JMXProperties.getInstance().getProperty(
+ "server.S1.queryRequestRate");
+ assertEquals(totalqueriespersec, clusterQueriesPerSec);
+ }
+
+ @Test
+ public void testClusterGridViewMemberID() throws InterruptedException {
+ searchByIdAndClick("default_grid_button");
+ List<WebElement> elements = driver.findElements(By.xpath("//table[@id='memberList']/tbody/tr")); //gives me 11 rows
+
+ for (int memberCount = 1; memberCount < elements.size(); memberCount++) {
+ String memberId = driver.findElement(By.xpath("//table[@id='memberList']/tbody/tr[" + (memberCount + 1) + "]/td")).getText();
+ String propertMemeberId = JMXProperties.getInstance().getProperty("member.M" + memberCount + ".id");
+ assertEquals(memberId, propertMemeberId);
+ }
+ }
+
+ @Test
+ public void testClusterGridViewMemberName() {
+ searchByIdAndClick("default_grid_button");
+ List<WebElement> elements = driver.findElements(By.xpath("//table[@id='memberList']/tbody/tr"));
+ for (int memberNameCount = 1; memberNameCount < elements.size(); memberNameCount++) {
+ String gridMemberName = driver.findElement(By.xpath("//table[@id='memberList']/tbody/tr[" + (memberNameCount + 1) + "]/td[2]")).getText();
+ String memberName = JMXProperties.getInstance().getProperty("member.M" + memberNameCount + ".member");
+ assertEquals(gridMemberName, memberName);
+ }
+ }
+
+
+ @Test
+ public void testClusterGridViewMemberHost() {
+ searchByIdAndClick("default_grid_button");
+ List<WebElement> elements = driver.findElements(By.xpath("//table[@id='memberList']/tbody/tr"));
+ for (int memberHostCount = 1; memberHostCount < elements.size(); memberHostCount++) {
+ String MemberHost = driver.findElement(By.xpath("//table[@id='memberList']/tbody/tr[" + (memberHostCount + 1) + "]/td[3]")).getText();
+ String gridMemberHost = JMXProperties.getInstance().getProperty("member.M" + memberHostCount + ".host");
+ assertEquals(gridMemberHost, MemberHost);
+ }
+ }
+
+ @Test
+ public void testClusterGridViewHeapUsage() {
+ searchByIdAndClick("default_grid_button");
+ for (int i = 1; i <= 3; i++) {
+ Float HeapUsage = Float.parseFloat(driver
+ .findElement(
+ By.xpath("//table[@id='memberList']/tbody/tr[" + (i + 1) + "]/td[5]")).getText());
+ Float gridHeapUsagestring = Float.parseFloat(JMXProperties.getInstance()
+ .getProperty("member.M" + i + ".UsedMemory"));
+ assertEquals(gridHeapUsagestring, HeapUsage);
+ }
+ }
+
+ @Test
+ public void testClusterGridViewCPUUsage() throws Exception {
+ searchByIdAndClick("default_grid_button");
+ for (int i = 1; i <= 3; i++) {
+ String CPUUsage = driver.findElement(By.xpath("//table[@id='memberList']/tbody/tr[" + (i + 1) + "]/td[6]"))
+ .getText();
+ String gridCPUUsage = JMXProperties.getInstance().getProperty("member.M" + i + ".cpuUsage");
+ gridCPUUsage = gridCPUUsage.trim();
+ assertEquals(gridCPUUsage, CPUUsage);
+ }
+ }
+
+
+ public void testRgraphWidget() throws InterruptedException {
+ searchByIdAndClick("default_rgraph_button");
+ searchByIdAndClick("h1");
+ searchByIdAndClick("M1");
+ }
+
+ @Test // region count in properties file is 2 and UI is 1
+ public void testMemberTotalRegionCount() throws InterruptedException {
+ testRgraphWidget();
+ String RegionCount = driver.findElement(By.id(MEMBER_VIEW_REGION_ID)).getText();
+ String memberRegionCount = JMXProperties.getInstance().getProperty("member.M1.totalRegionCount");
+ assertEquals(memberRegionCount, RegionCount);
+ }
+
+ @Test
+ public void testMemberNumThread() throws InterruptedException {
+ searchByIdAndClick("default_grid_button");
+ searchByIdAndClick("M1&M1");
+ String ThreadCount = driver.findElement(By.id(MEMBER_VIEW_THREAD_ID)).getText();
+ String memberThreadCount = JMXProperties.getInstance().getProperty("member.M1.numThreads");
+ assertEquals(memberThreadCount, ThreadCount);
+ }
+
+ @Test
+ public void testMemberTotalFileDescriptorOpen() throws InterruptedException {
+ searchByIdAndClick("default_grid_button");
+ searchByIdAndClick("M1&M1");
+ String SocketCount = driver.findElement(By.id(MEMBER_VIEW_SOCKETS_ID))
+ .getText();
+ String memberSocketCount = JMXProperties.getInstance().getProperty(
+ "member.M1.totalFileDescriptorOpen");
+ assertEquals(memberSocketCount, SocketCount);
+ }
+
+ @Test
+ public void testMemberLoadAverage() throws InterruptedException {
+ searchByIdAndClick("default_grid_button");
+ searchByIdAndClick("M1&M1");
+ String LoadAvg = driver.findElement(By.id(MEMBER_VIEW_LOADAVG_ID))
+ .getText();
+ String memberLoadAvg = JMXProperties.getInstance().getProperty(
+ "member.M1.loadAverage");
+ assertEquals(df2.format(Double.valueOf(memberLoadAvg)), LoadAvg);
+ }
+
+ @Ignore("WIP") // May be useful in near future
+ @Test
+ public void testOffHeapFreeSize() {
+
+ String OffHeapFreeSizeString = driver.findElement(
+ By.id(MEMBER_VIEW_OFFHEAPFREESIZE_ID)).getText();
+ String OffHeapFreeSizetemp = OffHeapFreeSizeString.replaceAll("[a-zA-Z]",
+ "");
+ float OffHeapFreeSize = Float.parseFloat(OffHeapFreeSizetemp);
+ float memberOffHeapFreeSize = Float.parseFloat(JMXProperties.getInstance()
+ .getProperty("member.M1.OffHeapFreeSize"));
+ if (memberOffHeapFreeSize < 1048576) {
+ memberOffHeapFreeSize = memberOffHeapFreeSize / 1024;
+
+ }
+ else if (memberOffHeapFreeSize < 1073741824) {
+ memberOffHeapFreeSize = memberOffHeapFreeSize / 1024 / 1024;
+ }
+ else {
+ memberOffHeapFreeSize = memberOffHeapFreeSize / 1024 / 1024 / 1024;
+ }
+ memberOffHeapFreeSize = Float.parseFloat(new DecimalFormat("##.##")
+ .format(memberOffHeapFreeSize));
+ assertEquals(memberOffHeapFreeSize, OffHeapFreeSize);
+
+ }
+
+ @Ignore("WIP") // May be useful in near future
+ @Test
+ public void testOffHeapUsedSize() throws InterruptedException {
+
+ String OffHeapUsedSizeString = driver.findElement(
+ By.id(MEMBER_VIEW_OFFHEAPUSEDSIZE_ID)).getText();
+ String OffHeapUsedSizetemp = OffHeapUsedSizeString.replaceAll("[a-zA-Z]",
+ "");
+ float OffHeapUsedSize = Float.parseFloat(OffHeapUsedSizetemp);
+ float memberOffHeapUsedSize = Float.parseFloat(JMXProperties.getInstance()
+ .getProperty("member.M1.OffHeapUsedSize"));
+ if (memberOffHeapUsedSize < 1048576) {
+ memberOffHeapUsedSize = memberOffHeapUsedSize / 1024;
+
+ }
+ else if (memberOffHeapUsedSize < 1073741824) {
+ memberOffHeapUsedSize = memberOffHeapUsedSize / 1024 / 1024;
+ }
+ else {
+ memberOffHeapUsedSize = memberOffHeapUsedSize / 1024 / 1024 / 1024;
+ }
+ memberOffHeapUsedSize = Float.parseFloat(new DecimalFormat("##.##")
+ .format(memberOffHeapUsedSize));
+ assertEquals(memberOffHeapUsedSize, OffHeapUsedSize);
+ }
+
+ @Test
+ public void testMemberJVMPauses() throws Exception {
+ searchByIdAndClick("default_grid_button");
+ searchByIdAndClick("M1&M1");
+ String JVMPauses = driver.findElement(By.id(MEMBER_VIEW_JVMPAUSES_ID))
+ .getText();
+ String memberGcPausesAvg = JMXProperties.getInstance().getProperty(
+ "member.M1.JVMPauses");
+ assertEquals(memberGcPausesAvg, JVMPauses);
+ }
+
+ @Test
+ public void testMemberCPUUsage() {
+ searchByIdAndClick("default_grid_button");
+ searchByIdAndClick("M1&M1");
+ String CPUUsagevalue = driver.findElement(By.id(MEMBER_VIEW_CPUUSAGE_ID))
+ .getText();
+ String memberCPUUsage = JMXProperties.getInstance().getProperty(
+ "member.M1.cpuUsage");
+ assertEquals(memberCPUUsage, CPUUsagevalue);
+ }
+
+ @Test // difference between UI and properties file
+ public void testMemberAverageReads() {
+ searchByIdAndClick("default_grid_button");
+ searchByIdAndClick("M1&M1");
+ float ReadPerSec = Float.parseFloat(driver.findElement(By.id(MEMBER_VIEW_READPERSEC_ID)).getText());
+ float memberReadPerSec = Float.parseFloat(JMXProperties.getInstance().getProperty("member.M1.averageReads"));
+ memberReadPerSec = Float.parseFloat(new DecimalFormat("##.##")
+ .format(memberReadPerSec));
+ assertEquals(memberReadPerSec, ReadPerSec);
+ }
+
+ @Test
+ public void testMemberAverageWrites() throws InterruptedException {
+ testRgraphWidget();
+ String WritePerSec = driver.findElement(By.id(MEMBER_VIEW_WRITEPERSEC_ID))
+ .getText();
+ String memberWritePerSec = JMXProperties.getInstance().getProperty(
+ "member.M1.averageWrites");
+ assertEquals(memberWritePerSec, WritePerSec);
+ }
+
+
+ @Test
+ public void testMemberGridViewData() throws InterruptedException {
+ testRgraphWidget();
+ searchByXPathAndClick(PulseTestLocators.MemberDetailsView.gridButtonXpath);
+ // get the number of rows on the grid
+ List<WebElement> noOfRows = driver.findElements(By.xpath("//table[@id='memberRegionsList']/tbody/tr"));
+ String MemberRegionName = driver.findElement(By.xpath("//table[@id='memberRegionsList']/tbody/tr[2]/td[1]")).getText();
+ String memberRegionName = JMXProperties.getInstance().getProperty("region.R1.name");
+ assertEquals(memberRegionName, MemberRegionName);
+
+ String MemberRegionType = driver.findElement(By.xpath("//table[@id='memberRegionsList']/tbody/tr[2]/td[2]")).getText();
+ String memberRegionType = JMXProperties.getInstance().getProperty("region.R1.regionType");
+ assertEquals(memberRegionType, MemberRegionType);
+
+ String MemberRegionEntryCount = driver.findElement(By.xpath("//table[@id='memberRegionsList']/tbody/tr[2]/td[3]")).getText();
+ String memberRegionEntryCount = JMXProperties.getInstance().getProperty("regionOnMember./R1.M1.entryCount");
+ assertEquals(memberRegionEntryCount, MemberRegionEntryCount);
+ }
+
+ @Test
+ public void testDropDownList() throws InterruptedException {
+ searchByIdAndClick("default_grid_button");
+ searchByIdAndClick("M1&M1");
+ searchByIdAndClick("memberName");
+ searchByLinkAndClick("M3");
+ searchByIdAndClick("memberName");
+ searchByLinkAndClick("M2");
+ }
+
+ @Ignore("WIP")
+ @Test
+ public void testDataViewRegionName() throws InterruptedException {
+ searchByLinkAndClick(DATA_VIEW_LABEL);
+ Thread.sleep(7000);
+ searchByIdAndClick("default_grid_button");
+ String regionName = driver.findElement(By.id(REGION_NAME_LABEL)).getText();
+ String dataviewregionname = JMXProperties.getInstance().getProperty("region.R1.name");
+ assertEquals(dataviewregionname, regionName);
+ }
+
+ @Ignore("WIP")
+ @Test
+ public void testDataViewRegionPath() {
+ String regionPath = driver.findElement(By.id(REGION_PATH_LABEL)).getText();
+ String dataviewregionpath = JMXProperties.getInstance().getProperty(
+ "region.R1.fullPath");
+ assertEquals(dataviewregionpath, regionPath);
+ }
+
+ @Ignore("WIP")
+ @Test
+ public void testDataViewRegionType() {
+ String regionType = driver.findElement(By.id(REGION_TYPE_LABEL)).getText();
+ String dataviewregiontype = JMXProperties.getInstance().getProperty(
+ "region.R1.regionType");
+ assertEquals(dataviewregiontype, regionType);
+ }
+
+ @Ignore("WIP")
+ @Test
+ public void testDataViewEmptyNodes() {
+ String regionEmptyNodes = driver.findElement(By.id(DATA_VIEW_EMPTYNODES))
+ .getText();
+ String dataviewEmptyNodes = JMXProperties.getInstance().getProperty(
+ "region.R1.emptyNodes");
+ assertEquals(dataviewEmptyNodes, regionEmptyNodes);
+ }
+
+ @Ignore("WIP")
+ @Test
+ public void testDataViewSystemRegionEntryCount() {
+ String regionEntryCount = driver.findElement(By.id(DATA_VIEW_ENTRYCOUNT))
+ .getText();
+ String dataviewEntryCount = JMXProperties.getInstance().getProperty(
+ "region.R1.systemRegionEntryCount");
+ assertEquals(dataviewEntryCount, regionEntryCount);
+ }
+
+ @Ignore("WIP")
+ @Test
+ public void testDataViewPersistentEnabled() {
+ String regionPersistence = driver.findElement(
+ By.id(REGION_PERSISTENCE_LABEL)).getText();
+ String dataviewregionpersistence = JMXProperties.getInstance().getProperty(
+ "region.R1.persistentEnabled");
+ assertEquals(dataviewregionpersistence, regionPersistence);
+ }
+
+ @Ignore("WIP")
+ @Test
+ public void testDataViewDiskWritesRate() {
+ String regionWrites = driver.findElement(By.id(DATA_VIEW_WRITEPERSEC))
+ .getText();
+ String dataviewRegionWrites = JMXProperties.getInstance().getProperty(
+ "region.R1.diskWritesRate");
+ assertEquals(dataviewRegionWrites, regionWrites);
+ }
+
+ @Ignore("WIP")
+ @Test
+ public void testDataViewDiskReadsRate() {
+ String regionReads = driver.findElement(By.id(DATA_VIEW_READPERSEC))
+ .getText();
+ String dataviewRegionReads = JMXProperties.getInstance().getProperty(
+ "region.R1.diskReadsRate");
+ assertEquals(dataviewRegionReads, regionReads);
+ }
+
+ @Ignore("WIP")
+ @Test
+ public void testDataViewDiskUsage() {
+ String regionMemoryUsed = driver.findElement(By.id(DATA_VIEW_USEDMEMORY))
+ .getText();
+ String dataviewMemoryUsed = JMXProperties.getInstance().getProperty(
+ "region.R1.diskUsage");
+ assertEquals(dataviewMemoryUsed, regionMemoryUsed);
+ searchByLinkAndClick(QUERY_STATISTICS_LABEL);
+ }
+
+ @Ignore("WIP")
+ @Test
+ public void testDataViewGridValue() {
+ String DataViewRegionName = driver.findElement(
+ By.xpath("//*[id('6')/x:td[1]]")).getText();
+ String dataViewRegionName = JMXProperties.getInstance().getProperty(
+ "region.R1.name");
+ assertEquals(dataViewRegionName, DataViewRegionName);
+
+ String DataViewRegionType = driver.findElement(
+ By.xpath("//*[id('6')/x:td[2]")).getText();
+ String dataViewRegionType = JMXProperties.getInstance().getProperty(
+ "region.R2.regionType");
+ assertEquals(dataViewRegionType, DataViewRegionType);
+
+ String DataViewEntryCount = driver.findElement(
+ By.xpath("//*[id('6')/x:td[3]")).getText();
+ String dataViewEntryCount = JMXProperties.getInstance().getProperty(
+ "region.R2.systemRegionEntryCount");
+ assertEquals(dataViewEntryCount, DataViewEntryCount);
+
+ String DataViewEntrySize = driver.findElement(
+ By.xpath("//*[id('6')/x:td[4]")).getText();
+ String dataViewEntrySize = JMXProperties.getInstance().getProperty(
+ "region.R2.entrySize");
+ assertEquals(dataViewEntrySize, DataViewEntrySize);
+
+ }
+
+
+ public void loadDataBrowserpage() {
+ searchByLinkAndClick(DATA_BROWSER_LABEL);
+ //Thread.sleep(7000);
+ }
+
+ @Test
+ public void testDataBrowserRegionName() throws InterruptedException {
+ loadDataBrowserpage();
+ String DataBrowserRegionName1 = driver.findElement(By.id(DATA_BROWSER_REGIONName1))
+ .getText();
+ String databrowserRegionNametemp1 = JMXProperties.getInstance().getProperty(
+ "region.R1.name");
+ String databrowserRegionName1 = databrowserRegionNametemp1.replaceAll("[\\/]", "");
+ assertEquals(databrowserRegionName1, DataBrowserRegionName1);
+
+ String DataBrowserRegionName2 = driver.findElement(By.id(DATA_BROWSER_REGIONName2))
+ .getText();
+ String databrowserRegionNametemp2 = JMXProperties.getInstance().getProperty(
+ "region.R2.name");
+ String databrowserRegionName2 = databrowserRegionNametemp2.replaceAll("[\\/]", "");
+ assertEquals(databrowserRegionName2, DataBrowserRegionName2);
+
+ String DataBrowserRegionName3 = driver.findElement(By.id(DATA_BROWSER_REGIONName3))
+ .getText();
+ String databrowserRegionNametemp3 = JMXProperties.getInstance().getProperty(
+ "region.R3.name");
+ String databrowserRegionName3 = databrowserRegionNametemp3.replaceAll("[\\/]", "");
+ assertEquals(databrowserRegionName3, DataBrowserRegionName3);
+
+ }
+
+ @Test
+ public void testDataBrowserRegionMembersVerificaition() throws InterruptedException {
+ loadDataBrowserpage();
+ searchByIdAndClick(DATA_BROWSER_REGION1_CHECKBOX);
+ String DataBrowserMember1Name1 = driver.findElement(By.xpath("//label[@for='Member0']"))
+ .getText();
+ String DataBrowserMember1Name2 = driver.findElement(By.xpath("//label[@for='Member1']"))
+ .getText();
+ String DataBrowserMember1Name3 = driver.findElement(By.xpath("//label[@for='Member2']"))
+ .getText();
+ String databrowserMember1Names = JMXProperties.getInstance().getProperty(
+ "region.R1.members");
+
+ String databrowserMember1Names1 = databrowserMember1Names.substring(0, 2);
+ assertEquals(databrowserMember1Names1, DataBrowserMember1Name1);
+
+ String databrowserMember1Names2 = databrowserMember1Names.substring(3, 5);
+ assertEquals(databrowserMember1Names2, DataBrowserMember1Name2);
+
+ String databrowserMember1Names3 = databrowserMember1Names.substring(6, 8);
+ assertEquals(databrowserMember1Names3, DataBrowserMember1Name3);
+ searchByIdAndClick(DATA_BROWSER_REGION1_CHECKBOX);
+
+ searchByIdAndClick(DATA_BROWSER_REGION2_CHECKBOX);
+ String DataBrowserMember2Name1 = driver.findElement(By.xpath("//label[@for='Member0']"))
+ .getText();
+ String DataBrowserMember2Name2 = driver.findElement(By.xpath("//label[@for='Member1']"))
+ .getText();
+ String databrowserMember2Names = JMXProperties.getInstance().getProperty(
+ "region.R2.members");
+
+ String databrowserMember2Names1 = databrowserMember2Names.substring(0, 2);
+ assertEquals(databrowserMember2Names1, DataBrowserMember2Name1);
+
+ String databrowserMember2Names2 = databrowserMember2Names.substring(3, 5);
+ assertEquals(databrowserMember2Names2, DataBrowserMember2Name2);
+ searchByIdAndClick(DATA_BROWSER_REGION2_CHECKBOX);
+
+ searchByIdAndClick(DATA_BROWSER_REGION3_CHECKBOX);
+ String DataBrowserMember3Name1 = driver.findElement(By.xpath("//label[@for='Member0']"))
+ .getText();
+ String DataBrowserMember3Name2 = driver.findElement(By.xpath("//label[@for='Member1']"))
+ .getText();
+ String databrowserMember3Names = JMXProperties.getInstance().getProperty(
+ "region.R3.members");
+
+ String databrowserMember3Names1 = databrowserMember3Names.substring(0, 2);
+ assertEquals(databrowserMember3Names1, DataBrowserMember3Name1);
+
+ String databrowserMember3Names2 = databrowserMember3Names.substring(3, 5);
+ assertEquals(databrowserMember3Names2, DataBrowserMember3Name2);
+ searchByIdAndClick(DATA_BROWSER_REGION3_CHECKBOX);
+ }
+
+ @Test
+ public void testDataBrowserColocatedRegions() throws InterruptedException {
+ loadDataBrowserpage();
+ String databrowserMemberNames1 = JMXProperties.getInstance().getProperty(
+ "region.R1.members");
+ String databrowserMemberNames2 = JMXProperties.getInstance().getProperty(
+ "region.R2.members");
+ String databrowserMemberNames3 = JMXProperties.getInstance().getProperty(
+ "region.R3.members");
+
+ if ((databrowserMemberNames1.matches(databrowserMemberNames2 + "(.*)"))) {
+ if ((databrowserMemberNames1.matches(databrowserMemberNames3 + "(.*)"))) {
+ if ((databrowserMemberNames2.matches(databrowserMemberNames3 + "(.*)"))) {
+ System.out.println("R1, R2 and R3 are colocated regions");
+ }
+ }
+ }
+ searchByIdAndClick(DATA_BROWSER_REGION1_CHECKBOX);
+ searchByLinkAndClick(DATA_BROWSER_COLOCATED_REGION);
+ String DataBrowserColocatedRegion1 = driver.findElement(By.id(DATA_BROWSER_COLOCATED_REGION_NAME1))
+ .getText();
+ String DataBrowserColocatedRegion2 = driver.findElement(By.id(DATA_BROWSER_COLOCATED_REGION_NAME2))
+ .getText();
+ String DataBrowserColocatedRegion3 = driver.findElement(By.id(DATA_BROWSER_COLOCATED_REGION_NAME3))
+ .getText();
+
+ String databrowserColocatedRegiontemp1 = JMXProperties.getInstance().getProperty(
+ "region.R1.name");
+ String databrowserColocatedRegion1 = databrowserColocatedRegiontemp1.replaceAll("[\\/]", "");
+
+ String databrowserColocatedRegiontemp2 = JMXProperties.getInstance().getProperty(
+ "region.R2.name");
+ String databrowserColocatedRegion2 = databrowserColocatedRegiontemp2.replaceAll("[\\/]", "");
+
+ String databrowserColocatedRegiontemp3 = JMXProperties.getInstance().getProperty(
+ "region.R3.name");
+ String databrowserColocatedRegion3 = databrowserColocatedRegiontemp3.replaceAll("[\\/]", "");
+
+ assertEquals(databrowserColocatedRegion1, DataBrowserColocatedRegion1);
+ assertEquals(databrowserColocatedRegion2, DataBrowserColocatedRegion2);
+ assertEquals(databrowserColocatedRegion3, DataBrowserColocatedRegion3);
+
+ }
+
+ @Ignore("WIP") // clusterDetails element not found on Data Browser page. No assertions in test
+ @Test
+ public void testDataBrowserQueryValidation() throws IOException, InterruptedException {
+ loadDataBrowserpage();
+ WebElement textArea = driver.findElement(By.id("dataBrowserQueryText"));
+ textArea.sendKeys("query1");
+ WebElement executeButton = driver.findElement(By.id("btnExecuteQuery"));
+ executeButton.click();
+ String QueryResultHeader1 = driver.findElement(By.xpath("//div[@id='clusterDetails']/div/div/span[@class='n-title']")).getText();
+ double count = 0, countBuffer = 0, countLine = 0;
+ String lineNumber = "";
+ String filePath = "E:\\springsource\\springsourceWS\\Pulse-Cedar\\src\\main\\resources\\testQueryResultSmall.txt";
+ BufferedReader br;
+ String line = "";
+ br = new BufferedReader(new FileReader(filePath));
+ while ((line = br.readLine()) != null) {
+ countLine++;
+ String[] words = line.split(" ");
+
+ for (String word : words) {
+ if (word.equals(QueryResultHeader1)) {
+ count++;
+ countBuffer++;
+ }
+ }
+ }
+ }
+
+ public void testTreeMapPopUpData(String S1, String gridIcon) {
+ for (int i = 1; i <= 3; i++) {
+ searchByLinkAndClick(CLUSTER_VIEW_LABEL);
+ if (gridIcon.equals(SERVER_GROUP_GRID_ID)) {
+ WebElement ServerGroupRadio = driver.findElement(By.xpath("//label[@for='radio-servergroups']"));
+ ServerGroupRadio.click();
+ }
+ if (gridIcon.equals(REDUNDANCY_GRID_ID)) {
+ WebElement ServerGroupRadio = driver.findElement(By.xpath("//label[@for='radio-redundancyzones']"));
+ ServerGroupRadio.click();
+ }
+ searchByIdAndClick(gridIcon);
+ WebElement TreeMapMember = driver.findElement(By.xpath("//div[@id='" + S1 + "M" + (i) + "']/div"));
+ Actions builder = new Actions(driver);
+ builder.clickAndHold(TreeMapMember).perform();
+ int j = 1;
+ String CPUUsageM1temp = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div/div[2]/div"))
+ .getText();
+ String CPUUsageM1 = CPUUsageM1temp.replaceAll("[\\%]", "");
+ String cpuUsageM1 = JMXProperties.getInstance().getProperty(
+ "member.M" + (i) + ".cpuUsage");
+ assertEquals(cpuUsageM1, CPUUsageM1);
+
+ String MemoryUsageM1temp = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 1) + "]/div[2]/div"))
+ .getText();
+ String MemoryUsageM1 = MemoryUsageM1temp.replaceAll("MB", "");
+ String memoryUsageM1 = JMXProperties.getInstance().getProperty(
+ "member.M" + (i) + ".UsedMemory");
+ assertEquals(memoryUsageM1, MemoryUsageM1);
+
+ String LoadAvgM1 = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 2) + "]/div[2]/div"))
+ .getText();
+ String loadAvgM1 = JMXProperties.getInstance().getProperty(
+ "member.M" + (i) + ".loadAverage");
+ assertEquals(df2.format(Double.valueOf(loadAvgM1)), LoadAvgM1);
+
+
+ String ThreadsM1 = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 3) + "]/div[2]/div"))
+ .getText();
+ String threadsM1 = JMXProperties.getInstance().getProperty(
+ "member.M" + (i) + ".numThreads");
+ assertEquals(threadsM1, ThreadsM1);
+
+ String SocketsM1 = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 4) + "]/div[2]/div"))
+ .getText();
+ String socketsM1 = JMXProperties.getInstance().getProperty(
+ "member.M" + (i) + ".totalFileDescriptorOpen");
+ assertEquals(socketsM1, SocketsM1);
+ builder.moveToElement(TreeMapMember).release().perform();
+ }
+ }
+
+ @Test
+ public void testTopologyPopUpData() {
+ testTreeMapPopUpData("", CLUSTER_VIEW_GRID_ID);
+ }
+
+ @Test
+ public void testServerGroupTreeMapPopUpData() {
+ testTreeMapPopUpData("SG1(!)", SERVER_GROUP_GRID_ID);
+ }
+
+ @Test
+ public void testDataViewTreeMapPopUpData() {
+ searchByLinkAndClick(CLUSTER_VIEW_LABEL);
+ searchByLinkAndClick(DATA_DROPDOWN_ID);
+ WebElement TreeMapMember = driver.findElement(By.id("GraphTreeMapClusterData-canvas"));
+ Actions builder = new Actions(driver);
+ builder.clickAndHold(TreeMapMember).perform();
+ String RegionType = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div/div[2]/div"))
+ .getText();
+ String regionType = JMXProperties.getInstance().getProperty(
+ "region.R2.regionType");
+ assertEquals(regionType, RegionType);
+
+ String EntryCount = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[2]/div[2]/div"))
+ .getText();
+ String entryCount = JMXProperties.getInstance().getProperty(
+ "region.R2.systemRegionEntryCount");
+ assertEquals(entryCount, EntryCount);
+
+ String EntrySizetemp = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[3]/div[2]/div"))
+ .getText();
+ float EntrySize = Float.parseFloat(EntrySizetemp);
+ float entrySize = Float.parseFloat(JMXProperties.getInstance().getProperty(
+ "region.R2.entrySize"));
+ entrySize = entrySize / 1024 / 1024;
+ entrySize = Float.parseFloat(new DecimalFormat("##.####")
+ .format(entrySize));
+ assertEquals(entrySize, EntrySize);
+ builder.moveToElement(TreeMapMember).release().perform();
+ }
+
+ @Test
+ public void testRegionViewTreeMapPopUpData() {
+ searchByLinkAndClick(CLUSTER_VIEW_LABEL);
+ searchByLinkAndClick(DATA_DROPDOWN_ID);
+ WebElement TreeMapMember = driver.findElement(By.id("GraphTreeMapClusterData-canvas"));
+ TreeMapMember.click();
+ }
+
+ @Ignore("WIP")
+ @Test
+ public void testNumberOfRegions() throws InterruptedException {
+
+ driver.findElement(By.xpath("//a[text()='Data Browser']")).click();
+
+ Thread.sleep(1000);
+ List<WebElement> regionList = driver.findElements(By.xpath("//ul[@id='treeDemo']/li"));
+ String regions = JMXProperties.getInstance().getProperty("regions");
+ String[] regionName = regions.split(" ");
+ for (String string : regionName) {
+ }
+ //JMXProperties.getInstance().getProperty("region.R1.regionType");
+ int i = 1;
+ for (WebElement webElement : regionList) {
+ //webElement.getAttribute(arg0)
+ i++;
+ }
+
+ driver.findElement(By.id("treeDemo_1_check")).click();
+
+ List<WebElement> memeberList = driver.findElements(By.xpath("//ul[@id='membersList']/li"));
+ int j = 0;
+ for (WebElement webElement : memeberList) {
+ j++;
+ }
+ }
+
+ @Ignore("WIP")
+ @Test
+ public void testDataBrowser() {
+
+ driver.findElement(By.linkText("Data Browser")).click();
+ // WebElement dataBrowserLabel = driver.findElement(By.xpath(""));
+ WebDriverWait wait = new WebDriverWait(driver, 20);
+ wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//label[text()='Data Browser']"))));
+
+
+ // Verify all elements must be displayed on data browser screen
+ assertTrue(driver.findElement(By.xpath("//a[text()='Data Regions']")).isDisplayed());
+ assertTrue(driver.findElement(By.id("linkColocatedRegions")).isDisplayed());
+ assertTrue(driver.findElement(By.linkText("All Regions")).isDisplayed());
+
+ assertTrue(driver.findElement(By.xpath("//a[text()='Region Members']")).isDisplayed());
+
+ assertTrue(driver.findElement(By.xpath("//a[text()='Queries']")).isDisplayed());
+ assertTrue(driver.findElement(By.xpath("//label[text()='Query Editor']")).isDisplayed());
+ assertTrue(driver.findElement(By.xpath("//label[text()='Result']")).isDisplayed());
+ assertTrue(driver.findElement(By.xpath("//input[@value='Export Result']")).isDisplayed());
+ assertTrue(driver.findElement(By.id("btnExecuteQuery")).isDisplayed());
+ assertTrue(driver.findElement(By.xpath("//input[@value='Clear']")).isDisplayed());
+ assertTrue(driver.findElement(By.id("dataBrowserQueryText")).isDisplayed());
+
+ assertTrue(driver.findElement(By.id("historyIcon")).isDisplayed());
+
+ //Actual query execution
+
+ driver.findElement(By.id("dataBrowserQueryText")).sendKeys("Query1");
+
+ // Assert data regions are displayed
+ assertTrue(driver.findElement(By.id("treeDemo_1")).isDisplayed());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAuthTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAuthTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAuthTest.java
new file mode 100644
index 0000000..e5e30d2
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAuthTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.tests;
+
+import org.apache.geode.test.junit.categories.UITest;
+import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
+import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
+
+@Category(UITest.class)
+@FixMethodOrder(MethodSorters.JVM)
+public class PulseAuthTest extends PulseAbstractTest {
+
+ @BeforeClass
+ public static void beforeClassSetup() throws Exception {
+ setUpServer("pulseUser", "12345", "/pulse-auth.json");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAutomatedTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAutomatedTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAutomatedTest.java
new file mode 100644
index 0000000..90e1bd9
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/PulseAutomatedTest.java
@@ -0,0 +1,784 @@
+/*
+ *
+ * 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.
+ *
+ */
+/**
+* This test class contains automated tests for Pulse application related to
+* 1. Different grid data validations for example - Topology, Server Group, Redundancy Zone
+* 2. Data Browser
+* 3.
+*
+*
+* @version 1.0
+* @since GemFire 2014-04-02
+*/
+package com.vmware.geode.tools.pulse.tests;
+
+import static org.junit.Assert.*;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import org.apache.geode.test.junit.categories.UITest;
+
+@Category(UITest.class)
+public class PulseAutomatedTest extends PulseAbstractTest {
+
+ @BeforeClass
+ public static void beforeClassSetup() throws Exception {
+ setUpServer("pulseUser", "12345", "/pulse-auth.json");
+ }
+
+ @Test
+ public void serverGroupGridDataValidation() {
+ navigateToServerGroupGridView();
+ validateServerGroupGridData();
+ }
+
+ @Test
+ public void redundancyZonesGridDataValidation() {
+ navigateToRedundancyZonesGridView();
+ validateRedundancyZonesGridData();
+ }
+
+ @Test
+ public void topologyGridDataValidation() {
+ navigateToTopologyGridView();
+ validateTopologyGridData();
+ }
+
+ @Test
+ public void dataViewGridDataValidation() {
+ navigateToDataPrespectiveGridView();
+ validateDataPrespectiveGridData();
+ }
+
+ @Test
+ public void regionDetailsGridDataValidation() {
+ navigateToRegionDetailsGridView();
+ validateRegionDetailsGridData();
+
+ }
+
+ @Test
+ public void regionDetailsNavigationTest() {
+ navigateToRegionDetailsView();
+ assertEquals("/R2", getTextUsingId(PulseTestLocators.RegionDetailsView.regionNameDivId));
+ }
+
+ @Test
+ public void regionName() {
+ navigateToRegionDetailsView();
+ assertEquals(getPropertyValue("region.R2.name"), getTextUsingId(PulseTestLocators.RegionDetailsView.regionNameDivId));
+ }
+
+ @Test
+ public void regionPath() {
+ navigateToRegionDetailsView();
+ assertEquals(getPropertyValue("region.R2.fullPath"),
+ getTextUsingId(PulseTestLocators.RegionDetailsView.regionPathId));
+ }
+
+ @Test
+ public void regionType() {
+ navigateToRegionDetailsView();
+ assertEquals(getPropertyValue("region.R2.regionType"),
+ getTextUsingId(PulseTestLocators.RegionDetailsView.regionTypeId));
+ }
+
+ @Test
+ public void regionMembers() {
+ navigateToRegionDetailsView();
+ assertEquals(getPropertyValue("region.R2.memberCount"),
+ getTextUsingId(PulseTestLocators.RegionDetailsView.regionMembersTextId));
+ }
+
+ @Test
+ public void regionEmptyNodes() {
+ navigateToRegionDetailsView();
+ assertEquals(getPropertyValue("region.R2.emptyNodes"),
+ getTextUsingId(PulseTestLocators.RegionDetailsView.regionEmptyNodesId));
+ }
+
+ @Test
+ public void regionEntryCount() {
+ navigateToRegionDetailsView();
+ assertEquals(getPropertyValue("region.R2.systemRegionEntryCount"),
+ getTextUsingId(PulseTestLocators.RegionDetailsView.regionEntryCountTextId));
+ }
+
+ @Test
+ public void regionDiskUsage() {
+ navigateToRegionDetailsView();
+ assertEquals(getPropertyValue("region.R2.diskUsage"),
+ getTextUsingId(PulseTestLocators.RegionDetailsView.regionDiskUsageId));
+ }
+
+ @Test
+ public void regionPersistence() {
+ navigateToRegionDetailsView();
+ assertEquals(getPersistanceEnabled(getPropertyValue("region.R2.persistentEnabled")),
+ getTextUsingId(PulseTestLocators.RegionDetailsView.regionPersistenceId));
+ }
+
+ @Ignore("WIP")
+ @Test
+ public void regionMemoryUsage() {
+ navigateToRegionDetailsView();
+ // need to check the respective property values
+ }
+
+ @Test
+ public void regionInMemoryRead() {
+ navigateToRegionDetailsView();
+ assertEquals(getPropertyValue("region.R2.getsRate"),
+ getTextUsingId(PulseTestLocators.RegionDetailsView.inMemoryReadsId));
+
+ }
+
+ @Test
+ public void regionInMemoryWrites() {
+ navigateToRegionDetailsView();
+ assertEquals(getPropertyValue("region.R2.putsRate"),
+ getTextUsingId(PulseTestLocators.RegionDetailsView.inMemoryWritesId));
+ }
+
+ @Test
+ public void regionDiskRead() {
+ navigateToRegionDetailsView();
+ assertEquals(getPropertyValue("region.R2.diskReadsRate"),
+ getTextUsingId(PulseTestLocators.RegionDetailsView.diskReadsId));
+ }
+
+ @Test
+ public void regionDiskWrites() {
+ navigateToRegionDetailsView();
+ assertEquals(getPropertyValue("region.R2.diskWritesRate"),
+ getTextUsingId(PulseTestLocators.RegionDetailsView.diskWritesId));
+ }
+
+ @Test
+ public void clickHostShowsMemberTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.nodeH1Id);
+ verifyElementPresentById(PulseTestLocators.TopologyView.memberM1Id);
+ clickElementUsingId(PulseTestLocators.TopologyView.nodeH2Id);
+ verifyElementPresentById(PulseTestLocators.TopologyView.memberM2Id);
+ clickElementUsingId(PulseTestLocators.TopologyView.nodeH3Id);
+ verifyElementPresentById(PulseTestLocators.TopologyView.memberM3Id);
+ }
+
+ @Test
+ @Ignore("Issue with highlighting")
+ public void verifyHostTooltipsOfTopologyGraphTest() {
+ for (int i = 1; i <=3; i++) {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ mouseClickAndHoldOverElementById("h" + i);
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.hostNameTTXpath, getPropertyValue("member.M" + i + ".host"));
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.cpuUsageTTXpath, "0%");
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memoryUsageTTXpath, getPropertyValue("member.M" + i
+ + ".UsedMemory"));
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.loadAvgTTXpath, getPropertyValue("member.M" + i
+ + ".loadAverage"));
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.soketsTTXpath, getPropertyValue("member.M" + i
+ + ".totalFileDescriptorOpen"));
+ mouseReleaseById("h" + i);
+ driver.navigate().refresh();
+ }
+ }
+
+ @Ignore("Issues with member tooltip xpath")
+ @Test
+ public void verifyMemberTooltipsOfTopologyGraphTest() {
+
+ verifyElementPresentById(PulseTestLocators.TopologyView.nodeH1Id);
+ clickElementUsingId(PulseTestLocators.TopologyView.nodeH1Id);
+ mouseClickAndHoldOverElementById(PulseTestLocators.TopologyView.memberM1Id);
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memNameTTXpath, getPropertyValue("member.M1.member"));
+ //verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memCpuUsageTTXpath, getPropertyValue("member.M1.cpuUsage") + "%");
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.jvmPausesTTXpath, getPropertyValue("member.M1.JVMPauses"));
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.regionsTTXpath, getPropertyValue("member.M1.totalRegionCount"));
+ verifyElementPresentById(PulseTestLocators.TopologyView.nodeH2Id);
+ clickElementUsingId(PulseTestLocators.TopologyView.nodeH2Id);
+ mouseClickAndHoldOverElementById(PulseTestLocators.TopologyView.memberM2Id);
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memNameTTXpath, getPropertyValue("member.M2.member"));
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memCpuUsageTTXpath, getPropertyValue("member.M2.cpuUsage") + "%");
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.jvmPausesTTXpath, getPropertyValue("member.M2.JVMPauses"));
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.regionsTTXpath, getPropertyValue("member.M2.totalRegionCount"));
+
+ verifyElementPresentById(PulseTestLocators.TopologyView.nodeH3Id);
+ clickElementUsingId(PulseTestLocators.TopologyView.nodeH3Id);
+ mouseClickAndHoldOverElementById(PulseTestLocators.TopologyView.memberM3Id);
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memNameTTXpath, getPropertyValue("member.M3.member"));
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memCpuUsageTTXpath, getPropertyValue("member.M3.cpuUsage") + "%");
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.jvmPausesTTXpath, getPropertyValue("member.M3.JVMPauses"));
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.regionsTTXpath, getPropertyValue("member.M3.totalRegionCount"));
+
+ }
+
+ @Test
+ public void VerifyRGraphTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ verifyElementPresentById(PulseTestLocators.TopologyView.nodeH1Id);
+ verifyElementPresentById(PulseTestLocators.TopologyView.nodeH2Id);
+ verifyElementPresentById(PulseTestLocators.TopologyView.nodeH3Id);
+ }
+
+ @Test
+ public void clickMembersOfTopologyGraphTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.nodeH1Id);
+ clickElementUsingId(PulseTestLocators.TopologyView.memberM1Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.nodeH2Id);
+ clickElementUsingId(PulseTestLocators.TopologyView.memberM2Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.nodeH3Id);
+ clickElementUsingId(PulseTestLocators.TopologyView.memberM3Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
+ }
+
+ @Test
+ public void clickTreeMapViewShowingTreeMapTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
+ verifyElementPresentById(PulseTestLocators.TopologyView.memberM1Id);
+ verifyElementPresentById(PulseTestLocators.TopologyView.memberM2Id);
+ verifyElementPresentById(PulseTestLocators.TopologyView.memberM3Id);
+ }
+
+ @Test
+ public void verifyMembersPresentInTreeMapTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
+ verifyElementPresentById(PulseTestLocators.TopologyView.memberM1Id);
+ verifyElementPresentById(PulseTestLocators.TopologyView.memberM2Id);
+ verifyElementPresentById(PulseTestLocators.TopologyView.memberM3Id);
+ verifyTextPresrntById(PulseTestLocators.TopologyView.memberM1Id, "M1");
+ verifyTextPresrntById(PulseTestLocators.TopologyView.memberM2Id, "M2");
+ verifyTextPresrntById(PulseTestLocators.TopologyView.memberM3Id, "M3");
+ }
+
+ @Test
+ public void clickMemberNavigatingToCorrespondingRegionTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
+ verifyElementPresentById(PulseTestLocators.TopologyView.memberM1Id);
+ verifyTextPresrntById(PulseTestLocators.TopologyView.memberM1Id, "M1");
+ clickElementUsingId(PulseTestLocators.TopologyView.memberM1Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
+ verifyElementPresentById(PulseTestLocators.TopologyView.memberM2Id);
+ verifyTextPresrntById(PulseTestLocators.TopologyView.memberM2Id, "M2");
+ clickElementUsingId(PulseTestLocators.TopologyView.memberM2Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
+ verifyElementPresentById(PulseTestLocators.TopologyView.memberM3Id);
+ verifyTextPresrntById(PulseTestLocators.TopologyView.memberM3Id, "M3");
+ clickElementUsingId(PulseTestLocators.TopologyView.memberM3Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
+ }
+
+ @Test
+ public void clickGridButtonShowsGridTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.idM1Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.nameM1Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.hostH1Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.idM2Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.nameM2Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.hostH2Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.idM3Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.nameM3Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.hostH3Xpath);
+ }
+
+ @Test
+ public void verifyMembersPresentInGridTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.nameM1Xpath);
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.nameM1Xpath, "M1");
+
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.nameM2Xpath);
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.nameM2Xpath, "M2");
+
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.nameM3Xpath);
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.nameM3Xpath, "M3");
+ }
+
+ @Test
+ public void verifyHostNamesInGridTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.hostH1Xpath);
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.hostH1Xpath, "h1");
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.hostH2Xpath);
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.hostH2Xpath, "h2");
+ verifyElementPresentByXpath(PulseTestLocators.TopologyView.hostH3Xpath);
+ verifyTextPresrntByXpath(PulseTestLocators.TopologyView.hostH3Xpath, "h3");
+ }
+
+ @Test
+ public void clickOnGridMemNameNavigatingToCorrespondingRegionTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
+ clickElementUsingXpath(PulseTestLocators.TopologyView.nameM1Xpath);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
+
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
+ clickElementUsingXpath(PulseTestLocators.TopologyView.nameM2Xpath);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
+
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
+ clickElementUsingXpath(PulseTestLocators.TopologyView.nameM3Xpath);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
+ }
+
+ @Test
+ public void verifyMembersPresentInSvrGrpTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrpsRadioXpath);
+ verifyElementPresentById(PulseTestLocators.ServerGroups.serverGrp1Id);
+ verifyElementPresentById(PulseTestLocators.ServerGroups.serverGrp2Id);
+ verifyElementPresentById(PulseTestLocators.ServerGroups.serverGrp3Id);
+
+ verifyElementPresentById(PulseTestLocators.ServerGroups.sg1M1Id);
+ verifyElementPresentById(PulseTestLocators.ServerGroups.sg1M2Id);
+ verifyElementPresentById(PulseTestLocators.ServerGroups.sg1M3Id);
+
+ verifyElementPresentById(PulseTestLocators.ServerGroups.sg2M1Id);
+ verifyElementPresentById(PulseTestLocators.ServerGroups.sg2M2Id);
+
+ verifyElementPresentById(PulseTestLocators.ServerGroups.sg3M3Id);
+ }
+
+ @Test
+ public void expandAndCloseServerGroupsTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ //waitForElement(findElementByXpath(PulseTestLocators.ServerGroups.serverGrpsRadioXpath));
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrpsRadioXpath);
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrp1Xpath);
+ verifyElementAttributeById(PulseTestLocators.ServerGroups.serverGrp1Id, "style", "width: 720px; height: 415px;");
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrp1Xpath);
+ verifyElementAttributeById(PulseTestLocators.ServerGroups.serverGrp1Id, "style", "width: 239.667px; height: 399px;");
+
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrp2Xpath);
+ verifyElementAttributeById(PulseTestLocators.ServerGroups.serverGrp2Id, "style", "width: 720px; height: 415px;");
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrp2Xpath);
+ verifyElementAttributeById(PulseTestLocators.ServerGroups.serverGrp2Id, "style", "width: 239.667px; height: 399px;");
+
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrp3Xpath);
+ verifyElementAttributeById(PulseTestLocators.ServerGroups.serverGrp3Id, "style", "width: 720px; height: 415px;");
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrp3Xpath);
+ verifyElementAttributeById(PulseTestLocators.ServerGroups.serverGrp3Id, "style", "width: 239.667px; height: 399px;");
+ }
+
+ @Test
+ public void verifyMembersInServGrpTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrpsRadioXpath);
+
+ verifyTextPresrntById(PulseTestLocators.ServerGroups.serverGrp1Id, "SG1");
+ verifyTextPresrntById(PulseTestLocators.ServerGroups.serverGrp2Id, "SG2");
+ verifyTextPresrntById(PulseTestLocators.ServerGroups.serverGrp3Id, "SG3");
+
+ verifyTextPresrntById(PulseTestLocators.ServerGroups.sg1M1Id, "M1");
+ verifyTextPresrntById(PulseTestLocators.ServerGroups.sg1M2Id, "M2");
+ verifyTextPresrntById(PulseTestLocators.ServerGroups.sg1M3Id, "M3");
+
+ verifyTextPresrntById(PulseTestLocators.ServerGroups.sg2M1Id, "M1");
+ verifyTextPresrntById(PulseTestLocators.ServerGroups.sg2M2Id, "M2");
+
+ verifyTextPresrntById(PulseTestLocators.ServerGroups.sg3M3Id, "M3");
+ }
+
+ @Test
+ public void memberNavigationFromServGrpTest() {
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrpsRadioXpath);
+ clickElementUsingId(PulseTestLocators.ServerGroups.sg1M1Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
+ navigateToServerGroupTreeView();
+ clickElementUsingId(PulseTestLocators.ServerGroups.sg1M2Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
+ navigateToServerGroupTreeView();
+ clickElementUsingId(PulseTestLocators.ServerGroups.sg1M3Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
+ navigateToServerGroupTreeView();
+ clickElementUsingId(PulseTestLocators.ServerGroups.sg2M1Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
+ navigateToServerGroupTreeView();
+ clickElementUsingId(PulseTestLocators.ServerGroups.sg2M2Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
+ navigateToServerGroupTreeView();
+ clickElementUsingId(PulseTestLocators.ServerGroups.sg3M3Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
+ }
+
+ @Test
+ public void clickServGrpGridButtonShowsGridTest() {
+ navigateToServerGroupGridView();
+ verifyElementPresentByXpath(PulseTestLocators.ServerGroups.idSG1M3Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.ServerGroups.idSG1M2Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.ServerGroups.idSG1M1Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.ServerGroups.nameM3Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.ServerGroups.nameM2Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.ServerGroups.nameM1Xpath);
+
+ }
+
+ @Test
+ public void memberNavigationFromServGrpGridTest() {
+ navigateToServerGroupGridView();
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.idSG1M3Xpath);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
+ navigateToServerGroupGridView();
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.idSG1M1Xpath);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
+ navigateToServerGroupGridView();
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.idSG1M2Xpath);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
+ }
+
+ @Test
+ public void verifyZonePresentTest() {
+ navigateToRedundancyZonesTreeView();
+ verifyElementPresentByXpath(PulseTestLocators.RedundancyZone.zoneRZ1RZ2Xpath);
+ verifyElementPresentById(PulseTestLocators.RedundancyZone.zoneRZ2Id);
+ }
+
+ @Test
+ public void expandAndCloseRdncyZoneTest() {
+ navigateToRedundancyZonesTreeView();
+ clickElementUsingXpath(PulseTestLocators.RedundancyZone.zoneRZ1RZ2Xpath);
+ verifyElementAttributeById(PulseTestLocators.RedundancyZone.zoneRZ1Id, "style", "width: 720px; height: 415px;");
+ clickElementUsingXpath(PulseTestLocators.RedundancyZone.zoneRZ1RZ2Xpath);
+ clickElementUsingXpath(PulseTestLocators.RedundancyZone.zoneRZ2Xpath);
+ verifyElementAttributeById(PulseTestLocators.RedundancyZone.zoneRZ2Id, "style", "width: 720px; height: 415px;");
+
+ }
+
+ @Test
+ public void clickRZMembersNavigationTest() {
+ navigateToRedundancyZonesTreeView();
+ clickElementUsingId(PulseTestLocators.RedundancyZone.m1RZ1RZ2Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
+ navigateToRedundancyZonesTreeView();
+ clickElementUsingId(PulseTestLocators.RedundancyZone.m2RZ1Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
+ navigateToRedundancyZonesTreeView();
+ clickElementUsingId(PulseTestLocators.RedundancyZone.m3RZ2Id);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
+ }
+
+ @Test
+ public void clickRZGridShowingGridTest() {
+ navigateToRedundancyZonesGridView();
+ verifyElementPresentByXpath(PulseTestLocators.RedundancyZone.idM2Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.RedundancyZone.idM1Xpath);
+ verifyElementPresentByXpath(PulseTestLocators.RedundancyZone.idM3Xpath);
+ verifyTextPresrntByXpath(PulseTestLocators.RedundancyZone.idM2Xpath, "M2");
+ verifyTextPresrntByXpath(PulseTestLocators.RedundancyZone.idM1Xpath, "M1");
+ verifyTextPresrntByXpath(PulseTestLocators.RedundancyZone.idM3Xpath, "M3");
+ }
+
+ @Test
+ public void clickRZGridMembersNavigationTest() {
+ navigateToRedundancyZonesGridView();
+ clickElementUsingXpath(PulseTestLocators.RedundancyZone.idM2Xpath);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
+ navigateToRedundancyZonesGridView();
+ clickElementUsingXpath(PulseTestLocators.RedundancyZone.idM1Xpath);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
+ navigateToRedundancyZonesGridView();
+ clickElementUsingXpath(PulseTestLocators.RedundancyZone.idM3Xpath);
+ verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
+ }
+
+
+ @Test
+ public void verifySortingOptionsTest(){
+ clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
+ clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
+ verifyElementPresentById(PulseTestLocators.TopologyView.hotSpotId);
+ clickElementUsingId(PulseTestLocators.TopologyView.hotSpotId);
+ verifyElementPresentByLinkText("Heap Usage");
+ verifyElementPresentByLinkText("CPU Usage");
+ }
+
+ /*
+ * HotSpot test scripts -
+ */
+ //--- Topology view
+
+ @Test
+ public void testHotSpotOptPrsntOnTopologyView(){
+ navigateToTopologyTreeView();
+ assertEquals(PulseTestData.Topology.hotSpotHeapLbl, getTextUsingId(PulseTestLocators.TopologyView.hotSpotId));
+ }
+
+ @Test
+ public void testHotSpotOptionsTopologyView(){
+ navigateToTopologyTreeView();
+ clickElementUsingId(PulseTestLocators.TopologyView.hotSpotId);
+ assertEquals(PulseTestData.Topology.hotSpotHeapLbl, getTextUsingXpath(PulseTestLocators.TopologyView.heapUsageXpath));
+ assertEquals(PulseTestData.Topology.hotSpotCPULbl, getTextUsingXpath(PulseTestLocators.TopologyView.cpuUsageXpath));
+ }
+
+ @Test
+ public void testCpuUsageNavigationOnTopologyView(){
+ navigateToTopologyTreeView();
+ clickElementUsingId(PulseTestLocators.TopologyView.hotSpotId);
+ clickElementUsingXpath(PulseTestLocators.TopologyView.cpuUsageXpath);
+ assertEquals(PulseTestData.Topology.hotSpotCPULbl, getTextUsingId(PulseTestLocators.TopologyView.hotSpotId));
+ }
+
+ @Test
+ public void testHeapUsageNavigationOnTopologyView(){
+ navigateToTopologyTreeView();
+ clickElementUsingId(PulseTestLocators.TopologyView.hotSpotId);
+ clickElementUsingXpath(PulseTestLocators.TopologyView.heapUsageXpath);
+ assertEquals(PulseTestData.Topology.hotSpotHeapLbl, getTextUsingId(PulseTestLocators.TopologyView.hotSpotId));
+ }
+
+ @Test
+ public void testSortingUsingCpuUsageOnTopologyView(){
+ navigateToTopologyTreeView();
+ clickElementUsingId(PulseTestLocators.TopologyView.hotSpotId);
+ clickElementUsingXpath(PulseTestLocators.TopologyView.cpuUsageXpath);
+ assertMemberSortingByCpuUsage();
+ }
+
+ @Test
+ public void testSortingUsingHeapUsageOnTopologyView(){
+ navigateToTopologyTreeView();
+ clickElementUsingId(PulseTestLocators.TopologyView.hotSpotId);
+ clickElementUsingXpath(PulseTestLocators.TopologyView.heapUsageXpath);
+ assertMemberSortingByHeapUsage();
+ }
+
+ //--- Server Group view
+
+ @Test
+ public void testHotSpotOptPrsntOnServerGroupView(){
+ navigateToServerGroupTreeView();
+ assertEquals(PulseTestData.ServerGroups.hotSpotHeapLbl, getTextUsingId(PulseTestLocators.ServerGroups.hotSpotId));
+ }
+
+ @Test
+ public void testHotSpotOptionsServerGroupView(){
+ navigateToServerGroupTreeView();
+ clickElementUsingId(PulseTestLocators.ServerGroups.hotSpotId);
+ assertEquals(PulseTestData.ServerGroups.hotSpotHeapLbl, getTextUsingXpath(PulseTestLocators.ServerGroups.heapUsageXpath));
+ assertEquals(PulseTestData.ServerGroups.hotSpotCPULbl, getTextUsingXpath(PulseTestLocators.ServerGroups.cpuUsageXpath));
+ }
+
+ @Test
+ public void testCpuUsageNavigationOnServerGroupView(){
+ navigateToServerGroupTreeView();
+ clickElementUsingId(PulseTestLocators.ServerGroups.hotSpotId);
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.cpuUsageXpath);
+ assertEquals(PulseTestData.ServerGroups.hotSpotCPULbl, getTextUsingId(PulseTestLocators.ServerGroups.hotSpotId));
+ }
+
+ @Test
+ public void testHeapUsageNavigationOnServerGroupView(){
+ navigateToServerGroupTreeView();
+ clickElementUsingId(PulseTestLocators.ServerGroups.hotSpotId);
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.heapUsageXpath);
+ assertEquals(PulseTestData.ServerGroups.hotSpotHeapLbl, getTextUsingId(PulseTestLocators.ServerGroups.hotSpotId));
+ }
+
+ @Test
+ public void testSortingUsingHeapUsageOnServerGroupView(){
+ navigateToServerGroupTreeView();
+ clickElementUsingId(PulseTestLocators.ServerGroups.hotSpotId);
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.heapUsageXpath);
+ assertMemberSortingBySgHeapUsage();
+ }
+
+ @Test
+ public void testSortingUsingCpuUsageOnServerGroupView(){
+ navigateToServerGroupTreeView();
+ clickElementUsingId(PulseTestLocators.ServerGroups.hotSpotId);
+ clickElementUsingXpath(PulseTestLocators.ServerGroups.cpuUsageXpath);
+ assertMemberSortingBySgCpuUsage();
+ }
+
+ //--- Redundancy Zone view
+
+ @Test
+ public void testHotSpotOptPrsntOnRedundancyZoneView(){
+ navigateToRedundancyZonesTreeView();
+ assertEquals(PulseTestData.RedundancyZone.hotSpotHeapLbl, getTextUsingId(PulseTestLocators.RedundancyZone.hotSpotId));
+ }
+
+
+ @Test
+ public void testHotSpotOptionsRedundancyZoneView(){
+ // navigate to Redundancy Zones - Tree View
+ navigateToRedundancyZonesTreeView();
+ clickElementUsingId(PulseTestLocators.RedundancyZone.hotSpotId);
+ assertEquals(PulseTestData.RedundancyZone.hotSpotHeapLbl, getTextUsingXpath(PulseTestLocators.RedundancyZone.heapUsageXpath));
+ assertEquals(PulseTestData.RedundancyZone.hotSpotCPULbl, getTextUsingXpath(PulseTestLocators.RedundancyZone.cpuUsageXpath));
+ }
+
+ @Test
+ public void testCpuUsageNavigationOnRedundancyZoneView(){
+ // navigate to Redundancy Zones - Tree View
+ navigateToRedundancyZonesTreeView();
+ clickElementUsingId(PulseTestLocators.RedundancyZone.hotSpotId);
+ clickElementUsingXpath(PulseTestLocators.RedundancyZone.cpuUsageXpath);
+ assertEquals(PulseTestData.RedundancyZone.hotSpotCPULbl, getTextUsingId(PulseTestLocators.RedundancyZone.hotSpotId));
+ }
+
+ @Test
+ public void testHeapUsageNavigationOnRedundancyZoneView(){
+ // navigate to Redundancy Zones - Tree View
+ navigateToRedundancyZonesTreeView();
+ clickElementUsingId(PulseTestLocators.RedundancyZone.hotSpotId);
+ clickElementUsingXpath(PulseTestLocators.RedundancyZone.heapUsageXpath);
+ assertEquals(PulseTestData.RedundancyZone.hotSpotHeapLbl, getTextUsingId(PulseTestLocators.RedundancyZone.hotSpotId));
+ }
+
+ @Test
+ public void testSortingUsingHeapUsageOnRedundancyView(){
+ // navigate to Redundancy Zones - Tree View
+ navigateToRedundancyZonesTreeView();
+ clickElementUsingId(PulseTestLocators.RedundancyZone.hotSpotId);
+ clickElementUsingXpath(PulseTestLocators.RedundancyZone.heapUsageXpath);
+ assertMemberSortingByRzHeapUsage();
+ }
+
+ @Test
+ public void testSortingUsingCpuUsageOnRedundancyView(){
+ // navigate to Redundancy Zones - Tree View
+ navigateToRedundancyZonesTreeView();
+ clickElementUsingId(PulseTestLocators.RedundancyZone.hotSpotId);
+ clickElementUsingXpath(PulseTestLocators.RedundancyZone.cpuUsageXpath);
+ assertMemeberSortingByRzCpuUsage();
+ }
+
+ @Test
+ public void testDataBrowserFilterFeature(){
+ // navigate to Data browser page
+ loadDataBrowserpage();
+ List<WebElement> regionLst = getRegionsFromDataBrowser();
+ String []regionNames = new String[regionLst.size()];
+ for(int regionIndex = 0; regionIndex < regionLst.size(); regionIndex++){
+ regionNames[regionIndex] = findElementByXpath(PulseTestLocators.DataBrowser.rgnSpanFirstPart + (regionIndex + 1 ) + PulseTestLocators.DataBrowser.rgnSpanSecondPart).getText();
+ }
+ // type each region name in region filter and verify respective region(s) are displayed in region list
+ for (String region : regionNames) {
+ findElementById(PulseTestLocators.DataBrowser.rgnFilterTxtBoxId).clear();
+ findElementById(PulseTestLocators.DataBrowser.rgnFilterTxtBoxId).sendKeys(region);
+
+ List<WebElement> regionLst1 = getRegionsFromDataBrowser();
+
+ for(int regionIndex = 1; regionIndex <= regionLst1.size(); regionIndex++){
+ assertEquals(region, findElementByXpath(PulseTestLocators.DataBrowser.rgnSpanFirstPart + regionIndex + PulseTestLocators.DataBrowser.rgnSpanSecondPart).getText());
+ }
+ }
+ }
+
+ @Test
+ public void testDataBrowserFilterPartialRegionName(){
+ // navigate to Data browser page
+ loadDataBrowserpage();
+ findElementById(PulseTestLocators.DataBrowser.rgnFilterTxtBoxId).clear();
+
+ // type partial region name in region filter and verify that all the regions that contains that text displays
+ findElementById(PulseTestLocators.DataBrowser.rgnFilterTxtBoxId).sendKeys(PulseTestData.DataBrowser.partialRgnName);
+ List<WebElement> regionLst = getRegionsFromDataBrowser();
+
+ for(int regionIndex = 0; regionIndex < regionLst.size(); regionIndex++){
+ assertTrue(findElementByXpath(PulseTestLocators.DataBrowser.rgnSpanFirstPart +
+ (regionIndex + 1 ) +
+ PulseTestLocators.DataBrowser.rgnSpanSecondPart).
+ getText().
+ contains(PulseTestData.DataBrowser.partialRgnName));
+ }
+ }
+
+ @Test
+ public void testDataBrowserClearButton(){
+ // navigate to Data browser page
+ loadDataBrowserpage();
+
+ sendKeysUsingId(PulseTestLocators.DataBrowser.queryEditorTxtBoxId, PulseTestData.DataBrowser.query1Text);
+ String editorTextBeforeClear = getTextUsingId(PulseTestLocators.DataBrowser.queryEditorTxtBoxId);
+ clickElementUsingXpath(PulseTestLocators.DataBrowser.btnClearXpath);
+ String editorTextAfterClear = getTextUsingId(PulseTestLocators.DataBrowser.queryEditorTxtBoxId);
+
+ assertFalse(PulseTestData.DataBrowser.query1Text.equals(editorTextAfterClear));
+ }
+
+ @Ignore("WIP") // Data Browser's Query History not showing any data on button click, therefore this test is failing
+ @Test
+ public void testDataBrowserHistoryQueue(){
+ // navigate to Data browser page
+ loadDataBrowserpage();
+
+ List<WebElement> numOfReg = driver.findElements(By.xpath(PulseTestLocators.DataBrowser.divDataRegions));
+
+ for(int i = 1; i <= numOfReg.size(); i ++){
+ if(getTextUsingId("treeDemo_" + i + "_span").equals( PulseTestData.DataBrowser.regName)){
+ searchByIdAndClick("treeDemo_" + i + "_check"); //driver.findElement(By.id("treeDemo_" + i + "_check")).click();
+ }
+ }
+
+ sendKeysUsingId(PulseTestLocators.DataBrowser.queryEditorTxtBoxId, PulseAbstractTest.QUERY_TYPE_ONE);
+ clickElementUsingId(PulseTestLocators.DataBrowser.btnExecuteQueryId);
+
+ //Get required datetime format and extract date and hours from date time.
+ DateFormat dateFormat = new SimpleDateFormat(PulseTestData.DataBrowser.datePattern);
+ String queryDateTime = dateFormat.format(System.currentTimeMillis());
+ String queryTime[] = queryDateTime.split(":");
+ System.out.println("Query Time from System: " + queryTime[0]);
+
+
+ clickElementUsingId(PulseTestLocators.DataBrowser.historyIcon);
+ List<WebElement> historyLst = driver.findElements(By.xpath(PulseTestLocators.DataBrowser.historyLst));
+ String queryText = findElementByXpath(PulseTestLocators.DataBrowser.historyLst)
+ .findElement(By.cssSelector(PulseTestLocators.DataBrowser.queryText)).getText();
+ String historyDateTime = findElementByXpath(PulseTestLocators.DataBrowser.historyLst)
+ .findElement(By.cssSelector(PulseTestLocators.DataBrowser.historyDateTime)).getText();
+ System.out.println("Query Text from History Table: " + queryText);
+ System.out.println("Query Time from History Table: " + historyDateTime);
+ //verify the query text, query datetime in history panel
+ assertTrue(PulseAbstractTest.QUERY_TYPE_ONE.equals(queryText));
+ assertTrue(historyDateTime.contains(queryTime[0]));
+
+ }
+}
[03/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/BaseServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/BaseServiceTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/BaseServiceTest.java
new file mode 100644
index 0000000..29fae16
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/BaseServiceTest.java
@@ -0,0 +1,254 @@
+/*
+ *
+ * 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.tests.junit;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.geode.test.junit.categories.UITest;
+import com.google.gson.JsonObject;
+import com.vmware.geode.tools.pulse.internal.json.JSONObject;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.methods.RequestBuilder;
+import org.apache.http.cookie.Cookie;
+import org.apache.http.impl.client.BasicCookieStore;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+import java.util.List;
+import java.util.Properties;
+
+
+/**
+ * Base class to be extended by other JUnit test classes. This class defines and automatically invokes test for testing server login-logout so no need to add
+ * this test in each sub-class. It also provides doLogin(), doLogout() and print error functionality as protected
+ * functions.
+ *
+ * <b>Sub-classes should ensure that they call doLogin() in @BeforeClass and doLogout() in @AfterClass otherwise tests will fail.</b>
+ *
+ *
+ */
+@Ignore
+@Category(UITest.class)
+public abstract class BaseServiceTest {
+
+ protected static Properties propsForJUnit = new Properties();
+ protected static String strHost = null;
+ protected static String strPort = null;
+ protected static String LOGIN_URL;
+ protected static String LOGOUT_URL;
+ protected static String IS_AUTHENTICATED_USER_URL;
+ protected static String PULSE_UPDATE_URL;
+
+ protected static final String PULSE_UPDATE_PARAM = "pulseData";
+ protected static final String PULSE_UPDATE_1_VALUE = "{'ClusterSelectedRegion':{'regionFullPath':'/GlobalVilage_2/GlobalVilage_9'}}";
+ protected static final String PULSE_UPDATE_2_VALUE = "{'ClusterSelectedRegion':{'regionFullPath':'/Rubbish'}}";
+
+ protected static final String PULSE_UPDATE_3_VALUE = "{'ClusterSelectedRegionsMember':{'regionFullPath':'/GlobalVilage_2/GlobalVilage_9'}}";
+ protected static final String PULSE_UPDATE_4_VALUE = "{'ClusterSelectedRegionsMember':{'regionFullPath':'/Rubbish'}}";
+
+ protected static final String PULSE_UPDATE_5_VALUE = "{'MemberGatewayHub':{'memberName':'pnq-visitor1'}}";
+ protected static final String PULSE_UPDATE_6_VALUE = "{'MemberGatewayHub':{'memberName':'pnq-visitor2'}}";
+ protected static CloseableHttpClient httpclient = null;
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ InputStream stream = BaseServiceTest.class.getClassLoader().getResourceAsStream("pulse.properties");
+
+ try {
+ propsForJUnit.load(stream);
+ } catch (Exception exProps) {
+ System.out.println("BaseServiceTest :: Error loading properties from pulse.properties in classpath");
+ }
+ strHost = propsForJUnit.getProperty("pulse.host");
+ strPort = propsForJUnit.getProperty("pulse.port");
+ System.out.println(
+ "BaseServiceTest :: Loaded properties from classpath. Checking properties for hostname. Hostname found = " + strHost);
+ LOGIN_URL = "http://" + strHost + ":" + strPort + "/pulse/j_spring_security_check";
+ LOGOUT_URL = "http://" + strHost + ":" + strPort + "/pulse/clusterLogout";
+ IS_AUTHENTICATED_USER_URL = "http://" + strHost + ":" + strPort + "/pulse/authenticateUser";
+ PULSE_UPDATE_URL = "http://" + strHost + ":" + strPort + "/pulse/pulseUpdate";
+
+ }
+ /**
+ *
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ doLogout();
+ System.out.println("BaseServiceTest :: Setup done");
+ }
+
+ /**
+ *
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ doLogin();
+ System.out.println("BaseServiceTest :: Teardown done");
+ }
+
+ /**
+ * Login to pulse server and setup httpClient for tests
+ * To be called from setupBeforeClass in each test class
+ */
+ protected static void doLogin() throws Exception {
+ System.out.println("BaseServiceTest :: Executing doLogin with user : admin, password : admin.");
+
+ CloseableHttpResponse loginResponse = null;
+ try{
+ BasicCookieStore cookieStore = new BasicCookieStore();
+ httpclient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
+ HttpUriRequest login = RequestBuilder.post().setUri(new URI(LOGIN_URL))
+ .addParameter("j_username", "admin").addParameter("j_password", "admin")
+ .build();
+ loginResponse = httpclient.execute(login);
+ try {
+ HttpEntity entity = loginResponse.getEntity();
+ EntityUtils.consume(entity);
+ System.out.println("BaseServiceTest :: HTTP request status : " + loginResponse.getStatusLine());
+
+ List<Cookie> cookies = cookieStore.getCookies();
+ if (cookies.isEmpty()) {
+ } else {
+ for (int i = 0; i < cookies.size(); i++) {
+ }
+ }
+ } finally {
+ if(loginResponse != null)
+ loginResponse.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ throw failed;
+ }
+
+ System.out.println("BaseServiceTest :: Executed doLogin");
+ }
+
+ /**
+ * Logout to pulse server and close httpClient
+ * To be called from setupAfterClass in each test class
+ */
+ protected static void doLogout() throws Exception {
+ System.out.println("BaseServiceTest :: Executing doLogout with user : admin, password : admin.");
+ if(httpclient != null){
+ CloseableHttpResponse logoutResponse = null;
+ try{
+ HttpUriRequest logout = RequestBuilder.get().setUri(new URI(LOGOUT_URL))
+ .build();
+ logoutResponse = httpclient.execute(logout);
+ try {
+ HttpEntity entity = logoutResponse.getEntity();
+ EntityUtils.consume(entity);
+ } finally {
+ if(logoutResponse != null)
+ logoutResponse.close();
+ httpclient.close();
+ httpclient = null;
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ throw failed;
+ }
+ System.out.println("BaseServiceTest :: Executed doLogout");
+ } else{
+ System.out.println("BaseServiceTest :: User NOT logged-in");
+ }
+ }
+
+ /**
+ * Print exception string to system.out
+ *
+ * @param failed
+ */
+ protected static void logException(Exception failed){
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ failed.printStackTrace(pw);
+ System.out.println("BaseServiceTest :: Logging exception details : " + sw.getBuffer().toString());
+ }
+
+ /**
+ *
+ * Tests that service returns json object
+ *
+ * Test method for {@link com.vmware.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
+ */
+ @Test
+ public void testServerLoginLogout() {
+ System.out.println("BaseServiceTest :: ------TESTCASE BEGIN : SERVER LOGIN-LOGOUT------");
+ try{
+ doLogin();
+
+ HttpUriRequest pulseupdate = RequestBuilder.get()
+ .setUri(new URI(IS_AUTHENTICATED_USER_URL))
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("BaseServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("BaseServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JsonNode jsonObj = mapper.readTree(jsonResp);
+ boolean isUserLoggedIn = jsonObj.get("isUserLoggedIn").booleanValue();
+ Assert.assertNotNull("BaseServiceTest :: Server returned null response in 'isUserLoggedIn'", isUserLoggedIn);
+ Assert.assertTrue("BaseServiceTest :: User login failed for this username, password", (isUserLoggedIn == true));
+ } finally {
+ response.close();
+ }
+
+ doLogout();
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ System.out.println("BaseServiceTest :: ------TESTCASE END : SERVER LOGIN-LOGOUT------");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java
new file mode 100644
index 0000000..22adcaf
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionServiceTest.java
@@ -0,0 +1,340 @@
+/*
+ *
+ * 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.tests.junit;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.methods.RequestBuilder;
+import org.apache.http.util.EntityUtils;
+import org.junit.*;
+
+import com.vmware.geode.tools.pulse.internal.json.JSONArray;
+import com.vmware.geode.tools.pulse.internal.json.JSONObject;
+
+/**
+ * JUnit Tests for ClusterSelectedRegionService in the back-end server for region detail page
+ *
+ *
+ */
+@Ignore
+public class ClusterSelectedRegionServiceTest extends BaseServiceTest {
+
+ /**
+ *
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ doLogin();
+ System.out.println("\n\nClusterSelectedRegionServiceTest :: Setup done");
+ }
+
+ /**
+ *
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ doLogout();
+ System.out.println("ClusterSelectedRegionServiceTest :: Teardown done");
+ }
+
+ /**
+ *
+ * @throws java.lang.Exception
+ */
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ *
+ * @throws java.lang.Exception
+ */
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Tests that service returns json object
+ *
+ */
+ @Test
+ public void testResponseNotNull() {
+ System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE BEGIN : NULL RESPONSE CHECK FOR CLUSTER REGIONS------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_1_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for ClusterSelectedRegion", jsonObj.getJSONObject("ClusterSelectedRegion"));
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
+ }
+ System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE END : NULL RESPONSE CHECK FOR CLUSTER REGIONS------\n");
+ }
+
+ /**
+ *
+ * Tests that response is for same logged in user
+ *
+ */
+ @Test
+ public void testResponseUsername() {
+ System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE BEGIN : NULL USERNAME IN RESPONSE CHECK FOR CLUSTER REGIONS------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_1_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegion");
+ Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for ClusterSelectedRegion", clusterSelectedRegionObj);
+ String szUser = clusterSelectedRegionObj.getString("userName");
+ Assert.assertEquals("ClusterSelectedRegionServiceTest :: Server returned wrong user name. Expected was admin. Server returned = " + szUser, szUser, "admin");
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
+ }
+ System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE END : NULL USERNAME IN RESPONSE CHECK FOR CLUSTER REGIONS------\n");
+ }
+
+ /**
+ *
+ * Tests that response is for same region
+ *
+ * Test method for {@link com.vmware.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
+ *
+ */
+ @Test
+ public void testResponseRegionPathMatches() {
+ System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE BEGIN : REGION PATH IN RESPONSE CHECK FOR CLUSTER REGIONS------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_1_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegion");
+ Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for ClusterSelectedRegion",clusterSelectedRegionObj);
+ JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegion");
+ Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for selectedRegion",jsonObjRegion);
+ Assert.assertTrue("ClusterSelectedRegionServiceTest :: Server did not return 'path' of region",jsonObjRegion.has("path"));
+ String szPath = jsonObjRegion.getString("path");
+ Assert.assertEquals("ClusterSelectedRegionServiceTest :: Server returned wrong region path. Expected region path = /GlobalVilage_2/GlobalVilage_9 , actual region path = " + szPath, szPath, "/GlobalVilage_2/GlobalVilage_9");
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
+ }
+ System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE END : REGION PATH IN RESPONSE CHECK FOR CLUSTER REGIONS------\n");
+ }
+
+ /**
+ *
+ * Tests that response is for same region
+ *
+ * Test method for {@link com.vmware.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
+ *
+ */
+ @Test
+ public void testResponseNonExistentRegion() {
+ System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE BEGIN : NON-EXISTENT REGION CHECK FOR CLUSTER REGIONS------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_2_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegion");
+ Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for ClusterSelectedRegion",clusterSelectedRegionObj);
+ JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegion");
+ Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response for selectedRegion",jsonObjRegion);
+ Assert.assertTrue("ClusterSelectedRegionServiceTest :: Server did not return error on non-existent region",jsonObjRegion.has("errorOnRegion"));
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
+ }
+ System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE END : NON-EXISTENT REGION CHECK FOR CLUSTER REGIONS------\n");
+ }
+
+ /**
+ *
+ * Tests that service returns json object
+ *
+ * Test method for {@link com.vmware.geode.tools.pulse.internal.service.ClusterSelectedRegionService#execute(javax.servlet.http.HttpServletRequest)}.
+ *
+ */
+ @Test
+ public void testResponseMemerberCount() {
+ System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE BEGIN : MISMATCHED MEMBERCOUNT FOR REGION CHECK FOR CLUSTER REGIONS------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_1_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("ClusterSelectedRegionServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("ClusterSelectedRegionServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegion");
+ Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null ClusterSelectedRegion",clusterSelectedRegionObj);
+ JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegion");
+ Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null for selectedRegion",jsonObjRegion);
+ Assert.assertTrue("ClusterSelectedRegionServiceTest :: Server did not return 'memberCount' of region",jsonObjRegion.has("memberCount"));
+ int memberCount = jsonObjRegion.getInt("memberCount");
+ Assert.assertTrue("ClusterSelectedRegionServiceTest :: Server did not return 'members' of region",jsonObjRegion.has("members"));
+ JSONArray arrMembers = jsonObjRegion.getJSONArray("members");
+ Assert.assertNotNull("ClusterSelectedRegionServiceTest :: Server returned null response in selectedRegion",arrMembers);
+ int members = arrMembers.length();
+ Assert.assertEquals("ClusterSelectedRegionServiceTest :: Server returned mismatched member count and region members", members, memberCount);
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("ClusterSelectedRegionServiceTest :: No Http connection was established.");
+ }
+ System.out.println("ClusterSelectedRegionServiceTest :: ------TESTCASE END : MISMATCHED MEMBERCOUNT FOR REGION CHECK FOR CLUSTER REGIONS------\n");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java
new file mode 100644
index 0000000..54b96ba
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/ClusterSelectedRegionsMemberServiceTest.java
@@ -0,0 +1,354 @@
+/*
+ *
+ * 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.tests.junit;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+import java.util.Iterator;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.methods.RequestBuilder;
+import org.apache.http.util.EntityUtils;
+import org.junit.*;
+
+import com.vmware.geode.tools.pulse.internal.json.JSONObject;
+
+/**
+ * JUnit Tests for ClusterSelectedRegionsMemberService in the back-end server for region detail page
+ *
+ *
+ */
+@Ignore
+public class ClusterSelectedRegionsMemberServiceTest extends BaseServiceTest {
+
+ /**
+ * @throws java.lang.Exception
+ *
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ doLogin();
+ System.out.println("\n\nClusterSelectedRegionsMemberServiceTest :: Setup done");
+ }
+
+ /**
+ * @throws java.lang.Exception
+ *
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ doLogout();
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: Teardown done");
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ System.out.println("running setup -- ClusterSelectedRegionsMemberServiceTest");
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ System.out.println("running teardown -- ClusterSelectedRegionsMemberServiceTest");
+ }
+
+ /**
+ * Tests that service returns json object
+ *
+ */
+ @Test
+ public void testResponseNotNull() {
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE BEGIN : NULL RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_3_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for ClusterSelectedRegionsMember", jsonObj.getJSONObject("ClusterSelectedRegionsMember"));
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
+ }
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE END : NULL RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+ }
+
+ /**
+ *
+ * Tests that response is for same logged in user
+ *
+ */
+ @Test
+ public void testResponseUsername() {
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE BEGIN : NULL USERNAME IN RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_3_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegionsMember");
+ Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for ClusterSelectedRegionsMember", clusterSelectedRegionObj);
+ Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server did not return 'userName' in request",clusterSelectedRegionObj.has("userName"));
+ String szUser = clusterSelectedRegionObj.getString("userName");
+ Assert.assertEquals("ClusterSelectedRegionsMemberServiceTest :: Server returned wrong user name. Expected was admin. Server returned = " + szUser, szUser, "admin");
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
+ }
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE END : NULL USERNAME IN RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+ }
+
+ /**
+ *
+ * Tests that response is for same region
+ *
+ *
+ */
+ @Test
+ public void testResponseRegionOnMemberInfoMatches() {
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE BEGIN : MEMBER INFO RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_3_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegionsMember");
+ Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for ClusterSelectedRegionsMember",clusterSelectedRegionObj);
+ JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegionsMembers");
+ Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for selectedRegionsMembers",jsonObjRegion);
+ Iterator<String> itrMemberNames = jsonObjRegion.keys();
+ Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null region on member info", itrMemberNames);
+ while(itrMemberNames.hasNext()){
+ String szMemberName = itrMemberNames.next();
+ Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null member name", szMemberName);
+ Assert.assertTrue("Server did not return member details",jsonObjRegion.has(szMemberName));
+ JSONObject jsonMemberObj = jsonObjRegion.getJSONObject(szMemberName);
+
+ Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server did not return 'regionFullPath' of region on member",jsonMemberObj.has("regionFullPath"));
+ String szPath = jsonMemberObj.getString("regionFullPath");
+ Assert.assertEquals("ClusterSelectedRegionsMemberServiceTest :: Server returned wrong region path for region on member", szPath, "/GlobalVilage_2/GlobalVilage_9");
+ }
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
+ }
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE END : MEMBER INFO RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+ }
+
+ /**
+ *
+ * Tests that response is for same region
+ *
+ *
+ */
+ @Test
+ public void testResponseNonExistentRegion() {
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE BEGIN : NON-EXISTENT REGION CHECK FOR CLUSTER REGION MEMBERS------");
+ if(httpclient != null){
+ try{
+ System.out.println("Test for non-existent region : /Rubbish");
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_4_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegionsMember");
+ Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null for ClusterSelectedRegionsMember",clusterSelectedRegionObj);
+ JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegionsMembers");
+ Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null for selectedRegionsMembers",jsonObjRegion);
+ Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server did not return error on non-existent region",jsonObjRegion.has("errorOnRegion"));
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
+ }
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE END : NON-EXISTENT REGION CHECK FOR CLUSTER REGION MEMBERS------");
+ }
+
+ /**
+ *
+ * Tests that response is for same region
+ *
+ *
+ */
+ @Test
+ public void testResponseRegionOnMemberAccessor() {
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE BEGIN : ACCESSOR RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_3_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ JSONObject clusterSelectedRegionObj = jsonObj.getJSONObject("ClusterSelectedRegionsMember");
+ Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for ClusterSelectedRegionsMember",clusterSelectedRegionObj);
+ JSONObject jsonObjRegion = clusterSelectedRegionObj.getJSONObject("selectedRegionsMembers");
+ Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null response for selectedRegionsMembers",jsonObjRegion);
+ Iterator<String> itrMemberNames = jsonObjRegion.keys();
+ Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null region on member info", itrMemberNames);
+ while(itrMemberNames.hasNext()){
+ String szMemberName = itrMemberNames.next();
+ Assert.assertNotNull("ClusterSelectedRegionsMemberServiceTest :: Server returned null member name", szMemberName);
+ Assert.assertTrue("Server did not return member details",jsonObjRegion.has(szMemberName));
+ JSONObject jsonMemberObj = jsonObjRegion.getJSONObject(szMemberName);
+
+ Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server did not return 'accessor' of region on member",jsonMemberObj.has("accessor"));
+ String szAccessor = jsonMemberObj.getString("accessor");
+ Assert.assertTrue("ClusterSelectedRegionsMemberServiceTest :: Server returned non-boolean value for accessor attribute", ((szAccessor.equalsIgnoreCase("True"))
+ || (szAccessor.equalsIgnoreCase("False"))) );
+ }
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("ClusterSelectedRegionsMemberServiceTest :: No Http connection was established.");
+ }
+ System.out.println("ClusterSelectedRegionsMemberServiceTest :: ------TESTCASE END : ACCESSOR RESPONSE CHECK FOR CLUSTER REGION MEMBERS------");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java
new file mode 100644
index 0000000..0a2fe0a
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/junit/MemberGatewayHubServiceTest.java
@@ -0,0 +1,412 @@
+/*
+ *
+ * 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.tests.junit;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.methods.RequestBuilder;
+import org.apache.http.util.EntityUtils;
+import org.junit.*;
+
+import com.vmware.geode.tools.pulse.internal.json.JSONArray;
+import com.vmware.geode.tools.pulse.internal.json.JSONObject;
+
+/**
+ * JUnit Tests for MemberGatewayHubService in the back-end server for region detail page
+ *
+ *
+ */
+@Ignore
+public class MemberGatewayHubServiceTest extends BaseServiceTest {
+
+ /**
+ *
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ doLogin();
+ System.out.println("\n\nMemberGatewayHubServiceTest :: Setup done");
+ }
+
+ /**
+ *
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ doLogout();
+ System.out.println("MemberGatewayHubServiceTest :: Teardown done");
+ }
+
+ /**
+ *
+ * @throws java.lang.Exception
+ */
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ *
+ * @throws java.lang.Exception
+ */
+ @Override
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Tests that service returns json object
+ *
+ */
+ @Test
+ public void testResponseNotNull() {
+ System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE BEGIN : NULL RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE --------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", jsonObj.getJSONObject("MemberGatewayHub"));
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
+ }
+ System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE END : NULL RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
+ }
+
+ /**
+ *
+ * Tests that response is for same region
+ *
+ * Test method for {@link com.vmware.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+ *
+ */
+ @Test
+ public void testResponseIsGatewaySender() {
+ System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE BEGIN : IS GATEWAY SENDER IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
+ Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'isGatewaySender' for member", memberGatewayHubObj.has("isGatewaySender"));
+ Boolean boolIsGatewaySender = memberGatewayHubObj.getBoolean("isGatewaySender");
+ Assert.assertEquals("MemberGatewayHubServiceTest :: Server returned wrong value for 'isGatewaySender'. Expected 'isGatewaySender' = true, actual 'isGatewaySender' = " + boolIsGatewaySender, boolIsGatewaySender, true);
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
+ }
+ System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE END : IS GATEWAY SENDER IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
+ }
+
+
+ /**
+ *
+ * Tests that response is for same region
+ *
+ * Test method for {@link com.vmware.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+ *
+ */
+ @Test
+ public void testResponseGatewaySenderCount() {
+ System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE BEGIN : GATEWAY SENDER COUNT IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
+ Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'isGatewaySender' for member", memberGatewayHubObj.has("isGatewaySender"));
+ Boolean boolIsGatewaySender = memberGatewayHubObj.getBoolean("isGatewaySender");
+
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'gatewaySenders' for member", memberGatewayHubObj.has("gatewaySenders"));
+ JSONArray arrGatewaySender = memberGatewayHubObj.getJSONArray("gatewaySenders");
+ Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for 'gatewaySenders'", arrGatewaySender);
+ Assert.assertTrue( "MemberGatewayHubServiceTest :: Server returned mis-matched values for 'isGatewaySender' and gateway senders array count", ((boolIsGatewaySender && (arrGatewaySender.length() > 0)) || ((! boolIsGatewaySender) && (arrGatewaySender.length() == 0))) );
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
+ }
+ System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE END : GATEWAY SENDER COUNT IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
+ }
+
+ /**
+ *
+ * Tests that response is for same region
+ *
+ * Test method for {@link com.vmware.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+ *
+ */
+ @Test
+ public void testResponseGatewaySenderProperties() {
+ System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE BEGIN : GATEWAY SENDER PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
+ Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'isGatewaySender' for member", memberGatewayHubObj.has("isGatewaySender"));
+ Boolean boolIsGatewaySender = memberGatewayHubObj.getBoolean("isGatewaySender");
+
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'gatewaySenders' for member", memberGatewayHubObj.has("gatewaySenders"));
+ JSONArray arrGatewaySender = memberGatewayHubObj.getJSONArray("gatewaySenders");
+ Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for 'gatewaySenders'", arrGatewaySender);
+ Assert.assertTrue( "MemberGatewayHubServiceTest :: Server returned mis-matched values for 'isGatewaySender' and gateway senders array count", ((boolIsGatewaySender && (arrGatewaySender.length() > 0)) || ((! boolIsGatewaySender) && (arrGatewaySender.length() == 0))) );
+
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'remoteDSId' for member", ((JSONObject)arrGatewaySender.get(0)).has("remoteDSId"));
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'eventsExceedingAlertThreshold' for member", ((JSONObject)arrGatewaySender.get(0)).has("eventsExceedingAlertThreshold"));
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
+ }
+ System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE END : GATEWAY SENDER PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
+ }
+
+ /**
+ *
+ * Tests that response is for same region
+ *
+ * Test method for {@link com.vmware.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+ *
+ */
+ @Test
+ public void testResponseAsyncEventQueueProperties() {
+ System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE BEGIN : ASYNC EVENT QUEUE PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_5_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
+ Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
+
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'asyncEventQueues' for member", memberGatewayHubObj.has("asyncEventQueues"));
+ JSONArray arrAsyncEventQueues = memberGatewayHubObj.getJSONArray("asyncEventQueues");
+ Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for 'asyncEventQueues'", arrAsyncEventQueues);
+
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'id' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("id"));
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'primary' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("primary"));
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'senderType' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("senderType"));
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'batchSize' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("batchSize"));
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'batchTimeInterval' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("batchTimeInterval"));
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'batchConflationEnabled' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("batchConflationEnabled"));
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'asyncEventListener' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("asyncEventListener"));
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'queueSize' for member", ((JSONObject)arrAsyncEventQueues.get(0)).has("queueSize"));
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
+ }
+ System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE END : ASYNC EVENT QUEUE PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
+ }
+
+ /**
+ *
+ * Tests that response is for same region
+ *
+ * Test method for {@link com.vmware.geode.tools.pulse.internal.service.MemberGatewayHubService#execute(javax.servlet.http.HttpServletRequest)}.
+ *
+ */
+ @Test
+ public void testResponseNoAsyncEventQueues() {
+ System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE BEGIN : NO ASYNC EVENT QUEUES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE------");
+ if(httpclient != null){
+ try{
+ HttpUriRequest pulseupdate = RequestBuilder.post()
+ .setUri(new URI(PULSE_UPDATE_URL))
+ .addParameter(PULSE_UPDATE_PARAM, PULSE_UPDATE_6_VALUE)
+ .build();
+ CloseableHttpResponse response = httpclient.execute(pulseupdate);
+ try {
+ HttpEntity entity = response.getEntity();
+
+ System.out.println("MemberGatewayHubServiceTest :: HTTP request status : " + response.getStatusLine());
+
+ BufferedReader respReader = new BufferedReader(new InputStreamReader(entity.getContent()));
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ String sz = null;
+ while((sz = respReader.readLine()) != null){
+ pw.print(sz);
+ }
+ String jsonResp = sw.getBuffer().toString();
+ System.out.println("MemberGatewayHubServiceTest :: JSON response returned : " + jsonResp);
+ EntityUtils.consume(entity);
+
+ JSONObject jsonObj = new JSONObject(jsonResp);
+ JSONObject memberGatewayHubObj = jsonObj.getJSONObject("MemberGatewayHub");
+ Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for MemberGatewayHub", memberGatewayHubObj);
+
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server did not return 'asyncEventQueues' for member", memberGatewayHubObj.has("asyncEventQueues"));
+ JSONArray arrAsyncEventQueues = memberGatewayHubObj.getJSONArray("asyncEventQueues");
+ Assert.assertNotNull("MemberGatewayHubServiceTest :: Server returned null response for 'asyncEventQueues'", arrAsyncEventQueues);
+ Assert.assertTrue("MemberGatewayHubServiceTest :: Server returned non-empty array for member 'pnq-visitor2' which has no event queues", (arrAsyncEventQueues.length() == 0));
+ } finally {
+ response.close();
+ }
+ } catch(Exception failed) {
+ logException(failed);
+ Assert.fail("Exception ! ");
+ }
+ } else {
+ Assert.fail("MemberGatewayHubServiceTest :: No Http connection was established.");
+ }
+ System.out.println("MemberGatewayHubServiceTest :: ------TESTCASE END : NO ASYNC EVENT QUEUES PROPERTIES IN RESPONSE CHECK FOR MEMBER GATEWAY HUB SERVICE ------\n");
+ }
+
+
+}
[29/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/JMXDataUpdater.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/JMXDataUpdater.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/JMXDataUpdater.java
deleted file mode 100644
index 10c821f..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/JMXDataUpdater.java
+++ /dev/null
@@ -1,2392 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.data;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
-import com.vmware.gemfire.tools.pulse.internal.data.JmxManagerFinder.JmxManagerInfo;
-import com.vmware.gemfire.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.MBeanException;
-import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.TabularData;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-import javax.rmi.ssl.SslRMIClientSocketFactory;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.management.ManagementFactory;
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.ResourceBundle;
-import java.util.Set;
-
-/**
- * Class JMXDataUpdater Class used for creating JMX connection and getting all
- * the required MBeans
- *
- *
- * @since GemFire version 7.0.Beta 2012-09-23
- */
-public class JMXDataUpdater implements IClusterUpdater, NotificationListener {
-
- private final PulseLogWriter LOGGER = PulseLogWriter.getLogger();
- private final ResourceBundle resourceBundle = Repository.get()
- .getResourceBundle();
-
- private JMXConnector conn = null;
- private MBeanServerConnection mbs;
- private final String serverName;
- private final String port;
- private final String userName;
- private final String userPassword;
- private Boolean isAddedNotiListner = false;
- private final Cluster cluster;
-
- // MBean object names
- private ObjectName MBEAN_OBJECT_NAME_SYSTEM_DISTRIBUTED;
- private ObjectName MBEAN_OBJECT_NAME_REGION_DISTRIBUTED;
- private ObjectName MBEAN_OBJECT_NAME_MEMBER;
- private ObjectName MBEAN_OBJECT_NAME_MEMBER_MANAGER;
- private ObjectName MBEAN_OBJECT_NAME_STATEMENT_DISTRIBUTED;
- private ObjectName MBEAN_OBJECT_NAME_TABLE_AGGREGATE;
-
- private Set<ObjectName> systemMBeans = null;
-
- private final String opSignature[] = { String.class.getName(),
- String.class.getName(), int.class.getName() };
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- /**
- * constructor used for creating JMX connection
- */
- public JMXDataUpdater(String server, String port, Cluster cluster) {
- this.serverName = server;
- this.port = port;
- this.userName = cluster.getJmxUserName();
- this.userPassword = cluster.getJmxUserPassword();
- this.cluster = cluster;
-
- try {
- // Initialize MBean object names
- this.MBEAN_OBJECT_NAME_SYSTEM_DISTRIBUTED = new ObjectName(
- PulseConstants.OBJECT_NAME_SYSTEM_DISTRIBUTED);
- this.MBEAN_OBJECT_NAME_REGION_DISTRIBUTED = new ObjectName(
- PulseConstants.OBJECT_NAME_REGION_DISTRIBUTED);
- this.MBEAN_OBJECT_NAME_MEMBER_MANAGER = new ObjectName(
- PulseConstants.OBJECT_NAME_MEMBER_MANAGER);
- this.MBEAN_OBJECT_NAME_MEMBER = new ObjectName(
- PulseConstants.OBJECT_NAME_MEMBER);
- this.MBEAN_OBJECT_NAME_STATEMENT_DISTRIBUTED = new ObjectName(
- PulseConstants.OBJECT_NAME_STATEMENT_DISTRIBUTED);
-
- // For SQLFire
- if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController
- .getPulseProductSupport())) {
- this.MBEAN_OBJECT_NAME_TABLE_AGGREGATE = new ObjectName(
- PulseConstants.OBJECT_NAME_TABLE_AGGREGATE);
- }
-
- } catch (MalformedObjectNameException e) {
- if (LOGGER.severeEnabled()) {
- LOGGER.severe(e.getMessage(), e);
- }
- } catch (NullPointerException e) {
- if (LOGGER.severeEnabled()) {
- LOGGER.severe(e.getMessage(), e);
- }
- }
-
- }
-
- private JmxManagerInfo getManagerInfoFromLocator(Repository repository) {
-
- try {
- String locatorHost = repository.getJmxHost();
- int locatorPort = Integer.parseInt(repository.getJmxPort());
-
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_HOST") + " : " + locatorHost + " & "
- + resourceBundle.getString("LOG_MSG_PORT") + " : " + locatorPort);
- }
-
- InetAddress inetAddr = InetAddress.getByName(locatorHost);
-
- if ((inetAddr instanceof Inet4Address) || (inetAddr instanceof Inet6Address)) {
-
- if (inetAddr instanceof Inet4Address) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_LOCATOR_IPV4_ADDRESS") + " - " + inetAddr.toString());
- }
- } else {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_LOCATOR_IPV6_ADDRESS") + " - " + inetAddr.toString());
- }
- }
-
- JmxManagerInfo jmxManagerInfo = JmxManagerFinder.askLocatorForJmxManager(inetAddr, locatorPort, 15000,
- repository.isUseSSLLocator());
-
- if (jmxManagerInfo.port == 0) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_LOCATOR_COULD_NOT_FIND_MANAGER"));
- }
- }
- return jmxManagerInfo;
- } else {
- // Locator has Invalid locator Address
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_LOCATOR_BAD_ADDRESS"));
- }
- cluster.setConnectionErrorMsg(resourceBundle.getString("LOG_MSG_JMX_CONNECTION_BAD_ADDRESS"));
- // update message to display on UI
- cluster.setConnectionErrorMsg(resourceBundle
- .getString("LOG_MSG_JMX_CONNECTION_BAD_ADDRESS"));
- return null;
- }
- } catch (IOException e) {
- StringWriter swBuffer = new StringWriter();
- PrintWriter prtWriter = new PrintWriter(swBuffer);
- e.printStackTrace(prtWriter);
- LOGGER.severe("Exception Details : " + swBuffer.toString() + "\n");
- }
- return null;
- }
-
- /**
- * Default connection is Pulse which uses configured userName and password
- */
- public JMXConnector getJMXConnection() {
- return getJMXConnection(true);
- }
-
- /**
- * Get connection for given userName and password. This is used for DataBrowser
- * queries which has to be fired using credentials provided at pulse login page
- */
- public JMXConnector getJMXConnection(final boolean registerURL) {
- JMXConnector connection = null;
- // Reference to repository
- Repository repository = Repository.get();
- try {
-
- String jmxSerURL = "";
-
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_USE_LOCATOR_VALUE") + ":"
- + repository.getJmxUseLocator());
- }
-
- if (repository.getJmxUseLocator()) {
- JmxManagerInfo jmxManagerInfo = getManagerInfoFromLocator(repository);
-
- if (jmxManagerInfo.port == 0) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle
- .getString("LOG_MSG_LOCATOR_COULD_NOT_FIND_MANAGER"));
- }
- } else {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle
- .getString("LOG_MSG_LOCATOR_FOUND_MANAGER")
- + " : "
- + resourceBundle.getString("LOG_MSG_HOST")
- + " : "
- + jmxManagerInfo.host
- + " & "
- + resourceBundle.getString("LOG_MSG_PORT")
- + " : "
- + jmxManagerInfo.port
- + (jmxManagerInfo.ssl ? resourceBundle
- .getString("LOG_MSG_WITH_SSL") : resourceBundle
- .getString("LOG_MSG_WITHOUT_SSL")));
- }
-
- jmxSerURL = formJMXServiceURLString(jmxManagerInfo.host,
- String.valueOf(jmxManagerInfo.port));
- }
- } else {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_HOST") + " : "
- + this.serverName + " & "
- + resourceBundle.getString("LOG_MSG_PORT") + " : " + this.port);
- }
- jmxSerURL = formJMXServiceURLString(this.serverName, this.port);
- }
-
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(jmxSerURL)) {
- JMXServiceURL url = new JMXServiceURL(jmxSerURL);
- String[] creds = { this.userName, this.userPassword };
- Map<String, Object> env = new HashMap<String, Object>();
- env.put(JMXConnector.CREDENTIALS, creds);
-
- if (repository.isUseSSLManager()) {
- // use ssl to connect
- env.put("com.sun.jndi.rmi.factory.socket",
- new SslRMIClientSocketFactory());
- }
- LOGGER.info("Connecting to jmxURL : " + jmxSerURL);
- connection = JMXConnectorFactory.connect(url, env);
-
- // Register Pulse URL if not already present in the JMX Manager
- if(registerURL)
- registerPulseUrlToManager(connection);
- }
- } catch (Exception e) {
- if (e instanceof UnknownHostException) {
- cluster.setConnectionErrorMsg(resourceBundle
- .getString("LOG_MSG_JMX_CONNECTION_UNKNOWN_HOST"));
- }
-
- StringWriter swBuffer = new StringWriter();
- PrintWriter prtWriter = new PrintWriter(swBuffer);
- e.printStackTrace(prtWriter);
- LOGGER.severe("Exception Details : " + swBuffer.toString() + "\n");
- if (this.conn != null) {
- try {
- this.conn.close();
- } catch (Exception e1) {
- LOGGER.severe("Error closing JMX connection " + swBuffer.toString()
- + "\n");
- }
- this.conn = null;
- }
- }
- return connection;
- }
-
- private String formJMXServiceURLString(String host, String port)
- throws UnknownHostException {
- /*
- * String jmxSerURL = "service:jmx:rmi://" + serverName + "/jndi/rmi://" +
- * serverName + ":" + port + "/jmxrmi";
- */
- String jmxSerURL = "";
- if (host.equalsIgnoreCase("localhost")) {
- // Create jmx service url for 'localhost'
- jmxSerURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":"
- + port + "/jmxrmi";
- } else {
- InetAddress inetAddr = InetAddress.getByName(host);
- if (inetAddr instanceof Inet4Address) {
- // Create jmx service url for IPv4 address
- jmxSerURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":"
- + port + "/jmxrmi";
- } else if (inetAddr instanceof Inet6Address) {
- // Create jmx service url for IPv6 address
- jmxSerURL = "service:jmx:rmi://[" + host + "]/jndi/rmi://[" + host + "]:"
- + port + "/jmxrmi";
- }
- }
-
- return jmxSerURL;
- }
-
- // Method registers Pulse URL if not already present in the JMX Manager
- private void registerPulseUrlToManager(JMXConnector connection)
- throws IOException, AttributeNotFoundException,
- InstanceNotFoundException, MBeanException, ReflectionException,
- MalformedObjectNameException, InvalidAttributeValueException {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle
- .getString("LOG_MSG_REGISTERING_APP_URL_TO_MANAGER"));
- }
-
- // Reference to repository
- Repository repository = Repository.get();
-
- // Register Pulse URL if not already present in the JMX Manager
- if (connection != null) {
- MBeanServerConnection mbsc = connection.getMBeanServerConnection();
-
- Set<ObjectName> mbeans = mbsc.queryNames(
- this.MBEAN_OBJECT_NAME_MEMBER_MANAGER, null);
-
- for (ObjectName mbeanName : mbeans) {
- String presentUrl = (String) mbsc.getAttribute(mbeanName,
- PulseConstants.MBEAN_MANAGER_ATTRIBUTE_PULSEURL);
- String pulseWebAppUrl = repository.getPulseWebAppUrl();
- if (pulseWebAppUrl != null
- && (presentUrl == null || !pulseWebAppUrl.equals(presentUrl))) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine(resourceBundle
- .getString("LOG_MSG_SETTING_APP_URL_TO_MANAGER"));
- }
- Attribute pulseUrlAttr = new Attribute(
- PulseConstants.MBEAN_MANAGER_ATTRIBUTE_PULSEURL, pulseWebAppUrl);
- mbsc.setAttribute(mbeanName, pulseUrlAttr);
- } else {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine(resourceBundle
- .getString("LOG_MSG_APP_URL_ALREADY_PRESENT_IN_MANAGER"));
- }
- }
- }
- }
- }
-
- private boolean isConnected() {
- // Reference to repository
- Repository repository = Repository.get();
- if (repository.getIsEmbeddedMode()) {
- if (this.mbs == null) {
- this.mbs = ManagementFactory.getPlatformMBeanServer();
- cluster.setConnectedFlag(true);
- }
- } else {
- try {
- if (this.conn == null) {
- cluster.setConnectedFlag(false);
- cluster.setConnectionErrorMsg(resourceBundle
- .getString("LOG_MSG_JMX_CONNECTION_NOT_FOUND")
- + " "
- + resourceBundle.getString("LOG_MSG_JMX_GETTING_NEW_CONNECTION"));
- if (LOGGER.fineEnabled()) {
- LOGGER.fine(resourceBundle
- .getString("LOG_MSG_JMX_CONNECTION_NOT_FOUND")
- + " "
- + resourceBundle.getString("LOG_MSG_JMX_GET_NEW_CONNECTION"));
- }
- this.conn = getJMXConnection();
- if (this.conn != null) {
- this.mbs = this.conn.getMBeanServerConnection();
- cluster.setConnectedFlag(true);
- } else {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle
- .getString("LOG_MSG_JMX_CONNECTION_NOT_FOUND"));
- }
- return false;
- }
- } else {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine(resourceBundle
- .getString("LOG_MSG_JMX_CONNECTION_IS_AVAILABLE"));
- }
- cluster.setConnectedFlag(true);
- if (this.mbs == null) {
- this.mbs = this.conn.getMBeanServerConnection();
- }
- }
- } catch (Exception e) {
- this.mbs = null;
- if (this.conn != null) {
- try {
- this.conn.close();
- } catch (Exception e1) {
- LOGGER.severe(e);
- }
- }
- this.conn = null;
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * function used for updating Cluster Data.
- */
- @Override
- public boolean updateData() {
- try {
- if (!this.isConnected()) {
- return false;
- }
-
- // deleted Members
- cluster.getDeletedMembers().clear();
- for (Entry<String, Cluster.Member> memberSet : cluster.getMembersHMap()
- .entrySet()) {
- cluster.getDeletedMembers().add(memberSet.getKey());
- }
-
- // Deleted Regions
- cluster.getDeletedRegions().clear();
- for (Cluster.Region region : cluster.getClusterRegions().values()) {
- cluster.getDeletedRegions().add(region.getFullPath());
- }
-
- // try {
-
- // Cluster
- this.systemMBeans = this.mbs.queryNames(
- this.MBEAN_OBJECT_NAME_SYSTEM_DISTRIBUTED, null);
- for (ObjectName sysMBean : this.systemMBeans) {
- updateClusterSystem(sysMBean);
- }
-
- // Cluster Regions/Tables
- Set<ObjectName> regionMBeans = this.mbs.queryNames(
- this.MBEAN_OBJECT_NAME_REGION_DISTRIBUTED, null);
-
- Set<ObjectName> tableMBeans = this.mbs.queryNames(
- this.MBEAN_OBJECT_NAME_TABLE_AGGREGATE, null);
-
- if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController
- .getPulseProductSupport())) {
- // For SQLfire
- for (ObjectName tableMBean : tableMBeans) {
- String regNameFromTable = StringUtils
- .getRegionNameFromTableName(tableMBean.getKeyProperty("table"));
- for (ObjectName regionMBean : regionMBeans) {
- String regionName = regionMBean.getKeyProperty("name");
- if (regNameFromTable.equals(regionName)) {
- updateClusterRegion(regionMBean);
- // Increment cluster region count
- cluster.setTotalRegionCount(cluster.getTotalRegionCount() + 1);
- break;
- }
- }
- }
- } else {
- // For Gemfire
- for (ObjectName regMBean : regionMBeans) {
- updateClusterRegion(regMBean);
- }
- }
-
- // Remove deleted regions from cluster's regions list
- for (Iterator<String> it = cluster.getDeletedRegions().iterator(); it
- .hasNext();) {
- cluster.removeClusterRegion(it.next());
- }
-
- // Cluster Members
- Set<ObjectName> memberMBeans = this.mbs.queryNames(
- this.MBEAN_OBJECT_NAME_MEMBER, null);
- for (ObjectName memMBean : memberMBeans) {
- String service = memMBean.getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_SERVICE);
- if(service==null){
- // Cluster Member
- updateClusterMember(memMBean);
- }
- else {
- switch (service) {
- case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_REGION:
- if (PulseConstants.PRODUCT_NAME_SQLFIRE
- .equalsIgnoreCase(PulseController.getPulseProductSupport())) {
- // For SQLfire
- for (ObjectName tableMBean : tableMBeans) {
- String regNameFromTable = StringUtils
- .getRegionNameFromTableName(tableMBean
- .getKeyProperty("table"));
- String regionName = memMBean.getKeyProperty("name");
- if (regNameFromTable.equals(regionName)) {
- updateMemberRegion(memMBean);
- break;
- }
- }
- } else {
- // For Gemfire
- updateMemberRegion(memMBean);
- }
- break;
- case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_CACHESERVER:
- updateMemberClient(memMBean);
- break;
- case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_GATEWAYRECEIVER:
- updateGatewayReceiver(memMBean);
- break;
- case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_GATEWAYSENDER:
- updateGatewaySender(memMBean);
- break;
- case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_ASYNCEVENTQUEUE:
- updateAsyncEventQueue(memMBean);
- break;
- case PulseConstants.MBEAN_KEY_PROPERTY_SERVICE_VALUE_LOCATOR:
- updateClusterMember(memMBean);
- break;
- }
- }
- }
-
- // Cluster Query Statistics
- Set<ObjectName> statementObjectNames = this.mbs.queryNames(
- this.MBEAN_OBJECT_NAME_STATEMENT_DISTRIBUTED, null);
- //LOGGER.info("statementObjectNames = " + statementObjectNames);
- for (ObjectName stmtObjectName : statementObjectNames) {
- //LOGGER.info("stmtObjectName = " + stmtObjectName);
- updateClusterStatement(stmtObjectName);
- }
- } catch (IOException ioe) {
-
- // write errors
- StringWriter swBuffer = new StringWriter();
- PrintWriter prtWriter = new PrintWriter(swBuffer);
- ioe.printStackTrace(prtWriter);
- LOGGER.severe("IOException Details : " + swBuffer.toString() + "\n");
- this.mbs = null;
- if (this.conn != null) {
- try {
- this.conn.close();
- } catch (IOException e1) {
- LOGGER.severe("Error closing JMX connection " + swBuffer.toString()
- + "\n");
- }
- }
-
- return false;
- }
-
- // If there were members deleted, remove them from the membersList &
- // physicalToMember.
- Iterator<String> iterator = cluster.getDeletedMembers().iterator();
- while (iterator.hasNext()) {
- String memberKey = iterator.next();
- if (cluster.getMembersHMap().containsKey(memberKey)) {
- Cluster.Member member = cluster.getMembersHMap().get(memberKey);
- List<Cluster.Member> memberArrList = cluster.getPhysicalToMember().get(
- member.getHost());
- if (memberArrList != null) {
- if (memberArrList.contains(member)) {
- String host = member.getHost();
- cluster.getPhysicalToMember().get(member.getHost()).remove(member);
-
- if (cluster.getPhysicalToMember().get(member.getHost()).size() == 0) {
- cluster.getPhysicalToMember().remove(host);
- }
- }
- }
- cluster.getMembersHMap().remove(memberKey);
- }
-
- }
-
- return true;
- }
-
- /**
- * function used to get attribute values of Cluster System and map them to
- * cluster vo
- *
- * @param mbeanName
- * Cluster System MBean
- * @throws IOException
- *
- */
- private void updateClusterSystem(ObjectName mbeanName) throws IOException {
- try {
- if (!this.isAddedNotiListner) {
- this.mbs.addNotificationListener(mbeanName, this, null, new Object());
- this.isAddedNotiListner = true;
- }
-
- if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController
- .getPulseProductSupport())) {
- // Reset to zero
- cluster.setServerCount(0);
- cluster.setTotalRegionCount(0);
- } else {
- String[] serverCnt = (String[]) (this.mbs.invoke(mbeanName,
- PulseConstants.MBEAN_OPERATION_LISTSERVERS, null, null));
- cluster.setServerCount(serverCnt.length);
- }
-
- TabularData table = (TabularData) (this.mbs.invoke(mbeanName,
- PulseConstants.MBEAN_OPERATION_VIEWREMOTECLUSTERSTATUS, null, null));
-
- Collection<CompositeData> rows = (Collection<CompositeData>) table
- .values();
- cluster.getWanInformationObject().clear();
- for (CompositeData row : rows) {
- final Object key = row.get("key");
- final Object value = row.get("value");
- cluster.getWanInformationObject().put((String) key, (Boolean) value);
- }
-
- AttributeList attributeList = this.mbs.getAttributes(mbeanName,
- PulseConstants.CLUSTER_MBEAN_ATTRIBUTES);
-
- for (int i = 0; i < attributeList.size(); i++) {
-
- Attribute attribute = (Attribute) attributeList.get(i);
- String name = attribute.getName();
- switch (name){
- case PulseConstants.MBEAN_ATTRIBUTE_MEMBERCOUNT:
- cluster.setMemberCount(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_NUMCLIENTS:
- cluster.setClientConnectionCount(getIntegerAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISTRIBUTEDSYSTEMID:
- cluster.setClusterId(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_LOCATORCOUNT:
- cluster.setLocatorCount(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_NUMRUNNIGFUNCTION:
- try {
- cluster.setRunningFunctionCount(getIntegerAttribute(
- attribute.getValue(), attribute.getName()));
- } catch (Exception e) {
- cluster.setRunningFunctionCount(0);
- continue;
- }
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_REGISTEREDCQCOUNT:
- cluster.setRegisteredCQCount(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_NUMSUBSCRIPTIONS:
- cluster.setSubscriptionCount(getIntegerAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_NUMTXNCOMMITTED:
- cluster.setTxnCommittedCount(getIntegerAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_NUMTXNROLLBACK:
- cluster.setTxnRollbackCount(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_TOTALHEAPSIZE:
- cluster.setTotalHeapSize(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_USEDHEAPSIZE:
- try {
- cluster.setUsedHeapSize(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- } catch (Exception e) {
- cluster.setUsedHeapSize((long) 0);
- continue;
- }
- cluster.getMemoryUsageTrend().add(cluster.getUsedHeapSize());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_TOTALREGIONENTRYCOUNT:
- cluster.setTotalRegionEntryCount(getLongAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_CURRENTENTRYCOUNT:
- cluster.setCurrentQueryCount(getIntegerAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_TOTALDISKUSAGE:
- try {
- cluster.setTotalBytesOnDisk(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- } catch (Exception e) {
- cluster.setTotalBytesOnDisk((long) 0);
- continue;
- }
- cluster.getTotalBytesOnDiskTrend().add(cluster.getTotalBytesOnDisk());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
- cluster.setDiskWritesRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- cluster.getThroughoutWritesTrend().add(cluster.getDiskWritesRate());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEWRITES:
- try {
- cluster.setWritePerSec(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- } catch (Exception e) {
- cluster.setWritePerSec(0);
- continue;
- }
- cluster.getWritePerSecTrend().add(cluster.getWritePerSec());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEREADS:
- try {
- cluster.setReadPerSec(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- } catch (Exception e) {
- cluster.setReadPerSec(0);
- continue;
- }
- cluster.getReadPerSecTrend().add(cluster.getReadPerSec());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_QUERYREQUESTRATE:
- cluster.setQueriesPerSec(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- cluster.getQueriesPerSecTrend().add(cluster.getQueriesPerSec());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
- cluster.setDiskReadsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- cluster.getThroughoutReadsTrend().add(cluster.getDiskReadsRate());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_JVMPAUSES:
- long trendVal = determineCurrentJVMPauses(
- PulseConstants.JVM_PAUSES_TYPE_CLUSTER, "",
- getLongAttribute(attribute.getValue(), attribute.getName()));
- cluster.setGarbageCollectionCount(trendVal);
- cluster.getGarbageCollectionTrend().add(
- cluster.getGarbageCollectionCount());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_TOTALREGIONCOUNT:
- if (!PulseConstants.PRODUCT_NAME_SQLFIRE
- .equalsIgnoreCase(PulseController.getPulseProductSupport())){
- // for Gemfire
- cluster.setTotalRegionCount(getIntegerAttribute(
- attribute.getValue(), attribute.getName()));
- }
- break;
- }
- }
-
- // SQLFIRE attributes
- if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController
- .getPulseProductSupport())) {
-
- try { // get sqlfire cluster mbean
-
- ObjectName sfMemberMbeansObjectName = new ObjectName(
- PulseConstants.OBJECT_NAME_SF_CLUSTER);
-
- Set<ObjectName> sfCluserMBeans = this.mbs.queryNames(
- sfMemberMbeansObjectName, null);
-
- for (ObjectName sfCluserMBean : sfCluserMBeans) {
-
- AttributeList attrList = this.mbs.getAttributes(sfCluserMBean,
- PulseConstants.SF_CLUSTER_MBEAN_ATTRIBUTES);
-
- for (int i = 0; i < attrList.size(); i++) {
-
- Attribute attribute = (Attribute) attrList.get(i);
-
- if (attribute.getName().equals(
- PulseConstants.MBEAN_ATTRIBUTE_PROCEDURECALLSINPROGRESS)) {
- try {
- cluster.setRunningFunctionCount(getIntegerAttribute(
- attribute.getValue(), attribute.getName()));
- } catch (Exception e) {
- cluster.setRunningFunctionCount(0);
- continue;
- }
- } else if (attribute
- .getName()
- .equals(
- PulseConstants.MBEAN_ATTRIBUTE_NETWORKSERVERCLIENTCONNECTIONSTATS)) {
- // set number of cluster's clients
- CompositeData nscConnStats = (CompositeData) attribute
- .getValue();
-
- cluster.setClientConnectionCount(getLongAttribute(nscConnStats
- .get(PulseConstants.COMPOSITE_DATA_KEY_CONNECTIONSACTIVE),
- PulseConstants.COMPOSITE_DATA_KEY_CONNECTIONSACTIVE));
- }
- }
- break;
- }
-
- } catch (MalformedObjectNameException e) {
- LOGGER.warning(e);
- } catch (NullPointerException e) {
- LOGGER.warning(e);
- }
-
- }
-
- } catch (InstanceNotFoundException infe) {
- LOGGER.warning(infe);
- } catch (ReflectionException re) {
- LOGGER.warning(re);
- } catch (MBeanException anfe) {
- LOGGER.warning(anfe);
- }
- }
-
- /**
- * function used to get attribute values of Gateway Receiver and map them to
- * GatewayReceiver inner class object
- *
- * @param mbeanName
- * @return GatewayReceiver object
- * @throws InstanceNotFoundException
- * @throws IntrospectionException
- * @throws ReflectionException
- * @throws IOException
- * @throws AttributeNotFoundException
- * @throws MBeanException
- *
- *
- */
- private Cluster.GatewayReceiver initGatewayReceiver(ObjectName mbeanName)
- throws InstanceNotFoundException, IntrospectionException,
- ReflectionException, IOException, AttributeNotFoundException,
- MBeanException {
-
- Cluster.GatewayReceiver gatewayReceiver = new Cluster.GatewayReceiver();
-
- AttributeList attributeList = this.mbs.getAttributes(mbeanName,
- PulseConstants.GATEWAY_MBEAN_ATTRIBUTES);
-
- for (int i = 0; i < attributeList.size(); i++) {
- Attribute attribute = (Attribute) attributeList.get(i);
-
- if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_PORT)) {
- gatewayReceiver.setListeningPort(getIntegerAttribute(
- attribute.getValue(), attribute.getName()));
- } else if (attribute.getName().equals(
- PulseConstants.MBEAN_ATTRIBUTE_EVENTRECEIVEDDATE)) {
- gatewayReceiver.setLinkThroughput(getDoubleAttribute(
- attribute.getValue(), attribute.getName()));
- } else if (attribute.getName().equals(
- PulseConstants.MBEAN_ATTRIBUTE_AVEARGEBATCHPROCESSINGTIME)) {
- gatewayReceiver.setAvgBatchProcessingTime(getLongAttribute(
- attribute.getValue(), attribute.getName()));
- } else if (attribute.getName().equals(
- PulseConstants.MBEAN_ATTRIBUTE_RUNNING)) {
- gatewayReceiver.setStatus(getBooleanAttribute(attribute.getValue(),
- attribute.getName()));
- }
- }
- return gatewayReceiver;
- }
-
- /**
- * function used to get attribute values of Gateway Sender and map them to
- * GatewaySender inner class object
- *
- * @param mbeanName
- * @return
- * @throws InstanceNotFoundException
- * @throws IntrospectionException
- * @throws ReflectionException
- * @throws IOException
- * @throws AttributeNotFoundException
- * @throws MBeanException
- */
- private Cluster.GatewaySender initGatewaySender(ObjectName mbeanName)
- throws InstanceNotFoundException, IntrospectionException,
- ReflectionException, IOException, AttributeNotFoundException,
- MBeanException {
-
- Cluster.GatewaySender gatewaySender = new Cluster.GatewaySender();
- AttributeList attributeList = this.mbs.getAttributes(mbeanName,
- PulseConstants.GATEWAYSENDER_MBEAN_ATTRIBUTES);
-
- for (int i = 0; i < attributeList.size(); i++) {
- Attribute attribute = (Attribute) attributeList.get(i);
- String name = attribute.getName();
- switch (name){
- case PulseConstants.MBEAN_ATTRIBUTE_EVENTRECEIVEDDATE:
- gatewaySender.setLinkThroughput(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_BATCHSIZE:
- gatewaySender.setBatchSize(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_SENDERID:
- gatewaySender.setId(getStringAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_EVENTQUEUESIZE:
- gatewaySender.setQueueSize(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_RUNNING:
- gatewaySender.setStatus(getBooleanAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_PRIMARY:
- gatewaySender.setPrimary(getBooleanAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_PERSISTENCEENABLED:
- gatewaySender.setPersistenceEnabled(getBooleanAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_PARALLEL:
- gatewaySender.setSenderType(getBooleanAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_REMOTE_DS_ID:
- gatewaySender.setRemoteDSId(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_EVENTS_EXCEEDING_ALERT_THRESHOLD:
- gatewaySender.setEventsExceedingAlertThreshold(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- }
- }
- return gatewaySender;
- }
-
- /**
- * function used for getting list of Gateway Senders from mBean for giving
- * member and update the list of gateway senders for respective member object
- */
- private void updateGatewaySender(ObjectName mbeanName) throws IOException {
-
- try {
- String memberName = mbeanName
- .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
-
- if (cluster.getMembersHMap().containsKey(memberName)) {
- Cluster.Member existingMember = cluster.getMembersHMap()
- .get(memberName);
- Cluster.GatewaySender gatewaySender = initGatewaySender(mbeanName);
- for (Iterator<Cluster.GatewaySender> it = existingMember
- .getGatewaySenderList().iterator(); it.hasNext();) {
- Cluster.GatewaySender exisGatewaySender = it.next();
- if ((exisGatewaySender.getId()).equals(gatewaySender.getId())) {
- it.remove();
- break;
- }
- }
-
- // Add gateway sender
- existingMember.getGatewaySenderList().add(gatewaySender);
-
- } else {
- Cluster.Member member = new Cluster.Member();
- member.setName(memberName);
- member.setId(memberName);
- Cluster.GatewaySender gatewaySender = initGatewaySender(mbeanName);
- member.getGatewaySenderList().add(gatewaySender);
- cluster.getMembersHMap().put(memberName, member);
- }
- } catch (InstanceNotFoundException infe) {
- LOGGER.warning(infe);
- } catch (ReflectionException re) {
- LOGGER.warning(re);
- } catch (MBeanException me) {
- LOGGER.warning(me);
- } catch (AttributeNotFoundException anfe) {
- LOGGER.warning(anfe);
- } catch (IntrospectionException ire) {
- LOGGER.warning(ire);
- }
- }
-
- /**
- * function used to get attribute values of Async Event Queue and map them to
- * Async Event Queue inner class object
- *
- * @param mbeanName
- * @return
- * @throws InstanceNotFoundException
- * @throws IntrospectionException
- * @throws ReflectionException
- * @throws IOException
- * @throws AttributeNotFoundException
- * @throws MBeanException
- */
- private Cluster.AsyncEventQueue initAsyncEventQueue(ObjectName mbeanName)
- throws InstanceNotFoundException, IntrospectionException,
- ReflectionException, IOException, AttributeNotFoundException,
- MBeanException {
-
- Cluster.AsyncEventQueue asyncEventQueue = new Cluster.AsyncEventQueue();
- AttributeList attributeList = this.mbs.getAttributes(mbeanName,
- PulseConstants.ASYNC_EVENT_QUEUE_MBEAN_ATTRIBUTES);
-
- for (int i = 0; i < attributeList.size(); i++) {
- Attribute attribute = (Attribute) attributeList.get(i);
- String name = attribute.getName();
- switch (name){
- case PulseConstants.MBEAN_ATTRIBUTE_AEQ_ASYNCEVENTID:
- asyncEventQueue.setId(getStringAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_AEQ_ASYNC_EVENT_LISTENER:
- asyncEventQueue.setAsyncEventListener(getStringAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_AEQ_BATCH_CONFLATION_ENABLED:
- asyncEventQueue.setBatchConflationEnabled(getBooleanAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_AEQ_BATCH_TIME_INTERVAL:
- asyncEventQueue.setBatchTimeInterval(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_AEQ_BATCH_SIZE:
- asyncEventQueue.setBatchSize(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_AEQ_EVENT_QUEUE_SIZE:
- asyncEventQueue.setEventQueueSize(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_AEQ_PARALLEL:
- asyncEventQueue.setParallel(getBooleanAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_AEQ_PRIMARY:
- asyncEventQueue.setPrimary(getBooleanAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- }
- }
- return asyncEventQueue;
- }
-
- /**
- * function used for getting list of Gateway Senders from mBean for giving
- * member and update the list of gateway senders for respective member object
- */
- private void updateAsyncEventQueue(ObjectName mbeanName) throws IOException {
- try {
- String memberName = mbeanName
- .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
-
- if (cluster.getMembersHMap().containsKey(memberName)) {
- Cluster.Member existingMember = cluster.getMembersHMap()
- .get(memberName);
- Cluster.AsyncEventQueue asyncQ = initAsyncEventQueue(mbeanName);
- for (Iterator<Cluster.AsyncEventQueue> it = existingMember.getAsyncEventQueueList().iterator(); it.hasNext();) {
- Cluster.AsyncEventQueue exisAsyncEventQueue = it.next();
- if ((exisAsyncEventQueue.getId()).equals(asyncQ.getId())) {
- it.remove();
- break;
- }
- }
-
- // Add async event queue
- existingMember.getAsyncEventQueueList().add(asyncQ);
- } else {
- Cluster.Member member = new Cluster.Member();
- member.setName(memberName);
- member.setId(memberName);
-
- Cluster.AsyncEventQueue asyncQ = initAsyncEventQueue(mbeanName);
- member.getAsyncEventQueueList().add(asyncQ);
-
- cluster.getMembersHMap().put(memberName, member);
- }
- } catch (InstanceNotFoundException infe) {
- LOGGER.warning(infe);
- } catch (ReflectionException re) {
- LOGGER.warning(re);
- } catch (MBeanException me) {
- LOGGER.warning(me);
- } catch (AttributeNotFoundException anfe) {
- LOGGER.warning(anfe);
- } catch (IntrospectionException ire) {
- LOGGER.warning(ire);
- }
- }
-
- /**
- * function used for getting a Gateway Receiver from mBean for giving member
- * and update the gateway receiver for respective member object
- */
- private void updateGatewayReceiver(ObjectName mbeanName) throws IOException {
-
- try {
- String memberName = mbeanName
- .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
-
- if (cluster.getMembersHMap().containsKey(memberName)) {
- Cluster.Member existingMember = cluster.getMembersHMap()
- .get(memberName);
- Cluster.GatewayReceiver gatewayReceiver = initGatewayReceiver(mbeanName);
- existingMember.setGatewayReceiver(gatewayReceiver);
- } else {
- Cluster.Member member = new Cluster.Member();
- member.setName(memberName);
- member.setId(memberName);
- Cluster.GatewayReceiver gatewayReceiver = initGatewayReceiver(mbeanName);
- member.setGatewayReceiver(gatewayReceiver);
- cluster.getMembersHMap().put(memberName, member);
- }
- } catch (InstanceNotFoundException infe) {
- LOGGER.warning(infe);
- } catch (ReflectionException re) {
- LOGGER.warning(re);
- } catch (MBeanException me) {
- LOGGER.warning(me);
- } catch (AttributeNotFoundException anfe) {
- LOGGER.warning(anfe);
- } catch (IntrospectionException ire) {
- LOGGER.warning(ire);
- }
- }
-
- /**
- * function used for getting member clients from mbean and update the clients
- * information in member object's client arraylist
- */
- private void updateMemberClient(ObjectName mbeanName) throws IOException {
-
- try {
- String memberName = mbeanName
- .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
-
- if (cluster.getMembersHMap().containsKey(memberName)) {
- Cluster.Member existingMember = cluster.getMembersHMap()
- .get(memberName);
- HashMap<String, Cluster.Client> memberClientsHM = new HashMap<String, Cluster.Client>();
-
- existingMember.setMemberPort(""
- + this.mbs.getAttribute(mbeanName,
- PulseConstants.MBEAN_ATTRIBUTE_PORT));
-
- this.mbs.getAttribute(mbeanName, PulseConstants.MBEAN_ATTRIBUTE_HOSTNAMEFORCLIENTS_ALT);
- existingMember.setHostnameForClients((String)this.mbs.getAttribute(mbeanName, PulseConstants.MBEAN_ATTRIBUTE_HOSTNAMEFORCLIENTS_ALT));
- existingMember.setBindAddress((String)this.mbs.getAttribute(mbeanName, PulseConstants.MBEAN_ATTRIBUTE_BINDADDRESS));
-
- CompositeData[] compositeData = (CompositeData[]) (this.mbs.invoke(
- mbeanName, PulseConstants.MBEAN_OPERATION_SHOWALLCLIENTS, null,
- null));
- for (CompositeData cmd : compositeData) {
- Cluster.Client client = new Cluster.Client();
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CLIENTID)) {
- client.setId((String) cmd
- .get(PulseConstants.COMPOSITE_DATA_KEY_CLIENTID));
- }
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NAME)) {
- client.setName((String) cmd
- .get(PulseConstants.COMPOSITE_DATA_KEY_NAME));
- }
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_HOSTNAME)) {
- client.setHost((String) cmd
- .get(PulseConstants.COMPOSITE_DATA_KEY_HOSTNAME));
- }
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_QUEUESIZE)) {
- client.setQueueSize((Integer) cmd
- .get(PulseConstants.COMPOSITE_DATA_KEY_QUEUESIZE));
- }
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_PROCESSCPUTIME)) {
- client.setProcessCpuTime((Long) cmd
- .get(PulseConstants.COMPOSITE_DATA_KEY_PROCESSCPUTIME));
- }
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_UPTIME)) {
- client.setUptime((Long) cmd
- .get(PulseConstants.COMPOSITE_DATA_KEY_UPTIME));
- }
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NUMOFTHREADS)) {
- client.setThreads((Integer) cmd
- .get(PulseConstants.COMPOSITE_DATA_KEY_NUMOFTHREADS));
- }
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NUMOFGETS)) {
- client.setGets((Integer) cmd
- .get(PulseConstants.COMPOSITE_DATA_KEY_NUMOFGETS));
- }
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_NUMOFPUTS)) {
- client.setPuts((Integer) cmd
- .get(PulseConstants.COMPOSITE_DATA_KEY_NUMOFPUTS));
- }
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CPUS)) {
- client.setCpus((Integer) cmd
- .get(PulseConstants.COMPOSITE_DATA_KEY_CPUS));
- }
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CPUS)) {
- client.setCpuUsage(0);
- }
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CONNECTED)){
- client.setConnected((Boolean) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_CONNECTED));
- }
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_CLIENTCQCOUNT)){
- client.setClientCQCount((Integer) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_CLIENTCQCOUNT));
- }
- if (cmd.containsKey(PulseConstants.COMPOSITE_DATA_KEY_SUBSCRIPTIONENABLED)){
- client.setSubscriptionEnabled((Boolean) cmd.get(PulseConstants.COMPOSITE_DATA_KEY_SUBSCRIPTIONENABLED));
- }
- memberClientsHM.put(client.getId(), client);
- }
- existingMember.updateMemberClientsHMap(memberClientsHM);
- }
- } catch (InstanceNotFoundException infe) {
- LOGGER.warning(infe);
- } catch (ReflectionException re) {
- LOGGER.warning(re);
- } catch (MBeanException me) {
- LOGGER.warning(me);
- } catch (AttributeNotFoundException anfe) {
- LOGGER.warning(anfe);
- }
- }
-
- /**
- * Add member specific region information on the region
- *
- * @param regionObjectName: used to construct the jmx objectname. For region name that has special characters in, it will have double quotes around it.
- * @param region
- */
- private void updateRegionOnMembers(String regionObjectName, String regionFullPath, Cluster.Region region) throws IOException {
-
- try{
- List<String> memberNamesTemp = region.getMemberName();
- ArrayList<String> memberNames = new ArrayList<String>(memberNamesTemp);
-
- List<Cluster.RegionOnMember> regionOnMemberList = new ArrayList<Cluster.RegionOnMember>();
- List<Cluster.RegionOnMember> regionOnMemberListNew = new ArrayList<Cluster.RegionOnMember>();
- Cluster.RegionOnMember[] regionOnMemberNames = region.getRegionOnMembers();
-
- if ((regionOnMemberNames != null) && (regionOnMemberNames.length > 0)) {
- regionOnMemberList = new ArrayList<Cluster.RegionOnMember>(Arrays.asList(regionOnMemberNames));
- }
- LOGGER.fine("updateRegionOnMembers : # regionOnMembers objects in region = " + regionOnMemberList.size());
-
- for(Cluster.RegionOnMember anRom : regionOnMemberList) {
-
- for(String memberName : memberNames){
- if(anRom.getMemberName().equals(memberName)){
- // Add regionOnMember object in new list
- regionOnMemberListNew.add(anRom);
-
- LOGGER.fine("updateRegionOnMembers : Processing existing Member name = " + anRom.getMemberName());
- String objectNameROM = PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_REGION + regionObjectName + PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_MEMBER + anRom.getMemberName();
- ObjectName regionOnMemberMBean = new ObjectName(objectNameROM);
- LOGGER.fine("updateRegionOnMembers : Object name = " + regionOnMemberMBean.getCanonicalName());
-
- AttributeList attributeList = this.mbs.getAttributes(regionOnMemberMBean, PulseConstants.REGION_ON_MEMBER_MBEAN_ATTRIBUTES);
- for (int i = 0; i < attributeList.size(); i++) {
- Attribute attribute = (Attribute) attributeList.get(i);
- String name = attribute.getName();
- switch(name){
- case PulseConstants.MBEAN_ATTRIBUTE_ENTRYSIZE:
- anRom.setEntrySize(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- LOGGER.fine("updateRegionOnMembers : anRom.getEntrySize() = " + anRom.getEntrySize());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_ENTRYCOUNT:
- anRom.setEntryCount(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- LOGGER.fine("updateRegionOnMembers : anRom.getEntryCount() = " + anRom.getEntryCount());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_PUTSRATE:
- anRom.setPutsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- LOGGER.fine("updateRegionOnMembers : anRom.getPutsRate() = " + anRom.getPutsRate());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_GETSRATE:
- anRom.setGetsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- LOGGER.fine("updateRegionOnMembers : anRom.getGetsRate() = " + anRom.getGetsRate());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
- anRom.setDiskGetsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- LOGGER.fine("updateRegionOnMembers : anRom.getDiskGetsRate() = " + anRom.getDiskGetsRate());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
- anRom.setDiskPutsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- LOGGER.fine("updateRegionOnMembers : anRom.getDiskPutsRate() = " + anRom.getDiskPutsRate());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_LOCALMAXMEMORY:
- anRom.setLocalMaxMemory(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- LOGGER.fine("updateRegionOnMembers : anRom.getLocalMaxMemory() = " + anRom.getLocalMaxMemory());
- break;
- }
- }
-
- anRom.getGetsPerSecTrend().add(anRom.getGetsRate());
- anRom.getPutsPerSecTrend().add(anRom.getPutsRate());
- anRom.getDiskReadsPerSecTrend().add(anRom.getDiskGetsRate());
- anRom.getDiskWritesPerSecTrend().add(anRom.getDiskPutsRate());
- LOGGER.fine("updateRegionOnMembers : Existing member on region : getGetsRate() = " + anRom.getGetsPerSecTrend().size() + ", getPutsRate() = "
- + anRom.getPutsPerSecTrend().size() + ", getDiskGetsRate() = " + anRom.getDiskReadsPerSecTrend().size() + ", getDiskPutsRate() = "
- + anRom.getDiskWritesPerSecTrend().size());
-
- //remove existing member names from list so only new ones will remain
- memberNames.remove(anRom.getMemberName());
-
- break;
- }
- }
- }
-
- LOGGER.fine("updateRegionOnMembers : Loop over remaining member names and adding new member in region. Existing count = " + regionOnMemberList.size());
- LOGGER.fine("updateRegionOnMembers : Remaining new members in this region = " + memberNames.size());
- //loop over the remaining regions members and add new members for this region
- for(String memberName : memberNames) {
- String objectNameROM = PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_REGION + regionObjectName + PulseConstants.OBJECT_NAME_REGION_ON_MEMBER_MEMBER + memberName;
- ObjectName regionOnMemberMBean = new ObjectName(objectNameROM);
- Cluster.RegionOnMember regionOnMember = new Cluster.RegionOnMember();
- regionOnMember.setMemberName(memberName);
- regionOnMember.setRegionFullPath(regionFullPath);
- AttributeList attributeList = this.mbs.getAttributes(regionOnMemberMBean, PulseConstants.REGION_ON_MEMBER_MBEAN_ATTRIBUTES);
- for (int i = 0; i < attributeList.size(); i++) {
- Attribute attribute = (Attribute) attributeList.get(i);
- String name=attribute.getName();
- switch (name){
- case PulseConstants.MBEAN_ATTRIBUTE_ENTRYSIZE:
- regionOnMember.setEntrySize(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_ENTRYCOUNT:
- regionOnMember.setEntryCount(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_PUTSRATE:
- regionOnMember.setPutsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_GETSRATE:
- regionOnMember.setGetsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
- regionOnMember.setDiskGetsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
- regionOnMember.setDiskPutsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_LOCALMAXMEMORY:
- regionOnMember.setLocalMaxMemory(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- }
- }
-
- regionOnMember.getGetsPerSecTrend().add(regionOnMember.getGetsRate());
- regionOnMember.getPutsPerSecTrend().add(regionOnMember.getPutsRate());
- regionOnMember.getDiskReadsPerSecTrend().add(regionOnMember.getDiskGetsRate());
- regionOnMember.getDiskWritesPerSecTrend().add(regionOnMember.getDiskPutsRate());
-
- LOGGER.fine("updateRegionOnMembers : Adding New member on region : getGetsRate() = " + regionOnMember.getGetsRate() + ", getPutsRate() = "
- + regionOnMember.getPutsRate() + ", getDiskGetsRate() = " + regionOnMember.getDiskGetsRate() + ", getDiskPutsRate() = "
- + regionOnMember.getDiskPutsRate());
-
- regionOnMemberListNew.add(regionOnMember);
- }
-
- //set region on member
- region.setRegionOnMembers(regionOnMemberListNew);
- LOGGER.fine("updateRegionOnMembers : Total regions on member in region " + region.getFullPath() + " after update = " + region.getRegionOnMembers().length);
- } catch (MalformedObjectNameException e) {
- LOGGER.warning(e);
- } catch (InstanceNotFoundException infe) {
- LOGGER.warning(infe);
- } catch (ReflectionException re) {
- LOGGER.warning(re);
- }
- }
-
- /**
- * function used to get attribute values of Cluster Region and map them to
- * cluster region vo
- *
- * @param mbeanName
- * Cluster Region MBean
- */
- private void updateClusterRegion(ObjectName mbeanName) throws IOException {
-
- try {
-
- AttributeList attributeList = this.mbs.getAttributes(mbeanName,
- PulseConstants.REGION_MBEAN_ATTRIBUTES);
-
- // retrieve the full path of the region
- String regionObjectName = mbeanName.getKeyProperty("name");
- String regionFullPath = null;
- for (int i = 0; i < attributeList.size(); i++) {
- Attribute attribute = (Attribute) attributeList.get(i);
-
- if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_FULLPATH)) {
- regionFullPath = getStringAttribute(attribute.getValue(),
- attribute.getName());
- break;
- }
- }
-
- Cluster.Region region = cluster.getClusterRegions().get(regionFullPath);
-
- if (null == region) {
- region = new Cluster.Region();
- }
-
- for (int i = 0; i < attributeList.size(); i++) {
-
- Attribute attribute = (Attribute) attributeList.get(i);
-
- String name = attribute.getName();
- switch (name){
- case PulseConstants.MBEAN_ATTRIBUTE_MEMBERS:
- String memName[] = (String[]) attribute.getValue();
- region.getMemberName().clear();
- for (int k = 0; k < memName.length; k++) {
- region.getMemberName().add(memName[k]);
- }
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_FULLPATH:
- region.setFullPath(getStringAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
- region.setDiskReadsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
- region.setDiskWritesRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_EMPTYNODES:
- region.setEmptyNode(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_GETSRATE:
- region.setGetsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_LRUEVICTIONRATE:
- region.setLruEvictionRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_PUTSRATE:
- region.setPutsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_REGIONTYPE:
- region.setRegionType(getStringAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_ENTRYSIZE:
- region.setEntrySize(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_SYSTEMREGIONENTRYCOUNT:
- region.setSystemRegionEntryCount(getLongAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_MEMBERCOUNT:
- region.setMemberCount(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_PERSISTENTENABLED:
- region.setPersistentEnabled(getBooleanAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_NAME:
- region.setName(getStringAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_GATEWAYENABLED:
- region.setWanEnabled(getBooleanAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISKUSAGE:
- region.setDiskUsage(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- }
- }
-
- //add for each member
- updateRegionOnMembers(regionObjectName, regionFullPath, region);
-
- cluster.addClusterRegion(regionFullPath, region);
- cluster.getDeletedRegions().remove(region.getFullPath());
- // Memory Reads and writes
- region.getPutsPerSecTrend().add(region.getPutsRate());
- region.getGetsPerSecTrend().add(region.getGetsRate());
- // Disk Reads and Writes
- region.getDiskReadsPerSecTrend().add(region.getDiskReadsRate());
- region.getDiskWritesPerSecTrend().add(region.getDiskWritesRate());
-
- } catch (InstanceNotFoundException infe) {
- LOGGER.warning(infe);
- } catch (ReflectionException re) {
- LOGGER.warning(re);
- }
- }
-
- private static boolean isQuoted(String value) {
- final int len = value.length();
- if (len < 2 || value.charAt(0) != '"' || value.charAt(len - 1) != '"') {
- return false;
- } else {
- return true;
- }
- }
-
- private void updateClusterStatement(ObjectName mbeanName) throws IOException {
-
- try {
-
- AttributeList attributeList = this.mbs.getAttributes(mbeanName,
- PulseConstants.STATEMENT_MBEAN_ATTRIBUTES);
- // retrieve the full path of the region
- String statementDefinition = mbeanName.getKeyProperty("name");
-
- if (isQuoted(statementDefinition)) {
- statementDefinition = ObjectName.unquote(statementDefinition);
- }
-
- Cluster.Statement statement = cluster.getClusterStatements().get(
- statementDefinition);
-
- if (null == statement) {
- statement = new Cluster.Statement();
- statement.setQueryDefinition(statementDefinition);
- }
-
- for (int i = 0; i < attributeList.size(); i++) {
- Attribute attribute = (Attribute) attributeList.get(i);
- String name = attribute.getName();
- switch (name){
- case PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESCOMPILED:
- statement.setNumTimesCompiled(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTION:
- statement.setNumExecution(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTIONSINPROGRESS:
- statement.setNumExecutionsInProgress(getLongAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESGLOBALINDEXLOOKUP:
- statement.setNumTimesGlobalIndexLookup(getLongAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_NUMROWSMODIFIED:
- statement.setNumRowsModified(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_PARSETIME:
- statement.setParseTime(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_BINDTIME:
- statement.setBindTime(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_OPTIMIZETIME:
- statement.setOptimizeTime(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_ROUTINGINFOTIME:
- statement.setRoutingInfoTime(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_GENERATETIME:
- statement.setGenerateTime(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_TOTALCOMPILATIONTIME:
- statement.setTotalCompilationTime(getLongAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_EXECUTIONTIME:
- statement.setExecutionTime(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_PROJECTIONTIME:
- statement.setProjectionTime(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_TOTALEXECUTIONTIME:
- statement.setTotalExecutionTime(getLongAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_ROWSMODIFICATIONTIME:
- statement.setRowsModificationTime(getLongAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_QNNUMROWSSEEN:
- statement.setqNNumRowsSeen(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_QNMSGSENDTIME:
- statement.setqNMsgSendTime(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_QNMSGSERTIME:
- statement.setqNMsgSerTime(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_QNRESPDESERTIME:
- statement.setqNRespDeSerTime(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- }
- }
-
- cluster.addClusterStatement(statementDefinition, statement);
- // TODO : to store data for sparklines later
- /*
- * region.getPutsPerSecTrend().add(region.getPutsRate());
- * region.getGetsPerSecTrend().add(region.getGetsRate());
- */
- } catch (InstanceNotFoundException infe) {
- LOGGER.warning(infe);
- } catch (ReflectionException re) {
- LOGGER.warning(re);
- }
- }
-
- /**
- * function used to iterate through all member attributes and return the
- * updated member
- */
- private Cluster.Member initializeMember(ObjectName mbeanName,
- Cluster.Member member) throws InstanceNotFoundException,
- ReflectionException, IOException {
-
- AttributeList attributeList = this.mbs.getAttributes(mbeanName,
- PulseConstants.MEMBER_MBEAN_ATTRIBUTES);
-
- for (int i = 0; i < attributeList.size(); i++) {
-
- Attribute attribute = (Attribute) attributeList.get(i);
- String name = attribute.getName();
- switch (name) {
- case PulseConstants.MBEAN_ATTRIBUTE_GEMFIREVERSION:
- if (member.getGemfireVersion() == null) {
- // Set Member's GemFire Version if not set already
- String gemfireVersion = obtainGemfireVersion(getStringAttribute(
- attribute.getValue(), attribute.getName()));
- member.setGemfireVersion(gemfireVersion);
- }
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_MANAGER:
- member.setManager(getBooleanAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_TOTALREGIONCOUNT:
- member.setTotalRegionCount(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_LOCATOR:
- member.setLocator(getBooleanAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_TOTALDISKUSAGE:
- member.setTotalDiskUsage(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_SERVER:
- member.setServer(getBooleanAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_TOTALFILEDESCRIPTOROPEN:
- member.setTotalFileDescriptorOpen(getLongAttribute(
- attribute.getValue(), attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_LOADAVERAGE:
- member.setLoadAverage(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
- member.setThroughputWrites(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- member.getThroughputWritesTrend().add(member.getThroughputWrites());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
- member.setThroughputReads(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- member.getThroughputReadsTrend().add(member.getThroughputReads());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_JVMPAUSES:
- long trendVal = determineCurrentJVMPauses(
- PulseConstants.JVM_PAUSES_TYPE_MEMBER, member.getName(),
- getLongAttribute(attribute.getValue(),
- attribute.getName()));
- member.setGarbageCollectionCount(trendVal);
- member.getGarbageCollectionSamples().add(
- member.getGarbageCollectionCount());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_USEDMEMORY:
- member.setCurrentHeapSize(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- member.getHeapUsageSamples().add(member.getCurrentHeapSize());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_MAXMEMORY:
- member.setMaxHeapSize(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_NUMTHREADS:
- member.setNumThreads(getIntegerAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_MEMBERUPTIME:
- member.setUptime(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_HOST:
- member.setHost(getStringAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_HOSTNAMEFORCLIENTS:
- member.setHostnameForClients(getStringAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_BINDADDRESS:
- member.setBindAddress(getStringAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_TOTALBYTESONDISK:
- member.setTotalBytesOnDisk(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- member.getTotalBytesOnDiskSamples().add(member.getTotalBytesOnDisk());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_CPUUSAGE:
- member.setCpuUsage(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- member.getCpuUsageSamples().add(member.getCpuUsage());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_HOSTCPUUSAGE:
- // Float value is expected for host cpu usage.
- // TODO Remove Float.valueOf() when float value is provided in mbean
- member.setHostCpuUsage(Double.valueOf(getIntegerAttribute(
- attribute.getValue(), attribute.getName())));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_MEMBER:
- member.setName(getStringAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_ID:
- member.setId(getStringAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEREADS:
- member.setGetsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- member.getGetsPerSecond().add(member.getGetsRate());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEWRITES:
- member.setPutsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- member.getPutsPerSecond().add(member.getPutsRate());
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_OFFHEAPFREESIZE:
- member.setOffHeapFreeSize(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_OFFHEAPUSEDSIZE:
- member.setOffHeapUsedSize(getLongAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_SERVERGROUPS:
- String sgValues[] = (String[]) attribute.getValue();
- member.getServerGroups().clear();
- for (int k = 0; k < sgValues.length; k++) {
- member.getServerGroups().add(sgValues[k]);
- }
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_REDUNDANCYZONES:
- String rzValue = "";
- if(null != attribute.getValue()){
- rzValue = getStringAttribute(attribute.getValue(),
- attribute.getName());
- }
- member.getRedundancyZones().clear();
- if(!rzValue.isEmpty()){
- member.getRedundancyZones().add(rzValue);
- }
- break;
- }
- }
-
- // SQLFire specific attributes
- if (PulseController.getPulseProductSupport().equalsIgnoreCase(
- PulseConstants.PRODUCT_NAME_SQLFIRE)) {
-
- try {
- // get sqlfire mbeans
- String memberName = mbeanName
- .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
-
- ObjectName sfMemberMbeansObjectName = new ObjectName(
- PulseConstants.OBJECT_NAME_SF_MEMBER_PATTERN + memberName);
-
- Set<ObjectName> sfMemberMBeans = this.mbs.queryNames(
- sfMemberMbeansObjectName, null);
- for (ObjectName sfMemberMBean : sfMemberMBeans) {
-
- AttributeList attrList = this.mbs.getAttributes(sfMemberMBean,
- PulseConstants.SF_MEMBER_MBEAN_ATTRIBUTES);
- for (int i = 0; i < attrList.size(); i++) {
-
- Attribute attribute = (Attribute) attrList.get(i);
-
- if (attribute.getName().equals(
- PulseConstants.MBEAN_ATTRIBUTE_DATASTORE)) {
- member.setServer(getBooleanAttribute(attribute.getValue(),
- attribute.getName()));
-
- // Update Server count
- if (member.isServer()) {
- cluster.setServerCount(cluster.getServerCount() + 1);
- }
- } else if (attribute.getName().equals(
- PulseConstants.MBEAN_ATTRIBUTE_NETWORKSERVERCLIENTCONNECTIONSTATS)) {
-
- CompositeData nscConnStats = (CompositeData) attribute.getValue();
-
- // Update sqlfire client count
- member.setNumSqlfireClients(getLongAttribute(nscConnStats
- .get(PulseConstants.COMPOSITE_DATA_KEY_CONNECTIONSACTIVE),
- PulseConstants.COMPOSITE_DATA_KEY_CONNECTIONSACTIVE));
- }
- }
- break;
- }
-
- } catch (MalformedObjectNameException e) {
- LOGGER.warning(e);
- } catch (NullPointerException e) {
- LOGGER.warning(e);
- }
-
- }
-
- return member;
- }
-
- /**
- * function used to get attribute values of Cluster Member and map them to
- * cluster member vo
- *
- * @param mbeanName
- * Cluster Member MBean
- */
- private void updateClusterMember(ObjectName mbeanName) throws IOException {
-
- try {
- String memberName = mbeanName
- .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
-
- Cluster.Member clusterMember = cluster.getMembersHMap().get(memberName);
-
- if (clusterMember != null) // checking if member exists or not
- {
- cluster.getDeletedMembers().remove(memberName);
- } else {
- clusterMember = new Cluster.Member();
- cluster.getMembersHMap().put(memberName, clusterMember);
- }
-
- // initialize member and add to cluster's member list
- clusterMember = initializeMember(mbeanName, clusterMember);
- ArrayList<Cluster.Member> memberArrList = (ArrayList<Cluster.Member>) cluster
- .getPhysicalToMember().get(clusterMember.getHost());
- if (memberArrList != null) {
- if (!memberArrList.contains(clusterMember)) {
- memberArrList.add(clusterMember);
- }
- } else {
- ArrayList<Cluster.Member> memberList = new ArrayList<Cluster.Member>();
- memberList.add(clusterMember);
- cluster.getPhysicalToMember().put(clusterMember.getHost(), memberList);
- }
- } catch (InstanceNotFoundException infe) {
- LOGGER.warning(infe);
- } catch (ReflectionException re) {
- LOGGER.warning(re);
- }
- }
-
- /**
- * function used to handle Float data type if the value for mbean for an
- * attribute is null then return 0.0 as default value else return the
- * attribute value
- */
- private Float getFloatAttribute(Object object, String name) {
- if (object == null) {
- return Float.valueOf(0.0f);
- }
-
- try {
- if (!(object.getClass().equals(Float.class))) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("************************Unexpected type for attribute: "
- + name + " Expected type: " + Float.class.getName()
- + " Received type: " + object.getClass().getName()
- + "************************");
- }
- return Float.valueOf(0.0f);
- } else {
- return (Float) object;
- }
- } catch (Exception e) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("Exception occurred: " + e.getMessage());
- }
- return Float.valueOf(0.0f);
- }
- }
-
- /**
- * function used to handle Integer data type if the value for mbean for an
- * attribute is null then return 0 as default value else return the attribute
- * value
- */
- private Integer getIntegerAttribute(Object object, String name) {
- if (object == null) {
- return Integer.valueOf(0);
- }
-
- try {
- if (!(object.getClass().equals(Integer.class))) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("************************Unexpected type for attribute: "
- + name + " Expected type: " + Integer.class.getName()
- + " Received type: " + object.getClass().getName()
- + "************************");
- }
- return Integer.valueOf(0);
- } else {
- return (Integer) object;
- }
- } catch (Exception e) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("Exception occurred: " + e.getMessage());
- }
- return Integer.valueOf(0);
- }
- }
-
- /**
- * function used to handle Long data type if the value for mbean for an
- * attribute is null then return 0 as default value else return the attribute
- * value
- */
- private Long getLongAttribute(Object object, String name) {
- if (object == null) {
- return Long.valueOf(0);
- }
-
- try {
- if (!(object.getClass().equals(Long.class))) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("************************Unexpected type for attribute: "
- + name + " Expected type: " + Long.class.getName()
- + " Received type: " + object.getClass().getName()
- + "************************");
- }
- return Long.valueOf(0);
- } else {
- return (Long) object;
- }
- } catch (Exception e) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("Exception occurred: " + e.getMessage());
- }
- return Long.valueOf(0);
- }
-
- }
-
- /**
- * function used to handle String data type if the value for mbean for an
- * attribute is null then return the empty string as default value else return
- * the attribute value
- */
- private String getStringAttribute(Object object, String name) {
- if (object == null) {
- return "";
- }
-
- try {
- if (!(object.getClass().equals(String.class))) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("************************Unexpected type for attribute: "
- + name + " Expected type: " + String.class.getName()
- + " Received type: " + object.getClass().getName()
- + "************************");
- }
- return "";
- } else {
- return (String) object;
- }
- } catch (Exception e) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("Exception occurred: " + e.getMessage());
- }
- return "";
- }
- }
-
- /**
- * function used to handle Boolean data type if the value for mbean for an
- * attribute is null then return false as default value else return the
- * attribute value
- */
- private Boolean getBooleanAttribute(Object object, String name) {
- if (object == null) {
- return Boolean.FALSE;
- }
-
- try {
- if (!(object.getClass().equals(Boolean.class))) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("************************Unexpected type for attribute: "
- + name + " Expected type: " + Boolean.class.getName()
- + " Received type: " + object.getClass().getName()
- + "************************");
- }
- return Boolean.FALSE;
- } else {
- return (Boolean) object;
- }
- } catch (Exception e) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("Exception Occured: " + e.getMessage());
- }
- return Boolean.FALSE;
- }
- }
-
- /**
- * function used to handle Double data type if the value for mbean for an
- * attribute is null then return 0.0 as default value else return the
- * attribute value
- */
- private Double getDoubleAttribute(Object object, String name) {
- if (object == null) {
- return Double.valueOf(0);
- }
-
- try {
- if (!(object.getClass().equals(Double.class))) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("************************Unexpected type for attribute: "
- + name + " Expected type: " + Double.class.getName()
- + " Received type: " + object.getClass().getName()
- + "************************");
- }
- return Double.valueOf(0);
- } else {
- return (Double) object;
- }
- } catch (Exception e) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info("Exception occurred: " + e.getMessage());
- }
- return Double.valueOf(0);
- }
- }
-
- /**
- * function used to get attribute values of Member Region and map them to
- * Member vo
- *
- * @param mbeanName
- * Member Region MBean
- */
- private void updateMemberRegion(ObjectName mbeanName) throws IOException {
-
- try {
- String memberName = mbeanName
- .getKeyProperty(PulseConstants.MBEAN_KEY_PROPERTY_MEMBER);
-
- Cluster.Member member = cluster.getMembersHMap().get(memberName);
-
- //Following attributes are not present in 9.0
- //"Members"
- //"EmptyNodes"
- //"SystemRegionEntryCount"
- //"MemberCount"
- AttributeList attributeList = this.mbs.getAttributes(mbeanName,
- PulseConstants.REGION_MBEAN_ATTRIBUTES);
-
- // retrieve the full path of the region
- String regionFullPathKey = null;
- for (int i = 0; i < attributeList.size(); i++) {
- Attribute attribute = (Attribute) attributeList.get(i);
-
- if (attribute.getName().equals(PulseConstants.MBEAN_ATTRIBUTE_FULLPATH)) {
- regionFullPathKey = getStringAttribute(attribute.getValue(),
- attribute.getName());
- break;
- }
- }
-
- // if member does not exists defined for this region then create a member
- if (null == member) {
- member = new Cluster.Member();
- member.setName(memberName);
- cluster.getMembersHMap().put(memberName, member);
- }
-
- // if region with given path exists then update same else add new region
- Cluster.Region region = member.getMemberRegions().get(regionFullPathKey);
- if (null == region) {
- region = new Cluster.Region();
- member.getMemberRegions().put(regionFullPathKey, region);
- member.setTotalRegionCount(member.getTotalRegionCount() + 1);
- }
- region.setFullPath(regionFullPathKey); // use already retrieved values
-
- // update the existing or new region
- for (int i = 0; i < attributeList.size(); i++) {
- Attribute attribute = (Attribute) attributeList.get(i);
- String name = attribute.getName();
- switch (name){
- case PulseConstants.MBEAN_ATTRIBUTE_FULLPATH:
- region.setFullPath(getStringAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
- region.setDiskReadsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
- region.setDiskWritesRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- case PulseConstants.MBEAN_ATTRIBUTE_GETSRATE:
- region.setGetsRate(getDoubleAttribute(attribute.getValue(),
- attribute.getName()));
- break;
- cas
<TRUNCATED>
[27/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONArray.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONArray.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONArray.java
deleted file mode 100644
index aa1c272..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONArray.java
+++ /dev/null
@@ -1,901 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.json;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * A JSONArray is an ordered sequence of values. Its external text form is a
- * string wrapped in square brackets with commas separating the values. The
- * internal form is an object having <code>get</code> and <code>opt</code>
- * methods for accessing the values by index, and <code>put</code> methods for
- * adding or replacing values. The values can be any of these types:
- * <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>,
- * <code>Number</code>, <code>String</code>, or the
- * <code>JSONObject.NULL object</code>.
- * <p>
- * The constructor can convert a JSON text into a Java object. The
- * <code>toString</code> method converts to JSON text.
- * <p>
- * A <code>get</code> method returns a value if one can be found, and throws an
- * exception if one cannot be found. An <code>opt</code> method returns a
- * default value instead of throwing an exception, and so is useful for
- * obtaining optional values.
- * <p>
- * The generic <code>get()</code> and <code>opt()</code> methods return an
- * object which you can cast or query for type. There are also typed
- * <code>get</code> and <code>opt</code> methods that do type checking and type
- * coercion for you.
- * <p>
- * The texts produced by the <code>toString</code> methods strictly conform to
- * JSON syntax rules. The constructors are more forgiving in the texts they will
- * accept:
- * <ul>
- * <li>An extra <code>,</code> <small>(comma)</small> may appear just
- * before the closing bracket.</li>
- * <li>The <code>null</code> value will be inserted when there is <code>,</code>
- * <small>(comma)</small> elision.</li>
- * <li>Strings may be quoted with <code>'</code> <small>(single
- * quote)</small>.</li>
- * <li>Strings do not need to be quoted at all if they do not begin with a quote
- * or single quote, and if they do not contain leading or trailing spaces, and
- * if they do not contain any of these characters:
- * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers and
- * if they are not the reserved words <code>true</code>, <code>false</code>, or
- * <code>null</code>.</li>
- * <li>Values can be separated by <code>;</code> <small>(semicolon)</small> as
- * well as by <code>,</code> <small>(comma)</small>.</li>
- * </ul>
- *
- * @author JSON.org
- * @version 2012-04-20
- */
-public class JSONArray {
-
-
- /**
- * The arrayList where the JSONArray's properties are kept.
- */
- private final ArrayList myArrayList;
-
-
- /**
- * Construct an empty JSONArray.
- */
- public JSONArray() {
- this.myArrayList = new ArrayList();
- }
-
- /**
- * Construct a JSONArray from a JSONTokener.
- * @param x A JSONTokener
- * @throws JSONException If there is a syntax error.
- */
- public JSONArray(JSONTokener x) throws JSONException {
- this();
- if (x.nextClean() != '[') {
- throw x.syntaxError("A JSONArray text must start with '['");
- }
- if (x.nextClean() != ']') {
- x.back();
- for (;;) {
- if (x.nextClean() == ',') {
- x.back();
- this.myArrayList.add(JSONObject.NULL);
- } else {
- x.back();
- this.myArrayList.add(x.nextValue());
- }
- switch (x.nextClean()) {
- case ';':
- case ',':
- if (x.nextClean() == ']') {
- return;
- }
- x.back();
- break;
- case ']':
- return;
- default:
- throw x.syntaxError("Expected a ',' or ']'");
- }
- }
- }
- }
-
-
- /**
- * Construct a JSONArray from a source JSON text.
- * @param source A string that begins with
- * <code>[</code> <small>(left bracket)</small>
- * and ends with <code>]</code> <small>(right bracket)</small>.
- * @throws JSONException If there is a syntax error.
- */
- public JSONArray(String source) throws JSONException {
- this(new JSONTokener(source));
- }
-
-
- /**
- * Construct a JSONArray from a Collection.
- * @param collection A Collection.
- */
- public JSONArray(Collection collection) {
- this.myArrayList = new ArrayList();
- if (collection != null) {
- Iterator iter = collection.iterator();
- while (iter.hasNext()) {
- this.myArrayList.add(JSONObject.wrap(iter.next()));
- }
- }
- }
-
-
- /**
- * Construct a JSONArray from an array
- * @throws JSONException If not an array.
- */
- public JSONArray(Object array) throws JSONException {
- this();
- if (array.getClass().isArray()) {
- int length = Array.getLength(array);
- for (int i = 0; i < length; i += 1) {
- this.put(JSONObject.wrap(Array.get(array, i)));
- }
- } else {
- throw new JSONException(
-"JSONArray initial value should be a string or collection or array.");
- }
- }
-
-
- /**
- * Get the object value associated with an index.
- * @param index
- * The index must be between 0 and length() - 1.
- * @return An object value.
- * @throws JSONException If there is no value for the index.
- */
- public Object get(int index) throws JSONException {
- Object object = this.opt(index);
- if (object == null) {
- throw new JSONException("JSONArray[" + index + "] not found.");
- }
- return object;
- }
-
-
- /**
- * Get the boolean value associated with an index.
- * The string values "true" and "false" are converted to boolean.
- *
- * @param index The index must be between 0 and length() - 1.
- * @return The truth.
- * @throws JSONException If there is no value for the index or if the
- * value is not convertible to boolean.
- */
- public boolean getBoolean(int index) throws JSONException {
- Object object = this.get(index);
- if (object.equals(Boolean.FALSE) ||
- (object instanceof String &&
- ((String)object).equalsIgnoreCase("false"))) {
- return false;
- } else if (object.equals(Boolean.TRUE) ||
- (object instanceof String &&
- ((String)object).equalsIgnoreCase("true"))) {
- return true;
- }
- throw new JSONException("JSONArray[" + index + "] is not a boolean.");
- }
-
-
- /**
- * Get the double value associated with an index.
- *
- * @param index The index must be between 0 and length() - 1.
- * @return The value.
- * @throws JSONException If the key is not found or if the value cannot
- * be converted to a number.
- */
- public double getDouble(int index) throws JSONException {
- Object object = this.get(index);
- try {
- return object instanceof Number
- ? ((Number)object).doubleValue()
- : Double.parseDouble((String)object);
- } catch (Exception e) {
- throw new JSONException("JSONArray[" + index +
- "] is not a number.");
- }
- }
-
-
- /**
- * Get the int value associated with an index.
- *
- * @param index The index must be between 0 and length() - 1.
- * @return The value.
- * @throws JSONException If the key is not found or if the value is not a number.
- */
- public int getInt(int index) throws JSONException {
- Object object = this.get(index);
- try {
- return object instanceof Number
- ? ((Number)object).intValue()
- : Integer.parseInt((String)object);
- } catch (Exception e) {
- throw new JSONException("JSONArray[" + index +
- "] is not a number.");
- }
- }
-
-
- /**
- * Get the JSONArray associated with an index.
- * @param index The index must be between 0 and length() - 1.
- * @return A JSONArray value.
- * @throws JSONException If there is no value for the index. or if the
- * value is not a JSONArray
- */
- public JSONArray getJSONArray(int index) throws JSONException {
- Object object = this.get(index);
- if (object instanceof JSONArray) {
- return (JSONArray)object;
- }
- throw new JSONException("JSONArray[" + index +
- "] is not a JSONArray.");
- }
-
-
- /**
- * Get the JSONObject associated with an index.
- * @param index subscript
- * @return A JSONObject value.
- * @throws JSONException If there is no value for the index or if the
- * value is not a JSONObject
- */
- public JSONObject getJSONObject(int index) throws JSONException {
- Object object = this.get(index);
- if (object instanceof JSONObject) {
- return (JSONObject)object;
- }
- throw new JSONException("JSONArray[" + index +
- "] is not a JSONObject.");
- }
-
-
- /**
- * Get the long value associated with an index.
- *
- * @param index The index must be between 0 and length() - 1.
- * @return The value.
- * @throws JSONException If the key is not found or if the value cannot
- * be converted to a number.
- */
- public long getLong(int index) throws JSONException {
- Object object = this.get(index);
- try {
- return object instanceof Number
- ? ((Number)object).longValue()
- : Long.parseLong((String)object);
- } catch (Exception e) {
- throw new JSONException("JSONArray[" + index +
- "] is not a number.");
- }
- }
-
-
- /**
- * Get the string associated with an index.
- * @param index The index must be between 0 and length() - 1.
- * @return A string value.
- * @throws JSONException If there is no string value for the index.
- */
- public String getString(int index) throws JSONException {
- Object object = this.get(index);
- if (object instanceof String) {
- return (String)object;
- }
- throw new JSONException("JSONArray[" + index + "] not a string.");
- }
-
-
- /**
- * Determine if the value is null.
- * @param index The index must be between 0 and length() - 1.
- * @return true if the value at the index is null, or if there is no value.
- */
- public boolean isNull(int index) {
- return JSONObject.NULL.equals(this.opt(index));
- }
-
-
- /**
- * Make a string from the contents of this JSONArray. The
- * <code>separator</code> string is inserted between each element.
- * Warning: This method assumes that the data structure is acyclical.
- * @param separator A string that will be inserted between the elements.
- * @return a string.
- * @throws JSONException If the array contains an invalid number.
- */
- public String join(String separator) throws JSONException {
- int len = this.length();
- StringBuffer sb = new StringBuffer();
-
- for (int i = 0; i < len; i += 1) {
- if (i > 0) {
- sb.append(separator);
- }
- sb.append(JSONObject.valueToString(this.myArrayList.get(i)));
- }
- return sb.toString();
- }
-
-
- /**
- * Get the number of elements in the JSONArray, included nulls.
- *
- * @return The length (or size).
- */
- public int length() {
- return this.myArrayList.size();
- }
-
-
- /**
- * Get the optional object value associated with an index.
- * @param index The index must be between 0 and length() - 1.
- * @return An object value, or null if there is no
- * object at that index.
- */
- public Object opt(int index) {
- return (index < 0 || index >= this.length())
- ? null
- : this.myArrayList.get(index);
- }
-
-
- /**
- * Get the optional boolean value associated with an index.
- * It returns false if there is no value at that index,
- * or if the value is not Boolean.TRUE or the String "true".
- *
- * @param index The index must be between 0 and length() - 1.
- * @return The truth.
- */
- public boolean optBoolean(int index) {
- return this.optBoolean(index, false);
- }
-
-
- /**
- * Get the optional boolean value associated with an index.
- * It returns the defaultValue if there is no value at that index or if
- * it is not a Boolean or the String "true" or "false" (case insensitive).
- *
- * @param index The index must be between 0 and length() - 1.
- * @param defaultValue A boolean default.
- * @return The truth.
- */
- public boolean optBoolean(int index, boolean defaultValue) {
- try {
- return this.getBoolean(index);
- } catch (Exception e) {
- return defaultValue;
- }
- }
-
-
- /**
- * Get the optional double value associated with an index.
- * NaN is returned if there is no value for the index,
- * or if the value is not a number and cannot be converted to a number.
- *
- * @param index The index must be between 0 and length() - 1.
- * @return The value.
- */
- public double optDouble(int index) {
- return this.optDouble(index, Double.NaN);
- }
-
-
- /**
- * Get the optional double value associated with an index.
- * The defaultValue is returned if there is no value for the index,
- * or if the value is not a number and cannot be converted to a number.
- *
- * @param index subscript
- * @param defaultValue The default value.
- * @return The value.
- */
- public double optDouble(int index, double defaultValue) {
- try {
- return this.getDouble(index);
- } catch (Exception e) {
- return defaultValue;
- }
- }
-
-
- /**
- * Get the optional int value associated with an index.
- * Zero is returned if there is no value for the index,
- * or if the value is not a number and cannot be converted to a number.
- *
- * @param index The index must be between 0 and length() - 1.
- * @return The value.
- */
- public int optInt(int index) {
- return this.optInt(index, 0);
- }
-
-
- /**
- * Get the optional int value associated with an index.
- * The defaultValue is returned if there is no value for the index,
- * or if the value is not a number and cannot be converted to a number.
- * @param index The index must be between 0 and length() - 1.
- * @param defaultValue The default value.
- * @return The value.
- */
- public int optInt(int index, int defaultValue) {
- try {
- return this.getInt(index);
- } catch (Exception e) {
- return defaultValue;
- }
- }
-
-
- /**
- * Get the optional JSONArray associated with an index.
- * @param index subscript
- * @return A JSONArray value, or null if the index has no value,
- * or if the value is not a JSONArray.
- */
- public JSONArray optJSONArray(int index) {
- Object o = this.opt(index);
- return o instanceof JSONArray ? (JSONArray)o : null;
- }
-
-
- /**
- * Get the optional JSONObject associated with an index.
- * Null is returned if the key is not found, or null if the index has
- * no value, or if the value is not a JSONObject.
- *
- * @param index The index must be between 0 and length() - 1.
- * @return A JSONObject value.
- */
- public JSONObject optJSONObject(int index) {
- Object o = this.opt(index);
- return o instanceof JSONObject ? (JSONObject)o : null;
- }
-
-
- /**
- * Get the optional long value associated with an index.
- * Zero is returned if there is no value for the index,
- * or if the value is not a number and cannot be converted to a number.
- *
- * @param index The index must be between 0 and length() - 1.
- * @return The value.
- */
- public long optLong(int index) {
- return this.optLong(index, 0);
- }
-
-
- /**
- * Get the optional long value associated with an index.
- * The defaultValue is returned if there is no value for the index,
- * or if the value is not a number and cannot be converted to a number.
- * @param index The index must be between 0 and length() - 1.
- * @param defaultValue The default value.
- * @return The value.
- */
- public long optLong(int index, long defaultValue) {
- try {
- return this.getLong(index);
- } catch (Exception e) {
- return defaultValue;
- }
- }
-
-
- /**
- * Get the optional string value associated with an index. It returns an
- * empty string if there is no value at that index. If the value
- * is not a string and is not null, then it is coverted to a string.
- *
- * @param index The index must be between 0 and length() - 1.
- * @return A String value.
- */
- public String optString(int index) {
- return this.optString(index, "");
- }
-
-
- /**
- * Get the optional string associated with an index.
- * The defaultValue is returned if the key is not found.
- *
- * @param index The index must be between 0 and length() - 1.
- * @param defaultValue The default value.
- * @return A String value.
- */
- public String optString(int index, String defaultValue) {
- Object object = this.opt(index);
- return JSONObject.NULL.equals(object)
- ? defaultValue : object
- .toString();
- }
-
-
- /**
- * Append a boolean value. This increases the array's length by one.
- *
- * @param value A boolean value.
- * @return this.
- */
- public JSONArray put(boolean value) {
- this.put(value ? Boolean.TRUE : Boolean.FALSE);
- return this;
- }
-
-
- /**
- * Put a value in the JSONArray, where the value will be a
- * JSONArray which is produced from a Collection.
- * @param value A Collection value.
- * @return this.
- */
- public JSONArray put(Collection value) {
- this.put(new JSONArray(value));
- return this;
- }
-
-
- /**
- * Append a double value. This increases the array's length by one.
- *
- * @param value A double value.
- * @throws JSONException if the value is not finite.
- * @return this.
- */
- public JSONArray put(double value) throws JSONException {
- Double d = new Double(value);
- JSONObject.testValidity(d);
- this.put(d);
- return this;
- }
-
-
- /**
- * Append an int value. This increases the array's length by one.
- *
- * @param value An int value.
- * @return this.
- */
- public JSONArray put(int value) {
- this.put(new Integer(value));
- return this;
- }
-
-
- /**
- * Append an long value. This increases the array's length by one.
- *
- * @param value A long value.
- * @return this.
- */
- public JSONArray put(long value) {
- this.put(new Long(value));
- return this;
- }
-
-
- /**
- * Put a value in the JSONArray, where the value will be a
- * JSONObject which is produced from a Map.
- * @param value A Map value.
- * @return this.
- */
- public JSONArray put(Map value) {
- this.put(new JSONObject(value));
- return this;
- }
-
-
- /**
- * Append an object value. This increases the array's length by one.
- * @param value An object value. The value should be a
- * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
- * JSONObject.NULL object.
- * @return this.
- */
- public JSONArray put(Object value) {
- this.myArrayList.add(value);
- return this;
- }
-
-
- /**
- * Put or replace a boolean value in the JSONArray. If the index is greater
- * than the length of the JSONArray, then null elements will be added as
- * necessary to pad it out.
- * @param index The subscript.
- * @param value A boolean value.
- * @return this.
- * @throws JSONException If the index is negative.
- */
- public JSONArray put(int index, boolean value) throws JSONException {
- this.put(index, value ? Boolean.TRUE : Boolean.FALSE);
- return this;
- }
-
-
- /**
- * Put a value in the JSONArray, where the value will be a
- * JSONArray which is produced from a Collection.
- * @param index The subscript.
- * @param value A Collection value.
- * @return this.
- * @throws JSONException If the index is negative or if the value is
- * not finite.
- */
- public JSONArray put(int index, Collection value) throws JSONException {
- this.put(index, new JSONArray(value));
- return this;
- }
-
-
- /**
- * Put or replace a double value. If the index is greater than the length of
- * the JSONArray, then null elements will be added as necessary to pad
- * it out.
- * @param index The subscript.
- * @param value A double value.
- * @return this.
- * @throws JSONException If the index is negative or if the value is
- * not finite.
- */
- public JSONArray put(int index, double value) throws JSONException {
- this.put(index, new Double(value));
- return this;
- }
-
-
- /**
- * Put or replace an int value. If the index is greater than the length of
- * the JSONArray, then null elements will be added as necessary to pad
- * it out.
- * @param index The subscript.
- * @param value An int value.
- * @return this.
- * @throws JSONException If the index is negative.
- */
- public JSONArray put(int index, int value) throws JSONException {
- this.put(index, new Integer(value));
- return this;
- }
-
-
- /**
- * Put or replace a long value. If the index is greater than the length of
- * the JSONArray, then null elements will be added as necessary to pad
- * it out.
- * @param index The subscript.
- * @param value A long value.
- * @return this.
- * @throws JSONException If the index is negative.
- */
- public JSONArray put(int index, long value) throws JSONException {
- this.put(index, new Long(value));
- return this;
- }
-
-
- /**
- * Put a value in the JSONArray, where the value will be a
- * JSONObject that is produced from a Map.
- * @param index The subscript.
- * @param value The Map value.
- * @return this.
- * @throws JSONException If the index is negative or if the the value is
- * an invalid number.
- */
- public JSONArray put(int index, Map value) throws JSONException {
- this.put(index, new JSONObject(value));
- return this;
- }
-
-
- /**
- * Put or replace an object value in the JSONArray. If the index is greater
- * than the length of the JSONArray, then null elements will be added as
- * necessary to pad it out.
- * @param index The subscript.
- * @param value The value to put into the array. The value should be a
- * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
- * JSONObject.NULL object.
- * @return this.
- * @throws JSONException If the index is negative or if the the value is
- * an invalid number.
- */
- public JSONArray put(int index, Object value) throws JSONException {
- JSONObject.testValidity(value);
- if (index < 0) {
- throw new JSONException("JSONArray[" + index + "] not found.");
- }
- if (index < this.length()) {
- this.myArrayList.set(index, value);
- } else {
- while (index != this.length()) {
- this.put(JSONObject.NULL);
- }
- this.put(value);
- }
- return this;
- }
-
-
- /**
- * Remove an index and close the hole.
- * @param index The index of the element to be removed.
- * @return The value that was associated with the index,
- * or null if there was no value.
- */
- public Object remove(int index) {
- Object o = this.opt(index);
- this.myArrayList.remove(index);
- return o;
- }
-
-
- /**
- * Produce a JSONObject by combining a JSONArray of names with the values
- * of this JSONArray.
- * @param names A JSONArray containing a list of key strings. These will be
- * paired with the values.
- * @return A JSONObject, or null if there are no names or if this JSONArray
- * has no values.
- * @throws JSONException If any of the names are null.
- */
- public JSONObject toJSONObject(JSONArray names) throws JSONException {
- if (names == null || names.length() == 0 || this.length() == 0) {
- return null;
- }
- JSONObject jo = new JSONObject();
- for (int i = 0; i < names.length(); i += 1) {
- jo.put(names.getString(i), this.opt(i));
- }
- return jo;
- }
-
-
- /**
- * Make a JSON text of this JSONArray. For compactness, no
- * unnecessary whitespace is added. If it is not possible to produce a
- * syntactically correct JSON text then null will be returned instead. This
- * could occur if the array contains an invalid number.
- * <p>
- * Warning: This method assumes that the data structure is acyclical.
- *
- * @return a printable, displayable, transmittable
- * representation of the array.
- */
- public String toString() {
- try {
- return '[' + this.join(",") + ']';
- } catch (Exception e) {
- return null;
- }
- }
-
-
- /**
- * Make a prettyprinted JSON text of this JSONArray.
- * Warning: This method assumes that the data structure is acyclical.
- * @param indentFactor The number of spaces to add to each level of
- * indentation.
- * @return a printable, displayable, transmittable
- * representation of the object, beginning
- * with <code>[</code> <small>(left bracket)</small> and ending
- * with <code>]</code> <small>(right bracket)</small>.
- * @throws JSONException
- */
- public String toString(int indentFactor) throws JSONException {
- StringWriter sw = new StringWriter();
- synchronized (sw.getBuffer()) {
- return this.write(sw, indentFactor, 0).toString();
- }
- }
-
- /**
- * Write the contents of the JSONArray as JSON text to a writer. For
- * compactness, no whitespace is added.
- * <p>
- * Warning: This method assumes that the data structure is acyclical.
- *
- * @return The writer.
- * @throws JSONException
- */
- public Writer write(Writer writer) throws JSONException {
- return this.write(writer, 0, 0);
- }
-
- /**
- * Write the contents of the JSONArray as JSON text to a writer. For
- * compactness, no whitespace is added.
- * <p>
- * Warning: This method assumes that the data structure is acyclical.
- *
- * @param indentFactor
- * The number of spaces to add to each level of indentation.
- * @param indent
- * The indention of the top level.
- * @return The writer.
- * @throws JSONException
- */
- Writer write(Writer writer, int indentFactor, int indent)
- throws JSONException {
- try {
- boolean commanate = false;
- int length = this.length();
- writer.write('[');
-
- if (length == 1) {
- JSONObject.writeValue(writer, this.myArrayList.get(0),
- indentFactor, indent);
- } else if (length != 0) {
- final int newindent = indent + indentFactor;
-
- for (int i = 0; i < length; i += 1) {
- if (commanate) {
- writer.write(',');
- }
- if (indentFactor > 0) {
- writer.write('\n');
- }
- JSONObject.indent(writer, newindent);
- JSONObject.writeValue(writer, this.myArrayList.get(i),
- indentFactor, newindent);
- commanate = true;
- }
- if (indentFactor > 0) {
- writer.write('\n');
- }
- JSONObject.indent(writer, indent);
- }
- writer.write(']');
- return writer;
- } catch (IOException e) {
- throw new JSONException(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONException.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONException.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONException.java
deleted file mode 100644
index be88930..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.json;
-
-/**
- * The JSONException is thrown by the JSON.org classes when things are amiss.
- * @author JSON.org
- * @version 2010-12-24
- */
-public class JSONException extends Exception {
- private static final long serialVersionUID = 0;
- private Throwable cause;
-
- /**
- * Constructs a JSONException with an explanatory message.
- * @param message Detail about the reason for the exception.
- */
- public JSONException(String message) {
- super(message);
- }
-
- public JSONException(Throwable cause) {
- super(cause.getMessage());
- this.cause = cause;
- }
-
- public Throwable getCause() {
- return this.cause;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONML.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONML.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONML.java
deleted file mode 100644
index 2ddbffc..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/json/JSONML.java
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.json;
-
-import java.util.Iterator;
-
-
-/**
- * This provides static methods to convert an XML text into a JSONArray or
- * JSONObject, and to covert a JSONArray or JSONObject into an XML text using
- * the JsonML transform.
- *
- * @author JSON.org
- * @version 2012-03-28
- */
-public class JSONML {
-
- /**
- * Parse XML values and store them in a JSONArray.
- * @param x The XMLTokener containing the source string.
- * @param arrayForm true if array form, false if object form.
- * @param ja The JSONArray that is containing the current tag or null
- * if we are at the outermost level.
- * @return A JSONArray if the value is the outermost tag, otherwise null.
- * @throws JSONException
- */
- private static Object parse(
- XMLTokener x,
- boolean arrayForm,
- JSONArray ja
- ) throws JSONException {
- String attribute;
- char c;
- String closeTag = null;
- int i;
- JSONArray newja = null;
- JSONObject newjo = null;
- Object token;
- String tagName = null;
-
-// Test for and skip past these forms:
-// <!-- ... -->
-// <![ ... ]]>
-// <! ... >
-// <? ... ?>
-
- while (true) {
- if (!x.more()) {
- throw x.syntaxError("Bad XML");
- }
- token = x.nextContent();
- if (token == XML.LT) {
- token = x.nextToken();
- if (token instanceof Character) {
- if (token == XML.SLASH) {
-
-// Close tag </
-
- token = x.nextToken();
- if (!(token instanceof String)) {
- throw new JSONException(
- "Expected a closing name instead of '" +
- token + "'.");
- }
- if (x.nextToken() != XML.GT) {
- throw x.syntaxError("Misshaped close tag");
- }
- return token;
- } else if (token == XML.BANG) {
-
-// <!
-
- c = x.next();
- if (c == '-') {
- if (x.next() == '-') {
- x.skipPast("-->");
- } else {
- x.back();
- }
- } else if (c == '[') {
- token = x.nextToken();
- if (token.equals("CDATA") && x.next() == '[') {
- if (ja != null) {
- ja.put(x.nextCDATA());
- }
- } else {
- throw x.syntaxError("Expected 'CDATA['");
- }
- } else {
- i = 1;
- do {
- token = x.nextMeta();
- if (token == null) {
- throw x.syntaxError("Missing '>' after '<!'.");
- } else if (token == XML.LT) {
- i += 1;
- } else if (token == XML.GT) {
- i -= 1;
- }
- } while (i > 0);
- }
- } else if (token == XML.QUEST) {
-
-// <?
-
- x.skipPast("?>");
- } else {
- throw x.syntaxError("Misshaped tag");
- }
-
-// Open tag <
-
- } else {
- if (!(token instanceof String)) {
- throw x.syntaxError("Bad tagName '" + token + "'.");
- }
- tagName = (String)token;
- newja = new JSONArray();
- newjo = new JSONObject();
- if (arrayForm) {
- newja.put(tagName);
- if (ja != null) {
- ja.put(newja);
- }
- } else {
- newjo.put("tagName", tagName);
- if (ja != null) {
- ja.put(newjo);
- }
- }
- token = null;
- for (;;) {
- if (token == null) {
- token = x.nextToken();
- }
- if (token == null) {
- throw x.syntaxError("Misshaped tag");
- }
- if (!(token instanceof String)) {
- break;
- }
-
-// attribute = value
-
- attribute = (String)token;
- if (!arrayForm && ("tagName".equals(attribute) || "childNode".equals(attribute))) {
- throw x.syntaxError("Reserved attribute.");
- }
- token = x.nextToken();
- if (token == XML.EQ) {
- token = x.nextToken();
- if (!(token instanceof String)) {
- throw x.syntaxError("Missing value");
- }
- newjo.accumulate(attribute, XML.stringToValue((String)token));
- token = null;
- } else {
- newjo.accumulate(attribute, "");
- }
- }
- if (arrayForm && newjo.length() > 0) {
- newja.put(newjo);
- }
-
-// Empty tag <.../>
-
- if (token == XML.SLASH) {
- if (x.nextToken() != XML.GT) {
- throw x.syntaxError("Misshaped tag");
- }
- if (ja == null) {
- if (arrayForm) {
- return newja;
- } else {
- return newjo;
- }
- }
-
-// Content, between <...> and </...>
-
- } else {
- if (token != XML.GT) {
- throw x.syntaxError("Misshaped tag");
- }
- closeTag = (String)parse(x, arrayForm, newja);
- if (closeTag != null) {
- if (!closeTag.equals(tagName)) {
- throw x.syntaxError("Mismatched '" + tagName +
- "' and '" + closeTag + "'");
- }
- tagName = null;
- if (!arrayForm && newja.length() > 0) {
- newjo.put("childNodes", newja);
- }
- if (ja == null) {
- if (arrayForm) {
- return newja;
- } else {
- return newjo;
- }
- }
- }
- }
- }
- } else {
- if (ja != null) {
- ja.put(token instanceof String
- ? XML.stringToValue((String)token)
- : token);
- }
- }
- }
- }
-
-
- /**
- * Convert a well-formed (but not necessarily valid) XML string into a
- * JSONArray using the JsonML transform. Each XML tag is represented as
- * a JSONArray in which the first element is the tag name. If the tag has
- * attributes, then the second element will be JSONObject containing the
- * name/value pairs. If the tag contains children, then strings and
- * JSONArrays will represent the child tags.
- * Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
- * @param string The source string.
- * @return A JSONArray containing the structured data from the XML string.
- * @throws JSONException
- */
- public static JSONArray toJSONArray(String string) throws JSONException {
- return toJSONArray(new XMLTokener(string));
- }
-
-
- /**
- * Convert a well-formed (but not necessarily valid) XML string into a
- * JSONArray using the JsonML transform. Each XML tag is represented as
- * a JSONArray in which the first element is the tag name. If the tag has
- * attributes, then the second element will be JSONObject containing the
- * name/value pairs. If the tag contains children, then strings and
- * JSONArrays will represent the child content and tags.
- * Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
- * @param x An XMLTokener.
- * @return A JSONArray containing the structured data from the XML string.
- * @throws JSONException
- */
- public static JSONArray toJSONArray(XMLTokener x) throws JSONException {
- return (JSONArray)parse(x, true, null);
- }
-
-
- /**
- * Convert a well-formed (but not necessarily valid) XML string into a
- * JSONObject using the JsonML transform. Each XML tag is represented as
- * a JSONObject with a "tagName" property. If the tag has attributes, then
- * the attributes will be in the JSONObject as properties. If the tag
- * contains children, the object will have a "childNodes" property which
- * will be an array of strings and JsonML JSONObjects.
-
- * Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
- * @param x An XMLTokener of the XML source text.
- * @return A JSONObject containing the structured data from the XML string.
- * @throws JSONException
- */
- public static JSONObject toJSONObject(XMLTokener x) throws JSONException {
- return (JSONObject)parse(x, false, null);
- }
-
-
- /**
- * Convert a well-formed (but not necessarily valid) XML string into a
- * JSONObject using the JsonML transform. Each XML tag is represented as
- * a JSONObject with a "tagName" property. If the tag has attributes, then
- * the attributes will be in the JSONObject as properties. If the tag
- * contains children, the object will have a "childNodes" property which
- * will be an array of strings and JsonML JSONObjects.
-
- * Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
- * @param string The XML source text.
- * @return A JSONObject containing the structured data from the XML string.
- * @throws JSONException
- */
- public static JSONObject toJSONObject(String string) throws JSONException {
- return toJSONObject(new XMLTokener(string));
- }
-
-
- /**
- * Reverse the JSONML transformation, making an XML text from a JSONArray.
- * @param ja A JSONArray.
- * @return An XML string.
- * @throws JSONException
- */
- public static String toString(JSONArray ja) throws JSONException {
- int i;
- JSONObject jo;
- String key;
- Iterator keys;
- int length;
- Object object;
- StringBuffer sb = new StringBuffer();
- String tagName;
- String value;
-
-// Emit <tagName
-
- tagName = ja.getString(0);
- XML.noSpace(tagName);
- tagName = XML.escape(tagName);
- sb.append('<');
- sb.append(tagName);
-
- object = ja.opt(1);
- if (object instanceof JSONObject) {
- i = 2;
- jo = (JSONObject)object;
-
-// Emit the attributes
-
- keys = jo.keys();
- while (keys.hasNext()) {
- key = keys.next().toString();
- XML.noSpace(key);
- value = jo.optString(key);
- if (value != null) {
- sb.append(' ');
- sb.append(XML.escape(key));
- sb.append('=');
- sb.append('"');
- sb.append(XML.escape(value));
- sb.append('"');
- }
- }
- } else {
- i = 1;
- }
-
-//Emit content in body
-
- length = ja.length();
- if (i >= length) {
- sb.append('/');
- sb.append('>');
- } else {
- sb.append('>');
- do {
- object = ja.get(i);
- i += 1;
- if (object != null) {
- if (object instanceof String) {
- sb.append(XML.escape(object.toString()));
- } else if (object instanceof JSONObject) {
- sb.append(toString((JSONObject)object));
- } else if (object instanceof JSONArray) {
- sb.append(toString((JSONArray)object));
- }
- }
- } while (i < length);
- sb.append('<');
- sb.append('/');
- sb.append(tagName);
- sb.append('>');
- }
- return sb.toString();
- }
-
- /**
- * Reverse the JSONML transformation, making an XML text from a JSONObject.
- * The JSONObject must contain a "tagName" property. If it has children,
- * then it must have a "childNodes" property containing an array of objects.
- * The other properties are attributes with string values.
- * @param jo A JSONObject.
- * @return An XML string.
- * @throws JSONException
- */
- public static String toString(JSONObject jo) throws JSONException {
- StringBuffer sb = new StringBuffer();
- int i;
- JSONArray ja;
- String key;
- Iterator keys;
- int length;
- Object object;
- String tagName;
- String value;
-
-//Emit <tagName
-
- tagName = jo.optString("tagName");
- if (tagName == null) {
- return XML.escape(jo.toString());
- }
- XML.noSpace(tagName);
- tagName = XML.escape(tagName);
- sb.append('<');
- sb.append(tagName);
-
-//Emit the attributes
-
- keys = jo.keys();
- while (keys.hasNext()) {
- key = keys.next().toString();
- if (!"tagName".equals(key) && !"childNodes".equals(key)) {
- XML.noSpace(key);
- value = jo.optString(key);
- if (value != null) {
- sb.append(' ');
- sb.append(XML.escape(key));
- sb.append('=');
- sb.append('"');
- sb.append(XML.escape(value));
- sb.append('"');
- }
- }
- }
-
-//Emit content in body
-
- ja = jo.optJSONArray("childNodes");
- if (ja == null) {
- sb.append('/');
- sb.append('>');
- } else {
- sb.append('>');
- length = ja.length();
- for (i = 0; i < length; i += 1) {
- object = ja.get(i);
- if (object != null) {
- if (object instanceof String) {
- sb.append(XML.escape(object.toString()));
- } else if (object instanceof JSONObject) {
- sb.append(toString((JSONObject)object));
- } else if (object instanceof JSONArray) {
- sb.append(toString((JSONArray)object));
- } else {
- sb.append(object.toString());
- }
- }
- }
- sb.append('<');
- sb.append('/');
- sb.append(tagName);
- sb.append('>');
- }
- return sb.toString();
- }
-}
[16/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONObject.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONObject.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONObject.java
new file mode 100644
index 0000000..3fd3c38
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONObject.java
@@ -0,0 +1,1585 @@
+/*
+ *
+ * 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.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+/**
+ * A JSONObject is an unordered collection of name/value pairs. Its external
+ * form is a string wrapped in curly braces with colons between the names and
+ * values, and commas between the values and names. The internal form is an
+ * object having <code>get</code> and <code>opt</code> methods for accessing the
+ * values by name, and <code>put</code> methods for adding or replacing values
+ * by name. The values can be any of these types: <code>Boolean</code>,
+ * <code>JSONArray</code>, <code>JSONObject</code>, <code>Number</code>,
+ * <code>String</code>, or the <code>JSONObject.NULL</code> object. A JSONObject
+ * constructor can be used to convert an external form JSON text into an
+ * internal form whose values can be retrieved with the <code>get</code> and
+ * <code>opt</code> methods, or to convert values into a JSON text using the
+ * <code>put</code> and <code>toString</code> methods. A <code>get</code> method
+ * returns a value if one can be found, and throws an exception if one cannot be
+ * found. An <code>opt</code> method returns a default value instead of throwing
+ * an exception, and so is useful for obtaining optional values.
+ * <p>
+ * The generic <code>get()</code> and <code>opt()</code> methods return an
+ * object, which you can cast or query for type. There are also typed
+ * <code>get</code> and <code>opt</code> methods that do type checking and type
+ * coercion for you. The opt methods differ from the get methods in that they do
+ * not throw. Instead, they return a specified value, such as null.
+ * <p>
+ * The <code>put</code> methods add or replace values in an object. For example,
+ *
+ * <pre>
+ * myString = new JSONObject().put("JSON", "Hello, World!").toString();
+ * </pre>
+ *
+ * produces the string <code>{"JSON": "Hello, World"}</code>.
+ * <p>
+ * The texts produced by the <code>toString</code> methods strictly conform to
+ * the JSON syntax rules. The constructors are more forgiving in the texts they
+ * will accept:
+ * <ul>
+ * <li>An extra <code>,</code> <small>(comma)</small> may appear just
+ * before the closing brace.</li>
+ * <li>Strings may be quoted with <code>'</code> <small>(single
+ * quote)</small>.</li>
+ * <li>Strings do not need to be quoted at all if they do not begin with a quote
+ * or single quote, and if they do not contain leading or trailing spaces, and
+ * if they do not contain any of these characters:
+ * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers and
+ * if they are not the reserved words <code>true</code>, <code>false</code>, or
+ * <code>null</code>.</li>
+ * <li>Keys can be followed by <code>=</code> or <code>=></code> as well as by
+ * <code>:</code>.</li>
+ * <li>Values can be followed by <code>;</code> <small>(semicolon)</small> as
+ * well as by <code>,</code> <small>(comma)</small>.</li>
+ * </ul>
+ *
+ * @author JSON.org
+ * @version 2012-07-02
+ */
+public class JSONObject {
+
+ /**
+ * JSONObject.NULL is equivalent to the value that JavaScript calls null,
+ * whilst Java's null is equivalent to the value that JavaScript calls
+ * undefined.
+ */
+ private static final class Null {
+
+ /**
+ * There is only intended to be a single instance of the NULL object,
+ * so the clone method returns itself.
+ * @return NULL.
+ */
+ protected final Object clone() {
+ return this;
+ }
+
+ /**
+ * A Null object is equal to the null value and to itself.
+ * @param object An object to test for nullness.
+ * @return true if the object parameter is the JSONObject.NULL object
+ * or null.
+ */
+ public boolean equals(Object object) {
+ return object == null || object == this;
+ }
+
+ /**
+ * Get the "null" string value.
+ * @return The string "null".
+ */
+ public String toString() {
+ return "null";
+ }
+ }
+
+
+ /**
+ * The map where the JSONObject's properties are kept.
+ */
+ private final Map map;
+
+
+ /**
+ * It is sometimes more convenient and less ambiguous to have a
+ * <code>NULL</code> object than to use Java's <code>null</code> value.
+ * <code>JSONObject.NULL.equals(null)</code> returns <code>true</code>.
+ * <code>JSONObject.NULL.toString()</code> returns <code>"null"</code>.
+ */
+ public static final Object NULL = new Null();
+
+
+ /**
+ * Construct an empty JSONObject.
+ */
+ public JSONObject() {
+ this.map = new HashMap();
+ }
+
+
+ /**
+ * Construct a JSONObject from a subset of another JSONObject.
+ * An array of strings is used to identify the keys that should be copied.
+ * Missing keys are ignored.
+ * @param jo A JSONObject.
+ * @param names An array of strings.
+ */
+ public JSONObject(JSONObject jo, String[] names) {
+ this();
+ for (int i = 0; i < names.length; i += 1) {
+ try {
+ this.putOnce(names[i], jo.opt(names[i]));
+ } catch (Exception ignore) {
+ }
+ }
+ }
+
+
+ /**
+ * Construct a JSONObject from a JSONTokener.
+ * @param x A JSONTokener object containing the source string.
+ * @throws JSONException If there is a syntax error in the source string
+ * or a duplicated key.
+ */
+ public JSONObject(JSONTokener x) throws JSONException {
+ this();
+ char c;
+ String key;
+
+ if (x.nextClean() != '{') {
+ throw x.syntaxError("A JSONObject text must begin with '{'");
+ }
+ for (;;) {
+ c = x.nextClean();
+ switch (c) {
+ case 0:
+ throw x.syntaxError("A JSONObject text must end with '}'");
+ case '}':
+ return;
+ default:
+ x.back();
+ key = x.nextValue().toString();
+ }
+
+// The key is followed by ':'. We will also tolerate '=' or '=>'.
+
+ c = x.nextClean();
+ if (c == '=') {
+ if (x.next() != '>') {
+ x.back();
+ }
+ } else if (c != ':') {
+ throw x.syntaxError("Expected a ':' after a key");
+ }
+ this.putOnce(key, x.nextValue());
+
+// Pairs are separated by ','. We will also tolerate ';'.
+
+ switch (x.nextClean()) {
+ case ';':
+ case ',':
+ if (x.nextClean() == '}') {
+ return;
+ }
+ x.back();
+ break;
+ case '}':
+ return;
+ default:
+ throw x.syntaxError("Expected a ',' or '}'");
+ }
+ }
+ }
+
+
+ /**
+ * Construct a JSONObject from a Map.
+ *
+ * @param map A map object that can be used to initialize the contents of
+ * the JSONObject.
+ */
+ public JSONObject(Map map) {
+ this.map = new HashMap();
+ if (map != null) {
+ Iterator i = map.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry e = (Map.Entry)i.next();
+ Object value = e.getValue();
+ if (value != null) {
+ this.map.put(e.getKey(), wrap(value));
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Construct a JSONObject from an Object using bean getters.
+ * It reflects on all of the public methods of the object.
+ * For each of the methods with no parameters and a name starting
+ * with <code>"get"</code> or <code>"is"</code> followed by an uppercase letter,
+ * the method is invoked, and a key and the value returned from the getter method
+ * are put into the new JSONObject.
+ *
+ * The key is formed by removing the <code>"get"</code> or <code>"is"</code> prefix.
+ * If the second remaining character is not upper case, then the first
+ * character is converted to lower case.
+ *
+ * For example, if an object has a method named <code>"getName"</code>, and
+ * if the result of calling <code>object.getName()</code> is <code>"Larry Fine"</code>,
+ * then the JSONObject will contain <code>"name": "Larry Fine"</code>.
+ *
+ * @param bean An object that has getter methods that should be used
+ * to make a JSONObject.
+ */
+ public JSONObject(Object bean) {
+ this();
+ this.populateMap(bean);
+ }
+
+
+ /**
+ * Construct a JSONObject from an Object, using reflection to find the
+ * public members. The resulting JSONObject's keys will be the strings
+ * from the names array, and the values will be the field values associated
+ * with those keys in the object. If a key is not found or not visible,
+ * then it will not be copied into the new JSONObject.
+ * @param object An object that has fields that should be used to make a
+ * JSONObject.
+ * @param names An array of strings, the names of the fields to be obtained
+ * from the object.
+ */
+ public JSONObject(Object object, String names[]) {
+ this();
+ Class c = object.getClass();
+ for (int i = 0; i < names.length; i += 1) {
+ String name = names[i];
+ try {
+ this.putOpt(name, c.getField(name).get(object));
+ } catch (Exception ignore) {
+ }
+ }
+ }
+
+
+ /**
+ * Construct a JSONObject from a source JSON text string.
+ * This is the most commonly used JSONObject constructor.
+ * @param source A string beginning
+ * with <code>{</code> <small>(left brace)</small> and ending
+ * with <code>}</code> <small>(right brace)</small>.
+ * @exception JSONException If there is a syntax error in the source
+ * string or a duplicated key.
+ */
+ public JSONObject(String source) throws JSONException {
+ this(new JSONTokener(source));
+ }
+
+
+ /**
+ * Construct a JSONObject from a ResourceBundle.
+ * @param baseName The ResourceBundle base name.
+ * @param locale The Locale to load the ResourceBundle for.
+ * @throws JSONException If any JSONExceptions are detected.
+ */
+ public JSONObject(String baseName, Locale locale) throws JSONException {
+ this();
+ ResourceBundle bundle = ResourceBundle.getBundle(baseName, locale,
+ Thread.currentThread().getContextClassLoader());
+
+// Iterate through the keys in the bundle.
+
+ Enumeration keys = bundle.getKeys();
+ while (keys.hasMoreElements()) {
+ Object key = keys.nextElement();
+ if (key instanceof String) {
+
+// Go through the path, ensuring that there is a nested JSONObject for each
+// segment except the last. Add the value using the last segment's name into
+// the deepest nested JSONObject.
+
+ String[] path = ((String)key).split("\\.");
+ int last = path.length - 1;
+ JSONObject target = this;
+ for (int i = 0; i < last; i += 1) {
+ String segment = path[i];
+ JSONObject nextTarget = target.optJSONObject(segment);
+ if (nextTarget == null) {
+ nextTarget = new JSONObject();
+ target.put(segment, nextTarget);
+ }
+ target = nextTarget;
+ }
+ target.put(path[last], bundle.getString((String)key));
+ }
+ }
+ }
+
+
+ /**
+ * Accumulate values under a key. It is similar to the put method except
+ * that if there is already an object stored under the key then a
+ * JSONArray is stored under the key to hold all of the accumulated values.
+ * If there is already a JSONArray, then the new value is appended to it.
+ * In contrast, the put method replaces the previous value.
+ *
+ * If only one value is accumulated that is not a JSONArray, then the
+ * result will be the same as using put. But if multiple values are
+ * accumulated, then the result will be like append.
+ * @param key A key string.
+ * @param value An object to be accumulated under the key.
+ * @return this.
+ * @throws JSONException If the value is an invalid number
+ * or if the key is null.
+ */
+ public JSONObject accumulate(
+ String key,
+ Object value
+ ) throws JSONException {
+ testValidity(value);
+ Object object = this.opt(key);
+ if (object == null) {
+ this.put(key, value instanceof JSONArray
+ ? new JSONArray().put(value)
+ : value);
+ } else if (object instanceof JSONArray) {
+ ((JSONArray)object).put(value);
+ } else {
+ this.put(key, new JSONArray().put(object).put(value));
+ }
+ return this;
+ }
+
+
+ /**
+ * Append values to the array under a key. If the key does not exist in the
+ * JSONObject, then the key is put in the JSONObject with its value being a
+ * JSONArray containing the value parameter. If the key was already
+ * associated with a JSONArray, then the value parameter is appended to it.
+ * @param key A key string.
+ * @param value An object to be accumulated under the key.
+ * @return this.
+ * @throws JSONException If the key is null or if the current value
+ * associated with the key is not a JSONArray.
+ */
+ public JSONObject append(String key, Object value) throws JSONException {
+ testValidity(value);
+ Object object = this.opt(key);
+ if (object == null) {
+ this.put(key, new JSONArray().put(value));
+ } else if (object instanceof JSONArray) {
+ this.put(key, ((JSONArray)object).put(value));
+ } else {
+ throw new JSONException("JSONObject[" + key +
+ "] is not a JSONArray.");
+ }
+ return this;
+ }
+
+
+ /**
+ * Produce a string from a double. The string "null" will be returned if
+ * the number is not finite.
+ * @param d A double.
+ * @return A String.
+ */
+ public static String doubleToString(double d) {
+ if (Double.isInfinite(d) || Double.isNaN(d)) {
+ return "null";
+ }
+
+// Shave off trailing zeros and decimal point, if possible.
+
+ String string = Double.toString(d);
+ if (string.indexOf('.') > 0 && string.indexOf('e') < 0 &&
+ string.indexOf('E') < 0) {
+ while (string.endsWith("0")) {
+ string = string.substring(0, string.length() - 1);
+ }
+ if (string.endsWith(".")) {
+ string = string.substring(0, string.length() - 1);
+ }
+ }
+ return string;
+ }
+
+
+ /**
+ * Get the value object associated with a key.
+ *
+ * @param key A key string.
+ * @return The object associated with the key.
+ * @throws JSONException if the key is not found.
+ */
+ public Object get(String key) throws JSONException {
+ if (key == null) {
+ throw new JSONException("Null key.");
+ }
+ Object object = this.opt(key);
+ if (object == null) {
+ throw new JSONException("JSONObject[" + quote(key) +
+ "] not found.");
+ }
+ return object;
+ }
+
+
+ /**
+ * Get the boolean value associated with a key.
+ *
+ * @param key A key string.
+ * @return The truth.
+ * @throws JSONException
+ * if the value is not a Boolean or the String "true" or "false".
+ */
+ public boolean getBoolean(String key) throws JSONException {
+ Object object = this.get(key);
+ if (object.equals(Boolean.FALSE) ||
+ (object instanceof String &&
+ ((String)object).equalsIgnoreCase("false"))) {
+ return false;
+ } else if (object.equals(Boolean.TRUE) ||
+ (object instanceof String &&
+ ((String)object).equalsIgnoreCase("true"))) {
+ return true;
+ }
+ throw new JSONException("JSONObject[" + quote(key) +
+ "] is not a Boolean.");
+ }
+
+
+ /**
+ * Get the double value associated with a key.
+ * @param key A key string.
+ * @return The numeric value.
+ * @throws JSONException if the key is not found or
+ * if the value is not a Number object and cannot be converted to a number.
+ */
+ public double getDouble(String key) throws JSONException {
+ Object object = this.get(key);
+ try {
+ return object instanceof Number
+ ? ((Number)object).doubleValue()
+ : Double.parseDouble((String)object);
+ } catch (Exception e) {
+ throw new JSONException("JSONObject[" + quote(key) +
+ "] is not a number.");
+ }
+ }
+
+
+ /**
+ * Get the int value associated with a key.
+ *
+ * @param key A key string.
+ * @return The integer value.
+ * @throws JSONException if the key is not found or if the value cannot
+ * be converted to an integer.
+ */
+ public int getInt(String key) throws JSONException {
+ Object object = this.get(key);
+ try {
+ return object instanceof Number
+ ? ((Number)object).intValue()
+ : Integer.parseInt((String)object);
+ } catch (Exception e) {
+ throw new JSONException("JSONObject[" + quote(key) +
+ "] is not an int.");
+ }
+ }
+
+
+ /**
+ * Get the JSONArray value associated with a key.
+ *
+ * @param key A key string.
+ * @return A JSONArray which is the value.
+ * @throws JSONException if the key is not found or
+ * if the value is not a JSONArray.
+ */
+ public JSONArray getJSONArray(String key) throws JSONException {
+ Object object = this.get(key);
+ if (object instanceof JSONArray) {
+ return (JSONArray)object;
+ }
+ throw new JSONException("JSONObject[" + quote(key) +
+ "] is not a JSONArray.");
+ }
+
+
+ /**
+ * Get the JSONObject value associated with a key.
+ *
+ * @param key A key string.
+ * @return A JSONObject which is the value.
+ * @throws JSONException if the key is not found or
+ * if the value is not a JSONObject.
+ */
+ public JSONObject getJSONObject(String key) throws JSONException {
+ Object object = this.get(key);
+ if (object instanceof JSONObject) {
+ return (JSONObject)object;
+ }
+ throw new JSONException("JSONObject[" + quote(key) +
+ "] is not a JSONObject.");
+ }
+
+
+ /**
+ * Get the long value associated with a key.
+ *
+ * @param key A key string.
+ * @return The long value.
+ * @throws JSONException if the key is not found or if the value cannot
+ * be converted to a long.
+ */
+ public long getLong(String key) throws JSONException {
+ Object object = this.get(key);
+ try {
+ return object instanceof Number
+ ? ((Number)object).longValue()
+ : Long.parseLong((String)object);
+ } catch (Exception e) {
+ throw new JSONException("JSONObject[" + quote(key) +
+ "] is not a long.");
+ }
+ }
+
+
+ /**
+ * Get an array of field names from a JSONObject.
+ *
+ * @return An array of field names, or null if there are no names.
+ */
+ public static String[] getNames(JSONObject jo) {
+ int length = jo.length();
+ if (length == 0) {
+ return null;
+ }
+ Iterator iterator = jo.keys();
+ String[] names = new String[length];
+ int i = 0;
+ while (iterator.hasNext()) {
+ names[i] = (String)iterator.next();
+ i += 1;
+ }
+ return names;
+ }
+
+
+ /**
+ * Get an array of field names from an Object.
+ *
+ * @return An array of field names, or null if there are no names.
+ */
+ public static String[] getNames(Object object) {
+ if (object == null) {
+ return null;
+ }
+ Class klass = object.getClass();
+ Field[] fields = klass.getFields();
+ int length = fields.length;
+ if (length == 0) {
+ return null;
+ }
+ String[] names = new String[length];
+ for (int i = 0; i < length; i += 1) {
+ names[i] = fields[i].getName();
+ }
+ return names;
+ }
+
+
+ /**
+ * Get the string associated with a key.
+ *
+ * @param key A key string.
+ * @return A string which is the value.
+ * @throws JSONException if there is no string value for the key.
+ */
+ public String getString(String key) throws JSONException {
+ Object object = this.get(key);
+ if (object instanceof String) {
+ return (String)object;
+ }
+ throw new JSONException("JSONObject[" + quote(key) +
+ "] not a string.");
+ }
+
+
+ /**
+ * Determine if the JSONObject contains a specific key.
+ * @param key A key string.
+ * @return true if the key exists in the JSONObject.
+ */
+ public boolean has(String key) {
+ return this.map.containsKey(key);
+ }
+
+
+ /**
+ * Increment a property of a JSONObject. If there is no such property,
+ * create one with a value of 1. If there is such a property, and if
+ * it is an Integer, Long, Double, or Float, then add one to it.
+ * @param key A key string.
+ * @return this.
+ * @throws JSONException If there is already a property with this name
+ * that is not an Integer, Long, Double, or Float.
+ */
+ public JSONObject increment(String key) throws JSONException {
+ Object value = this.opt(key);
+ if (value == null) {
+ this.put(key, 1);
+ } else if (value instanceof Integer) {
+ this.put(key, ((Integer)value).intValue() + 1);
+ } else if (value instanceof Long) {
+ this.put(key, ((Long)value).longValue() + 1);
+ } else if (value instanceof Double) {
+ this.put(key, ((Double)value).doubleValue() + 1);
+ } else if (value instanceof Float) {
+ this.put(key, ((Float)value).floatValue() + 1);
+ } else {
+ throw new JSONException("Unable to increment [" + quote(key) + "].");
+ }
+ return this;
+ }
+
+
+ /**
+ * Determine if the value associated with the key is null or if there is
+ * no value.
+ * @param key A key string.
+ * @return true if there is no value associated with the key or if
+ * the value is the JSONObject.NULL object.
+ */
+ public boolean isNull(String key) {
+ return JSONObject.NULL.equals(this.opt(key));
+ }
+
+
+ /**
+ * Get an enumeration of the keys of the JSONObject.
+ *
+ * @return An iterator of the keys.
+ */
+ public Iterator keys() {
+ return this.map.keySet().iterator();
+ }
+
+
+ /**
+ * Get the number of keys stored in the JSONObject.
+ *
+ * @return The number of keys in the JSONObject.
+ */
+ public int length() {
+ return this.map.size();
+ }
+
+
+ /**
+ * Produce a JSONArray containing the names of the elements of this
+ * JSONObject.
+ * @return A JSONArray containing the key strings, or null if the JSONObject
+ * is empty.
+ */
+ public JSONArray names() {
+ JSONArray ja = new JSONArray();
+ Iterator keys = this.keys();
+ while (keys.hasNext()) {
+ ja.put(keys.next());
+ }
+ return ja.length() == 0 ? null : ja;
+ }
+
+ /**
+ * Produce a string from a Number.
+ * @param number A Number
+ * @return A String.
+ * @throws JSONException If n is a non-finite number.
+ */
+ public static String numberToString(Number number)
+ throws JSONException {
+ if (number == null) {
+ throw new JSONException("Null pointer");
+ }
+ testValidity(number);
+
+// Shave off trailing zeros and decimal point, if possible.
+
+ String string = number.toString();
+ if (string.indexOf('.') > 0 && string.indexOf('e') < 0 &&
+ string.indexOf('E') < 0) {
+ while (string.endsWith("0")) {
+ string = string.substring(0, string.length() - 1);
+ }
+ if (string.endsWith(".")) {
+ string = string.substring(0, string.length() - 1);
+ }
+ }
+ return string;
+ }
+
+
+ /**
+ * Get an optional value associated with a key.
+ * @param key A key string.
+ * @return An object which is the value, or null if there is no value.
+ */
+ public Object opt(String key) {
+ return key == null ? null : this.map.get(key);
+ }
+
+
+ /**
+ * Get an optional boolean associated with a key.
+ * It returns false if there is no such key, or if the value is not
+ * Boolean.TRUE or the String "true".
+ *
+ * @param key A key string.
+ * @return The truth.
+ */
+ public boolean optBoolean(String key) {
+ return this.optBoolean(key, false);
+ }
+
+
+ /**
+ * Get an optional boolean associated with a key.
+ * It returns the defaultValue if there is no such key, or if it is not
+ * a Boolean or the String "true" or "false" (case insensitive).
+ *
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return The truth.
+ */
+ public boolean optBoolean(String key, boolean defaultValue) {
+ try {
+ return this.getBoolean(key);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get an optional double associated with a key,
+ * or NaN if there is no such key or if its value is not a number.
+ * If the value is a string, an attempt will be made to evaluate it as
+ * a number.
+ *
+ * @param key A string which is the key.
+ * @return An object which is the value.
+ */
+ public double optDouble(String key) {
+ return this.optDouble(key, Double.NaN);
+ }
+
+
+ /**
+ * Get an optional double associated with a key, or the
+ * defaultValue if there is no such key or if its value is not a number.
+ * If the value is a string, an attempt will be made to evaluate it as
+ * a number.
+ *
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return An object which is the value.
+ */
+ public double optDouble(String key, double defaultValue) {
+ try {
+ return this.getDouble(key);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get an optional int value associated with a key,
+ * or zero if there is no such key or if the value is not a number.
+ * If the value is a string, an attempt will be made to evaluate it as
+ * a number.
+ *
+ * @param key A key string.
+ * @return An object which is the value.
+ */
+ public int optInt(String key) {
+ return this.optInt(key, 0);
+ }
+
+
+ /**
+ * Get an optional int value associated with a key,
+ * or the default if there is no such key or if the value is not a number.
+ * If the value is a string, an attempt will be made to evaluate it as
+ * a number.
+ *
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return An object which is the value.
+ */
+ public int optInt(String key, int defaultValue) {
+ try {
+ return this.getInt(key);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get an optional JSONArray associated with a key.
+ * It returns null if there is no such key, or if its value is not a
+ * JSONArray.
+ *
+ * @param key A key string.
+ * @return A JSONArray which is the value.
+ */
+ public JSONArray optJSONArray(String key) {
+ Object o = this.opt(key);
+ return o instanceof JSONArray ? (JSONArray)o : null;
+ }
+
+
+ /**
+ * Get an optional JSONObject associated with a key.
+ * It returns null if there is no such key, or if its value is not a
+ * JSONObject.
+ *
+ * @param key A key string.
+ * @return A JSONObject which is the value.
+ */
+ public JSONObject optJSONObject(String key) {
+ Object object = this.opt(key);
+ return object instanceof JSONObject ? (JSONObject)object : null;
+ }
+
+
+ /**
+ * Get an optional long value associated with a key,
+ * or zero if there is no such key or if the value is not a number.
+ * If the value is a string, an attempt will be made to evaluate it as
+ * a number.
+ *
+ * @param key A key string.
+ * @return An object which is the value.
+ */
+ public long optLong(String key) {
+ return this.optLong(key, 0);
+ }
+
+
+ /**
+ * Get an optional long value associated with a key,
+ * or the default if there is no such key or if the value is not a number.
+ * If the value is a string, an attempt will be made to evaluate it as
+ * a number.
+ *
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return An object which is the value.
+ */
+ public long optLong(String key, long defaultValue) {
+ try {
+ return this.getLong(key);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get an optional string associated with a key.
+ * It returns an empty string if there is no such key. If the value is not
+ * a string and is not null, then it is converted to a string.
+ *
+ * @param key A key string.
+ * @return A string which is the value.
+ */
+ public String optString(String key) {
+ return this.optString(key, "");
+ }
+
+
+ /**
+ * Get an optional string associated with a key.
+ * It returns the defaultValue if there is no such key.
+ *
+ * @param key A key string.
+ * @param defaultValue The default.
+ * @return A string which is the value.
+ */
+ public String optString(String key, String defaultValue) {
+ Object object = this.opt(key);
+ return NULL.equals(object) ? defaultValue : object.toString();
+ }
+
+
+ private void populateMap(Object bean) {
+ Class klass = bean.getClass();
+
+// If klass is a System class then set includeSuperClass to false.
+
+ boolean includeSuperClass = klass.getClassLoader() != null;
+
+ Method[] methods = includeSuperClass
+ ? klass.getMethods()
+ : klass.getDeclaredMethods();
+ for (int i = 0; i < methods.length; i += 1) {
+ try {
+ Method method = methods[i];
+ if (Modifier.isPublic(method.getModifiers())) {
+ String name = method.getName();
+ String key = "";
+ if (name.startsWith("get")) {
+ if ("getClass".equals(name) ||
+ "getDeclaringClass".equals(name)) {
+ key = "";
+ } else {
+ key = name.substring(3);
+ }
+ } else if (name.startsWith("is")) {
+ key = name.substring(2);
+ }
+ if (key.length() > 0 &&
+ Character.isUpperCase(key.charAt(0)) &&
+ method.getParameterTypes().length == 0) {
+ if (key.length() == 1) {
+ key = key.toLowerCase();
+ } else if (!Character.isUpperCase(key.charAt(1))) {
+ key = key.substring(0, 1).toLowerCase() +
+ key.substring(1);
+ }
+
+ Object result = method.invoke(bean, (Object[])null);
+ if (result != null) {
+ this.map.put(key, wrap(result));
+ }
+ }
+ }
+ } catch (Exception ignore) {
+ }
+ }
+ }
+
+
+ /**
+ * Put a key/boolean pair in the JSONObject.
+ *
+ * @param key A key string.
+ * @param value A boolean which is the value.
+ * @return this.
+ * @throws JSONException If the key is null.
+ */
+ public JSONObject put(String key, boolean value) throws JSONException {
+ this.put(key, value ? Boolean.TRUE : Boolean.FALSE);
+ return this;
+ }
+
+
+ /**
+ * Put a key/value pair in the JSONObject, where the value will be a
+ * JSONArray which is produced from a Collection.
+ * @param key A key string.
+ * @param value A Collection value.
+ * @return this.
+ * @throws JSONException
+ */
+ public JSONObject put(String key, Collection value) throws JSONException {
+ this.put(key, new JSONArray(value));
+ return this;
+ }
+
+
+ /**
+ * Put a key/double pair in the JSONObject.
+ *
+ * @param key A key string.
+ * @param value A double which is the value.
+ * @return this.
+ * @throws JSONException If the key is null or if the number is invalid.
+ */
+ public JSONObject put(String key, double value) throws JSONException {
+ this.put(key, new Double(value));
+ return this;
+ }
+
+
+ /**
+ * Put a key/int pair in the JSONObject.
+ *
+ * @param key A key string.
+ * @param value An int which is the value.
+ * @return this.
+ * @throws JSONException If the key is null.
+ */
+ public JSONObject put(String key, int value) throws JSONException {
+ this.put(key, new Integer(value));
+ return this;
+ }
+
+
+ /**
+ * Put a key/long pair in the JSONObject.
+ *
+ * @param key A key string.
+ * @param value A long which is the value.
+ * @return this.
+ * @throws JSONException If the key is null.
+ */
+ public JSONObject put(String key, long value) throws JSONException {
+ this.put(key, new Long(value));
+ return this;
+ }
+
+
+ /**
+ * Put a key/value pair in the JSONObject, where the value will be a
+ * JSONObject which is produced from a Map.
+ * @param key A key string.
+ * @param value A Map value.
+ * @return this.
+ * @throws JSONException
+ */
+ public JSONObject put(String key, Map value) throws JSONException {
+ this.put(key, new JSONObject(value));
+ return this;
+ }
+
+
+ /**
+ * Put a key/value pair in the JSONObject. If the value is null,
+ * then the key will be removed from the JSONObject if it is present.
+ * @param key A key string.
+ * @param value An object which is the value. It should be of one of these
+ * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
+ * or the JSONObject.NULL object.
+ * @return this.
+ * @throws JSONException If the value is non-finite number
+ * or if the key is null.
+ */
+ public JSONObject put(String key, Object value) throws JSONException {
+ if (key == null) {
+ throw new JSONException("Null key.");
+ }
+ if (value != null) {
+ testValidity(value);
+ this.map.put(key, value);
+ } else {
+ this.remove(key);
+ }
+ return this;
+ }
+
+
+ /**
+ * Put a key/value pair in the JSONObject, but only if the key and the
+ * value are both non-null, and only if there is not already a member
+ * with that name.
+ * @param key
+ * @param value
+ * @return his.
+ * @throws JSONException if the key is a duplicate
+ */
+ public JSONObject putOnce(String key, Object value) throws JSONException {
+ if (key != null && value != null) {
+ if (this.opt(key) != null) {
+ throw new JSONException("Duplicate key \"" + key + "\"");
+ }
+ this.put(key, value);
+ }
+ return this;
+ }
+
+
+ /**
+ * Put a key/value pair in the JSONObject, but only if the
+ * key and the value are both non-null.
+ * @param key A key string.
+ * @param value An object which is the value. It should be of one of these
+ * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
+ * or the JSONObject.NULL object.
+ * @return this.
+ * @throws JSONException If the value is a non-finite number.
+ */
+ public JSONObject putOpt(String key, Object value) throws JSONException {
+ if (key != null && value != null) {
+ this.put(key, value);
+ }
+ return this;
+ }
+
+
+ /**
+ * Produce a string in double quotes with backslash sequences in all the
+ * right places. A backslash will be inserted within </, producing <\/,
+ * allowing JSON text to be delivered in HTML. In JSON text, a string
+ * cannot contain a control character or an unescaped quote or backslash.
+ * @param string A String
+ * @return A String correctly formatted for insertion in a JSON text.
+ */
+ public static String quote(String string) {
+ StringWriter sw = new StringWriter();
+ synchronized (sw.getBuffer()) {
+ try {
+ return quote(string, sw).toString();
+ } catch (IOException ignored) {
+ // will never happen - we are writing to a string writer
+ return "";
+ }
+ }
+ }
+
+ public static Writer quote(String string, Writer w) throws IOException {
+ if (string == null || string.length() == 0) {
+ w.write("\"\"");
+ return w;
+ }
+
+ char b;
+ char c = 0;
+ String hhhh;
+ int i;
+ int len = string.length();
+
+ w.write('"');
+ for (i = 0; i < len; i += 1) {
+ b = c;
+ c = string.charAt(i);
+ switch (c) {
+ case '\\':
+ case '"':
+ w.write('\\');
+ w.write(c);
+ break;
+ case '/':
+ if (b == '<') {
+ w.write('\\');
+ }
+ w.write(c);
+ break;
+ case '\b':
+ w.write("\\b");
+ break;
+ case '\t':
+ w.write("\\t");
+ break;
+ case '\n':
+ w.write("\\n");
+ break;
+ case '\f':
+ w.write("\\f");
+ break;
+ case '\r':
+ w.write("\\r");
+ break;
+ default:
+ if (c < ' ' || (c >= '\u0080' && c < '\u00a0')
+ || (c >= '\u2000' && c < '\u2100')) {
+ hhhh = "000" + Integer.toHexString(c);
+ w.write("\\u" + hhhh.substring(hhhh.length() - 4));
+ } else {
+ w.write(c);
+ }
+ }
+ }
+ w.write('"');
+ return w;
+ }
+
+ /**
+ * Remove a name and its value, if present.
+ * @param key The name to be removed.
+ * @return The value that was associated with the name,
+ * or null if there was no value.
+ */
+ public Object remove(String key) {
+ return this.map.remove(key);
+ }
+
+ /**
+ * Try to convert a string into a number, boolean, or null. If the string
+ * can't be converted, return the string.
+ * @param string A String.
+ * @return A simple JSON value.
+ */
+ public static Object stringToValue(String string) {
+ Double d;
+ if (string.equals("")) {
+ return string;
+ }
+ if (string.equalsIgnoreCase("true")) {
+ return Boolean.TRUE;
+ }
+ if (string.equalsIgnoreCase("false")) {
+ return Boolean.FALSE;
+ }
+ if (string.equalsIgnoreCase("null")) {
+ return JSONObject.NULL;
+ }
+
+ /*
+ * If it might be a number, try converting it.
+ * If a number cannot be produced, then the value will just
+ * be a string. Note that the plus and implied string
+ * conventions are non-standard. A JSON parser may accept
+ * non-JSON forms as long as it accepts all correct JSON forms.
+ */
+
+ char b = string.charAt(0);
+ if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') {
+ try {
+ if (string.indexOf('.') > -1 ||
+ string.indexOf('e') > -1 || string.indexOf('E') > -1) {
+ d = Double.valueOf(string);
+ if (!d.isInfinite() && !d.isNaN()) {
+ return d;
+ }
+ } else {
+ Long myLong = new Long(string);
+ if (myLong.longValue() == myLong.intValue()) {
+ return new Integer(myLong.intValue());
+ } else {
+ return myLong;
+ }
+ }
+ } catch (Exception ignore) {
+ }
+ }
+ return string;
+ }
+
+
+ /**
+ * Throw an exception if the object is a NaN or infinite number.
+ * @param o The object to test.
+ * @throws JSONException If o is a non-finite number.
+ */
+ public static void testValidity(Object o) throws JSONException {
+ if (o != null) {
+ if (o instanceof Double) {
+ if (((Double)o).isInfinite() || ((Double)o).isNaN()) {
+ throw new JSONException(
+ "JSON does not allow non-finite numbers.");
+ }
+ } else if (o instanceof Float) {
+ if (((Float)o).isInfinite() || ((Float)o).isNaN()) {
+ throw new JSONException(
+ "JSON does not allow non-finite numbers.");
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Produce a JSONArray containing the values of the members of this
+ * JSONObject.
+ * @param names A JSONArray containing a list of key strings. This
+ * determines the sequence of the values in the result.
+ * @return A JSONArray of values.
+ * @throws JSONException If any of the values are non-finite numbers.
+ */
+ public JSONArray toJSONArray(JSONArray names) throws JSONException {
+ if (names == null || names.length() == 0) {
+ return null;
+ }
+ JSONArray ja = new JSONArray();
+ for (int i = 0; i < names.length(); i += 1) {
+ ja.put(this.opt(names.getString(i)));
+ }
+ return ja;
+ }
+
+ /**
+ * Make a JSON text of this JSONObject. For compactness, no whitespace
+ * is added. If this would not result in a syntactically correct JSON text,
+ * then null will be returned instead.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ *
+ * @return a printable, displayable, portable, transmittable
+ * representation of the object, beginning
+ * with <code>{</code> <small>(left brace)</small> and ending
+ * with <code>}</code> <small>(right brace)</small>.
+ */
+ public String toString() {
+ try {
+ return this.toString(0);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+
+ /**
+ * Make a prettyprinted JSON text of this JSONObject.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ * @param indentFactor The number of spaces to add to each level of
+ * indentation.
+ * @return a printable, displayable, portable, transmittable
+ * representation of the object, beginning
+ * with <code>{</code> <small>(left brace)</small> and ending
+ * with <code>}</code> <small>(right brace)</small>.
+ * @throws JSONException If the object contains an invalid number.
+ */
+ public String toString(int indentFactor) throws JSONException {
+ StringWriter w = new StringWriter();
+ synchronized (w.getBuffer()) {
+ return this.write(w, indentFactor, 0).toString();
+ }
+ }
+
+ /**
+ * Make a JSON text of an Object value. If the object has an
+ * value.toJSONString() method, then that method will be used to produce
+ * the JSON text. The method is required to produce a strictly
+ * conforming text. If the object does not contain a toJSONString
+ * method (which is the most common case), then a text will be
+ * produced by other means. If the value is an array or Collection,
+ * then a JSONArray will be made from it and its toJSONString method
+ * will be called. If the value is a MAP, then a JSONObject will be made
+ * from it and its toJSONString method will be called. Otherwise, the
+ * value's toString method will be called, and the result will be quoted.
+ *
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ * @param value The value to be serialized.
+ * @return a printable, displayable, transmittable
+ * representation of the object, beginning
+ * with <code>{</code> <small>(left brace)</small> and ending
+ * with <code>}</code> <small>(right brace)</small>.
+ * @throws JSONException If the value is or contains an invalid number.
+ */
+ public static String valueToString(Object value) throws JSONException {
+ if (value == null || value.equals(null)) {
+ return "null";
+ }
+ if (value instanceof JSONString) {
+ Object object;
+ try {
+ object = ((JSONString)value).toJSONString();
+ } catch (Exception e) {
+ throw new JSONException(e);
+ }
+ if (object instanceof String) {
+ return (String)object;
+ }
+ throw new JSONException("Bad value from toJSONString: " + object);
+ }
+ if (value instanceof Number) {
+ return numberToString((Number) value);
+ }
+ if (value instanceof Boolean || value instanceof JSONObject ||
+ value instanceof JSONArray) {
+ return value.toString();
+ }
+ if (value instanceof Map) {
+ return new JSONObject((Map)value).toString();
+ }
+ if (value instanceof Collection) {
+ return new JSONArray((Collection)value).toString();
+ }
+ if (value.getClass().isArray()) {
+ return new JSONArray(value).toString();
+ }
+ return quote(value.toString());
+ }
+
+ /**
+ * Wrap an object, if necessary. If the object is null, return the NULL
+ * object. If it is an array or collection, wrap it in a JSONArray. If
+ * it is a map, wrap it in a JSONObject. If it is a standard property
+ * (Double, String, et al) then it is already wrapped. Otherwise, if it
+ * comes from one of the java packages, turn it into a string. And if
+ * it doesn't, try to wrap it in a JSONObject. If the wrapping fails,
+ * then null is returned.
+ *
+ * @param object The object to wrap
+ * @return The wrapped value
+ */
+ public static Object wrap(Object object) {
+ try {
+ if (object == null) {
+ return NULL;
+ }
+ if (object instanceof JSONObject || object instanceof JSONArray ||
+ NULL.equals(object) || object instanceof JSONString ||
+ object instanceof Byte || object instanceof Character ||
+ object instanceof Short || object instanceof Integer ||
+ object instanceof Long || object instanceof Boolean ||
+ object instanceof Float || object instanceof Double ||
+ object instanceof String || object instanceof Enum) {
+ return object;
+ }
+
+ if (object instanceof Collection) {
+ return new JSONArray((Collection)object);
+ }
+ if (object.getClass().isArray()) {
+ return new JSONArray(object);
+ }
+ if (object instanceof Map) {
+ return new JSONObject((Map)object);
+ }
+ Package objectPackage = object.getClass().getPackage();
+ String objectPackageName = objectPackage != null
+ ? objectPackage.getName()
+ : "";
+ if (
+ objectPackageName.startsWith("java.") ||
+ objectPackageName.startsWith("javax.") ||
+ object.getClass().getClassLoader() == null
+ ) {
+ return object.toString();
+ }
+ return new JSONObject(object);
+ } catch(Exception exception) {
+ return null;
+ }
+ }
+
+
+ /**
+ * Write the contents of the JSONObject as JSON text to a writer.
+ * For compactness, no whitespace is added.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ *
+ * @return The writer.
+ * @throws JSONException
+ */
+ public Writer write(Writer writer) throws JSONException {
+ return this.write(writer, 0, 0);
+ }
+
+
+ static final Writer writeValue(Writer writer, Object value,
+ int indentFactor, int indent) throws JSONException, IOException {
+ if (value == null || value.equals(null)) {
+ writer.write("null");
+ } else if (value instanceof JSONObject) {
+ ((JSONObject) value).write(writer, indentFactor, indent);
+ } else if (value instanceof JSONArray) {
+ ((JSONArray) value).write(writer, indentFactor, indent);
+ } else if (value instanceof Map) {
+ new JSONObject((Map) value).write(writer, indentFactor, indent);
+ } else if (value instanceof Collection) {
+ new JSONArray((Collection) value).write(writer, indentFactor,
+ indent);
+ } else if (value.getClass().isArray()) {
+ new JSONArray(value).write(writer, indentFactor, indent);
+ } else if (value instanceof Number) {
+ writer.write(numberToString((Number) value));
+ } else if (value instanceof Boolean) {
+ writer.write(value.toString());
+ } else if (value instanceof JSONString) {
+ Object o;
+ try {
+ o = ((JSONString) value).toJSONString();
+ } catch (Exception e) {
+ throw new JSONException(e);
+ }
+ writer.write(o != null ? o.toString() : quote(value.toString()));
+ } else {
+ quote(value.toString(), writer);
+ }
+ return writer;
+ }
+
+ static final void indent(Writer writer, int indent) throws IOException {
+ for (int i = 0; i < indent; i += 1) {
+ writer.write(' ');
+ }
+ }
+
+ /**
+ * Write the contents of the JSONObject as JSON text to a writer. For
+ * compactness, no whitespace is added.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ *
+ * @return The writer.
+ * @throws JSONException
+ */
+ Writer write(Writer writer, int indentFactor, int indent)
+ throws JSONException {
+ try {
+ boolean commanate = false;
+ final int length = this.length();
+ Iterator keys = this.keys();
+ writer.write('{');
+
+ if (length == 1) {
+ Object key = keys.next();
+ writer.write(quote(key.toString()));
+ writer.write(':');
+ if (indentFactor > 0) {
+ writer.write(' ');
+ }
+ writeValue(writer, this.map.get(key), indentFactor, indent);
+ } else if (length != 0) {
+ final int newindent = indent + indentFactor;
+ while (keys.hasNext()) {
+ Object key = keys.next();
+ if (commanate) {
+ writer.write(',');
+ }
+ if (indentFactor > 0) {
+ writer.write('\n');
+ }
+ indent(writer, newindent);
+ writer.write(quote(key.toString()));
+ writer.write(':');
+ if (indentFactor > 0) {
+ writer.write(' ');
+ }
+ writeValue(writer, this.map.get(key), indentFactor,
+ newindent);
+ commanate = true;
+ }
+ if (indentFactor > 0) {
+ writer.write('\n');
+ }
+ indent(writer, indent);
+ }
+ writer.write('}');
+ return writer;
+ } catch (IOException exception) {
+ throw new JSONException(exception);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONString.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONString.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONString.java
new file mode 100644
index 0000000..64674ff
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONString.java
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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 <code>JSONString</code> interface allows a <code>toJSONString()</code>
+ * method so that a class can change the behavior of
+ * <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
+ * and <code>JSONWriter.value(</code>Object<code>)</code>. The
+ * <code>toJSONString</code> method will be used instead of the default behavior
+ * of using the Object's <code>toString()</code> method and quoting the result.
+ */
+public interface JSONString {
+ /**
+ * The <code>toJSONString</code> method allows a class to produce its own JSON
+ * serialization.
+ *
+ * @return A strictly syntactically correct JSON text.
+ */
+ String toJSONString();
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONStringer.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONStringer.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONStringer.java
new file mode 100644
index 0000000..41adf5f
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONStringer.java
@@ -0,0 +1,73 @@
+/*
+ *
+ * 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.io.StringWriter;
+
+/**
+ * JSONStringer provides a quick and convenient way of producing JSON text.
+ * The texts produced strictly conform to JSON syntax rules. No whitespace is
+ * added, so the results are ready for transmission or storage. Each instance of
+ * JSONStringer can produce one JSON text.
+ * <p>
+ * A JSONStringer instance provides a <code>value</code> method for appending
+ * values to the
+ * text, and a <code>key</code>
+ * method for adding keys before values in objects. There are <code>array</code>
+ * and <code>endArray</code> methods that make and bound array values, and
+ * <code>object</code> and <code>endObject</code> methods which make and bound
+ * object values. All of these methods return the JSONWriter instance,
+ * permitting cascade style. For example, <pre>
+ * myString = new JSONStringer()
+ * .object()
+ * .key("JSON")
+ * .value("Hello, World!")
+ * .endObject()
+ * .toString();</pre> which produces the string <pre>
+ * {"JSON":"Hello, World!"}</pre>
+ * <p>
+ * The first method called must be <code>array</code> or <code>object</code>.
+ * There are no methods for adding commas or colons. JSONStringer adds them for
+ * you. Objects and arrays can be nested up to 20 levels deep.
+ * <p>
+ * This can sometimes be easier than using a JSONObject to build a string.
+ * @author JSON.org
+ * @version 2008-09-18
+ */
+public class JSONStringer extends JSONWriter {
+ /**
+ * Make a fresh JSONStringer. It can be used to build one JSON text.
+ */
+ public JSONStringer() {
+ super(new StringWriter());
+ }
+
+ /**
+ * Return the JSON text. This method is used to obtain the product of the
+ * JSONStringer instance. It will return <code>null</code> if there was a
+ * problem in the construction of the JSON text (such as the calls to
+ * <code>array</code> were not properly balanced with calls to
+ * <code>endArray</code>).
+ * @return The JSON text.
+ */
+ public String toString() {
+ return this.mode == 'd' ? this.writer.toString() : null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONTokener.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONTokener.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONTokener.java
new file mode 100644
index 0000000..99f5658
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONTokener.java
@@ -0,0 +1,441 @@
+/*
+ *
+ * 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.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+
+/**
+ * A JSONTokener takes a source string and extracts characters and tokens from
+ * it. It is used by the JSONObject and JSONArray constructors to parse
+ * JSON source strings.
+ * @author JSON.org
+ * @version 2012-02-16
+ */
+public class JSONTokener {
+
+ private long character;
+ private boolean eof;
+ private long index;
+ private long line;
+ private char previous;
+ private Reader reader;
+ private boolean usePrevious;
+
+
+ /**
+ * Construct a JSONTokener from a Reader.
+ *
+ * @param reader A reader.
+ */
+ public JSONTokener(Reader reader) {
+ this.reader = reader.markSupported()
+ ? reader
+ : new BufferedReader(reader);
+ this.eof = false;
+ this.usePrevious = false;
+ this.previous = 0;
+ this.index = 0;
+ this.character = 1;
+ this.line = 1;
+ }
+
+
+ /**
+ * Construct a JSONTokener from an InputStream.
+ */
+ public JSONTokener(InputStream inputStream) throws JSONException {
+ this(new InputStreamReader(inputStream));
+ }
+
+
+ /**
+ * Construct a JSONTokener from a string.
+ *
+ * @param s A source string.
+ */
+ public JSONTokener(String s) {
+ this(new StringReader(s));
+ }
+
+
+ /**
+ * Back up one character. This provides a sort of lookahead capability,
+ * so that you can test for a digit or letter before attempting to parse
+ * the next number or identifier.
+ */
+ public void back() throws JSONException {
+ if (this.usePrevious || this.index <= 0) {
+ throw new JSONException("Stepping back two steps is not supported");
+ }
+ this.index -= 1;
+ this.character -= 1;
+ this.usePrevious = true;
+ this.eof = false;
+ }
+
+
+ /**
+ * Get the hex value of a character (base16).
+ * @param c A character between '0' and '9' or between 'A' and 'F' or
+ * between 'a' and 'f'.
+ * @return An int between 0 and 15, or -1 if c was not a hex digit.
+ */
+ public static int dehexchar(char c) {
+ if (c >= '0' && c <= '9') {
+ return c - '0';
+ }
+ if (c >= 'A' && c <= 'F') {
+ return c - ('A' - 10);
+ }
+ if (c >= 'a' && c <= 'f') {
+ return c - ('a' - 10);
+ }
+ return -1;
+ }
+
+ public boolean end() {
+ return this.eof && !this.usePrevious;
+ }
+
+
+ /**
+ * Determine if the source string still contains characters that next()
+ * can consume.
+ * @return true if not yet at the end of the source.
+ */
+ public boolean more() throws JSONException {
+ this.next();
+ if (this.end()) {
+ return false;
+ }
+ this.back();
+ return true;
+ }
+
+
+ /**
+ * Get the next character in the source string.
+ *
+ * @return The next character, or 0 if past the end of the source string.
+ */
+ public char next() throws JSONException {
+ int c;
+ if (this.usePrevious) {
+ this.usePrevious = false;
+ c = this.previous;
+ } else {
+ try {
+ c = this.reader.read();
+ } catch (IOException exception) {
+ throw new JSONException(exception);
+ }
+
+ if (c <= 0) { // End of stream
+ this.eof = true;
+ c = 0;
+ }
+ }
+ this.index += 1;
+ if (this.previous == '\r') {
+ this.line += 1;
+ this.character = c == '\n' ? 0 : 1;
+ } else if (c == '\n') {
+ this.line += 1;
+ this.character = 0;
+ } else {
+ this.character += 1;
+ }
+ this.previous = (char) c;
+ return this.previous;
+ }
+
+
+ /**
+ * Consume the next character, and check that it matches a specified
+ * character.
+ * @param c The character to match.
+ * @return The character.
+ * @throws JSONException if the character does not match.
+ */
+ public char next(char c) throws JSONException {
+ char n = this.next();
+ if (n != c) {
+ throw this.syntaxError("Expected '" + c + "' and instead saw '" +
+ n + "'");
+ }
+ return n;
+ }
+
+
+ /**
+ * Get the next n characters.
+ *
+ * @param n The number of characters to take.
+ * @return A string of n characters.
+ * @throws JSONException
+ * Substring bounds error if there are not
+ * n characters remaining in the source string.
+ */
+ public String next(int n) throws JSONException {
+ if (n == 0) {
+ return "";
+ }
+
+ char[] chars = new char[n];
+ int pos = 0;
+
+ while (pos < n) {
+ chars[pos] = this.next();
+ if (this.end()) {
+ throw this.syntaxError("Substring bounds error");
+ }
+ pos += 1;
+ }
+ return new String(chars);
+ }
+
+
+ /**
+ * Get the next char in the string, skipping whitespace.
+ * @throws JSONException
+ * @return A character, or 0 if there are no more characters.
+ */
+ public char nextClean() throws JSONException {
+ for (;;) {
+ char c = this.next();
+ if (c == 0 || c > ' ') {
+ return c;
+ }
+ }
+ }
+
+
+ /**
+ * Return the characters up to the next close quote character.
+ * Backslash processing is done. The formal JSON format does not
+ * allow strings in single quotes, but an implementation is allowed to
+ * accept them.
+ * @param quote The quoting character, either
+ * <code>"</code> <small>(double quote)</small> or
+ * <code>'</code> <small>(single quote)</small>.
+ * @return A String.
+ * @throws JSONException Unterminated string.
+ */
+ public String nextString(char quote) throws JSONException {
+ char c;
+ StringBuffer sb = new StringBuffer();
+ for (;;) {
+ c = this.next();
+ switch (c) {
+ case 0:
+ case '\n':
+ case '\r':
+ throw this.syntaxError("Unterminated string");
+ case '\\':
+ c = this.next();
+ switch (c) {
+ case 'b':
+ sb.append('\b');
+ break;
+ case 't':
+ sb.append('\t');
+ break;
+ case 'n':
+ sb.append('\n');
+ break;
+ case 'f':
+ sb.append('\f');
+ break;
+ case 'r':
+ sb.append('\r');
+ break;
+ case 'u':
+ sb.append((char)Integer.parseInt(this.next(4), 16));
+ break;
+ case '"':
+ case '\'':
+ case '\\':
+ case '/':
+ sb.append(c);
+ break;
+ default:
+ throw this.syntaxError("Illegal escape.");
+ }
+ break;
+ default:
+ if (c == quote) {
+ return sb.toString();
+ }
+ sb.append(c);
+ }
+ }
+ }
+
+
+ /**
+ * Get the text up but not including the specified character or the
+ * end of line, whichever comes first.
+ * @param delimiter A delimiter character.
+ * @return A string.
+ */
+ public String nextTo(char delimiter) throws JSONException {
+ StringBuffer sb = new StringBuffer();
+ for (;;) {
+ char c = this.next();
+ if (c == delimiter || c == 0 || c == '\n' || c == '\r') {
+ if (c != 0) {
+ this.back();
+ }
+ return sb.toString().trim();
+ }
+ sb.append(c);
+ }
+ }
+
+
+ /**
+ * Get the text up but not including one of the specified delimiter
+ * characters or the end of line, whichever comes first.
+ * @param delimiters A set of delimiter characters.
+ * @return A string, trimmed.
+ */
+ public String nextTo(String delimiters) throws JSONException {
+ char c;
+ StringBuffer sb = new StringBuffer();
+ for (;;) {
+ c = this.next();
+ if (delimiters.indexOf(c) >= 0 || c == 0 ||
+ c == '\n' || c == '\r') {
+ if (c != 0) {
+ this.back();
+ }
+ return sb.toString().trim();
+ }
+ sb.append(c);
+ }
+ }
+
+
+ /**
+ * Get the next value. The value can be a Boolean, Double, Integer,
+ * JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
+ * @throws JSONException If syntax error.
+ *
+ * @return An object.
+ */
+ public Object nextValue() throws JSONException {
+ char c = this.nextClean();
+ String string;
+
+ switch (c) {
+ case '"':
+ case '\'':
+ return this.nextString(c);
+ case '{':
+ this.back();
+ return new JSONObject(this);
+ case '[':
+ this.back();
+ return new JSONArray(this);
+ }
+
+ /*
+ * Handle unquoted text. This could be the values true, false, or
+ * null, or it can be a number. An implementation (such as this one)
+ * is allowed to also accept non-standard forms.
+ *
+ * Accumulate characters until we reach the end of the text or a
+ * formatting character.
+ */
+
+ StringBuffer sb = new StringBuffer();
+ while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
+ sb.append(c);
+ c = this.next();
+ }
+ this.back();
+
+ string = sb.toString().trim();
+ if ("".equals(string)) {
+ throw this.syntaxError("Missing value");
+ }
+ return JSONObject.stringToValue(string);
+ }
+
+
+ /**
+ * Skip characters until the next character is the requested character.
+ * If the requested character is not found, no characters are skipped.
+ * @param to A character to skip to.
+ * @return The requested character, or zero if the requested character
+ * is not found.
+ */
+ public char skipTo(char to) throws JSONException {
+ char c;
+ try {
+ long startIndex = this.index;
+ long startCharacter = this.character;
+ long startLine = this.line;
+ this.reader.mark(1000000);
+ do {
+ c = this.next();
+ if (c == 0) {
+ this.reader.reset();
+ this.index = startIndex;
+ this.character = startCharacter;
+ this.line = startLine;
+ return c;
+ }
+ } while (c != to);
+ } catch (IOException exc) {
+ throw new JSONException(exc);
+ }
+
+ this.back();
+ return c;
+ }
+
+
+ /**
+ * Make a JSONException to signal a syntax error.
+ *
+ * @param message The error message.
+ * @return A JSONException object, suitable for throwing
+ */
+ public JSONException syntaxError(String message) {
+ return new JSONException(message + this.toString());
+ }
+
+
+ /**
+ * Make a printable string of this JSONTokener.
+ *
+ * @return " at {index} [character {character} line {line}]"
+ */
+ public String toString() {
+ return " at " + this.index + " [character " + this.character + " line " +
+ this.line + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONWriter.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONWriter.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONWriter.java
new file mode 100644
index 0000000..d1a661c
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONWriter.java
@@ -0,0 +1,322 @@
+/*
+ *
+ * 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.io.IOException;
+import java.io.Writer;
+
+/**
+ * JSONWriter provides a quick and convenient way of producing JSON text.
+ * The texts produced strictly conform to JSON syntax rules. No whitespace is
+ * added, so the results are ready for transmission or storage. Each instance of
+ * JSONWriter can produce one JSON text.
+ * <p>
+ * A JSONWriter instance provides a <code>value</code> method for appending
+ * values to the
+ * text, and a <code>key</code>
+ * method for adding keys before values in objects. There are <code>array</code>
+ * and <code>endArray</code> methods that make and bound array values, and
+ * <code>object</code> and <code>endObject</code> methods which make and bound
+ * object values. All of these methods return the JSONWriter instance,
+ * permitting a cascade style. For example, <pre>
+ * new JSONWriter(myWriter)
+ * .object()
+ * .key("JSON")
+ * .value("Hello, World!")
+ * .endObject();</pre> which writes <pre>
+ * {"JSON":"Hello, World!"}</pre>
+ * <p>
+ * The first method called must be <code>array</code> or <code>object</code>.
+ * There are no methods for adding commas or colons. JSONWriter adds them for
+ * you. Objects and arrays can be nested up to 20 levels deep.
+ * <p>
+ * This can sometimes be easier than using a JSONObject to build a string.
+ * @author JSON.org
+ * @version 2011-11-24
+ */
+public class JSONWriter {
+ private static final int maxdepth = 200;
+
+ /**
+ * The comma flag determines if a comma should be output before the next
+ * value.
+ */
+ private boolean comma;
+
+ /**
+ * The current mode. Values:
+ * 'a' (array),
+ * 'd' (done),
+ * 'i' (initial),
+ * 'k' (key),
+ * 'o' (object).
+ */
+ protected char mode;
+
+ /**
+ * The object/array stack.
+ */
+ private final JSONObject stack[];
+
+ /**
+ * The stack top index. A value of 0 indicates that the stack is empty.
+ */
+ private int top;
+
+ /**
+ * The writer that will receive the output.
+ */
+ protected Writer writer;
+
+ /**
+ * Make a fresh JSONWriter. It can be used to build one JSON text.
+ */
+ public JSONWriter(Writer w) {
+ this.comma = false;
+ this.mode = 'i';
+ this.stack = new JSONObject[maxdepth];
+ this.top = 0;
+ this.writer = w;
+ }
+
+ /**
+ * Append a value.
+ * @param string A string value.
+ * @return this
+ * @throws JSONException If the value is out of sequence.
+ */
+ private JSONWriter append(String string) throws JSONException {
+ if (string == null) {
+ throw new JSONException("Null pointer");
+ }
+ if (this.mode == 'o' || this.mode == 'a') {
+ try {
+ if (this.comma && this.mode == 'a') {
+ this.writer.write(',');
+ }
+ this.writer.write(string);
+ } catch (IOException e) {
+ throw new JSONException(e);
+ }
+ if (this.mode == 'o') {
+ this.mode = 'k';
+ }
+ this.comma = true;
+ return this;
+ }
+ throw new JSONException("Value out of sequence.");
+ }
+
+ /**
+ * Begin appending a new array. All values until the balancing
+ * <code>endArray</code> will be appended to this array. The
+ * <code>endArray</code> method must be called to mark the array's end.
+ * @return this
+ * @throws JSONException If the nesting is too deep, or if the object is
+ * started in the wrong place (for example as a key or after the end of the
+ * outermost array or object).
+ */
+ public JSONWriter array() throws JSONException {
+ if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') {
+ this.push(null);
+ this.append("[");
+ this.comma = false;
+ return this;
+ }
+ throw new JSONException("Misplaced array.");
+ }
+
+ /**
+ * End something.
+ * @param mode Mode
+ * @param c Closing character
+ * @return this
+ * @throws JSONException If unbalanced.
+ */
+ private JSONWriter end(char mode, char c) throws JSONException {
+ if (this.mode != mode) {
+ throw new JSONException(mode == 'a'
+ ? "Misplaced endArray."
+ : "Misplaced endObject.");
+ }
+ this.pop(mode);
+ try {
+ this.writer.write(c);
+ } catch (IOException e) {
+ throw new JSONException(e);
+ }
+ this.comma = true;
+ return this;
+ }
+
+ /**
+ * End an array. This method most be called to balance calls to
+ * <code>array</code>.
+ * @return this
+ * @throws JSONException If incorrectly nested.
+ */
+ public JSONWriter endArray() throws JSONException {
+ return this.end('a', ']');
+ }
+
+ /**
+ * End an object. This method most be called to balance calls to
+ * <code>object</code>.
+ * @return this
+ * @throws JSONException If incorrectly nested.
+ */
+ public JSONWriter endObject() throws JSONException {
+ return this.end('k', '}');
+ }
+
+ /**
+ * Append a key. The key will be associated with the next value. In an
+ * object, every value must be preceded by a key.
+ * @param string A key string.
+ * @return this
+ * @throws JSONException If the key is out of place. For example, keys
+ * do not belong in arrays or if the key is null.
+ */
+ public JSONWriter key(String string) throws JSONException {
+ if (string == null) {
+ throw new JSONException("Null key.");
+ }
+ if (this.mode == 'k') {
+ try {
+ this.stack[this.top - 1].putOnce(string, Boolean.TRUE);
+ if (this.comma) {
+ this.writer.write(',');
+ }
+ this.writer.write(JSONObject.quote(string));
+ this.writer.write(':');
+ this.comma = false;
+ this.mode = 'o';
+ return this;
+ } catch (IOException e) {
+ throw new JSONException(e);
+ }
+ }
+ throw new JSONException("Misplaced key.");
+ }
+
+
+ /**
+ * Begin appending a new object. All keys and values until the balancing
+ * <code>endObject</code> will be appended to this object. The
+ * <code>endObject</code> method must be called to mark the object's end.
+ * @return this
+ * @throws JSONException If the nesting is too deep, or if the object is
+ * started in the wrong place (for example as a key or after the end of the
+ * outermost array or object).
+ */
+ public JSONWriter object() throws JSONException {
+ if (this.mode == 'i') {
+ this.mode = 'o';
+ }
+ if (this.mode == 'o' || this.mode == 'a') {
+ this.append("{");
+ this.push(new JSONObject());
+ this.comma = false;
+ return this;
+ }
+ throw new JSONException("Misplaced object.");
+
+ }
+
+
+ /**
+ * Pop an array or object scope.
+ * @param c The scope to close.
+ * @throws JSONException If nesting is wrong.
+ */
+ private void pop(char c) throws JSONException {
+ if (this.top <= 0) {
+ throw new JSONException("Nesting error.");
+ }
+ char m = this.stack[this.top - 1] == null ? 'a' : 'k';
+ if (m != c) {
+ throw new JSONException("Nesting error.");
+ }
+ this.top -= 1;
+ this.mode = this.top == 0
+ ? 'd'
+ : this.stack[this.top - 1] == null
+ ? 'a'
+ : 'k';
+ }
+
+ /**
+ * Push an array or object scope.
+ * @param jo The scope to open.
+ * @throws JSONException If nesting is too deep.
+ */
+ private void push(JSONObject jo) throws JSONException {
+ if (this.top >= maxdepth) {
+ throw new JSONException("Nesting too deep.");
+ }
+ this.stack[this.top] = jo;
+ this.mode = jo == null ? 'a' : 'k';
+ this.top += 1;
+ }
+
+
+ /**
+ * Append either the value <code>true</code> or the value
+ * <code>false</code>.
+ * @param b A boolean.
+ * @return this
+ * @throws JSONException
+ */
+ public JSONWriter value(boolean b) throws JSONException {
+ return this.append(b ? "true" : "false");
+ }
+
+ /**
+ * Append a double value.
+ * @param d A double.
+ * @return this
+ * @throws JSONException If the number is not finite.
+ */
+ public JSONWriter value(double d) throws JSONException {
+ return this.value(new Double(d));
+ }
+
+ /**
+ * Append a long value.
+ * @param l A long.
+ * @return this
+ * @throws JSONException
+ */
+ public JSONWriter value(long l) throws JSONException {
+ return this.append(Long.toString(l));
+ }
+
+
+ /**
+ * Append an object value.
+ * @param object The object to append. It can be null, or a Boolean, Number,
+ * String, JSONObject, or JSONArray, or an object that implements JSONString.
+ * @return this
+ * @throws JSONException If the value is out of sequence.
+ */
+ public JSONWriter value(Object object) throws JSONException {
+ return this.append(JSONObject.valueToString(object));
+ }
+}
[17/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONArray.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONArray.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONArray.java
new file mode 100644
index 0000000..5715db5
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONArray.java
@@ -0,0 +1,901 @@
+/*
+ *
+ * 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.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * A JSONArray is an ordered sequence of values. Its external text form is a
+ * string wrapped in square brackets with commas separating the values. The
+ * internal form is an object having <code>get</code> and <code>opt</code>
+ * methods for accessing the values by index, and <code>put</code> methods for
+ * adding or replacing values. The values can be any of these types:
+ * <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>,
+ * <code>Number</code>, <code>String</code>, or the
+ * <code>JSONObject.NULL object</code>.
+ * <p>
+ * The constructor can convert a JSON text into a Java object. The
+ * <code>toString</code> method converts to JSON text.
+ * <p>
+ * A <code>get</code> method returns a value if one can be found, and throws an
+ * exception if one cannot be found. An <code>opt</code> method returns a
+ * default value instead of throwing an exception, and so is useful for
+ * obtaining optional values.
+ * <p>
+ * The generic <code>get()</code> and <code>opt()</code> methods return an
+ * object which you can cast or query for type. There are also typed
+ * <code>get</code> and <code>opt</code> methods that do type checking and type
+ * coercion for you.
+ * <p>
+ * The texts produced by the <code>toString</code> methods strictly conform to
+ * JSON syntax rules. The constructors are more forgiving in the texts they will
+ * accept:
+ * <ul>
+ * <li>An extra <code>,</code> <small>(comma)</small> may appear just
+ * before the closing bracket.</li>
+ * <li>The <code>null</code> value will be inserted when there is <code>,</code>
+ * <small>(comma)</small> elision.</li>
+ * <li>Strings may be quoted with <code>'</code> <small>(single
+ * quote)</small>.</li>
+ * <li>Strings do not need to be quoted at all if they do not begin with a quote
+ * or single quote, and if they do not contain leading or trailing spaces, and
+ * if they do not contain any of these characters:
+ * <code>{ } [ ] / \ : , = ; #</code> and if they do not look like numbers and
+ * if they are not the reserved words <code>true</code>, <code>false</code>, or
+ * <code>null</code>.</li>
+ * <li>Values can be separated by <code>;</code> <small>(semicolon)</small> as
+ * well as by <code>,</code> <small>(comma)</small>.</li>
+ * </ul>
+ *
+ * @author JSON.org
+ * @version 2012-04-20
+ */
+public class JSONArray {
+
+
+ /**
+ * The arrayList where the JSONArray's properties are kept.
+ */
+ private final ArrayList myArrayList;
+
+
+ /**
+ * Construct an empty JSONArray.
+ */
+ public JSONArray() {
+ this.myArrayList = new ArrayList();
+ }
+
+ /**
+ * Construct a JSONArray from a JSONTokener.
+ * @param x A JSONTokener
+ * @throws JSONException If there is a syntax error.
+ */
+ public JSONArray(JSONTokener x) throws JSONException {
+ this();
+ if (x.nextClean() != '[') {
+ throw x.syntaxError("A JSONArray text must start with '['");
+ }
+ if (x.nextClean() != ']') {
+ x.back();
+ for (;;) {
+ if (x.nextClean() == ',') {
+ x.back();
+ this.myArrayList.add(JSONObject.NULL);
+ } else {
+ x.back();
+ this.myArrayList.add(x.nextValue());
+ }
+ switch (x.nextClean()) {
+ case ';':
+ case ',':
+ if (x.nextClean() == ']') {
+ return;
+ }
+ x.back();
+ break;
+ case ']':
+ return;
+ default:
+ throw x.syntaxError("Expected a ',' or ']'");
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Construct a JSONArray from a source JSON text.
+ * @param source A string that begins with
+ * <code>[</code> <small>(left bracket)</small>
+ * and ends with <code>]</code> <small>(right bracket)</small>.
+ * @throws JSONException If there is a syntax error.
+ */
+ public JSONArray(String source) throws JSONException {
+ this(new JSONTokener(source));
+ }
+
+
+ /**
+ * Construct a JSONArray from a Collection.
+ * @param collection A Collection.
+ */
+ public JSONArray(Collection collection) {
+ this.myArrayList = new ArrayList();
+ if (collection != null) {
+ Iterator iter = collection.iterator();
+ while (iter.hasNext()) {
+ this.myArrayList.add(JSONObject.wrap(iter.next()));
+ }
+ }
+ }
+
+
+ /**
+ * Construct a JSONArray from an array
+ * @throws JSONException If not an array.
+ */
+ public JSONArray(Object array) throws JSONException {
+ this();
+ if (array.getClass().isArray()) {
+ int length = Array.getLength(array);
+ for (int i = 0; i < length; i += 1) {
+ this.put(JSONObject.wrap(Array.get(array, i)));
+ }
+ } else {
+ throw new JSONException(
+"JSONArray initial value should be a string or collection or array.");
+ }
+ }
+
+
+ /**
+ * Get the object value associated with an index.
+ * @param index
+ * The index must be between 0 and length() - 1.
+ * @return An object value.
+ * @throws JSONException If there is no value for the index.
+ */
+ public Object get(int index) throws JSONException {
+ Object object = this.opt(index);
+ if (object == null) {
+ throw new JSONException("JSONArray[" + index + "] not found.");
+ }
+ return object;
+ }
+
+
+ /**
+ * Get the boolean value associated with an index.
+ * The string values "true" and "false" are converted to boolean.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The truth.
+ * @throws JSONException If there is no value for the index or if the
+ * value is not convertible to boolean.
+ */
+ public boolean getBoolean(int index) throws JSONException {
+ Object object = this.get(index);
+ if (object.equals(Boolean.FALSE) ||
+ (object instanceof String &&
+ ((String)object).equalsIgnoreCase("false"))) {
+ return false;
+ } else if (object.equals(Boolean.TRUE) ||
+ (object instanceof String &&
+ ((String)object).equalsIgnoreCase("true"))) {
+ return true;
+ }
+ throw new JSONException("JSONArray[" + index + "] is not a boolean.");
+ }
+
+
+ /**
+ * Get the double value associated with an index.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The value.
+ * @throws JSONException If the key is not found or if the value cannot
+ * be converted to a number.
+ */
+ public double getDouble(int index) throws JSONException {
+ Object object = this.get(index);
+ try {
+ return object instanceof Number
+ ? ((Number)object).doubleValue()
+ : Double.parseDouble((String)object);
+ } catch (Exception e) {
+ throw new JSONException("JSONArray[" + index +
+ "] is not a number.");
+ }
+ }
+
+
+ /**
+ * Get the int value associated with an index.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The value.
+ * @throws JSONException If the key is not found or if the value is not a number.
+ */
+ public int getInt(int index) throws JSONException {
+ Object object = this.get(index);
+ try {
+ return object instanceof Number
+ ? ((Number)object).intValue()
+ : Integer.parseInt((String)object);
+ } catch (Exception e) {
+ throw new JSONException("JSONArray[" + index +
+ "] is not a number.");
+ }
+ }
+
+
+ /**
+ * Get the JSONArray associated with an index.
+ * @param index The index must be between 0 and length() - 1.
+ * @return A JSONArray value.
+ * @throws JSONException If there is no value for the index. or if the
+ * value is not a JSONArray
+ */
+ public JSONArray getJSONArray(int index) throws JSONException {
+ Object object = this.get(index);
+ if (object instanceof JSONArray) {
+ return (JSONArray)object;
+ }
+ throw new JSONException("JSONArray[" + index +
+ "] is not a JSONArray.");
+ }
+
+
+ /**
+ * Get the JSONObject associated with an index.
+ * @param index subscript
+ * @return A JSONObject value.
+ * @throws JSONException If there is no value for the index or if the
+ * value is not a JSONObject
+ */
+ public JSONObject getJSONObject(int index) throws JSONException {
+ Object object = this.get(index);
+ if (object instanceof JSONObject) {
+ return (JSONObject)object;
+ }
+ throw new JSONException("JSONArray[" + index +
+ "] is not a JSONObject.");
+ }
+
+
+ /**
+ * Get the long value associated with an index.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The value.
+ * @throws JSONException If the key is not found or if the value cannot
+ * be converted to a number.
+ */
+ public long getLong(int index) throws JSONException {
+ Object object = this.get(index);
+ try {
+ return object instanceof Number
+ ? ((Number)object).longValue()
+ : Long.parseLong((String)object);
+ } catch (Exception e) {
+ throw new JSONException("JSONArray[" + index +
+ "] is not a number.");
+ }
+ }
+
+
+ /**
+ * Get the string associated with an index.
+ * @param index The index must be between 0 and length() - 1.
+ * @return A string value.
+ * @throws JSONException If there is no string value for the index.
+ */
+ public String getString(int index) throws JSONException {
+ Object object = this.get(index);
+ if (object instanceof String) {
+ return (String)object;
+ }
+ throw new JSONException("JSONArray[" + index + "] not a string.");
+ }
+
+
+ /**
+ * Determine if the value is null.
+ * @param index The index must be between 0 and length() - 1.
+ * @return true if the value at the index is null, or if there is no value.
+ */
+ public boolean isNull(int index) {
+ return JSONObject.NULL.equals(this.opt(index));
+ }
+
+
+ /**
+ * Make a string from the contents of this JSONArray. The
+ * <code>separator</code> string is inserted between each element.
+ * Warning: This method assumes that the data structure is acyclical.
+ * @param separator A string that will be inserted between the elements.
+ * @return a string.
+ * @throws JSONException If the array contains an invalid number.
+ */
+ public String join(String separator) throws JSONException {
+ int len = this.length();
+ StringBuffer sb = new StringBuffer();
+
+ for (int i = 0; i < len; i += 1) {
+ if (i > 0) {
+ sb.append(separator);
+ }
+ sb.append(JSONObject.valueToString(this.myArrayList.get(i)));
+ }
+ return sb.toString();
+ }
+
+
+ /**
+ * Get the number of elements in the JSONArray, included nulls.
+ *
+ * @return The length (or size).
+ */
+ public int length() {
+ return this.myArrayList.size();
+ }
+
+
+ /**
+ * Get the optional object value associated with an index.
+ * @param index The index must be between 0 and length() - 1.
+ * @return An object value, or null if there is no
+ * object at that index.
+ */
+ public Object opt(int index) {
+ return (index < 0 || index >= this.length())
+ ? null
+ : this.myArrayList.get(index);
+ }
+
+
+ /**
+ * Get the optional boolean value associated with an index.
+ * It returns false if there is no value at that index,
+ * or if the value is not Boolean.TRUE or the String "true".
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The truth.
+ */
+ public boolean optBoolean(int index) {
+ return this.optBoolean(index, false);
+ }
+
+
+ /**
+ * Get the optional boolean value associated with an index.
+ * It returns the defaultValue if there is no value at that index or if
+ * it is not a Boolean or the String "true" or "false" (case insensitive).
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @param defaultValue A boolean default.
+ * @return The truth.
+ */
+ public boolean optBoolean(int index, boolean defaultValue) {
+ try {
+ return this.getBoolean(index);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get the optional double value associated with an index.
+ * NaN is returned if there is no value for the index,
+ * or if the value is not a number and cannot be converted to a number.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The value.
+ */
+ public double optDouble(int index) {
+ return this.optDouble(index, Double.NaN);
+ }
+
+
+ /**
+ * Get the optional double value associated with an index.
+ * The defaultValue is returned if there is no value for the index,
+ * or if the value is not a number and cannot be converted to a number.
+ *
+ * @param index subscript
+ * @param defaultValue The default value.
+ * @return The value.
+ */
+ public double optDouble(int index, double defaultValue) {
+ try {
+ return this.getDouble(index);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get the optional int value associated with an index.
+ * Zero is returned if there is no value for the index,
+ * or if the value is not a number and cannot be converted to a number.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The value.
+ */
+ public int optInt(int index) {
+ return this.optInt(index, 0);
+ }
+
+
+ /**
+ * Get the optional int value associated with an index.
+ * The defaultValue is returned if there is no value for the index,
+ * or if the value is not a number and cannot be converted to a number.
+ * @param index The index must be between 0 and length() - 1.
+ * @param defaultValue The default value.
+ * @return The value.
+ */
+ public int optInt(int index, int defaultValue) {
+ try {
+ return this.getInt(index);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get the optional JSONArray associated with an index.
+ * @param index subscript
+ * @return A JSONArray value, or null if the index has no value,
+ * or if the value is not a JSONArray.
+ */
+ public JSONArray optJSONArray(int index) {
+ Object o = this.opt(index);
+ return o instanceof JSONArray ? (JSONArray)o : null;
+ }
+
+
+ /**
+ * Get the optional JSONObject associated with an index.
+ * Null is returned if the key is not found, or null if the index has
+ * no value, or if the value is not a JSONObject.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return A JSONObject value.
+ */
+ public JSONObject optJSONObject(int index) {
+ Object o = this.opt(index);
+ return o instanceof JSONObject ? (JSONObject)o : null;
+ }
+
+
+ /**
+ * Get the optional long value associated with an index.
+ * Zero is returned if there is no value for the index,
+ * or if the value is not a number and cannot be converted to a number.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return The value.
+ */
+ public long optLong(int index) {
+ return this.optLong(index, 0);
+ }
+
+
+ /**
+ * Get the optional long value associated with an index.
+ * The defaultValue is returned if there is no value for the index,
+ * or if the value is not a number and cannot be converted to a number.
+ * @param index The index must be between 0 and length() - 1.
+ * @param defaultValue The default value.
+ * @return The value.
+ */
+ public long optLong(int index, long defaultValue) {
+ try {
+ return this.getLong(index);
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
+
+ /**
+ * Get the optional string value associated with an index. It returns an
+ * empty string if there is no value at that index. If the value
+ * is not a string and is not null, then it is coverted to a string.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @return A String value.
+ */
+ public String optString(int index) {
+ return this.optString(index, "");
+ }
+
+
+ /**
+ * Get the optional string associated with an index.
+ * The defaultValue is returned if the key is not found.
+ *
+ * @param index The index must be between 0 and length() - 1.
+ * @param defaultValue The default value.
+ * @return A String value.
+ */
+ public String optString(int index, String defaultValue) {
+ Object object = this.opt(index);
+ return JSONObject.NULL.equals(object)
+ ? defaultValue : object
+ .toString();
+ }
+
+
+ /**
+ * Append a boolean value. This increases the array's length by one.
+ *
+ * @param value A boolean value.
+ * @return this.
+ */
+ public JSONArray put(boolean value) {
+ this.put(value ? Boolean.TRUE : Boolean.FALSE);
+ return this;
+ }
+
+
+ /**
+ * Put a value in the JSONArray, where the value will be a
+ * JSONArray which is produced from a Collection.
+ * @param value A Collection value.
+ * @return this.
+ */
+ public JSONArray put(Collection value) {
+ this.put(new JSONArray(value));
+ return this;
+ }
+
+
+ /**
+ * Append a double value. This increases the array's length by one.
+ *
+ * @param value A double value.
+ * @throws JSONException if the value is not finite.
+ * @return this.
+ */
+ public JSONArray put(double value) throws JSONException {
+ Double d = new Double(value);
+ JSONObject.testValidity(d);
+ this.put(d);
+ return this;
+ }
+
+
+ /**
+ * Append an int value. This increases the array's length by one.
+ *
+ * @param value An int value.
+ * @return this.
+ */
+ public JSONArray put(int value) {
+ this.put(new Integer(value));
+ return this;
+ }
+
+
+ /**
+ * Append an long value. This increases the array's length by one.
+ *
+ * @param value A long value.
+ * @return this.
+ */
+ public JSONArray put(long value) {
+ this.put(new Long(value));
+ return this;
+ }
+
+
+ /**
+ * Put a value in the JSONArray, where the value will be a
+ * JSONObject which is produced from a Map.
+ * @param value A Map value.
+ * @return this.
+ */
+ public JSONArray put(Map value) {
+ this.put(new JSONObject(value));
+ return this;
+ }
+
+
+ /**
+ * Append an object value. This increases the array's length by one.
+ * @param value An object value. The value should be a
+ * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
+ * JSONObject.NULL object.
+ * @return this.
+ */
+ public JSONArray put(Object value) {
+ this.myArrayList.add(value);
+ return this;
+ }
+
+
+ /**
+ * Put or replace a boolean value in the JSONArray. If the index is greater
+ * than the length of the JSONArray, then null elements will be added as
+ * necessary to pad it out.
+ * @param index The subscript.
+ * @param value A boolean value.
+ * @return this.
+ * @throws JSONException If the index is negative.
+ */
+ public JSONArray put(int index, boolean value) throws JSONException {
+ this.put(index, value ? Boolean.TRUE : Boolean.FALSE);
+ return this;
+ }
+
+
+ /**
+ * Put a value in the JSONArray, where the value will be a
+ * JSONArray which is produced from a Collection.
+ * @param index The subscript.
+ * @param value A Collection value.
+ * @return this.
+ * @throws JSONException If the index is negative or if the value is
+ * not finite.
+ */
+ public JSONArray put(int index, Collection value) throws JSONException {
+ this.put(index, new JSONArray(value));
+ return this;
+ }
+
+
+ /**
+ * Put or replace a double value. If the index is greater than the length of
+ * the JSONArray, then null elements will be added as necessary to pad
+ * it out.
+ * @param index The subscript.
+ * @param value A double value.
+ * @return this.
+ * @throws JSONException If the index is negative or if the value is
+ * not finite.
+ */
+ public JSONArray put(int index, double value) throws JSONException {
+ this.put(index, new Double(value));
+ return this;
+ }
+
+
+ /**
+ * Put or replace an int value. If the index is greater than the length of
+ * the JSONArray, then null elements will be added as necessary to pad
+ * it out.
+ * @param index The subscript.
+ * @param value An int value.
+ * @return this.
+ * @throws JSONException If the index is negative.
+ */
+ public JSONArray put(int index, int value) throws JSONException {
+ this.put(index, new Integer(value));
+ return this;
+ }
+
+
+ /**
+ * Put or replace a long value. If the index is greater than the length of
+ * the JSONArray, then null elements will be added as necessary to pad
+ * it out.
+ * @param index The subscript.
+ * @param value A long value.
+ * @return this.
+ * @throws JSONException If the index is negative.
+ */
+ public JSONArray put(int index, long value) throws JSONException {
+ this.put(index, new Long(value));
+ return this;
+ }
+
+
+ /**
+ * Put a value in the JSONArray, where the value will be a
+ * JSONObject that is produced from a Map.
+ * @param index The subscript.
+ * @param value The Map value.
+ * @return this.
+ * @throws JSONException If the index is negative or if the the value is
+ * an invalid number.
+ */
+ public JSONArray put(int index, Map value) throws JSONException {
+ this.put(index, new JSONObject(value));
+ return this;
+ }
+
+
+ /**
+ * Put or replace an object value in the JSONArray. If the index is greater
+ * than the length of the JSONArray, then null elements will be added as
+ * necessary to pad it out.
+ * @param index The subscript.
+ * @param value The value to put into the array. The value should be a
+ * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
+ * JSONObject.NULL object.
+ * @return this.
+ * @throws JSONException If the index is negative or if the the value is
+ * an invalid number.
+ */
+ public JSONArray put(int index, Object value) throws JSONException {
+ JSONObject.testValidity(value);
+ if (index < 0) {
+ throw new JSONException("JSONArray[" + index + "] not found.");
+ }
+ if (index < this.length()) {
+ this.myArrayList.set(index, value);
+ } else {
+ while (index != this.length()) {
+ this.put(JSONObject.NULL);
+ }
+ this.put(value);
+ }
+ return this;
+ }
+
+
+ /**
+ * Remove an index and close the hole.
+ * @param index The index of the element to be removed.
+ * @return The value that was associated with the index,
+ * or null if there was no value.
+ */
+ public Object remove(int index) {
+ Object o = this.opt(index);
+ this.myArrayList.remove(index);
+ return o;
+ }
+
+
+ /**
+ * Produce a JSONObject by combining a JSONArray of names with the values
+ * of this JSONArray.
+ * @param names A JSONArray containing a list of key strings. These will be
+ * paired with the values.
+ * @return A JSONObject, or null if there are no names or if this JSONArray
+ * has no values.
+ * @throws JSONException If any of the names are null.
+ */
+ public JSONObject toJSONObject(JSONArray names) throws JSONException {
+ if (names == null || names.length() == 0 || this.length() == 0) {
+ return null;
+ }
+ JSONObject jo = new JSONObject();
+ for (int i = 0; i < names.length(); i += 1) {
+ jo.put(names.getString(i), this.opt(i));
+ }
+ return jo;
+ }
+
+
+ /**
+ * Make a JSON text of this JSONArray. For compactness, no
+ * unnecessary whitespace is added. If it is not possible to produce a
+ * syntactically correct JSON text then null will be returned instead. This
+ * could occur if the array contains an invalid number.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ *
+ * @return a printable, displayable, transmittable
+ * representation of the array.
+ */
+ public String toString() {
+ try {
+ return '[' + this.join(",") + ']';
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+
+ /**
+ * Make a prettyprinted JSON text of this JSONArray.
+ * Warning: This method assumes that the data structure is acyclical.
+ * @param indentFactor The number of spaces to add to each level of
+ * indentation.
+ * @return a printable, displayable, transmittable
+ * representation of the object, beginning
+ * with <code>[</code> <small>(left bracket)</small> and ending
+ * with <code>]</code> <small>(right bracket)</small>.
+ * @throws JSONException
+ */
+ public String toString(int indentFactor) throws JSONException {
+ StringWriter sw = new StringWriter();
+ synchronized (sw.getBuffer()) {
+ return this.write(sw, indentFactor, 0).toString();
+ }
+ }
+
+ /**
+ * Write the contents of the JSONArray as JSON text to a writer. For
+ * compactness, no whitespace is added.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ *
+ * @return The writer.
+ * @throws JSONException
+ */
+ public Writer write(Writer writer) throws JSONException {
+ return this.write(writer, 0, 0);
+ }
+
+ /**
+ * Write the contents of the JSONArray as JSON text to a writer. For
+ * compactness, no whitespace is added.
+ * <p>
+ * Warning: This method assumes that the data structure is acyclical.
+ *
+ * @param indentFactor
+ * The number of spaces to add to each level of indentation.
+ * @param indent
+ * The indention of the top level.
+ * @return The writer.
+ * @throws JSONException
+ */
+ Writer write(Writer writer, int indentFactor, int indent)
+ throws JSONException {
+ try {
+ boolean commanate = false;
+ int length = this.length();
+ writer.write('[');
+
+ if (length == 1) {
+ JSONObject.writeValue(writer, this.myArrayList.get(0),
+ indentFactor, indent);
+ } else if (length != 0) {
+ final int newindent = indent + indentFactor;
+
+ for (int i = 0; i < length; i += 1) {
+ if (commanate) {
+ writer.write(',');
+ }
+ if (indentFactor > 0) {
+ writer.write('\n');
+ }
+ JSONObject.indent(writer, newindent);
+ JSONObject.writeValue(writer, this.myArrayList.get(i),
+ indentFactor, newindent);
+ commanate = true;
+ }
+ if (indentFactor > 0) {
+ writer.write('\n');
+ }
+ JSONObject.indent(writer, indent);
+ }
+ writer.write(']');
+ return writer;
+ } catch (IOException e) {
+ throw new JSONException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONException.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONException.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONException.java
new file mode 100644
index 0000000..7533e49
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONException.java
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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 JSONException is thrown by the JSON.org classes when things are amiss.
+ * @author JSON.org
+ * @version 2010-12-24
+ */
+public class JSONException extends Exception {
+ private static final long serialVersionUID = 0;
+ private Throwable cause;
+
+ /**
+ * Constructs a JSONException with an explanatory message.
+ * @param message Detail about the reason for the exception.
+ */
+ public JSONException(String message) {
+ super(message);
+ }
+
+ public JSONException(Throwable cause) {
+ super(cause.getMessage());
+ this.cause = cause;
+ }
+
+ public Throwable getCause() {
+ return this.cause;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONML.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONML.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONML.java
new file mode 100644
index 0000000..3c52063
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONML.java
@@ -0,0 +1,462 @@
+/*
+ *
+ * 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;
+
+
+/**
+ * This provides static methods to convert an XML text into a JSONArray or
+ * JSONObject, and to covert a JSONArray or JSONObject into an XML text using
+ * the JsonML transform.
+ *
+ * @author JSON.org
+ * @version 2012-03-28
+ */
+public class JSONML {
+
+ /**
+ * Parse XML values and store them in a JSONArray.
+ * @param x The XMLTokener containing the source string.
+ * @param arrayForm true if array form, false if object form.
+ * @param ja The JSONArray that is containing the current tag or null
+ * if we are at the outermost level.
+ * @return A JSONArray if the value is the outermost tag, otherwise null.
+ * @throws JSONException
+ */
+ private static Object parse(
+ XMLTokener x,
+ boolean arrayForm,
+ JSONArray ja
+ ) throws JSONException {
+ String attribute;
+ char c;
+ String closeTag = null;
+ int i;
+ JSONArray newja = null;
+ JSONObject newjo = null;
+ Object token;
+ String tagName = null;
+
+// Test for and skip past these forms:
+// <!-- ... -->
+// <![ ... ]]>
+// <! ... >
+// <? ... ?>
+
+ while (true) {
+ if (!x.more()) {
+ throw x.syntaxError("Bad XML");
+ }
+ token = x.nextContent();
+ if (token == XML.LT) {
+ token = x.nextToken();
+ if (token instanceof Character) {
+ if (token == XML.SLASH) {
+
+// Close tag </
+
+ token = x.nextToken();
+ if (!(token instanceof String)) {
+ throw new JSONException(
+ "Expected a closing name instead of '" +
+ token + "'.");
+ }
+ if (x.nextToken() != XML.GT) {
+ throw x.syntaxError("Misshaped close tag");
+ }
+ return token;
+ } else if (token == XML.BANG) {
+
+// <!
+
+ c = x.next();
+ if (c == '-') {
+ if (x.next() == '-') {
+ x.skipPast("-->");
+ } else {
+ x.back();
+ }
+ } else if (c == '[') {
+ token = x.nextToken();
+ if (token.equals("CDATA") && x.next() == '[') {
+ if (ja != null) {
+ ja.put(x.nextCDATA());
+ }
+ } else {
+ throw x.syntaxError("Expected 'CDATA['");
+ }
+ } else {
+ i = 1;
+ do {
+ token = x.nextMeta();
+ if (token == null) {
+ throw x.syntaxError("Missing '>' after '<!'.");
+ } else if (token == XML.LT) {
+ i += 1;
+ } else if (token == XML.GT) {
+ i -= 1;
+ }
+ } while (i > 0);
+ }
+ } else if (token == XML.QUEST) {
+
+// <?
+
+ x.skipPast("?>");
+ } else {
+ throw x.syntaxError("Misshaped tag");
+ }
+
+// Open tag <
+
+ } else {
+ if (!(token instanceof String)) {
+ throw x.syntaxError("Bad tagName '" + token + "'.");
+ }
+ tagName = (String)token;
+ newja = new JSONArray();
+ newjo = new JSONObject();
+ if (arrayForm) {
+ newja.put(tagName);
+ if (ja != null) {
+ ja.put(newja);
+ }
+ } else {
+ newjo.put("tagName", tagName);
+ if (ja != null) {
+ ja.put(newjo);
+ }
+ }
+ token = null;
+ for (;;) {
+ if (token == null) {
+ token = x.nextToken();
+ }
+ if (token == null) {
+ throw x.syntaxError("Misshaped tag");
+ }
+ if (!(token instanceof String)) {
+ break;
+ }
+
+// attribute = value
+
+ attribute = (String)token;
+ if (!arrayForm && ("tagName".equals(attribute) || "childNode".equals(attribute))) {
+ throw x.syntaxError("Reserved attribute.");
+ }
+ token = x.nextToken();
+ if (token == XML.EQ) {
+ token = x.nextToken();
+ if (!(token instanceof String)) {
+ throw x.syntaxError("Missing value");
+ }
+ newjo.accumulate(attribute, XML.stringToValue((String)token));
+ token = null;
+ } else {
+ newjo.accumulate(attribute, "");
+ }
+ }
+ if (arrayForm && newjo.length() > 0) {
+ newja.put(newjo);
+ }
+
+// Empty tag <.../>
+
+ if (token == XML.SLASH) {
+ if (x.nextToken() != XML.GT) {
+ throw x.syntaxError("Misshaped tag");
+ }
+ if (ja == null) {
+ if (arrayForm) {
+ return newja;
+ } else {
+ return newjo;
+ }
+ }
+
+// Content, between <...> and </...>
+
+ } else {
+ if (token != XML.GT) {
+ throw x.syntaxError("Misshaped tag");
+ }
+ closeTag = (String)parse(x, arrayForm, newja);
+ if (closeTag != null) {
+ if (!closeTag.equals(tagName)) {
+ throw x.syntaxError("Mismatched '" + tagName +
+ "' and '" + closeTag + "'");
+ }
+ tagName = null;
+ if (!arrayForm && newja.length() > 0) {
+ newjo.put("childNodes", newja);
+ }
+ if (ja == null) {
+ if (arrayForm) {
+ return newja;
+ } else {
+ return newjo;
+ }
+ }
+ }
+ }
+ }
+ } else {
+ if (ja != null) {
+ ja.put(token instanceof String
+ ? XML.stringToValue((String)token)
+ : token);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Convert a well-formed (but not necessarily valid) XML string into a
+ * JSONArray using the JsonML transform. Each XML tag is represented as
+ * a JSONArray in which the first element is the tag name. If the tag has
+ * attributes, then the second element will be JSONObject containing the
+ * name/value pairs. If the tag contains children, then strings and
+ * JSONArrays will represent the child tags.
+ * Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
+ * @param string The source string.
+ * @return A JSONArray containing the structured data from the XML string.
+ * @throws JSONException
+ */
+ public static JSONArray toJSONArray(String string) throws JSONException {
+ return toJSONArray(new XMLTokener(string));
+ }
+
+
+ /**
+ * Convert a well-formed (but not necessarily valid) XML string into a
+ * JSONArray using the JsonML transform. Each XML tag is represented as
+ * a JSONArray in which the first element is the tag name. If the tag has
+ * attributes, then the second element will be JSONObject containing the
+ * name/value pairs. If the tag contains children, then strings and
+ * JSONArrays will represent the child content and tags.
+ * Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
+ * @param x An XMLTokener.
+ * @return A JSONArray containing the structured data from the XML string.
+ * @throws JSONException
+ */
+ public static JSONArray toJSONArray(XMLTokener x) throws JSONException {
+ return (JSONArray)parse(x, true, null);
+ }
+
+
+ /**
+ * Convert a well-formed (but not necessarily valid) XML string into a
+ * JSONObject using the JsonML transform. Each XML tag is represented as
+ * a JSONObject with a "tagName" property. If the tag has attributes, then
+ * the attributes will be in the JSONObject as properties. If the tag
+ * contains children, the object will have a "childNodes" property which
+ * will be an array of strings and JsonML JSONObjects.
+
+ * Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
+ * @param x An XMLTokener of the XML source text.
+ * @return A JSONObject containing the structured data from the XML string.
+ * @throws JSONException
+ */
+ public static JSONObject toJSONObject(XMLTokener x) throws JSONException {
+ return (JSONObject)parse(x, false, null);
+ }
+
+
+ /**
+ * Convert a well-formed (but not necessarily valid) XML string into a
+ * JSONObject using the JsonML transform. Each XML tag is represented as
+ * a JSONObject with a "tagName" property. If the tag has attributes, then
+ * the attributes will be in the JSONObject as properties. If the tag
+ * contains children, the object will have a "childNodes" property which
+ * will be an array of strings and JsonML JSONObjects.
+
+ * Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
+ * @param string The XML source text.
+ * @return A JSONObject containing the structured data from the XML string.
+ * @throws JSONException
+ */
+ public static JSONObject toJSONObject(String string) throws JSONException {
+ return toJSONObject(new XMLTokener(string));
+ }
+
+
+ /**
+ * Reverse the JSONML transformation, making an XML text from a JSONArray.
+ * @param ja A JSONArray.
+ * @return An XML string.
+ * @throws JSONException
+ */
+ public static String toString(JSONArray ja) throws JSONException {
+ int i;
+ JSONObject jo;
+ String key;
+ Iterator keys;
+ int length;
+ Object object;
+ StringBuffer sb = new StringBuffer();
+ String tagName;
+ String value;
+
+// Emit <tagName
+
+ tagName = ja.getString(0);
+ XML.noSpace(tagName);
+ tagName = XML.escape(tagName);
+ sb.append('<');
+ sb.append(tagName);
+
+ object = ja.opt(1);
+ if (object instanceof JSONObject) {
+ i = 2;
+ jo = (JSONObject)object;
+
+// Emit the attributes
+
+ keys = jo.keys();
+ while (keys.hasNext()) {
+ key = keys.next().toString();
+ XML.noSpace(key);
+ value = jo.optString(key);
+ if (value != null) {
+ sb.append(' ');
+ sb.append(XML.escape(key));
+ sb.append('=');
+ sb.append('"');
+ sb.append(XML.escape(value));
+ sb.append('"');
+ }
+ }
+ } else {
+ i = 1;
+ }
+
+//Emit content in body
+
+ length = ja.length();
+ if (i >= length) {
+ sb.append('/');
+ sb.append('>');
+ } else {
+ sb.append('>');
+ do {
+ object = ja.get(i);
+ i += 1;
+ if (object != null) {
+ if (object instanceof String) {
+ sb.append(XML.escape(object.toString()));
+ } else if (object instanceof JSONObject) {
+ sb.append(toString((JSONObject)object));
+ } else if (object instanceof JSONArray) {
+ sb.append(toString((JSONArray)object));
+ }
+ }
+ } while (i < length);
+ sb.append('<');
+ sb.append('/');
+ sb.append(tagName);
+ sb.append('>');
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Reverse the JSONML transformation, making an XML text from a JSONObject.
+ * The JSONObject must contain a "tagName" property. If it has children,
+ * then it must have a "childNodes" property containing an array of objects.
+ * The other properties are attributes with string values.
+ * @param jo A JSONObject.
+ * @return An XML string.
+ * @throws JSONException
+ */
+ public static String toString(JSONObject jo) throws JSONException {
+ StringBuffer sb = new StringBuffer();
+ int i;
+ JSONArray ja;
+ String key;
+ Iterator keys;
+ int length;
+ Object object;
+ String tagName;
+ String value;
+
+//Emit <tagName
+
+ tagName = jo.optString("tagName");
+ if (tagName == null) {
+ return XML.escape(jo.toString());
+ }
+ XML.noSpace(tagName);
+ tagName = XML.escape(tagName);
+ sb.append('<');
+ sb.append(tagName);
+
+//Emit the attributes
+
+ keys = jo.keys();
+ while (keys.hasNext()) {
+ key = keys.next().toString();
+ if (!"tagName".equals(key) && !"childNodes".equals(key)) {
+ XML.noSpace(key);
+ value = jo.optString(key);
+ if (value != null) {
+ sb.append(' ');
+ sb.append(XML.escape(key));
+ sb.append('=');
+ sb.append('"');
+ sb.append(XML.escape(value));
+ sb.append('"');
+ }
+ }
+ }
+
+//Emit content in body
+
+ ja = jo.optJSONArray("childNodes");
+ if (ja == null) {
+ sb.append('/');
+ sb.append('>');
+ } else {
+ sb.append('>');
+ length = ja.length();
+ for (i = 0; i < length; i += 1) {
+ object = ja.get(i);
+ if (object != null) {
+ if (object instanceof String) {
+ sb.append(XML.escape(object.toString()));
+ } else if (object instanceof JSONObject) {
+ sb.append(toString((JSONObject)object));
+ } else if (object instanceof JSONArray) {
+ sb.append(toString((JSONArray)object));
+ } else {
+ sb.append(object.toString());
+ }
+ }
+ }
+ sb.append('<');
+ sb.append('/');
+ sb.append(tagName);
+ sb.append('>');
+ }
+ return sb.toString();
+ }
+}
[06/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/driver/PulseUITest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/driver/PulseUITest.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/driver/PulseUITest.java
new file mode 100644
index 0000000..c2d55c3
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/driver/PulseUITest.java
@@ -0,0 +1,279 @@
+/*
+ * 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.testbed.driver;
+
+import static com.vmware.geode.tools.pulse.tests.PulseAbstractTest.*;
+import static org.junit.Assert.*;
+
+import java.net.InetAddress;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import org.apache.geode.internal.net.SSLConfigurationFactory;
+import org.apache.geode.internal.security.SecurableCommunicationChannel;
+import org.apache.geode.management.internal.JettyHelper;
+import org.apache.geode.test.junit.categories.UITest;
+import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Locator;
+import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Peer;
+import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Region;
+import com.vmware.geode.tools.pulse.testbed.GemFireDistributedSystem.Server;
+import com.vmware.geode.tools.pulse.testbed.TestBed;
+
+@Ignore("TODO: test is ignored")
+@Category(UITest.class)
+public class PulseUITest {
+
+ private static WebDriver driver;
+ private static TestBed testBed;
+ private static String pulseURL;
+ private static String path;
+ private static org.eclipse.jetty.server.Server jetty = null;
+
+ private static final String userName = "admin";
+ private static final String pasword = "admin";
+
+ private static final String DATA_VIEW_LABEL = "Data View";
+ private static final String CLUSTER_VIEW_MEMBERS_ID = "clusterTotalMembersText";
+ private static final String CLUSTER_VIEW_SERVERS_ID = "clusterServersText";
+ private static final String CLUSTER_VIEW_LOCATORS_ID = "clusterLocatorsText";
+ private static final String CLUSTER_VIEW_REGIONS_ID = "clusterTotalRegionsText";
+
+ @BeforeClass
+ public static void setUpJetty() throws Exception {
+ String host = InetAddress.getLocalHost().getHostAddress();
+ int port = 8080;
+ String context = "/pulse";
+ path = getPulseWarPath();
+ //System.setProperty("pulse.propMockDataUpdaterClass", "com.vmware.geode.tools.pulse.testbed.PropMockDataUpdater");
+
+ jetty = JettyHelper.initJetty(host, port, SSLConfigurationFactory.getSSLConfigForComponent(SecurableCommunicationChannel.WEB));
+ JettyHelper.addWebApplication(jetty, context, getPulseWarPath());
+ jetty.start();
+
+ pulseURL = "http://" + host + ":" + port + context;
+ Thread.sleep(1000); //wait till tomcat settles down
+ driver = new FirefoxDriver();
+ driver.manage().window().maximize();//required to make all elements visible
+
+ Thread.sleep(5000); //wait till pulse starts polling threads...
+ testBed = new TestBed();
+ loginToPulse(driver, userName, pasword);
+ }
+
+ @AfterClass
+ public static void stopJetty() throws Exception {
+ jetty.stop();
+ }
+
+ @After
+ public void closeSession() {
+ driver.close();
+ }
+
+ private static void loginToPulse(WebDriver driver, String userName,String password){
+ driver.get(pulseURL);
+ WebElement userNameElement = driver.findElement(By.id("user_name"));
+ WebElement passwordElement = driver.findElement(By.id("user_password"));
+ userNameElement.sendKeys(userName);
+ passwordElement.sendKeys(password);
+ passwordElement.submit();
+ WebElement userNameOnPulsePage = (new WebDriverWait(driver, 10))
+ .until(new ExpectedCondition<WebElement>() {
+ @Override
+ public WebElement apply(WebDriver d) {
+ return d.findElement(By.id("userName"));
+ }
+ });
+ assertNotNull(userNameOnPulsePage);
+ }
+
+
+ private void searchByLinkAndClick(String linkText){
+ WebElement dataViewButton= By.linkText(linkText).findElement(driver);
+ assertNotNull(dataViewButton);
+ dataViewButton.click();
+ }
+
+ private void searchByIdAndClick(String id){
+ WebElement element = driver.findElement(By.id(id));
+ assertNotNull(element);
+ element.click();
+ }
+
+ private void searchByXPathAndClick(String xpath){
+ WebElement element = driver.findElement(By.xpath(xpath));
+ assertNotNull(element);
+ element.click();
+ }
+
+ private void waitForElementByClassName(final String className, int seconds){
+ WebElement linkTextOnPulsePage1 = (new WebDriverWait(driver, seconds))
+ .until(new ExpectedCondition<WebElement>() {
+ @Override
+ public WebElement apply(WebDriver d) {
+ return d.findElement(By.className(className));
+ }
+ });
+ assertNotNull(linkTextOnPulsePage1);
+ }
+
+ private void waitForElementById(final String id, int seconds){
+ WebElement element = (new WebDriverWait(driver, 10))
+ .until(new ExpectedCondition<WebElement>() {
+ @Override
+ public WebElement apply(WebDriver d) {
+ return d.findElement(By.id(id));
+ }
+ });
+ assertNotNull(element);
+ }
+
+ @Test
+ public void testClusterViewTopRibbon() {
+ List<Server> servers = testBed.getRootDs().getServers();
+ List<Locator> locators = testBed.getRootDs().getLocators();
+ List<Peer> peers = testBed.getRootDs().getPeers();
+ List<Region> regions = testBed.getRootDs().getRegions();
+ int totalMembers = servers.size() + locators.size() + peers.size();
+ int clusterMembers = Integer.parseInt(driver.findElement(
+ By.id(CLUSTER_VIEW_MEMBERS_ID)).getText());
+ int clusterServers = Integer.parseInt(driver.findElement(
+ By.id(CLUSTER_VIEW_SERVERS_ID)).getText());
+ int clusterLocators = Integer.parseInt(driver.findElement(
+ By.id(CLUSTER_VIEW_LOCATORS_ID)).getText());
+ int clusterRegions = Integer.parseInt(driver.findElement(
+ By.id(CLUSTER_VIEW_REGIONS_ID)).getText());
+ assertEquals(totalMembers, clusterMembers);
+ assertEquals(servers.size(), clusterServers);
+ assertEquals(locators.size(), clusterLocators);
+ assertEquals(regions.size(), clusterRegions);
+ }
+
+
+ @Test
+ public void testDataViewRegionProperties() {
+ searchByLinkAndClick(DATA_VIEW_LABEL);
+ waitForElementByClassName("pointDetailsPadding",10);
+ searchByIdAndClick("btngridIcon");
+
+ for(int i=1;i<testBed.getRootDs().getRegions().size();i++){
+ searchByIdAndClick(""+i);
+ String regionName1 = driver.findElement(By.id("regionName")).getText();
+ @SuppressWarnings("rawtypes")
+ List regionMemberscount1 = testBed.getRootDs().getRegion(regionName1)
+ .getMembers();
+ int regionEntCount1 = testBed.getRootDs().getRegion(regionName1)
+ .getEntryCount();
+ int regionMembers1 = Integer.parseInt(driver.findElement(
+ By.id("regionMembers")).getText());
+ int regionEntryCount1 = Integer.parseInt(driver.findElement(
+ By.id("regionEntryCount")).getText());
+ assertEquals(regionMemberscount1.size(), regionMembers1);
+ assertEquals(regionEntCount1, regionEntryCount1);
+ }
+ }
+
+
+ @Test
+ public void testMemberViewRegions() {
+
+ searchByLinkAndClick(DATA_VIEW_LABEL);
+ waitForElementByClassName("pointDetailsPadding",10);
+ searchByXPathAndClick("//div[@title='peer1']");
+ waitForElementById("memberRegionsCount",10);
+
+ List<Server> servers = testBed.getRootDs().getServers();
+ List<Locator> locators = testBed.getRootDs().getLocators();
+ List<Peer> peers = testBed.getRootDs().getPeers();
+
+ String prevSelectedMember = "peer1";
+
+ for (Peer p : peers) {
+ String peer = p.getName();
+ System.out.println("Checking regions mapping for member " + peer);
+ WebElement comboBox = driver.findElement(By.linkText(prevSelectedMember));
+ comboBox.click();
+ WebElement comboList = driver.findElement(By.id("clusterMembersContainer"));
+ WebElement selectedMember = comboList.findElement(By.linkText(peer));
+ selectedMember.click();
+ timeout();
+ String peername = driver.findElement(By.id("memberName")).getText();
+ List<Region> peerRegionscount = testBed.getRootDs().getRegions(peer);
+ int peerRegions = Integer.parseInt(driver.findElement(
+ By.id("memberRegionsCount")).getText());
+ assertEquals(peerRegionscount.size(), peerRegions);
+ prevSelectedMember = peername;
+ }
+
+ for (Server s : servers) {
+ String server = s.getName();
+ System.out.println("Checking regions mapping for server " + server);
+ WebElement comboBox = driver.findElement(By.linkText(prevSelectedMember));
+ comboBox.click();
+ WebElement comboList = driver.findElement(By.id("clusterMembersContainer"));
+ WebElement selectedMember = comboList.findElement(By.linkText(server));
+ selectedMember.click();
+ timeout();
+ String peername = driver.findElement(By.id("memberName")).getText();
+ List<Region> serverRegionscount = testBed.getRootDs().getRegions(server);
+ int serverRegions = Integer.parseInt(driver.findElement(
+ By.id("memberRegionsCount")).getText());
+ assertEquals(serverRegionscount.size(), serverRegions);
+ prevSelectedMember = peername;
+ }
+ /*
+ for (Locator l : locators) {
+ String locator = l.getName();
+ System.out.println("Checking regions mapping for locator " + locator);
+ WebElement comboBox = driver.findElement(By.linkText(prevSelectedMember));
+ comboBox.click();
+ WebElement comboList = driver.findElement(By.id("clusterMembersContainer"));
+ WebElement selectedMember = comboList.findElement(By.linkText(locator));
+ selectedMember.click();
+ timeout();
+ String peername = driver.findElement(By.id("memberName")).getText();
+ List<Region> locatorRegionscount = testBed.getRootDs().getRegions(locator);
+ int locatorRegions = Integer.parseInt(driver.findElement(
+ By.id("memberRegionsCount")).getText());
+ assertIndexDetailsEquals(locatorRegionscount.size(), locatorRegions);
+ prevSelectedMember = peername;
+ }*/
+ }
+
+ public void timeout() {
+ WebElement memberNameOnPulsePage = (new WebDriverWait(driver, 10))
+ .until(new ExpectedCondition<WebElement>() {
+ @Override
+ public WebElement apply(WebDriver d) {
+ return d.findElement(By.id("memberName"));
+ }
+ });
+ assertNotNull(memberNameOnPulsePage);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatement.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatement.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatement.java
new file mode 100644
index 0000000..ebd310d
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatement.java
@@ -0,0 +1,217 @@
+/*
+ *
+ * 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.tests;
+
+public class AggregateStatement extends JMXBaseBean implements AggregateStatementMBean {
+ private String name = null;
+
+ public AggregateStatement(String name) {
+ this.name = name;
+ }
+
+ protected String getKey(String propName) {
+ return "aggregatestatement." + name + "." + propName;
+ }
+
+ /**
+ * Query definition
+ *
+ * @return
+ */
+ public String getQueryDefinition(){
+ return getString("queryDefinition");
+ }
+
+ /**
+ * Number of times this statement is compiled (including re compilations)
+ *
+ * @return
+ */
+ @Override
+ public long getNumTimesCompiled(){
+ return getLong("numTimesCompiled");
+ }
+
+ /**
+ * Number of times this statement is executed
+ *
+ * @return
+ */
+ @Override
+ public long getNumExecution(){
+ return getLong("numExecution");
+ }
+
+ /**
+ * Statements that are actively being processed during the statistics snapshot
+ *
+ * @return
+ */
+ public long getNumExecutionsInProgress(){
+ return getLong("numExecutionsInProgress");
+ }
+
+ /**
+ * Number of times global index lookup message exchanges occurred
+ *
+ * @return
+ */
+ public long getNumTimesGlobalIndexLookup(){
+ return getLong("numTimesGlobalIndexLookup");
+ }
+
+ /**
+ * Number of rows modified by DML operation of insert/delete/update
+ *
+ * @return
+ */
+ public long getNumRowsModified(){
+ return getLong("numRowsModified");
+ }
+
+ /**
+ * Time spent(in milliseconds) in parsing the query string
+ *
+ * @return
+ */
+ public long getParseTime(){
+ return getLong("parseTime");
+ }
+
+ /**
+ * Time spent (in milliseconds) mapping this statement with database object's metadata (bind)
+ *
+ * @return
+ */
+ public long getBindTime(){
+ return getLong("bindTime");
+ }
+
+ /**
+ * Time spent (in milliseconds) determining the best execution path for this statement
+ * (optimize)
+ *
+ * @return
+ */
+ public long getOptimizeTime(){
+ return getLong("optimizeTime");
+ }
+
+ /**
+ * Time spent (in milliseconds) compiling details about routing information of query strings to
+ * data node(s) (processQueryInfo)
+ *
+ * @return
+ */
+ public long getRoutingInfoTime(){
+ return getLong("routingInfoTime");
+ }
+
+ /**
+ * Time spent (in milliseconds) to generate query execution plan definition (activation class)
+ *
+ * @return
+ */
+ public long getGenerateTime(){
+ return getLong("generateTime");
+ }
+
+ /**
+ * Total compilation time (in milliseconds) of the statement on this node (prepMinion)
+ *
+ * @return
+ */
+ public long getTotalCompilationTime(){
+ return getLong("totalCompilationTime");
+ }
+
+ /**
+ * Time spent (in nanoseconds) in creation of all the layers of query processing (ac.execute)
+ *
+ * @return
+ */
+ public long getExecutionTime(){
+ return getLong("executionTime");
+ }
+
+ /**
+ * Time to apply (in nanoseconds) the projection and additional filters. (projectrestrict)
+ *
+ * @return
+ */
+ public long getProjectionTime(){
+ return getLong("projectionTime");
+ }
+
+ /**
+ * Total execution time (in nanoseconds) taken to process the statement on this node
+ * (execute/open/next/close)
+ *
+ * @return
+ */
+ public long getTotalExecutionTime(){
+ return getLong("totalExecutionTime");
+ }
+
+ /**
+ * Time taken (in nanoseconds) to modify rows by DML operation of insert/delete/update
+ *
+ * @return
+ */
+ public long getRowsModificationTime(){
+ return getLong("rowsModificationTime");
+ }
+
+ /**
+ * Number of rows returned from remote nodes (ResultHolder/Get convertibles)
+ *
+ * @return
+ */
+ public long getQNNumRowsSeen(){
+ return getLong("qnNumRowsSeen");
+ }
+
+ /**
+ * TCP send time (in nanoseconds) of all the messages including serialization time and queue
+ * wait time
+ *
+ * @return
+ */
+ public long getQNMsgSendTime(){
+ return getLong("qnMsgSendTime");
+ }
+
+ /**
+ * Serialization time (in nanoseconds) for all the messages while sending to remote node(s)
+ *
+ * @return
+ */
+ public long getQNMsgSerTime(){
+ return getLong("qnMsgSerTime");
+ }
+
+ /**
+ *
+ *
+ * @return
+ */
+ public long getQNRespDeSerTime(){
+ return getLong("qnRespDeSerTime");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatementMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatementMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatementMBean.java
new file mode 100644
index 0000000..b58b53b
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/AggregateStatementMBean.java
@@ -0,0 +1,168 @@
+/*
+ *
+ * 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.tests;
+
+public interface AggregateStatementMBean {
+ String OBJECT_NAME = "GemFireXD:service=Statement,type=Aggregate";
+
+ /**
+ * Query definition
+ *
+ * @return
+ */
+ String getQueryDefinition();
+
+ /**
+ * Number of times this statement is compiled (including re compilations)
+ *
+ * @return
+ */
+ long getNumTimesCompiled();
+
+ /**
+ * Number of times this statement is executed
+ *
+ * @return
+ */
+ long getNumExecution();
+
+ /**
+ * Statements that are actively being processed during the statistics snapshot
+ *
+ * @return
+ */
+ long getNumExecutionsInProgress();
+
+ /**
+ * Number of times global index lookup message exchanges occurred
+ *
+ * @return
+ */
+ long getNumTimesGlobalIndexLookup();
+
+ /**
+ * Number of rows modified by DML operation of insert/delete/update
+ *
+ * @return
+ */
+ long getNumRowsModified();
+
+ /**
+ * Time spent(in milliseconds) in parsing the query string
+ *
+ * @return
+ */
+ long getParseTime();
+
+ /**
+ * Time spent (in milliseconds) mapping this statement with database object's metadata (bind)
+ *
+ * @return
+ */
+ long getBindTime();
+
+ /**
+ * Time spent (in milliseconds) determining the best execution path for this statement
+ * (optimize)
+ *
+ * @return
+ */
+ long getOptimizeTime();
+
+ /**
+ * Time spent (in milliseconds) compiling details about routing information of query strings to
+ * data node(s) (processQueryInfo)
+ *
+ * @return
+ */
+ long getRoutingInfoTime();
+
+ /**
+ * Time spent (in milliseconds) to generate query execution plan definition (activation class)
+ *
+ * @return
+ */
+ long getGenerateTime();
+
+ /**
+ * Total compilation time (in milliseconds) of the statement on this node (prepMinion)
+ *
+ * @return
+ */
+ long getTotalCompilationTime();
+
+ /**
+ * Time spent (in nanoseconds) in creation of all the layers of query processing (ac.execute)
+ *
+ * @return
+ */
+ long getExecutionTime();
+
+ /**
+ * Time to apply (in nanoseconds) the projection and additional filters. (projectrestrict)
+ *
+ * @return
+ */
+ long getProjectionTime();
+
+ /**
+ * Total execution time (in nanoseconds) taken to process the statement on this node
+ * (execute/open/next/close)
+ *
+ * @return
+ */
+ long getTotalExecutionTime();
+
+ /**
+ * Time taken (in nanoseconds) to modify rows by DML operation of insert/delete/update
+ *
+ * @return
+ */
+ long getRowsModificationTime();
+
+ /**
+ * Number of rows returned from remote nodes (ResultHolder/Get convertibles)
+ *
+ * @return
+ */
+ long getQNNumRowsSeen();
+
+ /**
+ * TCP send time (in nanoseconds) of all the messages including serialization time and queue
+ * wait time
+ *
+ * @return
+ */
+ long getQNMsgSendTime();
+
+ /**
+ * Serialization time (in nanoseconds) for all the messages while sending to remote node(s)
+ *
+ * @return
+ */
+ long getQNMsgSerTime();
+
+ /**
+ *
+ *
+ * @return
+ */
+ long getQNRespDeSerTime();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/DataBrowserResultLoader.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/DataBrowserResultLoader.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/DataBrowserResultLoader.java
new file mode 100644
index 0000000..09fbda3
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/DataBrowserResultLoader.java
@@ -0,0 +1,84 @@
+/*
+ *
+ * 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.tests;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+public class DataBrowserResultLoader {
+ private static DataBrowserResultLoader dbResultLoader = new DataBrowserResultLoader();
+
+ public static DataBrowserResultLoader getInstance() {
+ return dbResultLoader;
+ }
+
+ public String load(String queryString) throws IOException {
+
+ URL url = null;
+ InputStream inputStream = null;
+ BufferedReader streamReader = null;
+ String inputStr = null;
+ StringBuilder sampleQueryResultResponseStrBuilder = null;
+
+ try {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+ if (queryString.equals(PulseAbstractTest.QUERY_TYPE_ONE)) {
+ url = classLoader.getResource("testQueryResultClusterSmall.txt");
+ } else if (queryString.equals(PulseAbstractTest.QUERY_TYPE_TWO)) {
+ url = classLoader.getResource("testQueryResultSmall.txt");
+ } else if (queryString.equals(PulseAbstractTest.QUERY_TYPE_THREE)) {
+ url = classLoader.getResource("testQueryResult.txt");
+ } else if (queryString.equals(PulseAbstractTest.QUERY_TYPE_FOUR)) {
+ url = classLoader.getResource("testQueryResultWithStructSmall.txt");
+ } else if (queryString.equals(PulseAbstractTest.QUERY_TYPE_FIVE)) {
+ url = classLoader.getResource("testQueryResultClusterWithStruct.txt");
+ } else if (queryString.equals(PulseAbstractTest.QUERY_TYPE_SIX)) {
+ url = classLoader.getResource("testQueryResultHashMapSmall.txt");
+ } else if (queryString.equals(PulseAbstractTest.QUERY_TYPE_SEVENE)) {
+ url = classLoader.getResource("testQueryResult1000.txt");
+ } else {
+ url = classLoader.getResource("testQueryResult.txt");
+ }
+
+ File sampleQueryResultFile = new File(url.getPath());
+ inputStream = new FileInputStream(sampleQueryResultFile);
+ streamReader = new BufferedReader(new InputStreamReader(inputStream,
+ "UTF-8"));
+ sampleQueryResultResponseStrBuilder = new StringBuilder();
+
+ while ((inputStr = streamReader.readLine()) != null) {
+ sampleQueryResultResponseStrBuilder.append(inputStr);
+ }
+
+ // close stream reader
+ streamReader.close();
+
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+
+ return sampleQueryResultResponseStrBuilder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTable.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTable.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTable.java
new file mode 100644
index 0000000..957d074
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTable.java
@@ -0,0 +1,46 @@
+/*
+ *
+ * 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.tests;
+
+import javax.management.NotificationBroadcasterSupport;
+
+public class GemFireXDAggregateTable extends NotificationBroadcasterSupport
+ implements GemFireXDAggregateTableMBean {
+ private String name = null;
+
+ public GemFireXDAggregateTable(String name) {
+ this.name = name;
+ }
+
+ private String getKey(String propName) {
+ return "table." + name + "." + propName;
+ }
+
+ @Override
+ public long getEntrySize() {
+ return Long.parseLong(JMXProperties.getInstance().getProperty(
+ getKey("EntrySize")));
+ }
+
+ @Override
+ public int getNumberOfRows() {
+ return Integer.parseInt(JMXProperties.getInstance().getProperty(
+ getKey("NumberOfRows")));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTableMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTableMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTableMBean.java
new file mode 100644
index 0000000..db0f45d
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDAggregateTableMBean.java
@@ -0,0 +1,28 @@
+/*
+ *
+ * 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.tests;
+
+public interface GemFireXDAggregateTableMBean {
+ public static final String OBJECT_NAME = "GemFireXD:service=Table,type=Aggregate,table=";
+
+ public long getEntrySize();
+
+ public int getNumberOfRows();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDCluster.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDCluster.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDCluster.java
new file mode 100644
index 0000000..a2b1edc
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDCluster.java
@@ -0,0 +1,95 @@
+/*
+ *
+ * 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.tests;
+
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+
+public class GemFireXDCluster extends NotificationBroadcasterSupport implements
+ GemFireXDClusterMBean {
+ private String name = null;
+
+ private static String[] itemNames = { "connectionsAttempted",
+ "connectionsActive", "connectionsClosed", "connectionsFailed" };;
+ private static String[] itemDescriptions = { "connectionsAttempted",
+ "connectionsActive", "connectionsClosed", "connectionsFailed" };
+ private static OpenType[] itemTypes = { SimpleType.LONG, SimpleType.LONG,
+ SimpleType.LONG, SimpleType.LONG };
+ private static CompositeType networkServerClientConnectionStats = null;
+
+ static {
+ try {
+ networkServerClientConnectionStats = new CompositeType(
+ "NetworkServerClientConnectionStats",
+ "Network Server Client Connection Stats Information", itemNames,
+ itemDescriptions, itemTypes);
+
+ } catch (OpenDataException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public GemFireXDCluster(String name) {
+ this.name = name;
+ }
+
+ private String getKey(String propName) {
+ return "gemfirexd." + name + "." + propName;
+ }
+
+ @Override
+ public int getProcedureCallsCompleted() {
+ return Integer.parseInt(JMXProperties.getInstance().getProperty(
+ getKey("ProcedureCallsCompleted")));
+ }
+
+ @Override
+ public int getProcedureCallsInProgress() {
+ return Integer.parseInt(JMXProperties.getInstance().getProperty(
+ getKey("ProcedureCallsInProgress")));
+ }
+
+ @Override
+ public CompositeData getNetworkServerClientConnectionStats() {
+ String value = JMXProperties.getInstance().getProperty(
+ getKey("NetworkServerClientConnectionStats"), "");
+ String[] values = value.split(",");
+ Long[] itemValues = new Long[values.length];
+ for (int i = 0; i < values.length; i++) {
+ itemValues[i] = Long.parseLong(values[i]);
+ }
+
+ CompositeData nscCompData;
+ try {
+ nscCompData = new CompositeDataSupport(
+ networkServerClientConnectionStats, itemNames, itemValues);
+ } catch (OpenDataException e) {
+ e.printStackTrace();
+ nscCompData = null;
+ }
+ return nscCompData;
+
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDClusterMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDClusterMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDClusterMBean.java
new file mode 100644
index 0000000..5a42d10
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDClusterMBean.java
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.tests;
+
+import javax.management.openmbean.CompositeData;
+
+public interface GemFireXDClusterMBean {
+ public static final String OBJECT_NAME = "GemFireXD:service=Cluster";
+
+ public int getProcedureCallsCompleted();
+
+ public int getProcedureCallsInProgress();
+
+ public CompositeData getNetworkServerClientConnectionStats();
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMember.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMember.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMember.java
new file mode 100644
index 0000000..16da77d
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMember.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.tests;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+
+public class GemFireXDMember extends JMXBaseBean implements
+ GemFireXDMemberMBean {
+ private String name = null;
+
+ private static String[] itemNames = { "connectionsAttempted",
+ "connectionsActive", "connectionsClosed", "connectionsFailed" };;
+ private static String[] itemDescriptions = { "connectionsAttempted",
+ "connectionsActive", "connectionsClosed", "connectionsFailed" };
+ private static OpenType[] itemTypes = { SimpleType.LONG, SimpleType.LONG,
+ SimpleType.LONG, SimpleType.LONG };
+ private static CompositeType networkServerClientConnectionStats = null;
+
+ static {
+ try {
+ networkServerClientConnectionStats = new CompositeType(
+ "NetworkServerClientConnectionStats",
+ "Network Server Client Connection Stats Information", itemNames,
+ itemDescriptions, itemTypes);
+
+ } catch (OpenDataException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public GemFireXDMember(String name) {
+ this.name = name;
+ }
+
+ @Override
+ protected String getKey(String propName) {
+ return "gemfirexdmember." + name + "." + propName;
+ }
+
+ @Override
+ public boolean getDataStore() {
+ return getBoolean("DataStore");
+ }
+
+ @Override
+ public CompositeData getNetworkServerClientConnectionStats() {
+ Long[] itemValues = getLongArray("NetworkServerClientConnectionStats");
+ CompositeData nscCompData;
+ try {
+ nscCompData = new CompositeDataSupport(
+ networkServerClientConnectionStats, itemNames, itemValues);
+ } catch (OpenDataException e) {
+ e.printStackTrace();
+ nscCompData = null;
+ }
+ return nscCompData;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMemberMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMemberMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMemberMBean.java
new file mode 100644
index 0000000..ceda56d
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/GemFireXDMemberMBean.java
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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.tests;
+
+import javax.management.openmbean.CompositeData;
+
+public interface GemFireXDMemberMBean {
+
+ public static final String OBJECT_NAME = "GemFireXD:group=DEFAULT,type=Member";
+
+ public boolean getDataStore();
+
+ public CompositeData getNetworkServerClientConnectionStats();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXBaseBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXBaseBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXBaseBean.java
new file mode 100644
index 0000000..2d1ffad
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXBaseBean.java
@@ -0,0 +1,67 @@
+/*
+ *
+ * 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.tests;
+
+public abstract class JMXBaseBean {
+
+ protected abstract String getKey(String propName);
+
+ protected String getString(String key) {
+ return JMXProperties.getInstance().getProperty(getKey(key));
+ }
+
+ protected String[] getStringArray(String key) {
+ return JMXProperties.getInstance().getProperty(getKey(key), "").split(" ");
+ }
+
+ protected boolean getBoolean(String key) {
+ return Boolean.parseBoolean(JMXProperties.getInstance().getProperty(
+ getKey(key)));
+ }
+
+ protected int getInt(String key) {
+ return Integer.parseInt(JMXProperties.getInstance()
+ .getProperty(getKey(key)));
+ }
+
+ protected long getLong(String key) {
+ return Long.parseLong(JMXProperties.getInstance().getProperty(getKey(key)));
+ }
+
+ protected Long[] getLongArray(String key) {
+ String value = JMXProperties.getInstance().getProperty(getKey(key), "");
+ String[] values = value.split(",");
+ Long[] longValues = new Long[values.length];
+ for (int i = 0; i < values.length; i++) {
+ longValues[i] = Long.parseLong(values[i]);
+ }
+ return longValues;
+ }
+
+ protected double getDouble(String key) {
+ return Double.parseDouble(JMXProperties.getInstance().getProperty(
+ getKey(key)));
+ }
+
+ protected float getFloat(String key) {
+ return Float.parseFloat(JMXProperties.getInstance()
+ .getProperty(getKey(key)));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXProperties.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXProperties.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXProperties.java
new file mode 100644
index 0000000..1562594
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/JMXProperties.java
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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.tests;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+public class JMXProperties extends Properties {
+ private static final long serialVersionUID = -6210901350494570026L;
+
+ private static JMXProperties props = new JMXProperties();
+
+ public static JMXProperties getInstance() {
+ return props;
+ }
+
+ public void load(String propFile) throws IOException {
+ if (propFile != null) {
+ FileInputStream fin;
+ fin = new FileInputStream(new File(propFile));
+ if (fin != null) {
+ clear();
+ load(fin);
+ }
+
+ fin.close();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Member.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Member.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Member.java
new file mode 100644
index 0000000..1192297
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/Member.java
@@ -0,0 +1,193 @@
+/*
+ *
+ * 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.tests;
+
+public class Member extends JMXBaseBean implements MemberMBean {
+ private String name = null;
+
+ public Member(String name) {
+ this.name = name;
+ }
+
+ protected String getKey(String propName) {
+ return "member." + name + "." + propName;
+ }
+
+ @Override
+ public boolean getManager() {
+ return getBoolean("manager");
+ }
+
+ @Override
+ public int getTotalRegionCount() {
+// This count is built dynamically in Pulse backend and region count is maintained in Cluster.Member data structure
+// return getInt("totalRegionCount");
+ return 0;
+ }
+
+ @Override
+ public boolean getLocator() {
+ return getBoolean("locator");
+ }
+
+ @Override
+ public long getTotalDiskUsage() {
+ return getLong("totalDiskUsage");
+ }
+
+ @Override
+ public boolean getServer() {
+ return getBoolean("sever");
+ }
+
+ @Override
+ public String[] getGroups() {
+ return getStringArray("Groups");
+ }
+
+ @Override
+ /*public String[] getRedundancyZone() {
+ return getStringArray("RedundancyZone");
+ }*/
+ public String getRedundancyZone() {
+ return getString("RedundancyZone");
+ }
+
+ @Override
+ public long getTotalFileDescriptorOpen() {
+ return getLong("totalFileDescriptorOpen");
+ }
+
+ @Override
+ public double getLoadAverage() {
+ return getDouble("loadAverage");
+ }
+
+ @Override
+ public double getDiskWritesRate() {
+ return getDouble("diskWritesRate");
+ }
+
+ @Override
+ public long getJVMPauses() {
+ return getLong("JVMPauses");
+ }
+
+ @Override
+ public long getCurrentHeapSize() {
+// return getLong("currentHeapSize");
+ return getLong("UsedMemory");
+ }
+
+ @Override
+ public long getMaximumHeapSize() {
+// return getLong("maximumHeapSize");
+ return getLong("MaxMemory");
+ }
+
+ @Override
+ public long getUsedMemory() {
+ return getLong("UsedMemory");
+ }
+
+ @Override
+ public long getMaxMemory() {
+ return getLong("MaxMemory");
+ }
+
+ @Override
+ public int getNumThreads() {
+ return getInt("numThreads");
+ }
+
+ @Override
+ public long getMemberUpTime() {
+ return getLong("memberUpTime");
+ }
+
+ @Override
+ public String getHost() {
+ return getString("host");
+ }
+
+ @Override
+ public long getTotalBytesOnDisk() {
+ return getLong("totalBytesOnDisk");
+ }
+
+ @Override
+ public double getCpuUsage() {
+ return getDouble("cpuUsage");
+ }
+
+ @Override
+ public String getMember() {
+ return getString("member");
+ }
+
+ @Override
+ public String getId() {
+ return getString("id");
+ }
+
+ @Override
+ public double getAverageReads() {
+ return getDouble("averageReads");
+ }
+
+ @Override
+ public double getAverageWrites() {
+ return getDouble("averageWrites");
+ }
+
+ @Override
+ public int getPort() {
+ return getInt("port");
+ }
+
+ @Override
+ public long getFoo() {
+ return getLong("foo");
+ }
+
+ @Override
+ public long getOffHeapFreeSize() {
+ return getLong("OffHeapFreeSize");
+ }
+
+ @Override
+ public long getOffHeapUsedSize() {
+ return getLong("OffHeapUsedSize");
+ }
+
+ @Override
+ public long getOffHeapFreeMemory() {
+ return getLong("OffHeapFreeMemory");
+ }
+
+ @Override
+ public long getOffHeapUsedMemory() {
+ return getLong("OffHeapUsedMemory");
+ }
+
+ @Override
+ public String getVersion() {
+ return getString("Version");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/MemberMBean.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/MemberMBean.java b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/MemberMBean.java
new file mode 100644
index 0000000..6051270
--- /dev/null
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/tests/MemberMBean.java
@@ -0,0 +1,86 @@
+/*
+ *
+ * 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.tests;
+
+public interface MemberMBean {
+ String OBJECT_NAME = "GemFire:type=Member";
+
+ boolean getManager();
+
+ int getTotalRegionCount();
+
+ boolean getLocator();
+
+ long getTotalDiskUsage();
+
+ boolean getServer();
+
+ String[] getGroups();
+
+ //public String[] getRedundancyZone();
+ String getRedundancyZone();
+
+ long getTotalFileDescriptorOpen();
+
+ double getLoadAverage();
+
+ double getDiskWritesRate();
+
+ long getJVMPauses();
+
+ long getCurrentHeapSize();
+
+ long getMaximumHeapSize();
+
+ long getUsedMemory();
+
+ long getMaxMemory();
+
+ int getNumThreads();
+
+ long getMemberUpTime();
+
+ String getHost();
+
+ long getTotalBytesOnDisk();
+
+ double getCpuUsage();
+
+ String getMember();
+
+ String getId();
+
+ double getAverageReads();
+
+ double getAverageWrites();
+
+ int getPort();
+
+ long getFoo();
+
+ long getOffHeapFreeSize();
+
+ long getOffHeapUsedSize();
+
+ long getOffHeapFreeMemory();
+
+ long getOffHeapUsedMemory();
+
+ String getVersion();
+}
[10/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseAbstractTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseAbstractTest.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseAbstractTest.java
deleted file mode 100644
index cc38c47..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseAbstractTest.java
+++ /dev/null
@@ -1,1049 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import static org.junit.Assert.*;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.DecimalFormat;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import com.jayway.awaitility.Awaitility;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.JavascriptExecutor;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.firefox.FirefoxDriver;
-import org.openqa.selenium.interactions.Actions;
-import org.openqa.selenium.support.ui.ExpectedCondition;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-
-import org.apache.geode.internal.net.SSLConfigurationFactory;
-import org.apache.geode.internal.security.SecurableCommunicationChannel;
-import org.apache.geode.management.internal.JettyHelper;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-
-@SuppressWarnings("deprecated")
-public abstract class PulseAbstractTest extends PulseBaseTest {
-
- private static String jmxPropertiesFile;
- private static String path;
-
- private static org.eclipse.jetty.server.Server jetty = null;
- private static Server server = null;
- private static String pulseURL = null;
- public static WebDriver driver;
-
- /* Constants for executing Data Browser queries */
- public static final String QUERY_TYPE_ONE = "query1";
- public static final String QUERY_TYPE_TWO = "query2";
- public static final String QUERY_TYPE_THREE = "query3";
- public static final String QUERY_TYPE_FOUR = "query4";
- public static final String QUERY_TYPE_FIVE = "query5";
- public static final String QUERY_TYPE_SIX = "query6";
- public static final String QUERY_TYPE_SEVENE = "query7";
-
- private static final String DATA_VIEW_LABEL = "Data View";
- private static final String CLUSTER_VIEW_MEMBERS_ID = "clusterTotalMembersText";
- private static final String CLUSTER_VIEW_SERVERS_ID = "clusterServersText";
- private static final String CLUSTER_VIEW_LOCATORS_ID = "clusterLocatorsText";
- private static final String CLUSTER_VIEW_REGIONS_ID = "clusterTotalRegionsText";
- private static final String CLUSTER_CLIENTS_ID = "clusterClientsText";
- private static final String CLUSTER_FUNCTIONS_ID = "clusterFunctions";
- private static final String CLUSTER_UNIQUECQS_ID = "clusterUniqueCQs";
- private static final String CLUSTER_SUBSCRIPTION_ID = "clusterSubscriptionsText";
- private static final String CLUSTER_MEMORY_USAGE_ID = "currentMemoryUsage";
- private static final String CLUSTER_THROUGHPUT_WRITES_ID = "currentThroughputWrites";
- private static final String CLUSTER_GCPAUSES_ID = "currentGCPauses";
- private static final String CLUSTER_WRITEPERSEC_ID = "writePerSec";
- private static final String CLUSTER_READPERSEC_ID = "readPerSec";
- private static final String CLUSTER_QUERIESPERSEC_ID = "queriesPerSec";
- private static final String CLUSTER_PROCEDURE_ID = "clusterTxnCommittedText";
- private static final String CLUSTER_TXNCOMMITTED_ID = "clusterTxnCommittedText";
- private static final String CLUSTER_TXNROLLBACK_ID = "clusterTxnRollbackText";
- private static final String MEMBER_VIEW_MEMBERNAME_ID = "memberName";
- private static final String MEMBER_VIEW_REGION_ID = "memberRegionsCount";
- private static final String MEMBER_VIEW_THREAD_ID = "threads";
- private static final String MEMBER_VIEW_SOCKETS_ID = "sockets";
- private static final String MEMBER_VIEW_LOADAVG_ID = "loadAverage";
- private static final String MEMBER_VIEW_LISTENINGPORT_ID = "receiverListeningPort";
- private static final String MEMBER_VIEW_LINKTHROUGHPUT_ID = "receiverLinkThroughput";
- private static final String MEMBER_VIEW_AVGBATCHLATENCY_ID = "receiverAvgBatchLatency";
- private static final String MEMBER_VIEW_HEAPUSAGE_ID = "memberHeapUsageAvg";
- private static final String MEMBER_VIEW_JVMPAUSES_ID = "memberGcPausesAvg";
- private static final String MEMBER_VIEW_CPUUSAGE_ID = "memberCPUUsageValue";
- private static final String MEMBER_VIEW_READPERSEC_ID = "memberGetsPerSecValue";
- private static final String MEMBER_VIEW_WRITEPERSEC_ID = "memberPutsPerSecValue";
- private static final String MEMBER_VIEW_OFFHEAPFREESIZE_ID = "offHeapFreeSize";
- private static final String MEMBER_VIEW_OFFHEAPUSEDSIZE_ID = "offHeapUsedSize";
- private static final String MEMBER_VIEW_CLIENTS_ID = "clusterClientsText";
-
- private static final String REGION_NAME_LABEL = "regionName";
- private static final String REGION_PATH_LABEL = "regionPath";
- private static final String REGION_TYPE_LABEL = "regionType";
- private static final String DATA_VIEW_WRITEPERSEC = "regionWrites";
- private static final String DATA_VIEW_READPERSEC = "regionReads";
- private static final String DATA_VIEW_EMPTYNODES = "regionEmptyNodes";
- private static final String DATA_VIEW_ENTRYCOUNT = "regionEntryCount";
- private static final String REGION_PERSISTENCE_LABEL = "regionPersistence";
- private static final String DATA_VIEW_USEDMEMORY = "memoryUsed";
- private static final String DATA_VIEW_TOTALMEMORY = "totalMemory";
-
- private static final String DATA_BROWSER_LABEL = "Data Browser";
- private static final String DATA_BROWSER_REGIONName1 = "treeDemo_1_span";
- private static final String DATA_BROWSER_REGIONName2 = "treeDemo_2_span";
- private static final String DATA_BROWSER_REGIONName3 = "treeDemo_3_span";
- private static final String DATA_BROWSER_REGION1_CHECKBOX = "treeDemo_1_check";
- private static final String DATA_BROWSER_REGION2_CHECKBOX = "treeDemo_2_check";
- private static final String DATA_BROWSER_REGION3_CHECKBOX = "treeDemo_3_check";
- private static final String DATA_BROWSER_COLOCATED_REGION = "Colocated Regions";
- private static final String DATA_BROWSER_COLOCATED_REGION_NAME1 = "treeDemo_1_span";
- private static final String DATA_BROWSER_COLOCATED_REGION_NAME2 = "treeDemo_2_span";
- private static final String DATA_BROWSER_COLOCATED_REGION_NAME3 = "treeDemo_3_span";
-
- private static final String QUERY_STATISTICS_LABEL = "Query Statistics";
- private static final String CLUSTER_VIEW_LABEL = "Cluster View";
- private static final String CLUSTER_VIEW_GRID_ID = "default_treemap_button";
- private static final String SERVER_GROUP_GRID_ID = "servergroups_treemap_button";
- private static final String REDUNDANCY_GRID_ID = "redundancyzones_treemap_button";
- private static final String MEMBER_DROPDOWN_ID = "Members";
- private static final String DATA_DROPDOWN_ID = "Data";
-
- private static final DecimalFormat df2 = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN);
-
- public static void setUpServer(String username, String password, String jsonAuthFile) throws Exception {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
- jmxPropertiesFile = classLoader.getResource("test.properties").getPath();
- path = getPulseWarPath();
- server = Server.createServer(9999, jmxPropertiesFile, jsonAuthFile);
-
- String host = "localhost";
- int port = 8080;
- String context = "/pulse";
-
- jetty = JettyHelper.initJetty(host, port, SSLConfigurationFactory.getSSLConfigForComponent(SecurableCommunicationChannel.WEB));
- JettyHelper.addWebApplication(jetty, context, getPulseWarPath());
- jetty.start();
-
- pulseURL = "http://" + host + ":" + port + context;
-
- Awaitility.await().until(()->jetty.isStarted());
-
- driver = new FirefoxDriver();
- driver.manage().window().maximize();
- driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
- driver.get(pulseURL);
- WebElement userNameElement = driver.findElement(By.id("user_name"));
- WebElement passwordElement = driver.findElement(By.id("user_password"));
- userNameElement.sendKeys(username);
- passwordElement.sendKeys(password);
- passwordElement.submit();
-
- Thread.sleep(3000);
- WebElement userNameOnPulsePage = (new WebDriverWait(driver, 10))
- .until(new ExpectedCondition<WebElement>() {
- @Override
- public WebElement apply(WebDriver d) {
- return d.findElement(By.id("userName"));
- }
- });
- assertNotNull(userNameOnPulsePage);
- driver.navigate().refresh();
- Thread.sleep(7000);
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- driver.close();
- jetty.stop();
- }
-
- @Before
- public void setup() throws Exception {
- // Make sure we go to the home page first
- searchByXPathAndClick(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- }
-
- public static String getPulseWarPath() throws Exception {
- String warPath = null;
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- InputStream inputStream = classLoader.getResourceAsStream("GemFireVersion.properties");
- Properties properties = new Properties();
- properties.load(inputStream);
- String version = properties.getProperty("Product-Version");
- warPath = "geode-pulse-" + version + ".war";
- String propFilePath = classLoader.getResource("GemFireVersion.properties").getPath();
- warPath = propFilePath.substring(0, propFilePath.indexOf("generated-resources")) + "libs/" + warPath;
- return warPath;
- }
-
- protected void searchByLinkAndClick(String linkText) {
- WebElement element = By.linkText(linkText).findElement(driver);
- assertNotNull(element);
- element.click();
- }
-
- protected void searchByIdAndClick(String id) {
- WebElement element = driver.findElement(By.id(id));
- assertNotNull(element);
- element.click();
- }
-
- protected void searchByClassAndClick(String Class) {
- WebElement element = driver.findElement(By.className(Class));
- assertNotNull(element);
- element.click();
- }
-
- protected void searchByXPathAndClick(String xpath) {
- WebElement element = driver.findElement(By.xpath(xpath));
- assertNotNull(element);
- element.click();
- }
-
- protected void waitForElementByClassName(final String className, int seconds) {
- WebElement linkTextOnPulsePage1 = (new WebDriverWait(driver, seconds))
- .until(new ExpectedCondition<WebElement>() {
- @Override
- public WebElement apply(WebDriver d) {
- return d.findElement(By.className(className));
- }
- });
- assertNotNull(linkTextOnPulsePage1);
- }
-
- protected void waitForElementById(final String id, int seconds) {
- WebElement element = (new WebDriverWait(driver, 10))
- .until(new ExpectedCondition<WebElement>() {
- @Override
- public WebElement apply(WebDriver d) {
- return d.findElement(By.id(id));
- }
- });
- assertNotNull(element);
- }
-
- protected void scrollbarVerticalDownScroll() {
- JavascriptExecutor js = (JavascriptExecutor) driver;
- js.executeScript("javascript:window.scrollBy(250,700)");
- WebElement pickerScroll = driver.findElement(By.className("jspDrag"));
- WebElement pickerScrollCorner = driver.findElement(By
- .className("jspCorner"));
- Actions builder = new Actions(driver);
- Actions movePicker = builder.dragAndDrop(pickerScroll, pickerScrollCorner);
- // pickerscroll is the web element
- movePicker.perform();
- }
-
- protected void scrollbarHorizontalRightScroll() {
- JavascriptExecutor js = (JavascriptExecutor) driver;
- js.executeScript("javascript:window.scrollBy(250,700)");
- WebElement pickerScroll = driver
- .findElement(By
- .xpath("//div[@id='gview_queryStatisticsList']/div[3]/div/div[3]/div[2]/div"));
- WebElement pickerScrollCorner = driver.findElement(By
- .className("jspCorner"));
- Actions builder = new Actions(driver);
- Actions movePicker = builder.dragAndDrop(pickerScroll, pickerScrollCorner);
- // pickerscroll is the web element
- movePicker.perform();
- }
-
-
- @Test
- public void testClusterLocatorCount() throws IOException {
- String clusterLocators = driver
- .findElement(By.id(CLUSTER_VIEW_LOCATORS_ID)).getText();
-
- String totallocators = JMXProperties.getInstance().getProperty("server.S1.locatorCount");
- assertEquals(totallocators, clusterLocators);
- }
-
- @Test
- public void testClusterRegionCount() {
- String clusterRegions = driver.findElement(By.id(CLUSTER_VIEW_REGIONS_ID))
- .getText();
- String totalregions = JMXProperties.getInstance().getProperty(
- "server.S1.totalRegionCount");
- assertEquals(totalregions, clusterRegions);
- }
-
- @Test
- public void testClusterMemberCount() {
- String clusterMembers = driver.findElement(By.id(CLUSTER_VIEW_MEMBERS_ID)).getText();
- String totalMembers = JMXProperties.getInstance().getProperty("server.S1.memberCount");
- assertEquals(totalMembers, clusterMembers);
- }
-
- @Test
- public void testClusterNumClient() {
- String clusterClients = driver.findElement(By.id(CLUSTER_CLIENTS_ID))
- .getText();
- String totalclients = JMXProperties.getInstance().getProperty(
- "server.S1.numClients");
- assertEquals(totalclients, clusterClients);
- }
-
- @Test
- public void testClusterNumRunningFunction() {
- String clusterFunctions = driver.findElement(By.id(CLUSTER_FUNCTIONS_ID))
- .getText();
- String totalfunctions = JMXProperties.getInstance().getProperty(
- "server.S1.numRunningFunctions");
- assertEquals(totalfunctions, clusterFunctions);
- }
-
- @Test
- public void testClusterRegisteredCQCount() {
- String clusterUniqueCQs = driver.findElement(By.id(CLUSTER_UNIQUECQS_ID))
- .getText();
- String totaluniqueCQs = JMXProperties.getInstance().getProperty(
- "server.S1.registeredCQCount");
- assertEquals(totaluniqueCQs, clusterUniqueCQs);
- }
-
- @Test
- public void testClusterNumSubscriptions() {
- String clusterSubscriptions = driver.findElement(
- By.id(CLUSTER_SUBSCRIPTION_ID)).getText();
- String totalSubscriptions = JMXProperties.getInstance().getProperty(
- "server.S1.numSubscriptions");
- assertEquals(totalSubscriptions, clusterSubscriptions);
- }
-
- @Test
- public void testClusterJVMPausesWidget() {
- String clusterJVMPauses = driver.findElement(By.id(CLUSTER_GCPAUSES_ID))
- .getText();
- String totalgcpauses = JMXProperties.getInstance().getProperty(
- "server.S1.jvmPauses");
- assertEquals(totalgcpauses, clusterJVMPauses);
- }
-
- @Test
- public void testClusterAverageWritesWidget() {
- String clusterWritePerSec = driver.findElement(
- By.id(CLUSTER_WRITEPERSEC_ID)).getText();
- String totalwritepersec = JMXProperties.getInstance().getProperty(
- "server.S1.averageWrites");
- assertEquals(totalwritepersec, clusterWritePerSec);
- }
-
- @Test
- public void testClusterAverageReadsWidget() {
- String clusterReadPerSec = driver.findElement(By.id(CLUSTER_READPERSEC_ID))
- .getText();
- String totalreadpersec = JMXProperties.getInstance().getProperty(
- "server.S1.averageReads");
- assertEquals(totalreadpersec, clusterReadPerSec);
- }
-
- @Test
- public void testClusterQuerRequestRateWidget() {
- String clusterQueriesPerSec = driver.findElement(
- By.id(CLUSTER_QUERIESPERSEC_ID)).getText();
- String totalqueriespersec = JMXProperties.getInstance().getProperty(
- "server.S1.queryRequestRate");
- assertEquals(totalqueriespersec, clusterQueriesPerSec);
- }
-
- @Test
- public void testClusterGridViewMemberID() throws InterruptedException {
- searchByIdAndClick("default_grid_button");
- List<WebElement> elements = driver.findElements(By.xpath("//table[@id='memberList']/tbody/tr")); //gives me 11 rows
-
- for (int memberCount = 1; memberCount < elements.size(); memberCount++) {
- String memberId = driver.findElement(By.xpath("//table[@id='memberList']/tbody/tr[" + (memberCount + 1) + "]/td")).getText();
- String propertMemeberId = JMXProperties.getInstance().getProperty("member.M" + memberCount + ".id");
- assertEquals(memberId, propertMemeberId);
- }
- }
-
- @Test
- public void testClusterGridViewMemberName() {
- searchByIdAndClick("default_grid_button");
- List<WebElement> elements = driver.findElements(By.xpath("//table[@id='memberList']/tbody/tr"));
- for (int memberNameCount = 1; memberNameCount < elements.size(); memberNameCount++) {
- String gridMemberName = driver.findElement(By.xpath("//table[@id='memberList']/tbody/tr[" + (memberNameCount + 1) + "]/td[2]")).getText();
- String memberName = JMXProperties.getInstance().getProperty("member.M" + memberNameCount + ".member");
- assertEquals(gridMemberName, memberName);
- }
- }
-
-
- @Test
- public void testClusterGridViewMemberHost() {
- searchByIdAndClick("default_grid_button");
- List<WebElement> elements = driver.findElements(By.xpath("//table[@id='memberList']/tbody/tr"));
- for (int memberHostCount = 1; memberHostCount < elements.size(); memberHostCount++) {
- String MemberHost = driver.findElement(By.xpath("//table[@id='memberList']/tbody/tr[" + (memberHostCount + 1) + "]/td[3]")).getText();
- String gridMemberHost = JMXProperties.getInstance().getProperty("member.M" + memberHostCount + ".host");
- assertEquals(gridMemberHost, MemberHost);
- }
- }
-
- @Test
- public void testClusterGridViewHeapUsage() {
- searchByIdAndClick("default_grid_button");
- for (int i = 1; i <= 3; i++) {
- Float HeapUsage = Float.parseFloat(driver
- .findElement(
- By.xpath("//table[@id='memberList']/tbody/tr[" + (i + 1) + "]/td[5]")).getText());
- Float gridHeapUsagestring = Float.parseFloat(JMXProperties.getInstance()
- .getProperty("member.M" + i + ".UsedMemory"));
- assertEquals(gridHeapUsagestring, HeapUsage);
- }
- }
-
- @Test
- public void testClusterGridViewCPUUsage() throws Exception {
- searchByIdAndClick("default_grid_button");
- for (int i = 1; i <= 3; i++) {
- String CPUUsage = driver.findElement(By.xpath("//table[@id='memberList']/tbody/tr[" + (i + 1) + "]/td[6]"))
- .getText();
- String gridCPUUsage = JMXProperties.getInstance().getProperty("member.M" + i + ".cpuUsage");
- gridCPUUsage = gridCPUUsage.trim();
- assertEquals(gridCPUUsage, CPUUsage);
- }
- }
-
-
- public void testRgraphWidget() throws InterruptedException {
- searchByIdAndClick("default_rgraph_button");
- searchByIdAndClick("h1");
- searchByIdAndClick("M1");
- }
-
- @Test // region count in properties file is 2 and UI is 1
- public void testMemberTotalRegionCount() throws InterruptedException {
- testRgraphWidget();
- String RegionCount = driver.findElement(By.id(MEMBER_VIEW_REGION_ID)).getText();
- String memberRegionCount = JMXProperties.getInstance().getProperty("member.M1.totalRegionCount");
- assertEquals(memberRegionCount, RegionCount);
- }
-
- @Test
- public void testMemberNumThread() throws InterruptedException {
- searchByIdAndClick("default_grid_button");
- searchByIdAndClick("M1&M1");
- String ThreadCount = driver.findElement(By.id(MEMBER_VIEW_THREAD_ID)).getText();
- String memberThreadCount = JMXProperties.getInstance().getProperty("member.M1.numThreads");
- assertEquals(memberThreadCount, ThreadCount);
- }
-
- @Test
- public void testMemberTotalFileDescriptorOpen() throws InterruptedException {
- searchByIdAndClick("default_grid_button");
- searchByIdAndClick("M1&M1");
- String SocketCount = driver.findElement(By.id(MEMBER_VIEW_SOCKETS_ID))
- .getText();
- String memberSocketCount = JMXProperties.getInstance().getProperty(
- "member.M1.totalFileDescriptorOpen");
- assertEquals(memberSocketCount, SocketCount);
- }
-
- @Test
- public void testMemberLoadAverage() throws InterruptedException {
- searchByIdAndClick("default_grid_button");
- searchByIdAndClick("M1&M1");
- String LoadAvg = driver.findElement(By.id(MEMBER_VIEW_LOADAVG_ID))
- .getText();
- String memberLoadAvg = JMXProperties.getInstance().getProperty(
- "member.M1.loadAverage");
- assertEquals(df2.format(Double.valueOf(memberLoadAvg)), LoadAvg);
- }
-
- @Ignore("WIP") // May be useful in near future
- @Test
- public void testOffHeapFreeSize() {
-
- String OffHeapFreeSizeString = driver.findElement(
- By.id(MEMBER_VIEW_OFFHEAPFREESIZE_ID)).getText();
- String OffHeapFreeSizetemp = OffHeapFreeSizeString.replaceAll("[a-zA-Z]",
- "");
- float OffHeapFreeSize = Float.parseFloat(OffHeapFreeSizetemp);
- float memberOffHeapFreeSize = Float.parseFloat(JMXProperties.getInstance()
- .getProperty("member.M1.OffHeapFreeSize"));
- if (memberOffHeapFreeSize < 1048576) {
- memberOffHeapFreeSize = memberOffHeapFreeSize / 1024;
-
- }
- else if (memberOffHeapFreeSize < 1073741824) {
- memberOffHeapFreeSize = memberOffHeapFreeSize / 1024 / 1024;
- }
- else {
- memberOffHeapFreeSize = memberOffHeapFreeSize / 1024 / 1024 / 1024;
- }
- memberOffHeapFreeSize = Float.parseFloat(new DecimalFormat("##.##")
- .format(memberOffHeapFreeSize));
- assertEquals(memberOffHeapFreeSize, OffHeapFreeSize);
-
- }
-
- @Ignore("WIP") // May be useful in near future
- @Test
- public void testOffHeapUsedSize() throws InterruptedException {
-
- String OffHeapUsedSizeString = driver.findElement(
- By.id(MEMBER_VIEW_OFFHEAPUSEDSIZE_ID)).getText();
- String OffHeapUsedSizetemp = OffHeapUsedSizeString.replaceAll("[a-zA-Z]",
- "");
- float OffHeapUsedSize = Float.parseFloat(OffHeapUsedSizetemp);
- float memberOffHeapUsedSize = Float.parseFloat(JMXProperties.getInstance()
- .getProperty("member.M1.OffHeapUsedSize"));
- if (memberOffHeapUsedSize < 1048576) {
- memberOffHeapUsedSize = memberOffHeapUsedSize / 1024;
-
- }
- else if (memberOffHeapUsedSize < 1073741824) {
- memberOffHeapUsedSize = memberOffHeapUsedSize / 1024 / 1024;
- }
- else {
- memberOffHeapUsedSize = memberOffHeapUsedSize / 1024 / 1024 / 1024;
- }
- memberOffHeapUsedSize = Float.parseFloat(new DecimalFormat("##.##")
- .format(memberOffHeapUsedSize));
- assertEquals(memberOffHeapUsedSize, OffHeapUsedSize);
- }
-
- @Test
- public void testMemberJVMPauses() throws Exception {
- searchByIdAndClick("default_grid_button");
- searchByIdAndClick("M1&M1");
- String JVMPauses = driver.findElement(By.id(MEMBER_VIEW_JVMPAUSES_ID))
- .getText();
- String memberGcPausesAvg = JMXProperties.getInstance().getProperty(
- "member.M1.JVMPauses");
- assertEquals(memberGcPausesAvg, JVMPauses);
- }
-
- @Test
- public void testMemberCPUUsage() {
- searchByIdAndClick("default_grid_button");
- searchByIdAndClick("M1&M1");
- String CPUUsagevalue = driver.findElement(By.id(MEMBER_VIEW_CPUUSAGE_ID))
- .getText();
- String memberCPUUsage = JMXProperties.getInstance().getProperty(
- "member.M1.cpuUsage");
- assertEquals(memberCPUUsage, CPUUsagevalue);
- }
-
- @Test // difference between UI and properties file
- public void testMemberAverageReads() {
- searchByIdAndClick("default_grid_button");
- searchByIdAndClick("M1&M1");
- float ReadPerSec = Float.parseFloat(driver.findElement(By.id(MEMBER_VIEW_READPERSEC_ID)).getText());
- float memberReadPerSec = Float.parseFloat(JMXProperties.getInstance().getProperty("member.M1.averageReads"));
- memberReadPerSec = Float.parseFloat(new DecimalFormat("##.##")
- .format(memberReadPerSec));
- assertEquals(memberReadPerSec, ReadPerSec);
- }
-
- @Test
- public void testMemberAverageWrites() throws InterruptedException {
- testRgraphWidget();
- String WritePerSec = driver.findElement(By.id(MEMBER_VIEW_WRITEPERSEC_ID))
- .getText();
- String memberWritePerSec = JMXProperties.getInstance().getProperty(
- "member.M1.averageWrites");
- assertEquals(memberWritePerSec, WritePerSec);
- }
-
-
- @Test
- public void testMemberGridViewData() throws InterruptedException {
- testRgraphWidget();
- searchByXPathAndClick(PulseTestLocators.MemberDetailsView.gridButtonXpath);
- // get the number of rows on the grid
- List<WebElement> noOfRows = driver.findElements(By.xpath("//table[@id='memberRegionsList']/tbody/tr"));
- String MemberRegionName = driver.findElement(By.xpath("//table[@id='memberRegionsList']/tbody/tr[2]/td[1]")).getText();
- String memberRegionName = JMXProperties.getInstance().getProperty("region.R1.name");
- assertEquals(memberRegionName, MemberRegionName);
-
- String MemberRegionType = driver.findElement(By.xpath("//table[@id='memberRegionsList']/tbody/tr[2]/td[2]")).getText();
- String memberRegionType = JMXProperties.getInstance().getProperty("region.R1.regionType");
- assertEquals(memberRegionType, MemberRegionType);
-
- String MemberRegionEntryCount = driver.findElement(By.xpath("//table[@id='memberRegionsList']/tbody/tr[2]/td[3]")).getText();
- String memberRegionEntryCount = JMXProperties.getInstance().getProperty("regionOnMember./R1.M1.entryCount");
- assertEquals(memberRegionEntryCount, MemberRegionEntryCount);
- }
-
- @Test
- public void testDropDownList() throws InterruptedException {
- searchByIdAndClick("default_grid_button");
- searchByIdAndClick("M1&M1");
- searchByIdAndClick("memberName");
- searchByLinkAndClick("M3");
- searchByIdAndClick("memberName");
- searchByLinkAndClick("M2");
- }
-
- @Ignore("WIP")
- @Test
- public void testDataViewRegionName() throws InterruptedException {
- searchByLinkAndClick(DATA_VIEW_LABEL);
- Thread.sleep(7000);
- searchByIdAndClick("default_grid_button");
- String regionName = driver.findElement(By.id(REGION_NAME_LABEL)).getText();
- String dataviewregionname = JMXProperties.getInstance().getProperty("region.R1.name");
- assertEquals(dataviewregionname, regionName);
- }
-
- @Ignore("WIP")
- @Test
- public void testDataViewRegionPath() {
- String regionPath = driver.findElement(By.id(REGION_PATH_LABEL)).getText();
- String dataviewregionpath = JMXProperties.getInstance().getProperty(
- "region.R1.fullPath");
- assertEquals(dataviewregionpath, regionPath);
- }
-
- @Ignore("WIP")
- @Test
- public void testDataViewRegionType() {
- String regionType = driver.findElement(By.id(REGION_TYPE_LABEL)).getText();
- String dataviewregiontype = JMXProperties.getInstance().getProperty(
- "region.R1.regionType");
- assertEquals(dataviewregiontype, regionType);
- }
-
- @Ignore("WIP")
- @Test
- public void testDataViewEmptyNodes() {
- String regionEmptyNodes = driver.findElement(By.id(DATA_VIEW_EMPTYNODES))
- .getText();
- String dataviewEmptyNodes = JMXProperties.getInstance().getProperty(
- "region.R1.emptyNodes");
- assertEquals(dataviewEmptyNodes, regionEmptyNodes);
- }
-
- @Ignore("WIP")
- @Test
- public void testDataViewSystemRegionEntryCount() {
- String regionEntryCount = driver.findElement(By.id(DATA_VIEW_ENTRYCOUNT))
- .getText();
- String dataviewEntryCount = JMXProperties.getInstance().getProperty(
- "region.R1.systemRegionEntryCount");
- assertEquals(dataviewEntryCount, regionEntryCount);
- }
-
- @Ignore("WIP")
- @Test
- public void testDataViewPersistentEnabled() {
- String regionPersistence = driver.findElement(
- By.id(REGION_PERSISTENCE_LABEL)).getText();
- String dataviewregionpersistence = JMXProperties.getInstance().getProperty(
- "region.R1.persistentEnabled");
- assertEquals(dataviewregionpersistence, regionPersistence);
- }
-
- @Ignore("WIP")
- @Test
- public void testDataViewDiskWritesRate() {
- String regionWrites = driver.findElement(By.id(DATA_VIEW_WRITEPERSEC))
- .getText();
- String dataviewRegionWrites = JMXProperties.getInstance().getProperty(
- "region.R1.diskWritesRate");
- assertEquals(dataviewRegionWrites, regionWrites);
- }
-
- @Ignore("WIP")
- @Test
- public void testDataViewDiskReadsRate() {
- String regionReads = driver.findElement(By.id(DATA_VIEW_READPERSEC))
- .getText();
- String dataviewRegionReads = JMXProperties.getInstance().getProperty(
- "region.R1.diskReadsRate");
- assertEquals(dataviewRegionReads, regionReads);
- }
-
- @Ignore("WIP")
- @Test
- public void testDataViewDiskUsage() {
- String regionMemoryUsed = driver.findElement(By.id(DATA_VIEW_USEDMEMORY))
- .getText();
- String dataviewMemoryUsed = JMXProperties.getInstance().getProperty(
- "region.R1.diskUsage");
- assertEquals(dataviewMemoryUsed, regionMemoryUsed);
- searchByLinkAndClick(QUERY_STATISTICS_LABEL);
- }
-
- @Ignore("WIP")
- @Test
- public void testDataViewGridValue() {
- String DataViewRegionName = driver.findElement(
- By.xpath("//*[id('6')/x:td[1]]")).getText();
- String dataViewRegionName = JMXProperties.getInstance().getProperty(
- "region.R1.name");
- assertEquals(dataViewRegionName, DataViewRegionName);
-
- String DataViewRegionType = driver.findElement(
- By.xpath("//*[id('6')/x:td[2]")).getText();
- String dataViewRegionType = JMXProperties.getInstance().getProperty(
- "region.R2.regionType");
- assertEquals(dataViewRegionType, DataViewRegionType);
-
- String DataViewEntryCount = driver.findElement(
- By.xpath("//*[id('6')/x:td[3]")).getText();
- String dataViewEntryCount = JMXProperties.getInstance().getProperty(
- "region.R2.systemRegionEntryCount");
- assertEquals(dataViewEntryCount, DataViewEntryCount);
-
- String DataViewEntrySize = driver.findElement(
- By.xpath("//*[id('6')/x:td[4]")).getText();
- String dataViewEntrySize = JMXProperties.getInstance().getProperty(
- "region.R2.entrySize");
- assertEquals(dataViewEntrySize, DataViewEntrySize);
-
- }
-
-
- public void loadDataBrowserpage() {
- searchByLinkAndClick(DATA_BROWSER_LABEL);
- //Thread.sleep(7000);
- }
-
- @Test
- public void testDataBrowserRegionName() throws InterruptedException {
- loadDataBrowserpage();
- String DataBrowserRegionName1 = driver.findElement(By.id(DATA_BROWSER_REGIONName1))
- .getText();
- String databrowserRegionNametemp1 = JMXProperties.getInstance().getProperty(
- "region.R1.name");
- String databrowserRegionName1 = databrowserRegionNametemp1.replaceAll("[\\/]", "");
- assertEquals(databrowserRegionName1, DataBrowserRegionName1);
-
- String DataBrowserRegionName2 = driver.findElement(By.id(DATA_BROWSER_REGIONName2))
- .getText();
- String databrowserRegionNametemp2 = JMXProperties.getInstance().getProperty(
- "region.R2.name");
- String databrowserRegionName2 = databrowserRegionNametemp2.replaceAll("[\\/]", "");
- assertEquals(databrowserRegionName2, DataBrowserRegionName2);
-
- String DataBrowserRegionName3 = driver.findElement(By.id(DATA_BROWSER_REGIONName3))
- .getText();
- String databrowserRegionNametemp3 = JMXProperties.getInstance().getProperty(
- "region.R3.name");
- String databrowserRegionName3 = databrowserRegionNametemp3.replaceAll("[\\/]", "");
- assertEquals(databrowserRegionName3, DataBrowserRegionName3);
-
- }
-
- @Test
- public void testDataBrowserRegionMembersVerificaition() throws InterruptedException {
- loadDataBrowserpage();
- searchByIdAndClick(DATA_BROWSER_REGION1_CHECKBOX);
- String DataBrowserMember1Name1 = driver.findElement(By.xpath("//label[@for='Member0']"))
- .getText();
- String DataBrowserMember1Name2 = driver.findElement(By.xpath("//label[@for='Member1']"))
- .getText();
- String DataBrowserMember1Name3 = driver.findElement(By.xpath("//label[@for='Member2']"))
- .getText();
- String databrowserMember1Names = JMXProperties.getInstance().getProperty(
- "region.R1.members");
-
- String databrowserMember1Names1 = databrowserMember1Names.substring(0, 2);
- assertEquals(databrowserMember1Names1, DataBrowserMember1Name1);
-
- String databrowserMember1Names2 = databrowserMember1Names.substring(3, 5);
- assertEquals(databrowserMember1Names2, DataBrowserMember1Name2);
-
- String databrowserMember1Names3 = databrowserMember1Names.substring(6, 8);
- assertEquals(databrowserMember1Names3, DataBrowserMember1Name3);
- searchByIdAndClick(DATA_BROWSER_REGION1_CHECKBOX);
-
- searchByIdAndClick(DATA_BROWSER_REGION2_CHECKBOX);
- String DataBrowserMember2Name1 = driver.findElement(By.xpath("//label[@for='Member0']"))
- .getText();
- String DataBrowserMember2Name2 = driver.findElement(By.xpath("//label[@for='Member1']"))
- .getText();
- String databrowserMember2Names = JMXProperties.getInstance().getProperty(
- "region.R2.members");
-
- String databrowserMember2Names1 = databrowserMember2Names.substring(0, 2);
- assertEquals(databrowserMember2Names1, DataBrowserMember2Name1);
-
- String databrowserMember2Names2 = databrowserMember2Names.substring(3, 5);
- assertEquals(databrowserMember2Names2, DataBrowserMember2Name2);
- searchByIdAndClick(DATA_BROWSER_REGION2_CHECKBOX);
-
- searchByIdAndClick(DATA_BROWSER_REGION3_CHECKBOX);
- String DataBrowserMember3Name1 = driver.findElement(By.xpath("//label[@for='Member0']"))
- .getText();
- String DataBrowserMember3Name2 = driver.findElement(By.xpath("//label[@for='Member1']"))
- .getText();
- String databrowserMember3Names = JMXProperties.getInstance().getProperty(
- "region.R3.members");
-
- String databrowserMember3Names1 = databrowserMember3Names.substring(0, 2);
- assertEquals(databrowserMember3Names1, DataBrowserMember3Name1);
-
- String databrowserMember3Names2 = databrowserMember3Names.substring(3, 5);
- assertEquals(databrowserMember3Names2, DataBrowserMember3Name2);
- searchByIdAndClick(DATA_BROWSER_REGION3_CHECKBOX);
- }
-
- @Test
- public void testDataBrowserColocatedRegions() throws InterruptedException {
- loadDataBrowserpage();
- String databrowserMemberNames1 = JMXProperties.getInstance().getProperty(
- "region.R1.members");
- String databrowserMemberNames2 = JMXProperties.getInstance().getProperty(
- "region.R2.members");
- String databrowserMemberNames3 = JMXProperties.getInstance().getProperty(
- "region.R3.members");
-
- if ((databrowserMemberNames1.matches(databrowserMemberNames2 + "(.*)"))) {
- if ((databrowserMemberNames1.matches(databrowserMemberNames3 + "(.*)"))) {
- if ((databrowserMemberNames2.matches(databrowserMemberNames3 + "(.*)"))) {
- System.out.println("R1, R2 and R3 are colocated regions");
- }
- }
- }
- searchByIdAndClick(DATA_BROWSER_REGION1_CHECKBOX);
- searchByLinkAndClick(DATA_BROWSER_COLOCATED_REGION);
- String DataBrowserColocatedRegion1 = driver.findElement(By.id(DATA_BROWSER_COLOCATED_REGION_NAME1))
- .getText();
- String DataBrowserColocatedRegion2 = driver.findElement(By.id(DATA_BROWSER_COLOCATED_REGION_NAME2))
- .getText();
- String DataBrowserColocatedRegion3 = driver.findElement(By.id(DATA_BROWSER_COLOCATED_REGION_NAME3))
- .getText();
-
- String databrowserColocatedRegiontemp1 = JMXProperties.getInstance().getProperty(
- "region.R1.name");
- String databrowserColocatedRegion1 = databrowserColocatedRegiontemp1.replaceAll("[\\/]", "");
-
- String databrowserColocatedRegiontemp2 = JMXProperties.getInstance().getProperty(
- "region.R2.name");
- String databrowserColocatedRegion2 = databrowserColocatedRegiontemp2.replaceAll("[\\/]", "");
-
- String databrowserColocatedRegiontemp3 = JMXProperties.getInstance().getProperty(
- "region.R3.name");
- String databrowserColocatedRegion3 = databrowserColocatedRegiontemp3.replaceAll("[\\/]", "");
-
- assertEquals(databrowserColocatedRegion1, DataBrowserColocatedRegion1);
- assertEquals(databrowserColocatedRegion2, DataBrowserColocatedRegion2);
- assertEquals(databrowserColocatedRegion3, DataBrowserColocatedRegion3);
-
- }
-
- @Ignore("WIP") // clusterDetails element not found on Data Browser page. No assertions in test
- @Test
- public void testDataBrowserQueryValidation() throws IOException, InterruptedException {
- loadDataBrowserpage();
- WebElement textArea = driver.findElement(By.id("dataBrowserQueryText"));
- textArea.sendKeys("query1");
- WebElement executeButton = driver.findElement(By.id("btnExecuteQuery"));
- executeButton.click();
- String QueryResultHeader1 = driver.findElement(By.xpath("//div[@id='clusterDetails']/div/div/span[@class='n-title']")).getText();
- double count = 0, countBuffer = 0, countLine = 0;
- String lineNumber = "";
- String filePath = "E:\\springsource\\springsourceWS\\Pulse-Cedar\\src\\main\\resources\\testQueryResultSmall.txt";
- BufferedReader br;
- String line = "";
- br = new BufferedReader(new FileReader(filePath));
- while ((line = br.readLine()) != null) {
- countLine++;
- String[] words = line.split(" ");
-
- for (String word : words) {
- if (word.equals(QueryResultHeader1)) {
- count++;
- countBuffer++;
- }
- }
- }
- }
-
- public void testTreeMapPopUpData(String S1, String gridIcon) {
- for (int i = 1; i <= 3; i++) {
- searchByLinkAndClick(CLUSTER_VIEW_LABEL);
- if (gridIcon.equals(SERVER_GROUP_GRID_ID)) {
- WebElement ServerGroupRadio = driver.findElement(By.xpath("//label[@for='radio-servergroups']"));
- ServerGroupRadio.click();
- }
- if (gridIcon.equals(REDUNDANCY_GRID_ID)) {
- WebElement ServerGroupRadio = driver.findElement(By.xpath("//label[@for='radio-redundancyzones']"));
- ServerGroupRadio.click();
- }
- searchByIdAndClick(gridIcon);
- WebElement TreeMapMember = driver.findElement(By.xpath("//div[@id='" + S1 + "M" + (i) + "']/div"));
- Actions builder = new Actions(driver);
- builder.clickAndHold(TreeMapMember).perform();
- int j = 1;
- String CPUUsageM1temp = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div/div[2]/div"))
- .getText();
- String CPUUsageM1 = CPUUsageM1temp.replaceAll("[\\%]", "");
- String cpuUsageM1 = JMXProperties.getInstance().getProperty(
- "member.M" + (i) + ".cpuUsage");
- assertEquals(cpuUsageM1, CPUUsageM1);
-
- String MemoryUsageM1temp = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 1) + "]/div[2]/div"))
- .getText();
- String MemoryUsageM1 = MemoryUsageM1temp.replaceAll("MB", "");
- String memoryUsageM1 = JMXProperties.getInstance().getProperty(
- "member.M" + (i) + ".UsedMemory");
- assertEquals(memoryUsageM1, MemoryUsageM1);
-
- String LoadAvgM1 = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 2) + "]/div[2]/div"))
- .getText();
- String loadAvgM1 = JMXProperties.getInstance().getProperty(
- "member.M" + (i) + ".loadAverage");
- assertEquals(df2.format(Double.valueOf(loadAvgM1)), LoadAvgM1);
-
-
- String ThreadsM1 = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 3) + "]/div[2]/div"))
- .getText();
- String threadsM1 = JMXProperties.getInstance().getProperty(
- "member.M" + (i) + ".numThreads");
- assertEquals(threadsM1, ThreadsM1);
-
- String SocketsM1 = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 4) + "]/div[2]/div"))
- .getText();
- String socketsM1 = JMXProperties.getInstance().getProperty(
- "member.M" + (i) + ".totalFileDescriptorOpen");
- assertEquals(socketsM1, SocketsM1);
- builder.moveToElement(TreeMapMember).release().perform();
- }
- }
-
- @Test
- public void testTopologyPopUpData() {
- testTreeMapPopUpData("", CLUSTER_VIEW_GRID_ID);
- }
-
- @Test
- public void testServerGroupTreeMapPopUpData() {
- testTreeMapPopUpData("SG1(!)", SERVER_GROUP_GRID_ID);
- }
-
- @Test
- public void testDataViewTreeMapPopUpData() {
- searchByLinkAndClick(CLUSTER_VIEW_LABEL);
- searchByLinkAndClick(DATA_DROPDOWN_ID);
- WebElement TreeMapMember = driver.findElement(By.id("GraphTreeMapClusterData-canvas"));
- Actions builder = new Actions(driver);
- builder.clickAndHold(TreeMapMember).perform();
- String RegionType = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div/div[2]/div"))
- .getText();
- String regionType = JMXProperties.getInstance().getProperty(
- "region.R2.regionType");
- assertEquals(regionType, RegionType);
-
- String EntryCount = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[2]/div[2]/div"))
- .getText();
- String entryCount = JMXProperties.getInstance().getProperty(
- "region.R2.systemRegionEntryCount");
- assertEquals(entryCount, EntryCount);
-
- String EntrySizetemp = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[3]/div[2]/div"))
- .getText();
- float EntrySize = Float.parseFloat(EntrySizetemp);
- float entrySize = Float.parseFloat(JMXProperties.getInstance().getProperty(
- "region.R2.entrySize"));
- entrySize = entrySize / 1024 / 1024;
- entrySize = Float.parseFloat(new DecimalFormat("##.####")
- .format(entrySize));
- assertEquals(entrySize, EntrySize);
- builder.moveToElement(TreeMapMember).release().perform();
- }
-
- @Test
- public void testRegionViewTreeMapPopUpData() {
- searchByLinkAndClick(CLUSTER_VIEW_LABEL);
- searchByLinkAndClick(DATA_DROPDOWN_ID);
- WebElement TreeMapMember = driver.findElement(By.id("GraphTreeMapClusterData-canvas"));
- TreeMapMember.click();
- }
-
- @Ignore("WIP")
- @Test
- public void testNumberOfRegions() throws InterruptedException {
-
- driver.findElement(By.xpath("//a[text()='Data Browser']")).click();
-
- Thread.sleep(1000);
- List<WebElement> regionList = driver.findElements(By.xpath("//ul[@id='treeDemo']/li"));
- String regions = JMXProperties.getInstance().getProperty("regions");
- String[] regionName = regions.split(" ");
- for (String string : regionName) {
- }
- //JMXProperties.getInstance().getProperty("region.R1.regionType");
- int i = 1;
- for (WebElement webElement : regionList) {
- //webElement.getAttribute(arg0)
- i++;
- }
-
- driver.findElement(By.id("treeDemo_1_check")).click();
-
- List<WebElement> memeberList = driver.findElements(By.xpath("//ul[@id='membersList']/li"));
- int j = 0;
- for (WebElement webElement : memeberList) {
- j++;
- }
- }
-
- @Ignore("WIP")
- @Test
- public void testDataBrowser() {
-
- driver.findElement(By.linkText("Data Browser")).click();
- // WebElement dataBrowserLabel = driver.findElement(By.xpath(""));
- WebDriverWait wait = new WebDriverWait(driver, 20);
- wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//label[text()='Data Browser']"))));
-
-
- // Verify all elements must be displayed on data browser screen
- assertTrue(driver.findElement(By.xpath("//a[text()='Data Regions']")).isDisplayed());
- assertTrue(driver.findElement(By.id("linkColocatedRegions")).isDisplayed());
- assertTrue(driver.findElement(By.linkText("All Regions")).isDisplayed());
-
- assertTrue(driver.findElement(By.xpath("//a[text()='Region Members']")).isDisplayed());
-
- assertTrue(driver.findElement(By.xpath("//a[text()='Queries']")).isDisplayed());
- assertTrue(driver.findElement(By.xpath("//label[text()='Query Editor']")).isDisplayed());
- assertTrue(driver.findElement(By.xpath("//label[text()='Result']")).isDisplayed());
- assertTrue(driver.findElement(By.xpath("//input[@value='Export Result']")).isDisplayed());
- assertTrue(driver.findElement(By.id("btnExecuteQuery")).isDisplayed());
- assertTrue(driver.findElement(By.xpath("//input[@value='Clear']")).isDisplayed());
- assertTrue(driver.findElement(By.id("dataBrowserQueryText")).isDisplayed());
-
- assertTrue(driver.findElement(By.id("historyIcon")).isDisplayed());
-
- //Actual query execution
-
- driver.findElement(By.id("dataBrowserQueryText")).sendKeys("Query1");
-
- // Assert data regions are displayed
- assertTrue(driver.findElement(By.id("treeDemo_1")).isDisplayed());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseAuthTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseAuthTest.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseAuthTest.java
deleted file mode 100644
index 4da7e9c..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseAuthTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.vmware.gemfire.tools.pulse.tests;
-
-import org.apache.geode.test.junit.categories.UITest;
-import org.junit.BeforeClass;
-import org.junit.FixMethodOrder;
-import org.junit.experimental.categories.Category;
-import org.junit.runners.MethodSorters;
-
-@Category(UITest.class)
-@FixMethodOrder(MethodSorters.JVM)
-public class PulseAuthTest extends PulseAbstractTest {
-
- @BeforeClass
- public static void beforeClassSetup() throws Exception {
- setUpServer("pulseUser", "12345", "/pulse-auth.json");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseAutomatedTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseAutomatedTest.java b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseAutomatedTest.java
deleted file mode 100644
index b843993..0000000
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/tests/PulseAutomatedTest.java
+++ /dev/null
@@ -1,784 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-/**
-* This test class contains automated tests for Pulse application related to
-* 1. Different grid data validations for example - Topology, Server Group, Redundancy Zone
-* 2. Data Browser
-* 3.
-*
-*
-* @version 1.0
-* @since GemFire 2014-04-02
-*/
-package com.vmware.gemfire.tools.pulse.tests;
-
-import static org.junit.Assert.*;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.List;
-
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import org.apache.geode.test.junit.categories.UITest;
-
-@Category(UITest.class)
-public class PulseAutomatedTest extends PulseAbstractTest {
-
- @BeforeClass
- public static void beforeClassSetup() throws Exception {
- setUpServer("pulseUser", "12345", "/pulse-auth.json");
- }
-
- @Test
- public void serverGroupGridDataValidation() {
- navigateToServerGroupGridView();
- validateServerGroupGridData();
- }
-
- @Test
- public void redundancyZonesGridDataValidation() {
- navigateToRedundancyZonesGridView();
- validateRedundancyZonesGridData();
- }
-
- @Test
- public void topologyGridDataValidation() {
- navigateToTopologyGridView();
- validateTopologyGridData();
- }
-
- @Test
- public void dataViewGridDataValidation() {
- navigateToDataPrespectiveGridView();
- validateDataPrespectiveGridData();
- }
-
- @Test
- public void regionDetailsGridDataValidation() {
- navigateToRegionDetailsGridView();
- validateRegionDetailsGridData();
-
- }
-
- @Test
- public void regionDetailsNavigationTest() {
- navigateToRegionDetailsView();
- assertEquals("/R2", getTextUsingId(PulseTestLocators.RegionDetailsView.regionNameDivId));
- }
-
- @Test
- public void regionName() {
- navigateToRegionDetailsView();
- assertEquals(getPropertyValue("region.R2.name"), getTextUsingId(PulseTestLocators.RegionDetailsView.regionNameDivId));
- }
-
- @Test
- public void regionPath() {
- navigateToRegionDetailsView();
- assertEquals(getPropertyValue("region.R2.fullPath"),
- getTextUsingId(PulseTestLocators.RegionDetailsView.regionPathId));
- }
-
- @Test
- public void regionType() {
- navigateToRegionDetailsView();
- assertEquals(getPropertyValue("region.R2.regionType"),
- getTextUsingId(PulseTestLocators.RegionDetailsView.regionTypeId));
- }
-
- @Test
- public void regionMembers() {
- navigateToRegionDetailsView();
- assertEquals(getPropertyValue("region.R2.memberCount"),
- getTextUsingId(PulseTestLocators.RegionDetailsView.regionMembersTextId));
- }
-
- @Test
- public void regionEmptyNodes() {
- navigateToRegionDetailsView();
- assertEquals(getPropertyValue("region.R2.emptyNodes"),
- getTextUsingId(PulseTestLocators.RegionDetailsView.regionEmptyNodesId));
- }
-
- @Test
- public void regionEntryCount() {
- navigateToRegionDetailsView();
- assertEquals(getPropertyValue("region.R2.systemRegionEntryCount"),
- getTextUsingId(PulseTestLocators.RegionDetailsView.regionEntryCountTextId));
- }
-
- @Test
- public void regionDiskUsage() {
- navigateToRegionDetailsView();
- assertEquals(getPropertyValue("region.R2.diskUsage"),
- getTextUsingId(PulseTestLocators.RegionDetailsView.regionDiskUsageId));
- }
-
- @Test
- public void regionPersistence() {
- navigateToRegionDetailsView();
- assertEquals(getPersistanceEnabled(getPropertyValue("region.R2.persistentEnabled")),
- getTextUsingId(PulseTestLocators.RegionDetailsView.regionPersistenceId));
- }
-
- @Ignore("WIP")
- @Test
- public void regionMemoryUsage() {
- navigateToRegionDetailsView();
- // need to check the respective property values
- }
-
- @Test
- public void regionInMemoryRead() {
- navigateToRegionDetailsView();
- assertEquals(getPropertyValue("region.R2.getsRate"),
- getTextUsingId(PulseTestLocators.RegionDetailsView.inMemoryReadsId));
-
- }
-
- @Test
- public void regionInMemoryWrites() {
- navigateToRegionDetailsView();
- assertEquals(getPropertyValue("region.R2.putsRate"),
- getTextUsingId(PulseTestLocators.RegionDetailsView.inMemoryWritesId));
- }
-
- @Test
- public void regionDiskRead() {
- navigateToRegionDetailsView();
- assertEquals(getPropertyValue("region.R2.diskReadsRate"),
- getTextUsingId(PulseTestLocators.RegionDetailsView.diskReadsId));
- }
-
- @Test
- public void regionDiskWrites() {
- navigateToRegionDetailsView();
- assertEquals(getPropertyValue("region.R2.diskWritesRate"),
- getTextUsingId(PulseTestLocators.RegionDetailsView.diskWritesId));
- }
-
- @Test
- public void clickHostShowsMemberTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.nodeH1Id);
- verifyElementPresentById(PulseTestLocators.TopologyView.memberM1Id);
- clickElementUsingId(PulseTestLocators.TopologyView.nodeH2Id);
- verifyElementPresentById(PulseTestLocators.TopologyView.memberM2Id);
- clickElementUsingId(PulseTestLocators.TopologyView.nodeH3Id);
- verifyElementPresentById(PulseTestLocators.TopologyView.memberM3Id);
- }
-
- @Test
- @Ignore("Issue with highlighting")
- public void verifyHostTooltipsOfTopologyGraphTest() {
- for (int i = 1; i <=3; i++) {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- mouseClickAndHoldOverElementById("h" + i);
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.hostNameTTXpath, getPropertyValue("member.M" + i + ".host"));
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.cpuUsageTTXpath, "0%");
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memoryUsageTTXpath, getPropertyValue("member.M" + i
- + ".UsedMemory"));
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.loadAvgTTXpath, getPropertyValue("member.M" + i
- + ".loadAverage"));
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.soketsTTXpath, getPropertyValue("member.M" + i
- + ".totalFileDescriptorOpen"));
- mouseReleaseById("h" + i);
- driver.navigate().refresh();
- }
- }
-
- @Ignore("Issues with member tooltip xpath")
- @Test
- public void verifyMemberTooltipsOfTopologyGraphTest() {
-
- verifyElementPresentById(PulseTestLocators.TopologyView.nodeH1Id);
- clickElementUsingId(PulseTestLocators.TopologyView.nodeH1Id);
- mouseClickAndHoldOverElementById(PulseTestLocators.TopologyView.memberM1Id);
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memNameTTXpath, getPropertyValue("member.M1.member"));
- //verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memCpuUsageTTXpath, getPropertyValue("member.M1.cpuUsage") + "%");
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.jvmPausesTTXpath, getPropertyValue("member.M1.JVMPauses"));
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.regionsTTXpath, getPropertyValue("member.M1.totalRegionCount"));
- verifyElementPresentById(PulseTestLocators.TopologyView.nodeH2Id);
- clickElementUsingId(PulseTestLocators.TopologyView.nodeH2Id);
- mouseClickAndHoldOverElementById(PulseTestLocators.TopologyView.memberM2Id);
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memNameTTXpath, getPropertyValue("member.M2.member"));
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memCpuUsageTTXpath, getPropertyValue("member.M2.cpuUsage") + "%");
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.jvmPausesTTXpath, getPropertyValue("member.M2.JVMPauses"));
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.regionsTTXpath, getPropertyValue("member.M2.totalRegionCount"));
-
- verifyElementPresentById(PulseTestLocators.TopologyView.nodeH3Id);
- clickElementUsingId(PulseTestLocators.TopologyView.nodeH3Id);
- mouseClickAndHoldOverElementById(PulseTestLocators.TopologyView.memberM3Id);
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memNameTTXpath, getPropertyValue("member.M3.member"));
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.memCpuUsageTTXpath, getPropertyValue("member.M3.cpuUsage") + "%");
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.jvmPausesTTXpath, getPropertyValue("member.M3.JVMPauses"));
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.regionsTTXpath, getPropertyValue("member.M3.totalRegionCount"));
-
- }
-
- @Test
- public void VerifyRGraphTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- verifyElementPresentById(PulseTestLocators.TopologyView.nodeH1Id);
- verifyElementPresentById(PulseTestLocators.TopologyView.nodeH2Id);
- verifyElementPresentById(PulseTestLocators.TopologyView.nodeH3Id);
- }
-
- @Test
- public void clickMembersOfTopologyGraphTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.nodeH1Id);
- clickElementUsingId(PulseTestLocators.TopologyView.memberM1Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.nodeH2Id);
- clickElementUsingId(PulseTestLocators.TopologyView.memberM2Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.nodeH3Id);
- clickElementUsingId(PulseTestLocators.TopologyView.memberM3Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
- }
-
- @Test
- public void clickTreeMapViewShowingTreeMapTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
- verifyElementPresentById(PulseTestLocators.TopologyView.memberM1Id);
- verifyElementPresentById(PulseTestLocators.TopologyView.memberM2Id);
- verifyElementPresentById(PulseTestLocators.TopologyView.memberM3Id);
- }
-
- @Test
- public void verifyMembersPresentInTreeMapTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
- verifyElementPresentById(PulseTestLocators.TopologyView.memberM1Id);
- verifyElementPresentById(PulseTestLocators.TopologyView.memberM2Id);
- verifyElementPresentById(PulseTestLocators.TopologyView.memberM3Id);
- verifyTextPresrntById(PulseTestLocators.TopologyView.memberM1Id, "M1");
- verifyTextPresrntById(PulseTestLocators.TopologyView.memberM2Id, "M2");
- verifyTextPresrntById(PulseTestLocators.TopologyView.memberM3Id, "M3");
- }
-
- @Test
- public void clickMemberNavigatingToCorrespondingRegionTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
- verifyElementPresentById(PulseTestLocators.TopologyView.memberM1Id);
- verifyTextPresrntById(PulseTestLocators.TopologyView.memberM1Id, "M1");
- clickElementUsingId(PulseTestLocators.TopologyView.memberM1Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
- verifyElementPresentById(PulseTestLocators.TopologyView.memberM2Id);
- verifyTextPresrntById(PulseTestLocators.TopologyView.memberM2Id, "M2");
- clickElementUsingId(PulseTestLocators.TopologyView.memberM2Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
- verifyElementPresentById(PulseTestLocators.TopologyView.memberM3Id);
- verifyTextPresrntById(PulseTestLocators.TopologyView.memberM3Id, "M3");
- clickElementUsingId(PulseTestLocators.TopologyView.memberM3Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
- }
-
- @Test
- public void clickGridButtonShowsGridTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.idM1Xpath);
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.nameM1Xpath);
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.hostH1Xpath);
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.idM2Xpath);
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.nameM2Xpath);
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.hostH2Xpath);
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.idM3Xpath);
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.nameM3Xpath);
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.hostH3Xpath);
- }
-
- @Test
- public void verifyMembersPresentInGridTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.nameM1Xpath);
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.nameM1Xpath, "M1");
-
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.nameM2Xpath);
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.nameM2Xpath, "M2");
-
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.nameM3Xpath);
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.nameM3Xpath, "M3");
- }
-
- @Test
- public void verifyHostNamesInGridTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.hostH1Xpath);
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.hostH1Xpath, "h1");
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.hostH2Xpath);
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.hostH2Xpath, "h2");
- verifyElementPresentByXpath(PulseTestLocators.TopologyView.hostH3Xpath);
- verifyTextPresrntByXpath(PulseTestLocators.TopologyView.hostH3Xpath, "h3");
- }
-
- @Test
- public void clickOnGridMemNameNavigatingToCorrespondingRegionTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
- clickElementUsingXpath(PulseTestLocators.TopologyView.nameM1Xpath);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
-
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
- clickElementUsingXpath(PulseTestLocators.TopologyView.nameM2Xpath);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
-
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.gridButtonId);
- clickElementUsingXpath(PulseTestLocators.TopologyView.nameM3Xpath);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
- }
-
- @Test
- public void verifyMembersPresentInSvrGrpTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
-
- clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrpsRadioXpath);
- verifyElementPresentById(PulseTestLocators.ServerGroups.serverGrp1Id);
- verifyElementPresentById(PulseTestLocators.ServerGroups.serverGrp2Id);
- verifyElementPresentById(PulseTestLocators.ServerGroups.serverGrp3Id);
-
- verifyElementPresentById(PulseTestLocators.ServerGroups.sg1M1Id);
- verifyElementPresentById(PulseTestLocators.ServerGroups.sg1M2Id);
- verifyElementPresentById(PulseTestLocators.ServerGroups.sg1M3Id);
-
- verifyElementPresentById(PulseTestLocators.ServerGroups.sg2M1Id);
- verifyElementPresentById(PulseTestLocators.ServerGroups.sg2M2Id);
-
- verifyElementPresentById(PulseTestLocators.ServerGroups.sg3M3Id);
- }
-
- @Test
- public void expandAndCloseServerGroupsTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- //waitForElement(findElementByXpath(PulseTestLocators.ServerGroups.serverGrpsRadioXpath));
- clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrpsRadioXpath);
- clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrp1Xpath);
- verifyElementAttributeById(PulseTestLocators.ServerGroups.serverGrp1Id, "style", "width: 720px; height: 415px;");
- clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrp1Xpath);
- verifyElementAttributeById(PulseTestLocators.ServerGroups.serverGrp1Id, "style", "width: 239.667px; height: 399px;");
-
- clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrp2Xpath);
- verifyElementAttributeById(PulseTestLocators.ServerGroups.serverGrp2Id, "style", "width: 720px; height: 415px;");
- clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrp2Xpath);
- verifyElementAttributeById(PulseTestLocators.ServerGroups.serverGrp2Id, "style", "width: 239.667px; height: 399px;");
-
- clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrp3Xpath);
- verifyElementAttributeById(PulseTestLocators.ServerGroups.serverGrp3Id, "style", "width: 720px; height: 415px;");
- clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrp3Xpath);
- verifyElementAttributeById(PulseTestLocators.ServerGroups.serverGrp3Id, "style", "width: 239.667px; height: 399px;");
- }
-
- @Test
- public void verifyMembersInServGrpTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrpsRadioXpath);
-
- verifyTextPresrntById(PulseTestLocators.ServerGroups.serverGrp1Id, "SG1");
- verifyTextPresrntById(PulseTestLocators.ServerGroups.serverGrp2Id, "SG2");
- verifyTextPresrntById(PulseTestLocators.ServerGroups.serverGrp3Id, "SG3");
-
- verifyTextPresrntById(PulseTestLocators.ServerGroups.sg1M1Id, "M1");
- verifyTextPresrntById(PulseTestLocators.ServerGroups.sg1M2Id, "M2");
- verifyTextPresrntById(PulseTestLocators.ServerGroups.sg1M3Id, "M3");
-
- verifyTextPresrntById(PulseTestLocators.ServerGroups.sg2M1Id, "M1");
- verifyTextPresrntById(PulseTestLocators.ServerGroups.sg2M2Id, "M2");
-
- verifyTextPresrntById(PulseTestLocators.ServerGroups.sg3M3Id, "M3");
- }
-
- @Test
- public void memberNavigationFromServGrpTest() {
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingXpath(PulseTestLocators.ServerGroups.serverGrpsRadioXpath);
- clickElementUsingId(PulseTestLocators.ServerGroups.sg1M1Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
- navigateToServerGroupTreeView();
- clickElementUsingId(PulseTestLocators.ServerGroups.sg1M2Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
- navigateToServerGroupTreeView();
- clickElementUsingId(PulseTestLocators.ServerGroups.sg1M3Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
- navigateToServerGroupTreeView();
- clickElementUsingId(PulseTestLocators.ServerGroups.sg2M1Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
- navigateToServerGroupTreeView();
- clickElementUsingId(PulseTestLocators.ServerGroups.sg2M2Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
- navigateToServerGroupTreeView();
- clickElementUsingId(PulseTestLocators.ServerGroups.sg3M3Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
- }
-
- @Test
- public void clickServGrpGridButtonShowsGridTest() {
- navigateToServerGroupGridView();
- verifyElementPresentByXpath(PulseTestLocators.ServerGroups.idSG1M3Xpath);
- verifyElementPresentByXpath(PulseTestLocators.ServerGroups.idSG1M2Xpath);
- verifyElementPresentByXpath(PulseTestLocators.ServerGroups.idSG1M1Xpath);
- verifyElementPresentByXpath(PulseTestLocators.ServerGroups.nameM3Xpath);
- verifyElementPresentByXpath(PulseTestLocators.ServerGroups.nameM2Xpath);
- verifyElementPresentByXpath(PulseTestLocators.ServerGroups.nameM1Xpath);
-
- }
-
- @Test
- public void memberNavigationFromServGrpGridTest() {
- navigateToServerGroupGridView();
- clickElementUsingXpath(PulseTestLocators.ServerGroups.idSG1M3Xpath);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
- navigateToServerGroupGridView();
- clickElementUsingXpath(PulseTestLocators.ServerGroups.idSG1M1Xpath);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
- navigateToServerGroupGridView();
- clickElementUsingXpath(PulseTestLocators.ServerGroups.idSG1M2Xpath);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
- }
-
- @Test
- public void verifyZonePresentTest() {
- navigateToRedundancyZonesTreeView();
- verifyElementPresentByXpath(PulseTestLocators.RedundancyZone.zoneRZ1RZ2Xpath);
- verifyElementPresentById(PulseTestLocators.RedundancyZone.zoneRZ2Id);
- }
-
- @Test
- public void expandAndCloseRdncyZoneTest() {
- navigateToRedundancyZonesTreeView();
- clickElementUsingXpath(PulseTestLocators.RedundancyZone.zoneRZ1RZ2Xpath);
- verifyElementAttributeById(PulseTestLocators.RedundancyZone.zoneRZ1Id, "style", "width: 720px; height: 415px;");
- clickElementUsingXpath(PulseTestLocators.RedundancyZone.zoneRZ1RZ2Xpath);
- clickElementUsingXpath(PulseTestLocators.RedundancyZone.zoneRZ2Xpath);
- verifyElementAttributeById(PulseTestLocators.RedundancyZone.zoneRZ2Id, "style", "width: 720px; height: 415px;");
-
- }
-
- @Test
- public void clickRZMembersNavigationTest() {
- navigateToRedundancyZonesTreeView();
- clickElementUsingId(PulseTestLocators.RedundancyZone.m1RZ1RZ2Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
- navigateToRedundancyZonesTreeView();
- clickElementUsingId(PulseTestLocators.RedundancyZone.m2RZ1Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
- navigateToRedundancyZonesTreeView();
- clickElementUsingId(PulseTestLocators.RedundancyZone.m3RZ2Id);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
- }
-
- @Test
- public void clickRZGridShowingGridTest() {
- navigateToRedundancyZonesGridView();
- verifyElementPresentByXpath(PulseTestLocators.RedundancyZone.idM2Xpath);
- verifyElementPresentByXpath(PulseTestLocators.RedundancyZone.idM1Xpath);
- verifyElementPresentByXpath(PulseTestLocators.RedundancyZone.idM3Xpath);
- verifyTextPresrntByXpath(PulseTestLocators.RedundancyZone.idM2Xpath, "M2");
- verifyTextPresrntByXpath(PulseTestLocators.RedundancyZone.idM1Xpath, "M1");
- verifyTextPresrntByXpath(PulseTestLocators.RedundancyZone.idM3Xpath, "M3");
- }
-
- @Test
- public void clickRZGridMembersNavigationTest() {
- navigateToRedundancyZonesGridView();
- clickElementUsingXpath(PulseTestLocators.RedundancyZone.idM2Xpath);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M2");
- navigateToRedundancyZonesGridView();
- clickElementUsingXpath(PulseTestLocators.RedundancyZone.idM1Xpath);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M1");
- navigateToRedundancyZonesGridView();
- clickElementUsingXpath(PulseTestLocators.RedundancyZone.idM3Xpath);
- verifyTextPresrntById(PulseTestLocators.RegionDetailsView.memberNameId, "M3");
- }
-
-
- @Test
- public void verifySortingOptionsTest(){
- clickElementUsingXpath(PulseTestLocators.TopNavigation.clusterViewLinkXpath);
- clickElementUsingId(PulseTestLocators.TopologyView.treeMapButtonId);
- verifyElementPresentById(PulseTestLocators.TopologyView.hotSpotId);
- clickElementUsingId(PulseTestLocators.TopologyView.hotSpotId);
- verifyElementPresentByLinkText("Heap Usage");
- verifyElementPresentByLinkText("CPU Usage");
- }
-
- /*
- * HotSpot test scripts -
- */
- //--- Topology view
-
- @Test
- public void testHotSpotOptPrsntOnTopologyView(){
- navigateToTopologyTreeView();
- assertEquals(PulseTestData.Topology.hotSpotHeapLbl, getTextUsingId(PulseTestLocators.TopologyView.hotSpotId));
- }
-
- @Test
- public void testHotSpotOptionsTopologyView(){
- navigateToTopologyTreeView();
- clickElementUsingId(PulseTestLocators.TopologyView.hotSpotId);
- assertEquals(PulseTestData.Topology.hotSpotHeapLbl, getTextUsingXpath(PulseTestLocators.TopologyView.heapUsageXpath));
- assertEquals(PulseTestData.Topology.hotSpotCPULbl, getTextUsingXpath(PulseTestLocators.TopologyView.cpuUsageXpath));
- }
-
- @Test
- public void testCpuUsageNavigationOnTopologyView(){
- navigateToTopologyTreeView();
- clickElementUsingId(PulseTestLocators.TopologyView.hotSpotId);
- clickElementUsingXpath(PulseTestLocators.TopologyView.cpuUsageXpath);
- assertEquals(PulseTestData.Topology.hotSpotCPULbl, getTextUsingId(PulseTestLocators.TopologyView.hotSpotId));
- }
-
- @Test
- public void testHeapUsageNavigationOnTopologyView(){
- navigateToTopologyTreeView();
- clickElementUsingId(PulseTestLocators.TopologyView.hotSpotId);
- clickElementUsingXpath(PulseTestLocators.TopologyView.heapUsageXpath);
- assertEquals(PulseTestData.Topology.hotSpotHeapLbl, getTextUsingId(PulseTestLocators.TopologyView.hotSpotId));
- }
-
- @Test
- public void testSortingUsingCpuUsageOnTopologyView(){
- navigateToTopologyTreeView();
- clickElementUsingId(PulseTestLocators.TopologyView.hotSpotId);
- clickElementUsingXpath(PulseTestLocators.TopologyView.cpuUsageXpath);
- assertMemberSortingByCpuUsage();
- }
-
- @Test
- public void testSortingUsingHeapUsageOnTopologyView(){
- navigateToTopologyTreeView();
- clickElementUsingId(PulseTestLocators.TopologyView.hotSpotId);
- clickElementUsingXpath(PulseTestLocators.TopologyView.heapUsageXpath);
- assertMemberSortingByHeapUsage();
- }
-
- //--- Server Group view
-
- @Test
- public void testHotSpotOptPrsntOnServerGroupView(){
- navigateToServerGroupTreeView();
- assertEquals(PulseTestData.ServerGroups.hotSpotHeapLbl, getTextUsingId(PulseTestLocators.ServerGroups.hotSpotId));
- }
-
- @Test
- public void testHotSpotOptionsServerGroupView(){
- navigateToServerGroupTreeView();
- clickElementUsingId(PulseTestLocators.ServerGroups.hotSpotId);
- assertEquals(PulseTestData.ServerGroups.hotSpotHeapLbl, getTextUsingXpath(PulseTestLocators.ServerGroups.heapUsageXpath));
- assertEquals(PulseTestData.ServerGroups.hotSpotCPULbl, getTextUsingXpath(PulseTestLocators.ServerGroups.cpuUsageXpath));
- }
-
- @Test
- public void testCpuUsageNavigationOnServerGroupView(){
- navigateToServerGroupTreeView();
- clickElementUsingId(PulseTestLocators.ServerGroups.hotSpotId);
- clickElementUsingXpath(PulseTestLocators.ServerGroups.cpuUsageXpath);
- assertEquals(PulseTestData.ServerGroups.hotSpotCPULbl, getTextUsingId(PulseTestLocators.ServerGroups.hotSpotId));
- }
-
- @Test
- public void testHeapUsageNavigationOnServerGroupView(){
- navigateToServerGroupTreeView();
- clickElementUsingId(PulseTestLocators.ServerGroups.hotSpotId);
- clickElementUsingXpath(PulseTestLocators.ServerGroups.heapUsageXpath);
- assertEquals(PulseTestData.ServerGroups.hotSpotHeapLbl, getTextUsingId(PulseTestLocators.ServerGroups.hotSpotId));
- }
-
- @Test
- public void testSortingUsingHeapUsageOnServerGroupView(){
- navigateToServerGroupTreeView();
- clickElementUsingId(PulseTestLocators.ServerGroups.hotSpotId);
- clickElementUsingXpath(PulseTestLocators.ServerGroups.heapUsageXpath);
- assertMemberSortingBySgHeapUsage();
- }
-
- @Test
- public void testSortingUsingCpuUsageOnServerGroupView(){
- navigateToServerGroupTreeView();
- clickElementUsingId(PulseTestLocators.ServerGroups.hotSpotId);
- clickElementUsingXpath(PulseTestLocators.ServerGroups.cpuUsageXpath);
- assertMemberSortingBySgCpuUsage();
- }
-
- //--- Redundancy Zone view
-
- @Test
- public void testHotSpotOptPrsntOnRedundancyZoneView(){
- navigateToRedundancyZonesTreeView();
- assertEquals(PulseTestData.RedundancyZone.hotSpotHeapLbl, getTextUsingId(PulseTestLocators.RedundancyZone.hotSpotId));
- }
-
-
- @Test
- public void testHotSpotOptionsRedundancyZoneView(){
- // navigate to Redundancy Zones - Tree View
- navigateToRedundancyZonesTreeView();
- clickElementUsingId(PulseTestLocators.RedundancyZone.hotSpotId);
- assertEquals(PulseTestData.RedundancyZone.hotSpotHeapLbl, getTextUsingXpath(PulseTestLocators.RedundancyZone.heapUsageXpath));
- assertEquals(PulseTestData.RedundancyZone.hotSpotCPULbl, getTextUsingXpath(PulseTestLocators.RedundancyZone.cpuUsageXpath));
- }
-
- @Test
- public void testCpuUsageNavigationOnRedundancyZoneView(){
- // navigate to Redundancy Zones - Tree View
- navigateToRedundancyZonesTreeView();
- clickElementUsingId(PulseTestLocators.RedundancyZone.hotSpotId);
- clickElementUsingXpath(PulseTestLocators.RedundancyZone.cpuUsageXpath);
- assertEquals(PulseTestData.RedundancyZone.hotSpotCPULbl, getTextUsingId(PulseTestLocators.RedundancyZone.hotSpotId));
- }
-
- @Test
- public void testHeapUsageNavigationOnRedundancyZoneView(){
- // navigate to Redundancy Zones - Tree View
- navigateToRedundancyZonesTreeView();
- clickElementUsingId(PulseTestLocators.RedundancyZone.hotSpotId);
- clickElementUsingXpath(PulseTestLocators.RedundancyZone.heapUsageXpath);
- assertEquals(PulseTestData.RedundancyZone.hotSpotHeapLbl, getTextUsingId(PulseTestLocators.RedundancyZone.hotSpotId));
- }
-
- @Test
- public void testSortingUsingHeapUsageOnRedundancyView(){
- // navigate to Redundancy Zones - Tree View
- navigateToRedundancyZonesTreeView();
- clickElementUsingId(PulseTestLocators.RedundancyZone.hotSpotId);
- clickElementUsingXpath(PulseTestLocators.RedundancyZone.heapUsageXpath);
- assertMemberSortingByRzHeapUsage();
- }
-
- @Test
- public void testSortingUsingCpuUsageOnRedundancyView(){
- // navigate to Redundancy Zones - Tree View
- navigateToRedundancyZonesTreeView();
- clickElementUsingId(PulseTestLocators.RedundancyZone.hotSpotId);
- clickElementUsingXpath(PulseTestLocators.RedundancyZone.cpuUsageXpath);
- assertMemeberSortingByRzCpuUsage();
- }
-
- @Test
- public void testDataBrowserFilterFeature(){
- // navigate to Data browser page
- loadDataBrowserpage();
- List<WebElement> regionLst = getRegionsFromDataBrowser();
- String []regionNames = new String[regionLst.size()];
- for(int regionIndex = 0; regionIndex < regionLst.size(); regionIndex++){
- regionNames[regionIndex] = findElementByXpath(PulseTestLocators.DataBrowser.rgnSpanFirstPart + (regionIndex + 1 ) + PulseTestLocators.DataBrowser.rgnSpanSecondPart).getText();
- }
- // type each region name in region filter and verify respective region(s) are displayed in region list
- for (String region : regionNames) {
- findElementById(PulseTestLocators.DataBrowser.rgnFilterTxtBoxId).clear();
- findElementById(PulseTestLocators.DataBrowser.rgnFilterTxtBoxId).sendKeys(region);
-
- List<WebElement> regionLst1 = getRegionsFromDataBrowser();
-
- for(int regionIndex = 1; regionIndex <= regionLst1.size(); regionIndex++){
- assertEquals(region, findElementByXpath(PulseTestLocators.DataBrowser.rgnSpanFirstPart + regionIndex + PulseTestLocators.DataBrowser.rgnSpanSecondPart).getText());
- }
- }
- }
-
- @Test
- public void testDataBrowserFilterPartialRegionName(){
- // navigate to Data browser page
- loadDataBrowserpage();
- findElementById(PulseTestLocators.DataBrowser.rgnFilterTxtBoxId).clear();
-
- // type partial region name in region filter and verify that all the regions that contains that text displays
- findElementById(PulseTestLocators.DataBrowser.rgnFilterTxtBoxId).sendKeys(PulseTestData.DataBrowser.partialRgnName);
- List<WebElement> regionLst = getRegionsFromDataBrowser();
-
- for(int regionIndex = 0; regionIndex < regionLst.size(); regionIndex++){
- assertTrue(findElementByXpath(PulseTestLocators.DataBrowser.rgnSpanFirstPart +
- (regionIndex + 1 ) +
- PulseTestLocators.DataBrowser.rgnSpanSecondPart).
- getText().
- contains(PulseTestData.DataBrowser.partialRgnName));
- }
- }
-
- @Test
- public void testDataBrowserClearButton(){
- // navigate to Data browser page
- loadDataBrowserpage();
-
- sendKeysUsingId(PulseTestLocators.DataBrowser.queryEditorTxtBoxId, PulseTestData.DataBrowser.query1Text);
- String editorTextBeforeClear = getTextUsingId(PulseTestLocators.DataBrowser.queryEditorTxtBoxId);
- clickElementUsingXpath(PulseTestLocators.DataBrowser.btnClearXpath);
- String editorTextAfterClear = getTextUsingId(PulseTestLocators.DataBrowser.queryEditorTxtBoxId);
-
- assertFalse(PulseTestData.DataBrowser.query1Text.equals(editorTextAfterClear));
- }
-
- @Ignore("WIP") // Data Browser's Query History not showing any data on button click, therefore this test is failing
- @Test
- public void testDataBrowserHistoryQueue(){
- // navigate to Data browser page
- loadDataBrowserpage();
-
- List<WebElement> numOfReg = driver.findElements(By.xpath(PulseTestLocators.DataBrowser.divDataRegions));
-
- for(int i = 1; i <= numOfReg.size(); i ++){
- if(getTextUsingId("treeDemo_" + i + "_span").equals( PulseTestData.DataBrowser.regName)){
- searchByIdAndClick("treeDemo_" + i + "_check"); //driver.findElement(By.id("treeDemo_" + i + "_check")).click();
- }
- }
-
- sendKeysUsingId(PulseTestLocators.DataBrowser.queryEditorTxtBoxId, PulseAbstractTest.QUERY_TYPE_ONE);
- clickElementUsingId(PulseTestLocators.DataBrowser.btnExecuteQueryId);
-
- //Get required datetime format and extract date and hours from date time.
- DateFormat dateFormat = new SimpleDateFormat(PulseTestData.DataBrowser.datePattern);
- String queryDateTime = dateFormat.format(System.currentTimeMillis());
- String queryTime[] = queryDateTime.split(":");
- System.out.println("Query Time from System: " + queryTime[0]);
-
-
- clickElementUsingId(PulseTestLocators.DataBrowser.historyIcon);
- List<WebElement> historyLst = driver.findElements(By.xpath(PulseTestLocators.DataBrowser.historyLst));
- String queryText = findElementByXpath(PulseTestLocators.DataBrowser.historyLst)
- .findElement(By.cssSelector(PulseTestLocators.DataBrowser.queryText)).getText();
- String historyDateTime = findElementByXpath(PulseTestLocators.DataBrowser.historyLst)
- .findElement(By.cssSelector(PulseTestLocators.DataBrowser.historyDateTime)).getText();
- System.out.println("Query Text from History Table: " + queryText);
- System.out.println("Query Time from History Table: " + historyDateTime);
- //verify the query text, query datetime in history panel
- assertTrue(PulseAbstractTest.QUERY_TYPE_ONE.equals(queryText));
- assertTrue(historyDateTime.contains(queryTime[0]));
-
- }
-}
[32/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
GEODE-37 renamed pulse package to geode
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/9a2b5d7b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/9a2b5d7b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/9a2b5d7b
Branch: refs/heads/develop
Commit: 9a2b5d7b2d00c8ebe7a849487aea3df01063000f
Parents: 5ba853d
Author: Hitesh Khamesra <hk...@pivotal.io>
Authored: Mon Sep 19 13:57:29 2016 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Tue Sep 20 14:29:51 2016 -0700
----------------------------------------------------------------------
.../tools/pulse/internal/PulseAppListener.java | 742 ----
.../controllers/ExceptionHandlingAdvice.java | 51 -
.../internal/controllers/PulseController.java | 524 ---
.../tools/pulse/internal/data/Cluster.java | 3815 ------------------
.../tools/pulse/internal/data/DataBrowser.java | 248 --
.../pulse/internal/data/IClusterUpdater.java | 35 -
.../pulse/internal/data/JMXDataUpdater.java | 2392 -----------
.../pulse/internal/data/JmxManagerFinder.java | 169 -
.../tools/pulse/internal/data/PulseConfig.java | 139 -
.../pulse/internal/data/PulseConstants.java | 434 --
.../tools/pulse/internal/data/PulseVersion.java | 103 -
.../tools/pulse/internal/data/Repository.java | 246 --
.../gemfire/tools/pulse/internal/json/CDL.java | 274 --
.../tools/pulse/internal/json/Cookie.java | 164 -
.../tools/pulse/internal/json/CookieList.java | 85 -
.../gemfire/tools/pulse/internal/json/HTTP.java | 158 -
.../tools/pulse/internal/json/HTTPTokener.java | 72 -
.../tools/pulse/internal/json/JSONArray.java | 901 -----
.../pulse/internal/json/JSONException.java | 47 -
.../tools/pulse/internal/json/JSONML.java | 462 ---
.../tools/pulse/internal/json/JSONObject.java | 1585 --------
.../tools/pulse/internal/json/JSONString.java | 37 -
.../tools/pulse/internal/json/JSONStringer.java | 73 -
.../tools/pulse/internal/json/JSONTokener.java | 441 --
.../tools/pulse/internal/json/JSONWriter.java | 322 --
.../gemfire/tools/pulse/internal/json/README | 68 -
.../gemfire/tools/pulse/internal/json/XML.java | 503 ---
.../tools/pulse/internal/json/XMLTokener.java | 360 --
.../tools/pulse/internal/log/LogWriter.java | 265 --
.../pulse/internal/log/MessageFormatter.java | 102 -
.../pulse/internal/log/PulseLogWriter.java | 299 --
.../tools/pulse/internal/log/PulseLogger.java | 142 -
.../security/GemFireAuthentication.java | 91 -
.../security/GemFireAuthenticationProvider.java | 80 -
.../pulse/internal/security/LogoutHandler.java | 55 -
.../internal/service/ClusterDetailsService.java | 104 -
.../service/ClusterDiskThroughputService.java | 71 -
.../service/ClusterGCPausesService.java | 69 -
.../service/ClusterKeyStatisticsService.java | 69 -
.../internal/service/ClusterMemberService.java | 132 -
.../service/ClusterMembersRGraphService.java | 359 --
.../service/ClusterMemoryUsageService.java | 65 -
.../internal/service/ClusterRegionService.java | 211 -
.../internal/service/ClusterRegionsService.java | 206 -
.../service/ClusterSelectedRegionService.java | 237 --
.../ClusterSelectedRegionsMemberService.java | 143 -
.../internal/service/ClusterWANInfoService.java | 75 -
.../service/MemberAsynchEventQueuesService.java | 99 -
.../internal/service/MemberClientsService.java | 101 -
.../internal/service/MemberDetailsService.java | 122 -
.../service/MemberDiskThroughputService.java | 76 -
.../internal/service/MemberGCPausesService.java | 73 -
.../service/MemberGatewayHubService.java | 149 -
.../service/MemberHeapUsageService.java | 73 -
.../service/MemberKeyStatisticsService.java | 76 -
.../internal/service/MemberRegionsService.java | 127 -
.../internal/service/MembersListService.java | 75 -
.../pulse/internal/service/PulseService.java | 40 -
.../internal/service/PulseServiceFactory.java | 55 -
.../internal/service/PulseVersionService.java | 65 -
.../service/QueryStatisticsService.java | 115 -
.../internal/service/SystemAlertsService.java | 127 -
.../pulse/internal/util/ConnectionUtil.java | 46 -
.../pulse/internal/util/IPAddressUtil.java | 65 -
.../tools/pulse/internal/util/StringUtils.java | 85 -
.../tools/pulse/internal/util/TimeUtils.java | 120 -
.../tools/pulse/internal/PulseAppListener.java | 742 ++++
.../controllers/ExceptionHandlingAdvice.java | 51 +
.../internal/controllers/PulseController.java | 524 +++
.../tools/pulse/internal/data/Cluster.java | 3815 ++++++++++++++++++
.../tools/pulse/internal/data/DataBrowser.java | 248 ++
.../pulse/internal/data/IClusterUpdater.java | 35 +
.../pulse/internal/data/JMXDataUpdater.java | 2392 +++++++++++
.../pulse/internal/data/JmxManagerFinder.java | 169 +
.../tools/pulse/internal/data/PulseConfig.java | 139 +
.../pulse/internal/data/PulseConstants.java | 434 ++
.../tools/pulse/internal/data/PulseVersion.java | 103 +
.../tools/pulse/internal/data/Repository.java | 246 ++
.../geode/tools/pulse/internal/json/CDL.java | 274 ++
.../geode/tools/pulse/internal/json/Cookie.java | 164 +
.../tools/pulse/internal/json/CookieList.java | 85 +
.../geode/tools/pulse/internal/json/HTTP.java | 158 +
.../tools/pulse/internal/json/HTTPTokener.java | 72 +
.../tools/pulse/internal/json/JSONArray.java | 901 +++++
.../pulse/internal/json/JSONException.java | 47 +
.../geode/tools/pulse/internal/json/JSONML.java | 462 +++
.../tools/pulse/internal/json/JSONObject.java | 1585 ++++++++
.../tools/pulse/internal/json/JSONString.java | 37 +
.../tools/pulse/internal/json/JSONStringer.java | 73 +
.../tools/pulse/internal/json/JSONTokener.java | 441 ++
.../tools/pulse/internal/json/JSONWriter.java | 322 ++
.../geode/tools/pulse/internal/json/README | 68 +
.../geode/tools/pulse/internal/json/XML.java | 503 +++
.../tools/pulse/internal/json/XMLTokener.java | 360 ++
.../tools/pulse/internal/log/LogWriter.java | 265 ++
.../pulse/internal/log/MessageFormatter.java | 102 +
.../pulse/internal/log/PulseLogWriter.java | 299 ++
.../tools/pulse/internal/log/PulseLogger.java | 142 +
.../security/GemFireAuthentication.java | 91 +
.../security/GemFireAuthenticationProvider.java | 80 +
.../pulse/internal/security/LogoutHandler.java | 55 +
.../internal/service/ClusterDetailsService.java | 104 +
.../service/ClusterDiskThroughputService.java | 71 +
.../service/ClusterGCPausesService.java | 69 +
.../service/ClusterKeyStatisticsService.java | 69 +
.../internal/service/ClusterMemberService.java | 132 +
.../service/ClusterMembersRGraphService.java | 359 ++
.../service/ClusterMemoryUsageService.java | 65 +
.../internal/service/ClusterRegionService.java | 211 +
.../internal/service/ClusterRegionsService.java | 206 +
.../service/ClusterSelectedRegionService.java | 237 ++
.../ClusterSelectedRegionsMemberService.java | 143 +
.../internal/service/ClusterWANInfoService.java | 75 +
.../service/MemberAsynchEventQueuesService.java | 99 +
.../internal/service/MemberClientsService.java | 101 +
.../internal/service/MemberDetailsService.java | 122 +
.../service/MemberDiskThroughputService.java | 76 +
.../internal/service/MemberGCPausesService.java | 73 +
.../service/MemberGatewayHubService.java | 149 +
.../service/MemberHeapUsageService.java | 73 +
.../service/MemberKeyStatisticsService.java | 76 +
.../internal/service/MemberRegionsService.java | 127 +
.../internal/service/MembersListService.java | 75 +
.../pulse/internal/service/PulseService.java | 40 +
.../internal/service/PulseServiceFactory.java | 55 +
.../internal/service/PulseVersionService.java | 65 +
.../service/QueryStatisticsService.java | 115 +
.../internal/service/SystemAlertsService.java | 127 +
.../pulse/internal/util/ConnectionUtil.java | 46 +
.../pulse/internal/util/IPAddressUtil.java | 65 +
.../tools/pulse/internal/util/StringUtils.java | 85 +
.../tools/pulse/internal/util/TimeUtils.java | 120 +
.../webapp/WEB-INF/mvc-dispatcher-servlet.xml | 2 +-
.../src/main/webapp/WEB-INF/spring-security.xml | 4 +-
geode-pulse/src/main/webapp/WEB-INF/web.xml | 2 +-
.../controllers/PulseControllerJUnitTest.java | 816 ----
.../pulse/testbed/GemFireDistributedSystem.java | 324 --
.../tools/pulse/testbed/GemfireTopology.java | 24 -
.../tools/pulse/testbed/PropFileHelper.java | 115 -
.../pulse/testbed/PropMockDataUpdater.java | 513 ---
.../gemfire/tools/pulse/testbed/TestBed.java | 84 -
.../tools/pulse/testbed/driver/PulseUITest.java | 279 --
.../tools/pulse/tests/AggregateStatement.java | 217 -
.../pulse/tests/AggregateStatementMBean.java | 168 -
.../pulse/tests/DataBrowserResultLoader.java | 84 -
.../pulse/tests/GemFireXDAggregateTable.java | 46 -
.../tests/GemFireXDAggregateTableMBean.java | 28 -
.../tools/pulse/tests/GemFireXDCluster.java | 95 -
.../pulse/tests/GemFireXDClusterMBean.java | 32 -
.../tools/pulse/tests/GemFireXDMember.java | 80 -
.../tools/pulse/tests/GemFireXDMemberMBean.java | 31 -
.../gemfire/tools/pulse/tests/JMXBaseBean.java | 67 -
.../tools/pulse/tests/JMXProperties.java | 47 -
.../gemfire/tools/pulse/tests/Member.java | 193 -
.../gemfire/tools/pulse/tests/MemberMBean.java | 86 -
.../tools/pulse/tests/PulseAbstractTest.java | 1049 -----
.../tools/pulse/tests/PulseAuthTest.java | 33 -
.../tools/pulse/tests/PulseAutomatedTest.java | 784 ----
.../tools/pulse/tests/PulseBaseTest.java | 693 ----
.../tools/pulse/tests/PulseNoAuthTest.java | 33 -
.../tools/pulse/tests/PulseTestData.java | 106 -
.../tools/pulse/tests/PulseTestLocators.java | 225 --
.../gemfire/tools/pulse/tests/Region.java | 187 -
.../gemfire/tools/pulse/tests/RegionMBean.java | 59 -
.../tools/pulse/tests/RegionOnMember.java | 95 -
.../tools/pulse/tests/RegionOnMemberMBean.java | 49 -
.../gemfire/tools/pulse/tests/Server.java | 247 --
.../gemfire/tools/pulse/tests/ServerObject.java | 267 --
.../tools/pulse/tests/ServerObjectMBean.java | 79 -
.../pulse/tests/junit/BaseServiceTest.java | 254 --
.../junit/ClusterSelectedRegionServiceTest.java | 340 --
...ClusterSelectedRegionsMemberServiceTest.java | 354 --
.../junit/MemberGatewayHubServiceTest.java | 412 --
.../controllers/PulseControllerJUnitTest.java | 816 ++++
.../pulse/testbed/GemFireDistributedSystem.java | 324 ++
.../tools/pulse/testbed/GemfireTopology.java | 24 +
.../tools/pulse/testbed/PropFileHelper.java | 115 +
.../pulse/testbed/PropMockDataUpdater.java | 513 +++
.../geode/tools/pulse/testbed/TestBed.java | 84 +
.../tools/pulse/testbed/driver/PulseUITest.java | 279 ++
.../tools/pulse/tests/AggregateStatement.java | 217 +
.../pulse/tests/AggregateStatementMBean.java | 168 +
.../pulse/tests/DataBrowserResultLoader.java | 84 +
.../pulse/tests/GemFireXDAggregateTable.java | 46 +
.../tests/GemFireXDAggregateTableMBean.java | 28 +
.../tools/pulse/tests/GemFireXDCluster.java | 95 +
.../pulse/tests/GemFireXDClusterMBean.java | 32 +
.../tools/pulse/tests/GemFireXDMember.java | 80 +
.../tools/pulse/tests/GemFireXDMemberMBean.java | 31 +
.../geode/tools/pulse/tests/JMXBaseBean.java | 67 +
.../geode/tools/pulse/tests/JMXProperties.java | 47 +
.../apache/geode/tools/pulse/tests/Member.java | 193 +
.../geode/tools/pulse/tests/MemberMBean.java | 86 +
.../tools/pulse/tests/PulseAbstractTest.java | 1049 +++++
.../geode/tools/pulse/tests/PulseAuthTest.java | 33 +
.../tools/pulse/tests/PulseAutomatedTest.java | 784 ++++
.../geode/tools/pulse/tests/PulseBaseTest.java | 693 ++++
.../tools/pulse/tests/PulseNoAuthTest.java | 33 +
.../geode/tools/pulse/tests/PulseTestData.java | 106 +
.../tools/pulse/tests/PulseTestLocators.java | 225 ++
.../apache/geode/tools/pulse/tests/Region.java | 187 +
.../geode/tools/pulse/tests/RegionMBean.java | 59 +
.../geode/tools/pulse/tests/RegionOnMember.java | 95 +
.../tools/pulse/tests/RegionOnMemberMBean.java | 49 +
.../apache/geode/tools/pulse/tests/Server.java | 247 ++
.../geode/tools/pulse/tests/ServerObject.java | 267 ++
.../tools/pulse/tests/ServerObjectMBean.java | 79 +
.../pulse/tests/junit/BaseServiceTest.java | 254 ++
.../junit/ClusterSelectedRegionServiceTest.java | 340 ++
...ClusterSelectedRegionsMemberServiceTest.java | 354 ++
.../junit/MemberGatewayHubServiceTest.java | 412 ++
211 files changed, 27513 insertions(+), 27513 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/PulseAppListener.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/PulseAppListener.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/PulseAppListener.java
deleted file mode 100644
index 1ca921e..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/PulseAppListener.java
+++ /dev/null
@@ -1,742 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal;
-
-import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConfig;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.context.support.WebApplicationContextUtils;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.logging.Level;
-
-/**
- * This class is used for checking the application running mode i.e. Embedded or
- * not
- *
- * @since GemFire version 7.0.Beta 2012-09-23
- *
- */
-// @WebListener
-public class PulseAppListener implements ServletContextListener {
- private PulseLogWriter LOGGER;
- private final ResourceBundle resourceBundle = Repository.get()
- .getResourceBundle();
-
- // String object to store all messages which needs to be logged into the log
- // file before logger gets initialized
- private String messagesToBeLogged = "";
-
- private Properties pulseProperties;
- private Properties pulseSecurityProperties;
- private Boolean sysPulseUseLocator;
- private String sysPulseHost;
- private String sysPulsePort;
- private String jmxUserName;
- private String jmxUserPassword;
-
- private boolean sysPulseUseSSLLocator;
- private boolean sysPulseUseSSLManager;
-
- //This property determines if pulse webApp login is authenticated against
- //GemFire integrated security or custom spring-security config provided
- //in pulse-authentication-custom.xml
- private boolean useGemFireCredentials;
-
- @Override
- public void contextDestroyed(ServletContextEvent event) {
-
- // Stop all running threads those are created in Pulse
- // Stop cluster threads
- Repository.get().removeAllClusters();
-
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_CONTEXT_DESTROYED")
- + event.getServletContext().getContextPath());
- }
- }
-
- @Override
- public void contextInitialized(ServletContextEvent event) {
-
- messagesToBeLogged = messagesToBeLogged
- .concat(formatLogString(resourceBundle
- .getString("LOG_MSG_CONTEXT_INITIALIZED")));
-
- // Load Pulse version details
- loadPulseVersionDetails();
-
- // Load Pulse Properties
- pulseProperties = loadProperties(PulseConstants.PULSE_PROPERTIES_FILE);
-
- if (pulseProperties.isEmpty()) {
- messagesToBeLogged = messagesToBeLogged
- .concat(formatLogString(resourceBundle
- .getString("LOG_MSG_PROPERTIES_NOT_FOUND")));
- } else {
- messagesToBeLogged = messagesToBeLogged
- .concat(formatLogString(resourceBundle
- .getString("LOG_MSG_PROPERTIES_FOUND")));
-
- // set Pulse product support into the Pulse controller for access from
- // client side
- // to display the appropriate ui depending on which product is supported
- // in present deployment
- String pulseProduct = pulseProperties.getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_PRODUCTSUPPORT);
- // default is gemfire
-
- if ((pulseProduct != null) && (pulseProduct.trim().equalsIgnoreCase(PulseConstants.PRODUCT_NAME_SQLFIRE))) {
- PulseController.setPulseProductSupport(PulseConstants.PRODUCT_NAME_SQLFIRE);
- }
- }
-
- pulseSecurityProperties = loadProperties(PulseConstants.PULSE_SECURITY_PROPERTIES_FILE);
-
- // Initialize logger
- initializeLogger();
-
- // Reference to repository
- Repository repository = Repository.get();
-
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_CHECK_APP_RUNNING_MODE"));
- }
-
- boolean sysIsEmbedded = Boolean
- .getBoolean(PulseConstants.SYSTEM_PROPERTY_PULSE_EMBEDDED);
-
- if (sysIsEmbedded) {
- // Application Pulse is running in Embedded Mode
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle
- .getString("LOG_MSG_APP_RUNNING_EMBEDDED_MODE"));
- }
- repository.setIsEmbeddedMode(true);
-
- sysPulseUseLocator = Boolean.FALSE;
- try{
- // Get host name of machine running pulse in embedded mode
- sysPulseHost = InetAddress.getLocalHost().getCanonicalHostName();
- } catch (UnknownHostException e) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine(resourceBundle
- .getString("LOG_MSG_JMX_CONNECTION_UNKNOWN_HOST")
- + e.getMessage());
- }
- // Set default host name
- sysPulseHost = PulseConstants.GEMFIRE_DEFAULT_HOST;
- } catch (Exception e) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine(resourceBundle
- .getString("LOG_MSG_JMX_CONNECTION_UNKNOWN_HOST")
- + e.getMessage());
- }
- // Set default host name
- sysPulseHost = PulseConstants.GEMFIRE_DEFAULT_HOST;
- }
- sysPulsePort = PulseConstants.GEMFIRE_DEFAULT_PORT;
-
- boolean pulseEmbededSqlf = Boolean.getBoolean(PulseConstants.SYSTEM_PROPERTY_PULSE_EMBEDDED_SQLF);
- if(pulseEmbededSqlf){
- PulseController.setPulseProductSupport(PulseConstants.PRODUCT_NAME_SQLFIRE);
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle
- .getString("LOG_MSG_APP_RUNNING_EMBEDDED_SQLF_MODE"));
- }
- }
-
- } else {
- // Application Pulse is running in Non-Embedded Mode
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle
- .getString("LOG_MSG_APP_RUNNING_NONEMBEDDED_MODE"));
- }
- repository.setIsEmbeddedMode(false);
-
- // Load JMX User Details
- loadJMXUserDetails();
- // Load locator and/or manager details
- loadLocatorManagerDetails();
-
- useGemFireCredentials = areWeUsingGemFireSecurityProfile(event);
- }
-
- // Set user details in repository
- repository.setJmxUserName(jmxUserName);
- repository.setJmxUserPassword(jmxUserPassword);
-
- // Set locator/Manager details in repository
- repository.setJmxUseLocator(sysPulseUseLocator);
- repository.setJmxHost(sysPulseHost);
- repository.setJmxPort(sysPulsePort);
-
- //set SSL info
- initializeSSL();
- repository.setUseSSLLocator(sysPulseUseSSLLocator);
- repository.setUseSSLManager(sysPulseUseSSLManager);
-
- repository.setUseGemFireCredentials(useGemFireCredentials);
-
- }
-
- /**
- * Return true if pulse is configure to authenticate using gemfire
- * integrated security
- *
- * @param event
- * @return
- */
- private boolean areWeUsingGemFireSecurityProfile(ServletContextEvent event) {
- String profile = null;
- WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
- if (ctx.getEnvironment() != null) {
- String[] profiles = ctx.getEnvironment().getActiveProfiles();
- if (profiles != null && profiles.length > 0) {
- StringBuilder sb = new StringBuilder();
- for (String p : profiles)
- sb.append(p).append(",");
- LOGGER.info("#SpringProfilesConfigured : " + sb.toString());
- profile = ctx.getEnvironment().getActiveProfiles()[0];
- LOGGER.info("#First Profile : " + profile);
- } else {
- LOGGER.info("No SpringProfileConfigured using default spring profile");
- return false;
- }
- }
- if (PulseConstants.APPLICATION_PROPERTY_PULSE_SEC_PROFILE_GEMFIRE.equals(profile)) {
- LOGGER.info("Using gemfire integrated security profile");
- return true;
- }
- return false;
- }
-
- // Function to load pulse version details from properties file
- private void loadPulseVersionDetails() {
-
- // Read version details from version property file
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- InputStream inputStream = classLoader
- .getResourceAsStream(PulseConstants.PULSE_VERSION_PROPERTIES_FILE);
-
- if (inputStream != null) {
- Properties properties = new Properties();
- try {
- properties.load(inputStream);
- } catch (IOException e) {
- messagesToBeLogged = messagesToBeLogged
- .concat(formatLogString(resourceBundle
- .getString("LOG_MSG_EXCEPTION_LOADING_PROPERTIES_FILE")));
- } finally {
- try {
- inputStream.close();
- } catch (IOException e) {
- messagesToBeLogged = messagesToBeLogged
- .concat(formatLogString(resourceBundle
- .getString("LOG_MSG_EXCEPTION_CLOSING_INPUT_STREAM")));
- }
- }
- // Set pulse version details in common object
- PulseController.pulseVersion.setPulseVersion(properties.getProperty(
- PulseConstants.PROPERTY_PULSE_VERSION, ""));
- PulseController.pulseVersion.setPulseBuildId(properties.getProperty(
- PulseConstants.PROPERTY_BUILD_ID, ""));
- PulseController.pulseVersion.setPulseBuildDate(properties.getProperty(
- PulseConstants.PROPERTY_BUILD_DATE, ""));
- PulseController.pulseVersion.setPulseSourceDate(properties.getProperty(
- PulseConstants.PROPERTY_SOURCE_DATE, ""));
- PulseController.pulseVersion.setPulseSourceRevision(properties
- .getProperty(PulseConstants.PROPERTY_SOURCE_REVISION, ""));
- PulseController.pulseVersion.setPulseSourceRepository(properties
- .getProperty(PulseConstants.PROPERTY_SOURCE_REPOSITORY, ""));
- }
-
- // Log Pulse Version details into log file
- messagesToBeLogged = messagesToBeLogged
- .concat(formatLogString(PulseController.pulseVersion
- .getPulseVersionLogMessage()));
- }
-
- private void initializeLogger() {
-
- // Override default log configuration by properties which are provided in
- // properties file.
- loadLogDetailsFromPropertyFile();
-
- // Override log configuration by properties which are provided in
- // through system properties.
- loadLogDetailsFromSystemProperties();
-
- // Initialize logger object
- LOGGER = PulseLogWriter.getLogger();
-
- // Log messages stored in messagesToBeLogged
- if (LOGGER.infoEnabled()) {
- LOGGER.info(messagesToBeLogged);
- messagesToBeLogged = "";
- }
- }
-
- // Function to load pulse properties from pulse.properties file
- private Properties loadProperties(String propertyFile) {
-
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- InputStream inputStream = classLoader.getResourceAsStream(propertyFile);
- Properties properties = new Properties();
-
- if (inputStream != null) {
- messagesToBeLogged = messagesToBeLogged.concat(formatLogString(propertyFile + " "
- + resourceBundle.getString("LOG_MSG_FILE_FOUND")));
-
- try {
- // Load properties from input stream
- properties.load(inputStream);
- } catch (IOException e1) {
- messagesToBeLogged = messagesToBeLogged.concat(formatLogString(resourceBundle
- .getString("LOG_MSG_EXCEPTION_LOADING_PROPERTIES_FILE")
- + " " + propertyFile));
- } finally {
- // Close input stream
- try {
- inputStream.close();
- } catch (IOException e) {
- messagesToBeLogged = messagesToBeLogged.concat(formatLogString(resourceBundle
- .getString("LOG_MSG_EXCEPTION_CLOSING_INPUT_STREAM")
- + " " + propertyFile));
- }
- }
-
- } else {
- messagesToBeLogged = messagesToBeLogged.concat(formatLogString(resourceBundle
- .getString("LOG_MSG_COULD_NOT_READ_FILE")
- + " " + propertyFile));
- }
- return properties;
- }
-
- // Function to load Logging details from properties file
- private void loadLogDetailsFromPropertyFile() {
-
- // return, if Pulse Properties are not provided
- if (pulseProperties.size() == 0) {
- return;
- }
-
- messagesToBeLogged = messagesToBeLogged
- .concat(formatLogString(resourceBundle
- .getString("LOG_MSG_CHECK_LOG_PROPERTIES_IN_FILE")));
-
- HashMap<String, String> logPropertiesHM = new HashMap<String, String>();
-
- logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME,
- pulseProperties.getProperty(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME, ""));
-
- logPropertiesHM.put(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION,
- pulseProperties.getProperty(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION, ""));
-
- logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE,
- pulseProperties.getProperty(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE, ""));
-
- logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT,
- pulseProperties.getProperty(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT, ""));
-
- logPropertiesHM.put(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN,
- pulseProperties.getProperty(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN, ""));
-
- logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL,
- pulseProperties.getProperty(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL, ""));
-
- logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND,
- pulseProperties.getProperty(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND, ""));
-
- if (logPropertiesHM.size() == 0) {
- messagesToBeLogged = messagesToBeLogged
- .concat(formatLogString(resourceBundle
- .getString("LOG_MSG_LOG_PROPERTIES_NOT_FOUND_IN_FILE")));
- } else {
- messagesToBeLogged = messagesToBeLogged
- .concat(formatLogString(resourceBundle
- .getString("LOG_MSG_LOG_PROPERTIES_FOUND_IN_FILE")));
- }
-
- setLogConfigurations(logPropertiesHM);
- }
-
- // Function to load Logging details from system properties
- private void loadLogDetailsFromSystemProperties() {
-
- messagesToBeLogged = messagesToBeLogged
- .concat(formatLogString(resourceBundle
- .getString("LOG_MSG_CHECK_LOG_PROPERTIES_IN_SYSTEM_PROPERTIES")));
-
- HashMap<String, String> logPropertiesHM = new HashMap<String, String>();
-
- String sysLogFileName = System
- .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME);
- String sysLogFileLocation = System
- .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION);
- String sysLogFileSize = System
- .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE);
- String sysLogFileCount = System
- .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT);
- String sysLogDatePattern = System
- .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN);
- String sysLogLevel = System
- .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL);
- String sysLogAppend = System
- .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND);
-
- if (sysLogFileName == null || sysLogFileName.isEmpty()) {
- logPropertiesHM.put(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME, "");
- } else {
- logPropertiesHM
- .put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME,
- sysLogFileName);
- }
-
- if (sysLogFileLocation == null || sysLogFileLocation.isEmpty()) {
- logPropertiesHM.put(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION, "");
- } else {
- logPropertiesHM.put(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION,
- sysLogFileLocation);
- }
-
- if (sysLogFileSize == null || sysLogFileSize.isEmpty()) {
- logPropertiesHM.put(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE, "");
- } else {
- logPropertiesHM
- .put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE,
- sysLogFileSize);
- }
-
- if (sysLogFileCount == null || sysLogFileCount.isEmpty()) {
- logPropertiesHM.put(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT, "");
- } else {
- logPropertiesHM.put(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT,
- sysLogFileCount);
- }
-
- if (sysLogDatePattern == null || sysLogDatePattern.isEmpty()) {
- logPropertiesHM.put(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN, "");
- } else {
- logPropertiesHM.put(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN,
- sysLogDatePattern);
- }
-
- if (sysLogLevel == null || sysLogLevel.isEmpty()) {
- logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL,
- "");
- } else {
- logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL,
- sysLogLevel);
- }
-
- if (sysLogAppend == null || sysLogAppend.isEmpty()) {
- logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND,
- "");
- } else {
- logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND,
- sysLogAppend);
- }
-
- if (logPropertiesHM.size() == 0) {
- messagesToBeLogged = messagesToBeLogged
- .concat(formatLogString(resourceBundle
- .getString("LOG_MSG_LOG_PROPERTIES_NOT_FOUND_IN_SYSTEM_PROPERTIES")));
- } else {
- messagesToBeLogged = messagesToBeLogged
- .concat(formatLogString(resourceBundle
- .getString("LOG_MSG_LOG_PROPERTIES_FOUND_IN_SYSTEM_PROPERTIES")));
- }
-
- setLogConfigurations(logPropertiesHM);
- }
-
- private void setLogConfigurations(HashMap<String, String> logPropertiesHM) {
-
- PulseConfig pulseConfig = Repository.get().getPulseConfig();
-
- // log file name
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
- .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME))) {
- pulseConfig.setLogFileName(logPropertiesHM
- .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME));
- }
-
- // log file location
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
- .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION))) {
- pulseConfig.setLogFileLocation(logPropertiesHM
- .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION));
- }
-
- // log file size
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
- .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE))) {
- pulseConfig.setLogFileSize(Integer.parseInt(logPropertiesHM
- .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE)));
- }
-
- // log file count
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
- .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT))) {
- pulseConfig.setLogFileCount(Integer.parseInt(logPropertiesHM
- .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT)));
- }
-
- // log message date pattern
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
- .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN))) {
- pulseConfig.setLogDatePattern(logPropertiesHM
- .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN));
- }
-
- // log level
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
- .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL))) {
- pulseConfig.setLogLevel(Level.parse(logPropertiesHM.get(
- PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL).toUpperCase()));
- }
-
- // log append
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
- .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND))) {
- pulseConfig.setLogAppend(Boolean.valueOf(logPropertiesHM
- .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND)));
- }
-
- }
-
- // Function to load JMX User details from properties
- private void loadJMXUserDetails() {
-
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_GET_JMX_USER_DETAILS"));
- }
-
- if (pulseProperties.isEmpty()) {
- if (LOGGER.infoEnabled()) {
- LOGGER
- .info(resourceBundle
- .getString("LOG_MSG_JMX_USER_DETAILS_NOT_FOUND")
- + resourceBundle
- .getString("LOG_MSG_REASON_USER_DETAILS_NOT_FOUND"));
- }
- } else {
- jmxUserName = pulseProperties.getProperty(
- PulseConstants.APPLICATION_PROPERTY_PULSE_JMXUSERNAME, "");
- jmxUserPassword = pulseProperties.getProperty(
- PulseConstants.APPLICATION_PROPERTY_PULSE_JMXPASSWORD, "");
-
- if (jmxUserName.isEmpty() || jmxUserPassword.isEmpty()) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle
- .getString("LOG_MSG_JMX_USER_DETAILS_NOT_FOUND")
- + resourceBundle
- .getString("LOG_MSG_REASON_USER_DETAILS_NOT_FOUND"));
- }
- } else {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle
- .getString("LOG_MSG_JMX_USER_DETAILS_FOUND"));
- }
- }
- }
- }
-
-//Function to set SSL VM arguments
- private void initializeSSL() {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_GET_SSL_DETAILS"));
- }
-
-
- this.sysPulseUseSSLLocator = Boolean.valueOf(pulseProperties.getProperty(
- PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_LOCATOR, "false"));
-
- this.sysPulseUseSSLManager = Boolean.valueOf(pulseProperties.getProperty(
- PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_MANAGER, "false"));
-
-
- if ((sysPulseUseSSLLocator || sysPulseUseSSLManager)) {
- Properties sslProperties = new Properties();
- if (!pulseSecurityProperties.isEmpty()) {
- Set entrySet = pulseSecurityProperties.entrySet();
- for (Iterator it = entrySet.iterator(); it.hasNext();) {
- Entry<String, String> entry = (Entry<String, String>) it.next();
- String key = entry.getKey();
- if (key.startsWith("javax.net.ssl.")) {
-
- String val = entry.getValue();
- System.setProperty(key, val);
- sslProperties.setProperty(key, val);
- }
- }
- }
- if (sslProperties.isEmpty()) {
- if (LOGGER.warningEnabled()) {
- LOGGER.warning(resourceBundle.getString("LOG_MSG_SSL_NOT_SET"));
- }
- }
- }
-
- }
-
- // Function to load locator and/or manager details
- private void loadLocatorManagerDetails() {
-
- // Get locator details through System Properties
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_GET_LOCATOR_DETAILS_1"));
- }
-
- // Required System properties are
- // -Dpulse.embedded="false" -Dpulse.useLocator="false"
- // -Dpulse.host="192.168.2.11" -Dpulse.port="2099"
- sysPulseUseLocator = Boolean
- .getBoolean(PulseConstants.SYSTEM_PROPERTY_PULSE_USELOCATOR);
- sysPulseHost = System
- .getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_HOST);
- sysPulsePort = System
- .getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_PORT);
-
- if (sysPulseHost == null || sysPulseHost.isEmpty() || sysPulsePort == null
- || sysPulsePort.isEmpty()) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle
- .getString("LOG_MSG_LOCATOR_DETAILS_NOT_FOUND")
- + resourceBundle
- .getString("LOG_MSG_REASON_LOCATOR_DETAILS_NOT_FOUND_1"));
- LOGGER.info(resourceBundle.getString("LOG_MSG_GET_LOCATOR_DETAILS_2"));
- }
-
- if (pulseProperties.isEmpty()) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle
- .getString("LOG_MSG_LOCATOR_DETAILS_NOT_FOUND")
- + resourceBundle
- .getString("LOG_MSG_REASON_LOCATOR_DETAILS_NOT_FOUND_2"));
- }
-
- sysPulseHost = "";
- sysPulsePort = "";
- } else {
- if (LOGGER.infoEnabled()) {
- LOGGER
- .info(resourceBundle.getString("LOG_MSG_LOCATOR_DETAILS_FOUND"));
- }
-
- sysPulseUseLocator = Boolean.valueOf(pulseProperties.getProperty(
- PulseConstants.APPLICATION_PROPERTY_PULSE_USELOCATOR, ""));
- sysPulseHost = pulseProperties.getProperty(
- PulseConstants.APPLICATION_PROPERTY_PULSE_HOST, "");
- sysPulsePort = pulseProperties.getProperty(
- PulseConstants.APPLICATION_PROPERTY_PULSE_PORT, "");
- }
- } else {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(resourceBundle.getString("LOG_MSG_LOCATOR_DETAILS_FOUND"));
- }
- }
- }
-
- private String formatLogString(String logMessage) {
-
- DateFormat df = new SimpleDateFormat(
- PulseConstants.LOG_MESSAGE_DATE_PATTERN);
- // DateFormat df = new
- // SimpleDateFormat(Repository.get().getPulseConfig().getLogDatePattern());
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
-
- pw.println();
- pw.print("[");
- pw.print("INFO");
- pw.print(" ");
- pw.print(df.format(new Date(System.currentTimeMillis())));
- String threadName = Thread.currentThread().getName();
- if (threadName != null) {
- pw.print(" ");
- pw.print(threadName);
- }
- pw.print(" tid=0x");
- pw.print(Long.toHexString(Thread.currentThread().getId()));
- pw.print("] ");
- pw.print("(msgTID=");
- pw.print("");
-
- pw.print(" msgSN=");
- pw.print("");
-
- pw.print(") ");
-
- pw.println("[" + PulseConstants.APP_NAME + "]");
-
- pw.println(PulseLogWriter.class.getName());
-
- pw.println(logMessage);
-
- pw.close();
- try {
- sw.close();
- } catch (IOException ignore) {
- }
- String result = sw.toString();
- return result;
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java
deleted file mode 100644
index f98b5fd..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.controllers;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-import com.vmware.gemfire.tools.pulse.internal.log.PulseLogWriter;
-
-/**
- * For handling IO exception in our controllers
- *
- *
- */
-@ControllerAdvice
-public class ExceptionHandlingAdvice {
-
- @ExceptionHandler(IOException.class)
- @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
- public void handleExc(IOException ext) {
- PulseLogWriter LOGGER = PulseLogWriter.getLogger();
- // write errors
- StringWriter swBuffer = new StringWriter();
- PrintWriter prtWriter = new PrintWriter(swBuffer);
- ext.printStackTrace(prtWriter);
- LOGGER.severe("IOException Details : " + swBuffer.toString() + "\n");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/controllers/PulseController.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/controllers/PulseController.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/controllers/PulseController.java
deleted file mode 100644
index 3b8a87d..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/controllers/PulseController.java
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.controllers;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseVersion;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.gemfire.tools.pulse.internal.service.PulseService;
-import com.vmware.gemfire.tools.pulse.internal.service.PulseServiceFactory;
-import com.vmware.gemfire.tools.pulse.internal.service.SystemAlertsService;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-
-import org.apache.commons.lang.StringEscapeUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-/**
- * Class PulseController
- *
- * This class contains the implementations for all http Ajax requests needs to
- * be served in Pulse.
- *
- * @since GemFire version 7.5
- */
-@Controller
-public class PulseController {
-
- private static final PulseLogWriter LOGGER = PulseLogWriter.getLogger();
-
- // CONSTANTS
- private final String DEFAULT_EXPORT_FILENAME = "DataBrowserQueryResult.json";
- private final String QUERYSTRING_PARAM_ACTION = "action";
- private final String QUERYSTRING_PARAM_QUERYID = "queryId";
- private final String ACTION_VIEW = "view";
- private final String ACTION_DELETE = "delete";
-
- private String STATUS_REPSONSE_SUCCESS = "success";
- private String STATUS_REPSONSE_FAIL = "fail";
-
- private String ERROR_REPSONSE_QUERYNOTFOUND = "No queries found";
- private String ERROR_REPSONSE_QUERYIDMISSING = "Query id is missing";
-
- private static final String EMPTY_JSON = "{}";
-
- // Shared object to hold pulse version details
- public static PulseVersion pulseVersion = new PulseVersion();
-
- //default is gemfire
- private static String pulseProductSupport = PulseConstants.PRODUCT_NAME_GEMFIRE;
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- @Autowired
- PulseServiceFactory pulseServiceFactory;
-
- @RequestMapping(value = "/pulseUpdate", method = RequestMethod.POST)
- public void getPulseUpdate(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
- String pulseData = request.getParameter("pulseData");
-
- ObjectNode responseMap = mapper.createObjectNode();
-
- JsonNode requestMap = null;
-
- try {
- requestMap = mapper.readTree(pulseData);
- Iterator<?> keys = requestMap.fieldNames();
-
- // Execute Services
- while (keys.hasNext()) {
- String serviceName = keys.next().toString();
- try {
- PulseService pulseService = pulseServiceFactory
- .getPulseServiceInstance(serviceName);
- responseMap.put(serviceName, pulseService.execute(request));
- } catch (Exception serviceException) {
- LOGGER.warning("serviceException [for service "+serviceName+"] = " + serviceException.getMessage());
- responseMap.put(serviceName, EMPTY_JSON);
- }
- }
- } catch (Exception e) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine("Exception Occurred : " + e.getMessage());
- }
- }
-
- // Create Response
- response.getOutputStream().write(responseMap.toString().getBytes());
- }
-
- @RequestMapping(value = "/authenticateUser", method = RequestMethod.GET)
- public void authenticateUser(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- try {
- responseJSON.put("isUserLoggedIn", this.isUserLoggedIn(request));
- // Send json response
- response.getOutputStream().write(responseJSON.toString().getBytes());
- } catch (Exception e) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine("Exception Occurred : " + e.getMessage());
- }
- }
- }
-
- /**
- * Method isUserLoggedIn Check whether user is logged in or not.
- *
- * @param request
- * @return boolean
- */
- protected boolean isUserLoggedIn(HttpServletRequest request) {
- return null != request.getUserPrincipal();
- }
-
- @RequestMapping(value = "/pulseVersion", method = RequestMethod.GET)
- public void pulseVersion(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- try {
- // Reference to repository
- Repository repository = Repository.get();
- // set pulse web app url
- String pulseWebAppUrl = request.getScheme() + "://"
- + request.getServerName() + ":" + request.getServerPort()
- + request.getContextPath();
-
- repository.setPulseWebAppUrl(pulseWebAppUrl);
-
- // Response
- responseJSON.put("pulseVersion", PulseController.pulseVersion.getPulseVersion());
- responseJSON.put("buildId", PulseController.pulseVersion.getPulseBuildId());
- responseJSON.put("buildDate", PulseController.pulseVersion.getPulseBuildDate());
- responseJSON.put("sourceDate", PulseController.pulseVersion.getPulseSourceDate());
- responseJSON.put("sourceRevision", PulseController.pulseVersion.getPulseSourceRevision());
- responseJSON.put("sourceRepository", PulseController.pulseVersion.getPulseSourceRepository());
-
- } catch (Exception e) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine("Exception Occured : " + e.getMessage());
- }
- }
-
- // Send json response
- response.getOutputStream().write(responseJSON.toString().getBytes());
- }
-
- @RequestMapping(value = "/clearAlerts", method = RequestMethod.GET)
- public void clearAlerts(HttpServletRequest request, HttpServletResponse response) throws IOException {
- int alertType;
- ObjectNode responseJSON = mapper.createObjectNode();
-
- try {
- alertType = Integer.valueOf(request.getParameter("alertType"));
- } catch (NumberFormatException e) {
- // Empty json response
- response.getOutputStream().write(responseJSON.toString().getBytes());
- if (LOGGER.finerEnabled()) {
- LOGGER.finer(e.getMessage());
- }
- return;
- }
-
- try {
- boolean isClearAll = Boolean.valueOf(request.getParameter("clearAll"));
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
- cluster.clearAlerts(alertType, isClearAll);
- responseJSON.put("status", "deleted");
- responseJSON.put(
- "systemAlerts", SystemAlertsService.getAlertsJson(cluster,
- cluster.getNotificationPageNumber()));
- responseJSON.put("pageNumber", cluster.getNotificationPageNumber());
-
- boolean isGFConnected = cluster.isConnectedFlag();
- if(isGFConnected){
- responseJSON.put("connectedFlag", isGFConnected);
- }else{
- responseJSON.put("connectedFlag", isGFConnected);
- responseJSON.put("connectedErrorMsg", cluster.getConnectionErrorMsg());
- }
- } catch (Exception e) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine("Exception Occurred : " + e.getMessage());
- }
- }
-
- // Send json response
- response.getOutputStream().write(responseJSON.toString().getBytes());
- }
-
- @RequestMapping(value = "/acknowledgeAlert", method = RequestMethod.GET)
- public void acknowledgeAlert(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
- int alertId;
- ObjectNode responseJSON = mapper.createObjectNode();
-
- try {
- alertId = Integer.valueOf(request.getParameter("alertId"));
- } catch (NumberFormatException e) {
- // Empty json response
- response.getOutputStream().write(responseJSON.toString().getBytes());
- if (LOGGER.finerEnabled()) {
- LOGGER.finer(e.getMessage());
- }
- return;
- }
-
- try {
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // set alert is acknowledged
- cluster.acknowledgeAlert(alertId);
- responseJSON.put("status", "deleted");
- } catch (Exception e) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine("Exception Occured : " + e.getMessage());
- }
- }
-
- // Send json response
- response.getOutputStream().write(responseJSON.toString().getBytes());
- }
-
- @RequestMapping(value = "/dataBrowserRegions", method = RequestMethod.GET)
- public void dataBrowserRegions(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
- ArrayNode regionsData = mapper.createArrayNode();
-
- try {
- // getting cluster's Regions
- responseJSON.put("clusterName", cluster.getServerName());
- regionsData = getRegionsJson(cluster);
- responseJSON.put("clusterRegions", regionsData);
- responseJSON.put("connectedFlag", cluster.isConnectedFlag());
- responseJSON.put("connectedErrorMsg", cluster.getConnectionErrorMsg());
- } catch (Exception e) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine("Exception Occured : " + e.getMessage());
- }
- }
-
- // Send json response
- response.getOutputStream().write(responseJSON.toString().getBytes());
- }
-
- /**
- * This method creates json for list of cluster regions
- *
- * @param cluster
- * @return ArrayNode JSON array
- */
- private ArrayNode getRegionsJson(Cluster cluster) {
-
- Collection<Cluster.Region> clusterRegions = cluster.getClusterRegions().values();
- ArrayNode regionsListJson = mapper.createArrayNode();
-
- if (!clusterRegions.isEmpty()) {
- for (Cluster.Region region : clusterRegions) {
- ObjectNode regionJSON = mapper.createObjectNode();
- regionJSON.put("name", region.getName());
- regionJSON.put("fullPath", region.getFullPath());
- regionJSON.put("regionType", region.getRegionType());
-
- if (region.getRegionType().contains("PARTITION")) {
- regionJSON.put("isPartition", true);
- } else {
- regionJSON.put("isPartition", false);
- }
-
- regionJSON.put("memberCount", region.getMemberCount());
- List<String> regionsMembers = region.getMemberName();
- ArrayNode jsonRegionMembers = mapper.createArrayNode();
-
- for (int i = 0; i < regionsMembers.size(); i++) {
- Cluster.Member member = cluster.getMembersHMap().get(
- regionsMembers.get(i));
- ObjectNode jsonMember = mapper.createObjectNode();
- jsonMember.put("key", regionsMembers.get(i));
- jsonMember.put("id", member.getId());
- jsonMember.put("name", member.getName());
-
- jsonRegionMembers.add(jsonMember);
- }
-
- regionJSON.put("members", jsonRegionMembers);
- regionsListJson.add(regionJSON);
- }
- }
- return regionsListJson;
- }
-
- @RequestMapping(value = "/dataBrowserQuery", method = RequestMethod.GET)
- public void dataBrowserQuery(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
- // get query string
- String query = request.getParameter("query");
- String members = request.getParameter("members");
- int limit = 0;
-
- try {
- limit = Integer.valueOf(request.getParameter("limit"));
- } catch (NumberFormatException e) {
- limit = 0;
- if (LOGGER.finerEnabled()) {
- LOGGER.finer(e.getMessage());
- }
- }
-
- ObjectNode queryResult = mapper.createObjectNode();
- try {
-
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(query)) {
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
- String userName = request.getUserPrincipal().getName();
-
- // Call execute query method
- queryResult = cluster.executeQuery(query, members, limit);
-
- // Add query in history if query is executed successfully
- if (!queryResult.has("error")) {
- // Add html escaped query to history
- String escapedQuery = StringEscapeUtils.escapeHtml(query);
- cluster.addQueryInHistory(escapedQuery, userName);
- }
- }
- } catch (Exception e) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine("Exception Occured : " + e.getMessage());
- }
- }
-
- response.getOutputStream().write(queryResult.toString().getBytes());
- }
-
- @RequestMapping(value = "/dataBrowserQueryHistory", method = RequestMethod.GET)
- public void dataBrowserQueryHistory(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
- ObjectNode responseJSON = mapper.createObjectNode();
- ArrayNode queryResult = null;
- String action = "";
-
- try {
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
- String userName = request.getUserPrincipal().getName();
-
- // get query string
- action = request.getParameter(QUERYSTRING_PARAM_ACTION);
- if (!StringUtils.isNotNullNotEmptyNotWhiteSpace(action)) {
- action = ACTION_VIEW;
- }
-
- if (action.toLowerCase().equalsIgnoreCase(ACTION_DELETE)) {
- String queryId = request.getParameter(QUERYSTRING_PARAM_QUERYID);
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(queryId)) {
-
- boolean deleteStatus = cluster.deleteQueryById(userName, queryId);
- if (deleteStatus) {
- responseJSON.put("status", STATUS_REPSONSE_SUCCESS);
- } else {
- responseJSON.put("status", STATUS_REPSONSE_FAIL);
- responseJSON.put("error", ERROR_REPSONSE_QUERYNOTFOUND);
- }
- } else {
- responseJSON.put("status", STATUS_REPSONSE_FAIL);
- responseJSON.put("error", ERROR_REPSONSE_QUERYIDMISSING);
- }
- }
-
- // Get list of past executed queries
- queryResult = cluster.getQueryHistoryByUserId(userName);
- responseJSON.put("queryHistory", queryResult);
- } catch (Exception e) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine("Exception Occured : " + e.getMessage());
- }
- }
- response.getOutputStream().write(responseJSON.toString().getBytes());
- }
-
- @RequestMapping(value = "/dataBrowserExport", method = RequestMethod.POST)
- public void dataBrowserExport(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
-
- // get query string
- String filename = request.getParameter("filename");
- String resultContent = request.getParameter("content");
-
- response.setHeader("Cache-Control", "");
- response.setHeader("Content-type", "text/plain");
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(filename)) {
- response.setHeader("Content-Disposition", "attachment; filename=" + filename);
- } else {
- response.setHeader("Content-Disposition", "attachment; filename=" + DEFAULT_EXPORT_FILENAME);
- }
-
- if (!StringUtils.isNotNullNotEmptyNotWhiteSpace(resultContent)) {
- resultContent = "";
- }
-
- response.getOutputStream().write(resultContent.getBytes());
- }
-
- @RequestMapping(value = "/pulseProductSupport", method = RequestMethod.GET)
- public void getConfiguredPulseProduct(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
- ObjectNode responseJSON = mapper.createObjectNode();
-
- try {
- responseJSON.put("product", pulseProductSupport);
-
- // Send json response
- response.getOutputStream().write(responseJSON.toString().getBytes());
- } catch (Exception e) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine("Exception Occurred : " + e.getMessage());
- }
- }
- }
-
- @RequestMapping(value = "/getQueryStatisticsGridModel", method = RequestMethod.GET)
- public void getQueryStatisticsGridModel(HttpServletRequest request,
- HttpServletResponse response) throws IOException {
-
- ObjectNode responseJSON = mapper.createObjectNode();
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
- String userName = request.getUserPrincipal().getName();
-
- try {
- String[] arrColNames = Cluster.Statement.getGridColumnNames();
- String[] arrColAttribs = Cluster.Statement.getGridColumnAttributes();
- int[] arrColWidths = Cluster.Statement.getGridColumnWidths();
-
- ArrayNode colNamesList = mapper.createArrayNode();
- for (int i = 0; i < arrColNames.length; ++i) {
- colNamesList.add(arrColNames[i]);
- }
-
- ArrayNode colModelList = mapper.createArrayNode();
- for (int i = 0; i < arrColAttribs.length; ++i) {
- ObjectNode columnJSON = mapper.createObjectNode();
- columnJSON.put("name", arrColAttribs[i]);
- columnJSON.put("index", arrColAttribs[i]);
- columnJSON.put("width", arrColWidths[i]);
- columnJSON.put("sortable", "true");
- columnJSON.put("sorttype", ((i == 0) ? "String" : "integer"));
- colModelList.add(columnJSON);
- }
-
- responseJSON.put("columnNames", colNamesList);
- responseJSON.put("columnModels", colModelList);
- responseJSON.put("clusterName", cluster.getServerName());
- responseJSON.put("userName", userName);
-
- // Send json response
- response.getOutputStream().write(responseJSON.toString().getBytes());
- } catch (Exception e) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine("Exception Occured : " + e.getMessage());
- }
- }
- }
-
- /**
- * @return the pulseProductSupport
- */
- public static String getPulseProductSupport() {
- return pulseProductSupport;
- }
-
- /**
- * @param pulseProductSupport
- * the pulseProductSupport to set
- */
- public static void setPulseProductSupport(String pulseProductSupport) {
- PulseController.pulseProductSupport = pulseProductSupport;
- }
-}
\ No newline at end of file
[34/35] incubator-geode git commit: GEODE-37 changed sequence.gemfire
to org.apache.geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/sequence/SequenceDiagram.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/sequence/SequenceDiagram.java b/geode-core/src/test/java/org/apache/sequence/SequenceDiagram.java
deleted file mode 100644
index 1663add..0000000
--- a/geode-core/src/test/java/org/apache/sequence/SequenceDiagram.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sequence;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.*;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Created by IntelliJ IDEA.
- * User: dsmith
- * Date: Oct 29, 2010
- * Time: 4:18:40 PM
- * To change this template use File | Settings | File Templates.
- */
-public class SequenceDiagram extends JPanel {
-
- /**
- *
- */
- private static final Color HIGHLIGHT_COLOR = Color.RED;
-
- private final List<String> lineNames;
- private final Map<String, List<String>> shortLineNames;
- private final SortedMap<Comparable, SubDiagram> subDiagrams = new TreeMap<Comparable, SubDiagram>();
- private final StateColorMap colorMap = new StateColorMap();
- private final long minTime;
- private final long maxTime;
-
- private static int PADDING_BETWEEN_LINES = 100;
- private static int Y_PADDING = 20;
- private static final int STATE_WIDTH = 20;
- private static final int LINE_LABEL_BOUNDARY = 5;
- private static final int AXIS_SIZE=35;
-
- private int lineStep;
- private int lineWidth;
- private Popup mouseover;
- private LifelineState mouseoverState;
- private LifelineState selectedState;
-
- public SequenceDiagram(long minTime, long maxTime, List<String> lineNames, LineMapper lineMapper) {
- this.lineNames = lineNames;
- this.shortLineNames = parseShortNames(lineNames, lineMapper);
- this.minTime = minTime;
- this.maxTime = maxTime;
- int width = getInitialWidth();
- int height = 500;
- super.setPreferredSize(new Dimension(width, height));
- resizeMe(width, height);
- addComponentListener(new ComponentAdapter() {
- @Override
- public void componentResized(ComponentEvent e) {
- Component source = (Component) e.getSource();
- resizeMe(source.getWidth(), source.getHeight());
- }
- });
- setBackground(Color.WHITE);
- }
-
- private Map<String, List<String>> parseShortNames(List<String> lineNames, LineMapper lineMapper) {
- Map<String, List<String>> shortNames = new LinkedHashMap<String, List<String>>(lineNames.size());
- for(String name : lineNames) {
- String shortName = lineMapper.getShortNameForLine(name);
- List<String> list = shortNames.get(shortName);
- if(list == null) {
- list = new ArrayList<String>();
- shortNames.put(shortName, list);
- }
- list.add(name);
- }
-
- return shortNames;
- }
-
- public List<Comparable> getSubDiagramsNames() {
- return new ArrayList<Comparable>(subDiagrams.keySet());
-
- }
-
- public void addSubDiagram(Comparable name, Map<String, Lifeline> lines, List<Arrow> arrows) {
- subDiagrams.put(name, new SubDiagram(name, lines, arrows));
- }
-
- public void removeSubDiagram(Comparable name) {
- this.subDiagrams.remove(name);
- }
-
- private int getInitialWidth() {
- return (this.shortLineNames.size()) * PADDING_BETWEEN_LINES;
- }
-
- public void resizeMe(int width, int height) {
- this.setPreferredSize(new Dimension(width, height));
- float xZoom = width / (float) getInitialWidth();
-
-
- long elapsedTime = maxTime - minTime;
- double yScale = height / (double) elapsedTime;
-// long yBase = (long) (minTime - ((long) Y_PADDING / yScale));
- long yBase = minTime;
- lineStep = (int) (PADDING_BETWEEN_LINES * xZoom);
- lineWidth = (int) (STATE_WIDTH * xZoom);
-
- if(subDiagrams.size() <= 0) {
- return;
- }
-
- int sublineWidth = lineWidth / subDiagrams.size();
- int sublineIndex = 0;
- for(SubDiagram diagram : subDiagrams.values()) {
- int lineIndex = 0;
- for(List<String> fullNames : shortLineNames.values()) {
- for(String name : fullNames) {
- Lifeline line = diagram.lifelines.get(name);
- if(line != null) {
- int lineX = lineIndex * lineStep + sublineIndex * sublineWidth;
- line.resize(lineX, sublineWidth, yBase, yScale);
- }
- }
- lineIndex++;
- }
- sublineIndex++;
- }
- }
-
- public void showPopupText(int x, int y, int xOnScreen, int yOnScreen) {
- LifelineState state = getStateAt(x, y);
- if(state == mouseoverState) {
- return;
- }
- if(mouseover != null) {
- mouseover.hide();
- }
- if(state == null) {
- mouseover = null;
- mouseoverState = null;
- } else {
- Component popupContents = state.getPopup();
- mouseoverState = state;
- mouseover = PopupFactory.getSharedInstance().getPopup(this, popupContents, xOnScreen + 20, yOnScreen);
- mouseover.show();
- }
- }
-
- public void selectState(int x, int y) {
- LifelineState state = getStateAt(x, y);
- if(state == selectedState) {
- return;
- }
-
- if(selectedState != null) {
- fireRepaintOfDependencies(selectedState);
- }
-
- selectedState = state;
-
- if(state != null) {
- fireRepaintOfDependencies(state);
- }
- }
-
- private LifelineState getStateAt(int x, int y) {
- //TODO - this needs some
- //serious optimization to go straight to the right state
- // I think we need a tree map of of lines, keyed by x offset
- //and a keymap of states keyed by y offset.
- //That could make painting faster as well.
- List<String> reverseList = new ArrayList<String>(lineNames);
- Collections.reverse(reverseList);
- for(SubDiagram diagram : subDiagrams.values()) {
- for(String name : reverseList) {
- Lifeline line = diagram.lifelines.get(name);
- if(line != null) {
- if(line.getX() < x && line.getX() + line.getWidth() > x) {
- LifelineState state = line.getStateAt(y);
- if(state != null) {
- return state;
- }
- }
- }
- }
- }
- return null;
- }
-
- @Override
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
- Graphics2D g2 = (Graphics2D) g.create();
- //TODO - we should clip these to the visible lines
- for(SubDiagram subDiagram : subDiagrams.values()) {
- subDiagram.paintStates(g2, colorMap);
- }
-
- for(SubDiagram subDiagram : subDiagrams.values()) {
- subDiagram.paintArrows(g2, colorMap);
- }
- paintHighlightedComponents(g2, selectedState, new HashSet<LifelineState>());
- }
-
- private void fireRepaintOfDependencies(LifelineState state) {
- //TODO - it might be more efficient to repaint just the changed
- //areas, but right now this will do.
- repaint();
- }
-
- private void paintHighlightedComponents(Graphics2D g2, LifelineState endingState, Set<LifelineState> visited) {
- if(!visited.add(endingState)) {
- //Prevent cycles
- return;
- }
- g2.setColor(HIGHLIGHT_COLOR);
- if(endingState != null) {
- endingState.highlight(g2);
-
- for(Arrow arrow : endingState.getInboundArrows()) {
- arrow.paint(g2);
- paintHighlightedComponents(g2, arrow.getStartingState(), visited);
- }
- }
-
-
- }
-
- public long getMinTime() {
- return minTime;
- }
-
- public long getMaxTime() {
- return maxTime;
- }
-
- public JComponent createMemberAxis() {
- return new MemberAxis();
- }
-
- private class MemberAxis extends JComponent {
- public MemberAxis() {
- setPreferredSize(new Dimension(getWidth(), AXIS_SIZE));
- SequenceDiagram.this.addComponentListener(new ComponentAdapter() {
- @Override
- public void componentResized(ComponentEvent e) {
- int newWidth = e.getComponent().getWidth();
- setPreferredSize(new Dimension(newWidth, AXIS_SIZE));
- revalidate();
- }
- });
- }
- @Override
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
- Rectangle bounds = g.getClipBounds();
- int index = 0;
- for(String name : shortLineNames.keySet()) {
- int nameWidth = g.getFontMetrics().stringWidth(name);
- int lineX = lineStep * index;
- index++;
- if(bounds.getMaxX() < lineX
- || bounds.getMinX() > lineX + nameWidth) {
- continue;
- }
- g.setClip(lineX + LINE_LABEL_BOUNDARY, 0, lineStep - + LINE_LABEL_BOUNDARY * 2, getHeight());
- g.drawString(name, lineX + LINE_LABEL_BOUNDARY, AXIS_SIZE / 3);
- g.setClip(null);
- }
- }
- }
-
- public static class SubDiagram {
- private final Map<String, Lifeline> lifelines;
- private final List<Arrow> arrows;
- private final Comparable name;
-
- public SubDiagram(Comparable name, Map<String, Lifeline> lines, List<Arrow> arrows) {
- this.name = name;
- this.lifelines = lines;
- this.arrows = arrows;
- }
-
- public void paintStates(Graphics2D g2, StateColorMap colorMap) {
- for(Lifeline line: lifelines.values()) {
- line.paint(g2, colorMap);
- }
- }
- public void paintArrows(Graphics2D g2, StateColorMap colorMap) {
- Color lineColor = colorMap.getColor(name);
- g2.setColor(lineColor);
- for(Arrow arrow: arrows) {
- arrow.paint(g2);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/sequence/SequencePanel.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/sequence/SequencePanel.java b/geode-core/src/test/java/org/apache/sequence/SequencePanel.java
deleted file mode 100644
index 05a13e3..0000000
--- a/geode-core/src/test/java/org/apache/sequence/SequencePanel.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sequence;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-
-/**
- * Created by IntelliJ IDEA.
- * User: dan
- * Date: Oct 28, 2010
- * Time: 10:29:23 PM
- * To change this template use File | Settings | File Templates.
- */
-public class SequencePanel extends JPanel {
-
- public SequencePanel(SequenceDiagram sequenceDiagram) {
- //Set up the drawing area.
- ZoomingPanel drawingPane = new ZoomingPanel();
- drawingPane.setBackground(Color.white);
- drawingPane.setSequenceDiagram(sequenceDiagram);
-
- //Put the drawing area in a scroll pane.
- final JScrollPane scroller = new JScrollPane(drawingPane);
- scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
- scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
- final TimeAxis timeAxis = new TimeAxis(TimeAxis.VERTICAL,
- sequenceDiagram.getMinTime(),
- sequenceDiagram.getMaxTime());
- timeAxis.setPreferredHeight(drawingPane.getHeight());
- scroller.setRowHeaderView(timeAxis);
- scroller.setColumnHeaderView(sequenceDiagram.createMemberAxis());
- int preferredWidth = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - 100);
- int preferredHeight = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 100);
- scroller.setPreferredSize(new Dimension(preferredWidth, preferredHeight));
- scroller.setAutoscrolls(true);
-// scroller.setPreferredSize(new Dimension(200,200));
-
- sequenceDiagram.addComponentListener(new ComponentAdapter() {
- @Override
- public void componentResized(ComponentEvent e) {
- int height = e.getComponent().getHeight();
- timeAxis.setPreferredHeight(height);
- timeAxis.revalidate();
- }
- });
-
- BorderLayout layout = new BorderLayout();
-// layout.setHgap(0);
-// layout.setVgap(0);
- setLayout(layout);
- //Lay out this demo.
-// add(instructionPanel, BorderLayout.PAGE_START);
- add(scroller, BorderLayout.CENTER);
-
- addComponentListener(new ComponentAdapter() {
- @Override
- public void componentResized(ComponentEvent e) {
- Component source =e.getComponent();
- scroller.setSize(source.getSize());
- scroller.revalidate();
- }
- });
-
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/sequence/StateColorMap.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/sequence/StateColorMap.java b/geode-core/src/test/java/org/apache/sequence/StateColorMap.java
deleted file mode 100644
index 8248f27..0000000
--- a/geode-core/src/test/java/org/apache/sequence/StateColorMap.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sequence;
-
-import java.awt.*;
-import java.util.HashMap;
-import java.util.Map;
-
-import static java.lang.Math.random;
-
-/**
- * Created by IntelliJ IDEA.
- * User: dsmith
- * Date: Nov 12, 2010
- * Time: 5:05:49 PM
- * To change this template use File | Settings | File Templates.
- */
-public class StateColorMap {
- private Map<Object, Color> colors = new HashMap<Object, Color>();
- private static Color[] PREDEFINED_COLORS = new Color[] { Color.BLUE, Color.BLACK, Color.PINK, Color.CYAN, Color.ORANGE, Color.GREEN};
-
- private ColorList colorList = new ColorList();
-
- public StateColorMap() {
- colors.put("created", Color.GREEN);
- colors.put("destroyed", Color.WHITE);
- colors.put("persisted", new Color(0, 150, 0));
- }
-
-
- public Color getColor(Object state) {
- Color color = colors.get(state);
- if(color == null) {
- color = colorList.nextColor();
- colors.put(state, color);
- }
-
- return color;
- }
-
- private static class ColorList {
- int colorIndex;
-
- public Color nextColor() {
- if(colorIndex < PREDEFINED_COLORS.length) {
- return PREDEFINED_COLORS[colorIndex++];
- } else {
- return Color.getHSBColor((float)random(), (float)random(), (float)random());
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/sequence/TimeAxis.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/sequence/TimeAxis.java b/geode-core/src/test/java/org/apache/sequence/TimeAxis.java
deleted file mode 100644
index c0a1fac..0000000
--- a/geode-core/src/test/java/org/apache/sequence/TimeAxis.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sequence;
-
-import javax.swing.*;
-import java.awt.*;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * Created by IntelliJ IDEA.
- * User: dsmith
- * Date: Oct 29, 2010
- * Time: 5:24:54 PM
- * To change this template use File | Settings | File Templates.
- */
-public class TimeAxis extends JComponent {
- public static final int HORIZONTAL = 0;
- public static final int VERTICAL = 1;
- public static final int SIZE = 100;
- private static final DateFormat DATE_FORMAT = new SimpleDateFormat("HH:mm:ss.SSS");
-
- public int orientation;
- private long minTime;
- private long maxTime;
-
- public TimeAxis(int orientation, long minTime, long maxTime) {
- this.orientation = orientation;
- this.minTime = minTime;
- this.maxTime = maxTime;
- }
-
- public void setPreferredHeight(int ph) {
- setPreferredSize(new Dimension(SIZE, ph));
- }
-
- public void setPreferredWidth(int pw) {
- setPreferredSize(new Dimension(pw, SIZE));
- }
-
- protected void paintComponent(Graphics g) {
- Rectangle drawHere = g.getClipBounds();
-
- int height = getHeight();
-
- double scale = (maxTime - minTime) / height;
- int increment = 30;
- // Fill clipping area with dirty brown/orange.
- g.setColor(new Color(230, 163, 4));
- g.fillRect(drawHere.x, drawHere.y, drawHere.width, drawHere.height);
-
- // Do the ruler labels in a small font that's black.
- g.setFont(new Font("SansSerif", Font.PLAIN, 10));
- g.setColor(Color.black);
-
- // Some vars we need.
- int end = 0;
- int start = 0;
- int tickLength = 0;
- String text = null;
-
- // Use clipping bounds to calculate first and last tick locations.
- if (orientation == HORIZONTAL) {
- start = (drawHere.x / increment) * increment;
- end = (((drawHere.x + drawHere.width) / increment) + 1)
- * increment;
- } else {
- start = (drawHere.y / increment) * increment;
- end = (((drawHere.y + drawHere.height) / increment) + 1)
- * increment;
- }
-
- // Make a special case of 0 to display the number
- // within the rule and draw a units label.
- if (start == 0) {
- text = DATE_FORMAT.format(new Date(minTime));
- tickLength = 10;
- if (orientation == HORIZONTAL) {
- g.drawLine(0, SIZE-1, 0, SIZE-tickLength-1);
- g.drawString(text, 2, 21);
- } else {
- g.drawLine(SIZE-1, 0, SIZE-tickLength-1, 0);
- g.drawString(text, 9, 10);
- }
- text = null;
- start = increment;
- }
-
- // ticks and labels
- for (int i = start; i < end; i += increment) {
- tickLength = 10;
- text = DATE_FORMAT.format(new Date((long) (minTime + i * scale)));
-
- if (tickLength != 0) {
- if (orientation == HORIZONTAL) {
- g.drawLine(i, SIZE-1, i, SIZE-tickLength-1);
- if (text != null)
- g.drawString(text, i-3, 21);
- } else {
- g.drawLine(SIZE-1, i, SIZE-tickLength-1, i);
- if (text != null)
- g.drawString(text, 9, i+3);
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/sequence/ZoomingPanel.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/sequence/ZoomingPanel.java b/geode-core/src/test/java/org/apache/sequence/ZoomingPanel.java
deleted file mode 100644
index 782ee7b..0000000
--- a/geode-core/src/test/java/org/apache/sequence/ZoomingPanel.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sequence;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseMotionAdapter;
-
-/**
- * Created by IntelliJ IDEA.
- * User: dan
- * Date: Oct 28, 2010
- * Time: 10:30:40 PM
- * To change this template use File | Settings | File Templates.
- */
-public class ZoomingPanel extends JPanel {
- private int zoomBoxStartX;
- private int zoomBoxStartY;
- private int zoomBoxWidth;
- private int zoomBoxHeight;
- private SequenceDiagram child;
-
-
- public ZoomingPanel() {
- super();
- addMouseListener(new MouseAdapter() {
- @Override
- public void mousePressed(MouseEvent e) {
- startBox(e.getX(), e.getY());
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- endBox(e.getX(), e.getY());
- }
-
- @Override
- public void mouseClicked(MouseEvent e) {
- if (e.getButton() != MouseEvent.BUTTON1) {
- unzoom();
- } else {
- child.selectState(e.getX(), e.getY());
- }
-
- }
- });
-
- addMouseMotionListener(new MouseMotionAdapter() {
- @Override
- public void mouseDragged(MouseEvent e) {
- Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1);
- ((JPanel)e.getSource()).scrollRectToVisible(r);
- showBox(e.getX(), e.getY());
- }
-
- @Override
- public void mouseMoved(MouseEvent e) {
- int popupX = ZoomingPanel.this.getLocationOnScreen().x + e.getX();
- int popupY = ZoomingPanel.this.getLocationOnScreen().y + e.getY();
- child.showPopupText(e.getX(), e.getY(), popupX, popupY);
- }
- });
- BorderLayout layout = new BorderLayout();
- layout.setHgap(0);
- layout.setVgap(0);
- this.setLayout(layout);
- }
-
- private void unzoom() {
- resizeMe(0, 0, getWidth(), getHeight());
- }
-
- void resizeMe(int zoomBoxX, int zoomBoxY, int zoomBoxWidth, int zoomBoxHeight) {
- Dimension viewSize = getParent().getSize();
- double windowWidth = viewSize.getWidth();
- double windowHeight = viewSize.getHeight();
- double scaleX = getWidth() / ((double) zoomBoxWidth);
- double scaleY = getHeight() / ((double) zoomBoxHeight);
- int oldWidth = getWidth();
- int oldHeight = getHeight();
- int width = (int) (scaleX * windowWidth);
- int height = (int) (scaleY * windowHeight);
-// this.setPreferredSize(new Dimension(width, height));
- child.resizeMe(width, height);
- //TODO not sure this one is needed
- this.revalidate();
-
- //scroll to the new rectangle
-// int scrollX = (int) (zoomBoxX * scaleX);
-// int scrollY = (int) (zoomBoxY * scaleY);
-// int scrollWidth= (int) (zoomBoxWidth * scaleX);
-// int scrollHeight = (int) (zoomBoxHeight * scaleY);
- int scrollX = (int) (zoomBoxX * (width / (double) oldWidth));
- int scrollY = (int) (zoomBoxY * (height / (double) oldHeight));
- int scrollWidth= (int) (zoomBoxWidth * (width / (double) oldWidth));
- int scrollHeight = (int) (zoomBoxHeight * (height / (double) oldHeight));
- Rectangle r = new Rectangle(scrollX, scrollY, scrollWidth, scrollHeight);
- ((JViewport)getParent()).scrollRectToVisible(r);
- repaint();
-
- }
-
- public void setSequenceDiagram(SequenceDiagram diag) {
- this.child = diag;
- this.add(child, BorderLayout.CENTER);
- }
-
- private void showBox(int x, int y) {
- if(zoomBoxWidth != -1) {
- repaint(getBoxX(), getBoxY(), getBoxWidth(), getBoxHeight());
- }
-
- this.zoomBoxWidth = x - zoomBoxStartX;
- this.zoomBoxHeight = y - zoomBoxStartY;
-
- repaint(getBoxX(), getBoxY(), getBoxWidth(), getBoxHeight());
- }
-
- private void startBox(int x, int y) {
- this.zoomBoxStartX = x;
- this.zoomBoxStartY = y;
- }
-
- private void endBox(int x, int y) {
- if(zoomBoxStartX != -1 && zoomBoxStartY != -1
- && zoomBoxWidth != -1 && zoomBoxHeight != -1
- && zoomBoxWidth != 0 && zoomBoxHeight != 0) {
- resizeMe(getBoxX() , getBoxY(), getBoxWidth(), getBoxHeight());
- repaint(getBoxX(), getBoxY(), getBoxWidth(), getBoxHeight());
- this.zoomBoxStartX = -1;
- this.zoomBoxStartY = -1;
- this.zoomBoxWidth = -1;
- this.zoomBoxHeight = -1;
- }
- }
-
- public int getBoxX() {
- return zoomBoxWidth >= 0 ? zoomBoxStartX : zoomBoxStartX + zoomBoxWidth;
- }
-
- public int getBoxY() {
- return zoomBoxHeight >= 0 ? zoomBoxStartY : zoomBoxStartY + zoomBoxHeight;
- }
-
- public int getBoxHeight() {
- return zoomBoxHeight >= 0 ? zoomBoxHeight : -zoomBoxHeight;
- }
-
- public int getBoxWidth() {
- return zoomBoxWidth >= 0 ? zoomBoxWidth : -zoomBoxWidth;
- }
-
-
-
- @Override
- public void paint(Graphics g) {
- super.paint(g);
-
- if(zoomBoxStartX != -1 && zoomBoxStartY != -1 && zoomBoxWidth != -1 && zoomBoxHeight != -1) {
- Graphics2D g2 = (Graphics2D) g.create();
-
- Composite old = g2.getComposite();
- g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
- g2.setColor(Color.BLUE);
-
-// g2.drawRect(zoomBoxStartX, zoomBoxStartY, zoomBoxWidth, zoomBoxHeight);
-// g2.setBackground(Color.BLUE);
- g2.fillRect(getBoxX(), getBoxY(), getBoxWidth(), getBoxHeight());
- g2.setComposite(old);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/sequence/gemfire/DefaultLineMapper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/sequence/gemfire/DefaultLineMapper.java b/geode-core/src/test/java/org/apache/sequence/gemfire/DefaultLineMapper.java
deleted file mode 100644
index 5f8268e..0000000
--- a/geode-core/src/test/java/org/apache/sequence/gemfire/DefaultLineMapper.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sequence.gemfire;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.sequence.LineMapper;
-
-/**
- * A lifeline mapper that just returns a shortened version of
- * a member id.
- *
- */
-public class DefaultLineMapper implements LineMapper {
- private static Pattern MEMBER_ID_RE = Pattern.compile(".*\\((\\d+)(:admin)?(:loner)?\\).*:\\d+(/\\d+|.*:.*)");
-
- public String getShortNameForLine(String name) {
- Matcher matcher = MEMBER_ID_RE.matcher(name);
- if(matcher.matches()) {
- return matcher.group(1);
- } else {
- return name;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/sequence/gemfire/GemfireSequenceDisplay.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/sequence/gemfire/GemfireSequenceDisplay.java b/geode-core/src/test/java/org/apache/sequence/gemfire/GemfireSequenceDisplay.java
deleted file mode 100644
index 062ba7e..0000000
--- a/geode-core/src/test/java/org/apache/sequence/gemfire/GemfireSequenceDisplay.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sequence.gemfire;
-
-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.sequence.*;
-
-import javax.swing.*;
-import java.awt.event.*;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.*;
-import java.util.regex.Pattern;
-
-/**
- */
-public class GemfireSequenceDisplay {
-
- private JLabel selectedGraphsLabel;
- private SelectGraphDialog selectGraphDialog;
-
- private Map<GraphID, Map<String, Lifeline>> lineMap = new HashMap();
- private Map<GraphID, List<Arrow>> arrowMap = new HashMap();
- private SequenceDiagram sequenceDiagram;
- private JFrame frame;
- private SequencePanel sequencePanel;
-
- /**
- * Create the GUI and show it. For thread safety,
- * this method should be invoked from the
- * event-dispatching thread.
- *
- * @param graphs
- * @param lineMapper
- */
- private void createAndShowGUI(final GraphSet graphs, LineMapper lineMapper) {
- //Create and set up the window.
-
- frame = new JFrame("SequenceDiagram");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-
- createMenu();
- createSequenceDiagram(graphs, lineMapper);
- createSequenceMaps(graphs);
-
- createSelectGraphDialog(graphs);
-
- // for (GraphID id : graphs.getMap().keySet()) {
- // showSubDiagram(id);
- //
- // }
-
- sequencePanel = new SequencePanel(sequenceDiagram);
- frame.getContentPane().add(sequencePanel);
- //Display the window.
- frame.pack();
- frame.setVisible(true);
- showGraphSelector();
- }
-
- private void createMenu() {
- JMenuBar menuBar = new JMenuBar();
-
- JMenu sequenceMenu = new JMenu("Sequence");
- sequenceMenu.setMnemonic(KeyEvent.VK_S);
- sequenceMenu.getAccessibleContext().setAccessibleDescription(
- "The only menu in this program that has menu items");
- menuBar.add(sequenceMenu);
- JMenuItem selectGraphs = new JMenuItem("Choose Graphs",
- KeyEvent.VK_G);
- selectGraphs.setAccelerator(KeyStroke.getKeyStroke(
- KeyEvent.VK_G, ActionEvent.ALT_MASK));
- selectGraphs.getAccessibleContext().setAccessibleDescription(
- "Select what graphs to display");
- selectGraphs.setActionCommand("selectgraphs");
- selectGraphs.addActionListener(new ActionListener() {
-
- public void actionPerformed(ActionEvent e) {
- showGraphSelector();
- }
- });
-
- sequenceMenu.add(selectGraphs);
- frame.setJMenuBar(menuBar);
- }
-
- private void createSelectGraphDialog(final GraphSet graphs) {
- selectGraphDialog = new SelectGraphDialog(graphs);
- selectGraphDialog.addSelectionListener(new SelectGraphDialog.SelectionListener() {
-
- public void selectionChanged(List<GraphID> selectedIds) {
- updateGraphs(selectedIds);
- }
- });
- selectGraphDialog.pack();
- }
-
- private void updateGraphs(List<GraphID> selectedIds) {
- List<GraphID> existingDiagrams =(List) sequenceDiagram.getSubDiagramsNames();
- for(GraphID id : selectedIds) {
- showSubDiagram(id);
- existingDiagrams.remove(id);
- }
- for(GraphID id : existingDiagrams) {
- hideSubDiagram(id);
- }
-
- sequenceDiagram.resizeMe(sequenceDiagram.getWidth(), sequenceDiagram.getHeight());
- sequencePanel.revalidate();
- sequencePanel.repaint();
- // sequenceDiagram.revalidate();
- // sequenceDiagram.repaint();
- }
-
- private void showGraphSelector() {
- selectGraphDialog.setVisible(true);
- }
-
- private void hideGraphSelector() {
- selectGraphDialog.setVisible(false);
- }
-
- // private static SequenceDiagram createSequenceDiagram() {
- // long startTime = System.currentTimeMillis();
- // List<Lifeline> lines = new ArrayList<Lifeline>();
- // List<Arrow> arrows = new ArrayList<Arrow>();
- // for(int i =0 ; i < 10; i++) {
- // List<LifelineState> states = new ArrayList<LifelineState>();
- // for(int j =0; j < 5; j++) {
- // LifelineState state = new LifelineState(startTime + 20* j, startTime + 20 * j + 20);
- // states.add(state);
- // }
- // Lifeline line = new Lifeline(i, states);
- // lines.add(line);
- //
- // if(i > 0) {
- // Arrow arrow = new Arrow("arrow" + i, line, lines.get(i - 1), line.getStates().get(2));
- // arrows.add(arrow);
- // }
- // }
- //
- // SequenceDiagram diag = new SequenceDiagram(startTime, startTime + 20 * 5, lines, arrows);
- // return diag;
- // }
-
- private void createSequenceMaps(GraphSet graphs) {
-
- Map<GraphID, Graph> map = graphs.getMap();
- for (Map.Entry<GraphID, Graph> entry : map.entrySet()) {
- GraphID graphId = entry.getKey();
- Graph graph = entry.getValue();
- Map<String, Lifeline> lines = new LinkedHashMap<String, Lifeline>(graphs.getLocations().size());
- List<Arrow> arrows = new ArrayList<Arrow>();
- Map<Vertex, LifelineState> states = new HashMap<Vertex, LifelineState>();
- for (String location : graphs.getLocations()) {
- lines.put(location, new Lifeline(graphId, location));
- }
-
- Collection<Edge> edges = graph.getEdges();
- for (Edge edge : edges) {
- Vertex dest = edge.getDest();
- Vertex source = edge.getSource();
- if (dest == null) {
- dest = source;
- }
- if (source == null) {
- source = dest;
- }
- LifelineState destState = states.get(dest);
- if (destState == null) {
- final Lifeline lifeline = lines.get(dest.getName());
- destState = createState(lifeline, graphs, dest);
- lifeline.addState(destState);
- states.put(dest, destState);
- }
- LifelineState sourceState = states.get(source);
- if (sourceState == null) {
- final Lifeline lifeline = lines.get(source.getName());
- sourceState = createState(lifeline, graphs, source);
- lifeline.addState(sourceState);
- states.put(source, sourceState);
- }
- Arrow arrow = new Arrow(edge.getName(), sourceState, destState);
- arrows.add(arrow);
- destState.addInboundArrow(arrow);
- }
-
-
- lineMap.put(graphId, lines);
- arrowMap.put(graphId, arrows);
- }
- }
-
- public void showSubDiagram(GraphID id) {
- sequenceDiagram.addSubDiagram(id, lineMap.get(id), arrowMap.get(id));
- }
-
- public void hideSubDiagram(GraphID id) {
- sequenceDiagram.removeSubDiagram(id);
- }
-
- private SequenceDiagram createSequenceDiagram(GraphSet graphs, LineMapper lineMapper) {
-
- sequenceDiagram = new SequenceDiagram(graphs.getMinTime(), graphs.getMaxTime(), graphs.getLocations(), lineMapper);
- return sequenceDiagram;
- }
-
- private static LifelineState createState(Lifeline lifeline, GraphSet graphs, Vertex dest) {
- long start = dest.getTimestamp();
- long end = dest.getNextVertexOnDest() == null ? graphs.getMaxTime() : dest.getNextVertexOnDest().getTimestamp();
- return new LifelineState(lifeline, dest.getState(), start, end);
- }
-
- public static void main(String[] args) throws IOException {
- File[] files;
- Set<String> keyFilters = new HashSet<String>();
- boolean areGemfireLogs = false;
- if (args.length > 0) {
- ArrayList<File> fileList = new ArrayList<File>();
- for (int i =0; i < args.length; i++) {
- String arg = args[i];
- if(arg.equals("-filterkey")) {
- keyFilters.add(args[i+1]);
- i++;
- } else if(arg.equals("-logs")) {
- areGemfireLogs = true;
- }
- else {
- fileList.add(new File(args[i]));
- }
-
- }
- files = fileList.toArray(new File[0]);
- } else {
- System.err.println("Usage: java -jar sequence.jar (-logs) (-filterkey key)* <file>+\n\n" +
- "\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);
- return;
- }
-
- final GraphSet graphs;
-
- graphs = getGraphs(areGemfireLogs, keyFilters, files);
-
- final LineMapper lineMapper = getLineMapper(files);
- final GemfireSequenceDisplay display = new GemfireSequenceDisplay();
- //Schedule a job for the event-dispatching thread:
- //creating and showing this application's GUI.
- javax.swing.SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- display.createAndShowGUI(graphs, lineMapper);
- }
- });
- }
-
- private static GraphSet getGraphs(boolean useLogFiles, Set<String> keyFilters, File[] files)
- throws IOException {
- Filter graphFilter = new KeyFilter(keyFilters);
-
-
- GraphReader reader = new GraphReader(files);
- final GraphSet graphs;
- if(keyFilters.isEmpty()) {
- graphs = reader.readGraphs(useLogFiles);
- } else {
- graphs = reader.readGraphs(graphFilter, useLogFiles);
- }
- return graphs;
- }
-
- /**
- * @param files
- * @return
- */
- private static LineMapper getLineMapper(File[] files) {
- if(HydraLineMapper.isInHydraRun(files)) {
- return new HydraLineMapper(files);
- } else {
- return new DefaultLineMapper();
- }
- }
-
- private static class KeyFilter implements Filter {
- Set<Pattern> patterns = new HashSet<Pattern>();
-
-
- public KeyFilter(Set<String> keyFilters) {
- for(String filterString : keyFilters) {
- patterns.add(Pattern.compile(filterString));
- }
- }
-
- public boolean accept(GraphType graphType, String name, String edgeName,
- String source, String dest) {
- if(graphType.equals(GraphType.KEY)) {
- for(Pattern pattern : patterns) {
- if(pattern.matcher(name).find()) {
- return true;
- }
- }
-
- return false;
- } else {
- return true;
- }
- }
-
- public boolean acceptPattern(GraphType graphType, Pattern pattern,
- String edgeName, String source, String dest) {
- return true;
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/sequence/gemfire/HydraLineMapper.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/sequence/gemfire/HydraLineMapper.java b/geode-core/src/test/java/org/apache/sequence/gemfire/HydraLineMapper.java
deleted file mode 100644
index ccb05d7..0000000
--- a/geode-core/src/test/java/org/apache/sequence/gemfire/HydraLineMapper.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sequence.gemfire;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.sequence.LineMapper;
-
-/**
- *
- */
-public class HydraLineMapper implements LineMapper {
- private static final Pattern VM_NAME_PATTERN = Pattern.compile("(vm_\\d+).*_(\\d+)(_end)?\\.log");
- private static final Pattern DISK_DIR_PATTERN = Pattern.compile("vm_(\\d+).*_disk_1");
- private final Map<String, String> processIdToVMName = new HashMap<String, String>();
- private final DefaultLineMapper defaultMapper = new DefaultLineMapper();
-
- public HydraLineMapper(File[] graphFiles) {
- File firstFile = graphFiles[0];
- File directory = firstFile.getParentFile();
- if(directory == null || ! new File(directory, "latest.prop").exists()) {
- directory = new File(".");
- }
- String[] files = directory.list();
- for(String file : files) {
- Matcher matcher = VM_NAME_PATTERN.matcher(file);
- if(matcher.matches()) {
- processIdToVMName.put(matcher.group(2), matcher.group(1));
- }
- }
-
- for(String file : files) {
- Matcher matcher = DISK_DIR_PATTERN.matcher(file);
- if(matcher.matches()) {
-
- String storeId = getDiskStoreId(file);
- if(storeId != null) {
- processIdToVMName.put(storeId, "disk_" + matcher.group(1));
- }
- }
- }
-
-
- }
-
- private String getDiskStoreId(String diskStoreDir) {
- File dir = new File(diskStoreDir);
- String[] files = dir.list();
- for(String fileName : files) {
- if(fileName.endsWith(".if")) {
- try {
- return getDiskStoreIdFromInitFile(dir, fileName);
- } catch (Exception e) {
- return null;
- }
- }
- }
-
- return null;
- }
-
- private String getDiskStoreIdFromInitFile(File dir, String fileName)
- throws FileNotFoundException, IOException {
- FileInputStream fis = new FileInputStream(new File(dir, fileName));
- try {
- byte[] bytes = new byte[1 + 8 + 8];
- fis.read(bytes);
- ByteBuffer buffer = ByteBuffer.wrap(bytes);
- //Skip the record type.
- buffer.get();
- long least = buffer.getLong();
- long most = buffer.getLong();
- UUID id = new UUID(most, least);
- return id.toString();
- } finally {
- fis.close();
- }
- }
-
- public String getShortNameForLine(String lineName) {
- String name = defaultMapper.getShortNameForLine(lineName);
- if(processIdToVMName.containsKey(name)) {
- return processIdToVMName.get(name);
- } else {
- return name;
- }
- }
-
- public static boolean isInHydraRun(File[] graphFiles) {
- if(graphFiles.length == 0) {
- return false;
- }
- File firstFile = graphFiles[0];
- File parentFile = firstFile.getParentFile();
- for(File file : graphFiles) {
- if(parentFile == null && file.getParentFile() == null) {
- return true;
- }
- if (parentFile == null || file.getParentFile() == null
- || !file.getParentFile().equals(parentFile)) {
- return false;
- }
- }
-
- return new File(parentFile, "latest.prop").exists()
- || new File("latest.prop").exists();
-
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5ba853da/geode-core/src/test/java/org/apache/sequence/gemfire/SelectGraphDialog.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/sequence/gemfire/SelectGraphDialog.java b/geode-core/src/test/java/org/apache/sequence/gemfire/SelectGraphDialog.java
deleted file mode 100644
index 7863008..0000000
--- a/geode-core/src/test/java/org/apache/sequence/gemfire/SelectGraphDialog.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sequence.gemfire;
-
-import org.apache.geode.internal.sequencelog.model.GraphID;
-import org.apache.geode.internal.sequencelog.model.GraphSet;
-
-import javax.swing.*;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.*;
-import java.util.List;
-import java.util.regex.Pattern;
-
-/**
- * Created by IntelliJ IDEA.
- * User: dsmith
- * Date: Dec 9, 2010
- * Time: 3:34:38 PM
- * To change this template use File | Settings | File Templates.
- */
-public class SelectGraphDialog extends JDialog {
- private List<GraphID> selectedIds = new ArrayList<GraphID>();
- private Set<SelectionListener> listeners = new HashSet<SelectionListener>();
-
- public SelectGraphDialog(final GraphSet graphs) {
-
- final List<GraphID> ids = new ArrayList<GraphID>(graphs.getMap().keySet());
- Collections.sort(ids);
- final FilterableListModel listModel = new FilterableListModel(ids);
- final JList list = new JList(listModel);
-
- JScrollPane selectGraphPane = new JScrollPane(list);
- selectGraphPane.setPreferredSize(new Dimension(500, 500));
-
- JButton apply = new JButton("Apply");
- apply.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- selectedIds = (List) Arrays.asList(list.getSelectedValues());
- fireSelectionChanged();
- setVisible(false);
- }
- });
-
- JButton cancel= new JButton("Cancel");
- cancel.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- setVisible(false);
- }
- });
-
- JPanel buttonPane = new JPanel();
- buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
- buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
- buttonPane.add(Box.createHorizontalGlue());
- buttonPane.add(apply);
- buttonPane.add(cancel);
-
- final JTextField searchField = new JTextField(10);
- searchField.getDocument().addDocumentListener(new DocumentListener() {
- public void removeUpdate(DocumentEvent e) {
- doUpdate();
- }
-
- public void insertUpdate(DocumentEvent e) {
- doUpdate();
- }
-
- public void changedUpdate(DocumentEvent e) {
- doUpdate();
- }
-
- private void doUpdate() {
- listModel.updateFilter(searchField.getText());
- }
- });
-
-
- Container contentPane = getContentPane();
- contentPane.add(searchField, BorderLayout.PAGE_START);
- contentPane.add(selectGraphPane, BorderLayout.CENTER);
- contentPane.add(buttonPane, BorderLayout.PAGE_END);
- }
-
- private void fireSelectionChanged() {
- for(SelectionListener listener : listeners) {
- listener.selectionChanged(selectedIds);
- }
- }
-
- public void addSelectionListener(SelectionListener listener) {
- listeners.add(listener);
-
- }
-
- public void removeSelectionListener(SelectionListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * A listener for changes to the graph selections
- */
- public static interface SelectionListener {
- void selectionChanged(List<GraphID> selectedIds);
- }
-
- private static class FilterableListModel extends AbstractListModel {
- private final List<?> allElements;
- private List<Object> filteredElements;
-
- public FilterableListModel(List<?> elements) {
- this.allElements = elements;
- this.filteredElements = new ArrayList<Object>(elements);
- }
-
- public int getSize() {
- return filteredElements.size();
- }
-
- public Object getElementAt(int index) {
- return filteredElements.get(index);
- }
-
- public void updateFilter(String filter) {
- Pattern pattern = Pattern.compile(filter);
- filteredElements = new ArrayList<Object>();
- for(Object element : allElements) {
- if(pattern.matcher(element.toString()).find()) {
- filteredElements.add(element);
- }
- }
-
- fireContentsChanged(this, 0, filteredElements.size());
- }
-
- }
-}
[02/35] incubator-geode git commit: GEODE-37 import change in pulse
module
Posted by hi...@apache.org.
GEODE-37 import change in pulse module
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/e9bf1176
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/e9bf1176
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/e9bf1176
Branch: refs/heads/develop
Commit: e9bf1176b4fb840c28b9dab91dac36c5f8d0d559
Parents: 46307d0
Author: Hitesh Khamesra <hk...@pivotal.io>
Authored: Tue Sep 20 10:45:02 2016 -0700
Committer: Hitesh Khamesra <hk...@pivotal.io>
Committed: Tue Sep 20 14:29:51 2016 -0700
----------------------------------------------------------------------
.../geode/codeAnalysis/excludedClasses.txt | 2 --
.../tools/pulse/internal/PulseAppListener.java | 16 ++++-----
.../controllers/ExceptionHandlingAdvice.java | 4 +--
.../internal/controllers/PulseController.java | 20 ++++++------
.../tools/pulse/internal/data/Cluster.java | 6 ++--
.../tools/pulse/internal/data/DataBrowser.java | 6 ++--
.../pulse/internal/data/IClusterUpdater.java | 2 +-
.../pulse/internal/data/JMXDataUpdater.java | 10 +++---
.../pulse/internal/data/JmxManagerFinder.java | 6 ++--
.../tools/pulse/internal/data/PulseConfig.java | 2 +-
.../pulse/internal/data/PulseConstants.java | 2 +-
.../tools/pulse/internal/data/PulseVersion.java | 2 +-
.../tools/pulse/internal/data/Repository.java | 4 +--
.../geode/tools/pulse/internal/json/CDL.java | 2 +-
.../geode/tools/pulse/internal/json/Cookie.java | 2 +-
.../tools/pulse/internal/json/CookieList.java | 2 +-
.../geode/tools/pulse/internal/json/HTTP.java | 2 +-
.../tools/pulse/internal/json/HTTPTokener.java | 2 +-
.../tools/pulse/internal/json/JSONArray.java | 2 +-
.../pulse/internal/json/JSONException.java | 2 +-
.../geode/tools/pulse/internal/json/JSONML.java | 2 +-
.../tools/pulse/internal/json/JSONObject.java | 2 +-
.../tools/pulse/internal/json/JSONString.java | 2 +-
.../tools/pulse/internal/json/JSONStringer.java | 2 +-
.../tools/pulse/internal/json/JSONTokener.java | 2 +-
.../tools/pulse/internal/json/JSONWriter.java | 2 +-
.../geode/tools/pulse/internal/json/XML.java | 2 +-
.../tools/pulse/internal/json/XMLTokener.java | 2 +-
.../tools/pulse/internal/log/LogWriter.java | 2 +-
.../pulse/internal/log/MessageFormatter.java | 6 ++--
.../pulse/internal/log/PulseLogWriter.java | 6 ++--
.../tools/pulse/internal/log/PulseLogger.java | 4 +--
.../security/GemFireAuthentication.java | 6 ++--
.../security/GemFireAuthenticationProvider.java | 6 ++--
.../pulse/internal/security/LogoutHandler.java | 6 ++--
.../internal/service/ClusterDetailsService.java | 8 ++---
.../service/ClusterDiskThroughputService.java | 6 ++--
.../service/ClusterGCPausesService.java | 6 ++--
.../service/ClusterKeyStatisticsService.java | 6 ++--
.../internal/service/ClusterMemberService.java | 12 +++----
.../service/ClusterMembersRGraphService.java | 8 ++---
.../service/ClusterMemoryUsageService.java | 6 ++--
.../internal/service/ClusterRegionService.java | 12 +++----
.../internal/service/ClusterRegionsService.java | 12 +++----
.../service/ClusterSelectedRegionService.java | 16 ++++-----
.../ClusterSelectedRegionsMemberService.java | 10 +++---
.../internal/service/ClusterWANInfoService.java | 6 ++--
.../service/MemberAsynchEventQueuesService.java | 8 ++---
.../internal/service/MemberClientsService.java | 10 +++---
.../internal/service/MemberDetailsService.java | 12 +++----
.../service/MemberDiskThroughputService.java | 8 ++---
.../internal/service/MemberGCPausesService.java | 8 ++---
.../service/MemberGatewayHubService.java | 8 ++---
.../service/MemberHeapUsageService.java | 8 ++---
.../service/MemberKeyStatisticsService.java | 8 ++---
.../internal/service/MemberRegionsService.java | 12 +++----
.../internal/service/MembersListService.java | 6 ++--
.../pulse/internal/service/PulseService.java | 2 +-
.../internal/service/PulseServiceFactory.java | 2 +-
.../internal/service/PulseVersionService.java | 4 +--
.../service/QueryStatisticsService.java | 8 ++---
.../internal/service/SystemAlertsService.java | 8 ++---
.../pulse/internal/util/ConnectionUtil.java | 2 +-
.../pulse/internal/util/IPAddressUtil.java | 2 +-
.../tools/pulse/internal/util/StringUtils.java | 2 +-
.../tools/pulse/internal/util/TimeUtils.java | 2 +-
.../controllers/PulseControllerJUnitTest.java | 12 +++----
.../pulse/testbed/GemFireDistributedSystem.java | 2 +-
.../tools/pulse/testbed/GemfireTopology.java | 2 +-
.../tools/pulse/testbed/PropFileHelper.java | 2 +-
.../pulse/testbed/PropMockDataUpdater.java | 34 ++++++++++----------
.../geode/tools/pulse/testbed/TestBed.java | 2 +-
.../tools/pulse/testbed/driver/PulseUITest.java | 16 ++++-----
.../tools/pulse/tests/AggregateStatement.java | 2 +-
.../pulse/tests/AggregateStatementMBean.java | 2 +-
.../pulse/tests/DataBrowserResultLoader.java | 2 +-
.../pulse/tests/GemFireXDAggregateTable.java | 2 +-
.../tests/GemFireXDAggregateTableMBean.java | 2 +-
.../tools/pulse/tests/GemFireXDCluster.java | 2 +-
.../pulse/tests/GemFireXDClusterMBean.java | 2 +-
.../tools/pulse/tests/GemFireXDMember.java | 2 +-
.../tools/pulse/tests/GemFireXDMemberMBean.java | 2 +-
.../geode/tools/pulse/tests/JMXBaseBean.java | 2 +-
.../geode/tools/pulse/tests/JMXProperties.java | 2 +-
.../apache/geode/tools/pulse/tests/Member.java | 2 +-
.../geode/tools/pulse/tests/MemberMBean.java | 2 +-
.../tools/pulse/tests/PulseAbstractTest.java | 4 +--
.../geode/tools/pulse/tests/PulseAuthTest.java | 2 +-
.../tools/pulse/tests/PulseAutomatedTest.java | 2 +-
.../geode/tools/pulse/tests/PulseBaseTest.java | 4 +--
.../tools/pulse/tests/PulseNoAuthTest.java | 2 +-
.../geode/tools/pulse/tests/PulseTestData.java | 2 +-
.../tools/pulse/tests/PulseTestLocators.java | 2 +-
.../apache/geode/tools/pulse/tests/Region.java | 2 +-
.../geode/tools/pulse/tests/RegionMBean.java | 2 +-
.../geode/tools/pulse/tests/RegionOnMember.java | 2 +-
.../tools/pulse/tests/RegionOnMemberMBean.java | 2 +-
.../apache/geode/tools/pulse/tests/Server.java | 4 +--
.../geode/tools/pulse/tests/ServerObject.java | 2 +-
.../tools/pulse/tests/ServerObjectMBean.java | 2 +-
.../pulse/tests/junit/BaseServiceTest.java | 6 ++--
.../junit/ClusterSelectedRegionServiceTest.java | 12 +++----
...ClusterSelectedRegionsMemberServiceTest.java | 4 +--
.../junit/MemberGatewayHubServiceTest.java | 16 ++++-----
104 files changed, 271 insertions(+), 273 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/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 6d5c84c..830930b 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
@@ -118,8 +118,6 @@ org/apache/geode/internal/security/IntegratedSecurityService
org/apache/geode/internal/security/IntegratedSecurityService$SerializationProxy
org/apache/geode/internal/security/SecurityService
org/apache/geode/internal/statistics/platform/LinuxProcFsStatistics$CPU
-com/gemstone/org/apache/logging/log4j/core/config/xml/GemFireXmlConfiguration
-com/gemstone/org/apache/logging/log4j/core/config/xml/GemFireXmlConfiguration$ErrorType
org/apache/geode/internal/ra/GFConnectionFactoryImpl
org/apache/geode/internal/ra/GFConnectionImpl
org/apache/geode/internal/ra/spi/JCAManagedConnectionFactory
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java
index 408eed3..d4d95a7 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java
@@ -17,14 +17,14 @@
*
*/
-package com.vmware.geode.tools.pulse.internal;
-
-import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
-import com.vmware.geode.tools.pulse.internal.data.PulseConfig;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+package org.apache.geode.tools.pulse.internal;
+
+import org.apache.geode.tools.pulse.internal.controllers.PulseController;
+import org.apache.geode.tools.pulse.internal.data.PulseConfig;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java
index 9e86637..24f8dc9 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.controllers;
+package org.apache.geode.tools.pulse.internal.controllers;
import java.io.IOException;
import java.io.PrintWriter;
@@ -28,7 +28,7 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
-import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
/**
* For handling IO exception in our controllers
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java
index 32fd810..4eb069e 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.controllers;
+package org.apache.geode.tools.pulse.internal.controllers;
import java.io.IOException;
import java.util.Collection;
@@ -30,15 +30,15 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.data.PulseVersion;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.geode.tools.pulse.internal.service.PulseService;
-import com.vmware.geode.tools.pulse.internal.service.PulseServiceFactory;
-import com.vmware.geode.tools.pulse.internal.service.SystemAlertsService;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.PulseVersion;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.internal.service.PulseService;
+import org.apache.geode.tools.pulse.internal.service.PulseServiceFactory;
+import org.apache.geode.tools.pulse.internal.service.SystemAlertsService;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.beans.factory.annotation.Autowired;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
index e15d282..7bf44ff 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/Cluster.java
@@ -17,14 +17,14 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.data;
+package org.apache.geode.tools.pulse.internal.data;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.apache.commons.collections.buffer.CircularFifoBuffer;
import javax.management.remote.JMXConnector;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/DataBrowser.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/DataBrowser.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/DataBrowser.java
index 668b74c..de4ea1f 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/DataBrowser.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/DataBrowser.java
@@ -17,14 +17,14 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.data;
+package org.apache.geode.tools.pulse.internal.data;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import java.io.File;
import java.io.FileInputStream;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/IClusterUpdater.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/IClusterUpdater.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/IClusterUpdater.java
index 106ea63..4ddfc1a 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/IClusterUpdater.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/IClusterUpdater.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.data;
+package org.apache.geode.tools.pulse.internal.data;
import com.fasterxml.jackson.databind.node.ObjectNode;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JMXDataUpdater.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JMXDataUpdater.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JMXDataUpdater.java
index 41374d8..1dbfea0 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JMXDataUpdater.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/data/JMXDataUpdater.java
@@ -17,14 +17,14 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.data;
+package org.apache.geode.tools.pulse.internal.data;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
-import com.vmware.geode.tools.pulse.internal.data.JmxManagerFinder.JmxManagerInfo;
-import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.controllers.PulseController;
+import org.apache.geode.tools.pulse.internal.data.JmxManagerFinder.JmxManagerInfo;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import javax.management.Attribute;
import javax.management.AttributeList;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/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
index f2d211a..f8dbcf9 100644
--- 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
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.data;
+package org.apache.geode.tools.pulse.internal.data;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -27,8 +27,8 @@ 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;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.internal.util.ConnectionUtil;
/**
* This class can be used to connect to a locator and ask it to find a jmx
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/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
index cfd6b62..a0b279b 100644
--- 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
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.data;
+package org.apache.geode.tools.pulse.internal.data;
import java.util.logging.Level;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/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
index c9e711a..9da8248 100644
--- 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
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.data;
+package org.apache.geode.tools.pulse.internal.data;
import java.util.logging.Level;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/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
index e7b62a2..23e4895 100644
--- 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
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.data;
+package org.apache.geode.tools.pulse.internal.data;
import java.util.ResourceBundle;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/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
index 8eea7cc..be06f20 100644
--- 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
@@ -17,9 +17,9 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.data;
+package org.apache.geode.tools.pulse.internal.data;
-import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/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
index 56ffeb8..8d513e3 100644
--- 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
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
/**
* This provides static methods to convert comma delimited text into a
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/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
index 8e208f0..a1250bf 100644
--- 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
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
/**
* Convert a web browser cookie specification to a JSONObject and back.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/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
index e03f75c..b206efe 100644
--- 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
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
import java.util.Iterator;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/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
index 19c7d53..5fd0afa 100644
--- 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
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
import java.util.Iterator;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/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
index 536aee0..b7b7c38 100644
--- 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
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
/**
* The HTTPTokener extends the JSONTokener to provide additional methods
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONArray.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONArray.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONArray.java
index 5715db5..3fe7a2d 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONArray.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONArray.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
import java.io.IOException;
import java.io.StringWriter;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONException.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONException.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONException.java
index 7533e49..c4cd7ad 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONException.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONException.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
/**
* The JSONException is thrown by the JSON.org classes when things are amiss.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONML.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONML.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONML.java
index 3c52063..cfbbbc6 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONML.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONML.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
import java.util.Iterator;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONObject.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONObject.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONObject.java
index 3fd3c38..abfbcdd 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONObject.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONObject.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
import java.io.IOException;
import java.io.StringWriter;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONString.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONString.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONString.java
index 64674ff..f2fa2f3 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONString.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONString.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
/**
* The <code>JSONString</code> interface allows a <code>toJSONString()</code>
* method so that a class can change the behavior of
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONStringer.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONStringer.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONStringer.java
index 41adf5f..55c1230 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONStringer.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONStringer.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
import java.io.StringWriter;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONTokener.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONTokener.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONTokener.java
index 99f5658..9050fb2 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONTokener.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONTokener.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
import java.io.BufferedReader;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONWriter.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONWriter.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONWriter.java
index d1a661c..2399d4d 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONWriter.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/JSONWriter.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
import java.io.IOException;
import java.io.Writer;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XML.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XML.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XML.java
index d43eb77..2aa8b8d 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XML.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XML.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
import java.util.Iterator;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XMLTokener.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XMLTokener.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XMLTokener.java
index aa18c85..7995af0 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XMLTokener.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/json/XMLTokener.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.json;
+package org.apache.geode.tools.pulse.internal.json;
/**
* The XMLTokener extends the JSONTokener to provide additional methods
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/LogWriter.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/LogWriter.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/LogWriter.java
index 662c561..72c9831 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/LogWriter.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/LogWriter.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.log;
+package org.apache.geode.tools.pulse.internal.log;
/**
* interface LogWriter
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/MessageFormatter.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/MessageFormatter.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/MessageFormatter.java
index 11fe290..3828759 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/MessageFormatter.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/MessageFormatter.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.log;
+package org.apache.geode.tools.pulse.internal.log;
import java.io.IOException;
import java.io.PrintWriter;
@@ -29,8 +29,8 @@ import java.util.logging.Formatter;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.Repository;
/**
* Class MessageFormatter
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogWriter.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogWriter.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogWriter.java
index fe4e88b..901f2f4 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogWriter.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogWriter.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.log;
+package org.apache.geode.tools.pulse.internal.log;
import java.io.IOException;
import java.io.PrintWriter;
@@ -26,8 +26,8 @@ import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
-import com.vmware.geode.tools.pulse.internal.data.PulseConfig;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.data.PulseConfig;
+import org.apache.geode.tools.pulse.internal.data.Repository;
/**
* Class PulseLogWriter
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogger.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogger.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogger.java
index 2de81bd..b4f08c1 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogger.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogger.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.log;
+package org.apache.geode.tools.pulse.internal.log;
import java.io.IOException;
import java.text.DateFormat;
@@ -30,7 +30,7 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
/**
* Class PulseLogger
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
index 6506667..425f5a5 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package com.vmware.geode.tools.pulse.internal.security;
+package org.apache.geode.tools.pulse.internal.security;
import java.util.ArrayList;
import java.util.Collection;
@@ -23,8 +23,8 @@ import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
index cd37aea..f4575cc 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
@@ -14,13 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.vmware.geode.tools.pulse.internal.security;
+package org.apache.geode.tools.pulse.internal.security;
import java.util.Collection;
import javax.management.remote.JMXConnector;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.AuthenticationServiceException;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
index 5056ce2..451e19a 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
@@ -14,15 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.vmware.geode.tools.pulse.internal.security;
+package org.apache.geode.tools.pulse.internal.security;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDetailsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDetailsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDetailsService.java
index 8b5e409..0216cb0 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDetailsService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDetailsService.java
@@ -17,13 +17,13 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.Repository;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDiskThroughputService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDiskThroughputService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDiskThroughputService.java
index 11247bc..b50b551 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDiskThroughputService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterDiskThroughputService.java
@@ -17,12 +17,12 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterGCPausesService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterGCPausesService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterGCPausesService.java
index 52ba79c..164e7e3 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterGCPausesService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterGCPausesService.java
@@ -17,13 +17,13 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterKeyStatisticsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterKeyStatisticsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterKeyStatisticsService.java
index 8c15ccc..9c35a3c 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterKeyStatisticsService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterKeyStatisticsService.java
@@ -17,12 +17,12 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemberService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemberService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemberService.java
index 6a42c0d..40eef85 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemberService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemberService.java
@@ -17,16 +17,16 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.util.TimeUtils;
+import org.apache.geode.tools.pulse.internal.controllers.PulseController;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.util.TimeUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMembersRGraphService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMembersRGraphService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMembersRGraphService.java
index f8617cb..6972144 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMembersRGraphService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMembersRGraphService.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import java.text.DecimalFormat;
import java.util.ArrayList;
@@ -33,9 +33,9 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.Repository;
/**
* Class ClusterMembersRGraphService
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemoryUsageService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemoryUsageService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemoryUsageService.java
index 519deb1..bde7270 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemoryUsageService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterMemoryUsageService.java
@@ -17,12 +17,12 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionService.java
index 1723a98..ab0aef3 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionService.java
@@ -17,16 +17,16 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.controllers.PulseController;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionsService.java
index 0568451..d0f4c77 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionsService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterRegionsService.java
@@ -17,16 +17,16 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.controllers.PulseController;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java
index 4dfc941..2dffa2c 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java
@@ -17,19 +17,19 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
-import com.vmware.geode.tools.pulse.internal.util.TimeUtils;
+import org.apache.geode.tools.pulse.internal.controllers.PulseController;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.util.TimeUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
index 1f3ffd6..abf8e6f 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
@@ -17,15 +17,15 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Cluster.RegionOnMember;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Cluster.RegionOnMember;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterWANInfoService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterWANInfoService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterWANInfoService.java
index 7e26724..fd6793d 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterWANInfoService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterWANInfoService.java
@@ -17,13 +17,13 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberAsynchEventQueuesService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberAsynchEventQueuesService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberAsynchEventQueuesService.java
index 5fe6785..5200704 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberAsynchEventQueuesService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberAsynchEventQueuesService.java
@@ -17,15 +17,15 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberClientsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberClientsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberClientsService.java
index 41f3684..ddd2b76 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberClientsService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberClientsService.java
@@ -17,16 +17,16 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
-import com.vmware.geode.tools.pulse.internal.util.TimeUtils;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.util.TimeUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDetailsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDetailsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDetailsService.java
index c4f2ff7..79cc2ba 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDetailsService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDetailsService.java
@@ -17,16 +17,16 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.controllers.PulseController;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDiskThroughputService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDiskThroughputService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDiskThroughputService.java
index 2dd8b55..9f1eba9 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDiskThroughputService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberDiskThroughputService.java
@@ -17,14 +17,14 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGCPausesService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGCPausesService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGCPausesService.java
index 5b34c73..b1fa07c 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGCPausesService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGCPausesService.java
@@ -17,14 +17,14 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGatewayHubService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGatewayHubService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGatewayHubService.java
index 932ec41..51abb3f 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGatewayHubService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGatewayHubService.java
@@ -17,15 +17,15 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberHeapUsageService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberHeapUsageService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberHeapUsageService.java
index 966b346..825413b 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberHeapUsageService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberHeapUsageService.java
@@ -17,14 +17,14 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberKeyStatisticsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberKeyStatisticsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberKeyStatisticsService.java
index 8519ad4..c7006c8 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberKeyStatisticsService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberKeyStatisticsService.java
@@ -17,14 +17,14 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberRegionsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberRegionsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberRegionsService.java
index ffd24d0..9181386 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberRegionsService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberRegionsService.java
@@ -17,17 +17,17 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.controllers.PulseController;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MembersListService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MembersListService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MembersListService.java
index 467d8c0..9bf8432 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MembersListService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MembersListService.java
@@ -17,13 +17,13 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseService.java
index 58d9dbf..6b8aa4d 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseService.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import javax.servlet.http.HttpServletRequest;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseServiceFactory.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseServiceFactory.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseServiceFactory.java
index ead5200..2aca834 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseServiceFactory.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseServiceFactory.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseVersionService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseVersionService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseVersionService.java
index 7b84404..81728bb 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseVersionService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseVersionService.java
@@ -17,11 +17,11 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
+import org.apache.geode.tools.pulse.internal.controllers.PulseController;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/QueryStatisticsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/QueryStatisticsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/QueryStatisticsService.java
index 87f65df..c456caf 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/QueryStatisticsService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/QueryStatisticsService.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import javax.servlet.http.HttpServletRequest;
@@ -28,9 +28,9 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.PulseConstants;
+import org.apache.geode.tools.pulse.internal.data.Repository;
/**
* Class QueryStatisticsService
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/SystemAlertsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/SystemAlertsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/SystemAlertsService.java
index d21f47a..2310cad 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/SystemAlertsService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/SystemAlertsService.java
@@ -17,15 +17,15 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.service;
+package org.apache.geode.tools.pulse.internal.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.geode.tools.pulse.internal.data.Cluster;
-import com.vmware.geode.tools.pulse.internal.data.Repository;
-import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.apache.geode.tools.pulse.internal.data.Cluster;
+import org.apache.geode.tools.pulse.internal.data.Repository;
+import org.apache.geode.tools.pulse.internal.util.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/ConnectionUtil.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/ConnectionUtil.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/ConnectionUtil.java
index 9bbed8a..8775723 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/ConnectionUtil.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/ConnectionUtil.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package com.vmware.geode.tools.pulse.internal.util;
+package org.apache.geode.tools.pulse.internal.util;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/IPAddressUtil.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/IPAddressUtil.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/IPAddressUtil.java
index 8cb6036..72b264f 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/IPAddressUtil.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/IPAddressUtil.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.util;
+package org.apache.geode.tools.pulse.internal.util;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/StringUtils.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/StringUtils.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/StringUtils.java
index 64f2731..e719d13 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/StringUtils.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/StringUtils.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.util;
+package org.apache.geode.tools.pulse.internal.util;
/**
* Class StringUtils This is utility class for string.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e9bf1176/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/TimeUtils.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/TimeUtils.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/TimeUtils.java
index 21f9116..4ddfe54 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/TimeUtils.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/TimeUtils.java
@@ -17,7 +17,7 @@
*
*/
-package com.vmware.geode.tools.pulse.internal.util;
+package org.apache.geode.tools.pulse.internal.util;
/**
* Class TimeUtils
[18/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
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();
+ }
+ }
+}
[22/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java
new file mode 100644
index 0000000..32fd810
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/PulseController.java
@@ -0,0 +1,524 @@
+/*
+ *
+ * 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.controllers;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.vmware.geode.tools.pulse.internal.data.Cluster;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.PulseVersion;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import com.vmware.geode.tools.pulse.internal.service.PulseService;
+import com.vmware.geode.tools.pulse.internal.service.PulseServiceFactory;
+import com.vmware.geode.tools.pulse.internal.service.SystemAlertsService;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+/**
+ * Class PulseController
+ *
+ * This class contains the implementations for all http Ajax requests needs to
+ * be served in Pulse.
+ *
+ * @since GemFire version 7.5
+ */
+@Controller
+public class PulseController {
+
+ private static final PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+
+ // CONSTANTS
+ private final String DEFAULT_EXPORT_FILENAME = "DataBrowserQueryResult.json";
+ private final String QUERYSTRING_PARAM_ACTION = "action";
+ private final String QUERYSTRING_PARAM_QUERYID = "queryId";
+ private final String ACTION_VIEW = "view";
+ private final String ACTION_DELETE = "delete";
+
+ private String STATUS_REPSONSE_SUCCESS = "success";
+ private String STATUS_REPSONSE_FAIL = "fail";
+
+ private String ERROR_REPSONSE_QUERYNOTFOUND = "No queries found";
+ private String ERROR_REPSONSE_QUERYIDMISSING = "Query id is missing";
+
+ private static final String EMPTY_JSON = "{}";
+
+ // Shared object to hold pulse version details
+ public static PulseVersion pulseVersion = new PulseVersion();
+
+ //default is gemfire
+ private static String pulseProductSupport = PulseConstants.PRODUCT_NAME_GEMFIRE;
+
+ private final ObjectMapper mapper = new ObjectMapper();
+
+ @Autowired
+ PulseServiceFactory pulseServiceFactory;
+
+ @RequestMapping(value = "/pulseUpdate", method = RequestMethod.POST)
+ public void getPulseUpdate(HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ String pulseData = request.getParameter("pulseData");
+
+ ObjectNode responseMap = mapper.createObjectNode();
+
+ JsonNode requestMap = null;
+
+ try {
+ requestMap = mapper.readTree(pulseData);
+ Iterator<?> keys = requestMap.fieldNames();
+
+ // Execute Services
+ while (keys.hasNext()) {
+ String serviceName = keys.next().toString();
+ try {
+ PulseService pulseService = pulseServiceFactory
+ .getPulseServiceInstance(serviceName);
+ responseMap.put(serviceName, pulseService.execute(request));
+ } catch (Exception serviceException) {
+ LOGGER.warning("serviceException [for service "+serviceName+"] = " + serviceException.getMessage());
+ responseMap.put(serviceName, EMPTY_JSON);
+ }
+ }
+ } catch (Exception e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine("Exception Occurred : " + e.getMessage());
+ }
+ }
+
+ // Create Response
+ response.getOutputStream().write(responseMap.toString().getBytes());
+ }
+
+ @RequestMapping(value = "/authenticateUser", method = RequestMethod.GET)
+ public void authenticateUser(HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ try {
+ responseJSON.put("isUserLoggedIn", this.isUserLoggedIn(request));
+ // Send json response
+ response.getOutputStream().write(responseJSON.toString().getBytes());
+ } catch (Exception e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine("Exception Occurred : " + e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Method isUserLoggedIn Check whether user is logged in or not.
+ *
+ * @param request
+ * @return boolean
+ */
+ protected boolean isUserLoggedIn(HttpServletRequest request) {
+ return null != request.getUserPrincipal();
+ }
+
+ @RequestMapping(value = "/pulseVersion", method = RequestMethod.GET)
+ public void pulseVersion(HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ try {
+ // Reference to repository
+ Repository repository = Repository.get();
+ // set pulse web app url
+ String pulseWebAppUrl = request.getScheme() + "://"
+ + request.getServerName() + ":" + request.getServerPort()
+ + request.getContextPath();
+
+ repository.setPulseWebAppUrl(pulseWebAppUrl);
+
+ // Response
+ responseJSON.put("pulseVersion", PulseController.pulseVersion.getPulseVersion());
+ responseJSON.put("buildId", PulseController.pulseVersion.getPulseBuildId());
+ responseJSON.put("buildDate", PulseController.pulseVersion.getPulseBuildDate());
+ responseJSON.put("sourceDate", PulseController.pulseVersion.getPulseSourceDate());
+ responseJSON.put("sourceRevision", PulseController.pulseVersion.getPulseSourceRevision());
+ responseJSON.put("sourceRepository", PulseController.pulseVersion.getPulseSourceRepository());
+
+ } catch (Exception e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine("Exception Occured : " + e.getMessage());
+ }
+ }
+
+ // Send json response
+ response.getOutputStream().write(responseJSON.toString().getBytes());
+ }
+
+ @RequestMapping(value = "/clearAlerts", method = RequestMethod.GET)
+ public void clearAlerts(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ int alertType;
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ try {
+ alertType = Integer.valueOf(request.getParameter("alertType"));
+ } catch (NumberFormatException e) {
+ // Empty json response
+ response.getOutputStream().write(responseJSON.toString().getBytes());
+ if (LOGGER.finerEnabled()) {
+ LOGGER.finer(e.getMessage());
+ }
+ return;
+ }
+
+ try {
+ boolean isClearAll = Boolean.valueOf(request.getParameter("clearAll"));
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+ cluster.clearAlerts(alertType, isClearAll);
+ responseJSON.put("status", "deleted");
+ responseJSON.put(
+ "systemAlerts", SystemAlertsService.getAlertsJson(cluster,
+ cluster.getNotificationPageNumber()));
+ responseJSON.put("pageNumber", cluster.getNotificationPageNumber());
+
+ boolean isGFConnected = cluster.isConnectedFlag();
+ if(isGFConnected){
+ responseJSON.put("connectedFlag", isGFConnected);
+ }else{
+ responseJSON.put("connectedFlag", isGFConnected);
+ responseJSON.put("connectedErrorMsg", cluster.getConnectionErrorMsg());
+ }
+ } catch (Exception e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine("Exception Occurred : " + e.getMessage());
+ }
+ }
+
+ // Send json response
+ response.getOutputStream().write(responseJSON.toString().getBytes());
+ }
+
+ @RequestMapping(value = "/acknowledgeAlert", method = RequestMethod.GET)
+ public void acknowledgeAlert(HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ int alertId;
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ try {
+ alertId = Integer.valueOf(request.getParameter("alertId"));
+ } catch (NumberFormatException e) {
+ // Empty json response
+ response.getOutputStream().write(responseJSON.toString().getBytes());
+ if (LOGGER.finerEnabled()) {
+ LOGGER.finer(e.getMessage());
+ }
+ return;
+ }
+
+ try {
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // set alert is acknowledged
+ cluster.acknowledgeAlert(alertId);
+ responseJSON.put("status", "deleted");
+ } catch (Exception e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine("Exception Occured : " + e.getMessage());
+ }
+ }
+
+ // Send json response
+ response.getOutputStream().write(responseJSON.toString().getBytes());
+ }
+
+ @RequestMapping(value = "/dataBrowserRegions", method = RequestMethod.GET)
+ public void dataBrowserRegions(HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+
+ // json object to be sent as response
+ ObjectNode responseJSON = mapper.createObjectNode();
+ ArrayNode regionsData = mapper.createArrayNode();
+
+ try {
+ // getting cluster's Regions
+ responseJSON.put("clusterName", cluster.getServerName());
+ regionsData = getRegionsJson(cluster);
+ responseJSON.put("clusterRegions", regionsData);
+ responseJSON.put("connectedFlag", cluster.isConnectedFlag());
+ responseJSON.put("connectedErrorMsg", cluster.getConnectionErrorMsg());
+ } catch (Exception e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine("Exception Occured : " + e.getMessage());
+ }
+ }
+
+ // Send json response
+ response.getOutputStream().write(responseJSON.toString().getBytes());
+ }
+
+ /**
+ * This method creates json for list of cluster regions
+ *
+ * @param cluster
+ * @return ArrayNode JSON array
+ */
+ private ArrayNode getRegionsJson(Cluster cluster) {
+
+ Collection<Cluster.Region> clusterRegions = cluster.getClusterRegions().values();
+ ArrayNode regionsListJson = mapper.createArrayNode();
+
+ if (!clusterRegions.isEmpty()) {
+ for (Cluster.Region region : clusterRegions) {
+ ObjectNode regionJSON = mapper.createObjectNode();
+ regionJSON.put("name", region.getName());
+ regionJSON.put("fullPath", region.getFullPath());
+ regionJSON.put("regionType", region.getRegionType());
+
+ if (region.getRegionType().contains("PARTITION")) {
+ regionJSON.put("isPartition", true);
+ } else {
+ regionJSON.put("isPartition", false);
+ }
+
+ regionJSON.put("memberCount", region.getMemberCount());
+ List<String> regionsMembers = region.getMemberName();
+ ArrayNode jsonRegionMembers = mapper.createArrayNode();
+
+ for (int i = 0; i < regionsMembers.size(); i++) {
+ Cluster.Member member = cluster.getMembersHMap().get(
+ regionsMembers.get(i));
+ ObjectNode jsonMember = mapper.createObjectNode();
+ jsonMember.put("key", regionsMembers.get(i));
+ jsonMember.put("id", member.getId());
+ jsonMember.put("name", member.getName());
+
+ jsonRegionMembers.add(jsonMember);
+ }
+
+ regionJSON.put("members", jsonRegionMembers);
+ regionsListJson.add(regionJSON);
+ }
+ }
+ return regionsListJson;
+ }
+
+ @RequestMapping(value = "/dataBrowserQuery", method = RequestMethod.GET)
+ public void dataBrowserQuery(HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ // get query string
+ String query = request.getParameter("query");
+ String members = request.getParameter("members");
+ int limit = 0;
+
+ try {
+ limit = Integer.valueOf(request.getParameter("limit"));
+ } catch (NumberFormatException e) {
+ limit = 0;
+ if (LOGGER.finerEnabled()) {
+ LOGGER.finer(e.getMessage());
+ }
+ }
+
+ ObjectNode queryResult = mapper.createObjectNode();
+ try {
+
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(query)) {
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+ String userName = request.getUserPrincipal().getName();
+
+ // Call execute query method
+ queryResult = cluster.executeQuery(query, members, limit);
+
+ // Add query in history if query is executed successfully
+ if (!queryResult.has("error")) {
+ // Add html escaped query to history
+ String escapedQuery = StringEscapeUtils.escapeHtml(query);
+ cluster.addQueryInHistory(escapedQuery, userName);
+ }
+ }
+ } catch (Exception e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine("Exception Occured : " + e.getMessage());
+ }
+ }
+
+ response.getOutputStream().write(queryResult.toString().getBytes());
+ }
+
+ @RequestMapping(value = "/dataBrowserQueryHistory", method = RequestMethod.GET)
+ public void dataBrowserQueryHistory(HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ ObjectNode responseJSON = mapper.createObjectNode();
+ ArrayNode queryResult = null;
+ String action = "";
+
+ try {
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+ String userName = request.getUserPrincipal().getName();
+
+ // get query string
+ action = request.getParameter(QUERYSTRING_PARAM_ACTION);
+ if (!StringUtils.isNotNullNotEmptyNotWhiteSpace(action)) {
+ action = ACTION_VIEW;
+ }
+
+ if (action.toLowerCase().equalsIgnoreCase(ACTION_DELETE)) {
+ String queryId = request.getParameter(QUERYSTRING_PARAM_QUERYID);
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(queryId)) {
+
+ boolean deleteStatus = cluster.deleteQueryById(userName, queryId);
+ if (deleteStatus) {
+ responseJSON.put("status", STATUS_REPSONSE_SUCCESS);
+ } else {
+ responseJSON.put("status", STATUS_REPSONSE_FAIL);
+ responseJSON.put("error", ERROR_REPSONSE_QUERYNOTFOUND);
+ }
+ } else {
+ responseJSON.put("status", STATUS_REPSONSE_FAIL);
+ responseJSON.put("error", ERROR_REPSONSE_QUERYIDMISSING);
+ }
+ }
+
+ // Get list of past executed queries
+ queryResult = cluster.getQueryHistoryByUserId(userName);
+ responseJSON.put("queryHistory", queryResult);
+ } catch (Exception e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine("Exception Occured : " + e.getMessage());
+ }
+ }
+ response.getOutputStream().write(responseJSON.toString().getBytes());
+ }
+
+ @RequestMapping(value = "/dataBrowserExport", method = RequestMethod.POST)
+ public void dataBrowserExport(HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+
+ // get query string
+ String filename = request.getParameter("filename");
+ String resultContent = request.getParameter("content");
+
+ response.setHeader("Cache-Control", "");
+ response.setHeader("Content-type", "text/plain");
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(filename)) {
+ response.setHeader("Content-Disposition", "attachment; filename=" + filename);
+ } else {
+ response.setHeader("Content-Disposition", "attachment; filename=" + DEFAULT_EXPORT_FILENAME);
+ }
+
+ if (!StringUtils.isNotNullNotEmptyNotWhiteSpace(resultContent)) {
+ resultContent = "";
+ }
+
+ response.getOutputStream().write(resultContent.getBytes());
+ }
+
+ @RequestMapping(value = "/pulseProductSupport", method = RequestMethod.GET)
+ public void getConfiguredPulseProduct(HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ ObjectNode responseJSON = mapper.createObjectNode();
+
+ try {
+ responseJSON.put("product", pulseProductSupport);
+
+ // Send json response
+ response.getOutputStream().write(responseJSON.toString().getBytes());
+ } catch (Exception e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine("Exception Occurred : " + e.getMessage());
+ }
+ }
+ }
+
+ @RequestMapping(value = "/getQueryStatisticsGridModel", method = RequestMethod.GET)
+ public void getQueryStatisticsGridModel(HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+
+ ObjectNode responseJSON = mapper.createObjectNode();
+ // get cluster object
+ Cluster cluster = Repository.get().getCluster();
+ String userName = request.getUserPrincipal().getName();
+
+ try {
+ String[] arrColNames = Cluster.Statement.getGridColumnNames();
+ String[] arrColAttribs = Cluster.Statement.getGridColumnAttributes();
+ int[] arrColWidths = Cluster.Statement.getGridColumnWidths();
+
+ ArrayNode colNamesList = mapper.createArrayNode();
+ for (int i = 0; i < arrColNames.length; ++i) {
+ colNamesList.add(arrColNames[i]);
+ }
+
+ ArrayNode colModelList = mapper.createArrayNode();
+ for (int i = 0; i < arrColAttribs.length; ++i) {
+ ObjectNode columnJSON = mapper.createObjectNode();
+ columnJSON.put("name", arrColAttribs[i]);
+ columnJSON.put("index", arrColAttribs[i]);
+ columnJSON.put("width", arrColWidths[i]);
+ columnJSON.put("sortable", "true");
+ columnJSON.put("sorttype", ((i == 0) ? "String" : "integer"));
+ colModelList.add(columnJSON);
+ }
+
+ responseJSON.put("columnNames", colNamesList);
+ responseJSON.put("columnModels", colModelList);
+ responseJSON.put("clusterName", cluster.getServerName());
+ responseJSON.put("userName", userName);
+
+ // Send json response
+ response.getOutputStream().write(responseJSON.toString().getBytes());
+ } catch (Exception e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine("Exception Occured : " + e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * @return the pulseProductSupport
+ */
+ public static String getPulseProductSupport() {
+ return pulseProductSupport;
+ }
+
+ /**
+ * @param pulseProductSupport
+ * the pulseProductSupport to set
+ */
+ public static void setPulseProductSupport(String pulseProductSupport) {
+ PulseController.pulseProductSupport = pulseProductSupport;
+ }
+}
\ No newline at end of file
[30/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
Posted by hi...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/DataBrowser.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/DataBrowser.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/DataBrowser.java
deleted file mode 100644
index 768fe41..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/DataBrowser.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.data;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.log.PulseLogWriter;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.Iterator;
-import java.util.ResourceBundle;
-import java.util.Scanner;
-
-/**
- * Class DataBrowser This class contains Data browser functionalities for
- * managing queries and histories.
- *
- * @since GemFire version 7.5.Beta 2013-03-25
- */
-public class DataBrowser {
-
- private final PulseLogWriter LOGGER = PulseLogWriter.getLogger();
- private final ResourceBundle resourceBundle = Repository.get()
- .getResourceBundle();
-
- private SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
- PulseConstants.PULSE_QUERY_HISTORY_DATE_PATTERN);
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- /**
- * addQueryInHistory method adds user's query into query history file
- *
- * @param userId
- * Logged in User's Id
- * @param queryText
- * Query text to execute
- */
- public boolean addQueryInHistory(String queryText, String userId) {
- boolean operationStatus = false;
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(queryText)
- && StringUtils.isNotNullNotEmptyNotWhiteSpace(userId)) {
-
- // Fetch all queries from query log file
- ObjectNode queries = fetchAllQueriesFromFile();
-
- // Get user's query history list
- ObjectNode userQueries = (ObjectNode) queries.get(userId);
- if (userQueries == null) {
- userQueries = mapper.createObjectNode();
- }
-
- // Add query in user's query history list
- userQueries.put(Long.toString(System.currentTimeMillis()), queryText);
- queries.put(userId, userQueries);
-
- // Store queries in file back
- operationStatus = storeQueriesInFile(queries);
- }
-
- return operationStatus;
- }
-
- /**
- * deleteQueryById method deletes query from query history file
- *
- * @param userId
- * Logged in user's Unique Id
- * @param queryId
- * Unique Id of Query to be deleted
- * @return boolean
- */
- public boolean deleteQueryById(String userId, String queryId) {
-
- boolean operationStatus = false;
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(queryId)
- && StringUtils.isNotNullNotEmptyNotWhiteSpace(userId)) {
-
- // Fetch all queries from query log file
- ObjectNode queries = fetchAllQueriesFromFile();
-
- // Get user's query history list
- ObjectNode userQueries = (ObjectNode) queries.get(userId);
-
- if (userQueries != null) {
- // Remove user's query
- userQueries.remove(queryId);
- queries.put(userId, userQueries);
-
- // Store queries in file back
- operationStatus = storeQueriesInFile(queries);
- }
- }
-
- return operationStatus;
- }
-
- /**
- * getQueryHistoryByUserId method reads and lists out the queries from history
- * file
- *
- * @param userId
- * Logged in User's Id
- */
- public ArrayNode getQueryHistoryByUserId(String userId) {
-
- ArrayNode queryList = mapper.createArrayNode();
-
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(userId)) {
-
- // Fetch all queries from query log file
- ObjectNode queries = fetchAllQueriesFromFile();
-
- // Get user's query history list
- ObjectNode userQueries = (ObjectNode) queries.get(userId);
-
- if (userQueries != null) {
- Iterator<String> it = userQueries.fieldNames();
- while (it.hasNext()) {
- String key = it.next();
- ObjectNode queryItem = mapper.createObjectNode();
- queryItem.put("queryId", key);
- queryItem.put("queryText", userQueries.get(key).toString());
- queryItem.put("queryDateTime", simpleDateFormat.format(Long.valueOf(key)));
- queryList.add(queryItem);
- }
- }
- }
-
- return queryList;
- }
-
- /**
- * generateQueryKey method fetches queries from query history file
- *
- * @return Properties A collection queries in form of key and values
- */
- private ObjectNode fetchAllQueriesFromFile() {
- InputStream inputStream = null;
- JsonNode queriesJSON = mapper.createObjectNode();
-
- try {
- inputStream = new FileInputStream(Repository.get().getPulseConfig().getQueryHistoryFileName());
- String inputStreamString = new Scanner(inputStream, "UTF-8").useDelimiter("\\A").next();
- queriesJSON = mapper.readTree(inputStreamString);
- } catch (FileNotFoundException e) {
- if (LOGGER.fineEnabled()) {
- LOGGER.fine(resourceBundle
- .getString("LOG_MSG_DATA_BROWSER_QUERY_HISTORY_FILE_NOT_FOUND")
- + " : " + e.getMessage());
- }
- } catch (Exception e) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(e.getMessage());
- }
- } finally {
- // Close input stream
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (IOException e) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(e.getMessage());
- }
- }
- }
- }
-
- return (ObjectNode) queriesJSON;
- }
-
- /**
- * generateQueryKey method stores queries in query history file.
- *
- * @return Boolean true is operation is successful, false otherwise
- */
- private boolean storeQueriesInFile(ObjectNode queries) {
- boolean operationStatus = false;
- FileOutputStream fileOut = null;
-
- File file = new File(Repository.get().getPulseConfig().getQueryHistoryFileName());
- try {
- fileOut = new FileOutputStream(file);
-
- // if file does not exists, then create it
- if (!file.exists()) {
- file.createNewFile();
- }
-
- // get the content in bytes
- byte[] contentInBytes = queries.toString().getBytes();
-
- fileOut.write(contentInBytes);
- fileOut.flush();
-
- operationStatus = true;
- } catch (FileNotFoundException e) {
-
- if (LOGGER.fineEnabled()) {
- LOGGER.fine(resourceBundle
- .getString("LOG_MSG_DATA_BROWSER_QUERY_HISTORY_FILE_NOT_FOUND")
- + " : " + e.getMessage());
- }
- } catch (IOException e) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(e.getMessage());
- }
- } finally {
- if (fileOut != null) {
- try {
- fileOut.close();
- } catch (IOException e) {
- if (LOGGER.infoEnabled()) {
- LOGGER.info(e.getMessage());
- }
- }
- }
- }
- return operationStatus;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/IClusterUpdater.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/IClusterUpdater.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/IClusterUpdater.java
deleted file mode 100644
index 49e2e1d..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/data/IClusterUpdater.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.data;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Interface having updateData() function which is getting Override by both
- * MockDataUpdater and JMXDataUpdater
- *
- * @since GemFire version 7.0.Beta 2012-09-23
- *
- */
-public interface IClusterUpdater {
- boolean updateData();
-
- ObjectNode executeQuery(String queryText, String members, int limit);
-}