helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject [26/50] [abbrv] git commit: Minor fixes to read the configuration from app spec yaml
Date Thu, 10 Jul 2014 17:05:09 GMT
Minor fixes to read the configuration from app spec yaml


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

Branch: refs/heads/master
Commit: b97cfb451037479745628cb3b15e2f4e35de7e11
Parents: c903186
Author: Kishore Gopalakrishna <g.kishore@gmail.com>
Authored: Tue Feb 25 17:40:32 2014 -0800
Committer: Kishore Gopalakrishna <g.kishore@gmail.com>
Committed: Tue Feb 25 17:40:32 2014 -0800

----------------------------------------------------------------------
 .../helix/provisioning/ServiceConfig.java       |  1 -
 .../yarn/example/HelloWordAppSpecFactory.java   |  1 +
 .../yarn/example/HelloworldAppSpec.java         | 25 ++++++++++++++++----
 .../main/resources/hello_world_app_spec.yaml    |  0
 4 files changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/b97cfb45/helix-provisioning/src/main/java/org/apache/helix/provisioning/ServiceConfig.java
----------------------------------------------------------------------
diff --git a/helix-provisioning/src/main/java/org/apache/helix/provisioning/ServiceConfig.java
b/helix-provisioning/src/main/java/org/apache/helix/provisioning/ServiceConfig.java
index 262344b..55ca0ae 100644
--- a/helix-provisioning/src/main/java/org/apache/helix/provisioning/ServiceConfig.java
+++ b/helix-provisioning/src/main/java/org/apache/helix/provisioning/ServiceConfig.java
@@ -8,7 +8,6 @@ import org.apache.helix.api.config.UserConfig;
 import org.apache.helix.api.id.ResourceId;
 
 public class ServiceConfig extends UserConfig{
-	public Map<String, String> config = new HashMap<String, String>();
 	
 	public ServiceConfig(Scope<ResourceId> scope) {
 	  super(scope);

http://git-wip-us.apache.org/repos/asf/helix/blob/b97cfb45/recipes/helloworld-provisioning-yarn/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWordAppSpecFactory.java
----------------------------------------------------------------------
diff --git a/recipes/helloworld-provisioning-yarn/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWordAppSpecFactory.java
b/recipes/helloworld-provisioning-yarn/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWordAppSpecFactory.java
index 20591cf..e9163d3 100644
--- a/recipes/helloworld-provisioning-yarn/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWordAppSpecFactory.java
+++ b/recipes/helloworld-provisioning-yarn/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWordAppSpecFactory.java
@@ -30,6 +30,7 @@ public class HelloWordAppSpecFactory implements ApplicationSpecFactory {
     HelloworldAppSpec spec = yaml.loadAs(resourceAsStream, HelloworldAppSpec.class);
     String dump = yaml.dump(spec);
     System.out.println(dump);
+    System.out.println(spec.getServiceConfig("HelloWorld").getStringField("num_containers",
"1"));
 
   }
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/b97cfb45/recipes/helloworld-provisioning-yarn/src/main/java/org/apache/helix/provisioning/yarn/example/HelloworldAppSpec.java
----------------------------------------------------------------------
diff --git a/recipes/helloworld-provisioning-yarn/src/main/java/org/apache/helix/provisioning/yarn/example/HelloworldAppSpec.java
b/recipes/helloworld-provisioning-yarn/src/main/java/org/apache/helix/provisioning/yarn/example/HelloworldAppSpec.java
index 588c84c..4fda91e 100644
--- a/recipes/helloworld-provisioning-yarn/src/main/java/org/apache/helix/provisioning/yarn/example/HelloworldAppSpec.java
+++ b/recipes/helloworld-provisioning-yarn/src/main/java/org/apache/helix/provisioning/yarn/example/HelloworldAppSpec.java
@@ -17,6 +17,8 @@ import org.apache.helix.provisioning.ApplicationSpec;
 import org.apache.helix.provisioning.ServiceConfig;
 import org.apache.helix.provisioning.TaskConfig;
 
+import com.google.common.collect.Maps;
+
 public class HelloworldAppSpec implements ApplicationSpec {
 
   public String _appName;
@@ -31,7 +33,7 @@ public class HelloworldAppSpec implements ApplicationSpec {
 
   private Map<String, String> _serviceMainClassMap;
 
-  private Map<String, Map<String, String>> _serviceConfigMap;
+  private Map<String, ServiceConfig> _serviceConfigMap;
 
   private List<TaskConfig> _taskConfigs;
 
@@ -68,11 +70,24 @@ public class HelloworldAppSpec implements ApplicationSpec {
   }
 
   public Map<String, Map<String, String>> getServiceConfigMap() {
-    return _serviceConfigMap;
+    Map<String,Map<String,String>> map = Maps.newHashMap();
+    for(String service:_serviceConfigMap.keySet()){
+      map.put(service, _serviceConfigMap.get(service).getSimpleFields());
+    }
+    return map;
   }
 
-  public void setServiceConfigMap(Map<String, Map<String, String>> serviceConfigMap)
{
-    _serviceConfigMap = serviceConfigMap;
+  public void setServiceConfigMap(Map<String, Map<String, Object>> map) {
+    _serviceConfigMap = Maps.newHashMap();
+
+    for(String service:map.keySet()){
+      ServiceConfig serviceConfig = new ServiceConfig(Scope.resource(ResourceId.from(service)));
+      Map<String, Object> simpleFields = map.get(service);
+      for(String key:simpleFields.keySet()){
+        serviceConfig.setSimpleField(key, simpleFields.get(key).toString());
+      }
+      _serviceConfigMap.put(service, serviceConfig);
+    }
   }
 
   public void setAppName(String appName) {
@@ -127,7 +142,7 @@ public class HelloworldAppSpec implements ApplicationSpec {
 
   @Override
   public ServiceConfig getServiceConfig(String serviceName) {
-    return new ServiceConfig(Scope.resource(ResourceId.from(serviceName)));
+    return _serviceConfigMap.get(serviceName);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/helix/blob/b97cfb45/recipes/helloworld-provisioning-yarn/src/main/resources/hello_world_app_spec.yaml
----------------------------------------------------------------------
diff --git a/recipes/helloworld-provisioning-yarn/src/main/resources/hello_world_app_spec.yaml
b/recipes/helloworld-provisioning-yarn/src/main/resources/hello_world_app_spec.yaml
old mode 100644
new mode 100755


Mime
View raw message