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
62ff0fa1
Commit
62ff0fa1
authored
6 years ago
by
Ludovic Claude
Browse files
Options
Downloads
Patches
Plain Diff
Improve init of actor system
parent
caba9c6d
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
-5
8 additions, 5 deletions
src/main/java/eu/hbp/mip/akka/WokenClientController.java
src/main/java/eu/hbp/mip/configuration/AkkaConfiguration.java
+1
-7
1 addition, 7 deletions
...main/java/eu/hbp/mip/configuration/AkkaConfiguration.java
with
9 additions
and
12 deletions
src/main/java/eu/hbp/mip/akka/WokenClientController.java
+
8
−
5
View file @
62ff0fa1
...
...
@@ -2,6 +2,7 @@ package eu.hbp.mip.akka;
import
akka.actor.ActorRef
;
import
akka.actor.ActorSystem
;
import
akka.cluster.pubsub.DistributedPubSub
;
import
akka.cluster.pubsub.DistributedPubSubMediator
;
import
akka.pattern.Patterns
;
import
akka.util.Timeout
;
...
...
@@ -10,6 +11,7 @@ import ch.chuv.lren.woken.messages.query.QueryResult;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -33,9 +35,6 @@ public abstract class WokenClientController {
@Value
(
"#{'${akka.woken.path:/user/entrypoint}'}"
)
private
String
wokenPath
;
@Autowired
private
ActorRef
wokenMediator
;
@SuppressWarnings
(
"unchecked"
)
protected
<
A
,
B
>
B
askWoken
(
A
message
,
int
waitInSeconds
)
throws
Exception
{
LOGGER
.
info
(
"Akka is trying to reach remote "
+
wokenPath
);
...
...
@@ -43,7 +42,7 @@ public abstract class WokenClientController {
DistributedPubSubMediator
.
Send
queryMessage
=
new
DistributedPubSubMediator
.
Send
(
wokenPath
,
message
,
false
);
Timeout
timeout
=
new
Timeout
(
Duration
.
create
(
waitInSeconds
,
"seconds"
));
Future
<
Object
>
future
=
Patterns
.
ask
(
wokenMediator
,
queryMessage
,
timeout
);
Future
<
Object
>
future
=
Patterns
.
ask
(
wokenMediator
()
,
queryMessage
,
timeout
);
return
(
B
)
Await
.
result
(
future
,
timeout
.
duration
());
}
...
...
@@ -75,10 +74,14 @@ public abstract class WokenClientController {
DistributedPubSubMediator
.
Send
queryMessage
=
new
DistributedPubSubMediator
.
Send
(
wokenPath
,
query
,
false
);
return
Patterns
.
ask
(
wokenMediator
,
queryMessage
,
waitInSeconds
);
return
Patterns
.
ask
(
wokenMediator
()
,
queryMessage
,
waitInSeconds
);
}
protected
ExecutionContext
getExecutor
()
{
return
actorSystem
.
dispatcher
();
}
private
ActorRef
wokenMediator
()
{
return
DistributedPubSub
.
get
(
actorSystem
).
mediator
();
}
}
This diff is collapsed.
Click to expand it.
src/main/java/eu/hbp/mip/configuration/AkkaConfiguration.java
+
1
−
7
View file @
62ff0fa1
...
...
@@ -53,6 +53,7 @@ public class AkkaConfiguration {
}
@Bean
@DependsOn
(
"actorSystem"
)
public
Cluster
wokenCluster
()
{
Cluster
cluster
=
Cluster
.
get
(
actorSystem
());
LOGGER
.
info
(
"Connect to Woken cluster nodes at "
+
String
.
join
(
","
,
wokenPath
()));
...
...
@@ -120,11 +121,4 @@ public class AkkaConfiguration {
return
config
.
getStringList
(
"akka.cluster.seed-nodes"
);
}
@Bean
@Lazy
@DependsOn
(
"wokenCluster"
)
public
ActorRef
wokenMediator
()
{
return
DistributedPubSub
.
get
(
actorSystem
()).
mediator
();
}
}
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