Indexed Scripts : Change preference and thread option for GetRequest.

This change forces the GetRequest when a script is being loaded from an index
to use preference("_local") and threaded(false) to prevent the script service from
forking for GetRequests.
This commit is contained in:
Brian Murphy 2014-08-27 10:44:11 +01:00
parent 5453c08f50
commit 6109ec36b5
1 changed files with 5 additions and 1 deletions

View File

@ -26,8 +26,10 @@ import com.google.common.collect.ImmutableMap;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.ElasticsearchIllegalStateException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
@ -381,6 +383,8 @@ public class ScriptService extends AbstractComponent {
return client.prepareGet(SCRIPT_INDEX, scriptLang, id)
.setVersion(version)
.setVersionType(versionType)
.setPreference("_local") //Set preference for no forking
.setOperationThreaded(false)
.get();
}