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.ElasticsearchIllegalArgumentException;
import org.elasticsearch.ElasticsearchIllegalStateException; import org.elasticsearch.ElasticsearchIllegalStateException;
import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse; import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.index.IndexResponse;
@ -376,11 +378,13 @@ public class ScriptService extends AbstractComponent {
} }
public GetResponse queryScriptIndex(Client client, String scriptLang, String id, public GetResponse queryScriptIndex(Client client, String scriptLang, String id,
long version, VersionType versionType){ long version, VersionType versionType) {
scriptLang = validateScriptLanguage(scriptLang); scriptLang = validateScriptLanguage(scriptLang);
return client.prepareGet(SCRIPT_INDEX, scriptLang, id) return client.prepareGet(SCRIPT_INDEX, scriptLang, id)
.setVersion(version) .setVersion(version)
.setVersionType(versionType) .setVersionType(versionType)
.setPreference("_local") //Set preference for no forking
.setOperationThreaded(false)
.get(); .get();
} }