1
1
package de .upb .cs .swt .delphi .instanceregistry .Docker
2
2
3
3
import akka .actor .{Actor , ActorLogging , ActorSystem , Props , Status }
4
- import akka .http .scaladsl .model .ws .Message
5
4
import akka .stream .ActorMaterializer
6
5
import de .upb .cs .swt .delphi .instanceregistry .Docker .DockerActor ._
7
6
import de .upb .cs .swt .delphi .instanceregistry .Registry
8
7
import de .upb .cs .swt .delphi .instanceregistry .io .swagger .client .model .InstanceEnums .ComponentType
9
- import org .reactivestreams .Publisher
10
8
11
9
import scala .concurrent .duration ._
12
- import scala .concurrent .{Await , ExecutionContext , Future }
10
+ import scala .concurrent .{Await , ExecutionContext }
13
11
import scala .util .{Failure , Success , Try }
14
12
15
13
class DockerActor (connection : DockerConnection ) extends Actor with ActorLogging {
@@ -27,13 +25,13 @@ class DockerActor(connection: DockerConnection) extends Actor with ActorLogging
27
25
def receive : PartialFunction [Any , Unit ] = {
28
26
29
27
case start(containerId) =>
30
- log.info (s " Docker Container started " )
31
- Try (Await .result(container.start(containerId), Duration .Inf )) match {
32
- case Success (_) =>
33
- sender ! Status .Success
34
- case Failure (ex) =>
35
- sender ! Status .Failure (ex)
36
- }
28
+ log.debug (s " Docker Container started " )
29
+ Try (Await .result(container.start(containerId), Duration .Inf )) match {
30
+ case Success (_) =>
31
+ sender ! Status .Success
32
+ case Failure (ex) =>
33
+ sender ! Status .Failure (ex)
34
+ }
37
35
38
36
case create(componentType, instanceId, containerName) =>
39
37
@@ -74,7 +72,7 @@ class DockerActor(connection: DockerConnection) extends Actor with ActorLogging
74
72
}
75
73
76
74
case stop(containerId) =>
77
- log.info (s " Stopping docker container.. " )
75
+ log.debug (s " Stopping docker container.. " )
78
76
79
77
Try (Await .result(container.stop(containerId), Duration .Inf )) match {
80
78
case Success (_) =>
@@ -84,9 +82,8 @@ class DockerActor(connection: DockerConnection) extends Actor with ActorLogging
84
82
}
85
83
86
84
87
-
88
85
case delete(containerId) =>
89
- log.info (s " Deleting docker container.. " )
86
+ log.debug (s " Deleting docker container.. " )
90
87
Try (Await .result(container.remove(containerId, force = false , removeVolumes = false ), Duration .Inf )) match {
91
88
case Success (_) =>
92
89
sender ! Status .Success
@@ -95,7 +92,7 @@ class DockerActor(connection: DockerConnection) extends Actor with ActorLogging
95
92
}
96
93
97
94
case pause(containerId) =>
98
- log.info (s " Pausing docker container.. " )
95
+ log.debug (s " Pausing docker container.. " )
99
96
Try (Await .result(container.pause(containerId), Duration .Inf )) match {
100
97
case Success (_) =>
101
98
sender ! Status .Success
@@ -104,7 +101,7 @@ class DockerActor(connection: DockerConnection) extends Actor with ActorLogging
104
101
}
105
102
106
103
case unpause(containerId) =>
107
- log.info (s " Unpausing docker container.. " )
104
+ log.debug (s " Unpausing docker container.. " )
108
105
Try (Await .result(container.unpause(containerId), Duration .Inf )) match {
109
106
case Success (_) =>
110
107
sender ! Status .Success
@@ -113,7 +110,7 @@ class DockerActor(connection: DockerConnection) extends Actor with ActorLogging
113
110
}
114
111
115
112
case restart(containerId) =>
116
- log.info (s " Restarting docker container.. " )
113
+ log.debug (s " Restarting docker container.. " )
117
114
Try (Await .result(container.restart(containerId), Duration .Inf )) match {
118
115
case Success (_) =>
119
116
sender ! Status .Success
@@ -122,7 +119,7 @@ class DockerActor(connection: DockerConnection) extends Actor with ActorLogging
122
119
}
123
120
124
121
case runCommand(containerId, command, attachStdin, attachStdout, attachStderr, detachKeys, privileged, tty, user) =>
125
- log.info (s " running command in docker container.. " )
122
+ log.debug (s " running command in docker container.. " )
126
123
val createCommand = Try (Await .result(container.commandCreate(containerId, command, attachStdin, attachStdout, attachStderr, detachKeys, privileged, tty, user), Duration .Inf ))
127
124
createCommand match {
128
125
case Failure (ex) => sender ! Failure (ex)
@@ -140,7 +137,7 @@ class DockerActor(connection: DockerConnection) extends Actor with ActorLogging
140
137
141
138
log.info(s " Fetching Container logs: stdErrSelected -> $stdErrSelected, stream -> $stream" )
142
139
143
- if (! stream){
140
+ if (! stream) {
144
141
val logResult = Try (Await .result(container.retrieveLogs(containerId, stdErrSelected), Duration .Inf ))
145
142
logResult match {
146
143
case Failure (ex) =>
@@ -189,4 +186,5 @@ object DockerActor {
189
186
tty : Option [Boolean ],
190
187
user : Option [String ]
191
188
)
189
+
192
190
}
0 commit comments