summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml226
-rw-r--r--src/main/java/org/onap/msb/sdk/httpclient/ProxyRetrofitCall.java11
-rw-r--r--src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandler.java3
-rw-r--r--src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandlerContext.java11
-rw-r--r--src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandlerFactory.java7
-rw-r--r--src/main/java/org/onap/msb/sdk/httpclient/handler/impl/MetricmanagerBuilder.java39
-rw-r--r--src/main/java/org/onap/msb/sdk/httpclient/metric/MetricManager.java84
-rw-r--r--src/main/java/org/onap/msb/sdk/httpclient/metric/MetricObject.java38
-rw-r--r--src/test/java/org/onap/msb/sdk/httpclient/handler/ServiceBuilderTest.java8
9 files changed, 78 insertions, 349 deletions
diff --git a/pom.xml b/pom.xml
index 5e3fdb8..00206df 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,142 +1,59 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<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">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.oparent</groupId>
- <artifactId>oparent</artifactId>
- <version>0.1.1</version>
- </parent>
-
- <groupId>org.onap.msb.java-sdk</groupId>
- <artifactId>msb-java-sdk</artifactId>
- <name>msb-java-sdk</name>
- <version>1.1.0-SNAPSHOT</version>
- <packaging>jar</packaging>
-
- <dependencies>
- <dependency>
- <groupId>com.squareup.retrofit2</groupId>
- <artifactId>retrofit</artifactId>
- <version>2.0.2</version>
- </dependency>
-
- <dependency>
- <groupId>org.reflections</groupId>
- <artifactId>reflections</artifactId>
- <version>0.9.9</version>
- <exclusions>
- <exclusion>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.bundles.repackaged/jersey-guava -->
- <dependency>
- <groupId>org.glassfish.jersey.bundles.repackaged</groupId>
- <artifactId>jersey-guava</artifactId>
- <version>2.6</version>
- </dependency>
-
- <dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-metrics</artifactId>
- <version>0.8.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.12</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>1.1.3</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>1.1.3</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.0</version>
- </dependency>
-
- <dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-core</artifactId>
- <version>0.8.0</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>2.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.0</version>
- </dependency>
- <dependency>
- <groupId>javax.annotation</groupId>
- <artifactId>javax.annotation-api</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>org.immutables</groupId>
- <artifactId>value</artifactId>
- <version>2.1.12</version>
- </dependency>
- <dependency>
- <groupId>com.eclipsesource.jaxrs</groupId>
- <artifactId>consumer</artifactId>
- <version>5.0</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.3.2</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.6</version>
- </dependency>
-
-
- <dependency>
- <groupId>org.glassfish.jersey.core</groupId>
- <artifactId>jersey-client</artifactId>
- <version>2.16</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.5</version>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.12</version>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
- <dependency>
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.oparent</groupId>
+ <artifactId>oparent</artifactId>
+ <version>0.1.1</version>
+ </parent>
+ <groupId>org.onap.msb.java-sdk</groupId>
+ <artifactId>msb-java-sdk</artifactId>
+ <name>msb-java-sdk</name>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>com.squareup.retrofit2</groupId>
+ <artifactId>retrofit</artifactId>
+ <version>2.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.12</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>1.1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.eclipsesource.jaxrs</groupId>
+ <artifactId>consumer</artifactId>
+ <version>5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.6.6</version>
@@ -148,20 +65,19 @@
<version>1.6.6</version>
<scope>test</scope>
</dependency>
-
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-enforcer-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/src/main/java/org/onap/msb/sdk/httpclient/ProxyRetrofitCall.java b/src/main/java/org/onap/msb/sdk/httpclient/ProxyRetrofitCall.java
index ac831e9..0e5968d 100644
--- a/src/main/java/org/onap/msb/sdk/httpclient/ProxyRetrofitCall.java
+++ b/src/main/java/org/onap/msb/sdk/httpclient/ProxyRetrofitCall.java
@@ -17,7 +17,6 @@ import java.io.IOException;
import java.lang.reflect.Method;
import org.onap.msb.sdk.httpclient.handler.RetrofitServiceHandler;
-import org.onap.msb.sdk.httpclient.metric.MetricObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,13 +41,8 @@ public class ProxyRetrofitCall<T extends Object> implements Call<T> {
private Object[] args;
- private MetricObject metricObject;
-
-
-
public ProxyRetrofitCall(Call targetCall, RetrofitServiceHandler retrofitServiceHandler,
- ServiceHttpEndPointObject endPoint, Object proxy, Method method, Object[] args,
- MetricObject metricObject) {
+ ServiceHttpEndPointObject endPoint, Object proxy, Method method, Object[] args) {
super();
this.targetCall = targetCall;
this.handler = retrofitServiceHandler;
@@ -56,7 +50,6 @@ public class ProxyRetrofitCall<T extends Object> implements Call<T> {
this.proxy = proxy;
this.method = method;
this.args = args;
- this.metricObject = metricObject;
}
@Override
@@ -116,7 +109,7 @@ public class ProxyRetrofitCall<T extends Object> implements Call<T> {
public Call<T> clone() {
// TODO Auto-generated method stub
return new ProxyRetrofitCall(targetCall.clone(), this.handler, this.endPoint, this.proxy,
- this.method, this.args, metricObject);
+ this.method, this.args);
}
@Override
diff --git a/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandler.java b/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandler.java
index 7b886d6..74096e7 100644
--- a/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandler.java
+++ b/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandler.java
@@ -87,8 +87,7 @@ public class RetrofitServiceHandler implements InvocationHandler {
if (resultObjecct instanceof Call) {
Call targetCall = (Call) resultObjecct;
- return new ProxyRetrofitCall(targetCall, this, wapper.endPoint, proxy, method, args,
- flowContext.getMetricmanager().getMetricObject(method));
+ return new ProxyRetrofitCall(targetCall, this, wapper.endPoint, proxy, method, args);
}
return resultObjecct;
}
diff --git a/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandlerContext.java b/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandlerContext.java
index 713d0f6..8825403 100644
--- a/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandlerContext.java
+++ b/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandlerContext.java
@@ -22,7 +22,6 @@ import org.onap.msb.sdk.httpclient.builder.IRetrofitObjectBuilder;
import org.onap.msb.sdk.httpclient.conf.HttpClientConf;
import org.onap.msb.sdk.httpclient.convert.IConverterFactoryBuilder;
import org.onap.msb.sdk.httpclient.lb.ILoadBalanceStrategy;
-import org.onap.msb.sdk.httpclient.metric.MetricManager;
import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
@@ -55,8 +54,6 @@ public class RetrofitServiceHandlerContext {
private ILoadBalanceStrategy lbStrategy;
- private MetricManager metricmanager;
-
private IRetrofitObjectBuilder retrofitObjectBuilder;
private ServiceHttpEndPointBeanObject serviceHttpEndPointBeanObject = null;
@@ -113,14 +110,6 @@ public class RetrofitServiceHandlerContext {
}
- public MetricManager getMetricmanager() {
- return metricmanager;
- }
-
- public void setMetricmanager(MetricManager metricmanager) {
- this.metricmanager = metricmanager;
- }
-
public IRetrofitObjectBuilder getRetrofitObjectBuilder() {
return retrofitObjectBuilder;
}
diff --git a/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandlerFactory.java b/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandlerFactory.java
index 1d65661..5b4bfda 100644
--- a/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandlerFactory.java
+++ b/src/main/java/org/onap/msb/sdk/httpclient/handler/RetrofitServiceHandlerFactory.java
@@ -18,6 +18,7 @@ package org.onap.msb.sdk.httpclient.handler;
import java.lang.reflect.InvocationHandler;
import java.util.List;
+import java.util.ArrayList;
import org.onap.msb.sdk.httpclient.ServiceHttpEndPointBeanObject;
import org.onap.msb.sdk.httpclient.conf.HttpClientConf;
@@ -25,13 +26,10 @@ import org.onap.msb.sdk.httpclient.exception.RetrofitServiceRuntimeException;
import org.onap.msb.sdk.httpclient.handler.impl.ConnectionParamsBuilder;
import org.onap.msb.sdk.httpclient.handler.impl.ConverterFactoryBuilder;
import org.onap.msb.sdk.httpclient.handler.impl.LBBuilder;
-import org.onap.msb.sdk.httpclient.handler.impl.MetricmanagerBuilder;
import org.onap.msb.sdk.httpclient.handler.impl.RetrofitHandlerContextBuilder;
import org.onap.msb.sdk.httpclient.handler.impl.ServiceHttpEndPointBeanObjectBuilder;
import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
-import com.google.common.collect.Lists;
-
/**
* @author 10071214
*
@@ -39,12 +37,11 @@ import com.google.common.collect.Lists;
public class RetrofitServiceHandlerFactory {
- private List<HandlerContextBuilder> builders = Lists.newArrayList();
+ private List<HandlerContextBuilder> builders = new ArrayList<>();
public void init() {
builders.add(new ServiceHttpEndPointBeanObjectBuilder());
- builders.add(new MetricmanagerBuilder());
builders.add(new LBBuilder());
builders.add(new ConnectionParamsBuilder());
builders.add(new ConverterFactoryBuilder());
diff --git a/src/main/java/org/onap/msb/sdk/httpclient/handler/impl/MetricmanagerBuilder.java b/src/main/java/org/onap/msb/sdk/httpclient/handler/impl/MetricmanagerBuilder.java
deleted file mode 100644
index 3dbe4e2..0000000
--- a/src/main/java/org/onap/msb/sdk/httpclient/handler/impl/MetricmanagerBuilder.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright 2017 ZTE, Inc. and others.
- *
- * Licensed 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 org.onap.msb.sdk.httpclient.handler.impl;
-
-import org.onap.msb.sdk.httpclient.exception.RetrofitServiceRuntimeException;
-import org.onap.msb.sdk.httpclient.handler.HandlerContextBuilder;
-import org.onap.msb.sdk.httpclient.handler.RetrofitServiceHandlerContext;
-import org.onap.msb.sdk.httpclient.metric.MetricManager;
-
-/**
- * @author 10071214
- *
- */
-public class MetricmanagerBuilder implements HandlerContextBuilder {
-
- @Override
- public void build(RetrofitServiceHandlerContext ctx) throws RetrofitServiceRuntimeException {
- MetricManager metricmanager = new MetricManager();
- ctx.setMetricmanager(metricmanager);
- metricmanager.initMetric(ctx.getRetrofitSrvInterfaceClazz());
-
- }
-
-
-}
diff --git a/src/main/java/org/onap/msb/sdk/httpclient/metric/MetricManager.java b/src/main/java/org/onap/msb/sdk/httpclient/metric/MetricManager.java
deleted file mode 100644
index ee81723..0000000
--- a/src/main/java/org/onap/msb/sdk/httpclient/metric/MetricManager.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright 2017 ZTE, Inc. and others.
- *
- * Licensed 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 org.onap.msb.sdk.httpclient.metric;
-
-import static com.codahale.metrics.MetricRegistry.name;
-
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.codahale.metrics.JmxReporter;
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.Slf4jReporter;
-import com.codahale.metrics.Timer;
-
-/**
- * @author hu.rui
- *
- */
-public class MetricManager {
-
- private static MetricRegistry registry = new MetricRegistry();
-
- private static Slf4jReporter slf4jReporter;
-
- private static JmxReporter jmxReporter;
-
- static {
- initMetricReporters();
- }
-
- protected Map<Method, Timer> timers = new HashMap<>();
- protected Map<Method, Meter> meters = new HashMap<>();
- protected Map<Method, Meter> exceptionmeters = new HashMap<>();
-
-
-
- private static void initMetricReporters() {
-
- /*
- * slf4jReporter = Slf4jReporter.forRegistry(registry)
- * .outputTo(LoggerFactory.getLogger(RetrofitServiceHandler.class))
- * .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build();
- * slf4jReporter.start(10, TimeUnit.MINUTES);
- */
-
- jmxReporter = JmxReporter.forRegistry(registry).build();
- jmxReporter.start();
-
- }
-
- public void initMetric(Class retrofitSrvInterfaceClazz) {
-
- for (Method method : retrofitSrvInterfaceClazz.getMethods()) {
-
- timers.put(method, registry.timer(chooseName(method, "timer")));
- meters.put(method, registry.meter(chooseName(method, "meter")));
- exceptionmeters.put(method, registry.meter(chooseName(method, "exception")));
- }
-
-
- }
-
- private String chooseName(final Method method, final String... suffixes) {
- return name(name(method.getDeclaringClass(), method.getName()), suffixes);
- }
-
- public MetricObject getMetricObject(Method method) {
- return new MetricObject(timers.get(method), meters.get(method), exceptionmeters.get(method));
- }
-
-}
diff --git a/src/main/java/org/onap/msb/sdk/httpclient/metric/MetricObject.java b/src/main/java/org/onap/msb/sdk/httpclient/metric/MetricObject.java
deleted file mode 100644
index 7cc1473..0000000
--- a/src/main/java/org/onap/msb/sdk/httpclient/metric/MetricObject.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright 2017 ZTE, Inc. and others.
- *
- * Licensed 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 org.onap.msb.sdk.httpclient.metric;
-
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.Timer;
-
-/**
- * @author hu.rui
- *
- */
-public class MetricObject {
-
- public Timer timer;
- public Meter meter;
- public Meter exceptionmeter;
-
- public MetricObject(Timer timer, Meter meter, Meter exceptionmeter) {
- super();
- this.timer = timer;
- this.meter = meter;
- this.exceptionmeter = exceptionmeter;
- }
-
-
-
-}
diff --git a/src/test/java/org/onap/msb/sdk/httpclient/handler/ServiceBuilderTest.java b/src/test/java/org/onap/msb/sdk/httpclient/handler/ServiceBuilderTest.java
index 6c29440..2228de6 100644
--- a/src/test/java/org/onap/msb/sdk/httpclient/handler/ServiceBuilderTest.java
+++ b/src/test/java/org/onap/msb/sdk/httpclient/handler/ServiceBuilderTest.java
@@ -19,6 +19,7 @@ package org.onap.msb.sdk.httpclient.handler;
import static org.junit.Assert.assertEquals;
import java.util.List;
+import java.util.ArrayList;
import org.junit.Before;
import org.junit.Test;
@@ -28,17 +29,13 @@ import org.onap.msb.sdk.httpclient.convert.jackson.JacksonConverterFactoryBuilde
import org.onap.msb.sdk.httpclient.handler.impl.ConnectionParamsBuilder;
import org.onap.msb.sdk.httpclient.handler.impl.ConverterFactoryBuilder;
import org.onap.msb.sdk.httpclient.handler.impl.LBBuilder;
-import org.onap.msb.sdk.httpclient.handler.impl.MetricmanagerBuilder;
import org.onap.msb.sdk.httpclient.handler.impl.RetrofitHandlerContextBuilder;
import org.onap.msb.sdk.httpclient.handler.impl.ServiceHttpEndPointBeanObjectBuilder;
import org.onap.msb.sdk.httpclient.lb.RoundRobinLBStrategy;
-import com.google.common.collect.Lists;
-
-
public class ServiceBuilderTest {
- private List<HandlerContextBuilder> builders = Lists.newArrayList();
+ private List<HandlerContextBuilder> builders = new ArrayList<>();
private HttpClientConf globalHttpClientConf;
/**
@@ -100,7 +97,6 @@ public class ServiceBuilderTest {
private void init() {
builders.add(new ServiceHttpEndPointBeanObjectBuilder());
- builders.add(new MetricmanagerBuilder());
builders.add(new LBBuilder());
builders.add(new ConnectionParamsBuilder());
builders.add(new ConverterFactoryBuilder());