Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
BUG-8792: allow transactions to not time out after reconnect
[controller.git]
/
opendaylight
/
md-sal
/
sal-distributed-datastore
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
cluster
/
datastore
/
FrontendClientMetadataBuilder.java
diff --git
a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java
b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java
index a13899c354b165526674469bbe02f8c9ad90cc12..4ffa27c60dcdb771767d836490d2af333b2c5f9f 100644
(file)
--- a/
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java
+++ b/
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java
@@
-11,10
+11,6
@@
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import com.google.common.collect.Collections2;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import com.google.common.collect.Collections2;
-import com.google.common.collect.Range;
-import com.google.common.collect.RangeSet;
-import com.google.common.collect.TreeRangeSet;
-import com.google.common.primitives.UnsignedLong;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
@@
-24,6
+20,7
@@
import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifie
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.datastore.persisted.FrontendClientMetadata;
import org.opendaylight.controller.cluster.datastore.persisted.FrontendHistoryMetadata;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.datastore.persisted.FrontendClientMetadata;
import org.opendaylight.controller.cluster.datastore.persisted.FrontendHistoryMetadata;
+import org.opendaylight.controller.cluster.datastore.utils.UnsignedLongRangeSet;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.slf4j.Logger;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.slf4j.Logger;
@@
-34,21
+31,24
@@
final class FrontendClientMetadataBuilder implements Builder<FrontendClientMetad
private static final Logger LOG = LoggerFactory.getLogger(FrontendClientMetadataBuilder.class);
private final Map<LocalHistoryIdentifier, FrontendHistoryMetadataBuilder> currentHistories = new HashMap<>();
private static final Logger LOG = LoggerFactory.getLogger(FrontendClientMetadataBuilder.class);
private final Map<LocalHistoryIdentifier, FrontendHistoryMetadataBuilder> currentHistories = new HashMap<>();
- private final
RangeSet<UnsignedLong>
purgedHistories;
+ private final
UnsignedLongRangeSet
purgedHistories;
private final ClientIdentifier identifier;
private final ClientIdentifier identifier;
+ private final String shardName;
- FrontendClientMetadataBuilder(final ClientIdentifier identifier) {
+ FrontendClientMetadataBuilder(final String shardName, final ClientIdentifier identifier) {
+ this.shardName = Preconditions.checkNotNull(shardName);
this.identifier = Preconditions.checkNotNull(identifier);
this.identifier = Preconditions.checkNotNull(identifier);
- purgedHistories =
Tree
RangeSet.create();
+ purgedHistories =
UnsignedLong
RangeSet.create();
// History for stand-alone transactions is always present
final LocalHistoryIdentifier standaloneId = standaloneHistoryId();
currentHistories.put(standaloneId, new FrontendHistoryMetadataBuilder(standaloneId));
}
// History for stand-alone transactions is always present
final LocalHistoryIdentifier standaloneId = standaloneHistoryId();
currentHistories.put(standaloneId, new FrontendHistoryMetadataBuilder(standaloneId));
}
- FrontendClientMetadataBuilder(final FrontendClientMetadata meta) {
+ FrontendClientMetadataBuilder(final String shardName, final FrontendClientMetadata meta) {
+ this.shardName = Preconditions.checkNotNull(shardName);
this.identifier = Preconditions.checkNotNull(meta.getIdentifier());
this.identifier = Preconditions.checkNotNull(meta.getIdentifier());
- purgedHistories =
Tree
RangeSet.create(meta.getPurgedHistories());
+ purgedHistories =
UnsignedLong
RangeSet.create(meta.getPurgedHistories());
for (FrontendHistoryMetadata h : meta.getCurrentHistories()) {
final FrontendHistoryMetadataBuilder b = new FrontendHistoryMetadataBuilder(identifier, h);
for (FrontendHistoryMetadata h : meta.getCurrentHistories()) {
final FrontendHistoryMetadataBuilder b = new FrontendHistoryMetadataBuilder(identifier, h);
@@
-58,8
+58,8
@@
final class FrontendClientMetadataBuilder implements Builder<FrontendClientMetad
// Sanity check and recovery
final LocalHistoryIdentifier standaloneId = standaloneHistoryId();
if (!currentHistories.containsKey(standaloneId)) {
// 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);
+ LOG.warn("
{}:
Client {} recovered histories {} do not contain stand-alone history, attempting recovery",
+
shardName,
identifier, currentHistories);
currentHistories.put(standaloneId, new FrontendHistoryMetadataBuilder(standaloneId));
}
}
currentHistories.put(standaloneId, new FrontendHistoryMetadataBuilder(standaloneId));
}
}
@@
-70,7
+70,7
@@
final class FrontendClientMetadataBuilder implements Builder<FrontendClientMetad
@Override
public FrontendClientMetadata build() {
@Override
public FrontendClientMetadata build() {
- return new FrontendClientMetadata(identifier, purgedHistories,
+ return new FrontendClientMetadata(identifier, purgedHistories
.toImmutable()
,
Collections2.transform(currentHistories.values(), FrontendHistoryMetadataBuilder::build));
}
Collections2.transform(currentHistories.values(), FrontendHistoryMetadataBuilder::build));
}
@@
-84,9
+84,9
@@
final class FrontendClientMetadataBuilder implements Builder<FrontendClientMetad
final FrontendHistoryMetadataBuilder oldMeta = currentHistories.putIfAbsent(historyId, newMeta);
if (oldMeta != null) {
// This should not be happening, warn about it
final FrontendHistoryMetadataBuilder oldMeta = currentHistories.putIfAbsent(historyId, newMeta);
if (oldMeta != null) {
// This should not be happening, warn about it
- LOG.warn("
Reused local history {}"
, historyId);
+ LOG.warn("
{}: Reused local history {}", shardName
, historyId);
} else {
} else {
- LOG.debug("
Created local history {}"
, historyId);
+ LOG.debug("
{}: Created local history {}", shardName
, historyId);
}
}
}
}
@@
-94,30
+94,30
@@
final class FrontendClientMetadataBuilder implements Builder<FrontendClientMetad
final FrontendHistoryMetadataBuilder builder = currentHistories.get(historyId);
if (builder != null) {
builder.onHistoryClosed();
final FrontendHistoryMetadataBuilder builder = currentHistories.get(historyId);
if (builder != null) {
builder.onHistoryClosed();
- LOG.debug("
Closed history {}"
, historyId);
+ LOG.debug("
{}: Closed history {}", shardName
, historyId);
} else {
} else {
- LOG.warn("
Closed unknown history {}, ignoring"
, historyId);
+ LOG.warn("
{}: Closed unknown history {}, ignoring", shardName
, historyId);
}
}
void onHistoryPurged(final LocalHistoryIdentifier historyId) {
final FrontendHistoryMetadataBuilder history = currentHistories.remove(historyId);
if (history == null) {
}
}
void onHistoryPurged(final LocalHistoryIdentifier historyId) {
final FrontendHistoryMetadataBuilder history = currentHistories.remove(historyId);
if (history == null) {
- LOG.warn("
Purging unknown history {}"
, historyId);
+ LOG.warn("
{}: Purging unknown history {}", shardName
, historyId);
}
// XXX: do we need to account for cookies?
}
// XXX: do we need to account for cookies?
- purgedHistories.add(
Range.singleton(UnsignedLong.fromLongBits(historyId.getHistoryId())
));
- LOG.debug("Purged history {}", historyId);
+ purgedHistories.add(
historyId.getHistoryId(
));
+ LOG.debug("
{}:
Purged history {}", historyId);
}
void onTransactionAborted(final TransactionIdentifier txId) {
final FrontendHistoryMetadataBuilder history = getHistory(txId);
if (history != null) {
history.onTransactionAborted(txId);
}
void onTransactionAborted(final TransactionIdentifier txId) {
final FrontendHistoryMetadataBuilder history = getHistory(txId);
if (history != null) {
history.onTransactionAborted(txId);
- LOG.debug("
Committed transaction {}"
, txId);
+ LOG.debug("
{}: Committed transaction {}", shardName
, txId);
} else {
} else {
- LOG.warn("
Unknown history for aborted transaction {}, ignoring"
, txId);
+ LOG.warn("
{}: Unknown history for aborted transaction {}, ignoring", shardName
, txId);
}
}
}
}
@@
-125,9
+125,9
@@
final class FrontendClientMetadataBuilder implements Builder<FrontendClientMetad
final FrontendHistoryMetadataBuilder history = getHistory(txId);
if (history != null) {
history.onTransactionCommitted(txId);
final FrontendHistoryMetadataBuilder history = getHistory(txId);
if (history != null) {
history.onTransactionCommitted(txId);
- LOG.debug("
Aborted transaction {}"
, txId);
+ LOG.debug("
{}: Aborted transaction {}", shardName
, txId);
} else {
} else {
- LOG.warn("
Unknown history for commited transaction {}, ignoring"
, txId);
+ LOG.warn("
{}: Unknown history for commited transaction {}, ignoring", shardName
, txId);
}
}
}
}
@@
-135,9
+135,9
@@
final class FrontendClientMetadataBuilder implements Builder<FrontendClientMetad
final FrontendHistoryMetadataBuilder history = getHistory(txId);
if (history != null) {
history.onTransactionPurged(txId);
final FrontendHistoryMetadataBuilder history = getHistory(txId);
if (history != null) {
history.onTransactionPurged(txId);
- LOG.debug("
Purged transaction {}"
, txId);
+ LOG.debug("
{}: Purged transaction {}", shardName
, txId);
} else {
} else {
- LOG.warn("
Unknown history for purged transaction {}, ignoring"
, txId);
+ LOG.warn("
{}: Unknown history for purged transaction {}, ignoring", shardName
, txId);
}
}
}
}
@@
-170,7
+170,7
@@
final class FrontendClientMetadataBuilder implements Builder<FrontendClientMetad
}
return new LeaderFrontendState(shard.persistenceId(), getIdentifier(), shard.getDataStore(),
}
return new LeaderFrontendState(shard.persistenceId(), getIdentifier(), shard.getDataStore(),
-
TreeRangeSet.create(purgedHistories
), singleHistory, histories);
+
purgedHistories.copy(
), singleHistory, histories);
}
private FrontendHistoryMetadataBuilder getHistory(final TransactionIdentifier txId) {
}
private FrontendHistoryMetadataBuilder getHistory(final TransactionIdentifier txId) {