Skip to content

Commit 23330ec

Browse files
committed
Formatting logs for Matching Instance & Result
1 parent a256b11 commit 23330ec

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,19 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
129129
} else {
130130
tryLinkMatching(callerId, compType) match {
131131
case Success(instance) =>
132-
log.info(s"Matching finished: First try yielded result $instance.")
132+
log.debug(s"Matching finished: First try yielded result $instance.")
133133
(OperationResult.Ok, Success(instance))
134134
case Failure(ex) =>
135135
log.warning(s"Matching pending: First try failed, message was ${ex.getMessage}")
136136
tryLabelMatching(callerId, compType) match {
137137
case Success(instance) =>
138-
log.info(s"Matching finished: Second try yielded result $instance.")
138+
log.debug(s"Matching finished: Second try yielded result $instance.")
139139
(OperationResult.Ok, Success(instance))
140140
case Failure(ex2) =>
141141
log.warning(s"Matching pending: Second try failed, message was ${ex2.getMessage}")
142142
tryDefaultMatching(compType) match {
143143
case Success(instance) =>
144-
log.info(s"Matching finished: Default matching yielded result $instance.")
144+
log.debug(s"Matching finished: Default matching yielded result $instance.")
145145
(OperationResult.Ok, Success(instance))
146146
case Failure(ex3) =>
147147
log.warning(s"Matching failed: Default matching did not yield result, message was ${ex3.getMessage}.")
@@ -228,7 +228,7 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
228228
instanceDao.setStateFor(matchedInstanceId, InstanceState.NotReachable)
229229
fireStateChangedEvent(instanceDao.getInstance(matchedInstanceId).get) //Re-retrieve instance bc reference was invalidated by 'setStateFor'
230230
}
231-
log.info(s"Applied matching result $matchingSuccess to instance with id $matchedInstanceId.")
231+
log.debug(s"Applied matching result $matchingSuccess to instance with id $matchedInstanceId.")
232232

233233
//Update link state
234234
if (!matchingSuccess) {
@@ -269,13 +269,13 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
269269

270270
deployResult match {
271271
case Failure(ex) =>
272-
log.error(s"Failed to deploy container, docker host not reachable.")
272+
log.warning(s"Failed to deploy container, docker host not reachable.")
273273
instanceDao.removeInstance(id)
274274
fireDockerOperationErrorEvent(None, s"Deploy failed with message: ${ex.getMessage}")
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 '$componentType' container with docker id: $dockerId, host: $normalizedHost and port: $port.")
278+
log.info(s"Deployed new $componentType container with docker id: $dockerId, host: $normalizedHost and port: $port.")
279279

280280
val newInstance = Instance(Some(id),
281281
normalizedHost,
@@ -419,7 +419,7 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
419419
} else {
420420
val instance = instanceDao.getInstance(id).get
421421
if (instance.instanceState == InstanceState.Running) {
422-
log.info(s"Handling /pause for instance with id $id...")
422+
log.debug(s"Handling /pause for instance with id $id...")
423423
implicit val timeout: Timeout = configuration.dockerOperationTimeout
424424

425425
(dockerActor ? pause(instance.dockerId.get)).map {
@@ -455,7 +455,7 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
455455
} else {
456456
val instance = instanceDao.getInstance(id).get
457457
if (instance.instanceState == InstanceState.Paused) {
458-
log.info(s"Handling /resume for instance with id $id...")
458+
log.debug(s"Handling /resume for instance with id $id...")
459459
implicit val timeout: Timeout = configuration.dockerOperationTimeout
460460

461461
(dockerActor ? unpause(instance.dockerId.get)).map {
@@ -493,7 +493,7 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
493493
log.warning(s"Cannot stop instance of type ${instance.componentType}.")
494494
OperationResult.InvalidTypeForOperation
495495
} else {
496-
log.info(s"Calling /stop on non-docker instance $instance..")
496+
log.debug(s"Calling /stop on non-docker instance $instance..")
497497
RestClient.executePost(RestClient.getUri(instance) + "/stop").map {
498498
response =>
499499
log.info(s"Request to /stop returned $response")
@@ -751,13 +751,13 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
751751
* @return Try[Instance], Success if matching was successful, Failure otherwise
752752
*/
753753
private def tryLinkMatching(callerId: Long, componentType: ComponentType): Try[Instance] = {
754-
log.info(s"Matching first try: Analyzing links for $callerId...")
754+
log.debug(s"Matching first try: Analyzing links for $callerId...")
755755

756756
val links = instanceDao.getLinksFrom(callerId).filter(link => link.linkState == LinkState.Assigned)
757757

758758
links.size match {
759759
case 0 =>
760-
log.info(s"Matching first try failed: No links present.")
760+
log.debug(s"Matching first try failed: No links present.")
761761
Failure(new RuntimeException("No links for instance."))
762762
case 1 =>
763763
val instanceAssigned = instanceDao.getInstance(links.head.idTo)
@@ -817,13 +817,13 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
817817
* @return Success(Instance) if successful, Failure otherwise.
818818
*/
819819
private def tryLabelMatching(callerId: Long, componentType: ComponentType): Try[Instance] = {
820-
log.info(s"Matching second try: Analyzing labels for $callerId...")
820+
log.debug(s"Matching second try: Analyzing labels for $callerId...")
821821

822822
val possibleMatches = instanceDao.getInstancesOfType(componentType)
823823

824824
possibleMatches.size match {
825825
case 0 =>
826-
log.warning(s"Matching second try failed: There are no instances of type $componentType present.")
826+
log.debug(s"Matching second try failed: There are no instances of type $componentType present.")
827827
Failure(new RuntimeException(s"Type $componentType not present."))
828828
case _ =>
829829
val labels = instanceDao.getInstance(callerId).get.labels
@@ -839,17 +839,17 @@ class RequestHandler(configuration: Configuration, instanceDao: InstanceDAO, con
839839
log.info(s"Finished matching second try: Successfully matched to $result based on $noOfSharedLabels shared labels.")
840840
Success(result)
841841
} else {
842-
log.warning(s"Matching second try failed: There are no instance with shared labels to $labels.")
842+
log.debug(s"Matching second try failed: There are no instance with shared labels to $labels.")
843843
Failure(new RuntimeException(s"No instance with shared labels."))
844844
}
845845
}
846846
}
847847

848848
private def tryDefaultMatching(componentType: ComponentType): Try[Instance] = {
849-
log.info(s"Matching fallback: Searching for instances of type $componentType ...")
849+
log.debug(s"Matching fallback: Searching for instances of type $componentType ...")
850850
getNumberOfInstances(componentType) match {
851851
case 0 =>
852-
log.error(s"Matching failed: Cannot match to any instance of type $componentType, no such instance present.")
852+
log.warning(s"Matching failed: Cannot match to any instance of type $componentType, no such instance present.")
853853
Failure(new RuntimeException(s"Cannot match to any instance of type $componentType, no instance present."))
854854
case 1 =>
855855
val instance: Instance = instanceDao.getInstancesOfType(componentType).head

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
@@ -314,7 +314,7 @@ class Server(handler: RequestHandler) extends HttpApp
314314
log.debug(s"GET instance/$id/matchingInstance?ComponentType=$compTypeString has been called")
315315

316316
val compType: ComponentType = ComponentType.values.find(v => v.toString == compTypeString).orNull
317-
log.info(s"Looking for instance of type $compType ...")
317+
log.debug(s"Looking for instance of type $compType ...")
318318

319319
if (compType != null) {
320320
handler.getMatchingInstanceOfType(id, compType) match {
@@ -344,7 +344,7 @@ class Server(handler: RequestHandler) extends HttpApp
344344
complete(HttpResponse(StatusCodes.NotFound, entity = s"Could not find matching instance of type $compType for instance with id $id."))
345345
}
346346
} else {
347-
log.error(s"Failed to deserialize parameter string $compTypeString to ComponentType.")
347+
log.warning(s"Failed to deserialize parameter string $compTypeString to ComponentType.")
348348
complete(HttpResponse(StatusCodes.BadRequest, entity = s"Could not deserialize parameter string $compTypeString to ComponentType"))
349349
}
350350
}

0 commit comments

Comments
 (0)