Commit 51425c54 by amir

end of day commits

parent 7f082b74
...@@ -222,4 +222,15 @@ public class CommonServices { ...@@ -222,4 +222,15 @@ public class CommonServices {
void unsubscribe(String topic); void unsubscribe(String topic);
} }
public interface ICacheClient <K,V>{
void set(K key, V val);
void set(K key, V val, int expiration);
void setExpiration(K key, int expiration);
V get(K key);
void delete(K key);
void deleteByPattern(K pattern);
V[] getByPattern(K pattern);
}
} }
...@@ -119,8 +119,12 @@ public class ServiceBuilderFactory { ...@@ -119,8 +119,12 @@ public class ServiceBuilderFactory {
CommonServices.EnumRestServiceMode serviceMode = CommonServices.EnumRestServiceMode.E_UNKNOWN; CommonServices.EnumRestServiceMode serviceMode = CommonServices.EnumRestServiceMode.E_UNKNOWN;
ZMQParams.ServerParams serverParams = null; ZMQParams.ServerParams serverParams = null;
ZMQParams.ServerParams clientParams = null; ZMQParams.ServerParams clientReceiveParams = null;
ZMQParams.ServerParams clientSendParams = null;
IRestServiceZmqImpl restServiceZmq = null; IRestServiceZmqImpl restServiceZmq = null;
int numOfClientWorkers = 0;
int numOfServerWorkers = 0;
public RestServiceZmqBuilder(CommonServices.EnumRestServiceMode serviceMode) { public RestServiceZmqBuilder(CommonServices.EnumRestServiceMode serviceMode) {
this.serviceMode = serviceMode; this.serviceMode = serviceMode;
} }
...@@ -128,8 +132,19 @@ public class ServiceBuilderFactory { ...@@ -128,8 +132,19 @@ public class ServiceBuilderFactory {
public void setServerParams(ZMQParams.ServerParams serverParams) { public void setServerParams(ZMQParams.ServerParams serverParams) {
this.serverParams = serverParams; this.serverParams = serverParams;
} }
public void setClientParams(ZMQParams.ServerParams clientParams) { public void setClientReceiveParams(ZMQParams.ServerParams clientReceiveParams) {
this.clientParams = clientParams; this.clientReceiveParams = clientReceiveParams;
}
public void setClientSendParams(ZMQParams.ServerParams clientSendParams) { this.clientSendParams = clientSendParams; }
public RestServiceZmqBuilder setNumOfClientWorkers(int num) {
numOfClientWorkers = num;
return this;
}
public RestServiceZmqBuilder setNumOfServerWorkers(int numOfServerWorkers) {
this.numOfServerWorkers = numOfServerWorkers;
return this;
} }
private boolean validateParams() { private boolean validateParams() {
...@@ -141,14 +156,22 @@ public class ServiceBuilderFactory { ...@@ -141,14 +156,22 @@ public class ServiceBuilderFactory {
return false; return false;
break; break;
case E_CLIENT: case E_CLIENT:
if (this.clientParams == null) if (this.clientReceiveParams == null || this.clientSendParams == null)
return false; return false;
break; break;
case E_CLIENT_SERVER: case E_CLIENT_SERVER:
if (this.serverParams == null || this.clientParams == null) if (this.serverParams == null || this.clientReceiveParams == null || this.clientSendParams == null)
return false; return false;
break; break;
} }
/**
* defaulting to number of processors
*/
if (numOfClientWorkers == 0){
numOfClientWorkers = Runtime.getRuntime().availableProcessors();
}
if (numOfServerWorkers == 0)
numOfServerWorkers = Runtime.getRuntime().availableProcessors();
return true; return true;
} }
...@@ -161,14 +184,14 @@ public class ServiceBuilderFactory { ...@@ -161,14 +184,14 @@ public class ServiceBuilderFactory {
switch (serviceMode) { switch (serviceMode) {
case E_SERVER: case E_SERVER:
restServiceZmq.setServerParams(serverParams); buildServer();
break; break;
case E_CLIENT: case E_CLIENT:
restServiceZmq.setClientParams(clientParams); buildClient();
break; break;
case E_CLIENT_SERVER: case E_CLIENT_SERVER:
restServiceZmq.setServerParams(serverParams); buildClient();
restServiceZmq.setClientParams(clientParams); buildServer();
break; break;
} }
} catch (Exception exp){ } catch (Exception exp){
...@@ -181,5 +204,16 @@ public class ServiceBuilderFactory { ...@@ -181,5 +204,16 @@ public class ServiceBuilderFactory {
return restServiceZmq; return restServiceZmq;
} }
private void buildServer() {
restServiceZmq.setServerParams(serverParams);
restServiceZmq.setNumOfServerWorkers(numOfServerWorkers);
}
private void buildClient() {
restServiceZmq.setClientReceiveParams(clientReceiveParams);
restServiceZmq.setClientSendParams(clientSendParams);
restServiceZmq.setNumOfClientWorkers(numOfClientWorkers);
}
} }
} }
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