}
}
@Override
public void process() throws IOException {
final ServerName serverName = this.serverName;
try {
NavigableMap<EntityGroupInfo, Result> egis = null;
while (!this.server.isStopped()) {
try {
egis = FMetaReader.getServerUserEntityGroups(
server.getConfiguration(), this.serverName);
break;
} catch (IOException ioe) {
LOG.info(
"Received exception accessing META during server shutdown of "
+ serverName + ", retrying META read", ioe);
}
}
if (this.server.isStopped()) {
throw new IOException("Server is stopped");
}
// Clean out anything in entityGroups in transition. Being conservative
// and
// doing after log splitting. Could do some states before -- OPENING?
// OFFLINE? -- and then others after like CLOSING that depend on log
// splitting.
List<EntityGroupState> entityGroupsInTransition = assignmentManager
.processServerShutdown(serverName);
LOG.info("Reassigning " + ((egis == null) ? 0 : egis.size())
+ " entityGroup(s) that "
+ (serverName == null ? "null" : serverName)
+ " was carrying (skipping " + entityGroupsInTransition.size()
+ " entityGroup(s) that are already in transition)");
// Iterate entityGroups that were on this server and assign them
if (egis != null) {
EntityGroupStates entityGroupStates = assignmentManager
.getEntityGroupStates();
List<EntityGroupInfo> toAssignEntityGroups = new ArrayList<EntityGroupInfo>();
for (Map.Entry<EntityGroupInfo, Result> e : egis.entrySet()) {
EntityGroupInfo egi = e.getKey();
EntityGroupState egit = entityGroupStates
.getEntityGroupTransitionState(egi);
if (processDeadEntityGroup(egi, e.getValue(), assignmentManager,
server)) {
ServerName addressFromAM = entityGroupStates
.getFServerOfEntityGroup(egi);
if (addressFromAM != null && !addressFromAM.equals(this.serverName)) {
// If this entityGroup is in transition on the dead server, it
// must be
// opening or pending_open, which is covered by
// AM#processServerShutdown
LOG.debug("Skip assigning entityGroup "
+ egi.getEntityGroupNameAsString()
+ " because it has been opened in "
+ addressFromAM.getServerName());
continue;
}
if (egit != null) {
if (!egit.isOnServer(serverName) || egit.isClosed()
|| egit.isOpened() || egit.isSplit()) {