From: Robert Varga Date: Thu, 7 May 2015 15:54:53 +0000 (+0200) Subject: Lower the size of deviceContext synchronized block X-Git-Tag: release/lithium~227 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=ae16842d541bf0b4ae97b5d8b3b10e70a3a232f4;p=openflowplugin.git Lower the size of deviceContext synchronized block The synchronized block is needlessly large, slowing things down with unrelated transitions happening. Change-Id: I700ba58f567c592a611fd50f94cf27594385f865 Signed-off-by: Robert Varga --- diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/callback/BaseCallback.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/callback/BaseCallback.java index 1f3379c072..63d5f296dd 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/callback/BaseCallback.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/callback/BaseCallback.java @@ -29,7 +29,7 @@ public class BaseCallback implements FutureCallback> { protected DeviceContext deviceContext; protected RequestContext requestContext; - private ListenableFuture> futureResultFromOfLib; + private final ListenableFuture> futureResultFromOfLib; public BaseCallback(final DeviceContext deviceContext, final RequestContext requestContext, final ListenableFuture> futureResultFromOfLib) { this.deviceContext = deviceContext; @@ -45,18 +45,19 @@ public class BaseCallback implements FutureCallback> { // remove current request from request cache in deviceContext deviceContext.unhookRequestCtx(requestContext.getXid()); - // handle requestContext failure - StringBuilder rpcErrors = new StringBuilder(); - if (null != fRpcResult.getErrors() && fRpcResult.getErrors().size() > 0) { - for (RpcError error : fRpcResult.getErrors()) { - rpcErrors.append(error.getMessage()); - } + } + + // handle requestContext failure + StringBuilder rpcErrors = new StringBuilder(); + if (null != fRpcResult.getErrors() && fRpcResult.getErrors().size() > 0) { + for (RpcError error : fRpcResult.getErrors()) { + rpcErrors.append(error.getMessage()); } - LOG.trace("OF Java result for XID {} was not successful. Errors : {}", requestContext.getXid().getValue(), rpcErrors.toString()); - requestContext.getFuture().set( - RpcResultBuilder.failed().withRpcErrors(fRpcResult.getErrors()).build()); - RequestContextUtil.closeRequstContext(requestContext); } + LOG.trace("OF Java result for XID {} was not successful. Errors : {}", requestContext.getXid().getValue(), rpcErrors.toString()); + requestContext.getFuture().set( + RpcResultBuilder.failed().withRpcErrors(fRpcResult.getErrors()).build()); + RequestContextUtil.closeRequstContext(requestContext); } else { // else: message was successfully sent - waiting for callback on requestContext.future to get invoked // or can be implemented specific processing via processSuccess() method