Skip to content

Commit 7bccc76

Browse files
committed
elasticsearch 0.90.3 compatibility
note that this change is incompatible with 0.90.2 or other earlier versions of elasticsearch
1 parent 063154a commit 7bccc76

13 files changed

+54
-31
lines changed

CHANGES.txt

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Changes for Elasticsearch InOut Plugin
55
Unreleased
66
==========
77

8+
- elasticsearch 0.90.3 compatibility.
9+
NOTE: This is incompatible with 0.90.2 or other earlier versions of
10+
elasticsearch
11+
812
2013/07/08 0.5.0
913
================
1014

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<url>https://github.com/crate/elasticsearch-inout-plugin</url>
1515
</scm>
1616
<properties>
17-
<elasticsearch.version>0.90.2</elasticsearch.version>
17+
<elasticsearch.version>0.90.3</elasticsearch.version>
1818
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1919
</properties>
2020
<build>

src/main/java/crate/elasticsearch/action/dump/TransportDumpAction.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import crate.elasticsearch.action.dump.parser.DumpParser;
44
import crate.elasticsearch.action.export.AbstractTransportExportAction;
55
import crate.elasticsearch.export.Exporter;
6+
import org.elasticsearch.cache.recycler.CacheRecycler;
67
import org.elasticsearch.cluster.ClusterService;
78
import org.elasticsearch.common.inject.Inject;
89
import org.elasticsearch.common.settings.Settings;
@@ -21,9 +22,10 @@ public class TransportDumpAction extends AbstractTransportExportAction {
2122
@Inject
2223
public TransportDumpAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
2324
TransportService transportService, IndicesService indicesService,
24-
ScriptService scriptService, DumpParser dumpParser, Exporter exporter,
25-
NodeEnvironment nodeEnv) {
26-
super(settings, threadPool, clusterService, transportService, indicesService, scriptService, dumpParser, exporter, nodeEnv);
25+
ScriptService scriptService, CacheRecycler cacheRecycler,
26+
DumpParser dumpParser, Exporter exporter, NodeEnvironment nodeEnv) {
27+
super(settings, threadPool, clusterService, transportService, indicesService, scriptService,
28+
cacheRecycler, dumpParser, exporter, nodeEnv);
2729
}
2830

2931
@Override

src/main/java/crate/elasticsearch/action/export/AbstractTransportExportAction.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
88
import org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException;
99
import org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction;
10+
import org.elasticsearch.cache.recycler.CacheRecycler;
1011
import org.elasticsearch.cluster.ClusterService;
1112
import org.elasticsearch.cluster.ClusterState;
1213
import org.elasticsearch.cluster.block.ClusterBlockException;
@@ -50,15 +51,19 @@ public abstract class AbstractTransportExportAction extends TransportBroadcastOp
5051

5152
private final Exporter exporter;
5253

54+
private final CacheRecycler cacheRecycler;
55+
5356
private String nodePath;
5457

5558
public AbstractTransportExportAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
5659
TransportService transportService, IndicesService indicesService,
57-
ScriptService scriptService, IExportParser exportParser, Exporter exporter,
60+
ScriptService scriptService, CacheRecycler cacheRecycler,
61+
IExportParser exportParser, Exporter exporter,
5862
NodeEnvironment nodeEnv) {
5963
super(settings, threadPool, clusterService, transportService);
6064
this.indicesService = indicesService;
6165
this.scriptService = scriptService;
66+
this.cacheRecycler = cacheRecycler;
6267
this.exportParser = exportParser;
6368
this.exporter = exporter;
6469
File[] paths = nodeEnv.nodeDataLocations();
@@ -142,7 +147,9 @@ protected ShardExportResponse shardOperation(ShardExportRequest request) throws
142147
IndexShard indexShard = indexService.shardSafe(request.shardId());
143148

144149
SearchShardTarget shardTarget = new SearchShardTarget(clusterService.localNode().id(), request.index(), request.shardId());
145-
ExportContext context = new ExportContext(0, new ShardSearchRequest().types(request.types()).filteringAliases(request.filteringAliases()), shardTarget, indexShard.searcher(), indexService, indexShard, scriptService, nodePath);
150+
ExportContext context = new ExportContext(0,
151+
new ShardSearchRequest().types(request.types()).filteringAliases(request.filteringAliases()),
152+
shardTarget, indexShard.searcher(), indexService, indexShard, scriptService, cacheRecycler, nodePath);
146153
ExportContext.setCurrent(context);
147154

148155
try {

src/main/java/crate/elasticsearch/action/export/ExportContext.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import crate.elasticsearch.export.Output;
44
import crate.elasticsearch.export.OutputCommand;
55
import crate.elasticsearch.export.OutputFile;
6+
import org.elasticsearch.cache.recycler.CacheRecycler;
67
import org.elasticsearch.cluster.ClusterName;
78
import org.elasticsearch.index.engine.Engine;
89
import org.elasticsearch.index.service.IndexService;
@@ -34,8 +35,10 @@ public class ExportContext extends SearchContext {
3435
private boolean mappings = false;
3536
private boolean settings = false;
3637

37-
public ExportContext(long id, ShardSearchRequest request, SearchShardTarget shardTarget, Engine.Searcher engineSearcher, IndexService indexService, IndexShard indexShard, ScriptService scriptService, String nodePath) {
38-
super(id, request, shardTarget, engineSearcher, indexService, indexShard, scriptService);
38+
public ExportContext(long id, ShardSearchRequest request, SearchShardTarget shardTarget,
39+
Engine.Searcher engineSearcher, IndexService indexService, IndexShard indexShard,
40+
ScriptService scriptService, CacheRecycler cacheRecycler, String nodePath) {
41+
super(id, request, shardTarget, engineSearcher, indexService, indexShard, scriptService, cacheRecycler);
3942
this.nodePath = nodePath;
4043
}
4144

src/main/java/crate/elasticsearch/action/export/TransportExportAction.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import crate.elasticsearch.action.export.parser.ExportParser;
44
import crate.elasticsearch.export.Exporter;
5+
import org.elasticsearch.cache.recycler.CacheRecycler;
56
import org.elasticsearch.cluster.ClusterService;
67
import org.elasticsearch.common.inject.Inject;
78
import org.elasticsearch.common.settings.Settings;
@@ -20,9 +21,10 @@ public class TransportExportAction extends AbstractTransportExportAction {
2021
@Inject
2122
public TransportExportAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
2223
TransportService transportService, IndicesService indicesService,
23-
ScriptService scriptService, ExportParser exportParser, Exporter exporter,
24-
NodeEnvironment nodeEnv) {
25-
super(settings, threadPool, clusterService, transportService, indicesService, scriptService, exportParser, exporter, nodeEnv);
24+
ScriptService scriptService, CacheRecycler cacheRecycler,
25+
ExportParser exportParser, Exporter exporter, NodeEnvironment nodeEnv) {
26+
super(settings, threadPool, clusterService, transportService, indicesService, scriptService,
27+
cacheRecycler, exportParser, exporter, nodeEnv);
2628
}
2729

2830
@Override

src/main/java/crate/elasticsearch/action/reindex/TransportReindexAction.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package crate.elasticsearch.action.reindex;
22

3+
import org.elasticsearch.cache.recycler.CacheRecycler;
34
import org.elasticsearch.cluster.ClusterService;
45
import org.elasticsearch.common.inject.Inject;
56
import org.elasticsearch.common.settings.Settings;
@@ -15,10 +16,10 @@ public class TransportReindexAction extends AbstractTransportSearchIntoAction {
1516

1617
@Inject
1718
public TransportReindexAction(Settings settings, ThreadPool threadPool,
18-
ClusterService clusterService, TransportService transportService,
19+
ClusterService clusterService, TransportService transportService, CacheRecycler cacheRecycler,
1920
IndicesService indicesService, ScriptService scriptService,
2021
ReindexParser parser, Writer writer) {
21-
super(settings, threadPool, clusterService, transportService, indicesService,
22+
super(settings, threadPool, clusterService, transportService, cacheRecycler, indicesService,
2223
scriptService, parser, writer);
2324
}
2425

src/main/java/crate/elasticsearch/action/searchinto/AbstractTransportSearchIntoAction.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
1414
import org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException;
1515
import org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction;
16+
import org.elasticsearch.cache.recycler.CacheRecycler;
1617
import org.elasticsearch.cluster.ClusterService;
1718
import org.elasticsearch.cluster.ClusterState;
1819
import org.elasticsearch.cluster.block.ClusterBlockException;
@@ -53,16 +54,19 @@ public abstract class AbstractTransportSearchIntoAction extends
5354

5455
private final ISearchIntoParser parser;
5556

57+
private final CacheRecycler cacheRecycler;
58+
5659
private final Writer writer;
5760

5861
@Inject
5962
public AbstractTransportSearchIntoAction(Settings settings,
6063
ThreadPool threadPool, ClusterService clusterService,
61-
TransportService transportService,
64+
TransportService transportService, CacheRecycler cacheRecycler,
6265
IndicesService indicesService, ScriptService scriptService,
6366
ISearchIntoParser parser, Writer writer) {
6467
super(settings, threadPool, clusterService, transportService);
6568
this.indicesService = indicesService;
69+
this.cacheRecycler = cacheRecycler;
6670
this.scriptService = scriptService;
6771
this.parser = parser;
6872
this.writer = writer;
@@ -163,11 +167,9 @@ protected ShardSearchIntoResponse shardOperation(ShardSearchIntoRequest
163167
clusterService.localNode().id(), request.index(),
164168
request.shardId());
165169
SearchIntoContext context = new SearchIntoContext(0,
166-
new ShardSearchRequest().types(
167-
request.types()).filteringAliases(
168-
request.filteringAliases()), shardTarget,
169-
indexShard.searcher(), indexService, indexShard,
170-
scriptService);
170+
new ShardSearchRequest().types(request.types()).filteringAliases(request.filteringAliases()),
171+
shardTarget, indexShard.searcher(), indexService, indexShard, scriptService, cacheRecycler
172+
);
171173
SearchIntoContext.setCurrent(context);
172174

173175
try {

src/main/java/crate/elasticsearch/action/searchinto/SearchIntoContext.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package crate.elasticsearch.action.searchinto;
22

3+
import org.elasticsearch.cache.recycler.CacheRecycler;
34
import org.elasticsearch.common.collect.ImmutableList;
45
import org.elasticsearch.common.collect.Lists;
56
import org.elasticsearch.common.transport.InetSocketTransportAddress;
@@ -36,9 +37,9 @@ public Map<String, String> outputNames() {
3637
public SearchIntoContext(long id, ShardSearchRequest request,
3738
SearchShardTarget shardTarget, Engine.Searcher engineSearcher,
3839
IndexService indexService, IndexShard indexShard,
39-
ScriptService scriptService) {
40+
ScriptService scriptService, CacheRecycler cacheRecycler) {
4041
super(id, request, shardTarget, engineSearcher, indexService,
41-
indexShard, scriptService);
42+
indexShard, scriptService, cacheRecycler);
4243
}
4344

4445
public String targetType() {

src/main/java/crate/elasticsearch/action/searchinto/TransportSearchIntoAction.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package crate.elasticsearch.action.searchinto;
22

3+
import org.elasticsearch.cache.recycler.CacheRecycler;
34
import org.elasticsearch.cluster.ClusterService;
45
import org.elasticsearch.common.inject.Inject;
56
import org.elasticsearch.common.settings.Settings;
@@ -20,10 +21,11 @@ public class TransportSearchIntoAction extends AbstractTransportSearchIntoAction
2021
@Inject
2122
public TransportSearchIntoAction(Settings settings,
2223
ThreadPool threadPool, ClusterService clusterService,
23-
TransportService transportService,
24+
TransportService transportService, CacheRecycler cacheRecycler,
2425
IndicesService indicesService, ScriptService scriptService,
2526
SearchIntoParser parser, Writer writer) {
26-
super(settings, threadPool, clusterService, transportService, indicesService, scriptService, parser, writer);
27+
super(settings, threadPool, clusterService, transportService, cacheRecycler, indicesService,
28+
scriptService, parser, writer);
2729
}
2830

2931
@Override

src/main/java/crate/elasticsearch/export/ExportCollector.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import org.apache.lucene.search.Collector;
1616
import org.apache.lucene.search.Scorer;
1717
import org.elasticsearch.common.bytes.BytesReference;
18-
import org.elasticsearch.common.io.stream.CachedStreamOutput;
18+
import org.elasticsearch.common.io.stream.BytesStreamOutput;
1919
import org.elasticsearch.common.text.StringAndBytesText;
2020
import org.elasticsearch.common.text.Text;
2121
import org.elasticsearch.common.xcontent.ToXContent;
@@ -171,14 +171,12 @@ public void collect(int doc) throws IOException {
171171

172172
searchHit.shardTarget(context.shardTarget());
173173
exportFields.hit(searchHit);
174-
CachedStreamOutput.Entry cachedEntry = CachedStreamOutput.popEntry();
175-
XContentBuilder builder = new XContentBuilder(XContentFactory
176-
.xContent(XContentType.JSON), cachedEntry.bytes());
174+
BytesStreamOutput os = new BytesStreamOutput();
175+
XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(XContentType.JSON), os);
177176
exportFields.toXContent(builder, ToXContent.EMPTY_PARAMS);
178177
builder.flush();
179-
BytesReference bytes = cachedEntry.bytes().bytes();
178+
BytesReference bytes = os.bytes();
180179
out.write(bytes.array(), bytes.arrayOffset(), bytes.length());
181-
CachedStreamOutput.pushEntry(cachedEntry);
182180
out.write('\n');
183181
out.flush();
184182
numExported++;

src/main/java/crate/elasticsearch/import_/Importer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ private ImmutableMap<String, IndexMetaData> getIndexMetaData(Set<String> indexes
370370
.filteredIndices(indexes.toArray(new String[indexes.size()]));
371371
clusterStateRequest.listenerThreaded(false);
372372
ClusterStateResponse response = client.admin().cluster().state(clusterStateRequest).actionGet();
373-
return response.getState().metaData().indices();
373+
return ImmutableMap.copyOf(response.getState().metaData().indices());
374374
}
375375

376376

src/test/java/crate/elasticsearch/module/import_/test/RestImportActionTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ public void testMappings() {
326326
executeImportRequest("{\"directory\": \"" + path + "\", \"mappings\": true}");
327327

328328
ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest().filteredIndices("index1");
329-
ImmutableMap<String, MappingMetaData> mappings = esSetup.client().admin().cluster().state(clusterStateRequest).actionGet().getState().metaData().index("index1").getMappings();
329+
ImmutableMap<String, MappingMetaData> mappings = ImmutableMap.copyOf(
330+
esSetup.client().admin().cluster().state(clusterStateRequest).actionGet().getState().metaData().index("index1").getMappings());
330331
assertEquals("{\"1\":{\"_timestamp\":{\"enabled\":true,\"store\":true},\"_ttl\":{\"enabled\":true,\"default\":86400000},\"properties\":{\"name\":{\"type\":\"string\",\"store\":true}}}}",
331332
mappings.get("1").source().toString());
332333
}

0 commit comments

Comments
 (0)