Handle renaming DocWriteResponse.Operation

It is now DocWriteResponse.Result. The enum constants have changed a bit
as well.

Original commit: elastic/x-pack-elasticsearch@395e7c15bb
This commit is contained in:
Nik Everett 2016-07-31 07:27:54 -04:00
parent 585837dbd3
commit 2297c493e4
17 changed files with 37 additions and 37 deletions

View File

@ -326,7 +326,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
.execute(new ActionListener<UpdateResponse>() {
@Override
public void onResponse(UpdateResponse updateResponse) {
assert updateResponse.getOperation() == DocWriteResponse.Operation.INDEX;
assert updateResponse.getResult() == DocWriteResponse.Result.UPDATED;
clearRealmCache(request.username(), listener, null);
}
@ -402,7 +402,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
.execute(new ActionListener<UpdateResponse>() {
@Override
public void onResponse(UpdateResponse updateResponse) {
assert updateResponse.getOperation() == DocWriteResponse.Operation.INDEX;
assert updateResponse.getResult() == DocWriteResponse.Result.UPDATED;
clearRealmCache(putUserRequest.username(), listener, false);
}
@ -443,7 +443,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
@Override
public void onResponse(IndexResponse indexResponse) {
// if the document was just created, then we don't need to clear cache
boolean created = indexResponse.getOperation() == DocWriteResponse.Operation.CREATE;
boolean created = indexResponse.getResult() == DocWriteResponse.Result.CREATED;
if (created) {
listener.onResponse(true);
return;
@ -474,7 +474,7 @@ public class NativeUsersStore extends AbstractComponent implements ClusterStateL
@Override
public void onResponse(DeleteResponse deleteResponse) {
clearRealmCache(deleteUserRequest.username(), listener,
deleteResponse.getOperation() == DocWriteResponse.Operation.DELETE);
deleteResponse.getResult() == DocWriteResponse.Result.DELETED);
}
@Override

View File

@ -274,7 +274,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
client.delete(request, new ActionListener<DeleteResponse>() {
@Override
public void onResponse(DeleteResponse deleteResponse) {
clearRoleCache(deleteRoleRequest.name(), listener, deleteResponse.getOperation() == DocWriteResponse.Operation.DELETE);
clearRoleCache(deleteRoleRequest.name(), listener, deleteResponse.getResult() == DocWriteResponse.Result.DELETED);
}
@Override
@ -304,7 +304,7 @@ public class NativeRolesStore extends AbstractComponent implements RolesStore, C
.execute(new ActionListener<IndexResponse>() {
@Override
public void onResponse(IndexResponse indexResponse) {
boolean created = indexResponse.getOperation() == DocWriteResponse.Operation.CREATE;
boolean created = indexResponse.getResult() == DocWriteResponse.Result.CREATED;
if (created) {
listener.onResponse(true);
return;

View File

@ -41,8 +41,8 @@ public class BulkUpdateTests extends SecurityIntegTestCase {
}
public void testThatBulkUpdateDoesNotLoseFields() {
assertEquals(DocWriteResponse.Operation.CREATE,
client().prepareIndex("index1", "type").setSource("{\"test\": \"test\"}").setId("1").get().getOperation());
assertEquals(DocWriteResponse.Result.CREATED,
client().prepareIndex("index1", "type").setSource("{\"test\": \"test\"}").setId("1").get().getResult());
GetResponse getResponse = internalCluster().transportClient().prepareGet("index1", "type", "1").setFields("test").get();
assertThat(getResponse.getField("test").getValue(), equalTo("test"));
@ -51,8 +51,8 @@ public class BulkUpdateTests extends SecurityIntegTestCase {
}
// update with a new field
assertEquals(DocWriteResponse.Operation.INDEX, internalCluster().transportClient().prepareUpdate("index1", "type", "1")
.setDoc("{\"not test\": \"not test\"}").get().getOperation());
assertEquals(DocWriteResponse.Result.UPDATED, internalCluster().transportClient().prepareUpdate("index1", "type", "1")
.setDoc("{\"not test\": \"not test\"}").get().getResult());
getResponse = internalCluster().transportClient().prepareGet("index1", "type", "1").setFields("test", "not test").get();
assertThat(getResponse.getField("test").getValue(), equalTo("test"));
assertThat(getResponse.getField("not test").getValue(), equalTo("not test"));
@ -64,7 +64,7 @@ public class BulkUpdateTests extends SecurityIntegTestCase {
// do it in a bulk
BulkResponse response = internalCluster().transportClient().prepareBulk().add(client().prepareUpdate("index1", "type", "1")
.setDoc("{\"bulk updated\": \"bulk updated\"}")).get();
assertEquals(DocWriteResponse.Operation.INDEX, response.getItems()[0].getResponse().getOperation());
assertEquals(DocWriteResponse.Result.UPDATED, response.getItems()[0].getResponse().getResult());
getResponse = internalCluster().transportClient().prepareGet("index1", "type", "1").
setFields("test", "not test", "bulk updated").get();
assertThat(getResponse.getField("test").getValue(), equalTo("test"));

View File

@ -120,7 +120,7 @@ public class ClearRolesCacheTests extends NativeRealmIntegTestCase {
.setDoc("run_as", new String[] { role })
.setRefreshPolicy(refresh ? IMMEDIATE : NONE)
.get();
assertEquals(DocWriteResponse.Operation.INDEX, response.getOperation());
assertEquals(DocWriteResponse.Result.UPDATED, response.getResult());
logger.debug("--> updated role [{}] with run_as", role);
}
@ -162,7 +162,7 @@ public class ClearRolesCacheTests extends NativeRealmIntegTestCase {
.prepareDelete(SecurityTemplateService.SECURITY_INDEX_NAME, NativeRolesStore.ROLE_DOC_TYPE, role)
.setRefreshPolicy(refresh ? IMMEDIATE : NONE)
.get();
assertEquals(DocWriteResponse.Operation.DELETE, response.getOperation());
assertEquals(DocWriteResponse.Result.DELETED, response.getResult());
assertBusy(new Runnable() {
@Override

View File

@ -70,7 +70,7 @@ public class DateMathExpressionIntegTests extends SecurityIntegTestCase {
IndexResponse response = client.prepareIndex(expression, "type").setSource("foo", "bar")
.setRefreshPolicy(refeshOnOperation ? IMMEDIATE : NONE).get();
assertEquals(DocWriteResponse.Operation.CREATE, response.getOperation());
assertEquals(DocWriteResponse.Result.CREATED, response.getResult());
assertThat(response.getIndex(), containsString(expectedIndexName));
if (refeshOnOperation == false) {
@ -90,7 +90,7 @@ public class DateMathExpressionIntegTests extends SecurityIntegTestCase {
.setDoc("new", "field")
.setRefreshPolicy(refeshOnOperation ? IMMEDIATE : NONE)
.get();
assertEquals(DocWriteResponse.Operation.INDEX, updateResponse.getOperation());
assertEquals(DocWriteResponse.Result.UPDATED, updateResponse.getResult());
if (refeshOnOperation == false) {
client.admin().indices().prepareRefresh(expression).get();

View File

@ -187,13 +187,13 @@ public class KibanaUserRoleIntegTests extends SecurityIntegTestCase {
.setSource("foo", "bar")
.setRefreshPolicy(IMMEDIATE)
.get();
assertEquals(DocWriteResponse.Operation.CREATE, response.getOperation());
assertEquals(DocWriteResponse.Result.CREATED, response.getResult());
DeleteResponse deleteResponse = client()
.filterWithHeader(singletonMap("Authorization", UsernamePasswordToken.basicAuthHeaderValue("kibana_user", USERS_PASSWD)))
.prepareDelete(index, "dashboard", response.getId())
.get();
assertEquals(DocWriteResponse.Operation.DELETE, deleteResponse.getOperation());
assertEquals(DocWriteResponse.Result.DELETED, deleteResponse.getResult());
}
// TODO: When we have an XPackIntegTestCase, this should test that we can send MonitoringBulkActions

View File

@ -76,14 +76,14 @@ public class MultipleIndicesPermissionsTests extends SecurityIntegTestCase {
.startObject()
.field("name", "value")
.endObject());
assertEquals(DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
indexResponse = index("test1", "type", jsonBuilder()
.startObject()
.field("name", "value1")
.endObject());
assertEquals(DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
refresh();
@ -151,13 +151,13 @@ public class MultipleIndicesPermissionsTests extends SecurityIntegTestCase {
.startObject()
.field("name", "value_a")
.endObject());
assertEquals(DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
indexResponse = index("b", "type", jsonBuilder()
.startObject()
.field("name", "value_b")
.endObject());
assertEquals(DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
refresh();

View File

@ -134,7 +134,7 @@ public abstract class AbstractAdLdapRealmTestCase extends SecurityIntegTestCase
.execute().actionGet();
assertEquals("user " + user + " should have write access to index " + index,
DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
DocWriteResponse.Result.CREATED, indexResponse.getResult());
refresh();

View File

@ -115,14 +115,14 @@ public class LicensingTests extends SecurityIntegTestCase {
.startObject()
.field("name", "value")
.endObject());
assertEquals(DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
indexResponse = index("test1", "type", jsonBuilder()
.startObject()
.field("name", "value1")
.endObject());
assertEquals(DocWriteResponse.Operation.CREATE, indexResponse.getOperation());
assertEquals(DocWriteResponse.Result.CREATED, indexResponse.getResult());
refresh();

View File

@ -80,7 +80,7 @@ public class PkiAuthenticationTests extends SecurityIntegTestCase {
try (TransportClient client = createTransportClient(settings)) {
client.addTransportAddress(randomFrom(internalCluster().getInstance(Transport.class).boundAddress().boundAddresses()));
IndexResponse response = client.prepareIndex("foo", "bar").setSource("pki", "auth").get();
assertEquals(DocWriteResponse.Operation.CREATE, response.getOperation());
assertEquals(DocWriteResponse.Result.CREATED, response.getResult());
}
}

View File

@ -121,7 +121,7 @@ public class WatcherService extends AbstractComponent {
}
try {
WatchStore.WatchDelete delete = watchStore.delete(id, force);
if (delete.deleteResponse().getOperation() == DocWriteResponse.Operation.DELETE) {
if (delete.deleteResponse().getResult() == DocWriteResponse.Result.DELETED) {
triggerService.remove(id);
}
return delete;

View File

@ -117,8 +117,8 @@ public class ExecutableIndexAction extends ExecutableAction<IndexAction> {
static void indexResponseToXContent(XContentBuilder builder, IndexResponse response) throws IOException {
builder.startObject()
.field("created", response.getOperation() == DocWriteResponse.Operation.CREATE)
.field("operation", response.getOperation().getLowercase())
.field("created", response.getResult() == DocWriteResponse.Result.CREATED)
.field("result", response.getResult().getLowercase())
.field("id", response.getId())
.field("version", response.getVersion())
.field("type", response.getType())

View File

@ -57,7 +57,7 @@ public class TransportDeleteWatchAction extends WatcherTransportAction<DeleteWat
try {
DeleteResponse deleteResponse = watcherService.deleteWatch(request.getId(), request.masterNodeTimeout(), request.isForce())
.deleteResponse();
boolean deleted = deleteResponse.getOperation() == DocWriteResponse.Operation.DELETE;
boolean deleted = deleteResponse.getResult() == DocWriteResponse.Result.DELETED;
DeleteWatchResponse response = new DeleteWatchResponse(deleteResponse.getId(), deleteResponse.getVersion(), deleted);
listener.onResponse(response);
} catch (Exception e) {

View File

@ -63,7 +63,7 @@ public class TransportPutWatchAction extends WatcherTransportAction<PutWatchRequ
try {
IndexResponse indexResponse = watcherService.putWatch(request.getId(), request.getSource(), request.masterNodeTimeout(),
request.isActive());
boolean created = indexResponse.getOperation() == DocWriteResponse.Operation.CREATE;
boolean created = indexResponse.getResult() == DocWriteResponse.Result.CREATED;
listener.onResponse(new PutWatchResponse(indexResponse.getId(), indexResponse.getVersion(), created));
} catch (Exception e) {
listener.onFailure(e);

View File

@ -170,7 +170,7 @@ public class WatcherServiceTests extends ESTestCase {
WatchStore.WatchDelete expectedWatchDelete = mock(WatchStore.WatchDelete.class);
DeleteResponse deleteResponse = mock(DeleteResponse.class);
when(deleteResponse.getOperation()).thenReturn(DocWriteResponse.Operation.DELETE);
when(deleteResponse.getResult()).thenReturn(DocWriteResponse.Result.DELETED);
when(expectedWatchDelete.deleteResponse()).thenReturn(deleteResponse);
when(watchStore.delete("_id", force)).thenReturn(expectedWatchDelete);
WatchStore.WatchDelete watchDelete = watcherService.deleteWatch("_id", timeout, force);
@ -199,7 +199,7 @@ public class WatcherServiceTests extends ESTestCase {
WatchStore.WatchDelete expectedWatchDelete = mock(WatchStore.WatchDelete.class);
DeleteResponse deleteResponse = mock(DeleteResponse.class);
when(deleteResponse.getOperation()).thenReturn(DocWriteResponse.Operation.DELETE);
when(deleteResponse.getResult()).thenReturn(DocWriteResponse.Result.DELETED);
when(expectedWatchDelete.deleteResponse()).thenReturn(deleteResponse);
when(watchStore.delete("_id", true)).thenReturn(expectedWatchDelete);
WatchStore.WatchDelete watchDelete = watcherService.deleteWatch("_id", timeout, true);
@ -216,7 +216,7 @@ public class WatcherServiceTests extends ESTestCase {
WatchStore.WatchDelete expectedWatchDelete = mock(WatchStore.WatchDelete.class);
DeleteResponse deleteResponse = mock(DeleteResponse.class);
when(deleteResponse.getOperation()).thenReturn(DocWriteResponse.Operation.NOOP);
when(deleteResponse.getResult()).thenReturn(DocWriteResponse.Result.NOOP);
when(expectedWatchDelete.deleteResponse()).thenReturn(deleteResponse);
when(watchStore.delete("_id", force)).thenReturn(expectedWatchDelete);
WatchStore.WatchDelete watchDelete = watcherService.deleteWatch("_id", timeout, force);

View File

@ -44,7 +44,7 @@ public class TimeThrottleIntegrationTests extends AbstractWatcherIntegrationTest
IndexResponse eventIndexResponse = client().prepareIndex("events", "event")
.setSource("level", "error")
.get();
assertEquals(DocWriteResponse.Operation.CREATE, eventIndexResponse.getOperation());
assertEquals(DocWriteResponse.Result.CREATED, eventIndexResponse.getResult());
refresh();
return eventIndexResponse;
}

View File

@ -59,7 +59,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
IndexResponse eventIndexResponse = client().prepareIndex("events", "event")
.setSource("level", "error")
.get();
assertEquals(DocWriteResponse.Operation.CREATE, eventIndexResponse.getOperation());
assertEquals(DocWriteResponse.Result.CREATED, eventIndexResponse.getResult());
refresh();
return eventIndexResponse;
}
@ -115,7 +115,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
// Now delete the event and the ack states should change to AWAITS_EXECUTION
DeleteResponse response = client().prepareDelete("events", "event", eventIndexResponse.getId()).get();
assertEquals(DocWriteResponse.Operation.DELETE, response.getOperation());
assertEquals(DocWriteResponse.Result.DELETED, response.getResult());
refresh();
if (timeWarped()) {
@ -197,7 +197,7 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
// Now delete the event and the ack states should change to AWAITS_EXECUTION
DeleteResponse response = client().prepareDelete("events", "event", eventIndexResponse.getId()).get();
assertEquals(DocWriteResponse.Operation.DELETE, response.getOperation());
assertEquals(DocWriteResponse.Result.DELETED, response.getResult());
refresh();
if (timeWarped()) {