Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.Yaml


public class MyTaskAppSpecFactory implements ApplicationSpecFactory {

  @Override
  public ApplicationSpec fromYaml(InputStream inputstream) {
    return (ApplicationSpec) new Yaml().load(inputstream);
    // return data;
  }
View Full Code Here


    // return data;
  }

  public static void main(String[] args) {

    Yaml yaml = new Yaml();
    InputStream resourceAsStream =
        ClassLoader.getSystemClassLoader().getResourceAsStream("job_runner_app_spec.yaml");
    MyTaskAppSpec spec = yaml.loadAs(resourceAsStream, MyTaskAppSpec.class);
    String dump = yaml.dump(spec);
    System.out.println(dump);
    System.out.println(spec.getServiceConfig("JobRunner").getStringField("num_containers", "1"));

  }
View Full Code Here

   * @param input InputStream representing the file
   * @return ClusterConfig Java wrapper of the configuration file
   */
  public YAMLClusterConfig setupCluster(InputStream input) {
    // parse the YAML
    Yaml yaml = new Yaml();
    YAMLClusterConfig cfg = yaml.loadAs(input, YAMLClusterConfig.class);

    // create the cluster
    HelixAdmin helixAdmin = new ZKHelixAdmin(_zkAddress);
    if (cfg.clusterName == null) {
      throw new HelixException("Cluster name is required!");
View Full Code Here

   * Read a workflow from an open input stream
   * @param inputStream the stream
   * @return Workflow
   */
  public static Workflow parse(InputStream inputStream) {
    Yaml yaml = new Yaml(new Constructor(WorkflowBean.class));
    WorkflowBean wf = (WorkflowBean) yaml.load(inputStream);
    return parse(wf);
  }
View Full Code Here

    return parse(wf);
  }

  /** Helper function to parse workflow from a generic {@link Reader} */
  private static Workflow parse(Reader reader) throws Exception {
    Yaml yaml = new Yaml(new Constructor(WorkflowBean.class));
    WorkflowBean wf = (WorkflowBean) yaml.load(reader);
    return parse(wf);
  }
View Full Code Here

        {
            byte[] profileBytes = Files.readAllBytes(Paths.get(file.toURI()));

            Constructor constructor = new Constructor(StressYaml.class);

            Yaml yaml = new Yaml(constructor);

            StressYaml profileYaml = yaml.loadAs(new ByteArrayInputStream(profileBytes), StressYaml.class);

            StressProfile profile = new StressProfile();
            profile.init(profileYaml);

            return profile;
View Full Code Here

        try
        {
            final Constructor constructor = new Constructor(CliUserHelp.class);
            TypeDescription desc = new TypeDescription(CliUserHelp.class);
            desc.putListPropertyType("commands", CliCommandHelp.class);
            final Yaml yaml = new Yaml(new Loader(constructor));
            return (CliUserHelp) yaml.load(is);
        }
        finally
        {
            FileUtils.closeQuietly(is);
        }
View Full Code Here

            }
            org.yaml.snakeyaml.constructor.Constructor constructor = new org.yaml.snakeyaml.constructor.Constructor(Config.class);
            TypeDescription seedDesc = new TypeDescription(SeedProviderDef.class);
            seedDesc.putMapPropertyType("parameters", String.class, String.class);
            constructor.addTypeDescription(seedDesc);
            Yaml yaml = new Yaml(new Loader(constructor));
            conf = (Config)yaml.load(input);

            if (!System.getProperty("os.arch").contains("64"))
                logger.info("32bit JVM detected.  It is recommended to run Cassandra on a 64bit JVM for better performance.");

            if (conf.commitlog_sync == null)
View Full Code Here

        try
        {
            final Constructor constructor = new Constructor(CliUserHelp.class);
            TypeDescription desc = new TypeDescription(CliUserHelp.class);
            desc.putListPropertyType("commands", CliCommandHelp.class);
            final Yaml yaml = new Yaml(new Loader(constructor));
            return (CliUserHelp)yaml.load(is);
        }
        finally
        {
            try
            {
View Full Code Here

        /* Use Tag.MAP to avoid the class name being included as global tag */
        representer.addClassTag(RawColumnFamily.class, Tag.MAP);
        representer.addClassTag(Keyspaces.class, Tag.MAP);
        representer.addClassTag(ColumnDefinition.class, Tag.MAP);
        Dumper dumper = new Dumper(representer, options);
        Yaml yaml = new Yaml(dumper);
        Keyspaces ks = new Keyspaces();
        ks.keyspaces = keyspaces;
        return yaml.dump(ks);
    }
View Full Code Here

TOP

Related Classes of org.yaml.snakeyaml.Yaml

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.