http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGatewayHubService.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGatewayHubService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGatewayHubService.java new file mode 100644 index 0000000..932ec41 --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberGatewayHubService.java @@ -0,0 +1,149 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.vmware.geode.tools.pulse.internal.service; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.vmware.geode.tools.pulse.internal.data.Cluster; +import com.vmware.geode.tools.pulse.internal.data.Repository; +import com.vmware.geode.tools.pulse.internal.util.StringUtils; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Class MemberGatewayHubService + * + * This class contains implementations of getting Gateway Receivers and Senders + * details of Cluster Member. + * + * @since GemFire version 7.5 + */ +@Component +@Service("MemberGatewayHub") +@Scope("singleton") +public class MemberGatewayHubService implements PulseService { + + private final ObjectMapper mapper = new ObjectMapper(); + + public ObjectNode execute(final HttpServletRequest request) throws Exception { + + // get cluster object + Cluster cluster = Repository.get().getCluster(); + + // json object to be sent as response + ObjectNode responseJSON = mapper.createObjectNode(); + + JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData")); + String memberName = requestDataJSON.get("MemberGatewayHub").get("memberName").textValue(); + + Cluster.Member clusterMember = cluster.getMember(StringUtils + .makeCompliantName(memberName)); + + if (clusterMember != null) { + // response + // get gateway receiver + Cluster.GatewayReceiver gatewayReceiver = clusterMember.getGatewayReceiver(); + + Boolean isGateway = false; + + if (gatewayReceiver != null) { + responseJSON.put("isGatewayReceiver", true); + responseJSON.put("listeningPort", gatewayReceiver.getListeningPort()); + responseJSON.put("linkTroughput", gatewayReceiver.getLinkThroughput()); + responseJSON.put("avgBatchLatency", gatewayReceiver.getAvgBatchProcessingTime()); + } else { + responseJSON.put("isGatewayReceiver", false); + } + + // get gateway senders + Cluster.GatewaySender[] gatewaySenders = clusterMember.getMemberGatewaySenders(); + + if (gatewaySenders.length > 0) { + isGateway = true; + } + responseJSON.put("isGatewaySender", isGateway); + // Senders + ArrayNode gatewaySendersJsonList = mapper.createArrayNode(); + + for (Cluster.GatewaySender gatewaySender : gatewaySenders) { + ObjectNode gatewaySenderJSON = mapper.createObjectNode(); + gatewaySenderJSON.put("id", gatewaySender.getId()); + gatewaySenderJSON.put("queueSize", gatewaySender.getQueueSize()); + gatewaySenderJSON.put("status", gatewaySender.getStatus()); + gatewaySenderJSON.put("primary", gatewaySender.getPrimary()); + gatewaySenderJSON.put("senderType", gatewaySender.getSenderType()); + gatewaySenderJSON.put("batchSize", gatewaySender.getBatchSize()); + gatewaySenderJSON.put("PersistenceEnabled", gatewaySender.getPersistenceEnabled()); + gatewaySenderJSON.put("remoteDSId", gatewaySender.getRemoteDSId()); + gatewaySenderJSON.put("eventsExceedingAlertThreshold", gatewaySender.getEventsExceedingAlertThreshold()); + + gatewaySendersJsonList.add(gatewaySenderJSON); + } + // senders response + responseJSON.put("gatewaySenders", gatewaySendersJsonList); + + // async event queues + Cluster.AsyncEventQueue[] asyncEventQueues = clusterMember.getMemberAsyncEventQueueList(); + ArrayNode asyncEventQueueJsonList = mapper.createArrayNode(); + + for (Cluster.AsyncEventQueue asyncEventQueue : asyncEventQueues) { + ObjectNode asyncEventQueueJSON = mapper.createObjectNode(); + asyncEventQueueJSON.put("id", asyncEventQueue.getId()); + asyncEventQueueJSON.put("primary", asyncEventQueue.getPrimary()); + asyncEventQueueJSON.put("senderType", asyncEventQueue.isParallel()); + asyncEventQueueJSON.put("batchSize", asyncEventQueue.getBatchSize()); + asyncEventQueueJSON.put("batchTimeInterval", asyncEventQueue.getBatchTimeInterval()); + asyncEventQueueJSON.put("batchConflationEnabled", asyncEventQueue.isBatchConflationEnabled()); + asyncEventQueueJSON.put("asyncEventListener", asyncEventQueue.getAsyncEventListener()); + asyncEventQueueJSON.put("queueSize", asyncEventQueue.getEventQueueSize()); + + asyncEventQueueJsonList.add(asyncEventQueueJSON); + } + responseJSON.put("asyncEventQueues", asyncEventQueueJsonList); + + Map<String,Cluster.Region> clusterRegions = cluster.getClusterRegions(); + + List<Cluster.Region> clusterRegionsList = new ArrayList<Cluster.Region>(); + clusterRegionsList.addAll(clusterRegions.values()); + + ArrayNode regionsList = mapper.createArrayNode(); + + for (Cluster.Region region : clusterRegionsList) { + if (region.getWanEnabled()) { + ObjectNode regionJSON = mapper.createObjectNode(); + regionJSON.put("name", region.getName()); + regionsList.add(regionJSON); + } + } + responseJSON.put("regionsInvolved", regionsList); + } + + // Send json response + return responseJSON; + } +}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberHeapUsageService.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberHeapUsageService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberHeapUsageService.java new file mode 100644 index 0000000..966b346 --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberHeapUsageService.java @@ -0,0 +1,73 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.vmware.geode.tools.pulse.internal.service; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.vmware.geode.tools.pulse.internal.data.Cluster; +import com.vmware.geode.tools.pulse.internal.data.Repository; +import com.vmware.geode.tools.pulse.internal.util.StringUtils; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; + +/** + * Class MemberHeapUsageService + * + * This class contains implementations of getting Memeber's current Heap Usage + * and its trend over the time. + * + * @since GemFire version 7.5 + */ +@Component +@Service("MemberHeapUsage") +@Scope("singleton") +public class MemberHeapUsageService implements PulseService { + + private final ObjectMapper mapper = new ObjectMapper(); + + public ObjectNode execute(final HttpServletRequest request) throws Exception { + + // get cluster object + Cluster cluster = Repository.get().getCluster(); + + // json object to be sent as response + ObjectNode responseJSON = mapper.createObjectNode(); + + // members list + JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData")); + String memberName = requestDataJSON.get("MemberHeapUsage").get("memberName").textValue(); + + Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName)); + + if (clusterMember != null) { + // response + responseJSON.put("heapUsageTrend", + mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_HEAP_USAGE_SAMPLE))); + responseJSON.put("currentHeapUsage", clusterMember.getCurrentHeapSize()); + } + + // Send json response + return responseJSON; + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberKeyStatisticsService.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberKeyStatisticsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberKeyStatisticsService.java new file mode 100644 index 0000000..8519ad4 --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberKeyStatisticsService.java @@ -0,0 +1,76 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.vmware.geode.tools.pulse.internal.service; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.vmware.geode.tools.pulse.internal.data.Cluster; +import com.vmware.geode.tools.pulse.internal.data.Repository; +import com.vmware.geode.tools.pulse.internal.util.StringUtils; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; + +/** + * Class MemberKeyStatisticsService + * + * This class contains implementations of getting Member's CPU, Memory and Read + * Write details + * + * @since GemFire version 7.5 + */ +@Component +@Service("MemberKeyStatistics") +@Scope("singleton") +public class MemberKeyStatisticsService implements PulseService { + + private final ObjectMapper mapper = new ObjectMapper(); + + public ObjectNode execute(final HttpServletRequest request) throws Exception { + + // get cluster object + Cluster cluster = Repository.get().getCluster(); + + // json object to be sent as response + ObjectNode responseJSON = mapper.createObjectNode(); + + JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData")); + String memberName = requestDataJSON.get("MemberKeyStatistics").get("memberName").textValue(); + + Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName)); + + if (clusterMember != null) { + // response + responseJSON.put("cpuUsageTrend", + mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_CPU_USAGE_SAMPLE))); + responseJSON.put("memoryUsageTrend", + mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_HEAP_USAGE_SAMPLE))); + responseJSON.put("readPerSecTrend", + mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_GETS_PER_SECOND))); + responseJSON.put("writePerSecTrend", + mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_PUTS_PER_SECOND))); + } + // Send json response + return responseJSON; + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberRegionsService.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberRegionsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberRegionsService.java new file mode 100644 index 0000000..ffd24d0 --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MemberRegionsService.java @@ -0,0 +1,127 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.vmware.geode.tools.pulse.internal.service; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.vmware.geode.tools.pulse.internal.controllers.PulseController; +import com.vmware.geode.tools.pulse.internal.data.Cluster; +import com.vmware.geode.tools.pulse.internal.data.PulseConstants; +import com.vmware.geode.tools.pulse.internal.data.Repository; +import com.vmware.geode.tools.pulse.internal.util.StringUtils; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; +import java.text.DecimalFormat; + +/** + * Class MemberRegionsService + * + * This class contains implementations of getting Memeber's Regions details. + * + * @since GemFire version 7.5 + */ + +@Component +@Service("MemberRegions") +@Scope("singleton") +public class MemberRegionsService implements PulseService { + + private final ObjectMapper mapper = new ObjectMapper(); + + // String constants used for forming a json response + private final String NAME = "name"; + private final String ENTRY_SIZE = "entrySize"; + private final String DISC_STORE_NAME = "diskStoreName"; + private final String DISC_SYNCHRONOUS = "diskSynchronous"; + + public ObjectNode execute(final HttpServletRequest request) throws Exception { + + // get cluster object + Cluster cluster = Repository.get().getCluster(); + + // json object to be sent as response + ObjectNode responseJSON = mapper.createObjectNode(); + + JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData")); + String memberName = requestDataJSON.get("MemberRegions").get("memberName").textValue(); + + Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName)); + + if (clusterMember != null) { + responseJSON.put("memberId", clusterMember.getId()); + responseJSON.put(this.NAME, clusterMember.getName()); + responseJSON.put("host", clusterMember.getHost()); + + // member's regions + Cluster.Region[] memberRegions = clusterMember.getMemberRegionsList(); + ArrayNode regionsListJson = mapper.createArrayNode(); + for (Cluster.Region memberRegion : memberRegions) { + ObjectNode regionJSON = mapper.createObjectNode(); + regionJSON.put(this.NAME, memberRegion.getName()); + + if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController.getPulseProductSupport())) { + // Convert region path to dot separated region path + regionJSON.put("fullPath", StringUtils.getTableNameFromRegionName(memberRegion.getFullPath())); + } else { + regionJSON.put("fullPath", memberRegion.getFullPath()); + } + + regionJSON.put("type", memberRegion.getRegionType()); + regionJSON.put("entryCount", memberRegion.getSystemRegionEntryCount()); + Long entrySize = memberRegion.getEntrySize(); + + DecimalFormat form = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN_2); + String entrySizeInMB = form.format(entrySize / (1024f * 1024f)); + + if (entrySize < 0) { + regionJSON.put(this.ENTRY_SIZE, this.VALUE_NA); + } else { + regionJSON.put(this.ENTRY_SIZE, entrySizeInMB); + } + regionJSON.put("scope", memberRegion.getScope()); + String diskStoreName = memberRegion.getDiskStoreName(); + if (StringUtils.isNotNullNotEmptyNotWhiteSpace(diskStoreName)) { + regionJSON.put(this.DISC_STORE_NAME, diskStoreName); + regionJSON.put(this.DISC_SYNCHRONOUS, + memberRegion.isDiskSynchronous()); + } else { + regionJSON.put(this.DISC_SYNCHRONOUS, this.VALUE_NA); + regionJSON.put(this.DISC_STORE_NAME, ""); + } + regionJSON.put("gatewayEnabled", memberRegion.getWanEnabled()); + + regionsListJson.add(regionJSON); + } + responseJSON.put("memberRegions", regionsListJson); + + // response + responseJSON.put("status", "Normal"); + + } + + // Send json response + return responseJSON; + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MembersListService.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MembersListService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MembersListService.java new file mode 100644 index 0000000..467d8c0 --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/MembersListService.java @@ -0,0 +1,75 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.vmware.geode.tools.pulse.internal.service; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.vmware.geode.tools.pulse.internal.data.Cluster; +import com.vmware.geode.tools.pulse.internal.data.Repository; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; + +/** + * Class MembersListService + * + * This class contains implementations of getting list of Cluster Members. + * + * @since GemFire version 7.5 + */ +@Component +@Service("MembersList") +@Scope("singleton") +public class MembersListService implements PulseService { + + private final ObjectMapper mapper = new ObjectMapper(); + + public ObjectNode execute(final HttpServletRequest request) throws Exception { + + // get cluster object + Cluster cluster = Repository.get().getCluster(); + + // json object to be sent as response + ObjectNode responseJSON = mapper.createObjectNode(); + + // members list + ArrayNode memberListJson = mapper.createArrayNode(); + Cluster.Member[] memberSet = cluster.getMembers(); + + for (Cluster.Member member : memberSet) { + ObjectNode memberJSON = mapper.createObjectNode(); + memberJSON.put("memberId", member.getId()); + memberJSON.put("name", member.getName()); + memberJSON.put("host", member.getHost()); + + memberListJson.add(memberJSON); + } + + // Response JSON + responseJSON.put("clusterMembers", memberListJson); + responseJSON.put("clusterName", cluster.getServerName()); + + // Send json response + return responseJSON; + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseService.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseService.java new file mode 100644 index 0000000..58d9dbf --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseService.java @@ -0,0 +1,40 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.vmware.geode.tools.pulse.internal.service; + +import javax.servlet.http.HttpServletRequest; + +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * Abstract class PulseService + * + * This is a base class for all services in pulse. + * + * @since GemFire version 7.5 + */ +public interface PulseService { + + String VALUE_NA = "NA"; + String VALUE_ON = "ON"; + String VALUE_OFF = "OFF"; + + ObjectNode execute(HttpServletRequest httpServletRequest) throws Exception; +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseServiceFactory.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseServiceFactory.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseServiceFactory.java new file mode 100644 index 0000000..ead5200 --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseServiceFactory.java @@ -0,0 +1,55 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.vmware.geode.tools.pulse.internal.service; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * Class PulseServiceFactory + * + * @since GemFire version 7.5 + */ +@Component +@Scope("singleton") +public class PulseServiceFactory implements ApplicationContextAware { + + static final long serialVersionUID = 02L; + ApplicationContext applicationContext = null; + + public PulseService getPulseServiceInstance(final String servicename) { + + if (applicationContext != null + && applicationContext.containsBean(servicename)) { + return (PulseService) applicationContext.getBean(servicename); + } + return null; + } + + @Override + public void setApplicationContext(final ApplicationContext applicationContext) + throws BeansException { + + this.applicationContext = applicationContext; + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseVersionService.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseVersionService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseVersionService.java new file mode 100644 index 0000000..7b84404 --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/PulseVersionService.java @@ -0,0 +1,65 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.vmware.geode.tools.pulse.internal.service; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.vmware.geode.tools.pulse.internal.controllers.PulseController; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; + +/** + * Class PulseVersionService + * + * This class contains implementations of getting Pulse Applications Version's + * details (like version details, build details, source details, etc) from + * properties file + * + * @since GemFire version 7.0.Beta + */ + +@Component +@Service("PulseVersion") +@Scope("singleton") +public class PulseVersionService implements PulseService { + + private final ObjectMapper mapper = new ObjectMapper(); + + public ObjectNode execute(final HttpServletRequest request) throws Exception { + + // json object to be sent as response + ObjectNode responseJSON = mapper.createObjectNode(); + + // Response + responseJSON.put("pulseVersion", PulseController.pulseVersion.getPulseVersion()); + responseJSON.put("buildId", PulseController.pulseVersion.getPulseBuildId()); + responseJSON.put("buildDate", PulseController.pulseVersion.getPulseBuildDate()); + responseJSON.put("sourceDate", PulseController.pulseVersion.getPulseSourceDate()); + responseJSON.put("sourceRevision", PulseController.pulseVersion.getPulseSourceRevision()); + responseJSON.put("sourceRepository", PulseController.pulseVersion.getPulseSourceRepository()); + + // Send json response + return responseJSON; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/QueryStatisticsService.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/QueryStatisticsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/QueryStatisticsService.java new file mode 100644 index 0000000..87f65df --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/QueryStatisticsService.java @@ -0,0 +1,115 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.vmware.geode.tools.pulse.internal.service; + +import javax.servlet.http.HttpServletRequest; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import com.vmware.geode.tools.pulse.internal.data.Cluster; +import com.vmware.geode.tools.pulse.internal.data.PulseConstants; +import com.vmware.geode.tools.pulse.internal.data.Repository; + +/** + * Class QueryStatisticsService + * + * This class returns top N queries based on pagination and filtering criteria + * if any + * + * @since GemFire version 7.5 + */ +@Component +@Service("QueryStatistics") +@Scope("singleton") +public class QueryStatisticsService implements PulseService { + + private final ObjectMapper mapper = new ObjectMapper(); + + @Override + public ObjectNode execute(final HttpServletRequest request) throws Exception { + + // get cluster object + Cluster cluster = Repository.get().getCluster(); + + // json object to be sent as response + ObjectNode responseJSON = mapper.createObjectNode(); + + Cluster.Statement[] stmts = cluster.getStatements(); + + ArrayNode queryListJson = mapper.createArrayNode(); + for (int i = 0; i < stmts.length; ++i) { + ObjectNode queryJSON = mapper.createObjectNode(); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QUERYDEFINITION, stmts[i].getQueryDefinition()); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESCOMPILED, + mapper.valueToTree(stmts[i].getNumTimesCompiled() < 0 ? this.VALUE_NA : stmts[i].getNumTimesCompiled())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTION, + mapper.valueToTree(stmts[i].getNumExecution() < 0 ? this.VALUE_NA : stmts[i].getNumExecution())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTIONSINPROGRESS, + mapper.valueToTree(stmts[i].getNumExecutionsInProgress() < 0 ? this.VALUE_NA : stmts[i].getNumExecutionsInProgress())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESGLOBALINDEXLOOKUP, + mapper.valueToTree(stmts[i].getNumTimesGlobalIndexLookup() < 0 ? this.VALUE_NA : stmts[i].getNumTimesGlobalIndexLookup())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMROWSMODIFIED, + mapper.valueToTree(stmts[i].getNumRowsModified() < 0 ? this.VALUE_NA : stmts[i].getNumRowsModified())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_PARSETIME, + mapper.valueToTree(stmts[i].getParseTime() < 0 ? this.VALUE_NA : stmts[i].getParseTime())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_BINDTIME, + mapper.valueToTree(stmts[i].getBindTime() < 0 ? this.VALUE_NA : stmts[i].getBindTime())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_OPTIMIZETIME, + mapper.valueToTree(stmts[i].getOptimizeTime() < 0 ? this.VALUE_NA : stmts[i].getOptimizeTime())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_ROUTINGINFOTIME, + mapper.valueToTree(stmts[i].getRoutingInfoTime() < 0 ? this.VALUE_NA : stmts[i].getRoutingInfoTime())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_GENERATETIME, + mapper.valueToTree(stmts[i].getGenerateTime() < 1 ? this.VALUE_NA : stmts[i].getGenerateTime())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_TOTALCOMPILATIONTIME, + mapper.valueToTree(stmts[i].getTotalCompilationTime() < 0 ? this.VALUE_NA : stmts[i].getTotalCompilationTime())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_EXECUTIONTIME, + mapper.valueToTree(stmts[i].getExecutionTime() < 0 ? this.VALUE_NA : stmts[i].getExecutionTime())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_PROJECTIONTIME, + mapper.valueToTree(stmts[i].getProjectionTime() < 0 ? this.VALUE_NA : stmts[i].getProjectionTime())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_TOTALEXECUTIONTIME, + mapper.valueToTree(stmts[i].getTotalExecutionTime() < 0 ? this.VALUE_NA : stmts[i].getTotalExecutionTime())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_ROWSMODIFICATIONTIME, + mapper.valueToTree(stmts[i].getRowsModificationTime() < 0 ? this.VALUE_NA : stmts[i].getRowsModificationTime())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNNUMROWSSEEN, + mapper.valueToTree(stmts[i].getqNNumRowsSeen() < 0 ? this.VALUE_NA : stmts[i].getqNNumRowsSeen())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNMSGSENDTIME, + mapper.valueToTree(stmts[i].getqNMsgSendTime() < 0 ? this.VALUE_NA : stmts[i].getqNMsgSendTime())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNMSGSERTIME, + mapper.valueToTree(stmts[i].getqNMsgSerTime() < 0 ? this.VALUE_NA : stmts[i].getqNMsgSerTime())); + queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNRESPDESERTIME, + mapper.valueToTree(stmts[i].getqNRespDeSerTime() < 0 ? this.VALUE_NA : stmts[i].getqNRespDeSerTime())); + queryListJson.add(queryJSON); + } + responseJSON.put("queriesList", queryListJson); + + // return jmx status + responseJSON.put("connectedFlag", cluster.isConnectedFlag()); + responseJSON.put("connectedErrorMsg", cluster.getConnectionErrorMsg()); + + // Send json response + return responseJSON; + + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/SystemAlertsService.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/SystemAlertsService.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/SystemAlertsService.java new file mode 100644 index 0000000..d21f47a --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/SystemAlertsService.java @@ -0,0 +1,127 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.vmware.geode.tools.pulse.internal.service; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.vmware.geode.tools.pulse.internal.data.Cluster; +import com.vmware.geode.tools.pulse.internal.data.Repository; +import com.vmware.geode.tools.pulse.internal.util.StringUtils; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; + +/** + * Class SystemAlertsService + * + * This class contains implementations of getting system's alerts details (like + * errors, warnings and severe errors). + * + * @since GemFire version 7.5 + */ + +@Component +@Service("SystemAlerts") +@Scope("singleton") +public class SystemAlertsService implements PulseService { + + private static final ObjectMapper mapper = new ObjectMapper(); + + public ObjectNode execute(final HttpServletRequest request) throws Exception { + + // get cluster object + Cluster cluster = Repository.get().getCluster(); + + // json object to be sent as response + ObjectNode responseJSON = mapper.createObjectNode(); + + JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData")); + int pageNumber = 1; // Default + String strPageNumber = requestDataJSON.get("SystemAlerts").get("pageNumber").textValue(); + if (StringUtils.isNotNullNotEmptyNotWhiteSpace(strPageNumber)) { + try { + pageNumber = Integer.valueOf(strPageNumber); + } catch (NumberFormatException e) { + } + } + + // cluster's Members + responseJSON.put("systemAlerts", getAlertsJson(cluster, pageNumber)); + responseJSON.put("pageNumber", cluster.getNotificationPageNumber()); + responseJSON.put("connectedFlag", cluster.isConnectedFlag()); + responseJSON.put("connectedErrorMsg", cluster.getConnectionErrorMsg()); + + // Send json response + return responseJSON; + } + + /** + * function used for getting all members details in format of JSON Object + * array defined under a cluster + * + * @param cluster + * @return JSONObject Array list + */ + public static ObjectNode getAlertsJson(Cluster cluster, int pageNumber) { + // getting list of all types of alerts + Cluster.Alert[] alertsList = cluster.getAlertsList(); + + // create alerts json + ObjectNode alertsJsonObject = mapper.createObjectNode(); + + if ((alertsList != null) && (alertsList.length > 0)) { + ArrayNode errorJsonArray = mapper.createArrayNode(); + ArrayNode severeJsonArray = mapper.createArrayNode(); + ArrayNode warningJsonArray = mapper.createArrayNode(); + ArrayNode infoJsonArray = mapper.createArrayNode(); + + cluster.setNotificationPageNumber(pageNumber); + for (Cluster.Alert alert : alertsList) { + ObjectNode objAlertJson = mapper.createObjectNode(); + objAlertJson.put("description", alert.getDescription()); + objAlertJson.put("memberName", alert.getMemberName()); + objAlertJson.put("severity", alert.getSeverity()); + objAlertJson.put("isAcknowledged", alert.isAcknowledged()); + objAlertJson.put("timestamp", alert.getTimestamp().toString()); + objAlertJson.put("iso8601Ts", alert.getIso8601Ts()); + objAlertJson.put("id", alert.getId()); + + if (alert.getSeverity() == Cluster.Alert.SEVERE) { + severeJsonArray.add(objAlertJson); + } else if (alert.getSeverity() == Cluster.Alert.ERROR) { + errorJsonArray.add(objAlertJson); + } else if (alert.getSeverity() == Cluster.Alert.WARNING) { + warningJsonArray.add(objAlertJson); + } else { + infoJsonArray.add(objAlertJson); + } + } + alertsJsonObject.put("info", infoJsonArray); + alertsJsonObject.put("warnings", warningJsonArray); + alertsJsonObject.put("errors", errorJsonArray); + alertsJsonObject.put("severe", severeJsonArray); + } + return alertsJsonObject; + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/ConnectionUtil.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/ConnectionUtil.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/ConnectionUtil.java new file mode 100644 index 0000000..9bbed8a --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/ConnectionUtil.java @@ -0,0 +1,46 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package com.vmware.geode.tools.pulse.internal.util; + +import java.io.IOException; + +import javax.net.SocketFactory; +import javax.net.ssl.SSLSocketFactory; + + +/** + * + * + */ +public class ConnectionUtil { + + + + public static SocketFactory getSocketFactory(boolean usessl) + throws IOException + { + if(usessl){ + return (SSLSocketFactory)SSLSocketFactory.getDefault(); + }else{ + return SocketFactory.getDefault(); + } + } + + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/IPAddressUtil.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/IPAddressUtil.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/IPAddressUtil.java new file mode 100644 index 0000000..8cb6036 --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/IPAddressUtil.java @@ -0,0 +1,65 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.vmware.geode.tools.pulse.internal.util; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.regex.PatternSyntaxException; + +/* [ NOTE: + * This class supposed to be removed, if required, after discussing with + * VMware team ] + */ +/** + * Class IPAddressUtil This is utility class for checking whether ip address is + * versions i.e. IPv4 or IPv6 address + * + * + * @since GemFire version 7.0.1 + */ +public class IPAddressUtil { + + private static Pattern VALID_IPV4_PATTERN = null; + private static Pattern VALID_IPV6_PATTERN = null; + private static final String ipv4Pattern = "(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])"; + private static final String ipv6Pattern = "([0-9a-f]{1,4}:){7}([0-9a-f]){1,4}"; + + static { + try { + VALID_IPV4_PATTERN = Pattern.compile(ipv4Pattern, + Pattern.CASE_INSENSITIVE); + VALID_IPV6_PATTERN = Pattern.compile(ipv6Pattern, + Pattern.CASE_INSENSITIVE); + } catch (PatternSyntaxException e) { + + } + } + + public static Boolean isIPv4LiteralAddress(String IPAddress) { + Matcher matcher = IPAddressUtil.VALID_IPV4_PATTERN.matcher(IPAddress); + return matcher.matches(); + } + + public static Boolean isIPv6LiteralAddress(String IPAddress) { + + Matcher matcher = IPAddressUtil.VALID_IPV6_PATTERN.matcher(IPAddress); + return matcher.matches(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/StringUtils.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/StringUtils.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/StringUtils.java new file mode 100644 index 0000000..64f2731 --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/StringUtils.java @@ -0,0 +1,85 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.vmware.geode.tools.pulse.internal.util; + +/** + * Class StringUtils This is utility class for string. + * + * + * @since GemFire version 7.0.1 + */ +public class StringUtils { + /** + * Checks the string if it is not null, not empty, and not white space only + * using standard Java classes. + * + * @param string + * String to be checked. + * @return {@code true} if provided String is not null, is not empty, and has + * at least one character that is not considered white space. + */ + public static boolean isNotNullNotEmptyNotWhiteSpace(final String string) { + return string != null && !string.isEmpty() && !string.trim().isEmpty(); + } + + /** + * Checking for String that is not null, not empty, and not white space only + * using standard Java classes. + * + * @param value + * String to be made compliant. + * @return string compliant string. + */ + public static String makeCompliantName(String value) { + value = value.replace(':', '-'); + value = value.replace(',', '-'); + value = value.replace('=', '-'); + value = value.replace('*', '-'); + value = value.replace('?', '-'); + if (value.length() < 1) { + value = "nothing"; + } + return value; + } + + /** + * Function to get table name derived from region name/full path + * + * @param regionName + * String to be made compliant. + * @return string compliant string. + */ + public static String getTableNameFromRegionName(String regionName) { + String tableName = regionName.replaceFirst("/", "").replace('/', '.'); + return tableName; + } + + /** + * Function to get region name/full path derived from table name + * + * @param tableName + * String to be made compliant. + * @return string compliant string. + */ + public static String getRegionNameFromTableName(String tableName) { + String regionName = "/" + tableName.replace('.', '/'); + return regionName; + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/TimeUtils.java ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/TimeUtils.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/TimeUtils.java new file mode 100644 index 0000000..21f9116 --- /dev/null +++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/util/TimeUtils.java @@ -0,0 +1,120 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.vmware.geode.tools.pulse.internal.util; + +/** + * Class TimeUtils + * + * This is utility class used for conversions of time. + * + * + * @since GemFire version 7.0.1 + */ +public class TimeUtils { + + /** + * Method to converts time given in milliseconds to string representation in + * days, hours, minutes and seconds + * + * @param longMilliSecs + * Time in milliseconds. + * @return String + */ + public static String convertTimeMillisecondsToHMS(long longMilliSecs) { + + long days = longMilliSecs / (1000 * 60 * 60 * 24); + long remainder = longMilliSecs % (1000 * 60 * 60 * 24); + + long hours = remainder / (1000 * 60 * 60); + remainder = remainder % (1000 * 60 * 60); + + long mins = remainder / (1000 * 60); + remainder = remainder % (1000 * 60); + + long secs = remainder / 1000; + + String strDaysHrsMinsSecs = ""; + + if (days > 0) { + strDaysHrsMinsSecs += days + " Days "; + } + + if (hours > 0) { + strDaysHrsMinsSecs += hours + " Hours "; + } else { + strDaysHrsMinsSecs += "0 Hours "; + } + + if (mins > 0) { + strDaysHrsMinsSecs += mins + " Mins "; + } else { + strDaysHrsMinsSecs += "0 Mins "; + } + + strDaysHrsMinsSecs += secs + " Secs"; + + return strDaysHrsMinsSecs; + } + + /** + * Method to converts time given in seconds to string representation in days, + * hours, minutes and seconds + * + * @param longSecs + * Time in seconds. + * @return String + */ + public static String convertTimeSecondsToHMS(long longSecs) { + + long days = longSecs / (60 * 60 * 24); + long remainder = longSecs % (60 * 60 * 24); + + long hours = remainder / (60 * 60); + remainder = remainder % (60 * 60); + + long mins = remainder / (60); + remainder = remainder % (60); + + long secs = remainder; + + String strDaysHrsMinsSecs = ""; + + if (days > 0) { + strDaysHrsMinsSecs += days + " Days "; + } + + if (hours > 0) { + strDaysHrsMinsSecs += hours + " Hours "; + } else { + strDaysHrsMinsSecs += "0 Hours "; + } + + if (mins > 0) { + strDaysHrsMinsSecs += mins + " Mins "; + } else { + strDaysHrsMinsSecs += "0 Mins "; + } + + strDaysHrsMinsSecs += secs + " Secs"; + + return strDaysHrsMinsSecs; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml b/geode-pulse/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml index 60edb18..cb7181d 100644 --- a/geode-pulse/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml +++ b/geode-pulse/src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml @@ -28,7 +28,7 @@ http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> - <context:component-scan base-package="com.vmware.gemfire.tools.pulse.internal" /> + <context:component-scan base-package="org.apache.geode.tools.pulse.internal" /> <mvc:annotation-driven /> http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml b/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml index b14d03d..3756df7 100644 --- a/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml +++ b/geode-pulse/src/main/webapp/WEB-INF/spring-security.xml @@ -56,7 +56,7 @@ </http> <beans:bean name="customLogoutSuccessHandler" - class="com.vmware.gemfire.tools.pulse.internal.security.LogoutHandler"> + class="org.apache.geode.tools.pulse.internal.security.LogoutHandler"> <beans:constructor-arg value="/Login.html"/> </beans:bean> @@ -73,7 +73,7 @@ </beans:bean> <beans:bean id="gemAuthenticationProvider" - class="com.vmware.gemfire.tools.pulse.internal.security.GemFireAuthenticationProvider"> + class="org.apache.geode.tools.pulse.internal.security.GemFireAuthenticationProvider"> </beans:bean> http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/webapp/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/geode-pulse/src/main/webapp/WEB-INF/web.xml b/geode-pulse/src/main/webapp/WEB-INF/web.xml index bd02158..ff8b101 100644 --- a/geode-pulse/src/main/webapp/WEB-INF/web.xml +++ b/geode-pulse/src/main/webapp/WEB-INF/web.xml @@ -57,6 +57,6 @@ <url-pattern>/*</url-pattern> </filter-mapping> <listener> - <listener-class>com.vmware.gemfire.tools.pulse.internal.PulseAppListener</listener-class> + <listener-class>org.apache.geode.tools.pulse.internal.PulseAppListener</listener-class> </listener> </web-app> \ No newline at end of file
