Skip to content

Commit

Permalink
Core: clarify index removal log message
Browse files Browse the repository at this point in the history
  • Loading branch information
imotov committed Nov 26, 2014
1 parent 200b6d2 commit 2c4b506
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void onFailure(String source, Throwable t) {
@Override
public ClusterState execute(ClusterState currentState) throws Exception {
boolean indexCreated = false;
String failureReason = null;
String removalReason = null;
try {
validate(request, currentState);

Expand Down Expand Up @@ -378,7 +378,7 @@ public ClusterState execute(ClusterState currentState) throws Exception {
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);
}
}
Expand All @@ -390,7 +390,7 @@ public ClusterState execute(ClusterState currentState) throws Exception {
// 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);
}
}
Expand Down Expand Up @@ -438,7 +438,7 @@ public ClusterState execute(ClusterState currentState) throws Exception {
try {
indexMetaData = indexMetaDataBuilder.build();
} catch (Exception e) {
failureReason = "failed to build index metadata";
removalReason = "failed to build index metadata";
throw e;
}

Expand Down Expand Up @@ -466,11 +466,12 @@ public ClusterState execute(ClusterState currentState) throws Exception {
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");
}
}
}
Expand Down

0 comments on commit 2c4b506

Please sign in to comment.