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
580e6bdd
authored
May 21, 2017
by
amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
end of day commits
parent
1796030a
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 @
580e6bdd
...
...
@@ -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
);
}
}
src/main/java/microservice/io/impl/service/IRestServiceZmqImpl.java
View file @
580e6bdd
This diff is collapsed.
Click to expand it.
src/main/java/microservice/utils/ServiceBuilderFactory.java
View file @
580e6bdd
...
...
@@ -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
.
client
ReceiveParams
==
null
||
this
.
clientSend
Params
==
null
)
return
false
;
break
;
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
;
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
);
}
}
}
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