-<?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>
<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>
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;
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;
this.proxy = proxy;
this.method = method;
this.args = args;
- this.metricObject = metricObject;
}
@Override
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
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;
}
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;
private ILoadBalanceStrategy lbStrategy;
- private MetricManager metricmanager;
-
private IRetrofitObjectBuilder retrofitObjectBuilder;
private ServiceHttpEndPointBeanObject serviceHttpEndPointBeanObject = null;
}
- public MetricManager getMetricmanager() {
- return metricmanager;
- }
-
- public void setMetricmanager(MetricManager metricmanager) {
- this.metricmanager = metricmanager;
- }
-
public IRetrofitObjectBuilder getRetrofitObjectBuilder() {
return retrofitObjectBuilder;
}
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;
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
*
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());
+++ /dev/null
-/*******************************************************************************
- * 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());
-
- }
-
-
-}
+++ /dev/null
-/*******************************************************************************
- * 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));
- }
-
-}
+++ /dev/null
-/*******************************************************************************
- * 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;
- }
-
-
-
-}
import static org.junit.Assert.assertEquals;
import java.util.List;
+import java.util.ArrayList;
import org.junit.Before;
import org.junit.Test;
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;
/**
private void init() {
builders.add(new ServiceHttpEndPointBeanObjectBuilder());
- builders.add(new MetricmanagerBuilder());
builders.add(new LBBuilder());
builders.add(new ConnectionParamsBuilder());
builders.add(new ConverterFactoryBuilder());