// may cause changes to be dropped from this map, so that they may
// be retried next time around.
ImmutableMap.Builder<StoreContext, ConnectorStamps> mapBuilder =
new ImmutableMap.Builder<StoreContext, ConnectorStamps>();
StoreContext m = getNext(mi);
StoreContext p = getNext(pi);
while (m != null && p != null) {
// Compare instance names.
int diff = m.getConnectorName().compareTo(p.getConnectorName());
NDC.pushAppend((diff < 0 ? m : p).getConnectorName());
try {
if (diff == 0) {
// Compare the inMemory vs inPStore ConnectorStamps for a
// connector instance. Notify ChangeListeners for items whose
// Stamps have changed.
ConnectorStamps stamps = compareInstancesAndNotifyListeners(
m, p, inMemoryInventory.get(m), persistentInventory.get(p));
// Remember the new ConnetorStamps for our new inMemory inventory.
mapBuilder.put(p, stamps);
// Advance to the next connector instance.
m = getNext(mi);
p = getNext(pi);
} else if (diff < 0) {
listener.connectorRemoved(m.getConnectorName());
m = getNext(mi);
} else { // diff > 0
try {
listener.connectorAdded(p.getConnectorName(),
store.getConnectorConfiguration(p));
mapBuilder.put(p, persistentInventory.get(p));
} catch (InstantiatorException e) {
// Forget about this one and retry on the next time around.
pi.remove();
}
p = getNext(pi);
}
} finally {
NDC.pop();
}
}
while (m != null) {
NDC.pushAppend(m.getConnectorName());
try {
listener.connectorRemoved(m.getConnectorName());
} finally {
NDC.pop();
}
m = getNext(mi);
}
while (p != null) {
NDC.pushAppend(p.getConnectorName());
try {
listener.connectorAdded(p.getConnectorName(),
store.getConnectorConfiguration(p));
mapBuilder.put(p, persistentInventory.get(p));
} catch (InstantiatorException e) {
// Forget about this one and retry on the next time around.
pi.remove();