Commit 580e6bdd by amir

end of day commits

parent 1796030a
......@@ -222,4 +222,15 @@ public class CommonServices {
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 {
CommonServices.EnumRestServiceMode serviceMode = CommonServices.EnumRestServiceMode.E_UNKNOWN;
ZMQParams.ServerParams serverParams = null;
ZMQParams.ServerParams clientParams = null;
ZMQParams.ServerParams clientReceiveParams = null;
ZMQParams.ServerParams clientSendParams = null;
IRestServiceZmqImpl restServiceZmq = null;
int numOfClientWorkers = 0;
int numOfServerWorkers = 0;
public RestServiceZmqBuilder(CommonServices.EnumRestServiceMode serviceMode) {
this.serviceMode = serviceMode;
}
......@@ -128,8 +132,19 @@ public class ServiceBuilderFactory {
public void setServerParams(ZMQParams.ServerParams serverParams) {
this.serverParams = serverParams;
}
public void setClientParams(ZMQParams.ServerParams clientParams) {
this.clientParams = clientParams;
public void setClientReceiveParams(ZMQParams.ServerParams clientReceiveParams) {
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() {
......@@ -141,14 +156,22 @@ public class ServiceBuilderFactory {
return false;
break;
case E_CLIENT:
if (this.clientParams == null)
if (this.clientReceiveParams == null || this.clientSendParams == null)
return false;
break;
case E_CLIENT_SERVER:
if (this.serverParams == null || this.clientParams == null)
if (this.serverParams == null || this.clientReceiveParams == null || this.clientSendParams == null)
return false;
break;
}
/**
* defaulting to number of processors
*/
if (numOfClientWorkers == 0){
numOfClientWorkers = Runtime.getRuntime().availableProcessors();
}
if (numOfServerWorkers == 0)
numOfServerWorkers = Runtime.getRuntime().availableProcessors();
return true;
}
......@@ -161,14 +184,14 @@ public class ServiceBuilderFactory {
switch (serviceMode) {
case E_SERVER:
restServiceZmq.setServerParams(serverParams);
buildServer();
break;
case E_CLIENT:
restServiceZmq.setClientParams(clientParams);
buildClient();
break;
case E_CLIENT_SERVER:
restServiceZmq.setServerParams(serverParams);
restServiceZmq.setClientParams(clientParams);
buildClient();
buildServer();
break;
}
} catch (Exception exp){
......@@ -181,5 +204,16 @@ public class ServiceBuilderFactory {
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