Repository: incubator-slider
Updated Branches:
  refs/heads/feature/packaging_improvements 8d0e337a0 -> a31d20eed


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a31d20ee/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/ComponentCommand.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/ComponentCommand.java
 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/ComponentCommand.java
new file mode 100644
index 0000000..aa7f3c3
--- /dev/null
+++ 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/ComponentCommand.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.slider.providers.agent.application.metadata.json;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents the metadata associated with the application.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class ComponentCommand {
+  protected static final Logger
+      log = LoggerFactory.getLogger(ComponentCommand.class);
+
+
+  private String exec;
+  private String name = "START";
+  private String type = "SHELL";
+
+  /**
+   * Creator.
+   */
+  public ComponentCommand() {
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setExec(String exec) {
+    this.exec = exec;
+  }
+
+  public String getExec() {
+    return exec;
+  }
+
+  public void setType(String type) {
+    this.type = type;
+  }
+
+  public String getType() {
+    return type;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a31d20ee/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/ConfigFile.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/ConfigFile.java
 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/ConfigFile.java
new file mode 100644
index 0000000..9a83f35
--- /dev/null
+++ 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/ConfigFile.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.slider.providers.agent.application.metadata.json;
+
+/**
+ *
+ */
+public class ConfigFile {
+  String type;
+  String fileName;
+  String dictionaryName;
+
+  public ConfigFile() {
+  }
+
+  public String getType() {
+    return type;
+  }
+
+  public void setType(String type) {
+    this.type = type;
+  }
+
+  public String getFileName() {
+    return fileName;
+  }
+
+  public void setFileName(String fileName) {
+    this.fileName = fileName;
+  }
+
+  public String getDictionaryName() {
+    return dictionaryName;
+  }
+
+  public void setDictionaryName(String dictionaryName) {
+    this.dictionaryName = dictionaryName;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a31d20ee/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/Export.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/Export.java
 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/Export.java
new file mode 100644
index 0000000..7331144
--- /dev/null
+++ 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/Export.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.slider.providers.agent.application.metadata.json;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Represents package description.
+ */
+public class Export {
+  protected static final Logger
+      log = LoggerFactory.getLogger(Export.class);
+
+
+  private String name;
+  private String value;
+
+  /**
+   * Creator.
+   */
+  public Export() {
+  }
+
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setValue(String value) {
+    this.value = value;
+  }
+
+  public String getValue() {
+    return value;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a31d20ee/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/ExportGroup.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/ExportGroup.java
 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/ExportGroup.java
new file mode 100644
index 0000000..e95497d
--- /dev/null
+++ 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/ExportGroup.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.slider.providers.agent.application.metadata.json;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents package description.
+ */
+public class ExportGroup {
+  protected static final Logger
+      log = LoggerFactory.getLogger(ExportGroup.class);
+
+
+  private String name;
+  private List<Export> exports = new ArrayList<Export>();
+
+  /**
+   * Creator.
+   */
+  public ExportGroup() {
+  }
+
+  @JsonProperty("exports")
+  public List<Export> getExports() {
+    return this.exports;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getName() {
+    return name;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a31d20ee/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/MetaInfo.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/MetaInfo.java
 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/MetaInfo.java
new file mode 100644
index 0000000..8938ee0
--- /dev/null
+++ 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/MetaInfo.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.slider.providers.agent.application.metadata.json;
+
+import org.apache.slider.core.exceptions.BadConfigException;
+import org.apache.slider.providers.agent.application.metadata.Metainfo;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Represents the metadata associated with the application.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class MetaInfo {
+  protected static final Logger
+      log = LoggerFactory.getLogger(MetaInfo.class);
+
+  private static final String UTF_8 = "UTF-8";
+
+  /**
+   * version
+   */
+  private String schemaVersion = "2.1";
+
+  private Application application;
+
+
+  /**
+   * Creator.
+   */
+  public MetaInfo() {
+  }
+
+  public void setApplication(Application application) {
+    this.application = application;
+  }
+
+  public Application getApplication() {
+    return application;
+  }
+
+  public void setSchemaVersion(String version) {
+    schemaVersion = version;
+  }
+
+  public String getSchemaVersion() {
+    return schemaVersion;
+  }
+
+  public static MetaInfo upConverted(Metainfo fromVersion2dot0) throws 
BadConfigException {
+    if (fromVersion2dot0 == null) {
+      return null;
+    }
+
+    MetaInfo metaInfo = new MetaInfo();
+
+    if (fromVersion2dot0.getApplication() != null) {
+      Application app = new Application();
+      metaInfo.setApplication(app);
+
+      app.setComment(fromVersion2dot0.getApplication().getComment());
+      
app.setExportedConfigs(fromVersion2dot0.getApplication().getExportedConfigs());
+      app.setName(fromVersion2dot0.getApplication().getName());
+      app.setVersion(fromVersion2dot0.getApplication().getVersion());
+
+      // command order
+      if (fromVersion2dot0.getApplication().getCommandOrder() != null) {
+        for 
(org.apache.slider.providers.agent.application.metadata.CommandOrder xmlCo :
+            fromVersion2dot0.getApplication().getCommandOrder()) {
+          CommandOrder co = new CommandOrder();
+          co.setCommand(xmlCo.getCommand());
+          co.setRequires(xmlCo.getRequires());
+          app.getCommandOrders().add(co);
+        }
+      }
+
+      // packages
+      if (fromVersion2dot0.getApplication().getOSSpecifics() != null) {
+        for (org.apache.slider.providers.agent.application.metadata.OSSpecific 
xmlOSS :
+            fromVersion2dot0.getApplication().getOSSpecifics()) {
+          for 
(org.apache.slider.providers.agent.application.metadata.OSPackage xmlOSP : 
xmlOSS.getPackages()) {
+            Package pkg = new Package();
+            pkg.setName(xmlOSP.getName());
+            pkg.setType(xmlOSP.getType());
+            app.getPackages().add(pkg);
+          }
+        }
+      }
+
+      // export
+      if (fromVersion2dot0.getApplication().getExportGroups() != null) {
+        for 
(org.apache.slider.providers.agent.application.metadata.ExportGroup xmlEg :
+            fromVersion2dot0.getApplication().getExportGroups()) {
+          ExportGroup eg = new ExportGroup();
+          eg.setName(xmlEg.getName());
+          app.getExportGroups().add(eg);
+          for (org.apache.slider.providers.agent.application.metadata.Export 
xmlEx :
+              xmlEg.getExports()) {
+            Export exp = new Export();
+            exp.setName(xmlEx.getName());
+            exp.setValue(xmlEx.getValue());
+            eg.getExports().add(exp);
+          }
+        }
+      }
+
+      // config file
+      if (fromVersion2dot0.getApplication().getConfigFiles() != null) {
+        for (org.apache.slider.providers.agent.application.metadata.ConfigFile 
xmlConf :
+            fromVersion2dot0.getApplication().getConfigFiles()) {
+          ConfigFile conf = new ConfigFile();
+          conf.setDictionaryName(xmlConf.getDictionaryName());
+          conf.setFileName(xmlConf.getFileName());
+          conf.setType(xmlConf.getType());
+          app.getConfigFiles().add(conf);
+        }
+      }
+
+      // component
+      if (fromVersion2dot0.getApplication().getComponents() != null) {
+        for (org.apache.slider.providers.agent.application.metadata.Component 
xmlComp :
+            fromVersion2dot0.getApplication().getComponents()) {
+          Component comp = new Component();
+          comp.setAppExports(xmlComp.getAppExports());
+          comp.setAutoStartOnFailure(xmlComp.getRequiresAutoRestart());
+          comp.setCategory(xmlComp.getCategory());
+          comp.setCompExports(xmlComp.getCompExports());
+          comp.setMaxInstanceCount(xmlComp.getMaxInstanceCountInt());
+          comp.setMinInstanceCount(xmlComp.getMinInstanceCountInt());
+          comp.setName(xmlComp.getName());
+          comp.setPublishConfig(xmlComp.getPublishConfig());
+          if(xmlComp.getCommandScript() != null) {
+            CommandScript commandScript = new CommandScript();
+            commandScript.setScript(xmlComp.getCommandScript().getScript());
+            
commandScript.setScriptType(xmlComp.getCommandScript().getScriptType());
+            commandScript.setTimeout(xmlComp.getCommandScript().getTimeout());
+            comp.setCommandScript(commandScript);
+          }
+        }
+      }
+
+    }
+    return metaInfo;
+  }
+
+  public Component getApplicationComponent(String roleName) {
+    if (application == null) {
+      log.error("Malformed app definition: Expect application as the top level 
element for metainfo");
+    } else {
+      for (Component component : application.getComponents()) {
+        if (component.getName().equals(roleName)) {
+          return component;
+        }
+      }
+    }
+    return null;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a31d20ee/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/MetaInfoParser.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/MetaInfoParser.java
 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/MetaInfoParser.java
new file mode 100644
index 0000000..f821b82
--- /dev/null
+++ 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/MetaInfoParser.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.slider.providers.agent.application.metadata.json;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+
+/**
+ * Represents the metadata associated with the application.
+ */
+public class MetaInfoParser {
+  protected static final Logger
+      log = LoggerFactory.getLogger(MetaInfoParser.class);
+
+  private final GsonBuilder gsonBuilder = new GsonBuilder();
+  private Gson gson;
+
+  /**
+   * Creator.
+   */
+  public MetaInfoParser() {
+    gson = gsonBuilder.create();
+  }
+
+
+  /**
+   * Convert to a JSON string
+   *
+   * @return a JSON string description
+   *
+   * @throws IOException Problems mapping/writing the object
+   */
+  public String toJsonString(MetaInfo metaInfo) throws IOException {
+    return gson.toJson(metaInfo);
+  }
+
+  /**
+   * Convert from JSON
+   *
+   * @param json input
+   *
+   * @return the parsed JSON
+   *
+   * @throws IOException IO
+   */
+  public MetaInfo fromJsonString(String json)
+      throws IOException {
+    return gson.fromJson(json, MetaInfo.class);
+  }
+
+  /**
+   * Parse metainfo from an IOStream
+   * @param is
+   * @return
+   * @throws IOException
+   */
+  public MetaInfo fromInputStream(InputStream is) throws IOException {
+    StringWriter writer = new StringWriter();
+    IOUtils.copy(is, writer);
+    return fromJsonString(writer.toString());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a31d20ee/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/Package.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/Package.java
 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/Package.java
new file mode 100644
index 0000000..b9bddd6
--- /dev/null
+++ 
b/slider-core/src/main/java/org/apache/slider/providers/agent/application/metadata/json/Package.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.slider.providers.agent.application.metadata.json;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Represents package description.
+ */
+public class Package {
+  protected static final Logger
+      log = LoggerFactory.getLogger(Package.class);
+
+
+  private String name;
+  private String type;
+
+  public Package() {
+  }
+
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public String getType() {
+    return type;
+  }
+
+  public void setType(String type) {
+    this.type = type;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a31d20ee/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
----------------------------------------------------------------------
diff --git 
a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
 
b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
index d96886a..c3f52e7 100644
--- 
a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
+++ 
b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
@@ -97,7 +97,7 @@ class TestWindowsSupport extends YarnMiniClusterTestBase {
     assumeWindows()
     SliderFileSystem sfs = new SliderFileSystem(new Configuration())
     try {
-      def metainfo = AgentUtils.getApplicationMetainfo(sfs, windowsFile)
+      def metainfo = AgentUtils.getApplicationMetaInfo(sfs, windowsFile)
     } catch (FileNotFoundException fnfe) {
       // expected
     }

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a31d20ee/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentClientProvider2.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentClientProvider2.java
 
b/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentClientProvider2.java
index 1e4d834..466b300 100644
--- 
a/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentClientProvider2.java
+++ 
b/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentClientProvider2.java
@@ -30,10 +30,9 @@ import org.apache.slider.core.conf.ConfTree;
 import org.apache.slider.core.exceptions.BadCommandArgumentsException;
 import org.apache.slider.core.exceptions.SliderException;
 import org.apache.slider.providers.ProviderUtils;
-import org.apache.slider.providers.agent.application.metadata.Application;
-import org.apache.slider.providers.agent.application.metadata.Metainfo;
-import org.apache.slider.providers.agent.application.metadata.OSPackage;
-import org.apache.slider.providers.agent.application.metadata.OSSpecific;
+import org.apache.slider.providers.agent.application.metadata.json.Application;
+import org.apache.slider.providers.agent.application.metadata.json.MetaInfo;
+import org.apache.slider.providers.agent.application.metadata.json.Package;
 import org.codehaus.jettison.json.JSONObject;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -121,16 +120,13 @@ public class TestAgentClientProvider2 {
     global.put("d", "{app_install_dir}/d");
     inputConfig.put("global", global);
 
-    Metainfo metainfo = new Metainfo();
+    MetaInfo metainfo = new MetaInfo();
     Application app = new Application();
     metainfo.setApplication(app);
-    OSSpecific osSpecific = new OSSpecific();
-    osSpecific.setOsType("any");
-    app.addOSSpecific(osSpecific);
-    OSPackage pkg = new OSPackage();
-    osSpecific.addOSPackage(pkg);
+    Package pkg = new Package();
     pkg.setName("app.tar");
     pkg.setType("tarball");
+    app.getPackages().add(pkg);
 
     File clientInstallPath = new File("/tmp/file1");
 

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a31d20ee/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentProviderService.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentProviderService.java
 
b/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentProviderService.java
index 38e7db1..0324af4 100644
--- 
a/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentProviderService.java
+++ 
b/slider-core/src/test/java/org/apache/slider/providers/agent/TestAgentProviderService.java
@@ -48,16 +48,17 @@ import org.apache.slider.core.registry.docstore.ExportEntry;
 import org.apache.slider.core.registry.docstore.PublishedExports;
 import org.apache.slider.core.registry.docstore.PublishedExportsSet;
 import org.apache.slider.providers.ProviderRole;
-import org.apache.slider.providers.agent.application.metadata.Application;
-import org.apache.slider.providers.agent.application.metadata.CommandOrder;
-import org.apache.slider.providers.agent.application.metadata.CommandScript;
-import org.apache.slider.providers.agent.application.metadata.Component;
+import org.apache.slider.providers.agent.application.metadata.json.Application;
+import 
org.apache.slider.providers.agent.application.metadata.json.CommandOrder;
+import 
org.apache.slider.providers.agent.application.metadata.json.CommandScript;
+import org.apache.slider.providers.agent.application.metadata.json.Component;
 import org.apache.slider.providers.agent.application.metadata.ComponentExport;
-import org.apache.slider.providers.agent.application.metadata.ConfigFile;
+import org.apache.slider.providers.agent.application.metadata.json.ConfigFile;
 import org.apache.slider.providers.agent.application.metadata.DefaultConfig;
-import org.apache.slider.providers.agent.application.metadata.Export;
-import org.apache.slider.providers.agent.application.metadata.ExportGroup;
-import org.apache.slider.providers.agent.application.metadata.Metainfo;
+import org.apache.slider.providers.agent.application.metadata.json.Export;
+import org.apache.slider.providers.agent.application.metadata.json.ExportGroup;
+import org.apache.slider.providers.agent.application.metadata.json.MetaInfo;
+import 
org.apache.slider.providers.agent.application.metadata.json.MetaInfoParser;
 import org.apache.slider.providers.agent.application.metadata.MetainfoParser;
 import org.apache.slider.providers.agent.application.metadata.PropertyInfo;
 import org.apache.slider.server.appmaster.model.mock.MockRegistryOperations;
@@ -264,7 +265,7 @@ public class TestAgentProviderService {
                                                + "</metainfo>";
 
   @Test
-  public void testRegistration() throws IOException {
+  public void testRegistration() throws Exception {
 
     ConfTree tree = new ConfTree();
     tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, ".");
@@ -303,7 +304,7 @@ public class TestAgentProviderService {
     CommandScript cs = new CommandScript();
     cs.setScript("scripts/hbase_master.py");
     doReturn(cs).when(mockAps).getScriptPathFromMetainfo(anyString());
-    Metainfo metainfo = new Metainfo();
+    MetaInfo metainfo = new MetaInfo();
     metainfo.setApplication(new Application());
     
doReturn(metainfo).when(mockAps).getApplicationMetainfo(any(SliderFileSystem.class),
 anyString());
 
@@ -422,7 +423,7 @@ public class TestAgentProviderService {
   }
 
   private AgentProviderService prepareProviderServiceForAgentStateTests()
-      throws IOException {
+      throws Exception {
     ContainerLaunchContext ctx = createNiceMock(ContainerLaunchContext.class);
     Container container = createNiceMock(Container.class);
     String role = "HBASE_MASTER";
@@ -450,12 +451,12 @@ public class TestAgentProviderService {
     cs.setScript("scripts/hbase_master.py");
     doReturn(cs).when(mockAps)
         .getScriptPathFromMetainfo(anyString());
-    Metainfo metainfo = new Metainfo();
+    MetaInfo metainfo = new MetaInfo();
     Application application = new Application();
     metainfo.setApplication(application);
     doReturn(metainfo).when(mockAps).getApplicationMetainfo(
         any(SliderFileSystem.class), anyString());
-    doReturn(metainfo).when(mockAps).getMetainfo();
+    doReturn(metainfo).when(mockAps).getMetaInfo();
 
 
 
@@ -502,7 +503,7 @@ public class TestAgentProviderService {
   @Test
   public void testThreeInstallFailures() throws IOException, SliderException {
     InputStream metainfo_1 = new 
ByteArrayInputStream(metainfo_1_str.getBytes());
-    Metainfo metainfo = new MetainfoParser().parse(metainfo_1);
+    MetaInfo metainfo = MetaInfo.upConverted(new 
MetainfoParser().parse(metainfo_1));
     ConfTree tree = new ConfTree();
     tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, ".");
 
@@ -543,7 +544,7 @@ public class TestAgentProviderService {
     doReturn(access).when(mockAps).getAmState();
     
doReturn(metainfo).when(mockAps).getApplicationMetainfo(any(SliderFileSystem.class),
 anyString());
     doReturn(new HashMap<String, DefaultConfig>()).when(mockAps).
-        initializeDefaultConfigs(any(SliderFileSystem.class), anyString(), 
any(Metainfo.class));
+        initializeDefaultConfigs(any(SliderFileSystem.class), anyString(), 
any(MetaInfo.class));
 
 
     try {
@@ -630,7 +631,7 @@ public class TestAgentProviderService {
   }
 
   @Test
-  public void testAgentStateStarted() throws IOException, SliderException {
+  public void testAgentStateStarted() throws Exception, SliderException {
     AggregateConf instanceDefinition = prepareConfForAgentStateTests();
     AgentProviderService mockAps = prepareProviderServiceForAgentStateTests();
     Register reg = new Register();
@@ -683,20 +684,20 @@ public class TestAgentProviderService {
   }
 
   @Test
-  public void testAgentStateInstalled() throws IOException, SliderException {
+  public void testAgentStateInstalled() throws Exception, SliderException {
     AggregateConf instanceDefinition = prepareConfForAgentStateTests();
     AgentProviderService mockAps = prepareProviderServiceForAgentStateTests();
 
-    Metainfo metainfo = new Metainfo();
+    MetaInfo metainfo = new MetaInfo();
     Application application = new Application();
     CommandOrder cmdOrder = new CommandOrder();
     cmdOrder.setCommand("HBASE_MASTER-START");
     cmdOrder.setRequires("HBASE_MASTER-INSTALLED");
-    application.addCommandOrder(cmdOrder);
+    application.getCommandOrders().add(cmdOrder);
     metainfo.setApplication(application);
     doReturn(metainfo).when(mockAps).getApplicationMetainfo(
         any(SliderFileSystem.class), anyString());
-    doReturn(metainfo).when(mockAps).getMetainfo();
+    doReturn(metainfo).when(mockAps).getMetaInfo();
     doNothing().when(mockAps).addRoleRelatedTokens(anyMap());
 
     Register reg = new Register();
@@ -807,54 +808,15 @@ public class TestAgentProviderService {
     aps.close();
   }
 
-  @Test
-  public void testComponentSpecificPublishes() throws Exception {
-    InputStream metainfo_1 = new 
ByteArrayInputStream(metainfo_1_str.getBytes());
-    Metainfo metainfo = new MetainfoParser().parse(metainfo_1);
-    AgentProviderService aps = createAgentProviderService(new Configuration());
-    AgentProviderService mockAps = Mockito.spy(aps);
-    doNothing().when(mockAps).publishApplicationInstanceData(anyString(), 
anyString(), anyCollection());
-    doReturn(metainfo).when(mockAps).getMetainfo();
-
-    Map<String, String> ports = new HashMap<String, String>();
-    ports.put("global.listen_port", "10010");
-    mockAps.processAndPublishComponentSpecificData(ports,
-                                                   "cid1",
-                                                   "host1",
-                                                   "HBASE_REGIONSERVER");
-    ArgumentCaptor<Collection> entriesCaptor = ArgumentCaptor.
-        forClass(Collection.class);
-    ArgumentCaptor<String> publishNameCaptor = ArgumentCaptor.
-        forClass(String.class);
-    Mockito.verify(mockAps, Mockito.times(1)).publishApplicationInstanceData(
-        anyString(),
-        publishNameCaptor.capture(),
-        entriesCaptor.capture());
-    assert entriesCaptor.getAllValues().size() == 1;
-    for (Collection coll : entriesCaptor.getAllValues()) {
-      Set<Map.Entry<String, String>> entrySet = (Set<Map.Entry<String, 
String>>) coll;
-      for (Map.Entry entry : entrySet) {
-        log.info("{}:{}", entry.getKey(), entry.getValue().toString());
-        if (entry.getKey().equals("PropertyA")) {
-          assert entry.getValue().toString().equals("host1:10010");
-        }
-      }
-    }
-    assert publishNameCaptor.getAllValues().size() == 1;
-    for (String coll : publishNameCaptor.getAllValues()) {
-      assert coll.equals("ComponentInstanceData");
-    }
-  }
-
 
   @Test
   public void testComponentSpecificPublishes2() throws Exception {
     InputStream metainfo_1 = new 
ByteArrayInputStream(metainfo_1_str.getBytes());
-    Metainfo metainfo = new MetainfoParser().parse(metainfo_1);
+    MetaInfo metainfo = MetaInfo.upConverted(new 
MetainfoParser().parse(metainfo_1));
     AgentProviderService aps = createAgentProviderService(new Configuration());
     AgentProviderService mockAps = Mockito.spy(aps);
     doNothing().when(mockAps).publishApplicationInstanceData(anyString(), 
anyString(), anyCollection());
-    doReturn(metainfo).when(mockAps).getMetainfo();
+    doReturn(metainfo).when(mockAps).getMetaInfo();
     StateAccessForProviders access = 
createNiceMock(StateAccessForProviders.class);
     doReturn(access).when(mockAps).getAmState();
     PublishedExportsSet pubExpSet = new PublishedExportsSet();
@@ -935,7 +897,7 @@ public class TestAgentProviderService {
   @Test
   public void testProcessConfig() throws Exception {
     InputStream metainfo_1 = new 
ByteArrayInputStream(metainfo_1_str.getBytes());
-    Metainfo metainfo = new MetainfoParser().parse(metainfo_1);
+    MetaInfo metainfo = MetaInfo.upConverted(new 
MetainfoParser().parse(metainfo_1));
     Assert.assertNotNull(metainfo.getApplication());
     AgentProviderService aps = createAgentProviderService(new Configuration());
     HeartBeat hb = new HeartBeat();
@@ -964,7 +926,7 @@ public class TestAgentProviderService {
         new MockContainerId(1), "cid");
     AgentProviderService mockAps = Mockito.spy(aps);
     doNothing().when(mockAps).publishApplicationInstanceData(anyString(), 
anyString(), anyCollection());
-    doReturn(metainfo).when(mockAps).getMetainfo();
+    doReturn(metainfo).when(mockAps).getMetaInfo();
     doReturn(roleClusterNodeMap).when(mockAps).getRoleClusterNodeMapping();
     StateAccessForProviders access = 
createNiceMock(StateAccessForProviders.class);
     doReturn(access).when(mockAps).getAmState();
@@ -1018,9 +980,9 @@ public class TestAgentProviderService {
   }
 
   @Test
-  public void testMetainfoParsing() throws Exception {
+  public void testMetaInfoParsing() throws Exception {
     InputStream metainfo_1 = new 
ByteArrayInputStream(metainfo_1_str.getBytes());
-    Metainfo metainfo = new MetainfoParser().parse(metainfo_1);
+    MetaInfo metainfo = MetaInfo.upConverted(new 
MetainfoParser().parse(metainfo_1));
     Assert.assertNotNull(metainfo.getApplication());
     Application application = metainfo.getApplication();
     log.info("Service: " + application.toString());
@@ -1032,31 +994,22 @@ public class TestAgentProviderService {
     for (Component component : components) {
       if (component.getName().equals("HBASE_MASTER")) {
         Assert.assertEquals(component.getAutoStartOnFailure(), "true");
-        Assert.assertEquals(component.getRequiresAutoRestart(), Boolean.TRUE);
+        Assert.assertEquals(component.getAutoStartOnFailure(), Boolean.TRUE);
         Assert.assertEquals(component.getMinInstanceCount(), "1");
         Assert.assertEquals(component.getMaxInstanceCount(), "2");
         Assert.assertEquals(component.getCommandScript().getScript(), 
"scripts/hbase_master.py");
         Assert.assertEquals(component.getCategory(), "MASTER");
-        Assert.assertEquals(component.getComponentExports().size(), 0);
         Assert.assertEquals(component.getAppExports(), 
"QuickLinks-JMX_Endpoint,QuickLinks-Master_Status");
         Assert.assertEquals(component.getCompExports(), 
"QuickLinks-Comp_Endpoint");
         found++;
       }
       if (component.getName().equals("HBASE_REGIONSERVER")) {
         Assert.assertEquals(component.getAutoStartOnFailure(), "Falsee");
-        Assert.assertEquals(component.getRequiresAutoRestart(), Boolean.FALSE);
+        Assert.assertEquals(component.getAutoStartOnFailure(), Boolean.FALSE);
         Assert.assertEquals(component.getMinInstanceCount(), "1");
         Assert.assertNull(component.getMaxInstanceCount());
         Assert.assertEquals(component.getCommandScript().getScript(), 
"scripts/hbase_regionserver.py");
         Assert.assertEquals(component.getCategory(), "SLAVE");
-        Assert.assertEquals(component.getComponentExports().size(), 2);
-        List<ComponentExport> es = component.getComponentExports();
-        ComponentExport e = es.get(0);
-        Assert.assertEquals(e.getName(), "PropertyA");
-        Assert.assertEquals(e.getValue(), 
"${THIS_HOST}:${site.global.listen_port}");
-        e = es.get(1);
-        Assert.assertEquals(e.getName(), "PropertyB");
-        Assert.assertEquals(e.getValue(), "AConstant");
         found++;
       }
     }
@@ -1083,10 +1036,10 @@ public class TestAgentProviderService {
     }
     Assert.assertEquals(found, 2);
 
-    List<CommandOrder> cmdOrders = application.getCommandOrder();
+    List<CommandOrder> cmdOrders = application.getCommandOrders();
     Assert.assertEquals(cmdOrders.size(), 2);
     found = 0;
-    for (CommandOrder co : application.getCommandOrder()) {
+    for (CommandOrder co : application.getCommandOrders()) {
       if (co.getCommand().equals("HBASE_REGIONSERVER-START")) {
         Assert.assertTrue(co.getRequires().equals("HBASE_MASTER-STARTED"));
         found++;
@@ -1117,7 +1070,7 @@ public class TestAgentProviderService {
 
     AgentProviderService aps = createAgentProviderService(new Configuration());
     AgentProviderService mockAps = Mockito.spy(aps);
-    doReturn(metainfo).when(mockAps).getMetainfo();
+    doReturn(metainfo).when(mockAps).getMetaInfo();
     CommandScript script = mockAps.getScriptPathFromMetainfo("HBASE_MASTER");
     Assert.assertEquals(script.getScript(), "scripts/hbase_master.py");
 
@@ -1131,25 +1084,25 @@ public class TestAgentProviderService {
                                 + "      </comment>\n";
 
     metainfo_1 = new ByteArrayInputStream(metainfo_1_str_bad.getBytes());
-    metainfo = new MetainfoParser().parse(metainfo_1);
+    metainfo = MetaInfo.upConverted(new MetainfoParser().parse(metainfo_1));
     Assert.assertNull(metainfo);
   }
 
   @Test
   public void testMetaInfoRelatedOperations() throws Exception {
     InputStream metainfo_1 = new 
ByteArrayInputStream(metainfo_1_str.getBytes());
-    Metainfo metainfo = new MetainfoParser().parse(metainfo_1);
+    MetaInfo metainfo = MetaInfo.upConverted(new 
MetainfoParser().parse(metainfo_1));
     InputStream metainfo_2 = new 
ByteArrayInputStream(metainfo_2_str.getBytes());
-    Metainfo metainfo2 = new MetainfoParser().parse(metainfo_2);
+    MetaInfo metainfo2 = MetaInfo.upConverted(new 
MetainfoParser().parse(metainfo_2));
     String role_hm = "HBASE_MASTER";
     String role_hrs = "HBASE_REGIONSERVER";
 
     AgentProviderService aps1 = createAgentProviderService(new 
Configuration());
     AgentProviderService mockAps = Mockito.spy(aps1);
-    doReturn(metainfo).when(mockAps).getMetainfo();
+    doReturn(metainfo).when(mockAps).getMetaInfo();
 
     AgentProviderService mockAps2 = Mockito.spy(aps1);
-    doReturn(metainfo2).when(mockAps2).getMetainfo();
+    doReturn(metainfo2).when(mockAps2).getMetaInfo();
 
     Assert.assertTrue(mockAps.isMaster(role_hm));
     Assert.assertFalse(mockAps.isMaster(role_hrs));
@@ -1165,11 +1118,11 @@ public class TestAgentProviderService {
   }
 
   @Test
-  public void testOrchestratedAppStart() throws IOException {
+  public void testOrchestratedAppStart() throws Exception {
     // App has two components HBASE_MASTER and HBASE_REGIONSERVER
     // Start of HBASE_RS depends on the start of HBASE_MASTER
     InputStream metainfo_1 = new 
ByteArrayInputStream(metainfo_1_str.getBytes());
-    Metainfo metainfo = new MetainfoParser().parse(metainfo_1);
+    MetaInfo metainfo = MetaInfo.upConverted(new 
MetainfoParser().parse(metainfo_1));
     ConfTree tree = new ConfTree();
     tree.global.put(InternalKeys.INTERNAL_APPLICATION_IMAGE_PATH, ".");
 
@@ -1212,7 +1165,7 @@ public class TestAgentProviderService {
     doReturn(access).when(mockAps).getAmState();
     
doReturn(metainfo).when(mockAps).getApplicationMetainfo(any(SliderFileSystem.class),
 anyString());
     doReturn(new HashMap<String, DefaultConfig>()).when(mockAps).
-        initializeDefaultConfigs(any(SliderFileSystem.class), anyString(), 
any(Metainfo.class));
+        initializeDefaultConfigs(any(SliderFileSystem.class), anyString(), 
any(MetaInfo.class));
 
 
     try {
@@ -1542,7 +1495,7 @@ public class TestAgentProviderService {
   @Test
   public void testAddInstallCommand() throws Exception {
     InputStream metainfo_1 = new 
ByteArrayInputStream(metainfo_1_str.getBytes());
-    Metainfo metainfo = new MetainfoParser().parse(metainfo_1);
+    MetaInfo metainfo = MetaInfo.upConverted(new 
MetainfoParser().parse(metainfo_1));
     AgentProviderService aps = createAgentProviderService(new Configuration());
     HeartBeatResponse hbr = new HeartBeatResponse();
 
@@ -1563,7 +1516,7 @@ public class TestAgentProviderService {
     expect(access.isApplicationLive()).andReturn(true).anyTimes();
 
     doReturn("HOST1").when(mockAps).getClusterInfoPropertyValue(anyString());
-    doReturn(metainfo).when(mockAps).getMetainfo();
+    doReturn(metainfo).when(mockAps).getMetaInfo();
     doReturn(new HashMap<String, 
DefaultConfig>()).when(mockAps).getDefaultConfigs();
 
     Map<String, Map<String, ClusterNode>> roleClusterNodeMap = new 
HashMap<String, Map<String, ClusterNode>>();

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a31d20ee/slider-core/src/test/java/org/apache/slider/providers/agent/TestComponentCommandOrder.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/test/java/org/apache/slider/providers/agent/TestComponentCommandOrder.java
 
b/slider-core/src/test/java/org/apache/slider/providers/agent/TestComponentCommandOrder.java
index c123fbb..bac1158 100644
--- 
a/slider-core/src/test/java/org/apache/slider/providers/agent/TestComponentCommandOrder.java
+++ 
b/slider-core/src/test/java/org/apache/slider/providers/agent/TestComponentCommandOrder.java
@@ -18,7 +18,7 @@
 
 package org.apache.slider.providers.agent;
 
-import org.apache.slider.providers.agent.application.metadata.CommandOrder;
+import 
org.apache.slider.providers.agent.application.metadata.json.CommandOrder;
 import org.apache.slider.server.appmaster.model.mock.MockContainerId;
 import org.junit.Assert;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a31d20ee/slider-core/src/test/java/org/apache/slider/providers/agent/application/metadata/json/TestMetaInfoParser.java
----------------------------------------------------------------------
diff --git 
a/slider-core/src/test/java/org/apache/slider/providers/agent/application/metadata/json/TestMetaInfoParser.java
 
b/slider-core/src/test/java/org/apache/slider/providers/agent/application/metadata/json/TestMetaInfoParser.java
new file mode 100644
index 0000000..3648a29
--- /dev/null
+++ 
b/slider-core/src/test/java/org/apache/slider/providers/agent/application/metadata/json/TestMetaInfoParser.java
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.slider.providers.agent.application.metadata.json;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ *
+ */
+public class TestMetaInfoParser {
+  protected static final Logger log =
+      LoggerFactory.getLogger(TestMetaInfoParser.class);
+
+  @Test
+  public void testParse() throws IOException {
+    String metaInfo1_json = "{\n"
+                            + "\"schemaVersion\":\"2.2\",\n"
+                            + "\"application\":{\n"
+                            +     "\"name\": \"MEMCACHED\","
+                            +     "\"exportGroups\": ["
+                            +        "{"
+                            +          "\"name\": \"Servers\","
+                            +          "\"exports\": ["
+                            +            "{"
+                            +               "\"name\": \"host_port\","
+                            +               "\"value\": 
\"${MEMCACHED_HOST}:${site.global.port}\""
+                            +            "}"
+                            +          "]"
+                            +        "}"
+                            +      "],"
+                            +     "\"components\": ["
+                            +        "{"
+                            +          "\"name\": \"MEMCACHED\","
+                            +          "\"compExports\": 
\"Servers-host_port\","
+                            +          "\"commands\": ["
+                            +            "{"
+                            +               "\"exec\": \"java -classpath 
/usr/myapps/memcached/*:/usr/lib/hadoop/lib/* com.thimbleware.jmemcached.Main\""
+                            +            "}"
+                            +          "]"
+                            +        "},"
+                            +        "{"
+                            +          "\"name\": \"MEMCACHED2\","
+                            +          "\"commands\": ["
+                            +            "{"
+                            +               "\"exec\": \"scripts/config.py\","
+                            +               "\"type\": \"PYTHON\","
+                            +               "\"name\": \"CONFIGURE\""
+                            +            "}"
+                            +          "]"
+                            +        "}"
+                            +      "]"
+                            +   "}"
+                            + "}";
+
+    MetaInfoParser parser = new MetaInfoParser();
+    MetaInfo mInfo = parser.fromJsonString(metaInfo1_json);
+    Assert.assertEquals("2.2", mInfo.getSchemaVersion());
+
+    Application app = mInfo.getApplication();
+    Assert.assertNotNull(app);
+
+    Assert.assertEquals("MEMCACHED", app.getName());
+    List<ExportGroup> egs = app.getExportGroups();
+    Assert.assertEquals(1, egs.size());
+    ExportGroup eg = egs.get(0);
+    Assert.assertEquals("Servers", eg.getName());
+    List<Export> exports = eg.getExports();
+    Assert.assertEquals(1, exports.size());
+    Export export = exports.get(0);
+    Assert.assertEquals("host_port", export.getName());
+    Assert.assertEquals("${MEMCACHED_HOST}:${site.global.port}", 
export.getValue());
+
+    List<Component> components = app.getComponents();
+    Assert.assertEquals(2, components.size());
+
+    Component c1 = app.getApplicationComponent("MEMCACHED");
+    Assert.assertNotNull(c1);
+    Assert.assertEquals("MEMCACHED", c1.getName());
+    Assert.assertEquals("Servers-host_port", c1.getCompExports());
+    Assert.assertEquals(1, c1.getCommands().size());
+    ComponentCommand cmd = c1.getCommands().get(0);
+    Assert.assertEquals("START", cmd.getName());
+    Assert.assertEquals("SHELL", cmd.getType());
+    Assert.assertEquals("java -classpath 
/usr/myapps/memcached/*:/usr/lib/hadoop/lib/* com.thimbleware.jmemcached.Main", 
cmd.getExec());
+
+    Component c2 = app.getApplicationComponent("MEMCACHED2");
+    Assert.assertNotNull(c2);
+    Assert.assertEquals("MEMCACHED2", c2.getName());
+    Assert.assertEquals(1, c2.getCommands().size());
+    cmd = c2.getCommands().get(0);
+    Assert.assertEquals("CONFIGURE", cmd.getName());
+    Assert.assertEquals("PYTHON", cmd.getType());
+    Assert.assertEquals("scripts/config.py", cmd.getExec());
+  }
+}

Reply via email to