import java.util.concurrent.Semaphore;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
/**
* Proposal for how a key based semaphore provider should look like.
* @param key semaphore identifier
* @return new or existing semaphore for given key, for one key there is always only one semaphore available
*/
- Semaphore summonGuard(@Nonnull K key);
+ Semaphore summonGuard(@Nonnull final K key);
+
+ /**
+ * Get guard and lock for key.
+ * @param key for which guard should be created and acquired
+ * @return semaphore guard
+ */
+ Semaphore summonGuardAndAcquire(@Nonnull final K key);
+
+ /**
+ * Unlock and release guard.
+ * @param guard semaphore guard which should be released
+ */
+ void releaseGuard(@Nullable final Semaphore guard);
}
* @param flowcapableNodePath path to openflow augmentation of node
* @param syncupEntry configured node + device reflection
* @return synchronization outcome
- * @throws InterruptedException
*/
ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
- final SyncupEntry syncupEntry) throws InterruptedException;
+ final SyncupEntry syncupEntry);
}
LOG.trace("Syncup for {} return from {} listener", nodeId.getValue(), dsType());
}
}
- } catch (InterruptedException e) {
- LOG.warn("Permit for forwarding rules sync not acquired: {}", nodeId.getValue());
} catch (Exception e) {
LOG.error("Error processing inventory node modification: {}, {}", nodeId.getValue(), e);
}
}
protected abstract Optional<ListenableFuture<Boolean>> processNodeModification(
- final DataTreeModification<T> modification) throws InterruptedException;
+ final DataTreeModification<T> modification);
protected abstract LogicalDatastoreType dsType();
final SyncReactor syncReactorRetry = new SyncReactorRetryDecorator(syncReactorImpl, reconciliationRegistry);
final SyncReactor syncReactorGuard = new SyncReactorGuardDecorator(syncReactorRetry,
new SemaphoreKeeperGuavaImpl<>(1, true));
- final SyncReactor syncReactorFutureZip = new SyncReactorFutureZipDecorator(syncReactorGuard, syncThreadPool);
+ final SyncReactor syncReactorFutureZip = new SyncReactorFutureZipDecorator(syncReactorGuard, syncThreadPool,
+ new SemaphoreKeeperGuavaImpl<>(1, true));
final SyncReactor reactor = new SyncReactorClusterDecorator(syncReactorFutureZip, deviceMastershipManager);
LOG.info("ForwardingRulesSync has started.");
}
- public void close() throws InterruptedException {
+ public void close() {
if (Objects.nonNull(dataTreeConfigChangeListener)) {
dataTreeConfigChangeListener.close();
dataTreeConfigChangeListener = null;
/**
* Update cache. If operational data are present, choose appropriate data and start syncup.
* Otherwise skip incoming change.
- * @throws InterruptedException from syncup
*/
protected Optional<ListenableFuture<Boolean>> processNodeModification(
- final DataTreeModification<FlowCapableNode> modification) throws InterruptedException {
+ final DataTreeModification<FlowCapableNode> modification) {
final InstanceIdentifier<FlowCapableNode> nodePath = modification.getRootPath().getRootIdentifier();
final NodeId nodeId = PathUtil.digNodeId(nodePath);
*/
private ListenableFuture<Boolean> onNodeAdded(final InstanceIdentifier<FlowCapableNode> nodePath,
final FlowCapableNode dataAfter,
- final FlowCapableNode operationalNode) throws InterruptedException {
+ final FlowCapableNode operationalNode) {
LOG.debug("Reconciliation {}: {}", dsType(), PathUtil.digNodeId(nodePath).getValue());
final SyncupEntry syncupEntry = new SyncupEntry(dataAfter, dsType(), operationalNode, LogicalDatastoreType.OPERATIONAL);
return reactor.syncup(nodePath, syncupEntry);
*/
private ListenableFuture<Boolean> onNodeUpdated(final InstanceIdentifier<FlowCapableNode> nodePath,
final FlowCapableNode dataBefore,
- final FlowCapableNode dataAfter) throws InterruptedException {
+ final FlowCapableNode dataAfter) {
final SyncupEntry syncupEntry = new SyncupEntry(dataAfter, dsType(), dataBefore, dsType());
return reactor.syncup(nodePath, syncupEntry);
}
* Note, this could be probably optimized using dedicated wipe-out RPC.
*/
private ListenableFuture<Boolean> onNodeDeleted(final InstanceIdentifier<FlowCapableNode> nodePath,
- final FlowCapableNode dataBefore) throws InterruptedException {
+ final FlowCapableNode dataBefore) {
final SyncupEntry syncupEntry = new SyncupEntry(null, dsType(), dataBefore, dsType());
return reactor.syncup(nodePath, syncupEntry);
}
/**
* Update cache, register for device mastership when device connected and start reconciliation if device
* is registered and actual modification is consistent.Skip the event otherwise.
- * @throws InterruptedException from syncup
*/
protected Optional<ListenableFuture<Boolean>> processNodeModification(
- final DataTreeModification<Node> modification) throws InterruptedException {
+ final DataTreeModification<Node> modification) {
final NodeId nodeId = ModificationUtil.nodeId(modification);
updateCache(modification);
* configuration (coming from operational) should be calculated and sent to device.
* @param modification from DS
* @return optional syncup future
- * @throws InterruptedException from syncup
*/
- private Optional<ListenableFuture<Boolean>> reconciliation(final DataTreeModification<Node> modification)
- throws InterruptedException {
+ private Optional<ListenableFuture<Boolean>> reconciliation(final DataTreeModification<Node> modification) {
final NodeId nodeId = ModificationUtil.nodeId(modification);
final Optional<FlowCapableNode> nodeConfiguration = configDao.loadByNodeId(nodeId);
@Override
public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
- final SyncupEntry syncupEntry) throws InterruptedException {
+ final SyncupEntry syncupEntry) {
final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
if (!deviceMastershipManager.isDeviceMastered(nodeId)) {
LOG.debug("Skip syncup since not master for: {}", nodeId.getValue());
}
public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
- final SyncupEntry syncupEntry) throws InterruptedException {
+ final SyncupEntry syncupEntry) {
final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
return executorService.submit(() -> {
try {
}
protected ListenableFuture<Boolean> doSyncupInFuture(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
- final SyncupEntry syncupEntry) throws InterruptedException {
+ final SyncupEntry syncupEntry) {
return delegate.syncup(flowcapableNodePath, syncupEntry);
}
}
import com.google.common.util.concurrent.ListeningExecutorService;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.Semaphore;
-import javax.annotation.concurrent.GuardedBy;
+import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;
import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
*/
public class SyncReactorFutureZipDecorator extends SyncReactorFutureDecorator {
- @GuardedBy("compressionGuard")
private final Map<InstanceIdentifier<FlowCapableNode>, SyncupEntry> compressionQueue = new HashMap<>();
- private final Semaphore compressionGuard = new Semaphore(1, true);
+ private final SemaphoreKeeper<InstanceIdentifier<FlowCapableNode>> semaphoreKeeper;
- public SyncReactorFutureZipDecorator(final SyncReactor delegate, final ListeningExecutorService executorService) {
+ public SyncReactorFutureZipDecorator(final SyncReactor delegate,
+ final ListeningExecutorService executorService,
+ final SemaphoreKeeper<InstanceIdentifier<FlowCapableNode>> semaphoreKeeper) {
super(delegate, executorService);
+ this.semaphoreKeeper = semaphoreKeeper;
}
public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
- final SyncupEntry syncupEntry) throws InterruptedException {
+ final SyncupEntry syncupEntry) {
+ Semaphore guard = null;
try {
- compressionGuard.acquire();
+ guard = semaphoreKeeper.summonGuardAndAcquire(flowcapableNodePath);
+ if (Objects.isNull(guard)) {
+ return Futures.immediateFuture(Boolean.FALSE);
+ }
final boolean newTaskNecessary = updateCompressionState(flowcapableNodePath, syncupEntry);
if (newTaskNecessary) {
super.syncup(flowcapableNodePath, syncupEntry);
}
return Futures.immediateFuture(Boolean.TRUE);
} finally {
- compressionGuard.release();
+ semaphoreKeeper.releaseGuard(guard);
}
}
protected ListenableFuture<Boolean> doSyncupInFuture(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
- final SyncupEntry syncupEntry) throws InterruptedException {
+ final SyncupEntry syncupEntry) {
final SyncupEntry lastCompressionState = removeLastCompressionState(flowcapableNodePath);
+
if (lastCompressionState == null) {
return Futures.immediateFuture(Boolean.TRUE);
} else {
private boolean updateCompressionState(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
final SyncupEntry syncupEntry) {
final SyncupEntry previousEntry = compressionQueue.get(flowcapableNodePath);
+
if (previousEntry != null && syncupEntry.isOptimizedConfigDelta()) {
updateOptimizedConfigDelta(flowcapableNodePath, syncupEntry, previousEntry);
} else {
}
private SyncupEntry removeLastCompressionState(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath) {
+ Semaphore guard = null;
try {
- try {
- compressionGuard.acquire();
- } catch (InterruptedException e) {
+ guard = semaphoreKeeper.summonGuardAndAcquire(flowcapableNodePath);
+ if (Objects.isNull(guard)) {
return null;
}
return compressionQueue.remove(flowcapableNodePath);
} finally {
- compressionGuard.release();
+ semaphoreKeeper.releaseGuard(guard);
}
}
}
\ No newline at end of file
package org.opendaylight.openflowplugin.applications.frsync.impl;
-import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Objects;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
}
public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
- final SyncupEntry syncupEntry) throws InterruptedException {
+ final SyncupEntry syncupEntry) {
final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
final long stampBeforeGuard = System.nanoTime();
- final Semaphore guard = summonGuardAndAcquire(flowcapableNodePath);
- if (guard == null) {
+ final Semaphore guard = semaphoreKeeper.summonGuardAndAcquire(flowcapableNodePath);
+ if (Objects.isNull(guard)) {
return Futures.immediateFuture(Boolean.FALSE);
}
final long stampAfterGuard = System.nanoTime();
- try {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Syncup guard acquired and running for {} ", nodeId.getValue());
- }
- final ListenableFuture<Boolean> endResult = delegate.syncup(flowcapableNodePath, syncupEntry);
- Futures.addCallback(endResult, createSyncupCallback(guard, stampBeforeGuard, stampAfterGuard, nodeId));
- return endResult;
- } catch (InterruptedException e) {
- releaseGuard(guard);
- throw e;
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Syncup guard acquired and running for {} ", nodeId.getValue());
}
+ final ListenableFuture<Boolean> endResult = delegate.syncup(flowcapableNodePath, syncupEntry);
+ Futures.addCallback(endResult, createSyncupCallback(guard, stampBeforeGuard, stampAfterGuard, nodeId));
+ return endResult;
}
- private static FutureCallback<Boolean> createSyncupCallback(final Semaphore guard,
+ private FutureCallback<Boolean> createSyncupCallback(final Semaphore guard,
final long stampBeforeGuard,
final long stampAfterGuard,
final NodeId nodeId) {
formatNanos(stampFinished - stampBeforeGuard), formatNanos(stampFinished - stampAfterGuard),
formatNanos(stampAfterGuard - stampBeforeGuard));
}
- releaseGuard(guard);
+ semaphoreKeeper.releaseGuard(guard);
}
@Override
public void onFailure(final Throwable t) {
LOG.warn("Syncup failed {} took:{} rpc:{} wait:{}", nodeId.getValue(),
formatNanos(stampFinished - stampBeforeGuard), formatNanos(stampFinished - stampAfterGuard),
formatNanos(stampAfterGuard - stampBeforeGuard));
- releaseGuard(guard);
+ semaphoreKeeper.releaseGuard(guard);
}};
}
private static String formatNanos(final long nanos) {
return "'" + TimeUnit.NANOSECONDS.toMillis(nanos) + " ms'";
}
-
- /**
- * Get guard and lock for node.
- * @param flowcapableNodePath II of node for which guard should be acquired
- * @return semaphore guard
- */
- private Semaphore summonGuardAndAcquire(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath) {
- final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
- final Semaphore guard = Preconditions.checkNotNull(semaphoreKeeper.summonGuard(flowcapableNodePath),
- "No guard for " + nodeId.getValue());
- try {
- guard.acquire();
- } catch (InterruptedException e) {
- LOG.warn("Syncup summon {} failed {}", nodeId.getValue(), e);
- return null;
- }
- if (LOG.isTraceEnabled()) {
- LOG.trace("Syncup summon {} guard:{}", nodeId.getValue(), guard);
- }
- return guard;
- }
-
- /**
- * Unlock and release guard.
- * @param guard semaphore guard which should be unlocked
- */
- private static void releaseGuard(final Semaphore guard) {
- if (guard != null) {
- guard.release();
- if (LOG.isTraceEnabled()) {
- LOG.trace("Syncup release guard:{} thread:{}", guard);
- }
- }
- }
}
final CrudCounts flowCrudCounts = counters.getFlowCrudCounts();
final CrudCounts meterCrudCounts = counters.getMeterCrudCounts();
final CrudCounts groupCrudCounts = counters.getGroupCrudCounts();
- LOG.debug("syncup outcome[{}] (added/updated/removed): flow={}/{}/{}, group={}/{}/{}, " +
+ LOG.debug("Syncup outcome[{}] (added/updated/removed): flow={}/{}/{}, group={}/{}/{}, " +
"meter={}/{}/{}, errors={}",
nodeId.getValue(),
flowCrudCounts.getAdded(), flowCrudCounts.getUpdated(), flowCrudCounts.getRemoved(),
}
public ListenableFuture<Boolean> syncup(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,
- final SyncupEntry syncupEntry) throws InterruptedException {
+ final SyncupEntry syncupEntry) {
final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);
if (syncupEntry.isOptimizedConfigDelta() && reconciliationRegistry.isRegistered(nodeId)) {
package org.opendaylight.openflowplugin.applications.frsync.util;
+import com.google.common.base.Preconditions;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
+import java.util.Objects;
import java.util.concurrent.Semaphore;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Key-based semaphore provider.
*/
public class SemaphoreKeeperGuavaImpl<K> implements SemaphoreKeeper<K> {
+ private static final Logger LOG = LoggerFactory.getLogger(SemaphoreKeeperGuavaImpl.class);
private final LoadingCache<K, Semaphore> semaphoreCache;
public SemaphoreKeeperGuavaImpl(final int permits, final boolean fair) {
}
@Override
- public Semaphore summonGuard(final @Nonnull K key) {
+ public Semaphore summonGuard(@Nonnull final K key) {
return semaphoreCache.getUnchecked(key);
}
@Override
- public String toString() {
- return super.toString() + " size:" + (semaphoreCache == null ? null : semaphoreCache.size()) + " " + semaphoreCache;
+ public Semaphore summonGuardAndAcquire(@Nonnull final K key) {
+ final Semaphore guard = Preconditions.checkNotNull(summonGuard(key), "Guard not available for " + key);
+ try {
+ guard.acquire();
+ } catch (InterruptedException e) {
+ LOG.warn("Could not acquire guard for {}, {}", key, e);
+ return null;
+ }
+ return guard;
+ }
+
+ @Override
+ public void releaseGuard(@Nullable final Semaphore guard) {
+ if (Objects.nonNull(guard)) {
+ guard.release();
+ }
}
}
}
@After
- public void tearDown() throws InterruptedException {
+ public void tearDown() {
provider.close();
}
}
@Test
- public void testOnDataTreeChangedAdd() throws InterruptedException {
+ public void testOnDataTreeChangedAdd() {
Mockito.when(configModification.getDataBefore()).thenReturn(null);
Mockito.when(configModification.getDataAfter()).thenReturn(dataAfter);
final SyncupEntry syncupEntry = loadOperationalDSAndPrepareSyncupEntry(dataAfter, confgDS, dataBefore, operationalDS);
}
@Test
- public void testOnDataTreeChangedUpdate() throws InterruptedException {
+ public void testOnDataTreeChangedUpdate() {
Mockito.when(configModification.getDataBefore()).thenReturn(dataBefore);
Mockito.when(configModification.getDataAfter()).thenReturn(dataAfter);
final SyncupEntry syncupEntry = loadOperationalDSAndPrepareSyncupEntry(dataAfter, confgDS, dataBefore, confgDS);
}
@Test
- public void testOnDataTreeChangedDelete() throws InterruptedException {
+ public void testOnDataTreeChangedDelete() {
Mockito.when(configModification.getDataBefore()).thenReturn(dataBefore);
Mockito.when(configModification.getDataAfter()).thenReturn(null);
final SyncupEntry syncupEntry = loadOperationalDSAndPrepareSyncupEntry(null, confgDS, dataBefore, confgDS);
}
private SyncupEntry loadOperationalDSAndPrepareSyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter,
- final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) throws InterruptedException {
+ final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) {
Mockito.when(roTx.read(LogicalDatastoreType.OPERATIONAL, fcNodePath))
.thenReturn(Futures.immediateCheckedFuture(Optional.of(dataBefore)));
final SyncupEntry syncupEntry = new SyncupEntry(after, dsTypeAfter, before, dsTypeBefore);
}
private SyncupEntry loadConfigDSAndPrepareSyncupEntry(final FlowCapableNode after, final LogicalDatastoreType dsTypeAfter,
- final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) throws InterruptedException {
+ final FlowCapableNode before, final LogicalDatastoreType dsTypeBefore) {
Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
.thenReturn(Futures.immediateCheckedFuture(Optional.of(configNode)));
final SyncupEntry syncupEntry = new SyncupEntry(after, dsTypeAfter, before, dsTypeBefore);
}
@Test
- public void testSyncupMaster() throws InterruptedException {
+ public void testSyncupMaster() {
Mockito.when(deviceMastershipManager.isDeviceMastered(NODE_ID)).thenReturn(true);
reactor.syncup(fcNodePath, syncupEntry);
}
@Test
- public void testSyncupSlave() throws InterruptedException {
+ public void testSyncupSlave() {
Mockito.when(deviceMastershipManager.isDeviceMastered(NODE_ID)).thenReturn(false);
reactor.syncup(fcNodePath, syncupEntry);
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;
import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
+import org.opendaylight.openflowplugin.applications.frsync.util.SemaphoreKeeperGuavaImpl;
import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@Before
public void setUp() {
+ final SemaphoreKeeper<InstanceIdentifier<FlowCapableNode>> semaphoreKeeper = new SemaphoreKeeperGuavaImpl<>(1, true);
final ExecutorService executorService = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder()
.setDaemon(false)
.setNameFormat("frsync-test-%d")
.setUncaughtExceptionHandler((thread, e) -> LOG.error("Uncaught exception {}", thread, e))
.build());
syncThreadPool = MoreExecutors.listeningDecorator(executorService);
- reactor = new SyncReactorFutureZipDecorator(delegate, syncThreadPool);
+ reactor = new SyncReactorFutureZipDecorator(delegate, syncThreadPool, semaphoreKeeper);
fcNodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID))
.augmentation(FlowCapableNode.class);
}
Mockito.verify(delegate, Mockito.times(1)).syncup(fcNodePath, second);
}
- private void mockSyncupWithEntry(final SyncupEntry entry) throws InterruptedException {
- Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Mockito.eq(entry)))
+ private void mockSyncupWithEntry(final SyncupEntry entry) {
+ Mockito.when(delegate.syncup(Matchers.any(), Mockito.eq(entry)))
.thenReturn(Futures.immediateFuture(Boolean.TRUE));
}
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;
import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;
import org.opendaylight.openflowplugin.applications.frsync.util.SemaphoreKeeperGuavaImpl;
import org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry;
@Before
public void setUp() throws Exception {
- final SemaphoreKeeperGuavaImpl semaphoreKeeper = new SemaphoreKeeperGuavaImpl<InstanceIdentifier<FlowCapableNode>>(1, true);
+ final SemaphoreKeeper<InstanceIdentifier<FlowCapableNode>> semaphoreKeeper = new SemaphoreKeeperGuavaImpl<>(1, true);
reactor = new SyncReactorGuardDecorator(delegate, semaphoreKeeper);
InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
fcNodePath = nodePath.augmentation(FlowCapableNode.class);
}
@Test
- public void testSyncupSuccess() throws Exception {
- Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<SyncupEntry>any()))
+ public void testSyncupSuccess() {
+ Mockito.when(delegate.syncup(Matchers.any(), Matchers.any()))
.thenReturn(Futures.immediateFuture(Boolean.TRUE));
reactor.syncup(fcNodePath, syncupEntry);
}
@Test
- public void testSyncupFail() throws Exception {
- Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<SyncupEntry>any()))
+ public void testSyncupFail() {
+ Mockito.when(delegate.syncup(Matchers.any(), Matchers.any()))
.thenReturn(Futures.immediateFailedFuture(new Exception()));
reactor.syncup(fcNodePath, syncupEntry);
Mockito.verify(delegate).syncup(fcNodePath, syncupEntry);
Mockito.verifyNoMoreInteractions(delegate);
-
}
-
}
\ No newline at end of file
}
@Test
- public void testSyncupSuccess() throws InterruptedException {
+ public void testSyncupSuccess() {
Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<SyncupEntry>any()))
.thenReturn(Futures.immediateFuture(Boolean.TRUE));
}
@Test
- public void testSyncupFail() throws InterruptedException {
+ public void testSyncupFail() {
Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(), Matchers.<SyncupEntry>any()))
.thenReturn(Futures.immediateFuture(Boolean.FALSE));
}
@Test
- public void testSyncupConfigIgnoreInRetry() throws InterruptedException {
+ public void testSyncupConfigIgnoreInRetry() {
Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(true);
Mockito.when(syncupEntry.isOptimizedConfigDelta()).thenReturn(true);
/**
* Test for {@link SemaphoreKeeperGuavaImpl}.
*/
-public class SemaphoreKeeperTest {
- private static final Logger LOG = LoggerFactory.getLogger(SemaphoreKeeperTest.class);
+public class SemaphoreKeeperGuavaImplTest {
+ private static final Logger LOG = LoggerFactory.getLogger(SemaphoreKeeperGuavaImplTest.class);
private SemaphoreKeeperGuavaImpl<String> semaphoreKeeper;
private final String key = "11";
@Before
public void setUp() throws Exception {
- semaphoreKeeper = new SemaphoreKeeperGuavaImpl(1, true);
+ semaphoreKeeper = new SemaphoreKeeperGuavaImpl<>(1, true);
}
@Test