Search in sources :

Example 1 with Yaml

use of org.yaml.snakeyaml.Yaml in project pinot by linkedin.

the class PerfBenchmarkDriverConf method main.

public static void main(String[] args) {
    DumperOptions options = new DumperOptions();
    options.setIndent(4);
    options.setDefaultFlowStyle(FlowStyle.BLOCK);
    Yaml yaml = new Yaml(options);
    String dump = yaml.dump(new PerfBenchmarkDriverConf());
    System.out.println(dump);
}
Also used : DumperOptions(org.yaml.snakeyaml.DumperOptions) Yaml(org.yaml.snakeyaml.Yaml)

Example 2 with Yaml

use of org.yaml.snakeyaml.Yaml in project storm by apache.

the class FluxParser method parseInputStream.

public static TopologyDef parseInputStream(InputStream inputStream, boolean dumpYaml, boolean processIncludes, String propertiesFile, boolean envSub) throws IOException {
    Yaml yaml = yaml();
    if (inputStream == null) {
        LOG.error("Unable to load input stream");
        System.exit(1);
    }
    TopologyDef topology = loadYaml(yaml, inputStream, propertiesFile, envSub);
    if (dumpYaml) {
        dumpYaml(topology, yaml);
    }
    if (processIncludes) {
        return processIncludes(yaml, topology, propertiesFile, envSub);
    } else {
        return topology;
    }
}
Also used : TopologyDef(org.apache.storm.flux.model.TopologyDef) Yaml(org.yaml.snakeyaml.Yaml)

Example 3 with Yaml

use of org.yaml.snakeyaml.Yaml in project sharding-jdbc by dangdangdotcom.

the class BestEffortsDeliveryJobMain method main.

/**
     * 启动入口.
     * 
     * @param args 启动参数
     */
// CHECKSTYLE:OFF
public static void main(final String[] args) throws Exception {
    // CHECKSTYLE:ON
    try (InputStreamReader inputStreamReader = new InputStreamReader(BestEffortsDeliveryJobMain.class.getResourceAsStream("/conf/config.yaml"), "UTF-8")) {
        BestEffortsDeliveryConfiguration config = new Yaml(new Constructor(BestEffortsDeliveryConfiguration.class)).loadAs(inputStreamReader, BestEffortsDeliveryConfiguration.class);
        new BestEffortsDeliveryJobFactory(config).init();
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Constructor(org.yaml.snakeyaml.constructor.Constructor) Yaml(org.yaml.snakeyaml.Yaml)

Example 4 with Yaml

use of org.yaml.snakeyaml.Yaml in project kiimate by SINeWang.

the class VisitRawAssetCtl method visit.

@RequestMapping(value = "/{" + GROUP + "}/{" + NAME + "}/{" + STABILITY + "}/{" + VERSION + ":.+}/raw")
public ResponseEntity<?> visit(@RequestHeader(value = ErestHeaders.REQUEST_ID, required = false) String requestId, @RequestHeader(ErestHeaders.VISITOR_ID) String visitorId, @PathVariable(OWNER_ID) String ownerId, @PathVariable(GROUP) String group, @PathVariable(NAME) String name, @PathVariable(STABILITY) String stability, @PathVariable(VERSION) String version, @RequestParam(value = FORMAT_YML, required = false) String yml) {
    ReadContext context = buildContext(requestId, ownerId, visitorId);
    VisitRawAssetApi.GroupNameForm form = new VisitRawAssetApi.GroupNameForm();
    form.setGroup(group);
    form.setName(name);
    if (null != stability) {
        form.setStability(stability);
    }
    if (null != version) {
        form.setVersion(version);
    }
    try {
        if (yml == null) {
            return VisitApiCaller.sync(api, context, form);
        } else {
            DumperOptions options = new DumperOptions();
            options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
            try {
                Yaml yaml = new Yaml(options);
                return ErestResponse.ok(requestId, yaml.dump(api.visit(context, form)));
            } catch (BadRequest badRequest) {
                return ErestResponse.badRequest(requestId, badRequest.getKeys());
            } catch (Panic panic) {
                return ErestResponse.badRequest(requestId, panic.getKeys());
            }
        }
    } catch (NotFound notFound) {
        return ErestResponse.notFound(requestId, notFound.getKeys());
    }
}
Also used : BadRequest(one.kii.summer.io.exception.BadRequest) Panic(one.kii.summer.io.exception.Panic) ReadContext(one.kii.summer.io.context.ReadContext) DumperOptions(org.yaml.snakeyaml.DumperOptions) VisitRawAssetApi(one.kii.kiimate.status.core.api.VisitRawAssetApi) Yaml(org.yaml.snakeyaml.Yaml) NotFound(one.kii.summer.io.exception.NotFound)

Example 5 with Yaml

use of org.yaml.snakeyaml.Yaml in project yyl_example by Relucent.

the class SnakeyamlTest method main.

public static void main(String[] args) throws IOException {
    Yaml yaml = new Yaml();
    try (InputStream input = SnakeyamlTest.class.getResourceAsStream("sample.yml")) {
        Object result = yaml.load(input);
        System.out.println(result.getClass());
        System.out.println(result);
    }
}
Also used : InputStream(java.io.InputStream) Yaml(org.yaml.snakeyaml.Yaml)

Aggregations

Yaml (org.yaml.snakeyaml.Yaml)294 Map (java.util.Map)109 HashMap (java.util.HashMap)88 IOException (java.io.IOException)63 FileInputStream (java.io.FileInputStream)53 InputStream (java.io.InputStream)50 File (java.io.File)47 DumperOptions (org.yaml.snakeyaml.DumperOptions)43 Constructor (org.yaml.snakeyaml.constructor.Constructor)32 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)25 FileNotFoundException (java.io.FileNotFoundException)22 SafeConstructor (org.yaml.snakeyaml.constructor.SafeConstructor)22 List (java.util.List)21 Writer (java.io.Writer)18 LinkedHashMap (java.util.LinkedHashMap)18 Path (java.nio.file.Path)17 Reader (java.io.Reader)16 Properties (java.util.Properties)14 FileWriter (java.io.FileWriter)13