Skip to content

Commit 076bd42

Browse files
committed
Formatting logs for /instances/deploy
1 parent 4d95473 commit 076bd42

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

src/main/scala/de/upb/cs/swt/delphi/instanceregistry/Docker/DockerActor.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package de.upb.cs.swt.delphi.instanceregistry.Docker
22

33
import akka.actor.{Actor, ActorLogging, ActorSystem, Props, Status}
4-
import akka.http.scaladsl.model.ws.Message
54
import akka.stream.ActorMaterializer
65
import de.upb.cs.swt.delphi.instanceregistry.Docker.DockerActor._
76
import de.upb.cs.swt.delphi.instanceregistry.Registry
87
import de.upb.cs.swt.delphi.instanceregistry.io.swagger.client.model.InstanceEnums.ComponentType
9-
import org.reactivestreams.Publisher
108

119
import scala.concurrent.duration._
12-
import scala.concurrent.{Await, ExecutionContext, Future}
10+
import scala.concurrent.{Await, ExecutionContext}
1311
import scala.util.{Failure, Success, Try}
1412

1513
class DockerActor(connection: DockerConnection) extends Actor with ActorLogging {
@@ -45,7 +43,7 @@ class DockerActor(connection: DockerConnection) extends Actor with ActorLogging
4543
case Failure(ex) => sender ! Failure(ex)
4644
case Success(containerResult) =>
4745
Await.ready(container.start(containerResult.Id), Duration.Inf)
48-
log.info(s"Docker Instance created and started")
46+
log.debug(s"Docker Instance created and started")
4947
val containerInfo = Await.result(container.get(containerResult.Id), Duration.Inf)
5048

5149
val instancePort = componentType match {
@@ -55,7 +53,7 @@ class DockerActor(connection: DockerConnection) extends Actor with ActorLogging
5553
case t => throw new RuntimeException(s"Invalid component type $t, cannot deploy container.")
5654
}
5755

58-
log.info("ip address is " + containerInfo.IPAddress)
56+
log.debug("ip address is " + containerInfo.IPAddress)
5957
sender ! Success(containerResult.Id, containerInfo.IPAddress, instancePort)
6058
}
6159

src/main/scala/de/upb/cs/swt/delphi/instanceregistry/Registry.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ object Registry extends AppLogging {
3232

3333
def main(args: Array[String]): Unit = {
3434
requestHandler.initialize()
35-
log.info("Starting server ...")
3635
server.startServer(configuration.bindHost, configuration.bindPort)
37-
log.info("Shutting down ...")
3836
requestHandler.shutdown()
3937
system.terminate()
4038
}

src/main/scala/de/upb/cs/swt/delphi/instanceregistry/RequestHandler.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
247247
}
248248

249249
def handleDeploy(componentType: ComponentType, name: Option[String]): Try[Long] = {
250-
log.info(s"Deploying container of type $componentType")
250+
log.debug(s"Deploying container of type $componentType")
251251
val instance = Instance(None,
252252
"",
253253
-1L,
@@ -275,7 +275,7 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
275275
Failure(new RuntimeException(s"Failed to deploy container, docker host not reachable (${ex.getMessage})."))
276276
case Success((dockerId, host, port)) =>
277277
val normalizedHost = host.substring(1, host.length - 1)
278-
log.info(s"Deployed new container with id $dockerId, host $normalizedHost and port $port.")
278+
log.info(s"Deployed new '$componentType' container with id: $dockerId, host: $normalizedHost and port: $port.")
279279

280280
val newInstance = Instance(Some(id),
281281
normalizedHost,
@@ -291,12 +291,12 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
291291

292292
instanceDao.updateInstance(newInstance) match {
293293
case Success(_) =>
294-
log.info("Successfully registered.")
294+
log.info("Instance successfully registered.")
295295
fireInstanceAddedEvent(newInstance)
296296
fireNumbersChangedEvent(newInstance.componentType)
297297
Success(id)
298298
case Failure(x) =>
299-
log.info(s"Failed to register. Exception: $x")
299+
log.warning(s"Failed to register. Exception: $x")
300300
Failure(x)
301301
}
302302
}

src/main/scala/de/upb/cs/swt/delphi/instanceregistry/connection/Server.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ class Server(handler: RequestHandler) extends HttpApp
436436
val compType: ComponentType = ComponentType.values.find(v => v.toString == compTypeString).orNull
437437

438438
if (compType != null) {
439-
log.info(s"Trying to deploy container of type $compType" + (if (name.isDefined) {
439+
log.debug(s"Trying to deploy container of type $compType" + (if (name.isDefined) {
440440
s" with name ${name.get}..."
441441
} else {
442442
"..."
@@ -453,7 +453,7 @@ class Server(handler: RequestHandler) extends HttpApp
453453
}
454454

455455
} else {
456-
log.error(s"Failed to deserialize parameter string $compTypeString to ComponentType.")
456+
log.warning(s"Failed to deserialize parameter string $compTypeString to ComponentType.")
457457
complete(HttpResponse(StatusCodes.BadRequest, entity = s"Could not deserialize parameter string $compTypeString to ComponentType"))
458458
}
459459
case Failure(ex) =>

0 commit comments

Comments
 (0)