import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
import org.opendaylight.netconf.api.FailedNetconfMessage;
import org.opendaylight.netconf.api.NetconfDocumentedException;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.NetconfTerminationReason;
+import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.netconf.client.NetconfClientDispatcher;
import org.opendaylight.netconf.client.NetconfClientSession;
import org.opendaylight.netconf.client.NetconfClientSessionListener;
final RemoteDeviceId id,
final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> remoteDevice,
final int rpcMessageLimit) {
- this(id, remoteDevice, Optional.<UserPreferences>absent(), rpcMessageLimit);
+ this(id, remoteDevice, Optional.absent(), rpcMessageLimit);
}
private NetconfDeviceCommunicator(
try {
request = requests.peek();
if (request != null && request.future.isUncancellable()) {
- requests.poll();
+ request = requests.poll();
// we have just removed one request from the queue
// we can also release one permit
if (semaphore != null) {
@Override
public ListenableFuture<RpcResult<NetconfMessage>> sendRequest(final NetconfMessage message, final QName rpc) {
sessionLock.lock();
-
- if (semaphore != null && !semaphore.tryAcquire()) {
- LOG.warn("Limit of concurrent rpc messages was reached (limit :"
- + concurentRpcMsgs + "). Rpc reply message is needed. Discarding request of Netconf device with id"
- + id.getName());
- sessionLock.unlock();
- return Futures.immediateFailedFuture(new NetconfDocumentedException(
- "Limit of rpc messages was reached (Limit :" + concurentRpcMsgs
- + ") waiting for emptying the queue of Netconf device with id" + id.getName()));
- }
-
try {
+ if (semaphore != null && !semaphore.tryAcquire()) {
+ LOG.warn("Limit of concurrent rpc messages was reached (limit :" + concurentRpcMsgs
+ + "). Rpc reply message is needed. Discarding request of Netconf device with id" + id.getName());
+ return Futures.immediateFailedFuture(new NetconfDocumentedException(
+ "Limit of rpc messages was reached (Limit :" + concurentRpcMsgs
+ + ") waiting for emptying the queue of Netconf device with id" + id.getName()));
+ }
+
return sendRequestWithLock(message, rpc);
} finally {
sessionLock.unlock();