Core: clarify index removal log message

This commit is contained in:
Igor Motov 2014-11-24 15:54:38 -05:00
parent 08521a4066
commit 7e0b75625b
1 changed files with 6 additions and 5 deletions

View File

@ -227,7 +227,7 @@ public class MetaDataCreateIndexService extends AbstractComponent {
@Override
public ClusterState execute(ClusterState currentState) throws Exception {
boolean indexCreated = false;
String failureReason = null;
String removalReason = null;
try {
validate(request, currentState);
@ -378,7 +378,7 @@ public class MetaDataCreateIndexService extends AbstractComponent {
try {
mapperService.merge(MapperService.DEFAULT_MAPPING, new CompressedString(XContentFactory.jsonBuilder().map(mappings.get(MapperService.DEFAULT_MAPPING)).string()), false);
} catch (Exception e) {
failureReason = "failed on parsing default mapping on index creation";
removalReason = "failed on parsing default mapping on index creation";
throw new MapperParsingException("mapping [" + MapperService.DEFAULT_MAPPING + "]", e);
}
}
@ -390,7 +390,7 @@ public class MetaDataCreateIndexService extends AbstractComponent {
// apply the default here, its the first time we parse it
mapperService.merge(entry.getKey(), new CompressedString(XContentFactory.jsonBuilder().map(entry.getValue()).string()), true);
} catch (Exception e) {
failureReason = "failed on parsing mappings on index creation";
removalReason = "failed on parsing mappings on index creation";
throw new MapperParsingException("mapping [" + entry.getKey() + "]", e);
}
}
@ -438,7 +438,7 @@ public class MetaDataCreateIndexService extends AbstractComponent {
try {
indexMetaData = indexMetaDataBuilder.build();
} catch (Exception e) {
failureReason = "failed to build index metadata";
removalReason = "failed to build index metadata";
throw e;
}
@ -466,11 +466,12 @@ public class MetaDataCreateIndexService extends AbstractComponent {
RoutingAllocation.Result routingResult = allocationService.reroute(ClusterState.builder(updatedState).routingTable(routingTableBuilder).build());
updatedState = ClusterState.builder(updatedState).routingResult(routingResult).build();
}
removalReason = "cleaning up after validating index on master";
return updatedState;
} finally {
if (indexCreated) {
// Index was already partially created - need to clean up
indicesService.removeIndex(request.index(), failureReason != null ? failureReason : "failed to create index");
indicesService.removeIndex(request.index(), removalReason != null ? removalReason : "failed to create index");
}
}
}