Index / Delete API: timeout should apply automatically to the auto create index API master timeout, closes #1664.

This commit is contained in:
Shay Banon 2012-02-05 13:45:32 +02:00
parent 5b62c2ae26
commit 3cee291bc2
3 changed files with 11 additions and 2 deletions

View File

@ -251,6 +251,15 @@ public class CreateIndexRequest extends MasterNodeOperationRequest {
return timeout(TimeValue.parseTimeValue(timeout, null));
}
/**
* A timeout value in case the master has not been discovered yet or disconnected.
*/
@Override
public CreateIndexRequest masterNodeTimeout(TimeValue timeout) {
this.masterNodeTimeout = timeout;
return this;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);

View File

@ -75,7 +75,7 @@ public class TransportDeleteAction extends TransportShardReplicationOperationAct
protected void doExecute(final DeleteRequest request, final ActionListener<DeleteResponse> listener) {
if (autoCreateIndex && !clusterService.state().metaData().hasConcreteIndex(request.index())) {
request.beforeLocalFork();
createIndexAction.execute(new CreateIndexRequest(request.index()), new ActionListener<CreateIndexResponse>() {
createIndexAction.execute(new CreateIndexRequest(request.index()).cause("auto(delete api)").masterNodeTimeout(request.timeout()), new ActionListener<CreateIndexResponse>() {
@Override
public void onResponse(CreateIndexResponse result) {
innerExecute(request, listener);

View File

@ -93,7 +93,7 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi
// if we don't have a master, we don't have metadata, that's fine, let it find a master using create index API
if (autoCreateIndex && !clusterService.state().metaData().hasConcreteIndex(request.index())) {
request.beforeLocalFork(); // we fork on another thread...
createIndexAction.execute(new CreateIndexRequest(request.index()).cause("auto(index api)"), new ActionListener<CreateIndexResponse>() {
createIndexAction.execute(new CreateIndexRequest(request.index()).cause("auto(index api)").masterNodeTimeout(request.timeout()), new ActionListener<CreateIndexResponse>() {
@Override
public void onResponse(CreateIndexResponse result) {
innerExecute(request, listener);