rename operationThreading method

This commit is contained in:
kimchy 2010-03-24 00:28:05 +02:00
parent 621d222c94
commit 6a476f440b
8 changed files with 20 additions and 20 deletions

View File

@ -56,8 +56,8 @@ public class SinglePingRequest extends SingleOperationRequest {
return this; return this;
} }
@Override public SinglePingRequest threadedOperation(boolean threadedOperation) { @Override public SinglePingRequest operationThreaded(boolean threadedOperation) {
super.threadedOperation(threadedOperation); super.operationThreaded(threadedOperation);
return this; return this;
} }

View File

@ -108,8 +108,8 @@ public class GetRequest extends SingleOperationRequest {
/** /**
* Controls if the operation will be executed on a separate thread when executed locally. * Controls if the operation will be executed on a separate thread when executed locally.
*/ */
@Override public GetRequest threadedOperation(boolean threadedOperation) { @Override public GetRequest operationThreaded(boolean threadedOperation) {
super.threadedOperation(threadedOperation); super.operationThreaded(threadedOperation);
return this; return this;
} }

View File

@ -37,7 +37,7 @@ public abstract class SingleOperationRequest implements ActionRequest {
protected String id; protected String id;
private boolean threadedListener = false; private boolean threadedListener = false;
private boolean threadedOperation = false; private boolean threadedOperation = true;
protected SingleOperationRequest() { protected SingleOperationRequest() {
} }
@ -89,14 +89,14 @@ public abstract class SingleOperationRequest implements ActionRequest {
/** /**
* Controls if the operation will be executed on a separate thread when executed locally. * Controls if the operation will be executed on a separate thread when executed locally.
*/ */
public boolean threadedOperation() { public boolean operationThreaded() {
return threadedOperation; return threadedOperation;
} }
/** /**
* Controls if the operation will be executed on a separate thread when executed locally. * Controls if the operation will be executed on a separate thread when executed locally.
*/ */
public SingleOperationRequest threadedOperation(boolean threadedOperation) { public SingleOperationRequest operationThreaded(boolean threadedOperation) {
this.threadedOperation = threadedOperation; this.threadedOperation = threadedOperation;
return this; return this;
} }

View File

@ -125,7 +125,7 @@ public abstract class TransportSingleOperationAction<Request extends SingleOpera
continue; continue;
} }
if (shard.currentNodeId().equals(nodes.localNodeId())) { if (shard.currentNodeId().equals(nodes.localNodeId())) {
if (request.threadedOperation()) { if (request.operationThreaded()) {
threadPool.execute(new Runnable() { threadPool.execute(new Runnable() {
@Override public void run() { @Override public void run() {
try { try {
@ -226,7 +226,7 @@ public abstract class TransportSingleOperationAction<Request extends SingleOpera
// no need to have a threaded listener since we just send back a response // no need to have a threaded listener since we just send back a response
request.listenerThreaded(false); request.listenerThreaded(false);
// if we have a local operation, execute it on a thread since we don't spawn // if we have a local operation, execute it on a thread since we don't spawn
request.threadedOperation(true); request.operationThreaded(true);
execute(request, new ActionListener<Response>() { execute(request, new ActionListener<Response>() {
@Override public void onResponse(Response result) { @Override public void onResponse(Response result) {
try { try {

View File

@ -49,7 +49,7 @@ public class RestSinglePingAction extends BaseRestHandler {
// no need to have a threaded listener since we just send back a response // no need to have a threaded listener since we just send back a response
singlePingRequest.listenerThreaded(false); singlePingRequest.listenerThreaded(false);
// if we have a local operation, execute it on a thread since we don't spawn // if we have a local operation, execute it on a thread since we don't spawn
singlePingRequest.threadedOperation(true); singlePingRequest.operationThreaded(true);
client.admin().cluster().ping(singlePingRequest, new ActionListener<SinglePingResponse>() { client.admin().cluster().ping(singlePingRequest, new ActionListener<SinglePingResponse>() {
@Override public void onResponse(SinglePingResponse result) { @Override public void onResponse(SinglePingResponse result) {
try { try {

View File

@ -59,7 +59,7 @@ public class RestGetAction extends BaseRestHandler {
// no need to have a threaded listener since we just send back a response // no need to have a threaded listener since we just send back a response
getRequest.listenerThreaded(false); getRequest.listenerThreaded(false);
// if we have a local operation, execute it on a thread since we don't spawn // if we have a local operation, execute it on a thread since we don't spawn
getRequest.threadedOperation(true); getRequest.operationThreaded(true);
List<String> fields = request.params("field"); List<String> fields = request.params("field");

View File

@ -101,10 +101,10 @@ public class DocumentActionsTests extends AbstractServersTests {
logger.info("Get [type1/1]"); logger.info("Get [type1/1]");
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
getResult = client1.get(getRequest("test").type("type1").id("1").threadedOperation(false)).actionGet(); getResult = client1.get(getRequest("test").type("type1").id("1").operationThreaded(false)).actionGet();
assertThat("cycle #" + i, getResult.sourceAsString(), equalTo(source("1", "test"))); assertThat("cycle #" + i, getResult.sourceAsString(), equalTo(source("1", "test")));
assertThat("cycle(map) #" + i, (String) ((Map) getResult.sourceAsMap().get("type1")).get("name"), equalTo("test")); assertThat("cycle(map) #" + i, (String) ((Map) getResult.sourceAsMap().get("type1")).get("name"), equalTo("test"));
getResult = client1.get(getRequest("test").type("type1").id("1").threadedOperation(true)).actionGet(); getResult = client1.get(getRequest("test").type("type1").id("1").operationThreaded(true)).actionGet();
assertThat("cycle #" + i, getResult.sourceAsString(), equalTo(source("1", "test"))); assertThat("cycle #" + i, getResult.sourceAsString(), equalTo(source("1", "test")));
} }

View File

@ -54,13 +54,13 @@ public class SimpleRecoveryTests extends AbstractServersTests {
GetResponse getResult; GetResponse getResult;
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
getResult = client("server1").get(getRequest("test").type("type1").id("1").threadedOperation(false)).actionGet(1000); getResult = client("server1").get(getRequest("test").type("type1").id("1").operationThreaded(false)).actionGet(1000);
assertThat(getResult.sourceAsString(), equalTo(source("1", "test"))); assertThat(getResult.sourceAsString(), equalTo(source("1", "test")));
getResult = client("server2").get(getRequest("test").type("type1").id("1").threadedOperation(false)).actionGet(1000); getResult = client("server2").get(getRequest("test").type("type1").id("1").operationThreaded(false)).actionGet(1000);
assertThat(getResult.sourceAsString(), equalTo(source("1", "test"))); assertThat(getResult.sourceAsString(), equalTo(source("1", "test")));
getResult = client("server1").get(getRequest("test").type("type1").id("2").threadedOperation(true)).actionGet(1000); getResult = client("server1").get(getRequest("test").type("type1").id("2").operationThreaded(true)).actionGet(1000);
assertThat(getResult.sourceAsString(), equalTo(source("2", "test"))); assertThat(getResult.sourceAsString(), equalTo(source("2", "test")));
getResult = client("server2").get(getRequest("test").type("type1").id("2").threadedOperation(true)).actionGet(1000); getResult = client("server2").get(getRequest("test").type("type1").id("2").operationThreaded(true)).actionGet(1000);
assertThat(getResult.sourceAsString(), equalTo(source("2", "test"))); assertThat(getResult.sourceAsString(), equalTo(source("2", "test")));
} }
@ -75,11 +75,11 @@ public class SimpleRecoveryTests extends AbstractServersTests {
assertThat(getResult.sourceAsString(), equalTo(source("1", "test"))); assertThat(getResult.sourceAsString(), equalTo(source("1", "test")));
getResult = client("server3").get(getRequest("test").type("type1").id("1")).actionGet(1000); getResult = client("server3").get(getRequest("test").type("type1").id("1")).actionGet(1000);
assertThat(getResult.sourceAsString(), equalTo(source("1", "test"))); assertThat(getResult.sourceAsString(), equalTo(source("1", "test")));
getResult = client("server1").get(getRequest("test").type("type1").id("2").threadedOperation(true)).actionGet(1000); getResult = client("server1").get(getRequest("test").type("type1").id("2").operationThreaded(true)).actionGet(1000);
assertThat(getResult.sourceAsString(), equalTo(source("2", "test"))); assertThat(getResult.sourceAsString(), equalTo(source("2", "test")));
getResult = client("server2").get(getRequest("test").type("type1").id("2").threadedOperation(true)).actionGet(1000); getResult = client("server2").get(getRequest("test").type("type1").id("2").operationThreaded(true)).actionGet(1000);
assertThat(getResult.sourceAsString(), equalTo(source("2", "test"))); assertThat(getResult.sourceAsString(), equalTo(source("2", "test")));
getResult = client("server3").get(getRequest("test").type("type1").id("2").threadedOperation(true)).actionGet(1000); getResult = client("server3").get(getRequest("test").type("type1").id("2").operationThreaded(true)).actionGet(1000);
assertThat(getResult.sourceAsString(), equalTo(source("2", "test"))); assertThat(getResult.sourceAsString(), equalTo(source("2", "test")));
} }
} }