diff --git a/src/main/scala/de/upb/cs/swt/delphi/instancemanagement/Instance.scala b/src/main/scala/de/upb/cs/swt/delphi/instancemanagement/Instance.scala index db29ab8..7325b96 100644 --- a/src/main/scala/de/upb/cs/swt/delphi/instancemanagement/Instance.scala +++ b/src/main/scala/de/upb/cs/swt/delphi/instancemanagement/Instance.scala @@ -54,7 +54,7 @@ trait JsonSupport extends SprayJsonSupport with DefaultJsonProtocol { } } - implicit val instanceFormat : JsonFormat[Instance] = jsonFormat7(Instance) + implicit val instanceFormat : JsonFormat[Instance] = jsonFormat8(Instance) } final case class Instance ( @@ -64,7 +64,8 @@ final case class Instance ( name: String, componentType: InstanceEnums.ComponentType, dockerId: Option[String], - instanceState: InstanceEnums.State + instanceState: InstanceEnums.State, + labels: List[String] ) object InstanceEnums { type ComponentType = ComponentType.Value diff --git a/src/main/scala/de/upb/cs/swt/delphi/instancemanagement/InstanceRegistry.scala b/src/main/scala/de/upb/cs/swt/delphi/instancemanagement/InstanceRegistry.scala index f01d42d..c908576 100644 --- a/src/main/scala/de/upb/cs/swt/delphi/instancemanagement/InstanceRegistry.scala +++ b/src/main/scala/de/upb/cs/swt/delphi/instancemanagement/InstanceRegistry.scala @@ -147,7 +147,9 @@ object InstanceRegistry extends JsonSupport with AppLogging if(!configuration.usingInstanceRegistry) { Failure(new RuntimeException("Cannot get ElasticSearch instance from Instance Registry, no Instance Registry available.")) } else { - val request = HttpRequest(method = HttpMethods.GET, configuration.instanceRegistryUri + "/matchingInstance?ComponentType=ElasticSearch") + val request = HttpRequest(method = HttpMethods.GET, + configuration.instanceRegistryUri + + s"/matchingInstance?Id=${configuration.assignedID.getOrElse(-1)}&ComponentType=ElasticSearch") Await.result(Http(system).singleRequest(request) map {response => response.status match { @@ -189,18 +191,17 @@ object InstanceRegistry extends JsonSupport with AppLogging val idToPost = configuration.elasticsearchInstance.id.getOrElse(-1L) val request = HttpRequest( method = HttpMethods.POST, - configuration.instanceRegistryUri + s"/matchingResult?Id=$idToPost&MatchingSuccessful=$isElasticSearchReachable") + configuration.instanceRegistryUri + + s"/matchingResult?CallerId=${configuration.assignedID.getOrElse(-1)}&MatchedInstanceId=$idToPost&MatchingSuccessful=$isElasticSearchReachable") Await.result(Http(system).singleRequest(request) map {response => - val status=response.status if(response.status == StatusCodes.OK){ log.info(s"Successfully posted matching result to Instance Registry.") Success() } else { - val statuscode = response.status - log.warning(s"Failed to post matching result to Instance Registry, server returned $statuscode") - Failure(new RuntimeException(s"Failed to post matching result to Instance Registry, server returned $statuscode")) + log.warning(s"Failed to post matching result to Instance Registry, server returned ${response.status}") + Failure(new RuntimeException(s"Failed to post matching result to Instance Registry, server returned ${response.status}")) } } recover {case ex => @@ -252,7 +253,7 @@ object InstanceRegistry extends JsonSupport with AppLogging private def createInstance(id: Option[Long], controlPort : Int, name : String) : Instance = Instance(id, InetAddress.getLocalHost.getHostAddress, - controlPort, name, ComponentType.WebApi, None, InstanceState.Running) + controlPort, name, ComponentType.WebApi, None, InstanceState.Running, List.empty[String]) def reportStart(id: String, configuration: Configuration):Try[ResponseEntity] ={ val request = HttpRequest(method = HttpMethods.GET, configuration.instanceRegistryUri + "/reportStart") diff --git a/src/main/scala/de/upb/cs/swt/delphi/webapi/Configuration.scala b/src/main/scala/de/upb/cs/swt/delphi/webapi/Configuration.scala index 3874191..1cc8b1a 100644 --- a/src/main/scala/de/upb/cs/swt/delphi/webapi/Configuration.scala +++ b/src/main/scala/de/upb/cs/swt/delphi/webapi/Configuration.scala @@ -49,7 +49,8 @@ class Configuration( //Server and Elasticsearch configuration "Default ElasticSearch instance", ComponentType.ElasticSearch, None, - InstanceState.Running) + InstanceState.Running, + List.empty[String]) } val defaultElasticSearchPort: Int = 9200 val defaultElasticSearchHost: String = "elasticsearch://localhost"