@Test public void testFullResyncTimeout() throws ExecutionException, InterruptedException, NetconfMessageBuilderException { makeDeviceTimeout(null); m_das.forceAlign(m_device1, m_getResponse); verify(m_deviceInterface).forceAlign(m_device1, m_getResponse); String expected; if (isWindowsSys()) { expected = "In Error, request sent : <rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\r\n" + " <copy-config>\r\n" + " <source>blah<source>\r\n" + "\t<target>\r\n" + " <running />\r\n" + " </target>\r\n" + " <test-option>set</test-option>\r\n" + " <config>\r\n" + " <some-config xmlns=\"some:ns\"/>\r\n" + " </config>\r\n" + " </copy-config>\r\n" + "</rpc>,\r\n" + "response received : request timed out"; } else { expected = "In Error, request sent : <rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n" + " <copy-config>\n" + " <source>blah<source>\n" + "\t<target>\n" + " <running />\n" + " </target>\n" + " <test-option>set</test-option>\n" + " <config>\n" + " <some-config xmlns=\"some:ns\"/>\n" + " </config>\n" + " </copy-config>\n" + "</rpc>,\n" + "response received : request timed out"; } verify(m_dm).updateConfigAlignmentState(m_device1.getDeviceName(), expected); }
@Override public void forceAlign(Device device, NetConfResponse getConfigResponse) { m_txService.executeWithTx(new TXTemplate<Void>() { @Override public Void execute() { new WithSynchronousDeviceQueue<Void>() { @Override Void execute(String info, List<EditConfigRequest> deviceQueue) throws RuntimeException { try { deviceQueue.clear(); DeviceInterface deviceInterface = AdapterUtils.getAdapterContext(device, m_adapterManager).getDeviceInterface(); Pair<AbstractNetconfRequest, Future<NetConfResponse>> copyConfigFuture = deviceInterface.forceAlign(device, getConfigResponse); NetConfResponse response = null; response = copyConfigFuture.getSecond().get(); if (response == null || !response.isOk()) { markDeviceInError(info, deviceQueue, copyConfigFuture.getFirst().requestToString(), response); } else { markDeviceAligned(info); } } catch (IllegalStateException e) { LOGGER.info(String.format("Device %s is not connected, force-align would be retried", device.getDeviceName())); } catch (ExecutionException | InterruptedException | NetconfMessageBuilderException e) { throw new RuntimeException(e); } return null; } }.execute(device.getDeviceName()); return null; } }); }
NetconfDeviceAlignmentServiceImpl implements NetconfDeviceAlignmentService { @Override public void forceAlign(Device device, NetConfResponse getConfigResponse) { m_txService.executeWithTx(new TXTemplate<Void>() { @Override public Void execute() { new WithSynchronousDeviceQueue<Void>() { @Override Void execute(String info, List<EditConfigRequest> deviceQueue) throws RuntimeException { try { deviceQueue.clear(); DeviceInterface deviceInterface = AdapterUtils.getAdapterContext(device, m_adapterManager).getDeviceInterface(); Pair<AbstractNetconfRequest, Future<NetConfResponse>> copyConfigFuture = deviceInterface.forceAlign(device, getConfigResponse); NetConfResponse response = null; response = copyConfigFuture.getSecond().get(); if (response == null || !response.isOk()) { markDeviceInError(info, deviceQueue, copyConfigFuture.getFirst().requestToString(), response); } else { markDeviceAligned(info); } } catch (IllegalStateException e) { LOGGER.info(String.format("Device %s is not connected, force-align would be retried", device.getDeviceName())); } catch (ExecutionException | InterruptedException | NetconfMessageBuilderException e) { throw new RuntimeException(e); } return null; } }.execute(device.getDeviceName()); return null; } }); } }
NetconfDeviceAlignmentServiceImpl implements NetconfDeviceAlignmentService { @Override public void forceAlign(Device device, NetConfResponse getConfigResponse) { m_txService.executeWithTx(new TXTemplate<Void>() { @Override public Void execute() { new WithSynchronousDeviceQueue<Void>() { @Override Void execute(String info, List<EditConfigRequest> deviceQueue) throws RuntimeException { try { deviceQueue.clear(); DeviceInterface deviceInterface = AdapterUtils.getAdapterContext(device, m_adapterManager).getDeviceInterface(); Pair<AbstractNetconfRequest, Future<NetConfResponse>> copyConfigFuture = deviceInterface.forceAlign(device, getConfigResponse); NetConfResponse response = null; response = copyConfigFuture.getSecond().get(); if (response == null || !response.isOk()) { markDeviceInError(info, deviceQueue, copyConfigFuture.getFirst().requestToString(), response); } else { markDeviceAligned(info); } } catch (IllegalStateException e) { LOGGER.info(String.format("Device %s is not connected, force-align would be retried", device.getDeviceName())); } catch (ExecutionException | InterruptedException | NetconfMessageBuilderException e) { throw new RuntimeException(e); } return null; } }.execute(device.getDeviceName()); return null; } }); } NetconfDeviceAlignmentServiceImpl(DeviceManager dm, NetconfConnectionManager ncm, AdapterManager manager); }
NetconfDeviceAlignmentServiceImpl implements NetconfDeviceAlignmentService { @Override public void forceAlign(Device device, NetConfResponse getConfigResponse) { m_txService.executeWithTx(new TXTemplate<Void>() { @Override public Void execute() { new WithSynchronousDeviceQueue<Void>() { @Override Void execute(String info, List<EditConfigRequest> deviceQueue) throws RuntimeException { try { deviceQueue.clear(); DeviceInterface deviceInterface = AdapterUtils.getAdapterContext(device, m_adapterManager).getDeviceInterface(); Pair<AbstractNetconfRequest, Future<NetConfResponse>> copyConfigFuture = deviceInterface.forceAlign(device, getConfigResponse); NetConfResponse response = null; response = copyConfigFuture.getSecond().get(); if (response == null || !response.isOk()) { markDeviceInError(info, deviceQueue, copyConfigFuture.getFirst().requestToString(), response); } else { markDeviceAligned(info); } } catch (IllegalStateException e) { LOGGER.info(String.format("Device %s is not connected, force-align would be retried", device.getDeviceName())); } catch (ExecutionException | InterruptedException | NetconfMessageBuilderException e) { throw new RuntimeException(e); } return null; } }.execute(device.getDeviceName()); return null; } }); } NetconfDeviceAlignmentServiceImpl(DeviceManager dm, NetconfConnectionManager ncm, AdapterManager manager); void init(); void destroy(); TxService getTxService(); void setTxService(TxService txService); @Override void queueEdit(String deviceName, EditConfigRequest request); @Override List<EditConfigRequest> getEditQueue(String deviceName); void alignAllDevices(); @Override String getAlignmentState(String deviceName); @Override void deviceAdded(String deviceName); @Override void deviceRemoved(String deviceName); @Override void forceAlign(Device device, NetConfResponse getConfigResponse); @Override void align(Device device, NetConfResponse getConfigResponse); }
NetconfDeviceAlignmentServiceImpl implements NetconfDeviceAlignmentService { @Override public void forceAlign(Device device, NetConfResponse getConfigResponse) { m_txService.executeWithTx(new TXTemplate<Void>() { @Override public Void execute() { new WithSynchronousDeviceQueue<Void>() { @Override Void execute(String info, List<EditConfigRequest> deviceQueue) throws RuntimeException { try { deviceQueue.clear(); DeviceInterface deviceInterface = AdapterUtils.getAdapterContext(device, m_adapterManager).getDeviceInterface(); Pair<AbstractNetconfRequest, Future<NetConfResponse>> copyConfigFuture = deviceInterface.forceAlign(device, getConfigResponse); NetConfResponse response = null; response = copyConfigFuture.getSecond().get(); if (response == null || !response.isOk()) { markDeviceInError(info, deviceQueue, copyConfigFuture.getFirst().requestToString(), response); } else { markDeviceAligned(info); } } catch (IllegalStateException e) { LOGGER.info(String.format("Device %s is not connected, force-align would be retried", device.getDeviceName())); } catch (ExecutionException | InterruptedException | NetconfMessageBuilderException e) { throw new RuntimeException(e); } return null; } }.execute(device.getDeviceName()); return null; } }); } NetconfDeviceAlignmentServiceImpl(DeviceManager dm, NetconfConnectionManager ncm, AdapterManager manager); void init(); void destroy(); TxService getTxService(); void setTxService(TxService txService); @Override void queueEdit(String deviceName, EditConfigRequest request); @Override List<EditConfigRequest> getEditQueue(String deviceName); void alignAllDevices(); @Override String getAlignmentState(String deviceName); @Override void deviceAdded(String deviceName); @Override void deviceRemoved(String deviceName); @Override void forceAlign(Device device, NetConfResponse getConfigResponse); @Override void align(Device device, NetConfResponse getConfigResponse); static final String EDITS_PENDING; static final String REQUEST_TIMED_OUT; static final String LINE_SEPARATOR; static final String RESPONSE_RECEIVED; static final String REQUEST_SENT; static final String COMMA; static final String ALIGNMENT_STATE; }