/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2015, 2017 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,
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
+
import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
+
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.CommitStatus;
}
@Override
+ @SuppressWarnings("IllegalCatch")
public synchronized void close() {
for (ObjectName tx : allOpenedTransactions) {
try {
if (isStillOpenTransaction(tx)) {
configRegistryClient.getConfigTransactionClient(tx).abortConfig();
}
- } catch (final Exception e) {
+ } catch (final RuntimeException e) {
LOG.debug("Ignoring exception while closing transaction {}", tx, e);
}
}
public synchronized Optional<ObjectName> getTransaction() {
- if (candidateTx == null){
+ if (candidateTx == null) {
return Optional.absent();
}
public synchronized Optional<ObjectName> getReadTransaction() {
- if (readTx == null){
+ if (readTx == null) {
return Optional.absent();
}
}
/**
- * Used for editConfig test option
+ * Used for editConfig test option.
*/
public synchronized ObjectName getTestTransaction() {
ObjectName testTx = configRegistryClient.beginConfig();
}
/**
- * Commit and notification send must be atomic
+ * Commit and notification send must be atomic.
*/
public CommitStatus commitTransaction() throws ValidationException, ConflictingVersionException {
return commitTransaction(configRegistryClient);
}
/**
- * Commit and notification send must be atomic
- * @param configRegistryClient
+ * Commit and notification send must be atomic.
*/
- public synchronized CommitStatus commitTransaction(final ConfigRegistryClient configRegistryClient) throws ValidationException, ConflictingVersionException {
- if (!getTransaction().isPresent()){
- //making empty commit without prior opened transaction, just return commit status with empty lists
+ public synchronized CommitStatus commitTransaction(final ConfigRegistryClient configRegistryClient)
+ throws ValidationException, ConflictingVersionException {
+ if (!getTransaction().isPresent()) {
+ // making empty commit without prior opened transaction, just return commit
+ // status with empty lists
LOG.debug("Making commit without open candidate transaction for session {}", sessionIdForReporting);
- return new CommitStatus(Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
+ return new CommitStatus(Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
}
final Optional<ObjectName> maybeTaON = getTransaction();
ObjectName taON = maybeTaON.get();
}
/**
- * Wiping means removing all module instances keeping the transaction open + service references.
+ * Wiping means removing all module instances keeping the transaction open +
+ * service references.
*/
synchronized void wipeInternal(final ObjectName taON, final boolean isTest) {
ConfigTransactionClient transactionClient = configRegistryClient.getConfigTransactionClient(taON);
Set<ObjectName> lookupConfigBeans = transactionClient.lookupConfigBeans();
- int i = lookupConfigBeans.size();
+ int index = lookupConfigBeans.size();
for (ObjectName instance : lookupConfigBeans) {
try {
transactionClient.destroyModule(instance);
} catch (final InstanceNotFoundException e) {
- if (isTest){
+ if (isTest) {
LOG.debug("Unable to clean configuration in transactiom {}", taON, e);
} else {
LOG.warn("Unable to clean configuration in transactiom {}", taON, e);
throw new IllegalStateException("Unable to clean configuration in transactiom " + taON, e);
}
}
- LOG.debug("Transaction {} wiped clean of {} config beans", taON, i);
+ LOG.debug("Transaction {} wiped clean of {} config beans", taON, index);
transactionClient.removeAllServiceReferences();
LOG.debug("Transaction {} wiped clean of all service references", taON);
Preconditions.checkState(taON.isPresent(), NO_TRANSACTION_FOUND_FOR_SESSION + sessionIdForReporting);
wipeInternal(taON.get(), false);
}
-
}