org.elasticsearch.river.RiverName Java Examples
The following examples show how to use
org.elasticsearch.river.RiverName.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GitHubRiver.java From elasticsearch-river-github with Apache License 2.0 | 5 votes |
@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."); }
Example #2
Source File: KafkaRiver.java From elasticsearch-river-kafka with Apache License 2.0 | 5 votes |
@Inject public KafkaRiver(RiverName riverName, RiverSettings settings, Client client) { super(riverName, settings); this.client = client; try { logger.info("KafkaRiver created: name={}, type={}", riverName.getName(), riverName.getType()); this.riverConfig = new KafkaRiverConfig(settings); } catch (Exception e) { logger.error("Unexpected Error occurred", e); throw new RuntimeException(e); } }
Example #3
Source File: HBaseRiver.java From Elasticsearch-HBase-River with Apache License 2.0 | 5 votes |
/** * Loads and verifies all the configuration needed to run this river. * * @param riverName * @param settings * @param esClient */ @Inject public HBaseRiver(final RiverName riverName, final RiverSettings settings, final Client esClient) { super(riverName, settings); this.esClient = esClient; this.logger.info("Creating HBase Stream River"); this.normalizeFields = Boolean.parseBoolean(readConfig("normalizeFields", "true")); this.hosts = readConfig("hosts"); this.table = readConfig("table"); this.columnSeparator = readConfig("columnSeparator", null); this.idField = normalizeField(readConfig("idField", null)); this.index = normalizeField(readConfig("index", riverName.name())); this.type = normalizeField(readConfig("type", this.table)); this.interval = Long.parseLong(readConfig("interval", "600000")); this.batchSize = Integer.parseInt(readConfig("batchSize", "100")); this.charset = Charset.forName(readConfig("charset", "UTF-8")); this.deleteOld = Boolean.parseBoolean(readConfig("deleteOld", "false")); final String family = readConfig("family", null); this.family = family != null ? family.getBytes(this.charset) : null; this.qualifiers = readConfig("qualifiers", null); this.customMapping = readConfig("customMapping", null); if (this.interval <= 0) { throw new IllegalArgumentException("The interval between runs must be at least 1 ms. The current config is set to " + this.interval); } if (this.batchSize <= 0) { throw new IllegalArgumentException("The batch size must be set to at least 1. The current config is set to " + this.batchSize); } }
Example #4
Source File: Neo4jDriver.java From elasticsearch-river-neo4j with Apache License 2.0 | 5 votes |
@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} ); }
Example #5
Source File: KafkaRiver.java From elasticsearch-river-kafka with Apache License 2.0 | 5 votes |
@Inject protected KafkaRiver(final RiverName riverName, final RiverSettings riverSettings, final Client client) { super(riverName, riverSettings); riverConfig = new RiverConfig(riverName, riverSettings); kafkaConsumer = new KafkaConsumer(riverConfig); stats = new Stats(); if(null != riverConfig.getStatsdHost()) { logger.debug("Found statsd configuration. Starting client (prefix={}, host={}, port={}, interval={})", riverConfig.getStatsdPrefix(), riverConfig.getStatsdHost(), riverConfig.getStatsdPort(), riverConfig.getStatsdIntervalInSeconds()); statsAgent = new StatsAgent(riverConfig); int intervalInMs = riverConfig.getStatsdIntervalInSeconds() * 1000; timer = new Timer(); timer.scheduleAtFixedRate(new LogStatsTask(), intervalInMs, intervalInMs); } else { logger.debug("No statsd configuration found. Will not report stats..."); } switch (riverConfig.getActionType()) { case INDEX: elasticsearchProducer = new IndexDocumentProducer(client, riverConfig, kafkaConsumer, stats); break; case DELETE: elasticsearchProducer = new DeleteDocumentProducer(client, riverConfig, kafkaConsumer, stats); break; case RAW_EXECUTE: elasticsearchProducer = new RawMessageProducer(client, riverConfig, kafkaConsumer, stats); break; } }
Example #6
Source File: S3River.java From es-amazon-s3-river with Apache License 2.0 | 4 votes |
@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; }
Example #7
Source File: RiverConfig.java From elasticsearch-river-kafka with Apache License 2.0 | 4 votes |
public RiverConfig(RiverName riverName, RiverSettings riverSettings) { // Extract kafka related configuration if (riverSettings.settings().containsKey("kafka")) { Map<String, Object> kafkaSettings = (Map<String, Object>) riverSettings.settings().get("kafka"); topic = (String) kafkaSettings.get(TOPIC); zookeeperConnect = XContentMapValues.nodeStringValue(kafkaSettings.get(ZOOKEEPER_CONNECT), "localhost"); zookeeperConnectionTimeout = XContentMapValues.nodeIntegerValue(kafkaSettings.get(ZOOKEEPER_CONNECTION_TIMEOUT), 10000); messageType = MessageType.fromValue(XContentMapValues.nodeStringValue(kafkaSettings.get(MESSAGE_TYPE), MessageType.JSON.toValue())); } else { zookeeperConnect = "localhost"; zookeeperConnectionTimeout = 10000; topic = "elasticsearch-river-kafka"; messageType = MessageType.JSON; } // Extract ElasticSearch related configuration if (riverSettings.settings().containsKey("index")) { Map<String, Object> indexSettings = (Map<String, Object>) riverSettings.settings().get("index"); indexName = XContentMapValues.nodeStringValue(indexSettings.get(INDEX_NAME), riverName.name()); typeName = XContentMapValues.nodeStringValue(indexSettings.get(MAPPING_TYPE), "status"); bulkSize = XContentMapValues.nodeIntegerValue(indexSettings.get(BULK_SIZE), 100); concurrentRequests = XContentMapValues.nodeIntegerValue(indexSettings.get(CONCURRENT_REQUESTS), 1); actionType = ActionType.fromValue(XContentMapValues.nodeStringValue(indexSettings.get(ACTION_TYPE), ActionType.INDEX.toValue())); flushInterval = TimeValue.parseTimeValue(XContentMapValues.nodeStringValue(indexSettings.get(FLUSH_INTERVAL), "12h"), FLUSH_12H); } else { indexName = riverName.name(); typeName = "status"; bulkSize = 100; concurrentRequests = 1; actionType = ActionType.INDEX; flushInterval = FLUSH_12H; } // Extract StatsD related configuration if (riverSettings.settings().containsKey("statsd")) { Map<String, Object> statsdSettings = (Map<String, Object>) riverSettings.settings().get("statsd"); statsdHost = XContentMapValues.nodeStringValue(statsdSettings.get(STATSD_HOST), "localhost"); statsdPrefix = XContentMapValues.nodeStringValue(statsdSettings.get(STATSD_PREFIX), "kafka_river"); statsdPort = XContentMapValues.nodeIntegerValue(statsdSettings.get(STATSD_PORT), 8125); statsdIntervalInSeconds = XContentMapValues.nodeIntegerValue(statsdSettings.get(STATSD_INTERVAL_IN_SECONDS), 10); } }