Commit 08a751a1 by Eli Ben Baruch

## 1.2.4:

- fix RestClient: return false with error reason rathar than run time exception handled by observable
- maven local repository
parent 9de8f150
### Microservice Framework in JAVA ### Microservice Framework in JAVA
## 1.2.4:
- fix RestClient: return false with error reason rathar than exception handled by observable
- maven local repository
## 1.2.3: ## 1.2.3:
- add cache timeout to every read command - add cache timeout to every read command
## Version 1.2.2: ## Version 1.2.2:
......
group 'com.ipgallery.common' group 'com.ipgallery.common'
version '1.2.3' version '1.2.4'
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
//for mavenLocal
//apply plugin: 'maven'
sourceCompatibility = 1.8 sourceCompatibility = 1.8
repositories { repositories {
//mavenCentral() //use mavenLocal in cases you want to create this jar on your local machine
//or to be able to use one
// mavenLocal()//defaults to ~/.m2/repository
maven { url "http://172.16.1.132:8081/repository/internal" } maven { url "http://172.16.1.132:8081/repository/internal" }
maven { url "http://mandubian-mvn.googlecode.com/svn/trunk/mandubian-mvn/repository" } maven { url "http://mandubian-mvn.googlecode.com/svn/trunk/mandubian-mvn/repository" }
} }
...@@ -22,8 +27,12 @@ dependencies { ...@@ -22,8 +27,12 @@ dependencies {
compile 'com.netflix.hystrix:hystrix-metrics-event-stream:1.4.12' compile 'com.netflix.hystrix:hystrix-metrics-event-stream:1.4.12'
compile 'redis.clients:jedis:2.4.2' compile 'redis.clients:jedis:2.4.2'
compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2' compile 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.0.2'
compile 'com.ipgallery.common:utils:1.1.2' // compile 'com.ipgallery.common:utils:1.1.3-LOCAL' //local
compile 'com.ipgallery.common:rabbitmq:1.0.1' compile 'com.ipgallery.common:utils:1.1.3'
// compile ('com.ipgallery.common:rabbitmq:1.0.1')
compile ('com.ipgallery.common:rabbitmq:1.0.1') {
exclude group: 'com.ipgallery.common', module: 'utils'
}
compile 'com.ecwid.consul:consul-api:1.1.9' compile 'com.ecwid.consul:consul-api:1.1.9'
compile 'com.github.davidb:metrics-influxdb:0.8.2' compile 'com.github.davidb:metrics-influxdb:0.8.2'
compile 'io.dropwizard.metrics:metrics-graphite:3.1.2' compile 'io.dropwizard.metrics:metrics-graphite:3.1.2'
...@@ -31,6 +40,18 @@ dependencies { ...@@ -31,6 +40,18 @@ dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11' testCompile group: 'junit', name: 'junit', version: '4.11'
} }
//1. use this install task (under "other" section) to create this jar localy on your machine.
// version will be extended with the Postfix "-LOCAL"
//2. in order to use this jar in a project using this jar:
// in the build.gradle add "mavenLocal()" as first repository
//and the dependency with correct version number ended with "-LOCAL"
//install {
// repositories.mavenInstaller {
// pom.version = version + '-LOCAL'
// }
//}
publishing { publishing {
publications { publications {
......
...@@ -107,10 +107,7 @@ public class IRestClientRestImpl implements ICommandClient ...@@ -107,10 +107,7 @@ public class IRestClientRestImpl implements ICommandClient
srr = httpRestClient.get(reqCtx.getEntity(), reqCtx.getParams(), reqCtx.getRequestParams()); srr = httpRestClient.get(reqCtx.getEntity(), reqCtx.getParams(), reqCtx.getRequestParams());
else else
srr = httpRestClient.get(reqCtx.getEntity(), reqCtx.getParamsString(),reqCtx.getRequestParams()); srr = httpRestClient.get(reqCtx.getEntity(), reqCtx.getParamsString(),reqCtx.getRequestParams());
BaseRestResponse brr = getBaseRestResponse(srr); return getBaseRestResponse(srr);
if (!brr.success)
throw new RuntimeException(brr.error);
return (brr);
} }
} }
...@@ -130,10 +127,7 @@ public class IRestClientRestImpl implements ICommandClient ...@@ -130,10 +127,7 @@ public class IRestClientRestImpl implements ICommandClient
srr = httpRestClient.post(reqCtx.getEntity(), reqCtx.getParams(), reqCtx.getRequestParams(),reqCtx.getContent()); srr = httpRestClient.post(reqCtx.getEntity(), reqCtx.getParams(), reqCtx.getRequestParams(),reqCtx.getContent());
else else
srr = httpRestClient.post(reqCtx.getEntity(), reqCtx.getParamsString(),reqCtx.getRequestParams(),reqCtx.getContent()); srr = httpRestClient.post(reqCtx.getEntity(), reqCtx.getParamsString(),reqCtx.getRequestParams(),reqCtx.getContent());
BaseRestResponse brr = getBaseRestResponse(srr); return getBaseRestResponse(srr);
if (!brr.success)
throw new RuntimeException(brr.error);
return (brr);
} }
} }
...@@ -153,10 +147,7 @@ public class IRestClientRestImpl implements ICommandClient ...@@ -153,10 +147,7 @@ public class IRestClientRestImpl implements ICommandClient
srr = httpRestClient.put(reqCtx.getEntity(), reqCtx.getParams(), reqCtx.getRequestParams(),reqCtx.getContent()); srr = httpRestClient.put(reqCtx.getEntity(), reqCtx.getParams(), reqCtx.getRequestParams(),reqCtx.getContent());
else else
srr = httpRestClient.put(reqCtx.getEntity(), reqCtx.getParamsString(),reqCtx.getRequestParams(),reqCtx.getContent()); srr = httpRestClient.put(reqCtx.getEntity(), reqCtx.getParamsString(),reqCtx.getRequestParams(),reqCtx.getContent());
BaseRestResponse brr = getBaseRestResponse(srr); return getBaseRestResponse(srr);
if (!brr.success)
throw new RuntimeException(brr.error);
return (brr);
} }
} }
...@@ -177,9 +168,7 @@ public class IRestClientRestImpl implements ICommandClient ...@@ -177,9 +168,7 @@ public class IRestClientRestImpl implements ICommandClient
else else
srr = httpRestClient.delete(reqCtx.getEntity(), reqCtx.getParamsString(),reqCtx.getRequestParams()); srr = httpRestClient.delete(reqCtx.getEntity(), reqCtx.getParamsString(),reqCtx.getRequestParams());
BaseRestResponse brr = getBaseRestResponse(srr); BaseRestResponse brr = getBaseRestResponse(srr);
if (!brr.success) return getBaseRestResponse(srr);
throw new RuntimeException(brr.error);
return (brr);
} }
} }
......
...@@ -134,21 +134,93 @@ public class TestMicroClient ...@@ -134,21 +134,93 @@ public class TestMicroClient
MicroserviceClient client = null; MicroserviceClient client = null;
BaseRestResponse brr = null; BaseRestResponse brr = null;
// http://62.90.235.105:8103/app/api/async/smartCity/getReports?ts=1469598279812&_=1469598274942
//http://172.16.1.97:8012/ds/deviceInstance/getDevicesOfSubscriber/97297705810 //http://172.16.1.97:8012/ds/deviceInstance/getDevicesOfSubscriber/97297705810
///mde/api/v1/chicago/transportation/routes?key=gT2nciTKwRv6Jy5njqm8fe7LW ///mde/api/v1/chicago/transportation/routes?key=gT2nciTKwRv6Jy5njqm8fe7LW
RestClientParams clientParams = new RestClientParams("ds",true,0, "172.16.1.97:8012",null,100); RestClientParams clientParams = new RestClientParams("app",true,0, "62.90.235.105:8103",null,100);
// final IServiceDiscoveryConsulImpl serDisco = new IServiceDiscoveryConsulImpl("localhost", 8500); // final IServiceDiscoveryConsulImpl serDisco = new IServiceDiscoveryConsulImpl("localhost", 8500);
try try
{ {
//http://62.90.235.105:8103/app/searchUsers.htm
// ICommandClient cmdClient = new IRestClientRestImpl(clientParams).withServiceDiscovery(serDisco); // ICommandClient cmdClient = new IRestClientRestImpl(clientParams).withServiceDiscovery(serDisco);
client = new MicroserviceClient(EnumRestClientType.E_HTTP,clientParams); client = new MicroserviceClient(EnumRestClientType.E_HTTP,clientParams);
CommandParams cmdParams = new CommandParams("/deviceInstance/getDevicesOfSubscriber", "97297705810", null, null, null); CommandParams cmdParams = new CommandParams("async/smartCity/", "getReports", "ts=1469598279812", null, null);
System.out.println("Start Testing"); System.out.println("Start Testing");
for (int i = 0 ; i < MAX_ITERATION; i++) for (int i = 0 ; i < MAX_ITERATION; i++)
{ {
//1 //1
brr = client.read(cmdParams); brr = client.create(cmdParams);
if (brr.success)
System.out.println("1. i="+i+ brr.objectNode.toString());
else
System.out.println("1. i="+i+brr.error);
Thread.sleep(500);
JsonNode metrics = client.getMetrics();
if (i % 10 == 0)
System.out.println("metrics: " + metrics.toString());
//2
brr = client.read(cmdParams,true);
if (brr.success)
System.out.println("2. i="+i+brr.objectNode.toString());
else
System.out.println("2. i="+i+brr.error);
Thread.sleep(500);
metrics = client.getMetrics();
if (i % 10 == 0)
System.out.println("2. i="+i+"metrics: " + metrics.toString());
//3
brr = client.read(cmdParams, 6);
if (brr.success)
System.out.println("3. i="+i+brr.objectNode.toString());
else
System.out.println("3. i="+i+brr.error);
Thread.sleep(500);
metrics = client.getMetrics();
if (i % 10 == 0)
System.out.println("3. i="+i+"metrics: " + metrics.toString());
}
System.out.println("End\nMetrics: " + client.getMetrics().toString());
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void testMicroClient_Post()
{
MicroserviceClient client = null;
BaseRestResponse brr = null;
// http://62.90.235.105:8103/app/api/async/smartCity/getReports?ts=1469598279812&_=1469598274942
//http://172.16.1.97:8012/ds/deviceInstance/getDevicesOfSubscriber/97297705810
///mde/api/v1/chicago/transportation/routes?key=gT2nciTKwRv6Jy5njqm8fe7LW
RestClientParams clientParams = new RestClientParams("app",true,0, "62.90.235.105:8103",null,100);
// final IServiceDiscoveryConsulImpl serDisco = new IServiceDiscoveryConsulImpl("localhost", 8500);
try
{
//http://62.90.235.105:8103/app/searchUsers.htm
// ICommandClient cmdClient = new IRestClientRestImpl(clientParams).withServiceDiscovery(serDisco);
client = new MicroserviceClient(EnumRestClientType.E_HTTP,clientParams);
CommandParams cmdParams = new CommandParams(null, "searchUsers.htm", "ts=1469598279812", null, null);
System.out.println("Start Testing");
for (int i = 0 ; i < MAX_ITERATION; i++)
{
//1
brr = client.create(cmdParams);
if (brr.success) if (brr.success)
System.out.println("1. i="+i+ brr.objectNode.toString()); System.out.println("1. i="+i+ brr.objectNode.toString());
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment