Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery.common.java
/
microservice
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
51425c54
authored
May 21, 2017
by
amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
end of day commits
parent
7f082b74
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
9 deletions
src/main/java/microservice/io/iface/CommonServices.java
src/main/java/microservice/io/impl/service/IRestServiceZmqImpl.java
src/main/java/microservice/utils/ServiceBuilderFactory.java
src/main/java/microservice/io/iface/CommonServices.java
View file @
51425c54
...
@@ -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
);
}
}
}
src/main/java/microservice/io/impl/service/IRestServiceZmqImpl.java
View file @
51425c54
This diff is collapsed.
Click to expand it.
src/main/java/microservice/utils/ServiceBuilderFactory.java
View file @
51425c54
...
@@ -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
.
client
ReceiveParams
==
null
||
this
.
clientSend
Params
==
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
.
client
ReceiveParams
==
null
||
this
.
clientSend
Params
==
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
);
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment