rename create mapping to put mapping
This commit is contained in:
parent
2201839091
commit
0e55c876a4
|
@ -33,7 +33,7 @@ import org.elasticsearch.action.admin.indices.flush.TransportFlushAction;
|
||||||
import org.elasticsearch.action.admin.indices.gateway.snapshot.TransportGatewaySnapshotAction;
|
import org.elasticsearch.action.admin.indices.gateway.snapshot.TransportGatewaySnapshotAction;
|
||||||
import org.elasticsearch.action.admin.indices.gateway.snapshot.TransportIndexGatewaySnapshotAction;
|
import org.elasticsearch.action.admin.indices.gateway.snapshot.TransportIndexGatewaySnapshotAction;
|
||||||
import org.elasticsearch.action.admin.indices.gateway.snapshot.TransportShardGatewaySnapshotAction;
|
import org.elasticsearch.action.admin.indices.gateway.snapshot.TransportShardGatewaySnapshotAction;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.create.TransportCreateMappingAction;
|
import org.elasticsearch.action.admin.indices.mapping.put.TransportPutMappingAction;
|
||||||
import org.elasticsearch.action.admin.indices.optimize.TransportOptimizeAction;
|
import org.elasticsearch.action.admin.indices.optimize.TransportOptimizeAction;
|
||||||
import org.elasticsearch.action.admin.indices.refresh.TransportRefreshAction;
|
import org.elasticsearch.action.admin.indices.refresh.TransportRefreshAction;
|
||||||
import org.elasticsearch.action.admin.indices.status.TransportIndicesStatusAction;
|
import org.elasticsearch.action.admin.indices.status.TransportIndicesStatusAction;
|
||||||
|
@ -67,7 +67,7 @@ public class TransportActionModule extends AbstractModule {
|
||||||
|
|
||||||
bind(TransportIndicesStatusAction.class).asEagerSingleton();
|
bind(TransportIndicesStatusAction.class).asEagerSingleton();
|
||||||
bind(TransportCreateIndexAction.class).asEagerSingleton();
|
bind(TransportCreateIndexAction.class).asEagerSingleton();
|
||||||
bind(TransportCreateMappingAction.class).asEagerSingleton();
|
bind(TransportPutMappingAction.class).asEagerSingleton();
|
||||||
bind(TransportDeleteIndexAction.class).asEagerSingleton();
|
bind(TransportDeleteIndexAction.class).asEagerSingleton();
|
||||||
|
|
||||||
bind(TransportShardGatewaySnapshotAction.class).asEagerSingleton();
|
bind(TransportShardGatewaySnapshotAction.class).asEagerSingleton();
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
package org.elasticsearch.action;
|
package org.elasticsearch.action;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class TransportActions {
|
public class TransportActions {
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class TransportActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Mapping {
|
public static class Mapping {
|
||||||
public static final String CREATE = "indices/createMapping";
|
public static final String PUT = "indices/mapping/put";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,162 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.mapping.create;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import org.elasticsearch.ExceptionsHelper;
|
|
||||||
import org.elasticsearch.action.ActionListener;
|
|
||||||
import org.elasticsearch.action.Actions;
|
|
||||||
import org.elasticsearch.action.TransportActions;
|
|
||||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
|
||||||
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
|
||||||
import org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction;
|
|
||||||
import org.elasticsearch.action.support.BaseAction;
|
|
||||||
import org.elasticsearch.cluster.ClusterService;
|
|
||||||
import org.elasticsearch.cluster.metadata.MetaDataService;
|
|
||||||
import org.elasticsearch.indices.IndexAlreadyExistsException;
|
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
|
||||||
import org.elasticsearch.transport.*;
|
|
||||||
import org.elasticsearch.util.io.VoidStreamable;
|
|
||||||
import org.elasticsearch.util.settings.Settings;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author kimchy (Shay Banon)
|
|
||||||
*/
|
|
||||||
public class TransportCreateMappingAction extends BaseAction<CreateMappingRequest, CreateMappingResponse> {
|
|
||||||
|
|
||||||
private final TransportService transportService;
|
|
||||||
|
|
||||||
private final ClusterService clusterService;
|
|
||||||
|
|
||||||
private final MetaDataService metaDataService;
|
|
||||||
|
|
||||||
private final TransportCreateIndexAction createIndexAction;
|
|
||||||
|
|
||||||
private final ThreadPool threadPool;
|
|
||||||
|
|
||||||
private final boolean autoCreateIndex;
|
|
||||||
|
|
||||||
@Inject public TransportCreateMappingAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
|
||||||
ThreadPool threadPool, MetaDataService metaDataService, TransportCreateIndexAction createIndexAction) {
|
|
||||||
super(settings);
|
|
||||||
this.transportService = transportService;
|
|
||||||
this.clusterService = clusterService;
|
|
||||||
this.threadPool = threadPool;
|
|
||||||
this.metaDataService = metaDataService;
|
|
||||||
this.createIndexAction = createIndexAction;
|
|
||||||
this.autoCreateIndex = settings.getAsBoolean("action.autoCreateIndex", true);
|
|
||||||
|
|
||||||
transportService.registerHandler(TransportActions.Admin.Indices.Mapping.CREATE, new TransportHandler());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override protected void doExecute(final CreateMappingRequest request, final ActionListener<CreateMappingResponse> listener) {
|
|
||||||
final String[] indices = Actions.processIndices(clusterService.state(), request.indices());
|
|
||||||
if (autoCreateIndex) {
|
|
||||||
final CountDownLatch latch = new CountDownLatch(indices.length);
|
|
||||||
for (String index : indices) {
|
|
||||||
if (!clusterService.state().metaData().hasIndex(index)) {
|
|
||||||
createIndexAction.execute(new CreateIndexRequest(index), new ActionListener<CreateIndexResponse>() {
|
|
||||||
@Override public void onResponse(CreateIndexResponse result) {
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void onFailure(Throwable e) {
|
|
||||||
if (ExceptionsHelper.unwrapCause(e) instanceof IndexAlreadyExistsException) {
|
|
||||||
latch.countDown();
|
|
||||||
} else {
|
|
||||||
listener.onFailure(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
latch.await(10, TimeUnit.SECONDS);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (clusterService.state().nodes().localNodeMaster()) {
|
|
||||||
threadPool.execute(new Runnable() {
|
|
||||||
@Override public void run() {
|
|
||||||
try {
|
|
||||||
metaDataService.addMapping(indices, request.type(), request.mappingSource(), request.timeout());
|
|
||||||
listener.onResponse(new CreateMappingResponse());
|
|
||||||
} catch (Exception e) {
|
|
||||||
listener.onFailure(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
transportService.sendRequest(clusterService.state().nodes().masterNode(), TransportActions.Admin.Indices.Mapping.CREATE, request,
|
|
||||||
new VoidTransportResponseHandler() {
|
|
||||||
@Override public void handleResponse(VoidStreamable response) {
|
|
||||||
listener.onResponse(new CreateMappingResponse());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void handleException(RemoteTransportException exp) {
|
|
||||||
listener.onFailure(exp);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TransportHandler extends BaseTransportRequestHandler<CreateMappingRequest> {
|
|
||||||
|
|
||||||
|
|
||||||
@Override public CreateMappingRequest newInstance() {
|
|
||||||
return new CreateMappingRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void messageReceived(final CreateMappingRequest request, final TransportChannel channel) throws Exception {
|
|
||||||
String[] indices = Actions.processIndices(clusterService.state(), request.indices());
|
|
||||||
if (clusterService.state().nodes().localNodeMaster()) {
|
|
||||||
// handle the actual creation of a new index
|
|
||||||
metaDataService.addMapping(indices, request.type(), request.mappingSource(), request.timeout());
|
|
||||||
channel.sendResponse(VoidStreamable.INSTANCE);
|
|
||||||
} else {
|
|
||||||
transportService.sendRequest(clusterService.state().nodes().masterNode(), TransportActions.Admin.Indices.Mapping.CREATE, request, new VoidTransportResponseHandler() {
|
|
||||||
|
|
||||||
@Override public void handleResponse(VoidStreamable response) {
|
|
||||||
try {
|
|
||||||
channel.sendResponse(response);
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error("Failed to send response", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void handleException(RemoteTransportException exp) {
|
|
||||||
try {
|
|
||||||
channel.sendResponse(exp);
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error("Failed to send response", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,13 +17,12 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.action.admin.indices.mapping.create;
|
package org.elasticsearch.action.admin.indices.mapping.put;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequest;
|
|
||||||
import org.elasticsearch.action.ActionRequestValidationException;
|
import org.elasticsearch.action.ActionRequestValidationException;
|
||||||
|
import org.elasticsearch.action.support.master.MasterNodeOperationRequest;
|
||||||
import org.elasticsearch.util.Required;
|
import org.elasticsearch.util.Required;
|
||||||
import org.elasticsearch.util.TimeValue;
|
import org.elasticsearch.util.TimeValue;
|
||||||
import org.elasticsearch.util.io.Streamable;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
|
@ -36,7 +35,7 @@ import static org.elasticsearch.util.TimeValue.*;
|
||||||
/**
|
/**
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (Shay Banon)
|
||||||
*/
|
*/
|
||||||
public class CreateMappingRequest implements ActionRequest, Streamable {
|
public class PutMappingRequest extends MasterNodeOperationRequest {
|
||||||
|
|
||||||
private String[] indices;
|
private String[] indices;
|
||||||
|
|
||||||
|
@ -46,18 +45,18 @@ public class CreateMappingRequest implements ActionRequest, Streamable {
|
||||||
|
|
||||||
private TimeValue timeout = new TimeValue(10, TimeUnit.SECONDS);
|
private TimeValue timeout = new TimeValue(10, TimeUnit.SECONDS);
|
||||||
|
|
||||||
CreateMappingRequest() {
|
PutMappingRequest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateMappingRequest(String... indices) {
|
public PutMappingRequest(String... indices) {
|
||||||
this.indices = indices;
|
this.indices = indices;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateMappingRequest(String index, String mappingType, String mappingSource) {
|
public PutMappingRequest(String index, String mappingType, String mappingSource) {
|
||||||
this(new String[]{index}, mappingType, mappingSource);
|
this(new String[]{index}, mappingType, mappingSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateMappingRequest(String[] indices, String mappingType, String mappingSource) {
|
public PutMappingRequest(String[] indices, String mappingType, String mappingSource) {
|
||||||
this.indices = indices;
|
this.indices = indices;
|
||||||
this.mappingType = mappingType;
|
this.mappingType = mappingType;
|
||||||
this.mappingSource = mappingSource;
|
this.mappingSource = mappingSource;
|
||||||
|
@ -71,12 +70,7 @@ public class CreateMappingRequest implements ActionRequest, Streamable {
|
||||||
return validationException;
|
return validationException;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean listenerThreaded() {
|
@Override public PutMappingRequest listenerThreaded(boolean threadedListener) {
|
||||||
// we don't really care about this...
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public CreateMappingRequest listenerThreaded(boolean threadedListener) {
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +86,7 @@ public class CreateMappingRequest implements ActionRequest, Streamable {
|
||||||
* The type of the mappings. Not required since it can be defined explicitly within the mapping source.
|
* The type of the mappings. Not required since it can be defined explicitly within the mapping source.
|
||||||
* If it is not defined within the mapping source, then it is required.
|
* If it is not defined within the mapping source, then it is required.
|
||||||
*/
|
*/
|
||||||
public CreateMappingRequest type(String mappingType) {
|
public PutMappingRequest type(String mappingType) {
|
||||||
this.mappingType = mappingType;
|
this.mappingType = mappingType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +95,7 @@ public class CreateMappingRequest implements ActionRequest, Streamable {
|
||||||
return mappingSource;
|
return mappingSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Required public CreateMappingRequest mappingSource(String mappingSource) {
|
@Required public PutMappingRequest mappingSource(String mappingSource) {
|
||||||
this.mappingSource = mappingSource;
|
this.mappingSource = mappingSource;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -110,12 +104,13 @@ public class CreateMappingRequest implements ActionRequest, Streamable {
|
||||||
return timeout;
|
return timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateMappingRequest timeout(TimeValue timeout) {
|
public PutMappingRequest timeout(TimeValue timeout) {
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void readFrom(DataInput in) throws IOException, ClassNotFoundException {
|
@Override public void readFrom(DataInput in) throws IOException, ClassNotFoundException {
|
||||||
|
super.readFrom(in);
|
||||||
indices = new String[in.readInt()];
|
indices = new String[in.readInt()];
|
||||||
for (int i = 0; i < indices.length; i++) {
|
for (int i = 0; i < indices.length; i++) {
|
||||||
indices[i] = in.readUTF();
|
indices[i] = in.readUTF();
|
||||||
|
@ -128,6 +123,7 @@ public class CreateMappingRequest implements ActionRequest, Streamable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void writeTo(DataOutput out) throws IOException {
|
@Override public void writeTo(DataOutput out) throws IOException {
|
||||||
|
super.writeTo(out);
|
||||||
if (indices == null) {
|
if (indices == null) {
|
||||||
out.writeInt(0);
|
out.writeInt(0);
|
||||||
} else {
|
} else {
|
|
@ -17,7 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.action.admin.indices.mapping.create;
|
package org.elasticsearch.action.admin.indices.mapping.put;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionResponse;
|
import org.elasticsearch.action.ActionResponse;
|
||||||
import org.elasticsearch.util.io.Streamable;
|
import org.elasticsearch.util.io.Streamable;
|
||||||
|
@ -27,9 +27,9 @@ import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class CreateMappingResponse implements ActionResponse, Streamable {
|
public class PutMappingResponse implements ActionResponse, Streamable {
|
||||||
|
|
||||||
@Override public void readFrom(DataInput in) throws IOException, ClassNotFoundException {
|
@Override public void readFrom(DataInput in) throws IOException, ClassNotFoundException {
|
||||||
}
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
/*
|
||||||
|
* 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.mapping.put;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import org.elasticsearch.ElasticSearchException;
|
||||||
|
import org.elasticsearch.ExceptionsHelper;
|
||||||
|
import org.elasticsearch.action.ActionListener;
|
||||||
|
import org.elasticsearch.action.TransportActions;
|
||||||
|
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
||||||
|
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
|
||||||
|
import org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction;
|
||||||
|
import org.elasticsearch.action.support.master.TransportMasterNodeOperationAction;
|
||||||
|
import org.elasticsearch.cluster.ClusterService;
|
||||||
|
import org.elasticsearch.cluster.metadata.MetaDataService;
|
||||||
|
import org.elasticsearch.indices.IndexAlreadyExistsException;
|
||||||
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
import org.elasticsearch.util.settings.Settings;
|
||||||
|
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static org.elasticsearch.action.Actions.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kimchy (Shay Banon)
|
||||||
|
*/
|
||||||
|
public class TransportPutMappingAction extends TransportMasterNodeOperationAction<PutMappingRequest, PutMappingResponse> {
|
||||||
|
|
||||||
|
private final MetaDataService metaDataService;
|
||||||
|
|
||||||
|
private final TransportCreateIndexAction createIndexAction;
|
||||||
|
|
||||||
|
private final boolean autoCreateIndex;
|
||||||
|
|
||||||
|
@Inject public TransportPutMappingAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||||
|
ThreadPool threadPool, MetaDataService metaDataService, TransportCreateIndexAction createIndexAction) {
|
||||||
|
super(settings, transportService, clusterService, threadPool);
|
||||||
|
this.metaDataService = metaDataService;
|
||||||
|
this.createIndexAction = createIndexAction;
|
||||||
|
this.autoCreateIndex = settings.getAsBoolean("action.autoCreateIndex", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override protected String transportAction() {
|
||||||
|
return TransportActions.Admin.Indices.Mapping.PUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected PutMappingRequest newRequest() {
|
||||||
|
return new PutMappingRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected PutMappingResponse newResponse() {
|
||||||
|
return new PutMappingResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected PutMappingResponse masterOperation(PutMappingRequest request) throws ElasticSearchException {
|
||||||
|
final String[] indices = processIndices(clusterService.state(), request.indices());
|
||||||
|
metaDataService.addMapping(indices, request.type(), request.mappingSource(), request.timeout());
|
||||||
|
return new PutMappingResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected void doExecute(final PutMappingRequest request, final ActionListener<PutMappingResponse> listener) {
|
||||||
|
final String[] indices = processIndices(clusterService.state(), request.indices());
|
||||||
|
if (autoCreateIndex) {
|
||||||
|
final CountDownLatch latch = new CountDownLatch(indices.length);
|
||||||
|
for (String index : indices) {
|
||||||
|
if (!clusterService.state().metaData().hasIndex(index)) {
|
||||||
|
createIndexAction.execute(new CreateIndexRequest(index), new ActionListener<CreateIndexResponse>() {
|
||||||
|
@Override public void onResponse(CreateIndexResponse response) {
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void onFailure(Throwable e) {
|
||||||
|
if (ExceptionsHelper.unwrapCause(e) instanceof IndexAlreadyExistsException) {
|
||||||
|
latch.countDown();
|
||||||
|
} else {
|
||||||
|
listener.onFailure(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
latch.countDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
latch.await(10, TimeUnit.SECONDS);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.doExecute(request, listener);
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,10 @@ package org.elasticsearch.action.support.master;
|
||||||
|
|
||||||
import org.elasticsearch.action.ActionRequest;
|
import org.elasticsearch.action.ActionRequest;
|
||||||
|
|
||||||
|
import java.io.DataInput;
|
||||||
|
import java.io.DataOutput;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (Shay Banon)
|
||||||
*/
|
*/
|
||||||
|
@ -35,4 +39,10 @@ public abstract class MasterNodeOperationRequest implements ActionRequest {
|
||||||
// really, does not mean anything in this case
|
// really, does not mean anything in this case
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public void readFrom(DataInput in) throws IOException, ClassNotFoundException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void writeTo(DataOutput out) throws IOException {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ import org.elasticsearch.action.admin.indices.flush.FlushRequest;
|
||||||
import org.elasticsearch.action.admin.indices.flush.FlushResponse;
|
import org.elasticsearch.action.admin.indices.flush.FlushResponse;
|
||||||
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotRequest;
|
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotRequest;
|
||||||
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotResponse;
|
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotResponse;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.create.CreateMappingRequest;
|
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.create.CreateMappingResponse;
|
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
|
||||||
import org.elasticsearch.action.admin.indices.optimize.OptimizeRequest;
|
import org.elasticsearch.action.admin.indices.optimize.OptimizeRequest;
|
||||||
import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse;
|
import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse;
|
||||||
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
|
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
|
||||||
|
@ -41,7 +41,7 @@ import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse;
|
||||||
/**
|
/**
|
||||||
* Administrative actions/operations against indices.
|
* Administrative actions/operations against indices.
|
||||||
*
|
*
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (shay.banon)
|
||||||
* @see AdminClient#indices()
|
* @see AdminClient#indices()
|
||||||
*/
|
*/
|
||||||
public interface IndicesAdminClient {
|
public interface IndicesAdminClient {
|
||||||
|
@ -219,9 +219,9 @@ public interface IndicesAdminClient {
|
||||||
*
|
*
|
||||||
* @param request The create mapping request
|
* @param request The create mapping request
|
||||||
* @return A result future
|
* @return A result future
|
||||||
* @see org.elasticsearch.client.Requests#createMappingRequest(String...)
|
* @see org.elasticsearch.client.Requests#putMappingRequest(String...)
|
||||||
*/
|
*/
|
||||||
ActionFuture<CreateMappingResponse> createMapping(CreateMappingRequest request);
|
ActionFuture<PutMappingResponse> putMapping(PutMappingRequest request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add mapping definition for a type into one or more indices.
|
* Add mapping definition for a type into one or more indices.
|
||||||
|
@ -229,18 +229,18 @@ public interface IndicesAdminClient {
|
||||||
* @param request The create mapping request
|
* @param request The create mapping request
|
||||||
* @param listener A listener to be notified with a result
|
* @param listener A listener to be notified with a result
|
||||||
* @return A result future
|
* @return A result future
|
||||||
* @see org.elasticsearch.client.Requests#createMappingRequest(String...)
|
* @see org.elasticsearch.client.Requests#putMappingRequest(String...)
|
||||||
*/
|
*/
|
||||||
ActionFuture<CreateMappingResponse> createMapping(CreateMappingRequest request, ActionListener<CreateMappingResponse> listener);
|
ActionFuture<PutMappingResponse> putMapping(PutMappingRequest request, ActionListener<PutMappingResponse> listener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add mapping definition for a type into one or more indices.
|
* Add mapping definition for a type into one or more indices.
|
||||||
*
|
*
|
||||||
* @param request The create mapping request
|
* @param request The create mapping request
|
||||||
* @param listener A listener to be notified with a result
|
* @param listener A listener to be notified with a result
|
||||||
* @see org.elasticsearch.client.Requests#createMappingRequest(String...)
|
* @see org.elasticsearch.client.Requests#putMappingRequest(String...)
|
||||||
*/
|
*/
|
||||||
void execCreateMapping(CreateMappingRequest request, ActionListener<CreateMappingResponse> listener);
|
void execPutMapping(PutMappingRequest request, ActionListener<PutMappingResponse> listener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Explicitly perform gateway snapshot for one or more indices.
|
* Explicitly perform gateway snapshot for one or more indices.
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
||||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
||||||
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
|
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
|
||||||
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotRequest;
|
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotRequest;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.create.CreateMappingRequest;
|
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
|
||||||
import org.elasticsearch.action.admin.indices.optimize.OptimizeRequest;
|
import org.elasticsearch.action.admin.indices.optimize.OptimizeRequest;
|
||||||
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
|
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
|
||||||
import org.elasticsearch.action.admin.indices.status.IndicesStatusRequest;
|
import org.elasticsearch.action.admin.indices.status.IndicesStatusRequest;
|
||||||
|
@ -173,10 +173,10 @@ public class Requests {
|
||||||
*
|
*
|
||||||
* @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 delete by query against. Use <tt>null</tt> or <tt>_all</tt> to execute against all indices
|
||||||
* @return The create mapping request
|
* @return The create mapping request
|
||||||
* @see org.elasticsearch.client.IndicesAdminClient#createMapping(org.elasticsearch.action.admin.indices.mapping.create.CreateMappingRequest)
|
* @see org.elasticsearch.client.IndicesAdminClient#putMapping(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest)
|
||||||
*/
|
*/
|
||||||
public static CreateMappingRequest createMappingRequest(String... indices) {
|
public static PutMappingRequest putMappingRequest(String... indices) {
|
||||||
return new CreateMappingRequest(indices);
|
return new PutMappingRequest(indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,9 +34,9 @@ import org.elasticsearch.action.admin.indices.flush.TransportFlushAction;
|
||||||
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotRequest;
|
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotRequest;
|
||||||
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotResponse;
|
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotResponse;
|
||||||
import org.elasticsearch.action.admin.indices.gateway.snapshot.TransportGatewaySnapshotAction;
|
import org.elasticsearch.action.admin.indices.gateway.snapshot.TransportGatewaySnapshotAction;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.create.CreateMappingRequest;
|
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.create.CreateMappingResponse;
|
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.create.TransportCreateMappingAction;
|
import org.elasticsearch.action.admin.indices.mapping.put.TransportPutMappingAction;
|
||||||
import org.elasticsearch.action.admin.indices.optimize.OptimizeRequest;
|
import org.elasticsearch.action.admin.indices.optimize.OptimizeRequest;
|
||||||
import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse;
|
import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse;
|
||||||
import org.elasticsearch.action.admin.indices.optimize.TransportOptimizeAction;
|
import org.elasticsearch.action.admin.indices.optimize.TransportOptimizeAction;
|
||||||
|
@ -67,14 +67,14 @@ public class ServerIndicesAdminClient extends AbstractComponent implements Indic
|
||||||
|
|
||||||
private final TransportOptimizeAction optimizeAction;
|
private final TransportOptimizeAction optimizeAction;
|
||||||
|
|
||||||
private final TransportCreateMappingAction createMappingAction;
|
private final TransportPutMappingAction putMappingAction;
|
||||||
|
|
||||||
private final TransportGatewaySnapshotAction gatewaySnapshotAction;
|
private final TransportGatewaySnapshotAction gatewaySnapshotAction;
|
||||||
|
|
||||||
@Inject public ServerIndicesAdminClient(Settings settings, TransportIndicesStatusAction indicesStatusAction,
|
@Inject public ServerIndicesAdminClient(Settings settings, TransportIndicesStatusAction indicesStatusAction,
|
||||||
TransportCreateIndexAction createIndexAction, TransportDeleteIndexAction deleteIndexAction,
|
TransportCreateIndexAction createIndexAction, TransportDeleteIndexAction deleteIndexAction,
|
||||||
TransportRefreshAction refreshAction, TransportFlushAction flushAction, TransportOptimizeAction optimizeAction,
|
TransportRefreshAction refreshAction, TransportFlushAction flushAction, TransportOptimizeAction optimizeAction,
|
||||||
TransportCreateMappingAction createMappingAction, TransportGatewaySnapshotAction gatewaySnapshotAction) {
|
TransportPutMappingAction putMappingAction, TransportGatewaySnapshotAction gatewaySnapshotAction) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.indicesStatusAction = indicesStatusAction;
|
this.indicesStatusAction = indicesStatusAction;
|
||||||
this.createIndexAction = createIndexAction;
|
this.createIndexAction = createIndexAction;
|
||||||
|
@ -82,7 +82,7 @@ public class ServerIndicesAdminClient extends AbstractComponent implements Indic
|
||||||
this.refreshAction = refreshAction;
|
this.refreshAction = refreshAction;
|
||||||
this.flushAction = flushAction;
|
this.flushAction = flushAction;
|
||||||
this.optimizeAction = optimizeAction;
|
this.optimizeAction = optimizeAction;
|
||||||
this.createMappingAction = createMappingAction;
|
this.putMappingAction = putMappingAction;
|
||||||
this.gatewaySnapshotAction = gatewaySnapshotAction;
|
this.gatewaySnapshotAction = gatewaySnapshotAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,16 +158,16 @@ public class ServerIndicesAdminClient extends AbstractComponent implements Indic
|
||||||
optimizeAction.execute(request, listener);
|
optimizeAction.execute(request, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public ActionFuture<CreateMappingResponse> createMapping(CreateMappingRequest request) {
|
@Override public ActionFuture<PutMappingResponse> putMapping(PutMappingRequest request) {
|
||||||
return createMappingAction.submit(request);
|
return putMappingAction.submit(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public ActionFuture<CreateMappingResponse> createMapping(CreateMappingRequest request, ActionListener<CreateMappingResponse> listener) {
|
@Override public ActionFuture<PutMappingResponse> putMapping(PutMappingRequest request, ActionListener<PutMappingResponse> listener) {
|
||||||
return createMapping(request, listener);
|
return putMapping(request, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void execCreateMapping(CreateMappingRequest request, ActionListener<CreateMappingResponse> listener) {
|
@Override public void execPutMapping(PutMappingRequest request, ActionListener<PutMappingResponse> listener) {
|
||||||
createMappingAction.execute(request, listener);
|
putMappingAction.execute(request, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public ActionFuture<GatewaySnapshotResponse> gatewaySnapshot(GatewaySnapshotRequest request) {
|
@Override public ActionFuture<GatewaySnapshotResponse> gatewaySnapshot(GatewaySnapshotRequest request) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.elasticsearch.client.transport.action.admin.indices.create.ClientTran
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.delete.ClientTransportDeleteIndexAction;
|
import org.elasticsearch.client.transport.action.admin.indices.delete.ClientTransportDeleteIndexAction;
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.flush.ClientTransportFlushAction;
|
import org.elasticsearch.client.transport.action.admin.indices.flush.ClientTransportFlushAction;
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.gateway.snapshot.ClientTransportGatewaySnapshotAction;
|
import org.elasticsearch.client.transport.action.admin.indices.gateway.snapshot.ClientTransportGatewaySnapshotAction;
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.mapping.create.ClientTransportCreateMappingAction;
|
import org.elasticsearch.client.transport.action.admin.indices.mapping.create.ClientTransportPutMappingAction;
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.optimize.ClientTransportOptimizeAction;
|
import org.elasticsearch.client.transport.action.admin.indices.optimize.ClientTransportOptimizeAction;
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.refresh.ClientTransportRefreshAction;
|
import org.elasticsearch.client.transport.action.admin.indices.refresh.ClientTransportRefreshAction;
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.status.ClientTransportIndicesStatusAction;
|
import org.elasticsearch.client.transport.action.admin.indices.status.ClientTransportIndicesStatusAction;
|
||||||
|
@ -63,7 +63,7 @@ public class ClientTransportActionModule extends AbstractModule {
|
||||||
bind(ClientTransportOptimizeAction.class).asEagerSingleton();
|
bind(ClientTransportOptimizeAction.class).asEagerSingleton();
|
||||||
bind(ClientTransportCreateIndexAction.class).asEagerSingleton();
|
bind(ClientTransportCreateIndexAction.class).asEagerSingleton();
|
||||||
bind(ClientTransportDeleteIndexAction.class).asEagerSingleton();
|
bind(ClientTransportDeleteIndexAction.class).asEagerSingleton();
|
||||||
bind(ClientTransportCreateMappingAction.class).asEagerSingleton();
|
bind(ClientTransportPutMappingAction.class).asEagerSingleton();
|
||||||
bind(ClientTransportGatewaySnapshotAction.class).asEagerSingleton();
|
bind(ClientTransportGatewaySnapshotAction.class).asEagerSingleton();
|
||||||
bind(ClientTransportNodesInfoAction.class).asEagerSingleton();
|
bind(ClientTransportNodesInfoAction.class).asEagerSingleton();
|
||||||
bind(ClientTransportSinglePingAction.class).asEagerSingleton();
|
bind(ClientTransportSinglePingAction.class).asEagerSingleton();
|
||||||
|
|
|
@ -21,22 +21,22 @@ package org.elasticsearch.client.transport.action.admin.indices.mapping.create;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import org.elasticsearch.action.TransportActions;
|
import org.elasticsearch.action.TransportActions;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.create.CreateMappingRequest;
|
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.create.CreateMappingResponse;
|
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
|
||||||
import org.elasticsearch.client.transport.action.support.BaseClientTransportAction;
|
import org.elasticsearch.client.transport.action.support.BaseClientTransportAction;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
import org.elasticsearch.util.settings.Settings;
|
import org.elasticsearch.util.settings.Settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class ClientTransportCreateMappingAction extends BaseClientTransportAction<CreateMappingRequest, CreateMappingResponse> {
|
public class ClientTransportPutMappingAction extends BaseClientTransportAction<PutMappingRequest, PutMappingResponse> {
|
||||||
|
|
||||||
@Inject public ClientTransportCreateMappingAction(Settings settings, TransportService transportService) {
|
@Inject public ClientTransportPutMappingAction(Settings settings, TransportService transportService) {
|
||||||
super(settings, transportService, CreateMappingResponse.class);
|
super(settings, transportService, PutMappingResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected String action() {
|
@Override protected String action() {
|
||||||
return TransportActions.Admin.Indices.Mapping.CREATE;
|
return TransportActions.Admin.Indices.Mapping.PUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,8 +31,8 @@ import org.elasticsearch.action.admin.indices.flush.FlushRequest;
|
||||||
import org.elasticsearch.action.admin.indices.flush.FlushResponse;
|
import org.elasticsearch.action.admin.indices.flush.FlushResponse;
|
||||||
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotRequest;
|
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotRequest;
|
||||||
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotResponse;
|
import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotResponse;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.create.CreateMappingRequest;
|
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.create.CreateMappingResponse;
|
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
|
||||||
import org.elasticsearch.action.admin.indices.optimize.OptimizeRequest;
|
import org.elasticsearch.action.admin.indices.optimize.OptimizeRequest;
|
||||||
import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse;
|
import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse;
|
||||||
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
|
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
|
||||||
|
@ -45,7 +45,7 @@ import org.elasticsearch.client.transport.action.admin.indices.create.ClientTran
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.delete.ClientTransportDeleteIndexAction;
|
import org.elasticsearch.client.transport.action.admin.indices.delete.ClientTransportDeleteIndexAction;
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.flush.ClientTransportFlushAction;
|
import org.elasticsearch.client.transport.action.admin.indices.flush.ClientTransportFlushAction;
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.gateway.snapshot.ClientTransportGatewaySnapshotAction;
|
import org.elasticsearch.client.transport.action.admin.indices.gateway.snapshot.ClientTransportGatewaySnapshotAction;
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.mapping.create.ClientTransportCreateMappingAction;
|
import org.elasticsearch.client.transport.action.admin.indices.mapping.create.ClientTransportPutMappingAction;
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.optimize.ClientTransportOptimizeAction;
|
import org.elasticsearch.client.transport.action.admin.indices.optimize.ClientTransportOptimizeAction;
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.refresh.ClientTransportRefreshAction;
|
import org.elasticsearch.client.transport.action.admin.indices.refresh.ClientTransportRefreshAction;
|
||||||
import org.elasticsearch.client.transport.action.admin.indices.status.ClientTransportIndicesStatusAction;
|
import org.elasticsearch.client.transport.action.admin.indices.status.ClientTransportIndicesStatusAction;
|
||||||
|
@ -54,7 +54,7 @@ import org.elasticsearch.util.component.AbstractComponent;
|
||||||
import org.elasticsearch.util.settings.Settings;
|
import org.elasticsearch.util.settings.Settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class InternalTransportIndicesAdminClient extends AbstractComponent implements IndicesAdminClient {
|
public class InternalTransportIndicesAdminClient extends AbstractComponent implements IndicesAdminClient {
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class InternalTransportIndicesAdminClient extends AbstractComponent imple
|
||||||
|
|
||||||
private final ClientTransportOptimizeAction optimizeAction;
|
private final ClientTransportOptimizeAction optimizeAction;
|
||||||
|
|
||||||
private final ClientTransportCreateMappingAction createMappingAction;
|
private final ClientTransportPutMappingAction putMappingAction;
|
||||||
|
|
||||||
private final ClientTransportGatewaySnapshotAction gatewaySnapshotAction;
|
private final ClientTransportGatewaySnapshotAction gatewaySnapshotAction;
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public class InternalTransportIndicesAdminClient extends AbstractComponent imple
|
||||||
ClientTransportIndicesStatusAction indicesStatusAction,
|
ClientTransportIndicesStatusAction indicesStatusAction,
|
||||||
ClientTransportCreateIndexAction createIndexAction, ClientTransportDeleteIndexAction deleteIndexAction,
|
ClientTransportCreateIndexAction createIndexAction, ClientTransportDeleteIndexAction deleteIndexAction,
|
||||||
ClientTransportRefreshAction refreshAction, ClientTransportFlushAction flushAction, ClientTransportOptimizeAction optimizeAction,
|
ClientTransportRefreshAction refreshAction, ClientTransportFlushAction flushAction, ClientTransportOptimizeAction optimizeAction,
|
||||||
ClientTransportCreateMappingAction createMappingAction, ClientTransportGatewaySnapshotAction gatewaySnapshotAction) {
|
ClientTransportPutMappingAction putMappingAction, ClientTransportGatewaySnapshotAction gatewaySnapshotAction) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.nodesService = nodesService;
|
this.nodesService = nodesService;
|
||||||
this.indicesStatusAction = indicesStatusAction;
|
this.indicesStatusAction = indicesStatusAction;
|
||||||
|
@ -89,7 +89,7 @@ public class InternalTransportIndicesAdminClient extends AbstractComponent imple
|
||||||
this.refreshAction = refreshAction;
|
this.refreshAction = refreshAction;
|
||||||
this.flushAction = flushAction;
|
this.flushAction = flushAction;
|
||||||
this.optimizeAction = optimizeAction;
|
this.optimizeAction = optimizeAction;
|
||||||
this.createMappingAction = createMappingAction;
|
this.putMappingAction = putMappingAction;
|
||||||
this.gatewaySnapshotAction = gatewaySnapshotAction;
|
this.gatewaySnapshotAction = gatewaySnapshotAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,26 +243,26 @@ public class InternalTransportIndicesAdminClient extends AbstractComponent imple
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public ActionFuture<CreateMappingResponse> createMapping(final CreateMappingRequest request) {
|
@Override public ActionFuture<PutMappingResponse> putMapping(final PutMappingRequest request) {
|
||||||
return nodesService.execute(new TransportClientNodesService.NodeCallback<ActionFuture<CreateMappingResponse>>() {
|
return nodesService.execute(new TransportClientNodesService.NodeCallback<ActionFuture<PutMappingResponse>>() {
|
||||||
@Override public ActionFuture<CreateMappingResponse> doWithNode(Node node) throws ElasticSearchException {
|
@Override public ActionFuture<PutMappingResponse> doWithNode(Node node) throws ElasticSearchException {
|
||||||
return createMappingAction.submit(node, request);
|
return putMappingAction.submit(node, request);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public ActionFuture<CreateMappingResponse> createMapping(final CreateMappingRequest request, final ActionListener<CreateMappingResponse> listener) {
|
@Override public ActionFuture<PutMappingResponse> putMapping(final PutMappingRequest request, final ActionListener<PutMappingResponse> listener) {
|
||||||
return nodesService.execute(new TransportClientNodesService.NodeCallback<ActionFuture<CreateMappingResponse>>() {
|
return nodesService.execute(new TransportClientNodesService.NodeCallback<ActionFuture<PutMappingResponse>>() {
|
||||||
@Override public ActionFuture<CreateMappingResponse> doWithNode(Node node) throws ElasticSearchException {
|
@Override public ActionFuture<PutMappingResponse> doWithNode(Node node) throws ElasticSearchException {
|
||||||
return createMappingAction.submit(node, request, listener);
|
return putMappingAction.submit(node, request, listener);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void execCreateMapping(final CreateMappingRequest request, final ActionListener<CreateMappingResponse> listener) {
|
@Override public void execPutMapping(final PutMappingRequest request, final ActionListener<PutMappingResponse> listener) {
|
||||||
nodesService.execute(new TransportClientNodesService.NodeCallback<Void>() {
|
nodesService.execute(new TransportClientNodesService.NodeCallback<Void>() {
|
||||||
@Override public Void doWithNode(Node node) throws ElasticSearchException {
|
@Override public Void doWithNode(Node node) throws ElasticSearchException {
|
||||||
createMappingAction.execute(node, request, listener);
|
putMappingAction.execute(node, request, listener);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,7 +29,7 @@ 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.delete.RestDeleteIndexAction;
|
||||||
import org.elasticsearch.rest.action.admin.indices.flush.RestFlushAction;
|
import org.elasticsearch.rest.action.admin.indices.flush.RestFlushAction;
|
||||||
import org.elasticsearch.rest.action.admin.indices.gateway.snapshot.RestGatewaySnapshotAction;
|
import org.elasticsearch.rest.action.admin.indices.gateway.snapshot.RestGatewaySnapshotAction;
|
||||||
import org.elasticsearch.rest.action.admin.indices.mapping.create.RestCreateMappingAction;
|
import org.elasticsearch.rest.action.admin.indices.mapping.put.RestPutMappingAction;
|
||||||
import org.elasticsearch.rest.action.admin.indices.optimize.RestOptimizeAction;
|
import org.elasticsearch.rest.action.admin.indices.optimize.RestOptimizeAction;
|
||||||
import org.elasticsearch.rest.action.admin.indices.refresh.RestRefreshAction;
|
import org.elasticsearch.rest.action.admin.indices.refresh.RestRefreshAction;
|
||||||
import org.elasticsearch.rest.action.admin.indices.status.RestIndicesStatusAction;
|
import org.elasticsearch.rest.action.admin.indices.status.RestIndicesStatusAction;
|
||||||
|
@ -61,7 +61,7 @@ public class RestActionModule extends AbstractModule {
|
||||||
bind(RestCreateIndexAction.class).asEagerSingleton();
|
bind(RestCreateIndexAction.class).asEagerSingleton();
|
||||||
bind(RestDeleteIndexAction.class).asEagerSingleton();
|
bind(RestDeleteIndexAction.class).asEagerSingleton();
|
||||||
|
|
||||||
bind(RestCreateMappingAction.class).asEagerSingleton();
|
bind(RestPutMappingAction.class).asEagerSingleton();
|
||||||
|
|
||||||
bind(RestGatewaySnapshotAction.class).asEagerSingleton();
|
bind(RestGatewaySnapshotAction.class).asEagerSingleton();
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.rest.action.admin.indices.mapping.create;
|
package org.elasticsearch.rest.action.admin.indices.mapping.put;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.create.CreateMappingRequest;
|
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.create.CreateMappingResponse;
|
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.index.mapper.InvalidTypeNameException;
|
import org.elasticsearch.index.mapper.InvalidTypeNameException;
|
||||||
import org.elasticsearch.indices.IndexMissingException;
|
import org.elasticsearch.indices.IndexMissingException;
|
||||||
|
@ -41,23 +41,23 @@ import static org.elasticsearch.rest.action.support.RestActions.*;
|
||||||
import static org.elasticsearch.util.TimeValue.*;
|
import static org.elasticsearch.util.TimeValue.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class RestCreateMappingAction extends BaseRestHandler {
|
public class RestPutMappingAction extends BaseRestHandler {
|
||||||
|
|
||||||
@Inject public RestCreateMappingAction(Settings settings, Client client, RestController controller) {
|
@Inject public RestPutMappingAction(Settings settings, Client client, RestController controller) {
|
||||||
super(settings, client);
|
super(settings, client);
|
||||||
controller.registerHandler(PUT, "/{index}/_mapping", this);
|
controller.registerHandler(PUT, "/{index}/_mapping", this);
|
||||||
controller.registerHandler(PUT, "/{index}/{type}/_mapping", this);
|
controller.registerHandler(PUT, "/{index}/{type}/_mapping", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void handleRequest(final RestRequest request, final RestChannel channel) {
|
@Override public void handleRequest(final RestRequest request, final RestChannel channel) {
|
||||||
CreateMappingRequest createMappingRequest = createMappingRequest(splitIndices(request.param("index")));
|
PutMappingRequest putMappingRequest = putMappingRequest(splitIndices(request.param("index")));
|
||||||
createMappingRequest.type(request.param("type"));
|
putMappingRequest.type(request.param("type"));
|
||||||
createMappingRequest.mappingSource(request.contentAsString());
|
putMappingRequest.mappingSource(request.contentAsString());
|
||||||
createMappingRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10)));
|
putMappingRequest.timeout(request.paramAsTime("timeout", timeValueSeconds(10)));
|
||||||
client.admin().indices().execCreateMapping(createMappingRequest, new ActionListener<CreateMappingResponse>() {
|
client.admin().indices().execPutMapping(putMappingRequest, new ActionListener<PutMappingResponse>() {
|
||||||
@Override public void onResponse(CreateMappingResponse result) {
|
@Override public void onResponse(PutMappingResponse result) {
|
||||||
try {
|
try {
|
||||||
JsonBuilder builder = RestJsonBuilder.cached(request);
|
JsonBuilder builder = RestJsonBuilder.cached(request);
|
||||||
builder.startObject()
|
builder.startObject()
|
Loading…
Reference in New Issue