*/
package org.opendaylight.controller.cluster.datastore;
+import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import com.google.common.collect.Collections2;
FrontendClientMetadataBuilder(final ClientIdentifier identifier) {
this.identifier = Preconditions.checkNotNull(identifier);
purgedHistories = TreeRangeSet.create();
+
+ // History for stand-alone transactions is always present
+ final LocalHistoryIdentifier standaloneId = standaloneHistoryId();
+ currentHistories.put(standaloneId, new FrontendHistoryMetadataBuilder(standaloneId));
}
FrontendClientMetadataBuilder(final FrontendClientMetadata meta) {
final FrontendHistoryMetadataBuilder b = new FrontendHistoryMetadataBuilder(identifier, h);
currentHistories.put(b.getIdentifier(), b);
}
+
+ // Sanity check and recovery
+ final LocalHistoryIdentifier standaloneId = standaloneHistoryId();
+ if (!currentHistories.containsKey(standaloneId)) {
+ LOG.warn("Client {} recovered histories {} do not contain stand-alone history, attempting recovery",
+ identifier, currentHistories);
+ currentHistories.put(standaloneId, new FrontendHistoryMetadataBuilder(standaloneId));
+ }
+ }
+
+ private LocalHistoryIdentifier standaloneHistoryId() {
+ return new LocalHistoryIdentifier(identifier, 0);
}
@Override
private FrontendHistoryMetadataBuilder getHistory(final TransactionIdentifier txId) {
return currentHistories.get(txId.getHistoryId());
}
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this).add("identifier", identifier).add("current", currentHistories)
+ .add("purged", purgedHistories).toString();
+ }
}