use of org.elasticsearch.common.transport.LocalTransportAddress in project flink by apache.
the class ElasticsearchSinkITCase method testDeprecatedIndexRequestBuilderVariant.
/**
* Tests that behaviour of the deprecated {@link IndexRequestBuilder} constructor works properly.
*/
@Test
public void testDeprecatedIndexRequestBuilderVariant() throws Exception {
final String index = "index-req-builder-test-index";
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStreamSource<Tuple2<Integer, String>> source = env.addSource(new SourceSinkDataTestKit.TestDataSourceFunction());
Map<String, String> userConfig = new HashMap<>();
// This instructs the sink to emit after every element, otherwise they would be buffered
userConfig.put(ElasticsearchSinkBase.CONFIG_KEY_BULK_FLUSH_MAX_ACTIONS, "1");
userConfig.put("cluster.name", CLUSTER_NAME);
userConfig.put("node.local", "true");
List<TransportAddress> transports = Lists.newArrayList();
transports.add(new LocalTransportAddress("1"));
source.addSink(new ElasticsearchSink<>(userConfig, transports, new TestIndexRequestBuilder(index)));
env.execute("Elasticsearch Deprecated IndexRequestBuilder Bridge Test");
// verify the results
Client client = embeddedNodeEnv.getClient();
SourceSinkDataTestKit.verifyProducedSinkData(client, index);
client.close();
}
use of org.elasticsearch.common.transport.LocalTransportAddress in project flink by apache.
the class ElasticsearchSinkITCase method createElasticsearchSinkForEmbeddedNode.
@Override
protected <T> ElasticsearchSinkBase<T> createElasticsearchSinkForEmbeddedNode(Map<String, String> userConfig, ElasticsearchSinkFunction<T> elasticsearchSinkFunction) throws Exception {
// Elasticsearch 1.x requires this setting when using
// LocalTransportAddress to connect to a local embedded node
userConfig.put("node.local", "true");
List<TransportAddress> transports = Lists.newArrayList();
transports.add(new LocalTransportAddress("1"));
return new ElasticsearchSink<>(userConfig, transports, elasticsearchSinkFunction);
}
Aggregations