final FlowCapableNode configTree, final FlowCapableNode operationalTree,\r
final LogicalDatastoreType dsType) throws InterruptedException {\r
final NodeId nodeId = PathUtil.digNodeId(flowcapableNodePath);\r
- LOG.trace("syncup {}", nodeId.getValue());\r
+ LOG.trace("syncup guard {}", nodeId.getValue());\r
\r
final long stampBeforeGuard = System.nanoTime();\r
final Semaphore guard = summonGuardAndAcquire(flowcapableNodePath);//TODO handle InteruptedException\r
public void onSuccess(@Nullable final Boolean result) {\r
if (LOG.isDebugEnabled()) {\r
final long stampFinished = System.nanoTime();\r
- LOG.debug("syncup finished {} took:{} rpc:{} wait:{} guard:{}, thread:{}", nodeId.getValue(),\r
+ LOG.debug("syncup finished {} took:{} rpc:{} wait:{} guard:{} permits thread:{}", nodeId.getValue(),\r
formatNanos(stampFinished - stampBeforeGuard),\r
formatNanos(stampFinished - stampAfterGuard),\r
formatNanos(stampAfterGuard - stampBeforeGuard),\r
- guard, threadName());\r
+ guard.availablePermits(), threadName());\r
}\r
\r
- releaseGuardForNodeId(nodeId, guard);\r
+ releaseGuardForNodeId(guard);\r
}\r
\r
@Override\r
public void onFailure(final Throwable t) {\r
if (LOG.isDebugEnabled()) {\r
final long stampFinished = System.nanoTime();\r
- LOG.warn("syncup failed {} took:{} rpc:{} wait:{} guard:{} thread:{}", nodeId.getValue(),\r
+ LOG.warn("syncup failed {} took:{} rpc:{} wait:{} guard:{} permits thread:{}", nodeId.getValue(),\r
formatNanos(stampFinished - stampBeforeGuard),\r
formatNanos(stampFinished - stampAfterGuard),\r
formatNanos(stampAfterGuard - stampBeforeGuard),\r
- guard, threadName());\r
+ guard.availablePermits(), threadName());\r
}\r
\r
- releaseGuardForNodeId(nodeId, guard);\r
+ releaseGuardForNodeId(guard);\r
}\r
});\r
return endResult;\r
- } catch(InterruptedException e) {\r
- releaseGuardForNodeId(nodeId, guard);\r
+ } catch (InterruptedException e) {\r
+ releaseGuardForNodeId(guard);\r
throw e;\r
}\r
}\r
\r
- protected String formatNanos(long nanos) {\r
+ private String formatNanos(long nanos) {\r
return "'" + TimeUnit.NANOSECONDS.toMillis(nanos) + " ms'";\r
}\r
\r
/**\r
- * get guard\r
- *\r
+ * Get guard and lock for node.\r
* @param flowcapableNodePath II of node for which guard should be acquired\r
* @return semaphore guard\r
*/\r
- protected Semaphore summonGuardAndAcquire(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath)\r
+ private Semaphore summonGuardAndAcquire(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath)\r
throws InterruptedException {\r
final Semaphore guard = Preconditions.checkNotNull(semaphoreKeeper.summonGuard(flowcapableNodePath),\r
"no guard for " + flowcapableNodePath);\r
}\r
\r
/**\r
- * unlock per node\r
- *\r
- * @param nodeId NodeId of node which should be unlocked\r
- * @param guard semaphore guard\r
+ * Unlock and release guard.\r
+ * @param guard semaphore guard which should be unlocked\r
*/\r
- protected void releaseGuardForNodeId(final NodeId nodeId, final Semaphore guard) {\r
+ private void releaseGuardForNodeId(final Semaphore guard) {\r
if (guard == null) {\r
return;\r
}\r
guard.release();\r
}\r
\r
- static String threadName() {\r
+ private static String threadName() {\r
final Thread currentThread = Thread.currentThread();\r
return currentThread.getName();\r
}\r