org.apache.flume.sink.elasticsearch
Class AbstractElasticSearchIndexRequestBuilderFactory

java.lang.Object
  extended by org.apache.flume.sink.elasticsearch.AbstractElasticSearchIndexRequestBuilderFactory
All Implemented Interfaces:
Configurable, ConfigurableComponent, ElasticSearchIndexRequestBuilderFactory
Direct Known Subclasses:
EventSerializerIndexRequestBuilderFactory

public abstract class AbstractElasticSearchIndexRequestBuilderFactory
extends Object
implements ElasticSearchIndexRequestBuilderFactory

Abstract base class for custom implementations of ElasticSearchIndexRequestBuilderFactory.


Field Summary
protected  org.apache.commons.lang.time.FastDateFormat fastDateFormat
          FastDateFormat to use for index names in getIndexName(String, long)
 
Fields inherited from interface org.apache.flume.sink.elasticsearch.ElasticSearchIndexRequestBuilderFactory
df
 
Constructor Summary
protected AbstractElasticSearchIndexRequestBuilderFactory(org.apache.commons.lang.time.FastDateFormat fastDateFormat)
          Constructor for subclasses
 
Method Summary
abstract  void configure(ComponentConfiguration arg0)
           
abstract  void configure(Context arg0)
           Request the implementing class to (re)configure itself.
 org.elasticsearch.action.index.IndexRequestBuilder createIndexRequest(org.elasticsearch.client.Client client, String indexPrefix, String indexType, Event event)
          Creates and prepares an IndexRequestBuilder from the supplied Client via delegation to the subclass-hook template methods getIndexName(String, long) and prepareIndexRequest(IndexRequestBuilder, String, String, Event)
protected  String getIndexName(String indexPrefix, long timestamp)
          Gets the name of the index to use for an index request
protected abstract  void prepareIndexRequest(org.elasticsearch.action.index.IndexRequestBuilder indexRequest, String indexName, String indexType, Event event)
          Prepares an ElasticSearch IndexRequestBuilder instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fastDateFormat

protected final org.apache.commons.lang.time.FastDateFormat fastDateFormat
FastDateFormat to use for index names in getIndexName(String, long)

Constructor Detail

AbstractElasticSearchIndexRequestBuilderFactory

protected AbstractElasticSearchIndexRequestBuilderFactory(org.apache.commons.lang.time.FastDateFormat fastDateFormat)
Constructor for subclasses

Parameters:
fastDateFormat - FastDateFormat to use for index names
Method Detail

configure

public abstract void configure(Context arg0)
Description copied from interface: Configurable

Request the implementing class to (re)configure itself.

When configuration parameters are changed, they must be reflected by the component asap.

There are no thread safety guarrantees on when configure might be called.

Specified by:
configure in interface Configurable
See Also:
Configurable

configure

public abstract void configure(ComponentConfiguration arg0)
Specified by:
configure in interface ConfigurableComponent
See Also:
ConfigurableComponent

createIndexRequest

public org.elasticsearch.action.index.IndexRequestBuilder createIndexRequest(org.elasticsearch.client.Client client,
                                                                             String indexPrefix,
                                                                             String indexType,
                                                                             Event event)
                                                                      throws IOException
Creates and prepares an IndexRequestBuilder from the supplied Client via delegation to the subclass-hook template methods getIndexName(String, long) and prepareIndexRequest(IndexRequestBuilder, String, String, Event)

Specified by:
createIndexRequest in interface ElasticSearchIndexRequestBuilderFactory
Parameters:
client - ElasticSearch Client to prepare index from
indexPrefix - Prefix of index name to use -- as configured on the sink
indexType - Index type to use -- as configured on the sink
event - Flume event to serialize and add to index request
Returns:
prepared ElasticSearch IndexRequestBuilder instance
Throws:
IOException - If an error occurs e.g. during serialization

getIndexName

protected String getIndexName(String indexPrefix,
                              long timestamp)
Gets the name of the index to use for an index request

Parameters:
indexPrefix - Prefix of index name to use -- as configured on the sink
timestamp - timestamp (millis) to format / use
Returns:
index name of the form 'indexPrefix-formattedTimestamp'

prepareIndexRequest

protected abstract void prepareIndexRequest(org.elasticsearch.action.index.IndexRequestBuilder indexRequest,
                                            String indexName,
                                            String indexType,
                                            Event event)
                                     throws IOException
Prepares an ElasticSearch IndexRequestBuilder instance

Parameters:
indexRequest - The (empty) ElasticSearch IndexRequestBuilder to prepare
indexName - Index name to use -- as per getIndexName(String, long)
indexType - Index type to use -- as configured on the sink
event - Flume event to serialize and add to index request
Throws:
IOException - If an error occurs e.g. during serialization


Copyright © 2009-2014 Apache Software Foundation. All Rights Reserved.