helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kisho...@apache.org
Subject [1/2] git commit: Sample Helloworld service
Date Wed, 19 Feb 2014 02:26:30 GMT
Repository: helix
Updated Branches:
  refs/heads/helix-provisioning e8620e4fc -> 48031f367


Sample Helloworld service


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

Branch: refs/heads/helix-provisioning
Commit: df9a3a31a65dd23e44335b352c4b9a96ebc7374e
Parents: 7387834
Author: Kishore Gopalakrishna <g.kishore@gmail.com>
Authored: Tue Feb 18 18:25:37 2014 -0800
Committer: Kishore Gopalakrishna <g.kishore@gmail.com>
Committed: Tue Feb 18 18:25:37 2014 -0800

----------------------------------------------------------------------
 helix-provisioning/pom.xml                      |  4 ++
 .../helix/provisioning/yarn/AppConfig.java      |  4 ++
 .../helix/provisioning/yarn/AppLauncher.java    | 56 +++++++++++-------
 .../provisioning/yarn/AppMasterConfig.java      | 61 ++++++++++++++------
 .../yarn/HelixYarnApplicationMasterMain.java    |  9 ++-
 .../provisioning/yarn/ParticipantLauncher.java  |  4 +-
 .../provisioning/yarn/YarnProvisioner.java      | 30 +++++-----
 .../yarn/example/HelloWordAppSpecFactory.java   | 57 +++++++++++++++---
 .../yarn/example/HelloWorldService.java         |  2 +-
 .../main/resources/hello_world_app_spec.yaml    | 21 +++++++
 10 files changed, 182 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/df9a3a31/helix-provisioning/pom.xml
----------------------------------------------------------------------
diff --git a/helix-provisioning/pom.xml b/helix-provisioning/pom.xml
index e04b3ef..ea5a0fe 100644
--- a/helix-provisioning/pom.xml
+++ b/helix-provisioning/pom.xml
@@ -85,6 +85,10 @@ under the License.
               <mainClass>org.apache.helix.provisioning.yarn.Client</mainClass>
               <name>yarn-job-launcher</name>
             </program>
+             <program>
+              <mainClass>org.apache.helix.provisioning.yarn.AppLauncher</mainClass>
+              <name>app-launcher</name>
+            </program>
           </programs>
         </configuration>
       </plugin>

http://git-wip-us.apache.org/repos/asf/helix/blob/df9a3a31/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppConfig.java
----------------------------------------------------------------------
diff --git a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppConfig.java
b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppConfig.java
index 82f6536..7ea3e42 100644
--- a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppConfig.java
+++ b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppConfig.java
@@ -10,4 +10,8 @@ public class AppConfig {
 	public String getValue(String key) {
 		return (config != null ? config.get(key) : null);
 	}
+	
+	public void setValue(String key, String value){
+	  config.put(key, value);
+	}
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/df9a3a31/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 c744062..409a195 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
@@ -51,8 +51,6 @@ public class AppLauncher {
 
   private static final Log LOG = LogFactory.getLog(Client.class);
 
-
-
   private ApplicationSpec _applicationSpec;
   private YarnClient yarnClient;
   private ApplicationSpecFactory _applicationSpecFactory;
@@ -66,8 +64,8 @@ public class AppLauncher {
 
   private AppMasterConfig _appMasterConfig;
 
-  public AppLauncher(File appMasterArchive, ApplicationSpecFactory applicationSpecFactory,
-      File yamlConfigFile) throws Exception {
+  public AppLauncher(ApplicationSpecFactory applicationSpecFactory, File yamlConfigFile)
+      throws Exception {
     _applicationSpecFactory = applicationSpecFactory;
     _yamlConfigFile = yamlConfigFile;
     init();
@@ -76,6 +74,7 @@ public class AppLauncher {
   private void init() throws Exception {
     _applicationSpec = _applicationSpecFactory.fromYaml(new FileInputStream(_yamlConfigFile));
     _appMasterConfig = new AppMasterConfig();
+    appMasterArchive = new File(_applicationSpec.getAppMasterPackage());
     yarnClient = YarnClient.createYarnClient();
     _conf = new YarnConfiguration();
     yarnClient.init(_conf);
@@ -102,13 +101,13 @@ public class AppLauncher {
     _appMasterConfig.setAppId(_appId.getId());
     String appName = _applicationSpec.getAppName();
     _appMasterConfig.setAppName(appName);
+    _appMasterConfig.setApplicationSpecFactory(_applicationSpecFactory.getClass()
+        .getCanonicalName());
     appContext.setApplicationName(appName);
 
     // Set up the container launch context for the application master
     ContainerLaunchContext amContainer = Records.newRecord(ContainerLaunchContext.class);
 
-
-
     LOG.info("Copy App archive file from local filesystem and add to local environment");
     // Copy the application master jar to the filesystem
     // Create a local resource to point to the destination jar path
@@ -116,12 +115,13 @@ public class AppLauncher {
 
     // get packages for each component packages
     Map<String, URI> packages = new HashMap<String, URI>();
-    packages.put(AppMasterConfig.AppEnvironment.APP_MASTER_PKG.toString(), appMasterArchive.toURI());
+    packages
+        .put(AppMasterConfig.AppEnvironment.APP_MASTER_PKG.toString(), appMasterArchive.toURI());
     packages.put(AppMasterConfig.AppEnvironment.APP_SPEC_FILE.toString(), _yamlConfigFile.toURI());
     for (String serviceName : _applicationSpec.getServices()) {
       packages.put(serviceName, _applicationSpec.getServicePackage(serviceName));
     }
-    Map<String, Path>  hdfsDest = new HashMap<String, Path>();
+    Map<String, Path> hdfsDest = new HashMap<String, Path>();
     Map<String, String> classpathMap = new HashMap<String, String>();
     for (String name : packages.keySet()) {
       URI uri = packages.get(name);
@@ -130,19 +130,27 @@ public class AppLauncher {
       String classpath = generateClasspathAfterExtraction(name, new File(uri));
       classpathMap.put(name, classpath);
       _appMasterConfig.setClasspath(name, classpath);
+      String serviceMainClass = _applicationSpec.getServiceMainClass(name);
+      if (serviceMainClass != null) {
+        _appMasterConfig.setMainClass(name, serviceMainClass);
+      }
     }
     // set local resources for the application master
     // local files or archives as needed
     // In this scenario, the jar file for the application master is part of the local resources
     Map<String, LocalResource> localResources = new HashMap<String, LocalResource>();
-    setupLocalResource(fs, hdfsDest.get(AppMasterConfig.AppEnvironment.APP_MASTER_PKG.toString()));
-    setupLocalResource(fs, hdfsDest.get(AppMasterConfig.AppEnvironment.APP_SPEC_FILE.toString()));
+    LocalResource appMasterPkg =
+        setupLocalResource(fs,
+            hdfsDest.get(AppMasterConfig.AppEnvironment.APP_MASTER_PKG.toString()));
+    LocalResource appSpecFile =
+        setupLocalResource(fs,
+            hdfsDest.get(AppMasterConfig.AppEnvironment.APP_SPEC_FILE.toString()));
+    localResources.put(AppMasterConfig.AppEnvironment.APP_MASTER_PKG.toString(), appMasterPkg);
+    localResources.put(AppMasterConfig.AppEnvironment.APP_SPEC_FILE.toString(), appSpecFile);
 
     // Set local resource info into app master container launch context
     amContainer.setLocalResources(localResources);
 
-    
-
     // Set the necessary security tokens as needed
     // amContainer.setContainerTokens(containerToken);
 
@@ -153,7 +161,8 @@ public class AppLauncher {
     // For now setting all required classpaths including
     // the classpath to "." for the application jar
     StringBuilder classPathEnv =
-        new StringBuilder(Environment.CLASSPATH.$()).append(File.pathSeparatorChar).append("./*");
+        new StringBuilder(Environment.CLASSPATH.$()).append(File.pathSeparatorChar).append("./*")
+            .append(File.pathSeparatorChar);
     classPathEnv.append(classpathMap.get(AppMasterConfig.AppEnvironment.APP_MASTER_PKG.toString()));
     for (String c : _conf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH,
         YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) {
@@ -167,10 +176,13 @@ public class AppLauncher {
       classPathEnv.append(':');
       classPathEnv.append(System.getProperty("java.class.path"));
     }
-    System.out.println("classpath" + classPathEnv.toString());
+    LOG.info("\n\n Setting the classpath for AppMaster:\n\n" + classPathEnv.toString());
     // Set the env variables to be setup in the env where the application master will be
run
-    LOG.info("Set the environment for the application master");
-    amContainer.setEnvironment(_appMasterConfig.getEnv());
+    Map<String, String> env = new HashMap<String, String>(_appMasterConfig.getEnv());
+    LOG.info("Set the environment for the application master" + env);
+    env.put("CLASSPATH", classPathEnv.toString());
+
+    amContainer.setEnvironment(env);
 
     // Set the necessary command to execute the application master
     Vector<CharSequence> vargs = new Vector<CharSequence>(30);
@@ -240,7 +252,7 @@ public class AppLauncher {
     pri.setPriority(amPriority);
     appContext.setPriority(pri);
 
-    String amQueue = "";
+    String amQueue = "default";
     // Set the queue to which this application is to be submitted in the RM
     appContext.setQueue(amQueue);
 
@@ -307,6 +319,8 @@ public class AppLauncher {
     // we don't need the jar file to be untarred for now
     if (isArchive(extension)) {
       amJarRsrc.setType(LocalResourceType.ARCHIVE);
+    } else {
+      amJarRsrc.setType(LocalResourceType.FILE);
     }
     // Set visibility of the resource
     // Setting to most private option
@@ -347,12 +361,10 @@ public class AppLauncher {
    * @throws Exception
    */
   public static void main(String[] args) throws Exception {
-    File appMasterArchive = new File(args[0]);
     ApplicationSpecFactory applicationSpecFactory =
-        (ApplicationSpecFactory) Class.forName(args[1]).newInstance();
-    File yamlConfigFile = new File(args[2]);
-    AppLauncher launcher =
-        new AppLauncher(appMasterArchive, applicationSpecFactory, yamlConfigFile);
+        (ApplicationSpecFactory) Class.forName(args[0]).newInstance();
+    File yamlConfigFile = new File(args[1]);
+    AppLauncher launcher = new AppLauncher(applicationSpecFactory, yamlConfigFile);
     launcher.launch();
     launcher.waitUntilDone();
 

http://git-wip-us.apache.org/repos/asf/helix/blob/df9a3a31/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppMasterConfig.java
----------------------------------------------------------------------
diff --git a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppMasterConfig.java
b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppMasterConfig.java
index 2b8836e..9dcabc2 100644
--- a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppMasterConfig.java
+++ b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppMasterConfig.java
@@ -4,24 +4,42 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.hadoop.yarn.api.ApplicationConstants.Environment;
+import org.apache.log4j.Logger;
 
 /**
  * Convenient method to pass information to containers
  * The methods simply sets up environment variables
  */
 public class AppMasterConfig {
-
+  private static Logger LOG = Logger.getLogger(AppMasterConfig.class);
   private Map<String, String> _envs;
 
   public enum AppEnvironment {
-    APP_MASTER_PKG,
-    APP_SPEC_FILE,
-    APP_NAME,
-    APP_ID;
+    APP_MASTER_PKG("APP_MASTER_PKG"),
+    APP_SPEC_FILE("APP_SPEC_FILE"),
+    APP_NAME("APP_NAME"),
+    APP_ID("APP_ID"),
+    APP_SPEC_FACTORY("APP_SPEC_FACTORY");
+    String _name;
+
+    private AppEnvironment(String name) {
+      _name = name;
+    }
+
+    public String toString() {
+      return _name;
+    }
   }
 
   public AppMasterConfig() {
-    _envs = new HashMap<String, String>(System.getenv());
+    _envs = new HashMap<String, String>();
+  }
+
+  private String get(String key) {
+    String value = (_envs.containsKey(key)) ? _envs.get(key) : System.getenv().get(key);
+    LOG.info("Returning value:"+ value +" for key:'"+ key + "'");
+    
+    return value;
   }
 
   public void setAppId(int id) {
@@ -29,27 +47,27 @@ public class AppMasterConfig {
   }
 
   public String getAppName() {
-    return _envs.get(AppEnvironment.APP_NAME.toString());
+    return get(AppEnvironment.APP_NAME.toString());
   }
 
   public int getAppId() {
-    return Integer.parseInt(_envs.get(AppEnvironment.APP_ID.toString()));
+    return Integer.parseInt(get(AppEnvironment.APP_ID.toString()));
   }
 
   public String getClassPath(String serviceName) {
-    return _envs.get(serviceName + ".classPath");
+    return get(serviceName + "_classpath");
   }
 
   public String getMainClass(String serviceName) {
-    return _envs.get(serviceName + ".mainClass");
+    return get(serviceName + "_mainClass");
   }
 
   public String getZKAddress() {
-    return _envs.get(Environment.NM_HOST.name()) + ":2181";
+    return get(Environment.NM_HOST.name()) + ":2181";
   }
 
   public String getContainerId() {
-    return _envs.get(Environment.CONTAINER_ID.name());
+    return get(Environment.CONTAINER_ID.name());
   }
 
   public Map<String, String> getEnv() {
@@ -62,16 +80,23 @@ public class AppMasterConfig {
   }
 
   public void setClasspath(String serviceName, String classpath) {
-    _envs.put(serviceName + ".classpath", classpath);
+    _envs.put(serviceName + "_classpath", classpath);
   }
 
   public String getApplicationSpecConfigFile() {
-    // TODO Auto-generated method stub
-    return null;
+    return get(AppEnvironment.APP_SPEC_FILE.toString());
+  }
+
+  public String getApplicationSpecFactory() {
+    return get(AppEnvironment.APP_SPEC_FACTORY.toString());
+  }
+
+  public void setApplicationSpecFactory(String className) {
+    _envs.put(AppEnvironment.APP_SPEC_FACTORY.toString(), className);
+
   }
 
-  public String getApplicationSpecProvider() {
-    // TODO Auto-generated method stub
-    return null;
+  public void setMainClass(String serviceName, String serviceMainClass) {
+    _envs.put(serviceName + "_mainClass", serviceMainClass);    
   }
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/df9a3a31/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/HelixYarnApplicationMasterMain.java
----------------------------------------------------------------------
diff --git a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/HelixYarnApplicationMasterMain.java
b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/HelixYarnApplicationMasterMain.java
index 604b228..058b384 100644
--- a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/HelixYarnApplicationMasterMain.java
+++ b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/HelixYarnApplicationMasterMain.java
@@ -44,6 +44,11 @@ public class HelixYarnApplicationMasterMain {
   public static Logger LOG = Logger.getLogger(HelixYarnApplicationMasterMain.class);
 
   public static void main(String[] args) throws Exception {
+    Map<String, String> env = System.getenv();
+    LOG.info("Starting app master with the following environment variables");
+    for(String key: env.keySet()){
+      LOG.info(key + "\t\t=" + env.get(key));
+    }
     int numContainers = 1;
 
     Options opts;
@@ -80,7 +85,7 @@ public class HelixYarnApplicationMasterMain {
 
     String configFile = AppMasterConfig.AppEnvironment.APP_SPEC_FILE.toString();
     ApplicationSpecFactory factory =
-        (ApplicationSpecFactory) Class.forName(appMasterConfig.getApplicationSpecProvider())
+        (ApplicationSpecFactory) Class.forName(appMasterConfig.getApplicationSpecFactory())
             .newInstance();
 
     GenericApplicationMaster genericApplicationMaster = new GenericApplicationMaster(appAttemptID);
@@ -91,7 +96,7 @@ public class HelixYarnApplicationMasterMain {
     YarnProvisioner.applicationSpec = factory.fromYaml(new FileInputStream(configFile));
     String zkAddress = appMasterConfig.getZKAddress();
     String clusterName = appMasterConfig.getAppName();
-
+    
     String resourceName = "HelloWorld";
     // CREATE CLUSTER and setup the resources
     // connect

http://git-wip-us.apache.org/repos/asf/helix/blob/df9a3a31/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/ParticipantLauncher.java
----------------------------------------------------------------------
diff --git a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/ParticipantLauncher.java
b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/ParticipantLauncher.java
index 8a3f19f..e9b6795 100644
--- a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/ParticipantLauncher.java
+++ b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/ParticipantLauncher.java
@@ -27,7 +27,7 @@ public class ParticipantLauncher {
     opts.addOption("cluster", true, "Cluster name, default app name");
     opts.addOption("participantId", true, "Participant Id");
     opts.addOption("zkAddress", true, "Zookeeper address");
-    opts.addOption("ParticipantClass", true, "ParticipantClass");
+    opts.addOption("participantClass", true, "Participant service class");
     try {
       CommandLine cliParser = new GnuParser().parse(opts, args);
       String zkAddress = cliParser.getOptionValue("zkAddress");
@@ -35,7 +35,7 @@ public class ParticipantLauncher {
       connection.connect();
       ClusterId clusterId = ClusterId.from(cliParser.getOptionValue("cluster"));
       ParticipantId participantId = ParticipantId.from(cliParser.getOptionValue("participantId"));
-      String participantClass = cliParser.getOptionValue("ParticipantClass");
+      String participantClass = cliParser.getOptionValue("participantClass");
       @SuppressWarnings("unchecked")
       Class<? extends AbstractParticipantService> clazz =
           (Class<? extends AbstractParticipantService>) Class.forName(participantClass);

http://git-wip-us.apache.org/repos/asf/helix/blob/df9a3a31/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 bf4d832..61b1d70 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
@@ -133,37 +133,38 @@ public class YarnProvisioner implements Provisioner, TargetProvider,
ContainerPr
     String appName = applicationMasterConfig.getAppName();
     int appId = applicationMasterConfig.getAppId();
     String serviceName = _resourceConfig.getId().stringify();
-    String classpath = applicationMasterConfig.getClassPath(serviceName);
+    String serviceClasspath = applicationMasterConfig.getClassPath(serviceName);
     String mainClass = applicationMasterConfig.getMainClass(serviceName);
     String zkAddress = applicationMasterConfig.getZKAddress();
 
     // set the localresources needed to launch container
     Map<String, LocalResource> localResources = new HashMap<String, LocalResource>();
 
-    LocalResource amJarRsrc = Records.newRecord(LocalResource.class);
+    LocalResource servicePackageResource = Records.newRecord(LocalResource.class);
     YarnConfiguration conf = new YarnConfiguration();
     FileSystem fs;
     fs = FileSystem.get(conf);
-    String pathSuffix = appName + "/" + appId + "/app-pkg.tar";
+    String pathSuffix = appName + "/" + appId + "/" + serviceName + ".tar";
     Path dst = new Path(fs.getHomeDirectory(), pathSuffix);
     FileStatus destStatus = fs.getFileStatus(dst);
 
     // Set the type of resource - file or archive
     // archives are untarred at destination
     // we don't need the jar file to be untarred for now
-    amJarRsrc.setType(LocalResourceType.ARCHIVE);
+    servicePackageResource.setType(LocalResourceType.ARCHIVE);
     // Set visibility of the resource
     // Setting to most private option
-    amJarRsrc.setVisibility(LocalResourceVisibility.APPLICATION);
+    servicePackageResource.setVisibility(LocalResourceVisibility.APPLICATION);
     // Set the resource to be copied over
-    amJarRsrc.setResource(ConverterUtils.getYarnUrlFromPath(dst));
+    servicePackageResource.setResource(ConverterUtils.getYarnUrlFromPath(dst));
     // Set timestamp and length of file so that the framework
     // can do basic sanity checks for the local resource
     // after it has been copied over to ensure it is the same
     // resource the client intended to use with the application
-    amJarRsrc.setTimestamp(destStatus.getModificationTime());
-    amJarRsrc.setSize(destStatus.getLen());
-    localResources.put("app-pkg", amJarRsrc);
+    servicePackageResource.setTimestamp(destStatus.getModificationTime());
+    servicePackageResource.setSize(destStatus.getLen());
+    LOG.info("Setting local resource:" + servicePackageResource + " for service" + serviceName
);
+    localResources.put(serviceName, servicePackageResource);
 
     // Set local resource info into app master container launch context
     participantContainer.setLocalResources(localResources);
@@ -174,7 +175,7 @@ public class YarnProvisioner implements Provisioner, TargetProvider, ContainerPr
     // Set the env variables to be setup in the env where the application master will be
run
     LOG.info("Set the environment for the application master");
     Map<String, String> env = new HashMap<String, String>();
-    env.put("app_pkg_path", dst.getName());
+    env.put(serviceName, dst.getName());
     // Add AppMaster.jar location to classpath
     // At some point we should not be required to add
     // the hadoop specific classpaths to the env.
@@ -184,15 +185,14 @@ public class YarnProvisioner implements Provisioner, TargetProvider,
ContainerPr
     StringBuilder classPathEnv =
         new StringBuilder(Environment.CLASSPATH.$()).append(File.pathSeparatorChar).append("./*");
     classPathEnv.append(File.pathSeparatorChar);
-    classPathEnv.append(classpath);
-
+    classPathEnv.append(serviceClasspath);
     for (String c : conf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH,
         YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) {
       classPathEnv.append(File.pathSeparatorChar);
       classPathEnv.append(c.trim());
     }
     classPathEnv.append(File.pathSeparatorChar).append("./log4j.properties");
-
+    LOG.info("Setting classpath for service:\n"+ classPathEnv.toString());
     env.put("CLASSPATH", classPathEnv.toString());
 
     participantContainer.setEnvironment(env);
@@ -206,11 +206,13 @@ public class YarnProvisioner implements Provisioner, TargetProvider,
ContainerPr
     // Set Xmx based on am memory size
     vargs.add("-Xmx" + 1024 + "m");
     // Set class name
-    vargs.add(mainClass);
+    vargs.add(ParticipantLauncher.class.getCanonicalName());
     // Set params for container participant
     vargs.add("--zkAddress " + zkAddress);
     vargs.add("--cluster " + appName);
     vargs.add("--participantId " + participant.getId().stringify());
+    vargs.add("--participantClass " + mainClass);;
+    
 
     vargs.add("1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/ContainerParticipant.stdout");
     vargs.add("2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/ContainerParticipant.stderr");

http://git-wip-us.apache.org/repos/asf/helix/blob/df9a3a31/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 dc0406e..1746fe6 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
@@ -1,30 +1,73 @@
 package org.apache.helix.provisioning.yarn.example;
 
+import java.io.File;
 import java.io.InputStream;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.helix.provisioning.yarn.AppConfig;
 import org.apache.helix.provisioning.yarn.ApplicationSpec;
 import org.apache.helix.provisioning.yarn.ApplicationSpecFactory;
+import org.yaml.snakeyaml.DumperOptions;
 import org.yaml.snakeyaml.Yaml;
 
-public class HelloWordAppSpecFactory implements ApplicationSpecFactory{
+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
+        .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[] {
+      "HelloWorld"
+    });
+
+  }
 
   @Override
   public ApplicationSpec fromYaml(InputStream yamlFile) {
-    return null;
+    return data;
   }
-  
+
   public static void main(String[] args) {
-    Yaml yaml = new Yaml();
+    DumperOptions options = new DumperOptions();
+    options.setPrettyFlow(true);
+
+    Yaml yaml = new Yaml(options);
     HelloworldAppSpec data = new HelloworldAppSpec();
     data._appConfig = new AppConfig();
-    data._appName="testApp";
-    data._serviceConfigMap = new HashMap<String, Map<String,String>>();
+    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
+        .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[] {
+      "HelloWorld"
+    });
     String dump = yaml.dump(data);
     System.out.println(dump);
   }

http://git-wip-us.apache.org/repos/asf/helix/blob/df9a3a31/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWorldService.java
----------------------------------------------------------------------
diff --git a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWorldService.java
b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWorldService.java
index db9e524..614be36 100644
--- a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWorldService.java
+++ b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/example/HelloWorldService.java
@@ -17,7 +17,7 @@ public class HelloWorldService extends AbstractParticipantService {
 	@Override
 	public void init() {
 		HelloWorldStateModelFactory stateModelFactory = new HelloWorldStateModelFactory();
-		getParticipant().getStateMachineEngine().registerStateModelFactory(StateModelDefId.from("OnlineOffline"),
stateModelFactory);
+		getParticipant().getStateMachineEngine().registerStateModelFactory(StateModelDefId.from("StatelessService"),
stateModelFactory);
 	}
 
   @Override

http://git-wip-us.apache.org/repos/asf/helix/blob/df9a3a31/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 e69de29..1f0bc70 100644
--- a/helix-provisioning/src/main/resources/hello_world_app_spec.yaml
+++ b/helix-provisioning/src/main/resources/hello_world_app_spec.yaml
@@ -0,0 +1,21 @@
+!!org.apache.helix.provisioning.yarn.example.HelloworldAppSpec
+_appConfig:
+  config: {
+    k1: v1
+  }
+_appMasterPackageUri: null
+_appName: testApp
+_serviceConfigMap:
+  HelloWorld: {
+    k1: v1
+  }
+_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
+}
+_services: [
+  HelloWorld]
+_taskConfigs: null
+


Mime
View raw message