You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/03/01 13:16:08 UTC

[GitHub] WillemJiang closed pull request #564: [SCB-361] fix warning in EventBus and MonitorManager and delete metrics-extension module

WillemJiang closed pull request #564: [SCB-361] fix warning in EventBus and MonitorManager and delete metrics-extension module
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/564
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/event/EventBus.java b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/event/EventBus.java
index df0a52b3f..849089a89 100644
--- a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/event/EventBus.java
+++ b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/event/EventBus.java
@@ -30,6 +30,8 @@
 public class EventBus {
   private static final Logger LOGGER = LoggerFactory.getLogger(EventBus.class);
 
+  //key is event object type,fast locate listener and fire
+  @SuppressWarnings("rawtypes")
   private final Map<Class, List<EventListener>> allEventListeners = new ConcurrentHashMapEx<>();
 
   private static final EventBus INSTANCE = new EventBus();
@@ -38,6 +40,8 @@ public static EventBus getInstance() {
     return INSTANCE;
   }
 
+  //event class will get from getEventClass method
+  @SuppressWarnings({"rawtypes"})
   private EventBus() {
     List<EventListener> listeners = SPIServiceUtils.getAllService(EventListener.class);
     for (EventListener listener : listeners) {
@@ -47,13 +51,17 @@ private EventBus() {
     }
   }
 
-  public <T> void registerEventListener(EventListener<T> eventListener) {
+  //event class will get from getEventClass method
+  @SuppressWarnings("rawtypes")
+  public void registerEventListener(EventListener eventListener) {
     List<EventListener> eventListeners = allEventListeners
         .computeIfAbsent(eventListener.getEventClass(), f -> new CopyOnWriteArrayList<>());
     eventListeners.add(eventListener);
   }
 
-  public <T> void unregisterEventListener(EventListener<T> eventListener) {
+  //event class will get from getEventClass method
+  @SuppressWarnings("rawtypes")
+  public void unregisterEventListener(EventListener eventListener) {
     List<EventListener> eventListeners = allEventListeners
         .computeIfAbsent(eventListener.getEventClass(), f -> new CopyOnWriteArrayList<>());
     if (eventListeners.contains(eventListener)) {
@@ -61,7 +69,8 @@ private EventBus() {
     }
   }
 
-  public <T> void triggerEvent(T event) {
+  @SuppressWarnings({"rawtypes", "unchecked"})
+  public void triggerEvent(Object event) {
     List<EventListener> eventListeners = allEventListeners.getOrDefault(event.getClass(), Collections.emptyList());
     for (EventListener eventListener : eventListeners) {
       eventListener.process(event);
diff --git a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/event/TestEventBus.java b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/event/TestEventBus.java
index 66a887232..77264adea 100644
--- a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/event/TestEventBus.java
+++ b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/event/TestEventBus.java
@@ -78,7 +78,7 @@ public void checkUnmatchTypeWillNotReceived() {
     EventBus.getInstance().registerEventListener(listener);
 
     //trigger a Integer type event object
-    EventBus.getInstance().triggerEvent(new Integer(1));
+    EventBus.getInstance().triggerEvent(1);
     Assert.assertFalse(eventReceived.get());
   }
 }
diff --git a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/MonitorManager.java b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/MonitorManager.java
index 110555fd9..be71b62ec 100644
--- a/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/MonitorManager.java
+++ b/metrics/metrics-core/src/main/java/org/apache/servicecomb/metrics/core/MonitorManager.java
@@ -54,7 +54,7 @@
 
   private final Map<String, MaxGauge> maxGauges;
 
-  private final Map<String, Gauge> gauges;
+  private final Map<String, Gauge<?>> gauges;
 
   private final Map<String, Timer> timers;
 
@@ -110,10 +110,10 @@ public MaxGauge getMaxGauge(String name, String... tags) {
     });
   }
 
-  public <V extends Number> Gauge getGauge(Callable<V> callable, String name, String... tags) {
+  public <V extends Number> Gauge<?> getGauge(Callable<V> callable, String name, String... tags) {
     validateMonitorNameAndTags(name, tags);
     return gauges.computeIfAbsent(getMonitorKey(name, tags), f -> {
-      Gauge gauge = new BasicGauge<>(getConfig(name, tags), callable);
+      Gauge<?> gauge = new BasicGauge<>(getConfig(name, tags), callable);
       basicMonitorRegistry.register(gauge);
       return gauge;
     });
@@ -130,7 +130,7 @@ public Timer getTimer(String name, String... tags) {
 
   public Map<String, Double> measure() {
     Map<String, Double> measurements = new HashMap<>();
-    for (Monitor monitor : basicMonitorRegistry.getRegisteredMonitors()) {
+    for (Monitor<?> monitor : basicMonitorRegistry.getRegisteredMonitors()) {
       measurements.put(getMonitorKey(monitor.getConfig()),
           ((Number) monitor.getValue(0)).doubleValue());
     }
diff --git a/metrics/metrics-extension/pom.xml b/metrics/metrics-extension/pom.xml
deleted file mode 100644
index 456126e52..000000000
--- a/metrics/metrics-extension/pom.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~     http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <parent>
-    <artifactId>metrics</artifactId>
-    <groupId>org.apache.servicecomb</groupId>
-    <version>1.0.0-m1-SNAPSHOT</version>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
-
-  <artifactId>metrics-extension</artifactId>
-  <name>Java Chassis::Metrics::Extension</name>
-  <packaging>pom</packaging>
-
-</project>
\ No newline at end of file
diff --git a/metrics/metrics-integration/metrics-prometheus/pom.xml b/metrics/metrics-integration/metrics-prometheus/pom.xml
index d54ba796f..2f4077686 100644
--- a/metrics/metrics-integration/metrics-prometheus/pom.xml
+++ b/metrics/metrics-integration/metrics-prometheus/pom.xml
@@ -27,7 +27,7 @@
   <modelVersion>4.0.0</modelVersion>
 
   <artifactId>metrics-prometheus</artifactId>
-  <name>Java Chassis::Metrics::Prometheus Integration</name>
+  <name>Java Chassis::Metrics::Integration::Prometheus</name>
 
   <dependencies>
     <dependency>
diff --git a/metrics/pom.xml b/metrics/pom.xml
index 9645c0c52..26bd52d05 100644
--- a/metrics/pom.xml
+++ b/metrics/pom.xml
@@ -33,7 +33,6 @@
 
   <modules>
     <module>metrics-core</module>
-    <module>metrics-extension</module>
     <module>metrics-integration</module>
   </modules>
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services