}
LOG.info("Node definition used for this host: {}, found {} configured peer nodes",
localDef, nodeDefs.size());
final NodeStateStore nodes = _stores.getNodeStore();
// Next: load state definitions from BDB
List<ActiveNodeState> storedStates = nodes.readAll(_keyspace);
LOG.info("Read {} persisted node entries from local store", storedStates.size());
// First things first: find and update node for local node
ActiveNodeState localAct = _remove(storedStates, localDef.getAddress());
if (localAct == null) { // need to create?
if (!_stuff.isRunningTests()) {
LOG.warn("No persisted entry for local node: will create and store one");
}
localAct = new ActiveNodeState(localDef, _startTime);
} else {
// index may have changed; if so, override
if (localAct.getIndex() != localDef.getIndex()) {
LOG.warn("Node index of current node changed from {} to {} -- may change key range!",
localAct.getIndex(), localDef.getIndex());
localAct = localAct.withIndex(localDef.getIndex());
}
}
// one more thing: force dummy update on restart as well (official startup time too)
localAct = localAct.withLastUpdated(_startTime);
// Either way, need to update persisted version
nodes.upsertEntry(localAct);
// then merge entries; create/delete orphans
Map<IpAndPort,ActiveNodeState> activeState = _mergeStates(nodes,
localAct, nodeDefs, storedStates);