Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upgrade to Elasticsearch 0.17.0.

  • Loading branch information...
commit 18035e13e47e7d7452eb45434c01d86a34e7105a 1 parent 41e902b
@deverton deverton authored
View
2  pom.xml
@@ -36,7 +36,7 @@
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
- <version>0.16.3</version>
+ <version>0.17.0</version>
</dependency>
<dependency>
View
31 src/test/java/org/elasticsearch/flume/ElasticSearchSinkTest.java
@@ -2,9 +2,9 @@
import static org.elasticsearch.client.Requests.refreshRequest;
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
-import static org.elasticsearch.index.query.xcontent.QueryBuilders.fieldQuery;
-import static org.elasticsearch.index.query.xcontent.QueryBuilders.matchAllQuery;
-import static org.elasticsearch.index.query.xcontent.QueryBuilders.queryString;
+import static org.elasticsearch.index.query.QueryBuilders.fieldQuery;
+import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
+import static org.elasticsearch.index.query.QueryBuilders.queryString;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
import static org.junit.Assert.assertEquals;
@@ -18,7 +18,7 @@
import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.gateway.Gateway;
-import org.elasticsearch.index.query.xcontent.XContentQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.search.SearchHit;
@@ -89,7 +89,8 @@ public void appendDifferentTypesOfLogMessage() throws IOException, InterruptedEx
sink.append(event);
sink.append(new EventImpl("bleh foo baz bar".getBytes(), 1, Priority.WARN, System.nanoTime(), "notlocalhost"));
sink.append(new EventImpl("{\"key\":\"value\"}".getBytes(), 2, Priority.DEBUG, System.nanoTime(), "jsonbody"));
- sink.append(new EventImpl("{\"key\":\"value\",\"complex\":{\"subkey\":\"subvalue\"}}".getBytes(), 3, Priority.DEBUG, System.nanoTime(), "complexjsonbody"));
+ sink.append(new EventImpl("{\"key\":\"value\",\"complex\":{\"subkey\":\"subvalue\"}}".getBytes(), 3, Priority.DEBUG,
+ System.nanoTime(), "complexjsonbody"));
sink.close();
@@ -108,7 +109,8 @@ public void appendDifferentTypesOfLogMessage() throws IOException, InterruptedEx
public void validateErrorCount() throws IOException, InterruptedException {
ElasticSearchSink sink = createAndOpenSink();
- EventImpl invalidJsonEvent1 = new EventImpl("{ \"not json\" : no".getBytes(), 1, Priority.DEBUG, System.nanoTime(), "notlocalhost") ;
+ EventImpl invalidJsonEvent1 = new EventImpl("{ \"not json\" : no".getBytes(), 1, Priority.DEBUG, System.nanoTime(),
+ "notlocalhost");
sink.append(invalidJsonEvent1);
sink.close();
@@ -124,16 +126,17 @@ public void validateSinkIndexTypeConfiguration() throws IOException, Interrupted
EventImpl event = new EventImpl("new index message".getBytes(), 1, Priority.WARN, System.nanoTime(), "notlocalhost");
sink.append(event);
sink.close();
-
+
assertSimpleTest(INDEX_NAME, "log", 1);
}
@Test
public void validateIndexNamePatternUsed() throws IOException, InterruptedException {
ElasticSearchSink sink = createAndOpenSink("", "log", "test_%Y-%m-%d");
-
+
sink.append(new EventImpl("new index message".getBytes(), 0, Priority.WARN, System.nanoTime(), "notlocalhost"));
- sink.append(new EventImpl("new index message".getBytes(), TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS), Priority.WARN, System.nanoTime(), "notlocalhost"));
+ sink.append(new EventImpl("new index message".getBytes(), TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS), Priority.WARN,
+ System.nanoTime(), "notlocalhost"));
sink.close();
assertSimpleTest("test_1970-01-01", "log", 1);
@@ -145,10 +148,10 @@ private void assertSimpleTest(String indexName, String indexType, int hits) {
searchClient.admin().indices().refresh(refreshRequest(indexName)).actionGet();
SearchResponse response = searchClient.prepareSearch(indexName).setTypes(indexType)
.setQuery(fieldQuery("message.text", "new")).execute().actionGet();
- assertEquals("There should have been " + hits + " search result for default index type", hits, response.getHits().getTotalHits());
+ assertEquals("There should have been " + hits + " search result for default index type", hits, response.getHits()
+ .getTotalHits());
}
-
private ElasticSearchSink createAndOpenSink() throws IOException, InterruptedException {
return createAndOpenSink(INDEX_NAME, INDEX_TYPE, "");
}
@@ -196,7 +199,7 @@ private void assertJsonBody(Event event) {
Map<String, Object> json = (Map<String, Object>) response.getHits().getAt(0).getSource().get("message");
assertEquals("value", json.get("key"));
}
-
+
@SuppressWarnings("unchecked")
private void assertComplexJsonBody(Event event) {
SearchResponse response = executeSearch(queryString("host:complexjsonbody"));
@@ -208,11 +211,11 @@ private void assertComplexJsonBody(Event event) {
assertEquals("subvalue", json.get("subkey"));
}
- private SearchResponse executeSearch(XContentQueryBuilder query) {
+ private SearchResponse executeSearch(QueryBuilder query) {
return executeSearch(query, INDEX_NAME, INDEX_TYPE);
}
- private SearchResponse executeSearch(XContentQueryBuilder query, String indexName, String indexType) {
+ private SearchResponse executeSearch(QueryBuilder query, String indexName, String indexType) {
return searchClient.prepareSearch(indexName).setTypes(indexType)
.setQuery(query)
.execute()

0 comments on commit 18035e1

Please sign in to comment.
Something went wrong with that request. Please try again.