Created
January 7, 2016 12:23
-
-
Save rolandkofler/809f788be93920785501 to your computer and use it in GitHub Desktop.
The Connector class configures the tasks and provides a template how to start the tasks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ElasticsearchSinkConnector extends SinkConnector { | |
public static final String ES_HOST = "es.host"; | |
public static final String INDEX_PREFIX = "index.prefix"; | |
private String esHost; | |
private String indexPrefix; | |
@Override | |
public String version() { | |
return AppInfoParser.getVersion(); | |
} | |
@Override | |
public void start(Map<String, String> props) { | |
esHost = props.get(ES_HOST); | |
indexPrefix = props.get(INDEX_PREFIX); | |
} | |
@Override | |
public Class<? extends Task> taskClass() { | |
return ElasticsearchSinkTask.class; | |
} | |
@Override | |
public List<Map<String, String>> taskConfigs(int maxTasks) { | |
ArrayList<Map<String, String>> configs = new ArrayList<>(); | |
for (int i = 0; i < maxTasks; i++) { | |
Map<String, String> config = new HashMap<>(); | |
if (esHost != null) | |
config.put(ES_HOST, esHost); | |
if (indexPrefix != null) | |
config.put(INDEX_PREFIX, indexPrefix); | |
configs.add(config); | |
} | |
return configs; | |
} | |
@Override | |
public void stop() { | |
//not implemented | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment