You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by hi...@apache.org on 2016/09/20 22:34:40 UTC
[23/35] incubator-geode git commit: GEODE-37 renamed pulse package to
geode
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberGatewayHubService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberGatewayHubService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberGatewayHubService.java
deleted file mode 100644
index dd84b75..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberGatewayHubService.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Class MemberGatewayHubService
- *
- * This class contains implementations of getting Gateway Receivers and Senders
- * details of Cluster Member.
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("MemberGatewayHub")
-@Scope("singleton")
-public class MemberGatewayHubService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- String memberName = requestDataJSON.get("MemberGatewayHub").get("memberName").textValue();
-
- Cluster.Member clusterMember = cluster.getMember(StringUtils
- .makeCompliantName(memberName));
-
- if (clusterMember != null) {
- // response
- // get gateway receiver
- Cluster.GatewayReceiver gatewayReceiver = clusterMember.getGatewayReceiver();
-
- Boolean isGateway = false;
-
- if (gatewayReceiver != null) {
- responseJSON.put("isGatewayReceiver", true);
- responseJSON.put("listeningPort", gatewayReceiver.getListeningPort());
- responseJSON.put("linkTroughput", gatewayReceiver.getLinkThroughput());
- responseJSON.put("avgBatchLatency", gatewayReceiver.getAvgBatchProcessingTime());
- } else {
- responseJSON.put("isGatewayReceiver", false);
- }
-
- // get gateway senders
- Cluster.GatewaySender[] gatewaySenders = clusterMember.getMemberGatewaySenders();
-
- if (gatewaySenders.length > 0) {
- isGateway = true;
- }
- responseJSON.put("isGatewaySender", isGateway);
- // Senders
- ArrayNode gatewaySendersJsonList = mapper.createArrayNode();
-
- for (Cluster.GatewaySender gatewaySender : gatewaySenders) {
- ObjectNode gatewaySenderJSON = mapper.createObjectNode();
- gatewaySenderJSON.put("id", gatewaySender.getId());
- gatewaySenderJSON.put("queueSize", gatewaySender.getQueueSize());
- gatewaySenderJSON.put("status", gatewaySender.getStatus());
- gatewaySenderJSON.put("primary", gatewaySender.getPrimary());
- gatewaySenderJSON.put("senderType", gatewaySender.getSenderType());
- gatewaySenderJSON.put("batchSize", gatewaySender.getBatchSize());
- gatewaySenderJSON.put("PersistenceEnabled", gatewaySender.getPersistenceEnabled());
- gatewaySenderJSON.put("remoteDSId", gatewaySender.getRemoteDSId());
- gatewaySenderJSON.put("eventsExceedingAlertThreshold", gatewaySender.getEventsExceedingAlertThreshold());
-
- gatewaySendersJsonList.add(gatewaySenderJSON);
- }
- // senders response
- responseJSON.put("gatewaySenders", gatewaySendersJsonList);
-
- // async event queues
- Cluster.AsyncEventQueue[] asyncEventQueues = clusterMember.getMemberAsyncEventQueueList();
- ArrayNode asyncEventQueueJsonList = mapper.createArrayNode();
-
- for (Cluster.AsyncEventQueue asyncEventQueue : asyncEventQueues) {
- ObjectNode asyncEventQueueJSON = mapper.createObjectNode();
- asyncEventQueueJSON.put("id", asyncEventQueue.getId());
- asyncEventQueueJSON.put("primary", asyncEventQueue.getPrimary());
- asyncEventQueueJSON.put("senderType", asyncEventQueue.isParallel());
- asyncEventQueueJSON.put("batchSize", asyncEventQueue.getBatchSize());
- asyncEventQueueJSON.put("batchTimeInterval", asyncEventQueue.getBatchTimeInterval());
- asyncEventQueueJSON.put("batchConflationEnabled", asyncEventQueue.isBatchConflationEnabled());
- asyncEventQueueJSON.put("asyncEventListener", asyncEventQueue.getAsyncEventListener());
- asyncEventQueueJSON.put("queueSize", asyncEventQueue.getEventQueueSize());
-
- asyncEventQueueJsonList.add(asyncEventQueueJSON);
- }
- responseJSON.put("asyncEventQueues", asyncEventQueueJsonList);
-
- Map<String,Cluster.Region> clusterRegions = cluster.getClusterRegions();
-
- List<Cluster.Region> clusterRegionsList = new ArrayList<Cluster.Region>();
- clusterRegionsList.addAll(clusterRegions.values());
-
- ArrayNode regionsList = mapper.createArrayNode();
-
- for (Cluster.Region region : clusterRegionsList) {
- if (region.getWanEnabled()) {
- ObjectNode regionJSON = mapper.createObjectNode();
- regionJSON.put("name", region.getName());
- regionsList.add(regionJSON);
- }
- }
- responseJSON.put("regionsInvolved", regionsList);
- }
-
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberHeapUsageService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberHeapUsageService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberHeapUsageService.java
deleted file mode 100644
index 3a64161..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberHeapUsageService.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class MemberHeapUsageService
- *
- * This class contains implementations of getting Memeber's current Heap Usage
- * and its trend over the time.
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("MemberHeapUsage")
-@Scope("singleton")
-public class MemberHeapUsageService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // members list
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- String memberName = requestDataJSON.get("MemberHeapUsage").get("memberName").textValue();
-
- Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
-
- if (clusterMember != null) {
- // response
- responseJSON.put("heapUsageTrend",
- mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_HEAP_USAGE_SAMPLE)));
- responseJSON.put("currentHeapUsage", clusterMember.getCurrentHeapSize());
- }
-
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberKeyStatisticsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberKeyStatisticsService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberKeyStatisticsService.java
deleted file mode 100644
index de69ca0..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberKeyStatisticsService.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class MemberKeyStatisticsService
- *
- * This class contains implementations of getting Member's CPU, Memory and Read
- * Write details
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("MemberKeyStatistics")
-@Scope("singleton")
-public class MemberKeyStatisticsService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- String memberName = requestDataJSON.get("MemberKeyStatistics").get("memberName").textValue();
-
- Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
-
- if (clusterMember != null) {
- // response
- responseJSON.put("cpuUsageTrend",
- mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_CPU_USAGE_SAMPLE)));
- responseJSON.put("memoryUsageTrend",
- mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_HEAP_USAGE_SAMPLE)));
- responseJSON.put("readPerSecTrend",
- mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_GETS_PER_SECOND)));
- responseJSON.put("writePerSecTrend",
- mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_PUTS_PER_SECOND)));
- }
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberRegionsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberRegionsService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberRegionsService.java
deleted file mode 100644
index a1000df..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MemberRegionsService.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-import java.text.DecimalFormat;
-
-/**
- * Class MemberRegionsService
- *
- * This class contains implementations of getting Memeber's Regions details.
- *
- * @since GemFire version 7.5
- */
-
-@Component
-@Service("MemberRegions")
-@Scope("singleton")
-public class MemberRegionsService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- // String constants used for forming a json response
- private final String NAME = "name";
- private final String ENTRY_SIZE = "entrySize";
- private final String DISC_STORE_NAME = "diskStoreName";
- private final String DISC_SYNCHRONOUS = "diskSynchronous";
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- String memberName = requestDataJSON.get("MemberRegions").get("memberName").textValue();
-
- Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName));
-
- if (clusterMember != null) {
- responseJSON.put("memberId", clusterMember.getId());
- responseJSON.put(this.NAME, clusterMember.getName());
- responseJSON.put("host", clusterMember.getHost());
-
- // member's regions
- Cluster.Region[] memberRegions = clusterMember.getMemberRegionsList();
- ArrayNode regionsListJson = mapper.createArrayNode();
- for (Cluster.Region memberRegion : memberRegions) {
- ObjectNode regionJSON = mapper.createObjectNode();
- regionJSON.put(this.NAME, memberRegion.getName());
-
- if (PulseConstants.PRODUCT_NAME_SQLFIRE.equalsIgnoreCase(PulseController.getPulseProductSupport())) {
- // Convert region path to dot separated region path
- regionJSON.put("fullPath", StringUtils.getTableNameFromRegionName(memberRegion.getFullPath()));
- } else {
- regionJSON.put("fullPath", memberRegion.getFullPath());
- }
-
- regionJSON.put("type", memberRegion.getRegionType());
- regionJSON.put("entryCount", memberRegion.getSystemRegionEntryCount());
- Long entrySize = memberRegion.getEntrySize();
-
- DecimalFormat form = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN_2);
- String entrySizeInMB = form.format(entrySize / (1024f * 1024f));
-
- if (entrySize < 0) {
- regionJSON.put(this.ENTRY_SIZE, this.VALUE_NA);
- } else {
- regionJSON.put(this.ENTRY_SIZE, entrySizeInMB);
- }
- regionJSON.put("scope", memberRegion.getScope());
- String diskStoreName = memberRegion.getDiskStoreName();
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(diskStoreName)) {
- regionJSON.put(this.DISC_STORE_NAME, diskStoreName);
- regionJSON.put(this.DISC_SYNCHRONOUS,
- memberRegion.isDiskSynchronous());
- } else {
- regionJSON.put(this.DISC_SYNCHRONOUS, this.VALUE_NA);
- regionJSON.put(this.DISC_STORE_NAME, "");
- }
- regionJSON.put("gatewayEnabled", memberRegion.getWanEnabled());
-
- regionsListJson.add(regionJSON);
- }
- responseJSON.put("memberRegions", regionsListJson);
-
- // response
- responseJSON.put("status", "Normal");
-
- }
-
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MembersListService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MembersListService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MembersListService.java
deleted file mode 100644
index c89f3d0..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/MembersListService.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class MembersListService
- *
- * This class contains implementations of getting list of Cluster Members.
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("MembersList")
-@Scope("singleton")
-public class MembersListService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // members list
- ArrayNode memberListJson = mapper.createArrayNode();
- Cluster.Member[] memberSet = cluster.getMembers();
-
- for (Cluster.Member member : memberSet) {
- ObjectNode memberJSON = mapper.createObjectNode();
- memberJSON.put("memberId", member.getId());
- memberJSON.put("name", member.getName());
- memberJSON.put("host", member.getHost());
-
- memberListJson.add(memberJSON);
- }
-
- // Response JSON
- responseJSON.put("clusterMembers", memberListJson);
- responseJSON.put("clusterName", cluster.getServerName());
-
- // Send json response
- return responseJSON;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseService.java
deleted file mode 100644
index 9fbfa1b..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseService.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import javax.servlet.http.HttpServletRequest;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Abstract class PulseService
- *
- * This is a base class for all services in pulse.
- *
- * @since GemFire version 7.5
- */
-public interface PulseService {
-
- String VALUE_NA = "NA";
- String VALUE_ON = "ON";
- String VALUE_OFF = "OFF";
-
- ObjectNode execute(HttpServletRequest httpServletRequest) throws Exception;
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseServiceFactory.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseServiceFactory.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseServiceFactory.java
deleted file mode 100644
index 48a1cc0..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseServiceFactory.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-/**
- * Class PulseServiceFactory
- *
- * @since GemFire version 7.5
- */
-@Component
-@Scope("singleton")
-public class PulseServiceFactory implements ApplicationContextAware {
-
- static final long serialVersionUID = 02L;
- ApplicationContext applicationContext = null;
-
- public PulseService getPulseServiceInstance(final String servicename) {
-
- if (applicationContext != null
- && applicationContext.containsBean(servicename)) {
- return (PulseService) applicationContext.getBean(servicename);
- }
- return null;
- }
-
- @Override
- public void setApplicationContext(final ApplicationContext applicationContext)
- throws BeansException {
-
- this.applicationContext = applicationContext;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseVersionService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseVersionService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseVersionService.java
deleted file mode 100644
index a04b9bb..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/PulseVersionService.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class PulseVersionService
- *
- * This class contains implementations of getting Pulse Applications Version's
- * details (like version details, build details, source details, etc) from
- * properties file
- *
- * @since GemFire version 7.0.Beta
- */
-
-@Component
-@Service("PulseVersion")
-@Scope("singleton")
-public class PulseVersionService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- // Response
- responseJSON.put("pulseVersion", PulseController.pulseVersion.getPulseVersion());
- responseJSON.put("buildId", PulseController.pulseVersion.getPulseBuildId());
- responseJSON.put("buildDate", PulseController.pulseVersion.getPulseBuildDate());
- responseJSON.put("sourceDate", PulseController.pulseVersion.getPulseSourceDate());
- responseJSON.put("sourceRevision", PulseController.pulseVersion.getPulseSourceRevision());
- responseJSON.put("sourceRepository", PulseController.pulseVersion.getPulseSourceRepository());
-
- // Send json response
- return responseJSON;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/QueryStatisticsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/QueryStatisticsService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/QueryStatisticsService.java
deleted file mode 100644
index 699e9be..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/QueryStatisticsService.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import javax.servlet.http.HttpServletRequest;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.PulseConstants;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-
-/**
- * Class QueryStatisticsService
- *
- * This class returns top N queries based on pagination and filtering criteria
- * if any
- *
- * @since GemFire version 7.5
- */
-@Component
-@Service("QueryStatistics")
-@Scope("singleton")
-public class QueryStatisticsService implements PulseService {
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- @Override
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- Cluster.Statement[] stmts = cluster.getStatements();
-
- ArrayNode queryListJson = mapper.createArrayNode();
- for (int i = 0; i < stmts.length; ++i) {
- ObjectNode queryJSON = mapper.createObjectNode();
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QUERYDEFINITION, stmts[i].getQueryDefinition());
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESCOMPILED,
- mapper.valueToTree(stmts[i].getNumTimesCompiled() < 0 ? this.VALUE_NA : stmts[i].getNumTimesCompiled()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTION,
- mapper.valueToTree(stmts[i].getNumExecution() < 0 ? this.VALUE_NA : stmts[i].getNumExecution()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTIONSINPROGRESS,
- mapper.valueToTree(stmts[i].getNumExecutionsInProgress() < 0 ? this.VALUE_NA : stmts[i].getNumExecutionsInProgress()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESGLOBALINDEXLOOKUP,
- mapper.valueToTree(stmts[i].getNumTimesGlobalIndexLookup() < 0 ? this.VALUE_NA : stmts[i].getNumTimesGlobalIndexLookup()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMROWSMODIFIED,
- mapper.valueToTree(stmts[i].getNumRowsModified() < 0 ? this.VALUE_NA : stmts[i].getNumRowsModified()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_PARSETIME,
- mapper.valueToTree(stmts[i].getParseTime() < 0 ? this.VALUE_NA : stmts[i].getParseTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_BINDTIME,
- mapper.valueToTree(stmts[i].getBindTime() < 0 ? this.VALUE_NA : stmts[i].getBindTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_OPTIMIZETIME,
- mapper.valueToTree(stmts[i].getOptimizeTime() < 0 ? this.VALUE_NA : stmts[i].getOptimizeTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_ROUTINGINFOTIME,
- mapper.valueToTree(stmts[i].getRoutingInfoTime() < 0 ? this.VALUE_NA : stmts[i].getRoutingInfoTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_GENERATETIME,
- mapper.valueToTree(stmts[i].getGenerateTime() < 1 ? this.VALUE_NA : stmts[i].getGenerateTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_TOTALCOMPILATIONTIME,
- mapper.valueToTree(stmts[i].getTotalCompilationTime() < 0 ? this.VALUE_NA : stmts[i].getTotalCompilationTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_EXECUTIONTIME,
- mapper.valueToTree(stmts[i].getExecutionTime() < 0 ? this.VALUE_NA : stmts[i].getExecutionTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_PROJECTIONTIME,
- mapper.valueToTree(stmts[i].getProjectionTime() < 0 ? this.VALUE_NA : stmts[i].getProjectionTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_TOTALEXECUTIONTIME,
- mapper.valueToTree(stmts[i].getTotalExecutionTime() < 0 ? this.VALUE_NA : stmts[i].getTotalExecutionTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_ROWSMODIFICATIONTIME,
- mapper.valueToTree(stmts[i].getRowsModificationTime() < 0 ? this.VALUE_NA : stmts[i].getRowsModificationTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNNUMROWSSEEN,
- mapper.valueToTree(stmts[i].getqNNumRowsSeen() < 0 ? this.VALUE_NA : stmts[i].getqNNumRowsSeen()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNMSGSENDTIME,
- mapper.valueToTree(stmts[i].getqNMsgSendTime() < 0 ? this.VALUE_NA : stmts[i].getqNMsgSendTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNMSGSERTIME,
- mapper.valueToTree(stmts[i].getqNMsgSerTime() < 0 ? this.VALUE_NA : stmts[i].getqNMsgSerTime()));
- queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNRESPDESERTIME,
- mapper.valueToTree(stmts[i].getqNRespDeSerTime() < 0 ? this.VALUE_NA : stmts[i].getqNRespDeSerTime()));
- queryListJson.add(queryJSON);
- }
- responseJSON.put("queriesList", queryListJson);
-
- // return jmx status
- responseJSON.put("connectedFlag", cluster.isConnectedFlag());
- responseJSON.put("connectedErrorMsg", cluster.getConnectionErrorMsg());
-
- // Send json response
- return responseJSON;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/SystemAlertsService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/SystemAlertsService.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/SystemAlertsService.java
deleted file mode 100644
index d1c61c4..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/SystemAlertsService.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.service;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
-import com.vmware.gemfire.tools.pulse.internal.data.Repository;
-import com.vmware.gemfire.tools.pulse.internal.util.StringUtils;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Class SystemAlertsService
- *
- * This class contains implementations of getting system's alerts details (like
- * errors, warnings and severe errors).
- *
- * @since GemFire version 7.5
- */
-
-@Component
-@Service("SystemAlerts")
-@Scope("singleton")
-public class SystemAlertsService implements PulseService {
-
- private static final ObjectMapper mapper = new ObjectMapper();
-
- public ObjectNode execute(final HttpServletRequest request) throws Exception {
-
- // get cluster object
- Cluster cluster = Repository.get().getCluster();
-
- // json object to be sent as response
- ObjectNode responseJSON = mapper.createObjectNode();
-
- JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
- int pageNumber = 1; // Default
- String strPageNumber = requestDataJSON.get("SystemAlerts").get("pageNumber").textValue();
- if (StringUtils.isNotNullNotEmptyNotWhiteSpace(strPageNumber)) {
- try {
- pageNumber = Integer.valueOf(strPageNumber);
- } catch (NumberFormatException e) {
- }
- }
-
- // cluster's Members
- responseJSON.put("systemAlerts", getAlertsJson(cluster, pageNumber));
- responseJSON.put("pageNumber", cluster.getNotificationPageNumber());
- responseJSON.put("connectedFlag", cluster.isConnectedFlag());
- responseJSON.put("connectedErrorMsg", cluster.getConnectionErrorMsg());
-
- // Send json response
- return responseJSON;
- }
-
- /**
- * function used for getting all members details in format of JSON Object
- * array defined under a cluster
- *
- * @param cluster
- * @return JSONObject Array list
- */
- public static ObjectNode getAlertsJson(Cluster cluster, int pageNumber) {
- // getting list of all types of alerts
- Cluster.Alert[] alertsList = cluster.getAlertsList();
-
- // create alerts json
- ObjectNode alertsJsonObject = mapper.createObjectNode();
-
- if ((alertsList != null) && (alertsList.length > 0)) {
- ArrayNode errorJsonArray = mapper.createArrayNode();
- ArrayNode severeJsonArray = mapper.createArrayNode();
- ArrayNode warningJsonArray = mapper.createArrayNode();
- ArrayNode infoJsonArray = mapper.createArrayNode();
-
- cluster.setNotificationPageNumber(pageNumber);
- for (Cluster.Alert alert : alertsList) {
- ObjectNode objAlertJson = mapper.createObjectNode();
- objAlertJson.put("description", alert.getDescription());
- objAlertJson.put("memberName", alert.getMemberName());
- objAlertJson.put("severity", alert.getSeverity());
- objAlertJson.put("isAcknowledged", alert.isAcknowledged());
- objAlertJson.put("timestamp", alert.getTimestamp().toString());
- objAlertJson.put("iso8601Ts", alert.getIso8601Ts());
- objAlertJson.put("id", alert.getId());
-
- if (alert.getSeverity() == Cluster.Alert.SEVERE) {
- severeJsonArray.add(objAlertJson);
- } else if (alert.getSeverity() == Cluster.Alert.ERROR) {
- errorJsonArray.add(objAlertJson);
- } else if (alert.getSeverity() == Cluster.Alert.WARNING) {
- warningJsonArray.add(objAlertJson);
- } else {
- infoJsonArray.add(objAlertJson);
- }
- }
- alertsJsonObject.put("info", infoJsonArray);
- alertsJsonObject.put("warnings", warningJsonArray);
- alertsJsonObject.put("errors", errorJsonArray);
- alertsJsonObject.put("severe", severeJsonArray);
- }
- return alertsJsonObject;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/ConnectionUtil.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/ConnectionUtil.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/ConnectionUtil.java
deleted file mode 100644
index 99e62e2..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/ConnectionUtil.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package com.vmware.gemfire.tools.pulse.internal.util;
-
-import java.io.IOException;
-
-import javax.net.SocketFactory;
-import javax.net.ssl.SSLSocketFactory;
-
-
-/**
- *
- *
- */
-public class ConnectionUtil {
-
-
-
- public static SocketFactory getSocketFactory(boolean usessl)
- throws IOException
- {
- if(usessl){
- return (SSLSocketFactory)SSLSocketFactory.getDefault();
- }else{
- return SocketFactory.getDefault();
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/IPAddressUtil.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/IPAddressUtil.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/IPAddressUtil.java
deleted file mode 100644
index 1158251..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/IPAddressUtil.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.util;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-/* [ NOTE:
- * This class supposed to be removed, if required, after discussing with
- * VMware team ]
- */
-/**
- * Class IPAddressUtil This is utility class for checking whether ip address is
- * versions i.e. IPv4 or IPv6 address
- *
- *
- * @since GemFire version 7.0.1
- */
-public class IPAddressUtil {
-
- private static Pattern VALID_IPV4_PATTERN = null;
- private static Pattern VALID_IPV6_PATTERN = null;
- private static final String ipv4Pattern = "(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])";
- private static final String ipv6Pattern = "([0-9a-f]{1,4}:){7}([0-9a-f]){1,4}";
-
- static {
- try {
- VALID_IPV4_PATTERN = Pattern.compile(ipv4Pattern,
- Pattern.CASE_INSENSITIVE);
- VALID_IPV6_PATTERN = Pattern.compile(ipv6Pattern,
- Pattern.CASE_INSENSITIVE);
- } catch (PatternSyntaxException e) {
-
- }
- }
-
- public static Boolean isIPv4LiteralAddress(String IPAddress) {
- Matcher matcher = IPAddressUtil.VALID_IPV4_PATTERN.matcher(IPAddress);
- return matcher.matches();
- }
-
- public static Boolean isIPv6LiteralAddress(String IPAddress) {
-
- Matcher matcher = IPAddressUtil.VALID_IPV6_PATTERN.matcher(IPAddress);
- return matcher.matches();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/StringUtils.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/StringUtils.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/StringUtils.java
deleted file mode 100644
index 56cbf1b..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/StringUtils.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.util;
-
-/**
- * Class StringUtils This is utility class for string.
- *
- *
- * @since GemFire version 7.0.1
- */
-public class StringUtils {
- /**
- * Checks the string if it is not null, not empty, and not white space only
- * using standard Java classes.
- *
- * @param string
- * String to be checked.
- * @return {@code true} if provided String is not null, is not empty, and has
- * at least one character that is not considered white space.
- */
- public static boolean isNotNullNotEmptyNotWhiteSpace(final String string) {
- return string != null && !string.isEmpty() && !string.trim().isEmpty();
- }
-
- /**
- * Checking for String that is not null, not empty, and not white space only
- * using standard Java classes.
- *
- * @param value
- * String to be made compliant.
- * @return string compliant string.
- */
- public static String makeCompliantName(String value) {
- value = value.replace(':', '-');
- value = value.replace(',', '-');
- value = value.replace('=', '-');
- value = value.replace('*', '-');
- value = value.replace('?', '-');
- if (value.length() < 1) {
- value = "nothing";
- }
- return value;
- }
-
- /**
- * Function to get table name derived from region name/full path
- *
- * @param regionName
- * String to be made compliant.
- * @return string compliant string.
- */
- public static String getTableNameFromRegionName(String regionName) {
- String tableName = regionName.replaceFirst("/", "").replace('/', '.');
- return tableName;
- }
-
- /**
- * Function to get region name/full path derived from table name
- *
- * @param tableName
- * String to be made compliant.
- * @return string compliant string.
- */
- public static String getRegionNameFromTableName(String tableName) {
- String regionName = "/" + tableName.replace('.', '/');
- return regionName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/TimeUtils.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/TimeUtils.java b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/TimeUtils.java
deleted file mode 100644
index 73ce389..0000000
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/util/TimeUtils.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.vmware.gemfire.tools.pulse.internal.util;
-
-/**
- * Class TimeUtils
- *
- * This is utility class used for conversions of time.
- *
- *
- * @since GemFire version 7.0.1
- */
-public class TimeUtils {
-
- /**
- * Method to converts time given in milliseconds to string representation in
- * days, hours, minutes and seconds
- *
- * @param longMilliSecs
- * Time in milliseconds.
- * @return String
- */
- public static String convertTimeMillisecondsToHMS(long longMilliSecs) {
-
- long days = longMilliSecs / (1000 * 60 * 60 * 24);
- long remainder = longMilliSecs % (1000 * 60 * 60 * 24);
-
- long hours = remainder / (1000 * 60 * 60);
- remainder = remainder % (1000 * 60 * 60);
-
- long mins = remainder / (1000 * 60);
- remainder = remainder % (1000 * 60);
-
- long secs = remainder / 1000;
-
- String strDaysHrsMinsSecs = "";
-
- if (days > 0) {
- strDaysHrsMinsSecs += days + " Days ";
- }
-
- if (hours > 0) {
- strDaysHrsMinsSecs += hours + " Hours ";
- } else {
- strDaysHrsMinsSecs += "0 Hours ";
- }
-
- if (mins > 0) {
- strDaysHrsMinsSecs += mins + " Mins ";
- } else {
- strDaysHrsMinsSecs += "0 Mins ";
- }
-
- strDaysHrsMinsSecs += secs + " Secs";
-
- return strDaysHrsMinsSecs;
- }
-
- /**
- * Method to converts time given in seconds to string representation in days,
- * hours, minutes and seconds
- *
- * @param longSecs
- * Time in seconds.
- * @return String
- */
- public static String convertTimeSecondsToHMS(long longSecs) {
-
- long days = longSecs / (60 * 60 * 24);
- long remainder = longSecs % (60 * 60 * 24);
-
- long hours = remainder / (60 * 60);
- remainder = remainder % (60 * 60);
-
- long mins = remainder / (60);
- remainder = remainder % (60);
-
- long secs = remainder;
-
- String strDaysHrsMinsSecs = "";
-
- if (days > 0) {
- strDaysHrsMinsSecs += days + " Days ";
- }
-
- if (hours > 0) {
- strDaysHrsMinsSecs += hours + " Hours ";
- } else {
- strDaysHrsMinsSecs += "0 Hours ";
- }
-
- if (mins > 0) {
- strDaysHrsMinsSecs += mins + " Mins ";
- } else {
- strDaysHrsMinsSecs += "0 Mins ";
- }
-
- strDaysHrsMinsSecs += secs + " Secs";
-
- return strDaysHrsMinsSecs;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java
new file mode 100644
index 0000000..408eed3
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/PulseAppListener.java
@@ -0,0 +1,742 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal;
+
+import com.vmware.geode.tools.pulse.internal.controllers.PulseController;
+import com.vmware.geode.tools.pulse.internal.data.PulseConfig;
+import com.vmware.geode.tools.pulse.internal.data.PulseConstants;
+import com.vmware.geode.tools.pulse.internal.data.Repository;
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+import com.vmware.geode.tools.pulse.internal.util.StringUtils;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.logging.Level;
+
+/**
+ * This class is used for checking the application running mode i.e. Embedded or
+ * not
+ *
+ * @since GemFire version 7.0.Beta 2012-09-23
+ *
+ */
+// @WebListener
+public class PulseAppListener implements ServletContextListener {
+ private PulseLogWriter LOGGER;
+ private final ResourceBundle resourceBundle = Repository.get()
+ .getResourceBundle();
+
+ // String object to store all messages which needs to be logged into the log
+ // file before logger gets initialized
+ private String messagesToBeLogged = "";
+
+ private Properties pulseProperties;
+ private Properties pulseSecurityProperties;
+ private Boolean sysPulseUseLocator;
+ private String sysPulseHost;
+ private String sysPulsePort;
+ private String jmxUserName;
+ private String jmxUserPassword;
+
+ private boolean sysPulseUseSSLLocator;
+ private boolean sysPulseUseSSLManager;
+
+ //This property determines if pulse webApp login is authenticated against
+ //GemFire integrated security or custom spring-security config provided
+ //in pulse-authentication-custom.xml
+ private boolean useGemFireCredentials;
+
+ @Override
+ public void contextDestroyed(ServletContextEvent event) {
+
+ // Stop all running threads those are created in Pulse
+ // Stop cluster threads
+ Repository.get().removeAllClusters();
+
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_CONTEXT_DESTROYED")
+ + event.getServletContext().getContextPath());
+ }
+ }
+
+ @Override
+ public void contextInitialized(ServletContextEvent event) {
+
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_CONTEXT_INITIALIZED")));
+
+ // Load Pulse version details
+ loadPulseVersionDetails();
+
+ // Load Pulse Properties
+ pulseProperties = loadProperties(PulseConstants.PULSE_PROPERTIES_FILE);
+
+ if (pulseProperties.isEmpty()) {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_PROPERTIES_NOT_FOUND")));
+ } else {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_PROPERTIES_FOUND")));
+
+ // set Pulse product support into the Pulse controller for access from
+ // client side
+ // to display the appropriate ui depending on which product is supported
+ // in present deployment
+ String pulseProduct = pulseProperties.getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_PRODUCTSUPPORT);
+ // default is gemfire
+
+ if ((pulseProduct != null) && (pulseProduct.trim().equalsIgnoreCase(PulseConstants.PRODUCT_NAME_SQLFIRE))) {
+ PulseController.setPulseProductSupport(PulseConstants.PRODUCT_NAME_SQLFIRE);
+ }
+ }
+
+ pulseSecurityProperties = loadProperties(PulseConstants.PULSE_SECURITY_PROPERTIES_FILE);
+
+ // Initialize logger
+ initializeLogger();
+
+ // Reference to repository
+ Repository repository = Repository.get();
+
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_CHECK_APP_RUNNING_MODE"));
+ }
+
+ boolean sysIsEmbedded = Boolean
+ .getBoolean(PulseConstants.SYSTEM_PROPERTY_PULSE_EMBEDDED);
+
+ if (sysIsEmbedded) {
+ // Application Pulse is running in Embedded Mode
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_APP_RUNNING_EMBEDDED_MODE"));
+ }
+ repository.setIsEmbeddedMode(true);
+
+ sysPulseUseLocator = Boolean.FALSE;
+ try{
+ // Get host name of machine running pulse in embedded mode
+ sysPulseHost = InetAddress.getLocalHost().getCanonicalHostName();
+ } catch (UnknownHostException e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine(resourceBundle
+ .getString("LOG_MSG_JMX_CONNECTION_UNKNOWN_HOST")
+ + e.getMessage());
+ }
+ // Set default host name
+ sysPulseHost = PulseConstants.GEMFIRE_DEFAULT_HOST;
+ } catch (Exception e) {
+ if (LOGGER.fineEnabled()) {
+ LOGGER.fine(resourceBundle
+ .getString("LOG_MSG_JMX_CONNECTION_UNKNOWN_HOST")
+ + e.getMessage());
+ }
+ // Set default host name
+ sysPulseHost = PulseConstants.GEMFIRE_DEFAULT_HOST;
+ }
+ sysPulsePort = PulseConstants.GEMFIRE_DEFAULT_PORT;
+
+ boolean pulseEmbededSqlf = Boolean.getBoolean(PulseConstants.SYSTEM_PROPERTY_PULSE_EMBEDDED_SQLF);
+ if(pulseEmbededSqlf){
+ PulseController.setPulseProductSupport(PulseConstants.PRODUCT_NAME_SQLFIRE);
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_APP_RUNNING_EMBEDDED_SQLF_MODE"));
+ }
+ }
+
+ } else {
+ // Application Pulse is running in Non-Embedded Mode
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_APP_RUNNING_NONEMBEDDED_MODE"));
+ }
+ repository.setIsEmbeddedMode(false);
+
+ // Load JMX User Details
+ loadJMXUserDetails();
+ // Load locator and/or manager details
+ loadLocatorManagerDetails();
+
+ useGemFireCredentials = areWeUsingGemFireSecurityProfile(event);
+ }
+
+ // Set user details in repository
+ repository.setJmxUserName(jmxUserName);
+ repository.setJmxUserPassword(jmxUserPassword);
+
+ // Set locator/Manager details in repository
+ repository.setJmxUseLocator(sysPulseUseLocator);
+ repository.setJmxHost(sysPulseHost);
+ repository.setJmxPort(sysPulsePort);
+
+ //set SSL info
+ initializeSSL();
+ repository.setUseSSLLocator(sysPulseUseSSLLocator);
+ repository.setUseSSLManager(sysPulseUseSSLManager);
+
+ repository.setUseGemFireCredentials(useGemFireCredentials);
+
+ }
+
+ /**
+ * Return true if pulse is configure to authenticate using gemfire
+ * integrated security
+ *
+ * @param event
+ * @return
+ */
+ private boolean areWeUsingGemFireSecurityProfile(ServletContextEvent event) {
+ String profile = null;
+ WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
+ if (ctx.getEnvironment() != null) {
+ String[] profiles = ctx.getEnvironment().getActiveProfiles();
+ if (profiles != null && profiles.length > 0) {
+ StringBuilder sb = new StringBuilder();
+ for (String p : profiles)
+ sb.append(p).append(",");
+ LOGGER.info("#SpringProfilesConfigured : " + sb.toString());
+ profile = ctx.getEnvironment().getActiveProfiles()[0];
+ LOGGER.info("#First Profile : " + profile);
+ } else {
+ LOGGER.info("No SpringProfileConfigured using default spring profile");
+ return false;
+ }
+ }
+ if (PulseConstants.APPLICATION_PROPERTY_PULSE_SEC_PROFILE_GEMFIRE.equals(profile)) {
+ LOGGER.info("Using gemfire integrated security profile");
+ return true;
+ }
+ return false;
+ }
+
+ // Function to load pulse version details from properties file
+ private void loadPulseVersionDetails() {
+
+ // Read version details from version property file
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ InputStream inputStream = classLoader
+ .getResourceAsStream(PulseConstants.PULSE_VERSION_PROPERTIES_FILE);
+
+ if (inputStream != null) {
+ Properties properties = new Properties();
+ try {
+ properties.load(inputStream);
+ } catch (IOException e) {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_EXCEPTION_LOADING_PROPERTIES_FILE")));
+ } finally {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_EXCEPTION_CLOSING_INPUT_STREAM")));
+ }
+ }
+ // Set pulse version details in common object
+ PulseController.pulseVersion.setPulseVersion(properties.getProperty(
+ PulseConstants.PROPERTY_PULSE_VERSION, ""));
+ PulseController.pulseVersion.setPulseBuildId(properties.getProperty(
+ PulseConstants.PROPERTY_BUILD_ID, ""));
+ PulseController.pulseVersion.setPulseBuildDate(properties.getProperty(
+ PulseConstants.PROPERTY_BUILD_DATE, ""));
+ PulseController.pulseVersion.setPulseSourceDate(properties.getProperty(
+ PulseConstants.PROPERTY_SOURCE_DATE, ""));
+ PulseController.pulseVersion.setPulseSourceRevision(properties
+ .getProperty(PulseConstants.PROPERTY_SOURCE_REVISION, ""));
+ PulseController.pulseVersion.setPulseSourceRepository(properties
+ .getProperty(PulseConstants.PROPERTY_SOURCE_REPOSITORY, ""));
+ }
+
+ // Log Pulse Version details into log file
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(PulseController.pulseVersion
+ .getPulseVersionLogMessage()));
+ }
+
+ private void initializeLogger() {
+
+ // Override default log configuration by properties which are provided in
+ // properties file.
+ loadLogDetailsFromPropertyFile();
+
+ // Override log configuration by properties which are provided in
+ // through system properties.
+ loadLogDetailsFromSystemProperties();
+
+ // Initialize logger object
+ LOGGER = PulseLogWriter.getLogger();
+
+ // Log messages stored in messagesToBeLogged
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(messagesToBeLogged);
+ messagesToBeLogged = "";
+ }
+ }
+
+ // Function to load pulse properties from pulse.properties file
+ private Properties loadProperties(String propertyFile) {
+
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ InputStream inputStream = classLoader.getResourceAsStream(propertyFile);
+ Properties properties = new Properties();
+
+ if (inputStream != null) {
+ messagesToBeLogged = messagesToBeLogged.concat(formatLogString(propertyFile + " "
+ + resourceBundle.getString("LOG_MSG_FILE_FOUND")));
+
+ try {
+ // Load properties from input stream
+ properties.load(inputStream);
+ } catch (IOException e1) {
+ messagesToBeLogged = messagesToBeLogged.concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_EXCEPTION_LOADING_PROPERTIES_FILE")
+ + " " + propertyFile));
+ } finally {
+ // Close input stream
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ messagesToBeLogged = messagesToBeLogged.concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_EXCEPTION_CLOSING_INPUT_STREAM")
+ + " " + propertyFile));
+ }
+ }
+
+ } else {
+ messagesToBeLogged = messagesToBeLogged.concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_COULD_NOT_READ_FILE")
+ + " " + propertyFile));
+ }
+ return properties;
+ }
+
+ // Function to load Logging details from properties file
+ private void loadLogDetailsFromPropertyFile() {
+
+ // return, if Pulse Properties are not provided
+ if (pulseProperties.size() == 0) {
+ return;
+ }
+
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_CHECK_LOG_PROPERTIES_IN_FILE")));
+
+ HashMap<String, String> logPropertiesHM = new HashMap<String, String>();
+
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME, ""));
+
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION, ""));
+
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE, ""));
+
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT, ""));
+
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN, ""));
+
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL, ""));
+
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND,
+ pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND, ""));
+
+ if (logPropertiesHM.size() == 0) {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_LOG_PROPERTIES_NOT_FOUND_IN_FILE")));
+ } else {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_LOG_PROPERTIES_FOUND_IN_FILE")));
+ }
+
+ setLogConfigurations(logPropertiesHM);
+ }
+
+ // Function to load Logging details from system properties
+ private void loadLogDetailsFromSystemProperties() {
+
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_CHECK_LOG_PROPERTIES_IN_SYSTEM_PROPERTIES")));
+
+ HashMap<String, String> logPropertiesHM = new HashMap<String, String>();
+
+ String sysLogFileName = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME);
+ String sysLogFileLocation = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION);
+ String sysLogFileSize = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE);
+ String sysLogFileCount = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT);
+ String sysLogDatePattern = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN);
+ String sysLogLevel = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL);
+ String sysLogAppend = System
+ .getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND);
+
+ if (sysLogFileName == null || sysLogFileName.isEmpty()) {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME, "");
+ } else {
+ logPropertiesHM
+ .put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME,
+ sysLogFileName);
+ }
+
+ if (sysLogFileLocation == null || sysLogFileLocation.isEmpty()) {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION, "");
+ } else {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION,
+ sysLogFileLocation);
+ }
+
+ if (sysLogFileSize == null || sysLogFileSize.isEmpty()) {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE, "");
+ } else {
+ logPropertiesHM
+ .put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE,
+ sysLogFileSize);
+ }
+
+ if (sysLogFileCount == null || sysLogFileCount.isEmpty()) {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT, "");
+ } else {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT,
+ sysLogFileCount);
+ }
+
+ if (sysLogDatePattern == null || sysLogDatePattern.isEmpty()) {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN, "");
+ } else {
+ logPropertiesHM.put(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN,
+ sysLogDatePattern);
+ }
+
+ if (sysLogLevel == null || sysLogLevel.isEmpty()) {
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL,
+ "");
+ } else {
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL,
+ sysLogLevel);
+ }
+
+ if (sysLogAppend == null || sysLogAppend.isEmpty()) {
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND,
+ "");
+ } else {
+ logPropertiesHM.put(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND,
+ sysLogAppend);
+ }
+
+ if (logPropertiesHM.size() == 0) {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_LOG_PROPERTIES_NOT_FOUND_IN_SYSTEM_PROPERTIES")));
+ } else {
+ messagesToBeLogged = messagesToBeLogged
+ .concat(formatLogString(resourceBundle
+ .getString("LOG_MSG_LOG_PROPERTIES_FOUND_IN_SYSTEM_PROPERTIES")));
+ }
+
+ setLogConfigurations(logPropertiesHM);
+ }
+
+ private void setLogConfigurations(HashMap<String, String> logPropertiesHM) {
+
+ PulseConfig pulseConfig = Repository.get().getPulseConfig();
+
+ // log file name
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME))) {
+ pulseConfig.setLogFileName(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILENAME));
+ }
+
+ // log file location
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION))) {
+ pulseConfig.setLogFileLocation(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILELOCATION));
+ }
+
+ // log file size
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE))) {
+ pulseConfig.setLogFileSize(Integer.parseInt(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILESIZE)));
+ }
+
+ // log file count
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT))) {
+ pulseConfig.setLogFileCount(Integer.parseInt(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGFILECOUNT)));
+ }
+
+ // log message date pattern
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN))) {
+ pulseConfig.setLogDatePattern(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGDATEPATTERN));
+ }
+
+ // log level
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL))) {
+ pulseConfig.setLogLevel(Level.parse(logPropertiesHM.get(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_LOGLEVEL).toUpperCase()));
+ }
+
+ // log append
+ if (StringUtils.isNotNullNotEmptyNotWhiteSpace(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND))) {
+ pulseConfig.setLogAppend(Boolean.valueOf(logPropertiesHM
+ .get(PulseConstants.APPLICATION_PROPERTY_PULSE_LOGAPPEND)));
+ }
+
+ }
+
+ // Function to load JMX User details from properties
+ private void loadJMXUserDetails() {
+
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_GET_JMX_USER_DETAILS"));
+ }
+
+ if (pulseProperties.isEmpty()) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER
+ .info(resourceBundle
+ .getString("LOG_MSG_JMX_USER_DETAILS_NOT_FOUND")
+ + resourceBundle
+ .getString("LOG_MSG_REASON_USER_DETAILS_NOT_FOUND"));
+ }
+ } else {
+ jmxUserName = pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_JMXUSERNAME, "");
+ jmxUserPassword = pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_JMXPASSWORD, "");
+
+ if (jmxUserName.isEmpty() || jmxUserPassword.isEmpty()) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_JMX_USER_DETAILS_NOT_FOUND")
+ + resourceBundle
+ .getString("LOG_MSG_REASON_USER_DETAILS_NOT_FOUND"));
+ }
+ } else {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_JMX_USER_DETAILS_FOUND"));
+ }
+ }
+ }
+ }
+
+//Function to set SSL VM arguments
+ private void initializeSSL() {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_GET_SSL_DETAILS"));
+ }
+
+
+ this.sysPulseUseSSLLocator = Boolean.valueOf(pulseProperties.getProperty(
+ PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_LOCATOR, "false"));
+
+ this.sysPulseUseSSLManager = Boolean.valueOf(pulseProperties.getProperty(
+ PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_MANAGER, "false"));
+
+
+ if ((sysPulseUseSSLLocator || sysPulseUseSSLManager)) {
+ Properties sslProperties = new Properties();
+ if (!pulseSecurityProperties.isEmpty()) {
+ Set entrySet = pulseSecurityProperties.entrySet();
+ for (Iterator it = entrySet.iterator(); it.hasNext();) {
+ Entry<String, String> entry = (Entry<String, String>) it.next();
+ String key = entry.getKey();
+ if (key.startsWith("javax.net.ssl.")) {
+
+ String val = entry.getValue();
+ System.setProperty(key, val);
+ sslProperties.setProperty(key, val);
+ }
+ }
+ }
+ if (sslProperties.isEmpty()) {
+ if (LOGGER.warningEnabled()) {
+ LOGGER.warning(resourceBundle.getString("LOG_MSG_SSL_NOT_SET"));
+ }
+ }
+ }
+
+ }
+
+ // Function to load locator and/or manager details
+ private void loadLocatorManagerDetails() {
+
+ // Get locator details through System Properties
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_GET_LOCATOR_DETAILS_1"));
+ }
+
+ // Required System properties are
+ // -Dpulse.embedded="false" -Dpulse.useLocator="false"
+ // -Dpulse.host="192.168.2.11" -Dpulse.port="2099"
+ sysPulseUseLocator = Boolean
+ .getBoolean(PulseConstants.SYSTEM_PROPERTY_PULSE_USELOCATOR);
+ sysPulseHost = System
+ .getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_HOST);
+ sysPulsePort = System
+ .getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_PORT);
+
+ if (sysPulseHost == null || sysPulseHost.isEmpty() || sysPulsePort == null
+ || sysPulsePort.isEmpty()) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_LOCATOR_DETAILS_NOT_FOUND")
+ + resourceBundle
+ .getString("LOG_MSG_REASON_LOCATOR_DETAILS_NOT_FOUND_1"));
+ LOGGER.info(resourceBundle.getString("LOG_MSG_GET_LOCATOR_DETAILS_2"));
+ }
+
+ if (pulseProperties.isEmpty()) {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle
+ .getString("LOG_MSG_LOCATOR_DETAILS_NOT_FOUND")
+ + resourceBundle
+ .getString("LOG_MSG_REASON_LOCATOR_DETAILS_NOT_FOUND_2"));
+ }
+
+ sysPulseHost = "";
+ sysPulsePort = "";
+ } else {
+ if (LOGGER.infoEnabled()) {
+ LOGGER
+ .info(resourceBundle.getString("LOG_MSG_LOCATOR_DETAILS_FOUND"));
+ }
+
+ sysPulseUseLocator = Boolean.valueOf(pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_USELOCATOR, ""));
+ sysPulseHost = pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_HOST, "");
+ sysPulsePort = pulseProperties.getProperty(
+ PulseConstants.APPLICATION_PROPERTY_PULSE_PORT, "");
+ }
+ } else {
+ if (LOGGER.infoEnabled()) {
+ LOGGER.info(resourceBundle.getString("LOG_MSG_LOCATOR_DETAILS_FOUND"));
+ }
+ }
+ }
+
+ private String formatLogString(String logMessage) {
+
+ DateFormat df = new SimpleDateFormat(
+ PulseConstants.LOG_MESSAGE_DATE_PATTERN);
+ // DateFormat df = new
+ // SimpleDateFormat(Repository.get().getPulseConfig().getLogDatePattern());
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+
+ pw.println();
+ pw.print("[");
+ pw.print("INFO");
+ pw.print(" ");
+ pw.print(df.format(new Date(System.currentTimeMillis())));
+ String threadName = Thread.currentThread().getName();
+ if (threadName != null) {
+ pw.print(" ");
+ pw.print(threadName);
+ }
+ pw.print(" tid=0x");
+ pw.print(Long.toHexString(Thread.currentThread().getId()));
+ pw.print("] ");
+ pw.print("(msgTID=");
+ pw.print("");
+
+ pw.print(" msgSN=");
+ pw.print("");
+
+ pw.print(") ");
+
+ pw.println("[" + PulseConstants.APP_NAME + "]");
+
+ pw.println(PulseLogWriter.class.getName());
+
+ pw.println(logMessage);
+
+ pw.close();
+ try {
+ sw.close();
+ } catch (IOException ignore) {
+ }
+ String result = sw.toString();
+ return result;
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/9a2b5d7b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java
new file mode 100644
index 0000000..9e86637
--- /dev/null
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/controllers/ExceptionHandlingAdvice.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.vmware.geode.tools.pulse.internal.controllers;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+import com.vmware.geode.tools.pulse.internal.log.PulseLogWriter;
+
+/**
+ * For handling IO exception in our controllers
+ *
+ *
+ */
+@ControllerAdvice
+public class ExceptionHandlingAdvice {
+
+ @ExceptionHandler(IOException.class)
+ @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
+ public void handleExc(IOException ext) {
+ PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+ // write errors
+ StringWriter swBuffer = new StringWriter();
+ PrintWriter prtWriter = new PrintWriter(swBuffer);
+ ext.printStackTrace(prtWriter);
+ LOGGER.severe("IOException Details : " + swBuffer.toString() + "\n");
+ }
+}