@Test public void unbindInterfacesOfServiceFunctionErrorNoException() throws Exception { when(sfcGeniusSfReader.readInterfacesOfSf(any())) .thenReturn(CompletableFuture.completedFuture(Arrays.asList("IF1", "IF2"))); when(readWriteTransaction.submit()).thenThrow(new SfcGeniusRuntimeException(new Throwable())); sfcGeniusInterfaceServiceManager.unbindInterfacesOfServiceFunction("SF1"); }
@Override public void unbindInterfacesOfServiceFunction(String sfName) { ReadWriteTransaction readWriteTransaction = dataBroker.newReadWriteTransaction(); SfcGeniusSfReader sfReader = getSfcGeniusSfReader(readWriteTransaction); SfcGeniusServiceHandler serviceHandler = getSfcGeniusServiceHandler(readWriteTransaction); LOG.debug("Unbind interfaces of service function {}", sfName); sfReader.readInterfacesOfSf(new SfName(sfName)) .thenCompose(interfaceList -> CompletableFuture.allOf( interfaceList.stream() .map(serviceHandler::unbindFromInterface) .toArray(size -> new CompletableFuture<?>[size]))) .thenCompose((aVoid) -> SfcGeniusUtils.toCompletableFuture(readWriteTransaction.submit(), executor)) .exceptionally(exception -> { if (exception.getCause() instanceof SfcGeniusRuntimeException) { LOG.error("Error unbinding from interfaces of service function {}", sfName, exception.getCause()); return null; } throw new CompletionException(exception.getCause()); }) .join(); }
SfcGeniusInterfaceServiceManager implements ISfcGeniusInterfaceServiceHandler { @Override public void unbindInterfacesOfServiceFunction(String sfName) { ReadWriteTransaction readWriteTransaction = dataBroker.newReadWriteTransaction(); SfcGeniusSfReader sfReader = getSfcGeniusSfReader(readWriteTransaction); SfcGeniusServiceHandler serviceHandler = getSfcGeniusServiceHandler(readWriteTransaction); LOG.debug("Unbind interfaces of service function {}", sfName); sfReader.readInterfacesOfSf(new SfName(sfName)) .thenCompose(interfaceList -> CompletableFuture.allOf( interfaceList.stream() .map(serviceHandler::unbindFromInterface) .toArray(size -> new CompletableFuture<?>[size]))) .thenCompose((aVoid) -> SfcGeniusUtils.toCompletableFuture(readWriteTransaction.submit(), executor)) .exceptionally(exception -> { if (exception.getCause() instanceof SfcGeniusRuntimeException) { LOG.error("Error unbinding from interfaces of service function {}", sfName, exception.getCause()); return null; } throw new CompletionException(exception.getCause()); }) .join(); } }
SfcGeniusInterfaceServiceManager implements ISfcGeniusInterfaceServiceHandler { @Override public void unbindInterfacesOfServiceFunction(String sfName) { ReadWriteTransaction readWriteTransaction = dataBroker.newReadWriteTransaction(); SfcGeniusSfReader sfReader = getSfcGeniusSfReader(readWriteTransaction); SfcGeniusServiceHandler serviceHandler = getSfcGeniusServiceHandler(readWriteTransaction); LOG.debug("Unbind interfaces of service function {}", sfName); sfReader.readInterfacesOfSf(new SfName(sfName)) .thenCompose(interfaceList -> CompletableFuture.allOf( interfaceList.stream() .map(serviceHandler::unbindFromInterface) .toArray(size -> new CompletableFuture<?>[size]))) .thenCompose((aVoid) -> SfcGeniusUtils.toCompletableFuture(readWriteTransaction.submit(), executor)) .exceptionally(exception -> { if (exception.getCause() instanceof SfcGeniusRuntimeException) { LOG.error("Error unbinding from interfaces of service function {}", sfName, exception.getCause()); return null; } throw new CompletionException(exception.getCause()); }) .join(); } SfcGeniusInterfaceServiceManager(DataBroker dataBroker,
                                            RpcProviderRegistry rpcProviderRegistry,
                                            Executor executor); }
SfcGeniusInterfaceServiceManager implements ISfcGeniusInterfaceServiceHandler { @Override public void unbindInterfacesOfServiceFunction(String sfName) { ReadWriteTransaction readWriteTransaction = dataBroker.newReadWriteTransaction(); SfcGeniusSfReader sfReader = getSfcGeniusSfReader(readWriteTransaction); SfcGeniusServiceHandler serviceHandler = getSfcGeniusServiceHandler(readWriteTransaction); LOG.debug("Unbind interfaces of service function {}", sfName); sfReader.readInterfacesOfSf(new SfName(sfName)) .thenCompose(interfaceList -> CompletableFuture.allOf( interfaceList.stream() .map(serviceHandler::unbindFromInterface) .toArray(size -> new CompletableFuture<?>[size]))) .thenCompose((aVoid) -> SfcGeniusUtils.toCompletableFuture(readWriteTransaction.submit(), executor)) .exceptionally(exception -> { if (exception.getCause() instanceof SfcGeniusRuntimeException) { LOG.error("Error unbinding from interfaces of service function {}", sfName, exception.getCause()); return null; } throw new CompletionException(exception.getCause()); }) .join(); } SfcGeniusInterfaceServiceManager(DataBroker dataBroker,
                                            RpcProviderRegistry rpcProviderRegistry,
                                            Executor executor); @Override void bindInterfacesOfServiceFunction(String sfName); @Override void unbindInterfacesOfServiceFunction(String sfName); @Override void interfaceStateUp(String interfaceName, BigInteger dpnId); @Override void interfaceStateDown(String interfaceName, BigInteger nodeId); }
SfcGeniusInterfaceServiceManager implements ISfcGeniusInterfaceServiceHandler { @Override public void unbindInterfacesOfServiceFunction(String sfName) { ReadWriteTransaction readWriteTransaction = dataBroker.newReadWriteTransaction(); SfcGeniusSfReader sfReader = getSfcGeniusSfReader(readWriteTransaction); SfcGeniusServiceHandler serviceHandler = getSfcGeniusServiceHandler(readWriteTransaction); LOG.debug("Unbind interfaces of service function {}", sfName); sfReader.readInterfacesOfSf(new SfName(sfName)) .thenCompose(interfaceList -> CompletableFuture.allOf( interfaceList.stream() .map(serviceHandler::unbindFromInterface) .toArray(size -> new CompletableFuture<?>[size]))) .thenCompose((aVoid) -> SfcGeniusUtils.toCompletableFuture(readWriteTransaction.submit(), executor)) .exceptionally(exception -> { if (exception.getCause() instanceof SfcGeniusRuntimeException) { LOG.error("Error unbinding from interfaces of service function {}", sfName, exception.getCause()); return null; } throw new CompletionException(exception.getCause()); }) .join(); } SfcGeniusInterfaceServiceManager(DataBroker dataBroker,
                                            RpcProviderRegistry rpcProviderRegistry,
                                            Executor executor); @Override void bindInterfacesOfServiceFunction(String sfName); @Override void unbindInterfacesOfServiceFunction(String sfName); @Override void interfaceStateUp(String interfaceName, BigInteger dpnId); @Override void interfaceStateDown(String interfaceName, BigInteger nodeId);  }