当前位置: 首页>>代码示例>>Java>>正文


Java XContentMapValues.nodeIntegerValue方法代码示例

本文整理汇总了Java中org.elasticsearch.common.xcontent.support.XContentMapValues.nodeIntegerValue方法的典型用法代码示例。如果您正苦于以下问题:Java XContentMapValues.nodeIntegerValue方法的具体用法?Java XContentMapValues.nodeIntegerValue怎么用?Java XContentMapValues.nodeIntegerValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.common.xcontent.support.XContentMapValues的用法示例。


在下文中一共展示了XContentMapValues.nodeIntegerValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseConfig

import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
private void parseConfig() {
    if (settings.settings().containsKey("wildfly")) {
        Map<String, Object> wildflySettings = (Map<String, Object>) settings.settings().get("wildfly");

        this.username = XContentMapValues.nodeStringValue(wildflySettings.get("user"), null);
        this.password = XContentMapValues.nodeStringValue(wildflySettings.get("user"), null);
        this.host = XContentMapValues.nodeStringValue(wildflySettings.get("host"), null);
        this.port = XContentMapValues.nodeIntegerValue(wildflySettings.get("port"), 9999);
        this.scheduleSeconds = XContentMapValues.nodeIntegerValue(wildflySettings.get("schedule"), 1);

    }
    else
    {
        logger.error("invalid wildfly plugin configuration");
    }

    if (settings.settings().containsKey("index")) {
        Map<String, Object> indexSettings = (Map<String, Object>) settings.settings().get("index");
        indexName = XContentMapValues.nodeStringValue(indexSettings.get("index"), riverName.name());
        typeName = XContentMapValues.nodeStringValue(indexSettings.get("type"), "status");
    }
    else
    {
        logger.error("invalid wildfly plugin configuration");
    }
}
 
开发者ID:heiko-braun,项目名称:river-metrics,代码行数:27,代码来源:WildlfyRiver.java

示例2: parse

import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@Override
public Mapper.Builder parse(String fieldName, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
    TextFieldMapper.Builder builder = new TextFieldMapper.Builder(fieldName);
    builder.fieldType().setIndexAnalyzer(parserContext.getIndexAnalyzers().getDefaultIndexAnalyzer());
    builder.fieldType().setSearchAnalyzer(parserContext.getIndexAnalyzers().getDefaultSearchAnalyzer());
    builder.fieldType().setSearchQuoteAnalyzer(parserContext.getIndexAnalyzers().getDefaultSearchQuoteAnalyzer());
    parseTextField(builder, fieldName, node, parserContext);
    for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> entry = iterator.next();
        String propName = entry.getKey();
        Object propNode = entry.getValue();
        if (propName.equals("position_increment_gap")) {
            int newPositionIncrementGap = XContentMapValues.nodeIntegerValue(propNode, -1);
            builder.positionIncrementGap(newPositionIncrementGap);
            iterator.remove();
        } else if (propName.equals("fielddata")) {
            builder.fielddata(XContentMapValues.nodeBooleanValue(propNode, "fielddata"));
            iterator.remove();
        } else if (propName.equals("eager_global_ordinals")) {
            builder.eagerGlobalOrdinals(XContentMapValues.nodeBooleanValue(propNode, "eager_global_ordinals"));
            iterator.remove();
        } else if (propName.equals("fielddata_frequency_filter")) {
            Map<?,?> frequencyFilter = (Map<?, ?>) propNode;
            double minFrequency = XContentMapValues.nodeDoubleValue(frequencyFilter.remove("min"), 0);
            double maxFrequency = XContentMapValues.nodeDoubleValue(frequencyFilter.remove("max"), Integer.MAX_VALUE);
            int minSegmentSize = XContentMapValues.nodeIntegerValue(frequencyFilter.remove("min_segment_size"), 0);
            builder.fielddataFrequencyFilter(minFrequency, maxFrequency, minSegmentSize);
            DocumentMapperParser.checkNoRemainingFields(propName, frequencyFilter, parserContext.indexVersionCreated());
            iterator.remove();
        }
    }
    return builder;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:TextFieldMapper.java

示例3: GitHubRiver

import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked"})
@Inject
public GitHubRiver(RiverName riverName, RiverSettings settings, Client client) {
    super(riverName, settings);
    this.client = client;

    if (!settings.settings().containsKey("github")) {
        throw new IllegalArgumentException("Need river settings - owner and repository.");
    }

    // get settings
    Map<String, Object> githubSettings = (Map<String, Object>) settings.settings().get("github");
    owner = XContentMapValues.nodeStringValue(githubSettings.get("owner"), null);
    repository = XContentMapValues.nodeStringValue(githubSettings.get("repository"), null);

    index = String.format("%s&%s", owner, repository);
    userRequestedInterval = XContentMapValues.nodeIntegerValue(githubSettings.get("interval"), 60);

    // auth (optional)
    username = null;
    password = null;
    if (githubSettings.containsKey("authentication")) {
        Map<String, Object> auth = (Map<String, Object>) githubSettings.get("authentication");
        username = XContentMapValues.nodeStringValue(auth.get("username"), null);
        password = XContentMapValues.nodeStringValue(auth.get("password"), null);
    }

    // endpoint (optional - default to github.com)
    endpoint = XContentMapValues.nodeStringValue(githubSettings.get("endpoint"), "https://api.github.com");

    logger.info("Created GitHub river.");
}
 
开发者ID:uberVU,项目名称:elasticsearch-river-github,代码行数:33,代码来源:GitHubRiver.java

示例4: Neo4jDriver

import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@Inject
public Neo4jDriver(RiverName riverName, RiverSettings settings, @RiverIndexName final String riverIndexName, final Client client) {
    super(riverName, settings);
    this.client = client;

    uri = XContentMapValues.nodeStringValue(XContentMapValues.extractValue("neo4j.uri", settings.settings()), DEFAULT_NEO_URI);
    List<Object> neo4jLabels = XContentMapValues.extractRawValues("neo4j.labels", settings.settings());
    String label;
    if(XContentMapValues.isArray(neo4jLabels)) {
        for (Object neo4jLabel : neo4jLabels) {
            label = XContentMapValues.nodeStringValue(neo4jLabel, null);
            labels.add(DynamicLabel.label(label));
        }
    }
    timestampField = XContentMapValues.nodeStringValue(XContentMapValues.extractValue("neo4j.timestampField", settings.settings()), DEFAULT_NEO_TIMESTAMP_FIELD);
    interval = XContentMapValues.nodeIntegerValue(XContentMapValues.extractValue("neo4j.interval", settings.settings()), DEFAULT_NEO_INTERVAL);
    index = XContentMapValues.nodeStringValue(XContentMapValues.extractValue("index.name", settings.settings()), DEFAULT_NEO_INDEX);
    type = XContentMapValues.nodeStringValue(XContentMapValues.extractValue("index.type", settings.settings()), DEFAULT_NEO_TYPE);
    indexFromLabel = XContentMapValues.nodeStringValue(XContentMapValues.extractValue("index.name.label",
        settings.settings()), null);
    typeFromLabel = XContentMapValues.nodeStringValue(XContentMapValues.extractValue("index.type.label",
        settings.settings()), null);

    logger.debug("Neo4j settings [uri={}]", new Object[]{uri});
    logger.debug("River settings [indexName={}, type={}, interval={}, timestampField={}, indexLabel={}, " +
            "typelabel={}]",
        new Object[]{index,
            type,
            interval,
            timestampField,
            indexFromLabel,
            typeFromLabel}
    );

}
 
开发者ID:sksamuel,项目名称:elasticsearch-river-neo4j,代码行数:36,代码来源:Neo4jDriver.java

示例5: newScript

import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
/**
 * This method is called for every search on every shard.
 *
 * @param params list of script parameters passed with the query
 * @return new native script
 */
@Override
public ExecutableScript newScript(@Nullable Map<String, Object> params) {
    // Example of a mandatory string parameter
    // The XContentMapValues helper class can be used to simplify parameter parsing
    String fieldName = params == null ? null : XContentMapValues.nodeStringValue(params.get("field"), defaultFieldName);
    if (!Strings.hasLength(fieldName)) {
        throw new IllegalArgumentException("Missing the field parameter");
    }

    // Example of an optional integer  parameter
    int certainty = params == null ? 10 : XContentMapValues.nodeIntegerValue(params.get("certainty"), 10);
    return new IsPrimeSearchScript(fieldName, certainty);
}
 
开发者ID:imotov,项目名称:elasticsearch-native-script-example,代码行数:20,代码来源:IsPrimeSearchScriptFactory.java

示例6: parse

import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@Override
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
    StringFieldMapper.Builder builder = stringField(name);
    parseTextField(builder, name, node, parserContext);
    for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> entry = iterator.next();
        String propName = Strings.toUnderscoreCase(entry.getKey());
        Object propNode = entry.getValue();
        if (propName.equals("null_value")) {
            if (propNode == null) {
                throw new MapperParsingException("Property [null_value] cannot be null.");
            }
            builder.nullValue(propNode.toString());
            iterator.remove();
        } else if (propName.equals("search_quote_analyzer")) {
            NamedAnalyzer analyzer = parserContext.analysisService().analyzer(propNode.toString());
            if (analyzer == null) {
                throw new MapperParsingException("Analyzer [" + propNode.toString() + "] not found for field [" + name + "]");
            }
            builder.searchQuotedAnalyzer(analyzer);
            iterator.remove();
        } else if (propName.equals("position_increment_gap") ||
                parserContext.indexVersionCreated().before(Version.V_2_0_0) && propName.equals("position_offset_gap")) {
            int newPositionIncrementGap = XContentMapValues.nodeIntegerValue(propNode, -1);
            if (newPositionIncrementGap < 0) {
                throw new MapperParsingException("positions_increment_gap less than 0 aren't allowed.");
            }
            builder.positionIncrementGap(newPositionIncrementGap);
            // we need to update to actual analyzers if they are not set in this case...
            // so we can inject the position increment gap...
            if (builder.fieldType().indexAnalyzer() == null) {
                builder.fieldType().setIndexAnalyzer(parserContext.analysisService().defaultIndexAnalyzer());
            }
            if (builder.fieldType().searchAnalyzer() == null) {
                builder.fieldType().setSearchAnalyzer(parserContext.analysisService().defaultSearchAnalyzer());
            }
            if (builder.fieldType().searchQuoteAnalyzer() == null) {
                builder.fieldType().setSearchQuoteAnalyzer(parserContext.analysisService().defaultSearchQuoteAnalyzer());
            }
            iterator.remove();
        } else if (propName.equals("ignore_above")) {
            builder.ignoreAbove(XContentMapValues.nodeIntegerValue(propNode, -1));
            iterator.remove();
        } else if (parseMultiField(builder, name, parserContext, propName, propNode)) {
            iterator.remove();
        }
    }
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:50,代码来源:StringFieldMapper.java

示例7: parse

import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@Override
public Mapper.Builder parse(final String fieldName, final Map<String, Object> node, final ParserContext parserContext) throws MapperParsingException {
    final LangStringFieldMapper.Builder builder = new LangStringFieldMapper.Builder(fieldName);
    builder.fieldType().setIndexAnalyzer(parserContext.getIndexAnalyzers().getDefaultIndexAnalyzer());
    builder.fieldType().setSearchAnalyzer(parserContext.getIndexAnalyzers().getDefaultSearchAnalyzer());
    builder.fieldType().setSearchQuoteAnalyzer(parserContext.getIndexAnalyzers().getDefaultSearchQuoteAnalyzer());
    parseTextField(builder, fieldName, node, parserContext);
    for (final Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
        final Map.Entry<String, Object> entry = iterator.next();
        final String propName = entry.getKey();
        final Object propNode = entry.getValue();
        if (propName.equals("position_increment_gap")) {
            final int newPositionIncrementGap = XContentMapValues.nodeIntegerValue(propNode, -1);
            builder.positionIncrementGap(newPositionIncrementGap);
            iterator.remove();
        } else if (propName.equals("fielddata")) {
            builder.fielddata(XContentMapValues.nodeBooleanValue(propNode, "fielddata"));
            iterator.remove();
        } else if (propName.equals("eager_global_ordinals")) {
            builder.eagerGlobalOrdinals(XContentMapValues.nodeBooleanValue(propNode, "eager_global_ordinals"));
            iterator.remove();
        } else if (propName.equals("fielddata_frequency_filter")) {
            final Map<?,?> frequencyFilter = (Map<?, ?>) propNode;
            final double minFrequency = XContentMapValues.nodeDoubleValue(frequencyFilter.remove("min"), 0);
            final double maxFrequency = XContentMapValues.nodeDoubleValue(frequencyFilter.remove("max"), Integer.MAX_VALUE);
            final int minSegmentSize = XContentMapValues.nodeIntegerValue(frequencyFilter.remove("min_segment_size"), 0);
            builder.fielddataFrequencyFilter(minFrequency, maxFrequency, minSegmentSize);
            DocumentMapperParser.checkNoRemainingFields(propName, frequencyFilter, parserContext.indexVersionCreated());
            iterator.remove();
        } else if (propName.equals(SEPARATOR_SETTING_KEY)) {
            builder.fieldSeparator(propNode.toString());
            iterator.remove();
        } else if (propName.equals(LANG_SETTING_KEY)) {
            builder.supportedLanguages(
                    XContentMapValues.nodeStringArrayValue(propNode));
            iterator.remove();
        } else if (propName.equals(LANG_FIELD_SETTING_KEY)) {
            builder.langField(propNode.toString());
            iterator.remove();
        } else if (propName.equals(LANG_BASE_NAME_SETTING_KEY)) {
            builder.langBaseName(propNode.toString());
            iterator.remove();
        }
    }
    return builder;
}
 
开发者ID:codelibs,项目名称:elasticsearch-langfield,代码行数:47,代码来源:LangStringFieldMapper.java

示例8: DynamoDbRiver

import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@Inject
public DynamoDbRiver(RiverName riverName, RiverSettings settings, Client client, @RiverIndexName String riverIndexName) {
    super(riverName, settings);
    this.client = client;
    this.riverIndexName = riverIndexName;

    if (settings.settings().containsKey("dynamodb")) {
        Map<String, Object> dynamoDbSetting = (Map<String, Object>) settings.settings().get("dynamodb");

        String accessKey = XContentMapValues.nodeStringValue(dynamoDbSetting.get("access_key"), null);
        String secretKey = XContentMapValues.nodeStringValue(dynamoDbSetting.get("secret_key"), null);
        AWSCredentialsProvider credentials = new AWSCredentialsProviderChain(new StaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey)));

        dynamoDBClient = new AmazonDynamoDBClient(credentials);

        String regionStr = XContentMapValues.nodeStringValue(dynamoDbSetting.get("region"), Regions.DEFAULT_REGION.getName());
        Regions region = null;
        for (Regions regions : Regions.values()) {
            if (regions.getName().equals(regionStr)) {
                region = regions;
                break;
            }
        }
        if (region == null) {
            logger.warn("Unable to find DynamoDB region");
            dynamoDBClient.setEndpoint(regionStr);  // use regionStr as endpoint directly, this should only happen in test or user has their own DynamoDB endpoint
        } else {
            dynamoDBClient.setRegion(Region.getRegion(region));
        }

        tableName = XContentMapValues.nodeStringValue(dynamoDbSetting.get("table_name"), null);
        idField = XContentMapValues.nodeStringValue(dynamoDbSetting.get("id_field"), "id");
        updatedTimestampField = XContentMapValues.nodeStringValue(dynamoDbSetting.get("updated_timestamp_field"), null);
        deletedTimestampField = XContentMapValues.nodeStringValue(dynamoDbSetting.get("deleted_timestamp_field"), null);
        indexName = XContentMapValues.nodeStringValue(dynamoDbSetting.get("index"), tableName);
        typeName = XContentMapValues.nodeStringValue(dynamoDbSetting.get("type"), tableName);
        bulkSize = XContentMapValues.nodeIntegerValue(dynamoDbSetting.get("bulk_size"), 100);
        bulkFlushInterval = TimeValue.parseTimeValue(XContentMapValues.nodeStringValue(
                dynamoDbSetting.get("flush_interval"), "5s"), TimeValue.timeValueSeconds(5));
        maxConcurrentBulk = XContentMapValues.nodeIntegerValue(dynamoDbSetting.get("max_concurrent_bulk"), 1);
        interval = TimeValue.parseTimeValue(XContentMapValues.nodeStringValue(
                dynamoDbSetting.get("interval"), "0s"), TimeValue.timeValueSeconds(0));


    } else {
        throw new ElasticsearchException("Unable to find DynamoDB river setting");
    }
}
 
开发者ID:kzwang,项目名称:elasticsearch-river-dynamodb,代码行数:49,代码来源:DynamoDbRiver.java

示例9: KafkaRiverConfig

import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
public KafkaRiverConfig(RiverSettings settings)
{
	if (settings.settings().containsKey("kafka")) {
        Map<String, Object> kafkaSettings = (Map<String, Object>) settings.settings().get("kafka");
        
        topic = (String)kafkaSettings.get("topic");
        zookeeper = XContentMapValues.nodeStringValue(kafkaSettings.get("zookeeper"), "localhost");
        factoryClass = XContentMapValues.nodeStringValue(kafkaSettings.get("message_handler_factory_class"), "org.elasticsearch.river.kafka.JsonMessageHandlerFactory");
        brokerHost = XContentMapValues.nodeStringValue(kafkaSettings.get("broker_host"), "localhost");
        brokerPort = XContentMapValues.nodeIntegerValue(kafkaSettings.get("broker_port"), 9092);
        partition = XContentMapValues.nodeIntegerValue(kafkaSettings.get("partition"), 0);
    }
	else
	{
		zookeeper = "localhost";
		brokerHost = "localhost";
		brokerPort = 9092;
		topic = "default_topic";
		partition = 0;
		factoryClass = "org.elasticsearch.river.kafka.JsonMessageHandlerFactory";
	}
    
    if (settings.settings().containsKey("index")) {
        Map<String, Object> indexSettings = (Map<String, Object>) settings.settings().get("index");
        bulkSize = XContentMapValues.nodeIntegerValue(indexSettings.get("bulk_size_bytes"), 10*1024*1024);
        if (indexSettings.containsKey("bulk_timeout")) {
            bulkTimeout = TimeValue.parseTimeValue(XContentMapValues.nodeStringValue(indexSettings.get("bulk_timeout"), "10ms"), TimeValue.timeValueMillis(10000));
        } else {
            bulkTimeout = TimeValue.timeValueMillis(10);
        }
    } else {
        bulkSize = 10*1024*1024;
        bulkTimeout = TimeValue.timeValueMillis(10000);
    }
    
    if (settings.settings().containsKey("statsd")) {
        Map<String, Object> statsdSettings = (Map<String, Object>) settings.settings().get("statsd");
        statsdHost = (String)statsdSettings.get("host");
        statsdPort = XContentMapValues.nodeIntegerValue(statsdSettings.get("port"), 8125);
        statsdPrefix = XContentMapValues.nodeStringValue(statsdSettings.get("prefix"), "es-kafka-river");
    }
	else
	{
		statsdHost = null;
		statsdPort = -1;
		statsdPrefix = null;
	}
}
 
开发者ID:endgameinc,项目名称:elasticsearch-river-kafka,代码行数:49,代码来源:KafkaRiverConfig.java

示例10: S3River

import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@Inject
@SuppressWarnings({ "unchecked" })
protected S3River(RiverName riverName, RiverSettings settings, Client client, ThreadPool threadPool) throws Exception{
   super(riverName, settings);
   this.client = client;
   this.threadPool = threadPool;
   this.riverStatus = RiverStatus.UNKNOWN;
   
   // Deal with connector settings.
   if (settings.settings().containsKey("amazon-s3")){
      Map<String, Object> feed = (Map<String, Object>)settings.settings().get("amazon-s3");
      
      // Retrieve feed settings.
      String feedname = XContentMapValues.nodeStringValue(feed.get("name"), null);
      String bucket = XContentMapValues.nodeStringValue(feed.get("bucket"), null);
      String pathPrefix = XContentMapValues.nodeStringValue(feed.get("pathPrefix"), null);
      String downloadHost = XContentMapValues.nodeStringValue(feed.get("download_host"), null);
      int updateRate = XContentMapValues.nodeIntegerValue(feed.get("update_rate"), 15 * 60 * 1000);
      boolean jsonSupport = XContentMapValues.nodeBooleanValue(feed.get("json_support"), false);
      double indexedCharsRatio  = XContentMapValues.nodeDoubleValue(feed.get("indexed_chars_ratio"), 0.0);
      
      String[] includes = S3RiverUtil.buildArrayFromSettings(settings.settings(), "amazon-s3.includes");
      String[] excludes = S3RiverUtil.buildArrayFromSettings(settings.settings(), "amazon-s3.excludes");
      
      // Retrieve connection settings.
      String accessKey = XContentMapValues.nodeStringValue(feed.get("accessKey"), null);
      String secretKey = XContentMapValues.nodeStringValue(feed.get("secretKey"), null);
      boolean useIAMRoleForEC2 = XContentMapValues.nodeBooleanValue(feed.get("use_EC2_IAM"), false);
      
      feedDefinition = new S3RiverFeedDefinition(feedname, bucket, pathPrefix, downloadHost,
            updateRate, Arrays.asList(includes), Arrays.asList(excludes), accessKey, secretKey, useIAMRoleForEC2,
            jsonSupport, indexedCharsRatio);
   } else {
      logger.error("You didn't define the amazon-s3 settings. Exiting... See https://github.com/lbroudoux/es-amazon-s3-river");
      indexName = null;
      typeName = null;
      bulkSize = 100;
      feedDefinition = null;
      s3 = null;
      return;
   }
   
   // Deal with index settings if provided.
   if (settings.settings().containsKey("index")) {
      Map<String, Object> indexSettings = (Map<String, Object>)settings.settings().get("index");
      
      indexName = XContentMapValues.nodeStringValue(indexSettings.get("index"), riverName.name());
      typeName = XContentMapValues.nodeStringValue(indexSettings.get("type"), S3RiverUtil.INDEX_TYPE_DOC);
      bulkSize = XContentMapValues.nodeIntegerValue(indexSettings.get("bulk_size"), 100);
   } else {
      indexName = riverName.name();
      typeName = S3RiverUtil.INDEX_TYPE_DOC;
      bulkSize = 100;
   }
   
   // We need to connect to Amazon S3 after ensure mandatory settings are here.
   if (feedDefinition.getBucket() == null){
      logger.error("Amazon S3 bucket should not be null. Please fix this.");
      throw new IllegalArgumentException("Amazon S3 bucket should not be null.");
   }
   // Connect using the appropriate authentication process.
   if (feedDefinition.getAccessKey() == null && feedDefinition.getSecretKey() == null) {
      s3 = new S3Connector(feedDefinition.isUseIAMRoleForEC2());
   } else {
      s3 = new S3Connector(feedDefinition.getAccessKey(), feedDefinition.getSecretKey());
   }
   try {
      s3.connectUserBucket(feedDefinition.getBucket(), feedDefinition.getPathPrefix());
   } catch (AmazonS3Exception ase){
      logger.error("Exception while connecting Amazon S3 user bucket. "
            + "Either access key, secret key, IAM Role or bucket name are incorrect");
      throw ase;
   }

   this.riverStatus = RiverStatus.INITIALIZED;
}
 
开发者ID:lbroudoux,项目名称:es-amazon-s3-river,代码行数:77,代码来源:S3River.java

示例11: DriveRiver

import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@Inject
@SuppressWarnings({ "unchecked" })
protected DriveRiver(RiverName riverName, RiverSettings settings, Client client) throws Exception{
   super(riverName, settings);
   this.client = client;
   
   // Deal with connector settings.
   if (settings.settings().containsKey("google-drive")){
      Map<String, Object> feed = (Map<String, Object>)settings.settings().get("google-drive");
      
      // Retrieve feed settings.
      String feedname = XContentMapValues.nodeStringValue(feed.get("name"), null);
      String folder = XContentMapValues.nodeStringValue(feed.get("folder"), null);
      int updateRate = XContentMapValues.nodeIntegerValue(feed.get("update_rate"), 15 * 60 * 1000);
      boolean jsonSupport = XContentMapValues.nodeBooleanValue(feed.get("json_support"), false);
      
      String[] includes = DriveRiverUtil.buildArrayFromSettings(settings.settings(), "google-drive.includes");
      String[] excludes = DriveRiverUtil.buildArrayFromSettings(settings.settings(), "google-drive.excludes");
      
      // Retrieve connection settings.
      String clientId = XContentMapValues.nodeStringValue(feed.get("clientId"), null);
      String clientSecret = XContentMapValues.nodeStringValue(feed.get("clientSecret"), null);
      String refreshToken = XContentMapValues.nodeStringValue(feed.get("refreshToken"), null);
      
      feedDefinition = new DriveRiverFeedDefinition(feedname, folder, updateRate, 
            Arrays.asList(includes), Arrays.asList(excludes), clientId, clientSecret, refreshToken, jsonSupport);
   } else {
      logger.error("You didn't define the google-drive settings. Exiting... See https://github.com/lbroudoux/es-google-drive-river");
      indexName = null;
      typeName = null;
      bulkSize = 100;
      feedDefinition = null;
      drive = null;
      return;
   }
   
   // Deal with index settings if provided.
   if (settings.settings().containsKey("index")) {
      Map<String, Object> indexSettings = (Map<String, Object>)settings.settings().get("index");
      
      indexName = XContentMapValues.nodeStringValue(indexSettings.get("index"), riverName.name());
      typeName = XContentMapValues.nodeStringValue(indexSettings.get("type"), DriveRiverUtil.INDEX_TYPE_DOC);
      bulkSize = XContentMapValues.nodeIntegerValue(indexSettings.get("bulk_size"), 100);
   } else {
      indexName = riverName.name();
      typeName = DriveRiverUtil.INDEX_TYPE_DOC;
      bulkSize = 100;
   }
   
   // We need to connect to Google Drive.
   drive = new DriveConnector(feedDefinition.getClientId(), feedDefinition.getClientSecret(), feedDefinition.getRefreshToken());
   drive.connectUserDrive(feedDefinition.getFolder());
}
 
开发者ID:lbroudoux,项目名称:es-google-drive-river,代码行数:54,代码来源:DriveRiver.java

示例12: JolokiaRiver

import org.elasticsearch.common.xcontent.support.XContentMapValues; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Inject
   public JolokiaRiver(RiverName riverName, RiverSettings riverSettings,
                    @RiverIndexName String riverIndexName,
                    Client client) {
       super(riverName, riverSettings);
       // riverIndexName = _river

       Map<String, Object> sourceSettings =
               riverSettings.settings().containsKey(TYPE)
                       ? (Map<String, Object>) riverSettings.settings().get(TYPE)
                       : new HashMap<String, Object>();

                       
       strategy = XContentMapValues.nodeStringValue(sourceSettings.get("strategy"), "simple");

       riverSetting = new JolokiaRiverSetting();                                
       riverSetting.setHosts(nodeToStringList(sourceSettings.get("hosts"), new ArrayList<String>()));
       riverSetting.setUrl(XContentMapValues.nodeStringValue(sourceSettings.get("url"), null));         
       riverSetting.setObjectName(XContentMapValues.nodeStringValue(sourceSettings.get("objectName"), null));
       riverSetting.setAttributes(nodeToAttributeList(sourceSettings.get("attributes"), new ArrayList<Attribute>()));
       riverSetting.setPrefix(XContentMapValues.nodeStringValue(sourceSettings.get("prefix"), ""));
       riverSetting.setConstants(nodeToMap(sourceSettings.get("constants"), new HashMap<String, Map<String, Object>>()));
       riverSetting.setLogType(XContentMapValues.nodeStringValue(sourceSettings.get("logType"), null));
       riverSetting.setOnlyUpdates(XContentMapValues.nodeBooleanValue(sourceSettings.get("onlyUpdates"),false));
       
       poll = XContentMapValues.nodeTimeValue(sourceSettings.get("poll"), TimeValue.timeValueMinutes(1));
       maxretries = XContentMapValues.nodeIntegerValue(sourceSettings.get("max_retries"), 3);
       maxretrywait = TimeValue.parseTimeValue(XContentMapValues.nodeStringValue(sourceSettings.get("max_retries_wait"), "10s"), TimeValue.timeValueMillis(30000));
       digesting = XContentMapValues.nodeBooleanValue(sourceSettings.get("digesting"), Boolean.TRUE);

       Map<String, Object> targetSettings =
               riverSettings.settings().containsKey("index")
                       ? (Map<String, Object>) riverSettings.settings().get("index")
                       : new HashMap<String, Object>();
       indexName = XContentMapValues.nodeStringValue(targetSettings.get("index"), TYPE);
       typeName = XContentMapValues.nodeStringValue(targetSettings.get("type"), TYPE);
       bulkSize = XContentMapValues.nodeIntegerValue(targetSettings.get("bulk_size"), 100);
       maxBulkRequests = XContentMapValues.nodeIntegerValue(targetSettings.get("max_bulk_requests"), 30);
       indexSettings = XContentMapValues.nodeStringValue(targetSettings.get("index_settings"), null);
       typeMapping = XContentMapValues.nodeStringValue(targetSettings.get("type_mapping"), null);
       versioning = XContentMapValues.nodeBooleanValue(sourceSettings.get("versioning"), Boolean.FALSE);
       acknowledgeBulk = XContentMapValues.nodeBooleanValue(sourceSettings.get("acknowledge"), Boolean.FALSE);

       riverSource = RiverServiceLoader.findRiverSource(strategy);
       
       logger.debug("found river source {} for strategy {}", riverSource.getClass().getName(), strategy);
       
       riverSource.setting(riverSetting);
       	

       riverMouth = RiverServiceLoader.findRiverMouth(strategy);
       logger.debug("found river mouth {} for strategy {}", riverMouth.getClass().getName(), strategy);
       riverMouth.indexTemplate(indexName)
               .type(typeName)
               .maxBulkActions(bulkSize)
               .maxConcurrentBulkRequests(maxBulkRequests)
               .acknowledge(acknowledgeBulk)
               .versioning(versioning)
               .client(client);

       riverContext = new RiverContext()
               .riverName(riverName.getName())
               .riverIndexName(riverIndexName)
               .riverSettings(riverSettings.settings())
               .riverSource(riverSource)
               .riverMouth(riverMouth)
               .pollInterval(poll)
               .retries(maxretries)
               .maxRetryWait(maxretrywait)
               .digesting(digesting)
               .contextualize();

       riverFlow = RiverServiceLoader.findRiverFlow(strategy);
       // prepare task for run
       riverFlow.riverContext(riverContext);

       logger.debug("found river flow {} for strategy {}", riverFlow.getClass().getName(), strategy);
   }
 
开发者ID:cwikman,项目名称:elasticsearch-river-jolokia,代码行数:80,代码来源:JolokiaRiver.java


注:本文中的org.elasticsearch.common.xcontent.support.XContentMapValues.nodeIntegerValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。