@Override
public DOMStoreTransactionChain createTransactionChain() {
- return new ClientBackedTransactionChain(getClient().createLocalHistory());
+ return new ClientBackedTransactionChain(getClient().createLocalHistory(), debugAllocation());
}
@Override
public DOMStoreReadTransaction newReadOnlyTransaction() {
- return new ClientBackedReadTransaction(getClient().createSnapshot(), null);
+ return new ClientBackedReadTransaction(getClient().createSnapshot(), null, allocationContext());
}
@Override
public DOMStoreWriteTransaction newWriteOnlyTransaction() {
- return new ClientBackedWriteTransaction(getClient().createTransaction());
+ return new ClientBackedWriteTransaction(getClient().createTransaction(), allocationContext());
}
@Override
public DOMStoreReadWriteTransaction newReadWriteTransaction() {
- return new ClientBackedReadWriteTransaction(getClient().createTransaction());
+ return new ClientBackedReadWriteTransaction(getClient().createTransaction(), allocationContext());
+ }
+
+ private boolean debugAllocation() {
+ return getActorContext().getDatastoreContext().isTransactionDebugContextEnabled();
+ }
+
+ private Throwable allocationContext() {
+ return debugAllocation() ? new Throwable("allocated at") : null;
}
}
@SuppressWarnings("unused")
private volatile ClientBackedTransactionChain parent;
- ClientBackedReadTransaction(final ClientSnapshot delegate, @Nullable final ClientBackedTransactionChain parent) {
- super(delegate);
+ ClientBackedReadTransaction(final ClientSnapshot delegate, @Nullable final ClientBackedTransactionChain parent,
+ @Nullable final Throwable allocationContext) {
+ super(delegate, allocationContext);
this.parent = parent;
}
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
+import javax.annotation.Nullable;
import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
final class ClientBackedReadWriteTransaction extends ClientBackedWriteTransaction
implements DOMStoreReadWriteTransaction {
- ClientBackedReadWriteTransaction(final ClientTransaction delegate) {
- super(delegate);
+ ClientBackedReadWriteTransaction(final ClientTransaction delegate, @Nullable final Throwable allocationContext) {
+ super(delegate, allocationContext);
}
@Override
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.controller.cluster.databroker.actors.dds.AbstractClientHandle;
import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
private static final Logger LOG = LoggerFactory.getLogger(Finalizer.class);
private final AbstractClientHandle<?> transaction;
+ private final Throwable allocationContext;
- private Finalizer(final ClientBackedTransaction<?> referent, final AbstractClientHandle<?> transaction) {
+ private Finalizer(final ClientBackedTransaction<?> referent, final AbstractClientHandle<?> transaction,
+ final Throwable allocationContext) {
super(referent, QUEUE);
this.transaction = Preconditions.checkNotNull(transaction);
+ this.allocationContext = allocationContext;
}
static @Nonnull <T extends AbstractClientHandle<?>> T recordTransaction(
- @Nonnull final ClientBackedTransaction<T> referent, @Nonnull final T transaction) {
- FINALIZERS.add(new Finalizer(referent, transaction));
+ @Nonnull final ClientBackedTransaction<T> referent, @Nonnull final T transaction,
+ @Nullable final Throwable allocationContext) {
+ FINALIZERS.add(new Finalizer(referent, transaction, allocationContext));
return transaction;
}
public void finalizeReferent() {
FINALIZERS.remove(this);
if (transaction.abort()) {
- LOG.info("Aborted orphan transaction {}", transaction);
+ LOG.info("Aborted orphan transaction {}", transaction, allocationContext);
}
}
}
private final T delegate;
- ClientBackedTransaction(final T delegate) {
+ ClientBackedTransaction(final T delegate, final Throwable allocationContext) {
super(delegate.getIdentifier());
- this.delegate = Finalizer.recordTransaction(this, delegate);
+ this.delegate = Finalizer.recordTransaction(this, delegate, allocationContext);
}
final T delegate() {
private final Map<AbstractClientHandle<?>, Boolean> openSnapshots = new WeakHashMap<>();
private final ClientLocalHistory history;
+ private final boolean debugAllocation;
- ClientBackedTransactionChain(final ClientLocalHistory history) {
+ ClientBackedTransactionChain(final ClientLocalHistory history, final boolean debugAllocation) {
this.history = Preconditions.checkNotNull(history);
+ this.debugAllocation = debugAllocation;
}
@Override
public DOMStoreReadTransaction newReadOnlyTransaction() {
- return new ClientBackedReadTransaction(createSnapshot(), this);
+ return new ClientBackedReadTransaction(createSnapshot(), this, allocationContext());
}
@Override
public DOMStoreReadWriteTransaction newReadWriteTransaction() {
- return new ClientBackedReadWriteTransaction(createTransaction());
+ return new ClientBackedReadWriteTransaction(createTransaction(), allocationContext());
}
@Override
public DOMStoreWriteTransaction newWriteOnlyTransaction() {
- return new ClientBackedWriteTransaction(createTransaction());
+ return new ClientBackedWriteTransaction(createTransaction(), allocationContext());
}
@Override
}
}
+ private Throwable allocationContext() {
+ return debugAllocation ? new Throwable("allocated at") : null;
+ }
+
private synchronized <T extends AbstractClientHandle<?>> T recordSnapshot(final T snapshot) {
openSnapshots.put(snapshot, Boolean.TRUE);
return snapshot;
*/
package org.opendaylight.controller.cluster.databroker;
+import javax.annotation.Nullable;
import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
*/
class ClientBackedWriteTransaction extends ClientBackedTransaction<ClientTransaction>
implements DOMStoreWriteTransaction {
- ClientBackedWriteTransaction(final ClientTransaction delegate) {
- super(delegate);
+ ClientBackedWriteTransaction(final ClientTransaction delegate, @Nullable final Throwable allocationContext) {
+ super(delegate, allocationContext);
}
@Override
Mockito.doReturn(Futures.immediateCheckedFuture(Optional.of(data))).when(delegate)
.read(YangInstanceIdentifier.EMPTY);
- object = new ClientBackedReadTransaction(delegate, null);
+ object = new ClientBackedReadTransaction(delegate, null, null);
}
@Test
Mockito.doReturn(Futures.immediateCheckedFuture(Optional.of(data))).when(delegate)
.read(YangInstanceIdentifier.EMPTY);
- object = new ClientBackedReadWriteTransaction(delegate);
+ object = new ClientBackedReadWriteTransaction(delegate, null);
}
@Test
Mockito.when(history.takeSnapshot()).thenReturn(snapshot);
Mockito.when(history.createTransaction()).thenReturn(transaction);
- chain = new ClientBackedTransactionChain(history);
+ chain = new ClientBackedTransactionChain(history, false);
}
@Test
Mockito.doReturn(TRANSACTION_ID).when(delegate).getIdentifier();
Mockito.doReturn(readyCohort).when(delegate).ready();
- object = new ClientBackedWriteTransaction(delegate);
+ object = new ClientBackedWriteTransaction(delegate, null);
}
@Override