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/09 21:43:58 UTC
[61/83] [abbrv] incubator-geode git commit: GEODE-37 renamed pulse
package
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/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 06d7f3d..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.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/eff7f216/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 4b25a8d..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.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/eff7f216/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 6470195..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.geode.tools.pulse.testbed;
-
-public class GemfireTopology {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/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 1892292..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.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/eff7f216/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 007be75..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.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/eff7f216/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 ba04c32..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.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