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); +}
