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 for scaling and listing services.
Date Fri, 26 May 2017 14:35:21 GMT
Repository: aries-containers
Updated Branches:
  refs/heads/master 49c288937 -> e9adc1259


Marathon: support for scaling and listing services.


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

Branch: refs/heads/master
Commit: e9adc12590b56f44baedc10e59fce6fbc85ac62c
Parents: 49c2889
Author: David Bosschaert <davidb@apache.org>
Authored: Fri May 26 15:34:51 2017 +0100
Committer: David Bosschaert <davidb@apache.org>
Committed: Fri May 26 15:34:51 2017 +0100

----------------------------------------------------------------------
 .../marathon/impl/MarathonContainerFactory.java | 29 +++++++++-----------
 .../containers/marathon/impl/ServiceImpl.java   | 10 +++----
 2 files changed, 17 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-containers/blob/e9adc125/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 a508c53..e5c6b16 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
@@ -20,7 +20,9 @@ package org.apache.aries.containers.marathon.impl;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.aries.containers.ContainerFactory;
@@ -133,22 +135,17 @@ public class MarathonContainerFactory implements ContainerFactory {
 
     @Override
     public Set<String> listServices() throws Exception {
-        GetAppsResponse apps = marathonClient.getApps();
-        return Collections.emptySet();
-//        apps.getApps().stream().filter(a -> a).map(mapper)
-
-        /*
-        return apps.getApps().stream().
-                filter(a -> {
-                    Map<String, String> labels = a.getLabels();
-                    if (labels != null)
-                        return MARK_LABEL_VALUE.equals(a.getLabels().get(MARK_LABEL_KEY));
-                    else
-                        return false;
-                }).
-                map(a -> marathonIdToGroupName(a.getId())).
-                collect(Collectors.toSet());
-        */
+        GetAppsResponse services = marathonClient.getApps(
+                Collections.singletonMap("label", SERVICE_NAME));
+
+        Set<String> serviceNames = new HashSet<>();
+        for (App app : services.getApps()) {
+            Map<String, String> labels = app.getLabels();
+            String name = labels.get(SERVICE_NAME);
+            if (name != null && name.length() > 0)
+                serviceNames.add(name);
+        }
+        return serviceNames;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/aries-containers/blob/e9adc125/containers-marathon/src/main/java/org/apache/aries/containers/marathon/impl/ServiceImpl.java
----------------------------------------------------------------------
diff --git a/containers-marathon/src/main/java/org/apache/aries/containers/marathon/impl/ServiceImpl.java
b/containers-marathon/src/main/java/org/apache/aries/containers/marathon/impl/ServiceImpl.java
index cc6d100..ce1ef99 100644
--- a/containers-marathon/src/main/java/org/apache/aries/containers/marathon/impl/ServiceImpl.java
+++ b/containers-marathon/src/main/java/org/apache/aries/containers/marathon/impl/ServiceImpl.java
@@ -71,15 +71,13 @@ class ServiceImpl implements Service {
 
     @Override
     public void setInstanceCount(int count) {
-        App curApp = marathonClient.getApp(marathonAppID).getApp();
-        curApp.setInstances(count);
-        marathonClient.updateApp(marathonAppID, curApp, true);
+        App updatedApp = new App();
+        updatedApp.setInstances(count);;
+        marathonClient.updateApp(marathonAppID, updatedApp, true);
     }
 
     @Override
     public void refresh() {
-        // TODO Auto-generated method stub
-
+        // No state held - noop
     }
-
 }


Mime
View raw message