Clear Indices Cache API: Allow to clear indices cache, closes #101
This commit is contained in:
parent
0e3ca48aa9
commit
fd574880fc
|
@ -30,6 +30,7 @@ import org.elasticsearch.action.admin.cluster.ping.replication.TransportShardRep
|
|||
import org.elasticsearch.action.admin.cluster.ping.single.TransportSinglePingAction;
|
||||
import org.elasticsearch.action.admin.cluster.state.TransportClusterStateAction;
|
||||
import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.TransportClearIndicesCacheAction;
|
||||
import org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction;
|
||||
import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction;
|
||||
import org.elasticsearch.action.admin.indices.flush.TransportFlushAction;
|
||||
|
@ -84,6 +85,7 @@ public class TransportActionModule extends AbstractModule {
|
|||
bind(TransportRefreshAction.class).asEagerSingleton();
|
||||
bind(TransportFlushAction.class).asEagerSingleton();
|
||||
bind(TransportOptimizeAction.class).asEagerSingleton();
|
||||
bind(TransportClearIndicesCacheAction.class).asEagerSingleton();
|
||||
|
||||
bind(TransportIndexAction.class).asEagerSingleton();
|
||||
bind(TransportGetAction.class).asEagerSingleton();
|
||||
|
|
|
@ -60,6 +60,10 @@ public class TransportActions {
|
|||
public static class Mapping {
|
||||
public static final String PUT = "indices/mapping/put";
|
||||
}
|
||||
|
||||
public static class Cache {
|
||||
public static final String CLEAR = "indices/cache/clear";
|
||||
}
|
||||
}
|
||||
|
||||
public static class Cluster {
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.admin.indices.cache.clear;
|
||||
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationRequest;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading;
|
||||
import org.elasticsearch.util.io.stream.StreamInput;
|
||||
import org.elasticsearch.util.io.stream.StreamOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ClearIndicesCacheRequest extends BroadcastOperationRequest {
|
||||
|
||||
private boolean filterCache = true;
|
||||
|
||||
ClearIndicesCacheRequest() {
|
||||
}
|
||||
|
||||
public ClearIndicesCacheRequest(String... indices) {
|
||||
super(indices, null);
|
||||
// we want to do the refresh in parallel on local shards...
|
||||
operationThreading(BroadcastOperationThreading.THREAD_PER_SHARD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the listener be called on a separate thread if needed.
|
||||
*/
|
||||
@Override public ClearIndicesCacheRequest listenerThreaded(boolean threadedListener) {
|
||||
super.listenerThreaded(threadedListener);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the operation threading model.
|
||||
*/
|
||||
@Override public ClearIndicesCacheRequest operationThreading(BroadcastOperationThreading operationThreading) {
|
||||
super.operationThreading(operationThreading);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean filterCache() {
|
||||
return filterCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the filter cache be cleared or not. Defaults to <tt>true</tt>.
|
||||
*/
|
||||
public ClearIndicesCacheRequest filterCache(boolean filterCache) {
|
||||
this.filterCache = filterCache;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
filterCache = in.readBoolean();
|
||||
}
|
||||
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeBoolean(filterCache);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.admin.indices.cache.clear;
|
||||
|
||||
import org.elasticsearch.action.ShardOperationFailedException;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationResponse;
|
||||
import org.elasticsearch.util.io.stream.StreamInput;
|
||||
import org.elasticsearch.util.io.stream.StreamOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The response of a refresh action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ClearIndicesCacheResponse extends BroadcastOperationResponse {
|
||||
|
||||
ClearIndicesCacheResponse() {
|
||||
|
||||
}
|
||||
|
||||
ClearIndicesCacheResponse(int successfulShards, int failedShards, List<ShardOperationFailedException> shardFailures) {
|
||||
super(successfulShards, failedShards, shardFailures);
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.admin.indices.cache.clear;
|
||||
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastShardOperationRequest;
|
||||
import org.elasticsearch.util.io.stream.StreamInput;
|
||||
import org.elasticsearch.util.io.stream.StreamOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
class ShardClearIndicesCacheRequest extends BroadcastShardOperationRequest {
|
||||
|
||||
private boolean filterCache = true;
|
||||
|
||||
ShardClearIndicesCacheRequest() {
|
||||
}
|
||||
|
||||
public ShardClearIndicesCacheRequest(String index, int shardId, ClearIndicesCacheRequest request) {
|
||||
super(index, shardId);
|
||||
filterCache = request.filterCache();
|
||||
}
|
||||
|
||||
public boolean filterCache() {
|
||||
return filterCache;
|
||||
}
|
||||
|
||||
public ShardClearIndicesCacheRequest waitForOperations(boolean waitForOperations) {
|
||||
this.filterCache = waitForOperations;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
filterCache = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeBoolean(filterCache);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.admin.indices.cache.clear;
|
||||
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastShardOperationResponse;
|
||||
import org.elasticsearch.util.io.stream.StreamInput;
|
||||
import org.elasticsearch.util.io.stream.StreamOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
class ShardClearIndicesCacheResponse extends BroadcastShardOperationResponse {
|
||||
|
||||
ShardClearIndicesCacheResponse() {
|
||||
}
|
||||
|
||||
public ShardClearIndicesCacheResponse(String index, int shardId) {
|
||||
super(index, shardId);
|
||||
}
|
||||
|
||||
@Override public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
}
|
||||
|
||||
@Override public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.admin.indices.cache.clear;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.action.ShardOperationFailedException;
|
||||
import org.elasticsearch.action.TransportActions;
|
||||
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastShardOperationFailedException;
|
||||
import org.elasticsearch.action.support.broadcast.TransportBroadcastOperationAction;
|
||||
import org.elasticsearch.cluster.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.routing.GroupShardsIterator;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.util.settings.Settings;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
|
||||
import static com.google.common.collect.Lists.*;
|
||||
|
||||
/**
|
||||
* Indices clear cache action.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class TransportClearIndicesCacheAction extends TransportBroadcastOperationAction<ClearIndicesCacheRequest, ClearIndicesCacheResponse, ShardClearIndicesCacheRequest, ShardClearIndicesCacheResponse> {
|
||||
|
||||
@Inject public TransportClearIndicesCacheAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
|
||||
TransportService transportService, IndicesService indicesService) {
|
||||
super(settings, threadPool, clusterService, transportService, indicesService);
|
||||
}
|
||||
|
||||
@Override protected String transportAction() {
|
||||
return TransportActions.Admin.Indices.Cache.CLEAR;
|
||||
}
|
||||
|
||||
@Override protected String transportShardAction() {
|
||||
return "indices/cache/clear/shard";
|
||||
}
|
||||
|
||||
|
||||
@Override protected ClearIndicesCacheRequest newRequest() {
|
||||
return new ClearIndicesCacheRequest();
|
||||
}
|
||||
|
||||
@Override protected ClearIndicesCacheResponse newResponse(ClearIndicesCacheRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
|
||||
int successfulShards = 0;
|
||||
int failedShards = 0;
|
||||
List<ShardOperationFailedException> shardFailures = null;
|
||||
for (int i = 0; i < shardsResponses.length(); i++) {
|
||||
Object shardResponse = shardsResponses.get(i);
|
||||
if (shardResponse == null) {
|
||||
failedShards++;
|
||||
} else if (shardResponse instanceof BroadcastShardOperationFailedException) {
|
||||
failedShards++;
|
||||
if (shardFailures == null) {
|
||||
shardFailures = newArrayList();
|
||||
}
|
||||
shardFailures.add(new DefaultShardOperationFailedException((BroadcastShardOperationFailedException) shardResponse));
|
||||
} else {
|
||||
successfulShards++;
|
||||
}
|
||||
}
|
||||
return new ClearIndicesCacheResponse(successfulShards, failedShards, shardFailures);
|
||||
}
|
||||
|
||||
@Override protected ShardClearIndicesCacheRequest newShardRequest() {
|
||||
return new ShardClearIndicesCacheRequest();
|
||||
}
|
||||
|
||||
@Override protected ShardClearIndicesCacheRequest newShardRequest(ShardRouting shard, ClearIndicesCacheRequest request) {
|
||||
return new ShardClearIndicesCacheRequest(shard.index(), shard.id(), request);
|
||||
}
|
||||
|
||||
@Override protected ShardClearIndicesCacheResponse newShardResponse() {
|
||||
return new ShardClearIndicesCacheResponse();
|
||||
}
|
||||
|
||||
@Override protected ShardClearIndicesCacheResponse shardOperation(ShardClearIndicesCacheRequest request) throws ElasticSearchException {
|
||||
// TODO we can optimize to go to a single node where the index exists
|
||||
IndexCache cache = indicesService.indexServiceSafe(request.index()).cache();
|
||||
if (request.filterCache()) {
|
||||
cache.filter().clear();
|
||||
}
|
||||
return new ShardClearIndicesCacheResponse(request.index(), request.shardId());
|
||||
}
|
||||
|
||||
/**
|
||||
* The refresh request works against *all* shards.
|
||||
*/
|
||||
@Override protected GroupShardsIterator shards(ClearIndicesCacheRequest request, ClusterState clusterState) {
|
||||
return clusterState.routingTable().allShardsGrouped(request.indices());
|
||||
}
|
||||
}
|
|
@ -46,6 +46,7 @@ public abstract class BroadcastOperationRequest implements ActionRequest {
|
|||
|
||||
protected BroadcastOperationRequest(String[] indices, @Nullable String queryHint) {
|
||||
this.indices = indices;
|
||||
this.queryHint = queryHint;
|
||||
}
|
||||
|
||||
public String[] indices() {
|
||||
|
|
|
@ -23,6 +23,8 @@ import org.elasticsearch.action.ActionFuture;
|
|||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
||||
|
@ -199,7 +201,7 @@ public interface IndicesAdminClient {
|
|||
* @return The result future
|
||||
* @see Requests#indexAliasesRequest()
|
||||
*/
|
||||
ActionFuture<IndicesAliasesResponse> indicesAliases(IndicesAliasesRequest request);
|
||||
ActionFuture<IndicesAliasesResponse> aliases(IndicesAliasesRequest request);
|
||||
|
||||
/**
|
||||
* Allows to add/remove aliases from indices.
|
||||
|
@ -209,4 +211,22 @@ public interface IndicesAdminClient {
|
|||
* @see Requests#indexAliasesRequest()
|
||||
*/
|
||||
void aliases(IndicesAliasesRequest request, ActionListener<IndicesAliasesResponse> listener);
|
||||
|
||||
/**
|
||||
* Clear indices cache.
|
||||
*
|
||||
* @param request The clear indices cache request
|
||||
* @return The result future
|
||||
* @see Requests#clearIndicesCache(String...)
|
||||
*/
|
||||
ActionFuture<ClearIndicesCacheResponse> clearCache(ClearIndicesCacheRequest request);
|
||||
|
||||
/**
|
||||
* Clear indices cache.
|
||||
*
|
||||
* @param request The clear indices cache request
|
||||
* @param listener A listener to be notified with a result
|
||||
* @see Requests#clearIndicesCache(String...)
|
||||
*/
|
||||
void clearCache(ClearIndicesCacheRequest request, ActionListener<ClearIndicesCacheResponse> listener);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.action.admin.cluster.ping.replication.ReplicationPingRe
|
|||
import org.elasticsearch.action.admin.cluster.ping.single.SinglePingRequest;
|
||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
||||
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
|
||||
|
@ -248,7 +249,7 @@ public class Requests {
|
|||
/**
|
||||
* Creates a gateway snapshot indices request.
|
||||
*
|
||||
* @param indices The indices the delete by query against. Use <tt>null</tt> or <tt>_all</tt> to execute against all indices
|
||||
* @param indices The indices the gateway wil be performed ont. Use <tt>null</tt> or <tt>_all</tt> to execute against all indices
|
||||
* @return The gateway snapshot request
|
||||
* @see org.elasticsearch.client.IndicesAdminClient#gatewaySnapshot(org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotRequest)
|
||||
*/
|
||||
|
@ -256,6 +257,16 @@ public class Requests {
|
|||
return new GatewaySnapshotRequest(indices);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a clean indices cache request.
|
||||
*
|
||||
* @param indices The indices the gateway wil be performed ont. Use <tt>null</tt> or <tt>_all</tt> to execute against all indices
|
||||
* @return The request
|
||||
*/
|
||||
public static ClearIndicesCacheRequest clearIndicesCache(String... indices) {
|
||||
return new ClearIndicesCacheRequest(indices);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a cluster state request.
|
||||
*
|
||||
|
|
|
@ -25,6 +25,9 @@ import org.elasticsearch.action.ActionListener;
|
|||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
|
||||
import org.elasticsearch.action.admin.indices.alias.TransportIndicesAliasesAction;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.TransportClearIndicesCacheAction;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction;
|
||||
|
@ -76,11 +79,13 @@ public class ServerIndicesAdminClient extends AbstractComponent implements Indic
|
|||
|
||||
private final TransportIndicesAliasesAction indicesAliasesAction;
|
||||
|
||||
private final TransportClearIndicesCacheAction clearIndicesCacheAction;
|
||||
|
||||
@Inject public ServerIndicesAdminClient(Settings settings, TransportIndicesStatusAction indicesStatusAction,
|
||||
TransportCreateIndexAction createIndexAction, TransportDeleteIndexAction deleteIndexAction,
|
||||
TransportRefreshAction refreshAction, TransportFlushAction flushAction, TransportOptimizeAction optimizeAction,
|
||||
TransportPutMappingAction putMappingAction, TransportGatewaySnapshotAction gatewaySnapshotAction,
|
||||
TransportIndicesAliasesAction indicesAliasesAction) {
|
||||
TransportIndicesAliasesAction indicesAliasesAction, TransportClearIndicesCacheAction clearIndicesCacheAction) {
|
||||
super(settings);
|
||||
this.indicesStatusAction = indicesStatusAction;
|
||||
this.createIndexAction = createIndexAction;
|
||||
|
@ -91,6 +96,7 @@ public class ServerIndicesAdminClient extends AbstractComponent implements Indic
|
|||
this.putMappingAction = putMappingAction;
|
||||
this.gatewaySnapshotAction = gatewaySnapshotAction;
|
||||
this.indicesAliasesAction = indicesAliasesAction;
|
||||
this.clearIndicesCacheAction = clearIndicesCacheAction;
|
||||
}
|
||||
|
||||
@Override public ActionFuture<IndicesStatusResponse> status(IndicesStatusRequest request) {
|
||||
|
@ -157,11 +163,19 @@ public class ServerIndicesAdminClient extends AbstractComponent implements Indic
|
|||
gatewaySnapshotAction.execute(request, listener);
|
||||
}
|
||||
|
||||
@Override public ActionFuture<IndicesAliasesResponse> indicesAliases(IndicesAliasesRequest request) {
|
||||
@Override public ActionFuture<IndicesAliasesResponse> aliases(IndicesAliasesRequest request) {
|
||||
return indicesAliasesAction.execute(request);
|
||||
}
|
||||
|
||||
@Override public void aliases(IndicesAliasesRequest request, ActionListener<IndicesAliasesResponse> listener) {
|
||||
indicesAliasesAction.execute(request, listener);
|
||||
}
|
||||
|
||||
@Override public ActionFuture<ClearIndicesCacheResponse> clearCache(ClearIndicesCacheRequest request) {
|
||||
return clearIndicesCacheAction.execute(request);
|
||||
}
|
||||
|
||||
@Override public void clearCache(ClearIndicesCacheRequest request, ActionListener<ClearIndicesCacheResponse> listener) {
|
||||
clearIndicesCacheAction.execute(request, listener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.client.transport.action.admin.cluster.ping.replication.
|
|||
import org.elasticsearch.client.transport.action.admin.cluster.ping.single.ClientTransportSinglePingAction;
|
||||
import org.elasticsearch.client.transport.action.admin.cluster.state.ClientTransportClusterStateAction;
|
||||
import org.elasticsearch.client.transport.action.admin.indices.alias.ClientTransportIndicesAliasesAction;
|
||||
import org.elasticsearch.client.transport.action.admin.indices.cache.clear.ClientTransportClearIndicesCacheAction;
|
||||
import org.elasticsearch.client.transport.action.admin.indices.create.ClientTransportCreateIndexAction;
|
||||
import org.elasticsearch.client.transport.action.admin.indices.delete.ClientTransportDeleteIndexAction;
|
||||
import org.elasticsearch.client.transport.action.admin.indices.flush.ClientTransportFlushAction;
|
||||
|
@ -69,6 +70,7 @@ public class ClientTransportActionModule extends AbstractModule {
|
|||
bind(ClientTransportPutMappingAction.class).asEagerSingleton();
|
||||
bind(ClientTransportGatewaySnapshotAction.class).asEagerSingleton();
|
||||
bind(ClientTransportIndicesAliasesAction.class).asEagerSingleton();
|
||||
bind(ClientTransportClearIndicesCacheAction.class).asEagerSingleton();
|
||||
|
||||
bind(ClientTransportNodesInfoAction.class).asEagerSingleton();
|
||||
bind(ClientTransportNodesShutdownAction.class).asEagerSingleton();
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.client.transport.action.admin.indices.cache.clear;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.elasticsearch.action.TransportActions;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse;
|
||||
import org.elasticsearch.client.transport.action.support.BaseClientTransportAction;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.util.settings.Settings;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ClientTransportClearIndicesCacheAction extends BaseClientTransportAction<ClearIndicesCacheRequest, ClearIndicesCacheResponse> {
|
||||
|
||||
@Inject public ClientTransportClearIndicesCacheAction(Settings settings, TransportService transportService) {
|
||||
super(settings, transportService, ClearIndicesCacheResponse.class);
|
||||
}
|
||||
|
||||
@Override protected String action() {
|
||||
return TransportActions.Admin.Indices.Cache.CLEAR;
|
||||
}
|
||||
}
|
|
@ -25,6 +25,8 @@ import org.elasticsearch.action.ActionFuture;
|
|||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
||||
|
@ -44,6 +46,7 @@ import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse;
|
|||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.transport.TransportClientNodesService;
|
||||
import org.elasticsearch.client.transport.action.admin.indices.alias.ClientTransportIndicesAliasesAction;
|
||||
import org.elasticsearch.client.transport.action.admin.indices.cache.clear.ClientTransportClearIndicesCacheAction;
|
||||
import org.elasticsearch.client.transport.action.admin.indices.create.ClientTransportCreateIndexAction;
|
||||
import org.elasticsearch.client.transport.action.admin.indices.delete.ClientTransportDeleteIndexAction;
|
||||
import org.elasticsearch.client.transport.action.admin.indices.flush.ClientTransportFlushAction;
|
||||
|
@ -81,12 +84,14 @@ public class InternalTransportIndicesAdminClient extends AbstractComponent imple
|
|||
|
||||
private final ClientTransportIndicesAliasesAction indicesAliasesAction;
|
||||
|
||||
private final ClientTransportClearIndicesCacheAction clearIndicesCacheAction;
|
||||
|
||||
@Inject public InternalTransportIndicesAdminClient(Settings settings, TransportClientNodesService nodesService,
|
||||
ClientTransportIndicesStatusAction indicesStatusAction,
|
||||
ClientTransportCreateIndexAction createIndexAction, ClientTransportDeleteIndexAction deleteIndexAction,
|
||||
ClientTransportRefreshAction refreshAction, ClientTransportFlushAction flushAction, ClientTransportOptimizeAction optimizeAction,
|
||||
ClientTransportPutMappingAction putMappingAction, ClientTransportGatewaySnapshotAction gatewaySnapshotAction,
|
||||
ClientTransportIndicesAliasesAction indicesAliasesAction) {
|
||||
ClientTransportIndicesAliasesAction indicesAliasesAction, ClientTransportClearIndicesCacheAction clearIndicesCacheAction) {
|
||||
super(settings);
|
||||
this.nodesService = nodesService;
|
||||
this.indicesStatusAction = indicesStatusAction;
|
||||
|
@ -98,6 +103,7 @@ public class InternalTransportIndicesAdminClient extends AbstractComponent imple
|
|||
this.putMappingAction = putMappingAction;
|
||||
this.gatewaySnapshotAction = gatewaySnapshotAction;
|
||||
this.indicesAliasesAction = indicesAliasesAction;
|
||||
this.clearIndicesCacheAction = clearIndicesCacheAction;
|
||||
}
|
||||
|
||||
@Override public ActionFuture<IndicesStatusResponse> status(final IndicesStatusRequest request) {
|
||||
|
@ -236,7 +242,7 @@ public class InternalTransportIndicesAdminClient extends AbstractComponent imple
|
|||
});
|
||||
}
|
||||
|
||||
@Override public ActionFuture<IndicesAliasesResponse> indicesAliases(final IndicesAliasesRequest request) {
|
||||
@Override public ActionFuture<IndicesAliasesResponse> aliases(final IndicesAliasesRequest request) {
|
||||
return nodesService.execute(new TransportClientNodesService.NodeCallback<ActionFuture<IndicesAliasesResponse>>() {
|
||||
@Override public ActionFuture<IndicesAliasesResponse> doWithNode(Node node) throws ElasticSearchException {
|
||||
return indicesAliasesAction.execute(node, request);
|
||||
|
@ -252,4 +258,21 @@ public class InternalTransportIndicesAdminClient extends AbstractComponent imple
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override public ActionFuture<ClearIndicesCacheResponse> clearCache(final ClearIndicesCacheRequest request) {
|
||||
return nodesService.execute(new TransportClientNodesService.NodeCallback<ActionFuture<ClearIndicesCacheResponse>>() {
|
||||
@Override public ActionFuture<ClearIndicesCacheResponse> doWithNode(Node node) throws ElasticSearchException {
|
||||
return clearIndicesCacheAction.execute(node, request);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override public void clearCache(final ClearIndicesCacheRequest request, final ActionListener<ClearIndicesCacheResponse> listener) {
|
||||
nodesService.execute(new TransportClientNodesService.NodeCallback<Void>() {
|
||||
@Override public Void doWithNode(Node node) throws ElasticSearchException {
|
||||
clearIndicesCacheAction.execute(node, request, listener);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
51
modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/IndexCache.java
vendored
Normal file
51
modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/IndexCache.java
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.cache;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
||||
import org.elasticsearch.index.cache.filter.none.NoneFilterCache;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
import org.elasticsearch.util.settings.Settings;
|
||||
|
||||
import static org.elasticsearch.util.settings.ImmutableSettings.Builder.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class IndexCache extends AbstractIndexComponent {
|
||||
|
||||
private final FilterCache filterCache;
|
||||
|
||||
public IndexCache(Index index) {
|
||||
this(index, EMPTY_SETTINGS, new NoneFilterCache(index, EMPTY_SETTINGS));
|
||||
}
|
||||
|
||||
@Inject public IndexCache(Index index, @IndexSettings Settings indexSettings, FilterCache filterCache) {
|
||||
super(index, indexSettings);
|
||||
this.filterCache = filterCache;
|
||||
}
|
||||
|
||||
public FilterCache filter() {
|
||||
return filterCache;
|
||||
}
|
||||
}
|
42
modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/IndexCacheModule.java
vendored
Normal file
42
modules/elasticsearch/src/main/java/org/elasticsearch/index/cache/IndexCacheModule.java
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.cache;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import org.elasticsearch.index.cache.filter.FilterCacheModule;
|
||||
import org.elasticsearch.util.settings.Settings;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class IndexCacheModule extends AbstractModule {
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
public IndexCacheModule(Settings settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override protected void configure() {
|
||||
new FilterCacheModule(settings).configure(binder());
|
||||
|
||||
bind(IndexCache.class).asEagerSingleton();
|
||||
}
|
||||
}
|
|
@ -31,4 +31,6 @@ public interface FilterCache extends IndexComponent, CloseableComponent {
|
|||
String type();
|
||||
|
||||
Filter cache(Filter filterToCache);
|
||||
|
||||
void clear();
|
||||
}
|
||||
|
|
|
@ -48,4 +48,8 @@ public class NoneFilterCache extends AbstractIndexComponent implements FilterCac
|
|||
@Override public Filter cache(Filter filterToCache) {
|
||||
return filterToCache;
|
||||
}
|
||||
|
||||
@Override public void clear() {
|
||||
// nothing to do here
|
||||
}
|
||||
}
|
|
@ -65,6 +65,10 @@ public abstract class AbstractConcurrentMapFilterCache extends AbstractIndexComp
|
|||
cache.clear();
|
||||
}
|
||||
|
||||
@Override public void clear() {
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
@Override public Filter cache(Filter filterToCache) {
|
||||
return new FilterCacheFilterWrapper(filterToCache);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import com.google.inject.Inject;
|
|||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.query.json.JsonIndexQueryParser;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
@ -51,12 +51,12 @@ public class IndexQueryParserService extends AbstractIndexComponent {
|
|||
|
||||
private final Map<String, IndexQueryParser> indexQueryParsers;
|
||||
|
||||
public IndexQueryParserService(Index index, MapperService mapperService, FilterCache filterCache, AnalysisService analysisService) {
|
||||
this(index, ImmutableSettings.Builder.EMPTY_SETTINGS, mapperService, filterCache, analysisService, null, null);
|
||||
public IndexQueryParserService(Index index, MapperService mapperService, IndexCache indexCache, AnalysisService analysisService) {
|
||||
this(index, ImmutableSettings.Builder.EMPTY_SETTINGS, mapperService, indexCache, analysisService, null, null);
|
||||
}
|
||||
|
||||
@Inject public IndexQueryParserService(Index index, @IndexSettings Settings indexSettings,
|
||||
MapperService mapperService, FilterCache filterCache,
|
||||
MapperService mapperService, IndexCache indexCache,
|
||||
AnalysisService analysisService,
|
||||
@Nullable SimilarityService similarityService,
|
||||
@Nullable Map<String, IndexQueryParserFactory> indexQueryParsersFactories) {
|
||||
|
@ -76,7 +76,7 @@ public class IndexQueryParserService extends AbstractIndexComponent {
|
|||
}
|
||||
}
|
||||
if (!qparsers.containsKey(Defaults.DEFAULT)) {
|
||||
IndexQueryParser defaultQueryParser = new JsonIndexQueryParser(index, indexSettings, mapperService, filterCache, analysisService, similarityService, null, null, Defaults.DEFAULT, null);
|
||||
IndexQueryParser defaultQueryParser = new JsonIndexQueryParser(index, indexSettings, mapperService, indexCache, analysisService, similarityService, null, null, Defaults.DEFAULT, null);
|
||||
qparsers.put(Defaults.DEFAULT, defaultQueryParser);
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ public class FieldJsonQueryParser extends AbstractIndexComponent implements Json
|
|||
throw new QueryParsingException(index, "No value specified for term query");
|
||||
}
|
||||
|
||||
MapperQueryParser queryParser = new MapperQueryParser(fieldName, analyzer, parseContext.mapperService(), parseContext.filterCache());
|
||||
MapperQueryParser queryParser = new MapperQueryParser(fieldName, analyzer, parseContext.mapperService(), parseContext.indexCache());
|
||||
queryParser.setEnablePositionIncrements(enablePositionIncrements);
|
||||
queryParser.setLowercaseExpandedTerms(lowercaseExpandedTerms);
|
||||
queryParser.setPhraseSlop(phraseSlop);
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.elasticsearch.ElasticSearchException;
|
|||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.query.IndexQueryParser;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
|
@ -61,7 +61,7 @@ public class JsonIndexQueryParser extends AbstractIndexComponent implements Inde
|
|||
|
||||
private ThreadLocal<ThreadLocals.CleanableValue<JsonQueryParseContext>> cache = new ThreadLocal<ThreadLocals.CleanableValue<JsonQueryParseContext>>() {
|
||||
@Override protected ThreadLocals.CleanableValue<JsonQueryParseContext> initialValue() {
|
||||
return new ThreadLocals.CleanableValue<JsonQueryParseContext>(new JsonQueryParseContext(index, queryParserRegistry, mapperService, similarityService, filterCache));
|
||||
return new ThreadLocals.CleanableValue<JsonQueryParseContext>(new JsonQueryParseContext(index, queryParserRegistry, mapperService, similarityService, indexCache));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -73,13 +73,13 @@ public class JsonIndexQueryParser extends AbstractIndexComponent implements Inde
|
|||
|
||||
private final SimilarityService similarityService;
|
||||
|
||||
private final FilterCache filterCache;
|
||||
private final IndexCache indexCache;
|
||||
|
||||
private final JsonQueryParserRegistry queryParserRegistry;
|
||||
|
||||
@Inject public JsonIndexQueryParser(Index index,
|
||||
@IndexSettings Settings indexSettings,
|
||||
MapperService mapperService, FilterCache filterCache,
|
||||
MapperService mapperService, IndexCache indexCache,
|
||||
AnalysisService analysisService, @Nullable SimilarityService similarityService,
|
||||
@Nullable Map<String, JsonQueryParserFactory> jsonQueryParsers,
|
||||
@Nullable Map<String, JsonFilterParserFactory> jsonFilterParsers,
|
||||
|
@ -88,7 +88,7 @@ public class JsonIndexQueryParser extends AbstractIndexComponent implements Inde
|
|||
this.name = name;
|
||||
this.mapperService = mapperService;
|
||||
this.similarityService = similarityService;
|
||||
this.filterCache = filterCache;
|
||||
this.indexCache = indexCache;
|
||||
|
||||
List<JsonQueryParser> queryParsers = newArrayList();
|
||||
if (jsonQueryParsers != null) {
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.lucene.search.Similarity;
|
|||
import org.codehaus.jackson.JsonParser;
|
||||
import org.codehaus.jackson.JsonToken;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.FieldMappers;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
|
@ -46,19 +46,19 @@ public class JsonQueryParseContext {
|
|||
|
||||
private final SimilarityService similarityService;
|
||||
|
||||
private final FilterCache filterCache;
|
||||
private final IndexCache indexCache;
|
||||
|
||||
private final JsonQueryParserRegistry queryParserRegistry;
|
||||
|
||||
private JsonParser jp;
|
||||
|
||||
public JsonQueryParseContext(Index index, JsonQueryParserRegistry queryParserRegistry,
|
||||
MapperService mapperService, SimilarityService similarityService, FilterCache filterCache) {
|
||||
MapperService mapperService, SimilarityService similarityService, IndexCache indexCache) {
|
||||
this.index = index;
|
||||
this.queryParserRegistry = queryParserRegistry;
|
||||
this.mapperService = mapperService;
|
||||
this.similarityService = similarityService;
|
||||
this.filterCache = filterCache;
|
||||
this.indexCache = indexCache;
|
||||
}
|
||||
|
||||
public void reset(JsonParser jp) {
|
||||
|
@ -81,15 +81,12 @@ public class JsonQueryParseContext {
|
|||
return similarityService != null ? similarityService.defaultSearchSimilarity() : null;
|
||||
}
|
||||
|
||||
public FilterCache filterCache() {
|
||||
return filterCache;
|
||||
public IndexCache indexCache() {
|
||||
return indexCache;
|
||||
}
|
||||
|
||||
public Filter cacheFilterIfPossible(Filter filter) {
|
||||
if (filterCache == null) {
|
||||
return filter;
|
||||
}
|
||||
return filterCache.cache(filter);
|
||||
return indexCache.filter().cache(filter);
|
||||
}
|
||||
|
||||
public Query parseInnerQuery() throws IOException, QueryParsingException {
|
||||
|
|
|
@ -149,6 +149,6 @@ public class MoreLikeThisFieldJsonQueryParser extends AbstractIndexComponent imp
|
|||
mltQuery.setAnalyzer(parseContext.mapperService().searchAnalyzer());
|
||||
}
|
||||
mltQuery.setMoreLikeFields(new String[]{fieldName});
|
||||
return wrapSmartNameQuery(mltQuery, smartNameFieldMappers, parseContext.filterCache());
|
||||
return wrapSmartNameQuery(mltQuery, smartNameFieldMappers, parseContext.indexCache());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,6 +75,6 @@ public class PrefixJsonFilterParser extends AbstractIndexComponent implements Js
|
|||
|
||||
Filter prefixFilter = new PrefixFilter(new Term(fieldName, value));
|
||||
prefixFilter = parseContext.cacheFilterIfPossible(prefixFilter);
|
||||
return wrapSmartNameFilter(prefixFilter, smartNameFieldMappers, parseContext.filterCache());
|
||||
return wrapSmartNameFilter(prefixFilter, smartNameFieldMappers, parseContext.indexCache());
|
||||
}
|
||||
}
|
|
@ -104,6 +104,6 @@ public class PrefixJsonQueryParser extends AbstractIndexComponent implements Jso
|
|||
PrefixQuery query = new PrefixQuery(new Term(fieldName, value));
|
||||
query.setRewriteMethod(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
|
||||
query.setBoost(boost);
|
||||
return wrapSmartNameQuery(query, smartNameFieldMappers, parseContext.filterCache());
|
||||
return wrapSmartNameQuery(query, smartNameFieldMappers, parseContext.indexCache());
|
||||
}
|
||||
}
|
|
@ -211,15 +211,15 @@ public class QueryStringJsonQueryParser extends AbstractIndexComponent implement
|
|||
MapperQueryParser queryParser;
|
||||
if (fields != null) {
|
||||
if (fields.size() == 1) {
|
||||
queryParser = new MapperQueryParser(fields.get(0), analyzer, parseContext.mapperService(), parseContext.filterCache());
|
||||
queryParser = new MapperQueryParser(fields.get(0), analyzer, parseContext.mapperService(), parseContext.indexCache());
|
||||
} else {
|
||||
MultiFieldMapperQueryParser mQueryParser = new MultiFieldMapperQueryParser(fields, boosts, analyzer, parseContext.mapperService(), parseContext.filterCache());
|
||||
MultiFieldMapperQueryParser mQueryParser = new MultiFieldMapperQueryParser(fields, boosts, analyzer, parseContext.mapperService(), parseContext.indexCache());
|
||||
mQueryParser.setTieBreaker(tieBreaker);
|
||||
mQueryParser.setUseDisMax(useDisMax);
|
||||
queryParser = mQueryParser;
|
||||
}
|
||||
} else {
|
||||
queryParser = new MapperQueryParser(defaultField, analyzer, parseContext.mapperService(), parseContext.filterCache());
|
||||
queryParser = new MapperQueryParser(defaultField, analyzer, parseContext.mapperService(), parseContext.indexCache());
|
||||
}
|
||||
queryParser.setEnablePositionIncrements(enablePositionIncrements);
|
||||
queryParser.setLowercaseExpandedTerms(lowercaseExpandedTerms);
|
||||
|
|
|
@ -118,6 +118,6 @@ public class RangeJsonFilterParser extends AbstractIndexComponent implements Jso
|
|||
if (filter == null) {
|
||||
filter = new TermRangeFilter(fieldName, from, to, includeLower, includeUpper);
|
||||
}
|
||||
return wrapSmartNameFilter(filter, smartNameFieldMappers, parseContext.filterCache());
|
||||
return wrapSmartNameFilter(filter, smartNameFieldMappers, parseContext.indexCache());
|
||||
}
|
||||
}
|
|
@ -122,6 +122,6 @@ public class RangeJsonQueryParser extends AbstractIndexComponent implements Json
|
|||
query = new TermRangeQuery(fieldName, from, to, includeLower, includeUpper);
|
||||
}
|
||||
query.setBoost(boost);
|
||||
return wrapSmartNameQuery(query, smartNameFieldMappers, parseContext.filterCache());
|
||||
return wrapSmartNameQuery(query, smartNameFieldMappers, parseContext.indexCache());
|
||||
}
|
||||
}
|
|
@ -102,6 +102,6 @@ public class SpanTermJsonQueryParser extends AbstractIndexComponent implements J
|
|||
|
||||
SpanTermQuery query = new SpanTermQuery(new Term(fieldName, value));
|
||||
query.setBoost(boost);
|
||||
return wrapSmartNameQuery(query, smartNameFieldMappers, parseContext.filterCache());
|
||||
return wrapSmartNameQuery(query, smartNameFieldMappers, parseContext.indexCache());
|
||||
}
|
||||
}
|
|
@ -79,6 +79,6 @@ public class TermJsonFilterParser extends AbstractIndexComponent implements Json
|
|||
filter = new TermFilter(new Term(fieldName, value));
|
||||
}
|
||||
filter = parseContext.cacheFilterIfPossible(filter);
|
||||
return wrapSmartNameFilter(filter, smartNameFieldMappers, parseContext.filterCache());
|
||||
return wrapSmartNameFilter(filter, smartNameFieldMappers, parseContext.indexCache());
|
||||
}
|
||||
}
|
|
@ -100,6 +100,6 @@ public class TermJsonQueryParser extends AbstractIndexComponent implements JsonQ
|
|||
query = new TermQuery(new Term(fieldName, value));
|
||||
}
|
||||
query.setBoost(boost);
|
||||
return wrapSmartNameQuery(query, smartNameFieldMappers, parseContext.filterCache());
|
||||
return wrapSmartNameQuery(query, smartNameFieldMappers, parseContext.indexCache());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,6 +88,6 @@ public class TermsJsonFilterParser extends AbstractIndexComponent implements Jso
|
|||
|
||||
|
||||
Filter filter = parseContext.cacheFilterIfPossible(termsFilter);
|
||||
return wrapSmartNameFilter(filter, smartNameFieldMappers, parseContext.filterCache());
|
||||
return wrapSmartNameFilter(filter, smartNameFieldMappers, parseContext.indexCache());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,6 +101,6 @@ public class WildcardJsonQueryParser extends AbstractIndexComponent implements J
|
|||
WildcardQuery query = new WildcardQuery(new Term(fieldName, value));
|
||||
query.setRewriteMethod(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
|
||||
query.setBoost(boost);
|
||||
return wrapSmartNameQuery(query, smartNameFieldMappers, parseContext.filterCache());
|
||||
return wrapSmartNameQuery(query, smartNameFieldMappers, parseContext.indexCache());
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ import org.apache.lucene.search.BooleanClause;
|
|||
import org.apache.lucene.search.MultiTermQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.FieldMappers;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
|
@ -51,16 +51,16 @@ public class MapperQueryParser extends QueryParser {
|
|||
|
||||
private final MapperService mapperService;
|
||||
|
||||
private final FilterCache filterCache;
|
||||
private final IndexCache indexCache;
|
||||
|
||||
private FieldMapper currentMapper;
|
||||
|
||||
public MapperQueryParser(String defaultField, Analyzer analyzer,
|
||||
@Nullable MapperService mapperService,
|
||||
@Nullable FilterCache filterCache) {
|
||||
@Nullable IndexCache indexCache) {
|
||||
super(Version.LUCENE_CURRENT, defaultField, analyzer);
|
||||
this.mapperService = mapperService;
|
||||
this.filterCache = filterCache;
|
||||
this.indexCache = indexCache;
|
||||
setMultiTermRewriteMethod(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class MapperQueryParser extends QueryParser {
|
|||
} else {
|
||||
query = super.getFieldQuery(currentMapper.names().indexName(), queryText);
|
||||
}
|
||||
return wrapSmartNameQuery(query, fieldMappers, filterCache);
|
||||
return wrapSmartNameQuery(query, fieldMappers, indexCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public class MapperQueryParser extends QueryParser {
|
|||
currentMapper = fieldMappers.fieldMappers().mapper();
|
||||
if (currentMapper != null) {
|
||||
Query rangeQuery = currentMapper.rangeQuery(part1, part2, inclusive, inclusive);
|
||||
return wrapSmartNameQuery(rangeQuery, fieldMappers, filterCache);
|
||||
return wrapSmartNameQuery(rangeQuery, fieldMappers, indexCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class MapperQueryParser extends QueryParser {
|
|||
if (currentMapper != null) {
|
||||
indexedNameField = currentMapper.names().indexName();
|
||||
}
|
||||
return wrapSmartNameQuery(super.getPrefixQuery(indexedNameField, termStr), fieldMappers, filterCache);
|
||||
return wrapSmartNameQuery(super.getPrefixQuery(indexedNameField, termStr), fieldMappers, indexCache);
|
||||
}
|
||||
}
|
||||
return super.getPrefixQuery(indexedNameField, termStr);
|
||||
|
@ -141,7 +141,7 @@ public class MapperQueryParser extends QueryParser {
|
|||
if (currentMapper != null) {
|
||||
indexedNameField = currentMapper.names().indexName();
|
||||
}
|
||||
return wrapSmartNameQuery(super.getFuzzyQuery(indexedNameField, termStr, minSimilarity), fieldMappers, filterCache);
|
||||
return wrapSmartNameQuery(super.getFuzzyQuery(indexedNameField, termStr, minSimilarity), fieldMappers, indexCache);
|
||||
}
|
||||
}
|
||||
return super.getFuzzyQuery(indexedNameField, termStr, minSimilarity);
|
||||
|
@ -157,7 +157,7 @@ public class MapperQueryParser extends QueryParser {
|
|||
if (currentMapper != null) {
|
||||
indexedNameField = currentMapper.names().indexName();
|
||||
}
|
||||
return wrapSmartNameQuery(super.getWildcardQuery(indexedNameField, termStr), fieldMappers, filterCache);
|
||||
return wrapSmartNameQuery(super.getWildcardQuery(indexedNameField, termStr), fieldMappers, indexCache);
|
||||
}
|
||||
}
|
||||
return super.getWildcardQuery(indexedNameField, termStr);
|
||||
|
|
|
@ -22,7 +22,7 @@ package org.elasticsearch.index.query.support;
|
|||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.util.Nullable;
|
||||
import org.elasticsearch.util.trove.ExtTObjectFloatHashMap;
|
||||
|
@ -43,8 +43,8 @@ public class MultiFieldMapperQueryParser extends MapperQueryParser {
|
|||
|
||||
private boolean useDisMax = true;
|
||||
|
||||
public MultiFieldMapperQueryParser(List<String> fields, @Nullable ExtTObjectFloatHashMap<String> boosts, Analyzer analyzer, @Nullable MapperService mapperService, @Nullable FilterCache filterCache) {
|
||||
super(null, analyzer, mapperService, filterCache);
|
||||
public MultiFieldMapperQueryParser(List<String> fields, @Nullable ExtTObjectFloatHashMap<String> boosts, Analyzer analyzer, @Nullable MapperService mapperService, @Nullable IndexCache indexCache) {
|
||||
super(null, analyzer, mapperService, indexCache);
|
||||
this.fields = fields;
|
||||
this.boosts = boosts;
|
||||
if (this.boosts != null) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.index.query.support;
|
||||
|
||||
import org.apache.lucene.search.*;
|
||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.util.Nullable;
|
||||
|
@ -36,7 +36,7 @@ public final class QueryParsers {
|
|||
}
|
||||
|
||||
public static Query wrapSmartNameQuery(Query query, @Nullable MapperService.SmartNameFieldMappers smartFieldMappers,
|
||||
@Nullable FilterCache filterCache) {
|
||||
@Nullable IndexCache indexCache) {
|
||||
if (smartFieldMappers == null) {
|
||||
return query;
|
||||
}
|
||||
|
@ -45,14 +45,14 @@ public final class QueryParsers {
|
|||
}
|
||||
DocumentMapper docMapper = smartFieldMappers.docMapper();
|
||||
Filter typeFilter = new TermFilter(docMapper.typeMapper().term(docMapper.type()));
|
||||
if (filterCache != null) {
|
||||
typeFilter = filterCache.cache(typeFilter);
|
||||
if (indexCache != null) {
|
||||
typeFilter = indexCache.filter().cache(typeFilter);
|
||||
}
|
||||
return new FilteredQuery(query, typeFilter);
|
||||
}
|
||||
|
||||
public static Filter wrapSmartNameFilter(Filter filter, @Nullable MapperService.SmartNameFieldMappers smartFieldMappers,
|
||||
@Nullable FilterCache filterCache) {
|
||||
@Nullable IndexCache indexCache) {
|
||||
if (smartFieldMappers == null) {
|
||||
return filter;
|
||||
}
|
||||
|
@ -62,15 +62,15 @@ public final class QueryParsers {
|
|||
DocumentMapper docMapper = smartFieldMappers.docMapper();
|
||||
BooleanFilter booleanFilter = new BooleanFilter();
|
||||
Filter typeFilter = new TermFilter(docMapper.typeMapper().term(docMapper.type()));
|
||||
if (filterCache != null) {
|
||||
typeFilter = filterCache.cache(typeFilter);
|
||||
if (indexCache != null) {
|
||||
typeFilter = indexCache.filter().cache(typeFilter);
|
||||
}
|
||||
booleanFilter.add(new FilterClause(typeFilter, BooleanClause.Occur.MUST));
|
||||
booleanFilter.add(new FilterClause(filter, BooleanClause.Occur.MUST));
|
||||
|
||||
Filter result = booleanFilter;
|
||||
if (filterCache != null) {
|
||||
result = filterCache.cache(result);
|
||||
if (indexCache != null) {
|
||||
result = indexCache.filter().cache(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.elasticsearch.ElasticSearchException;
|
|||
import org.elasticsearch.index.IndexComponent;
|
||||
import org.elasticsearch.index.IndexLifecycle;
|
||||
import org.elasticsearch.index.IndexShardMissingException;
|
||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.query.IndexQueryParserService;
|
||||
import org.elasticsearch.index.routing.OperationRouting;
|
||||
|
@ -42,7 +42,7 @@ public interface IndexService extends IndexComponent, Iterable<IndexShard>, Clos
|
|||
|
||||
Injector injector();
|
||||
|
||||
FilterCache filterCache();
|
||||
IndexCache cache();
|
||||
|
||||
OperationRouting operationRouting();
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.google.inject.Inject;
|
|||
import com.google.inject.Injector;
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.index.*;
|
||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.deletionpolicy.DeletionPolicyModule;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
import org.elasticsearch.index.engine.EngineModule;
|
||||
|
@ -79,7 +79,7 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde
|
|||
|
||||
private final SimilarityService similarityService;
|
||||
|
||||
private final FilterCache filterCache;
|
||||
private final IndexCache indexCache;
|
||||
|
||||
private final OperationRouting operationRouting;
|
||||
|
||||
|
@ -89,14 +89,14 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde
|
|||
|
||||
@Inject public InternalIndexService(Injector injector, Index index, @IndexSettings Settings indexSettings,
|
||||
MapperService mapperService, IndexQueryParserService queryParserService, SimilarityService similarityService,
|
||||
FilterCache filterCache, OperationRouting operationRouting) {
|
||||
IndexCache indexCache, OperationRouting operationRouting) {
|
||||
super(index, indexSettings);
|
||||
this.injector = injector;
|
||||
this.indexSettings = indexSettings;
|
||||
this.mapperService = mapperService;
|
||||
this.queryParserService = queryParserService;
|
||||
this.similarityService = similarityService;
|
||||
this.filterCache = filterCache;
|
||||
this.indexCache = indexCache;
|
||||
this.operationRouting = operationRouting;
|
||||
|
||||
this.pluginsService = injector.getInstance(PluginsService.class);
|
||||
|
@ -134,8 +134,8 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde
|
|||
return injector;
|
||||
}
|
||||
|
||||
@Override public FilterCache filterCache() {
|
||||
return filterCache;
|
||||
@Override public IndexCache cache() {
|
||||
return indexCache;
|
||||
}
|
||||
|
||||
@Override public OperationRouting operationRouting() {
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.elasticsearch.ElasticSearchException;
|
|||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
import org.elasticsearch.ElasticSearchIllegalStateException;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
import org.elasticsearch.index.engine.EngineException;
|
||||
import org.elasticsearch.index.engine.ScheduledRefreshableEngine;
|
||||
|
@ -69,7 +69,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||
|
||||
private final IndexQueryParserService queryParserService;
|
||||
|
||||
private final FilterCache filterCache;
|
||||
private final IndexCache indexCache;
|
||||
|
||||
private final Store store;
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||
private volatile ShardRouting shardRouting;
|
||||
|
||||
@Inject public InternalIndexShard(ShardId shardId, @IndexSettings Settings indexSettings, Store store, Engine engine, Translog translog,
|
||||
ThreadPool threadPool, MapperService mapperService, IndexQueryParserService queryParserService, FilterCache filterCache) {
|
||||
ThreadPool threadPool, MapperService mapperService, IndexQueryParserService queryParserService, IndexCache indexCache) {
|
||||
super(shardId, indexSettings);
|
||||
this.store = store;
|
||||
this.engine = engine;
|
||||
|
@ -94,7 +94,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||
this.threadPool = threadPool;
|
||||
this.mapperService = mapperService;
|
||||
this.queryParserService = queryParserService;
|
||||
this.filterCache = filterCache;
|
||||
this.indexCache = indexCache;
|
||||
state = IndexShardState.CREATED;
|
||||
logger.debug("Moved to state [CREATED]");
|
||||
}
|
||||
|
@ -491,7 +491,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||
throw new TypeMissingException(shardId.index(), type);
|
||||
}
|
||||
Filter typeFilter = new TermFilter(docMapper.typeMapper().term(docMapper.type()));
|
||||
typeFilter = filterCache.cache(typeFilter);
|
||||
typeFilter = indexCache.filter().cache(typeFilter);
|
||||
query = new FilteredQuery(query, typeFilter);
|
||||
} else {
|
||||
BooleanFilter booleanFilter = new BooleanFilter();
|
||||
|
@ -501,7 +501,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||
throw new TypeMissingException(shardId.index(), type);
|
||||
}
|
||||
Filter typeFilter = new TermFilter(docMapper.typeMapper().term(docMapper.type()));
|
||||
typeFilter = filterCache.cache(typeFilter);
|
||||
typeFilter = indexCache.filter().cache(typeFilter);
|
||||
booleanFilter.add(new FilterClause(typeFilter, BooleanClause.Occur.SHOULD));
|
||||
}
|
||||
query = new FilteredQuery(query, booleanFilter);
|
||||
|
|
|
@ -30,8 +30,8 @@ import org.elasticsearch.gateway.Gateway;
|
|||
import org.elasticsearch.index.*;
|
||||
import org.elasticsearch.index.analysis.AnalysisModule;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.cache.IndexCacheModule;
|
||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
||||
import org.elasticsearch.index.cache.filter.FilterCacheModule;
|
||||
import org.elasticsearch.index.gateway.IndexGateway;
|
||||
import org.elasticsearch.index.gateway.IndexGatewayModule;
|
||||
import org.elasticsearch.index.mapper.MapperServiceModule;
|
||||
|
@ -165,7 +165,7 @@ public class InternalIndicesService extends AbstractLifecycleComponent<IndicesSe
|
|||
new IndicesPluginsModule(indexSettings, pluginsService),
|
||||
new AnalysisModule(indexSettings),
|
||||
new SimilarityModule(indexSettings),
|
||||
new FilterCacheModule(indexSettings),
|
||||
new IndexCacheModule(indexSettings),
|
||||
new IndexQueryParserModule(indexSettings),
|
||||
new MapperServiceModule(),
|
||||
new IndexGatewayModule(indexSettings, injector.getInstance(Gateway.class)),
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.rest.action.admin.cluster.ping.replication.RestReplicat
|
|||
import org.elasticsearch.rest.action.admin.cluster.ping.single.RestSinglePingAction;
|
||||
import org.elasticsearch.rest.action.admin.cluster.state.RestClusterStateAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.alias.RestIndicesAliasesAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.cache.clear.RestClearIndicesCacheAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.create.RestCreateIndexAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.delete.RestDeleteIndexAction;
|
||||
import org.elasticsearch.rest.action.admin.indices.flush.RestFlushAction;
|
||||
|
@ -76,6 +77,7 @@ public class RestActionModule extends AbstractModule {
|
|||
bind(RestRefreshAction.class).asEagerSingleton();
|
||||
bind(RestFlushAction.class).asEagerSingleton();
|
||||
bind(RestOptimizeAction.class).asEagerSingleton();
|
||||
bind(RestClearIndicesCacheAction.class).asEagerSingleton();
|
||||
|
||||
bind(RestIndexAction.class).asEagerSingleton();
|
||||
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.rest.action.admin.indices.cache.clear;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastOperationThreading;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.rest.*;
|
||||
import org.elasticsearch.rest.action.support.RestActions;
|
||||
import org.elasticsearch.rest.action.support.RestJsonBuilder;
|
||||
import org.elasticsearch.util.json.JsonBuilder;
|
||||
import org.elasticsearch.util.settings.Settings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.elasticsearch.rest.RestRequest.Method.*;
|
||||
import static org.elasticsearch.rest.RestResponse.Status.*;
|
||||
import static org.elasticsearch.rest.action.support.RestActions.*;
|
||||
|
||||
/**
|
||||
* @author kimchy (Shay Banon)
|
||||
*/
|
||||
public class RestClearIndicesCacheAction extends BaseRestHandler {
|
||||
|
||||
@Inject public RestClearIndicesCacheAction(Settings settings, Client client, RestController controller) {
|
||||
super(settings, client);
|
||||
controller.registerHandler(POST, "/_cache/clear", this);
|
||||
controller.registerHandler(POST, "/{index}/_cache/clear", this);
|
||||
}
|
||||
|
||||
@Override public void handleRequest(final RestRequest request, final RestChannel channel) {
|
||||
ClearIndicesCacheRequest clearIndicesCacheRequest = new ClearIndicesCacheRequest(RestActions.splitIndices(request.param("index")));
|
||||
try {
|
||||
clearIndicesCacheRequest.filterCache(request.paramAsBoolean("filterCache", clearIndicesCacheRequest.filterCache()));
|
||||
|
||||
// we just send back a response, no need to fork a listener
|
||||
clearIndicesCacheRequest.listenerThreaded(false);
|
||||
BroadcastOperationThreading operationThreading = BroadcastOperationThreading.fromString(request.param("operationThreading"), BroadcastOperationThreading.SINGLE_THREAD);
|
||||
if (operationThreading == BroadcastOperationThreading.NO_THREADS) {
|
||||
// since we don't spawn, don't allow no_threads, but change it to a single thread
|
||||
operationThreading = BroadcastOperationThreading.THREAD_PER_SHARD;
|
||||
}
|
||||
clearIndicesCacheRequest.operationThreading(operationThreading);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
JsonBuilder builder = RestJsonBuilder.restJsonBuilder(request);
|
||||
channel.sendResponse(new JsonRestResponse(request, BAD_REQUEST, builder.startObject().field("error", e.getMessage()).endObject()));
|
||||
} catch (IOException e1) {
|
||||
logger.error("Failed to send failure response", e1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
client.admin().indices().clearCache(clearIndicesCacheRequest, new ActionListener<ClearIndicesCacheResponse>() {
|
||||
@Override public void onResponse(ClearIndicesCacheResponse response) {
|
||||
try {
|
||||
JsonBuilder builder = RestJsonBuilder.restJsonBuilder(request);
|
||||
builder.startObject();
|
||||
builder.field("ok", true);
|
||||
|
||||
buildBroadcastShardsHeader(builder, response);
|
||||
|
||||
builder.endObject();
|
||||
channel.sendResponse(new JsonRestResponse(request, OK, builder));
|
||||
} catch (Exception e) {
|
||||
onFailure(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onFailure(Throwable e) {
|
||||
try {
|
||||
channel.sendResponse(new JsonThrowableRestResponse(request, e));
|
||||
} catch (IOException e1) {
|
||||
logger.error("Failed to send failure response", e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -205,7 +205,7 @@ public class SearchContext implements Releasable {
|
|||
}
|
||||
|
||||
public FilterCache filterCache() {
|
||||
return indexService.filterCache();
|
||||
return indexService.cache().filter();
|
||||
}
|
||||
|
||||
public TimeValue timeout() {
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.lucene.util.NumericUtils;
|
|||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.cache.filter.none.NoneFilterCache;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.query.IndexQueryParser;
|
||||
import org.elasticsearch.util.lucene.search.MoreLikeThisQuery;
|
||||
|
@ -757,7 +757,7 @@ public class SimpleJsonIndexQueryParserTests {
|
|||
|
||||
private JsonIndexQueryParser newQueryParser() throws IOException {
|
||||
return new JsonIndexQueryParser(new Index("test"), EMPTY_SETTINGS,
|
||||
newMapperService(), new NoneFilterCache(index, EMPTY_SETTINGS), new AnalysisService(index), null, null, null, "test", null);
|
||||
newMapperService(), new IndexCache(index), new AnalysisService(index), null, null, null, "test", null);
|
||||
}
|
||||
|
||||
private MapperService newMapperService() throws IOException {
|
||||
|
|
|
@ -21,8 +21,7 @@ package org.elasticsearch.index.shard;
|
|||
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.cache.filter.FilterCache;
|
||||
import org.elasticsearch.index.cache.filter.none.NoneFilterCache;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.deletionpolicy.KeepOnlyLastDeletionPolicy;
|
||||
import org.elasticsearch.index.deletionpolicy.SnapshotDeletionPolicy;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
|
@ -65,8 +64,8 @@ public class SimpleIndexShardTests {
|
|||
ShardId shardId = new ShardId("test", 1);
|
||||
AnalysisService analysisService = new AnalysisService(shardId.index());
|
||||
MapperService mapperService = new MapperService(shardId.index(), settings, environment, analysisService);
|
||||
IndexQueryParserService queryParserService = new IndexQueryParserService(shardId.index(), mapperService, new NoneFilterCache(shardId.index(), EMPTY_SETTINGS), analysisService);
|
||||
FilterCache filterCache = new NoneFilterCache(shardId.index(), settings);
|
||||
IndexQueryParserService queryParserService = new IndexQueryParserService(shardId.index(), mapperService, new IndexCache(shardId.index()), analysisService);
|
||||
IndexCache indexCache = new IndexCache(shardId.index());
|
||||
|
||||
SnapshotDeletionPolicy policy = new SnapshotDeletionPolicy(new KeepOnlyLastDeletionPolicy(shardId, settings));
|
||||
Store store = new RamStore(shardId, settings);
|
||||
|
@ -77,7 +76,7 @@ public class SimpleIndexShardTests {
|
|||
|
||||
threadPool = new ScalingThreadPool();
|
||||
|
||||
indexShard = new InternalIndexShard(shardId, EMPTY_SETTINGS, store, engine, translog, threadPool, mapperService, queryParserService, filterCache).start();
|
||||
indexShard = new InternalIndexShard(shardId, EMPTY_SETTINGS, store, engine, translog, threadPool, mapperService, queryParserService, indexCache).start();
|
||||
}
|
||||
|
||||
@AfterMethod public void tearDown() {
|
||||
|
|
|
@ -83,7 +83,7 @@ public class IndexAliasesTests extends AbstractServersTests {
|
|||
}
|
||||
|
||||
logger.info("Aliasing index [test] with [alias1]");
|
||||
client1.admin().indices().indicesAliases(indexAliasesRequest().addAlias("test", "alias1")).actionGet();
|
||||
client1.admin().indices().aliases(indexAliasesRequest().addAlias("test", "alias1")).actionGet();
|
||||
Thread.sleep(300);
|
||||
|
||||
logger.info("Indexing against [alias1], should work now");
|
||||
|
@ -100,7 +100,7 @@ public class IndexAliasesTests extends AbstractServersTests {
|
|||
assertThat(clusterHealth.status(), equalTo(ClusterHealthStatus.GREEN));
|
||||
|
||||
logger.info("Remove [alias1], Aliasing index [test_x] with [alias1]");
|
||||
client1.admin().indices().indicesAliases(indexAliasesRequest().removeAlias("test", "alias1").addAlias("test_x", "alias1")).actionGet();
|
||||
client1.admin().indices().aliases(indexAliasesRequest().removeAlias("test", "alias1").addAlias("test_x", "alias1")).actionGet();
|
||||
Thread.sleep(300);
|
||||
|
||||
logger.info("Indexing against [alias1], should work against [test_x]");
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.test.integration.document;
|
|||
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse;
|
||||
import org.elasticsearch.action.admin.indices.flush.FlushResponse;
|
||||
import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse;
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
|
||||
|
@ -100,6 +101,11 @@ public class DocumentActionsTests extends AbstractServersTests {
|
|||
assertThat(refreshResponse.successfulShards(), equalTo(10));
|
||||
assertThat(refreshResponse.failedShards(), equalTo(0));
|
||||
|
||||
logger.info("Clearing cache");
|
||||
ClearIndicesCacheResponse clearIndicesCacheResponse = client1.admin().indices().clearCache(clearIndicesCache("test")).actionGet();
|
||||
assertThat(clearIndicesCacheResponse.successfulShards(), equalTo(10));
|
||||
assertThat(clearIndicesCacheResponse.failedShards(), equalTo(0));
|
||||
|
||||
logger.info("Optimizing");
|
||||
OptimizeResponse optimizeResponse = client1.admin().indices().optimize(optimizeRequest("test")).actionGet();
|
||||
assertThat(optimizeResponse.successfulShards(), equalTo(10));
|
||||
|
|
Loading…
Reference in New Issue