aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject aries-containers git commit: Marathon: support discovering previously deployed apps.
Date Fri, 26 May 2017 13:55:15 GMT
Repository: aries-containers
Updated Branches:
  refs/heads/master 81f6202bc -> 129ef689c


Marathon: support discovering previously deployed apps.


Project: http://git-wip-us.apache.org/repos/asf/aries-containers/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-containers/commit/129ef689
Tree: http://git-wip-us.apache.org/repos/asf/aries-containers/tree/129ef689
Diff: http://git-wip-us.apache.org/repos/asf/aries-containers/diff/129ef689

Branch: refs/heads/master
Commit: 129ef689cbc89db910af2d9f5c6c6cc7007b51ce
Parents: 81f6202
Author: David Bosschaert <davidb@apache.org>
Authored: Fri May 26 14:54:52 2017 +0100
Committer: David Bosschaert <davidb@apache.org>
Committed: Fri May 26 14:54:52 2017 +0100

----------------------------------------------------------------------
 .../marathon/impl/MarathonContainerFactory.java       | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-containers/blob/129ef689/containers-marathon/src/main/java/org/apache/aries/containers/marathon/impl/MarathonContainerFactory.java
----------------------------------------------------------------------
diff --git a/containers-marathon/src/main/java/org/apache/aries/containers/marathon/impl/MarathonContainerFactory.java
b/containers-marathon/src/main/java/org/apache/aries/containers/marathon/impl/MarathonContainerFactory.java
index 60321ba..a508c53 100644
--- a/containers-marathon/src/main/java/org/apache/aries/containers/marathon/impl/MarathonContainerFactory.java
+++ b/containers-marathon/src/main/java/org/apache/aries/containers/marathon/impl/MarathonContainerFactory.java
@@ -58,7 +58,11 @@ public class MarathonContainerFactory implements ContainerFactory {
 
     @Override
     public Service getService(ServiceConfig config) throws Exception {
-        // TODO get existing service
+        GetAppsResponse existing = marathonClient.getApps(
+                Collections.singletonMap("label", SERVICE_NAME + "==" + config.getServiceName()));
+        if (existing.getApps().size() > 0) {
+            return createServiceFromExistingApp(existing.getApps(), config);
+        }
 
         App app = new App();
         app.setId(config.getServiceName());
@@ -110,6 +114,14 @@ public class MarathonContainerFactory implements ContainerFactory {
         return createServiceFromApp(res, config);
     }
 
+    private Service createServiceFromExistingApp(List<App> apps, ServiceConfig config)
{
+        if (apps.size() != 1)
+            throw new IllegalStateException("More than one existing app found for service
" +
+                    config.getServiceName() + " " + apps);
+
+        return createServiceFromApp(apps.get(0), config);
+    }
+
     private Service createServiceFromApp(App app, ServiceConfig cfg) {
         // TODO make this check more thorough
         if (!cfg.getServiceName().equals(app.getLabels().get(SERVICE_NAME)))


Mime
View raw message