helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject [03/50] [abbrv] git commit: Works with hello world spec.yaml
Date Thu, 10 Jul 2014 17:04:46 GMT
Works with hello world spec.yaml


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

Branch: refs/heads/master
Commit: d1e7ca604de7cefd2effa65f43765902448b0820
Parents: 5a1391e
Author: Kishore Gopalakrishna <g.kishore@gmail.com>
Authored: Wed Feb 19 10:29:48 2014 -0800
Committer: Kishore Gopalakrishna <g.kishore@gmail.com>
Committed: Wed Feb 19 10:29:48 2014 -0800

----------------------------------------------------------------------
 .../provisioner/ContainerProvider.java          |  1 -
 .../integration/TestLocalContainerProvider.java |  5 --
 .../helix/provisioning/yarn/AppLauncher.java    |  2 -
 .../provisioning/yarn/YarnProvisioner.java      | 10 +--
 .../yarn/example/HelloWordAppSpecFactory.java   | 85 ++++++++++++--------
 .../yarn/example/HelloworldAppSpec.java         | 69 ++++++++++++++--
 .../main/resources/hello_world_app_spec.yaml    | 20 ++---
 7 files changed, 126 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/d1e7ca60/helix-core/src/main/java/org/apache/helix/controller/provisioner/ContainerProvider.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/provisioner/ContainerProvider.java
b/helix-core/src/main/java/org/apache/helix/controller/provisioner/ContainerProvider.java
index a95abe0..a6fd791 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/provisioner/ContainerProvider.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/provisioner/ContainerProvider.java
@@ -33,5 +33,4 @@ public interface ContainerProvider {
 
   ListenableFuture<Boolean> stopContainer(ContainerId containerId);
 
-  ContainerState getContainerState(ContainerId containerId);
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/d1e7ca60/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java
b/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java
index 8eb5f56..0e4c803 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java
@@ -270,11 +270,6 @@ public class TestLocalContainerProvider extends ZkUnitTestBase {
     }
 
     @Override
-    public ContainerState getContainerState(ContainerId containerId) {
-      return _states.get(containerId);
-    }
-
-    @Override
     public TargetProviderResponse evaluateExistingContainers(Cluster cluster,
         ResourceId resourceId, Collection<Participant> participants) {
       TargetProviderResponse response = new TargetProviderResponse();

http://git-wip-us.apache.org/repos/asf/helix/blob/d1e7ca60/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppLauncher.java
----------------------------------------------------------------------
diff --git a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppLauncher.java
b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppLauncher.java
index 409a195..d06ae67 100644
--- a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppLauncher.java
+++ b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppLauncher.java
@@ -367,7 +367,5 @@ public class AppLauncher {
     AppLauncher launcher = new AppLauncher(applicationSpecFactory, yamlConfigFile);
     launcher.launch();
     launcher.waitUntilDone();
-
   }
-
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/d1e7ca60/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/YarnProvisioner.java
----------------------------------------------------------------------
diff --git a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/YarnProvisioner.java
b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/YarnProvisioner.java
index 61b1d70..477023b 100644
--- a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/YarnProvisioner.java
+++ b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/YarnProvisioner.java
@@ -73,6 +73,9 @@ public class YarnProvisioner implements Provisioner, TargetProvider, ContainerPr
   Map<ContainerId, Container> allocatedContainersMap = new HashMap<ContainerId,
Container>();
   private HelixManager _helixManager;
   private ResourceConfig _resourceConfig;
+  public YarnProvisioner(){
+    
+  }
 
   @Override
   public ListenableFuture<ContainerId> allocateContainer(ContainerSpec spec) {
@@ -93,7 +96,7 @@ public class YarnProvisioner implements Provisioner, TargetProvider, ContainerPr
   }
 
   @Override
-  public ListenableFuture<Boolean> deallocateContainer(ContainerId containerId) {
+  public ListenableFuture<Boolean> deallocateContainer(final ContainerId containerId)
{
     ListenableFuture<ContainerReleaseResponse> releaseContainer =
         applicationMaster.releaseContainer(allocatedContainersMap.get(containerId));
     return Futures.transform(releaseContainer, new Function<ContainerReleaseResponse,
Boolean>() {
@@ -243,11 +246,6 @@ public class YarnProvisioner implements Provisioner, TargetProvider,
ContainerPr
   }
 
   @Override
-  public ContainerState getContainerState(ContainerId containerId) {
-    return null;
-  }
-
-  @Override
   public void init(HelixManager helixManager, ResourceConfig resourceConfig) {
     _helixManager = helixManager;
     _resourceConfig = resourceConfig;

http://git-wip-us.apache.org/repos/asf/helix/blob/d1e7ca60/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWordAppSpecFactory.java
----------------------------------------------------------------------
diff --git a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWordAppSpecFactory.java
b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWordAppSpecFactory.java
index 1746fe6..f9f1980 100644
--- a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWordAppSpecFactory.java
+++ b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWordAppSpecFactory.java
@@ -17,31 +17,34 @@ public class HelloWordAppSpecFactory implements ApplicationSpecFactory
{
   static HelloworldAppSpec data;
 
   static {
-    data = new HelloworldAppSpec();
-    data._appConfig = new AppConfig();
-    data._appConfig.setValue("k1", "v1");
-    data._appName = "testApp";
-    data._appMasterPackageUri =
-        new File("/Users/kgopalak/Documents/projects/incubator-helix/helix-provisioning/target/helix-provisioning-0.7.1-incubating-SNAPSHOT-pkg.tar").toURI().toString();
-    data._serviceConfigMap = new HashMap<String, Map<String, String>>();
-    data._serviceConfigMap.put("HelloWorld", new HashMap<String, String>());
-    data._serviceConfigMap.get("HelloWorld").put("k1", "v1");
-    data._serviceMainClassMap = new HashMap<String, String>();
-    data._serviceMainClassMap.put("HelloWorld", HelloWorldService.class.getCanonicalName());
-    data._servicePackageURIMap = new HashMap<String, String>();
-    data._servicePackageURIMap
+    HelloworldAppSpec data = new HelloworldAppSpec();
+    AppConfig appConfig = new AppConfig();
+    appConfig.setValue("k1", "v1");
+    data.setAppConfig(appConfig);
+    data.setAppName("testApp");
+    data.setAppMasterPackageUri(
+        "/Users/kgopalak/Documents/projects/incubator-helix/helix-provisioning/helix-provisioning-0.7.1-incubating-SNAPSHOT-pkg.tar");
+    HashMap<String, Map<String, String>> serviceConfigMap = new HashMap<String,
Map<String, String>>();
+    serviceConfigMap.put("HelloWorld", new HashMap<String, String>());
+    serviceConfigMap.get("HelloWorld").put("k1", "v1");
+    data.setServiceConfigMap(serviceConfigMap);
+    HashMap<String, String> serviceMainClassMap = new HashMap<String, String>();
+    serviceMainClassMap.put("HelloWorld", HelloWorldService.class.getCanonicalName());
+    data.setServiceMainClassMap(serviceMainClassMap);
+    HashMap<String, String> servicePackageURIMap = new HashMap<String, String>();
+    servicePackageURIMap
         .put(
             "HelloWorld",
-            new File("/Users/kgopalak/Documents/projects/incubator-helix/helix-provisioning/target/helix-provisioning-0.7.1-incubating-SNAPSHOT-pkg.tar").toURI().toString());
-    data._services = Arrays.asList(new String[] {
+            "/Users/kgopalak/Documents/projects/incubator-helix/helix-provisioning/helix-provisioning-0.7.1-incubating-SNAPSHOT-pkg.tar");
+    data.setServicePackageURIMap(servicePackageURIMap);
+    data.setServices(Arrays.asList(new String[] {
       "HelloWorld"
-    });
-
-  }
+    }));  }
 
   @Override
-  public ApplicationSpec fromYaml(InputStream yamlFile) {
-    return data;
+  public ApplicationSpec fromYaml(InputStream inputstream) {
+    return (ApplicationSpec) new Yaml().load(inputstream);
+    // return data;
   }
 
   public static void main(String[] args) {
@@ -50,26 +53,38 @@ public class HelloWordAppSpecFactory implements ApplicationSpecFactory
{
 
     Yaml yaml = new Yaml(options);
     HelloworldAppSpec data = new HelloworldAppSpec();
-    data._appConfig = new AppConfig();
-    data._appConfig.setValue("k1", "v1");
-    data._appName = "testApp";
-    data._appMasterPackageUri =
-        "/Users/kgopalak/Documents/projects/incubator-helix/helix-provisioning/helix-provisioning-0.7.1-incubating-SNAPSHOT-pkg.tar";
-    data._serviceConfigMap = new HashMap<String, Map<String, String>>();
-    data._serviceConfigMap.put("HelloWorld", new HashMap<String, String>());
-    data._serviceConfigMap.get("HelloWorld").put("k1", "v1");
-    data._serviceMainClassMap = new HashMap<String, String>();
-    data._serviceMainClassMap.put("HelloWorld", HelloWorldService.class.getCanonicalName());
-    data._servicePackageURIMap = new HashMap<String, String>();
-    data._servicePackageURIMap
+    AppConfig appConfig = new AppConfig();
+    appConfig.setValue("k1", "v1");
+    data.setAppConfig(appConfig);
+    data.setAppName("testApp");
+    data.setAppMasterPackageUri(
+        "/Users/kgopalak/Documents/projects/incubator-helix/helix-provisioning/helix-provisioning-0.7.1-incubating-SNAPSHOT-pkg.tar");
+    HashMap<String, Map<String, String>> serviceConfigMap = new HashMap<String,
Map<String, String>>();
+    serviceConfigMap.put("HelloWorld", new HashMap<String, String>());
+    serviceConfigMap.get("HelloWorld").put("k1", "v1");
+    data.setServiceConfigMap(serviceConfigMap);
+    HashMap<String, String> serviceMainClassMap = new HashMap<String, String>();
+    serviceMainClassMap.put("HelloWorld", HelloWorldService.class.getCanonicalName());
+    data.setServiceMainClassMap(serviceMainClassMap);
+    HashMap<String, String> servicePackageURIMap = new HashMap<String, String>();
+    servicePackageURIMap
         .put(
             "HelloWorld",
             "/Users/kgopalak/Documents/projects/incubator-helix/helix-provisioning/helix-provisioning-0.7.1-incubating-SNAPSHOT-pkg.tar");
-    data._services = Arrays.asList(new String[] {
+    data.setServicePackageURIMap(servicePackageURIMap);
+    data.setServices(Arrays.asList(new String[] {
       "HelloWorld"
-    });
+    }));
     String dump = yaml.dump(data);
     System.out.println(dump);
-  }
 
+    InputStream resourceAsStream = ClassLoader.getSystemClassLoader().getResourceAsStream("hello_world_app_spec.yaml");
+    HelloworldAppSpec load = yaml.loadAs(resourceAsStream,HelloworldAppSpec.class);
+    String dumpnew = yaml.dump(load);
+    System.out.println(dumpnew.equals(dump));
+    
+    System.out.println("==================================");
+    System.out.println(dumpnew);
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/d1e7ca60/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloworldAppSpec.java
----------------------------------------------------------------------
diff --git a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloworldAppSpec.java
b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloworldAppSpec.java
index 4bd3caa..2e4cd75 100644
--- a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloworldAppSpec.java
+++ b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloworldAppSpec.java
@@ -15,21 +15,74 @@ import org.apache.helix.provisioning.yarn.TaskConfig;
 
 public class HelloworldAppSpec implements ApplicationSpec {
 
-  public String _appName;
+  private String _appName;
 
-  public AppConfig _appConfig;
+  private AppConfig _appConfig;
 
-  public List<String> _services;
+  private List<String> _services;
 
-  public String _appMasterPackageUri;
+  private String _appMasterPackageUri;
+  
+  private Map<String, String> _servicePackageURIMap;
 
-  public Map<String, String> _servicePackageURIMap;
+  private Map<String, String> _serviceMainClassMap;
 
-  public Map<String, String> _serviceMainClassMap;
+  private Map<String,Map<String,String>> _serviceConfigMap;
 
-  public Map<String,Map<String,String>> _serviceConfigMap;
+  private List<TaskConfig> _taskConfigs;
+
+  public AppConfig getAppConfig() {
+    return _appConfig;
+  }
+
+  public void setAppConfig(AppConfig appConfig) {
+    _appConfig = appConfig;
+  }
+
+  public String getAppMasterPackageUri() {
+    return _appMasterPackageUri;
+  }
+
+  public void setAppMasterPackageUri(String appMasterPackageUri) {
+    _appMasterPackageUri = appMasterPackageUri;
+  }
+
+  public Map<String, String> getServicePackageURIMap() {
+    return _servicePackageURIMap;
+  }
+
+  public void setServicePackageURIMap(Map<String, String> servicePackageURIMap) {
+    _servicePackageURIMap = servicePackageURIMap;
+  }
+
+  public Map<String, String> getServiceMainClassMap() {
+    return _serviceMainClassMap;
+  }
+
+  public void setServiceMainClassMap(Map<String, String> serviceMainClassMap) {
+    _serviceMainClassMap = serviceMainClassMap;
+  }
+
+  public Map<String, Map<String, String>> getServiceConfigMap() {
+    return _serviceConfigMap;
+  }
+
+  public void setServiceConfigMap(Map<String, Map<String, String>> serviceConfigMap)
{
+    _serviceConfigMap = serviceConfigMap;
+  }
+
+  public void setAppName(String appName) {
+    _appName = appName;
+  }
+
+  public void setServices(List<String> services) {
+    _services = services;
+  }
+
+  public void setTaskConfigs(List<TaskConfig> taskConfigs) {
+    _taskConfigs = taskConfigs;
+  }
 
-  public List<TaskConfig> _taskConfigs;
   @Override
   public String getAppName() {
     return _appName;

http://git-wip-us.apache.org/repos/asf/helix/blob/d1e7ca60/helix-provisioning/src/main/resources/hello_world_app_spec.yaml
----------------------------------------------------------------------
diff --git a/helix-provisioning/src/main/resources/hello_world_app_spec.yaml b/helix-provisioning/src/main/resources/hello_world_app_spec.yaml
index 1f0bc70..648104a 100644
--- a/helix-provisioning/src/main/resources/hello_world_app_spec.yaml
+++ b/helix-provisioning/src/main/resources/hello_world_app_spec.yaml
@@ -1,21 +1,23 @@
 !!org.apache.helix.provisioning.yarn.example.HelloworldAppSpec
-_appConfig:
+appConfig:
   config: {
     k1: v1
   }
-_appMasterPackageUri: null
-_appName: testApp
-_serviceConfigMap:
+appMasterPackageUri: 'file:///Users/kgopalak/Documents/projects/incubator-helix/helix-provisioning/target/helix-provisioning-0.7.1-incubating-SNAPSHOT-pkg.tar'
+appName: testApp
+serviceConfigMap:
   HelloWorld: {
     k1: v1
   }
-_serviceMainClassMap: {
+serviceMainClassMap: {
   HelloWorld: org.apache.helix.provisioning.yarn.example.HelloWorldService
 }
-_servicePackageURIMap: {
-  HelloWorld: /Users/kgopalak/Documents/projects/incubator-helix/helix-provisioning/helix-provisioning-0.7.1-incubating-SNAPSHOT-pkg.tar
+servicePackageURIMap: {
+  HelloWorld: 'file:///Users/kgopalak/Documents/projects/incubator-helix/helix-provisioning/target/helix-provisioning-0.7.1-incubating-SNAPSHOT-pkg.tar'
 }
-_services: [
+services: [
   HelloWorld]
-_taskConfigs: null
+taskConfigs: null
+
+
 


Mime
View raw message