X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=applications%2Fforwardingrules-sync%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fapplications%2Ffrsync%2Fimpl%2FSyncReactorGuardDecorator.java;h=ebd10d89ef4f4138def2719b41302761bd32d481;hb=777c94332871b8c34f56f7f2010de1536cb759ba;hp=015cd8e4554a4ee2e9c809e86f1662476e75ece1;hpb=f1af4f7f93a7d7e27b85dc1b45e725a531799f26;p=openflowplugin.git diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java index 015cd8e455..ebd10d89ef 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java @@ -1,21 +1,18 @@ -/** +/* * Copyright (c) 2016 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.openflowplugin.applications.frsync.impl; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; -import java.util.Objects; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper; import org.opendaylight.openflowplugin.applications.frsync.SyncReactor; import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil; @@ -41,12 +38,13 @@ public class SyncReactorGuardDecorator implements SyncReactor { this.delegate = delegate; } + @Override public ListenableFuture syncup(final InstanceIdentifier flowcapableNodePath, final SyncupEntry syncupEntry) { final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath); final long stampBeforeGuard = System.nanoTime(); final Semaphore guard = semaphoreKeeper.summonGuardAndAcquire(flowcapableNodePath); - if (Objects.isNull(guard)) { + if (guard == null) { return Futures.immediateFuture(Boolean.FALSE); } final long stampAfterGuard = System.nanoTime(); @@ -64,9 +62,9 @@ public class SyncReactorGuardDecorator implements SyncReactor { final long stampBeforeGuard, final long stampAfterGuard, final NodeId nodeId) { - return new FutureCallback() { + return new FutureCallback<>() { @Override - public void onSuccess(@Nullable final Boolean result) { + public void onSuccess(final Boolean result) { if (LOG.isDebugEnabled()) { final long stampFinished = System.nanoTime(); LOG.debug("Syncup finished {} took:{} rpc:{} wait:{}", nodeId.getValue(), @@ -75,14 +73,16 @@ public class SyncReactorGuardDecorator implements SyncReactor { } semaphoreKeeper.releaseGuard(guard); } + @Override - public void onFailure(final Throwable t) { + public void onFailure(final Throwable failure) { final long stampFinished = System.nanoTime(); LOG.warn("Syncup failed {} took:{} rpc:{} wait:{}", nodeId.getValue(), formatNanos(stampFinished - stampBeforeGuard), formatNanos(stampFinished - stampAfterGuard), formatNanos(stampAfterGuard - stampBeforeGuard)); semaphoreKeeper.releaseGuard(guard); - }}; + } + }; } private static String formatNanos(final long nanos) {