X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fbroker%2Fimpl%2FAbstractDOMForwardedCompositeTransaction.java;h=763614d098d5785d92f17070824bb63c4d26d157;hp=c20c3650d2fc217a0a09109084b260b6d6031275;hb=HEAD;hpb=a4f7dc39abf87eff0e6bc24049f8f877cef298b7 diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java deleted file mode 100644 index c20c3650d2..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.md.sal.dom.broker.impl; - -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; - -import java.util.Collection; - -import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Composite DOM Transaction backed by {@link DOMStoreTransaction}. - * - * Abstract base for composite transaction, which provides access only to common - * functionality as retrieval of subtransaction, close method and retrieval of - * identifier. - * - * @param - * Subtransaction distinguisher - * @param - * Subtransaction type - */ -abstract class AbstractDOMForwardedCompositeTransaction implements - AsyncTransaction> { - - private final ImmutableMap backingTxs; - private final Object identifier; - - /** - * - * Creates new composite Transactions. - * - * @param identifier - * Identifier of transaction. - * @param backingTxs - * Key,value map of backing transactions. - */ - protected AbstractDOMForwardedCompositeTransaction(final Object identifier, final ImmutableMap backingTxs) { - this.identifier = Preconditions.checkNotNull(identifier, "Identifier should not be null"); - this.backingTxs = Preconditions.checkNotNull(backingTxs, "Backing transactions should not be null"); - } - - /** - * Returns subtransaction associated with supplied key. - * - * @param key - * @return - * @throws NullPointerException - * if key is null - * @throws IllegalArgumentException - * if no subtransaction is associated with key. - */ - protected final T getSubtransaction(final K key) { - Preconditions.checkNotNull(key, "key must not be null."); - Preconditions.checkArgument(backingTxs.containsKey(key), "No subtransaction associated with %s", key); - return backingTxs.get(key); - } - - /** - * Returns immutable Iterable of all subtransactions. - * - */ - protected Collection getSubtransactions() { - return backingTxs.values(); - } - - @Override - public Object getIdentifier() { - return identifier; - } - - protected void closeSubtransactions() { - /* - * We share one exception for all failures, which are added - * as supressedExceptions to it. - * - */ - IllegalStateException failure = null; - for (T subtransaction : backingTxs.values()) { - try { - subtransaction.close(); - } catch (Exception e) { - // If we did not allocated failure we allocate it - if(failure == null) { - failure = new IllegalStateException("Uncaught exception occured during closing transaction.", e); - } else { - // We update it with addotional exceptions, which occured during error. - failure.addSuppressed(e); - } - } - } - // If we have failure, we throw it at after all attempts to close. - if(failure != null) { - throw failure; - } - } -} \ No newline at end of file