try {
String name = entityGroupInfo.getEntityGroupNameAsString();
LOG.debug("Processing close of " + name);
String encodedEntityGroupName = entityGroupInfo.getEncodedName();
// Check that this entityGroup is being served here
EntityGroup entityGroup = this.fsServices
.getFromOnlineEntityGroups(encodedEntityGroupName);
if (entityGroup == null) {
LOG.warn("Received CLOSE for entityGroup " + name
+ " but currently not serving");
return;
}
// Close the entityGroup
try {
// If we need to keep updating CLOSING stamp to prevent against
// a timeout if this is long-running, need to spin up a thread?
if (!entityGroup.close(abort)) {
// This entityGroup got closed. Most likely due to a split. So instead
// of doing the setClosedState() below, let's just ignore cont
// The split message will clean up the master state.
LOG.warn("Can't close entityGroup: was already closed during close(): "
+ entityGroupInfo.getEntityGroupNameAsString());
return;
}
} catch (Throwable t) {
// A throwable here indicates that we couldn't successfully flush the
// memstore before closing. So, we need to abort the server and allow
// the master to split our logs in order to recover the data.
server.abort("Unrecoverable exception while closing entityGroup "
+ entityGroupInfo.getEntityGroupNameAsString()
+ ", still finishing close", t);
throw new RuntimeException(t);
}
this.fsServices.removeFromOnlineEntityGroups(entityGroupInfo
.getEncodedName());
// Remove it from RIT before set ZK data
this.fsServices.getEntityGroupsInTransitionInFS().remove(
this.entityGroupInfo.getEncodedNameAsBytes());
removedFromRIT = true;
if (this.zk) {
if (setClosedState(this.expectedVersion, entityGroup)) {
LOG.debug("set entityGroup closed state in zk successfully for entityGroup "
+ name + " sn name: " + this.server.getServerName());
} else {
LOG.debug("set entityGroup closed state in zk unsuccessfully for entityGroup "
+ name + " sn name: " + this.server.getServerName());
}
}
// Done! EntityGroup is closed on this FS
LOG.debug("Closed entityGroup "
+ entityGroup.getEntityGroupNameAsString());
} finally {
if (!removedFromRIT) {
this.fsServices.getEntityGroupsInTransitionInFS().remove(
this.entityGroupInfo.getEncodedNameAsBytes());
}