Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
portal-backend
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HBP Medical Informatics Platform
portal-backend
Commits
0ba1faf4
Commit
0ba1faf4
authored
6 years ago
by
Ludovic Claude
Browse files
Options
Downloads
Patches
Plain Diff
Replace cluster client by distributed pubsub
parent
eafc61a8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/eu/hbp/mip/akka/WokenClientController.java
+8
-18
8 additions, 18 deletions
src/main/java/eu/hbp/mip/akka/WokenClientController.java
src/main/resources/application.conf
+24
-19
24 additions, 19 deletions
src/main/resources/application.conf
with
32 additions
and
37 deletions
src/main/java/eu/hbp/mip/akka/WokenClientController.java
+
8
−
18
View file @
0ba1faf4
package
eu.hbp.mip.akka
;
import
akka.actor.ActorPath
;
import
akka.actor.ActorPaths
;
import
akka.actor.ActorRef
;
import
akka.actor.ActorSystem
;
import
akka.cluster.
client.ClusterClient
;
import
akka.cluster.
client.ClusterClientSettings
;
import
akka.cluster.
pubsub.DistributedPubSub
;
import
akka.cluster.
pubsub.DistributedPubSubMediator
;
import
akka.pattern.Patterns
;
import
akka.util.Timeout
;
import
ch.chuv.lren.woken.messages.query.Query
;
...
...
@@ -22,8 +20,6 @@ import scala.concurrent.Future;
import
scala.concurrent.duration.Duration
;
import
javax.annotation.PostConstruct
;
import
java.util.Collections
;
import
java.util.Set
;
import
java.util.function.Function
;
/**
...
...
@@ -42,29 +38,23 @@ public abstract class WokenClientController {
@Value
(
"#{'${akka.woken.path:/user/entrypoint}'}"
)
private
String
wokenPath
;
private
ActorRef
woken
Client
;
private
ActorRef
woken
Mediator
;
@SuppressWarnings
(
"unused"
)
@PostConstruct
public
void
initClusterClient
()
{
LOGGER
.
info
(
"Start Woken client "
+
wokenReceptionistPath
);
wokenClient
=
actorSystem
.
actorOf
(
ClusterClient
.
props
(
ClusterClientSettings
.
create
(
actorSystem
).
withInitialContacts
(
initialContacts
())),
"client-"
+
getClass
().
getSimpleName
());
}
private
Set
<
ActorPath
>
initialContacts
()
{
return
Collections
.
singleton
(
ActorPaths
.
fromString
(
wokenReceptionistPath
));
wokenMediator
=
DistributedPubSub
.
get
(
actorSystem
).
mediator
();
}
@SuppressWarnings
(
"unchecked"
)
protected
<
A
,
B
>
B
askWoken
(
A
message
,
int
waitInSeconds
)
throws
Exception
{
LOGGER
.
info
(
"Akka is trying to reach remote "
+
wokenPath
);
ClusterClient
.
Send
queryMessage
=
new
ClusterClient
.
Send
(
wokenPath
,
message
,
true
);
DistributedPubSubMediator
.
Send
queryMessage
=
new
DistributedPubSubMediator
.
Send
(
wokenPath
,
message
,
true
);
Timeout
timeout
=
new
Timeout
(
Duration
.
create
(
waitInSeconds
,
"seconds"
));
Future
<
Object
>
future
=
Patterns
.
ask
(
woken
Client
,
queryMessage
,
timeout
);
Future
<
Object
>
future
=
Patterns
.
ask
(
woken
Mediator
,
queryMessage
,
timeout
);
return
(
B
)
Await
.
result
(
future
,
timeout
.
duration
());
}
...
...
@@ -94,9 +84,9 @@ public abstract class WokenClientController {
protected
<
A
extends
Query
>
Future
<
Object
>
sendWokenQuery
(
A
query
,
int
timeout
)
{
LOGGER
.
info
(
"Akka is trying to reach remote "
+
wokenPath
);
ClusterClient
.
Send
queryMessage
=
new
ClusterClient
.
Send
(
wokenPath
,
query
,
true
);
DistributedPubSubMediator
.
Send
queryMessage
=
new
DistributedPubSubMediator
.
Send
(
wokenPath
,
query
,
true
);
return
Patterns
.
ask
(
woken
Client
,
queryMessage
,
timeout
);
return
Patterns
.
ask
(
woken
Mediator
,
queryMessage
,
timeout
);
}
protected
ExecutionContext
getExecutor
()
{
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/application.conf
+
24
−
19
View file @
0ba1faf4
akka
{
loglevel
=
INFO
log
-
config
-
on
-
start
=
on
loglevel
=
"WARNING"
loglevel
= ${?
LOG_LEVEL
}
stdout
-
loglevel
=
"WARNING"
stdout
-
loglevel
= ${?
LOG_LEVEL
}
loggers
= [
"akka.event.slf4j.Slf4jLogger"
]
logging
-
filter
=
"akka.event.slf4j.Slf4jLoggingFilter"
actor
{
provider
=
"cluster"
log
-
config
-
on
-
start
=
off
log
-
config
-
on
-
start
= ${?
LOG_CONFIG
}
debug
{
receive
=
on
autoreceive
=
off
lifecycle
=
on
fsm
=
on
unhandled
=
on
event
-
stream
=
off
}
log
-
dead
-
letters
=
10
log
-
dead
-
letters
-
during
-
shutdown
=
off
actor
{
provider
=
"cluster"
}
remote
{
log
-
sent
-
messages
=
on
log
-
received
-
messages
=
on
log
-
remote
-
lifecycle
-
events
=
on
maximum
-
payload
-
bytes
=
10000000
bytes
watch
-
failure
-
detector
{
acceptable
-
heartbeat
-
pause
=
20
s
}
netty
.
tcp
{
message
-
frame
-
size
=
10000000
b
send
-
buffer
-
size
=
10000000
b
...
...
@@ -31,21 +36,21 @@ akka {
hostname
= ${
clustering
.
ip
}
# external (logical) hostname
port
= ${
clustering
.
port
}
# external (logical) port
bind
.
hostname
=
0
.
0
.
0
.
0
# internal (bind) hostname
bind
.
port
= ${
clustering
.
port
}
# internal (bind) port
bind
-
hostname
=
0
.
0
.
0
.
0
# internal (bind) hostname
bind
-
port
= ${
clustering
.
port
}
# internal (bind) port
}
}
cluster
{
roles
= [
"test"
]
seed
-
nodes
= [
"akka.tcp://"
${
clustering
.
cluster
.
name
}
"@"
${
clustering
.
seed
-
ip
}
":"
${
clustering
.
seed
-
port
}
]
roles
= [
"portal"
]
client
{
initial
-
contacts
= [
"akka.tcp://"
${
clustering
.
cluster
.
name
}
"@"
${
clustering
.
seed
-
ip
}
":"
${
clustering
.
seed
-
port
}
"/system/receptionist"
]
}
}
extensions
+=
"akka.cluster.pubsub.DistributedPubSub"
extensions
+=
"akka.cluster.client.ClusterClientReceptionist"
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment