Example usage for com.fasterxml.jackson.dataformat.yaml YAMLFactory YAMLFactory

List of usage examples for com.fasterxml.jackson.dataformat.yaml YAMLFactory YAMLFactory

Introduction

In this page you can find the example usage for com.fasterxml.jackson.dataformat.yaml YAMLFactory YAMLFactory.

Prototype

public YAMLFactory() 

Source Link

Document

Default constructor used to create factory instances.

Usage

From source file:org.apache.myriad.Main.java

public static void initialize(Configuration hadoopConf, AbstractYarnScheduler yarnScheduler,
        RMContext rmContext, InterceptorRegistry registry) throws Exception {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    MyriadConfiguration cfg = mapper.readValue(
            Thread.currentThread().getContextClassLoader().getResource("myriad-config-default.yml"),
            MyriadConfiguration.class);

    MyriadModule myriadModule = new MyriadModule(cfg, hadoopConf, yarnScheduler, rmContext, registry);
    MesosModule mesosModule = new MesosModule();
    injector = Guice.createInjector(myriadModule, mesosModule, new WebAppGuiceModule());

    new Main().run(cfg);
}

From source file:org.apache.pulsar.functions.worker.WorkerConfig.java

public static WorkerConfig load(String yamlFile) throws IOException {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    return mapper.readValue(new File(yamlFile), WorkerConfig.class);
}

From source file:org.apache.pulsar.io.elasticsearch.ElasticSearchConfig.java

public static ElasticSearchConfig load(String yamlFile) throws IOException {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    return mapper.readValue(new File(yamlFile), ElasticSearchConfig.class);
}

From source file:org.apache.pulsar.io.file.FileSourceConfig.java

public static FileSourceConfig load(String yamlFile) throws IOException {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    return mapper.readValue(new File(yamlFile), FileSourceConfig.class);
}

From source file:org.apache.pulsar.io.hdfs.sink.HdfsSinkConfig.java

public static HdfsSinkConfig load(String yamlFile) throws IOException {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    return mapper.readValue(new File(yamlFile), HdfsSinkConfig.class);
}

From source file:org.apache.pulsar.io.mongodb.MongoConfig.java

public static MongoConfig load(String yamlFile) throws IOException {
    final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    final MongoConfig cfg = mapper.readValue(new File(yamlFile), MongoConfig.class);

    return cfg;/*w w  w .ja v a2  s  .  com*/
}

From source file:org.apache.pulsar.io.twitter.TwitterFireHoseConfig.java

public static TwitterFireHoseConfig load(String yamlFile) throws IOException {
    ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    return mapper.readValue(new File(yamlFile), TwitterFireHoseConfig.class);
}

From source file:org.finra.herd.swaggergen.AbstractTest.java

protected String toYaml(Object object) throws JsonProcessingException {
    ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
    objectMapper.setSerializationInclusion(Include.NON_EMPTY);
    objectMapper.setSerializationInclusion(Include.NON_NULL);
    return objectMapper.writeValueAsString(object);
}

From source file:org.janusgraph.codepipelines.AwsCodePipelinesCi.java

private void run() throws IOException {
    final File file = new File(getOptionValue(PIPELINES_JSON_OPTION));
    final Region region = Region.of(getOptionValue(REGION_OPTION));
    final AwsCredentialsProvider provider = ProfileCredentialsProvider.builder()
            .profileName(getOptionValue(PROFILE_OPTION)).build();

    final ClientHttpConfiguration http = ClientHttpConfiguration.builder()
            .httpClient(ApacheSdkHttpClientFactory.builder() //consider netty some other time
                    .socketTimeout(Duration.ofSeconds(10)).connectionTimeout(Duration.ofMillis(750)).build()
                    .createHttpClient())
            .build();/*from w w w .  jav  a 2  s.c o  m*/

    final AwsCodePipelinesLogic.AwsCodePipelinesLogicBuilder builder = AwsCodePipelinesLogic.builder()
            .githubToken(getOptionValue(GITHUB_TOKEN_OPTION)).githubOwner(getOptionValue(GITHUB_OWNER_OPTION))
            .githubRepo(getOptionValue(GITHUB_REPO_OPTION)).githubBranch(getOptionValue(GITHUB_BRANCH_OPTION))
            .codeBuildServiceRoleArn(getOptionValue(CODE_BUILD_SERVICE_ROLE_ARN_OPTION))
            .codePipelineRoleArn(getOptionValue(CODEPIPELINE_ROLE_ARN_OPTION))
            .s3Bucket(getOptionValue(BUCKET_OPTION))
            .s3BucketLocationConstraint(BucketLocationConstraint.fromValue(region.value()))
            .s3(S3Client.builder().httpConfiguration(http).region(region).credentialsProvider(provider).build())
            .codeBuild(CodeBuildClient.builder().httpConfiguration(http).region(region)
                    .credentialsProvider(provider).build())
            .codePipeline(CodePipelineClient.builder().httpConfiguration(http).region(region)
                    .credentialsProvider(provider).build());

    final Tag timeTag = Tag.builder().key("date").value(Long.toString(System.currentTimeMillis())).build();
    final PipelineDefinitions definitions = new ObjectMapper(new YAMLFactory()).readValue(file,
            PipelineDefinitions.class);
    definitions.getPipelines().stream()
            .map(def -> builder.pipelineName(def.getName()).sourceOutputArtifactName(def.getName() + "Source")
                    .parallelBuildActions(def.getParallelBuildActions())
                    .defaultComputeImage(definitions.getDefaultComputeImage())
                    .defaultComputeType(definitions.getDefaultComputeType())
                    .defaultPrivilegedMode(definitions.isDefaultPrivilegedMode())
                    .tags(ImmutableList.of(Tag.builder().key("project").value(def.getName()).build(), timeTag))
                    .build())
            .forEach(AwsCodePipelinesLogic::run);
}

From source file:org.lenskit.data.entities.EntityDefaults.java

/**
 * Look up the defaults for a particular entity type.
 * @param type The entity type.//from  w w w  . j ava 2 s.c o m
 * @return The defaults.
 */
@Nullable
public static EntityDefaults lookup(EntityType type) {
    // TODO Cache these defaults
    String name = type.getName();
    String path = String.format("META-INF/lenskit/entity-defaults/%s.yaml", name);
    try (InputStream stream = ClassLoaders.inferDefault(EntityDefaults.class).getResourceAsStream(path)) {
        if (stream == null) {
            return null;
        }
        ObjectReader read = new ObjectMapper(new YAMLFactory()).readerFor(DefaultsBean.class);
        DefaultsBean bean = read.readValue(stream);
        return fromBean(type, bean);
    } catch (IOException e) {
        throw new RuntimeException("error reading defaults", e);
    }
}