private ChannelOutboundHandlerAdapter createChannelAdapter() {
return new ChannelOutboundHandlerAdapter() {
@Override
- public void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise)
- throws Exception {
+ public void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) {
sshWriteAsyncHandler.write(ctx, msg, promise);
}
};
}
@Override
- protected void doBind(final SocketAddress localAddress) throws Exception {
+ protected void doBind(final SocketAddress localAddress) {
throw new UnsupportedOperationException("Bind not supported.");
}
}
@Override
- protected void doDisconnect() throws Exception {
+ protected void doDisconnect() {
LOG.info("Disconnect invoked");
doNettyDisconnect();
doMinaDisconnect(false);
}
@Override
- protected void doClose() throws Exception {
+ protected void doClose() {
context.removeSelf();
if (notClosing(session)) {
session.close(true);
}
@Override
- protected void doBeginRead() throws Exception {
+ protected void doBeginRead() {
// Intentional NOOP - read is started by AsyncSshHandlerReader
}
@Override
- protected void doWrite(final ChannelOutboundBuffer in) throws Exception {
+ protected void doWrite(final ChannelOutboundBuffer in) {
throw new IllegalStateException("Outbound writes to SSH should be done by SSH Write handler");
}
* Invoked when SSH session dropped during read using {@link AsyncSshHandlerReader}.
*/
@Override
- public void close() throws Exception {
+ public void close() {
doNettyDisconnect();
}
}
}
@Override
- public void close() throws Exception {
+ public void close() {
acceptor.close(true);
}
}
}
@Override
- public void close() throws Exception {
+ public void close() {
configReg.close();
deviceReg.close();
deviceOpReg.close();
}
@Override
- public void close() throws Exception {
+ public void close() {
reg.close();
}
}
}
@Override
- public void close() throws Exception {
+ public void close() {
authProvider.close();
statusReporter.close();
}
@Override
- public void close() throws Exception {
+ public void close() {
listeners1.clear();
schemaContextListenerListenerRegistration.close();
currentContext.set(null);
}
@Override
- public synchronized void close() throws Exception {
+ public synchronized void close() {
for (final DOMDataReadWriteTransaction rwt : allOpenReadWriteTransactions) {
rwt.cancel();
}
}
@Override
- public void close() throws Exception {
+ public void close() {
// TODO Delete modules-state from operational data store
}
}
@Override
- public void close() throws Exception {
+ public void close() {
closeStream();
}
import com.google.common.base.Optional;
import com.google.common.collect.Sets;
import java.util.Set;
-import org.opendaylight.netconf.api.NetconfDocumentedException;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
private final NetconfHelloMessageAdditionalHeader additionalHeader;
- public NetconfHelloMessage(final Document doc, final NetconfHelloMessageAdditionalHeader additionalHeader)
- throws NetconfDocumentedException {
+ public NetconfHelloMessage(final Document doc, final NetconfHelloMessageAdditionalHeader additionalHeader) {
super(doc);
checkHelloMessage(doc);
this.additionalHeader = additionalHeader;
}
- public NetconfHelloMessage(final Document doc) throws NetconfDocumentedException {
+ public NetconfHelloMessage(final Document doc) {
this(doc, null);
}
}
public static NetconfHelloMessage createClientHello(final Iterable<String> capabilities,
- final Optional<NetconfHelloMessageAdditionalHeader> additionalHeaderOptional)
- throws NetconfDocumentedException {
+ final Optional<NetconfHelloMessageAdditionalHeader> additionalHeaderOptional) {
return new NetconfHelloMessage(createHelloMessageDoc(capabilities), additionalHeaderOptional.orNull());
}
return doc;
}
- public static NetconfHelloMessage createServerHello(final Set<String> capabilities, final long sessionId)
- throws NetconfDocumentedException {
+ public static NetconfHelloMessage createServerHello(final Set<String> capabilities, final long sessionId) {
Document doc = createHelloMessageDoc(capabilities);
Element sessionIdElement = doc.createElementNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0,
XmlNetconfConstants.SESSION_ID);
@Override
protected NetconfClientSession getSession(final NetconfClientSessionListener sessionListener, final Channel channel,
- final NetconfHelloMessage message) throws NetconfDocumentedException {
+ final NetconfHelloMessage message) {
final long sessionId = extractSessionId(message.getDocument());
// Copy here is important: it disconnects the strings from the document
import io.netty.util.concurrent.Promise;
import java.util.Set;
import org.opendaylight.netconf.api.NetconfClientSessionPreferences;
-import org.opendaylight.netconf.api.NetconfDocumentedException;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
final Channel channel, final Promise<NetconfClientSession> promise) {
NetconfMessage startExiMessage = NetconfStartExiMessage.create(options, START_EXI_MESSAGE_ID);
- NetconfHelloMessage helloMessage = null;
- try {
- helloMessage = NetconfHelloMessage.createClientHello(clientCapabilities, additionalHeader);
- } catch (NetconfDocumentedException e) {
- LOG.error("Unable to create client hello message with capabilities {} and additional handler {}",
- clientCapabilities, additionalHeader);
- throw new IllegalStateException(e);
- }
+ NetconfHelloMessage helloMessage = NetconfHelloMessage.createClientHello(clientCapabilities, additionalHeader);
NetconfClientSessionPreferences proposal = new NetconfClientSessionPreferences(helloMessage, startExiMessage);
return new NetconfClientSessionNegotiator(proposal, promise, channel, timer,
import io.netty.channel.Channel;
import io.netty.util.concurrent.Promise;
-import java.io.IOException;
import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer;
import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
import org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler;
@Override
public void initialize(final Channel ch, final Promise<NetconfClientSession> promise) {
- try {
- // ssh handler has to be the first handler in pipeline
- ch.pipeline().addFirst(AsyncSshHandler.createForNetconfSubsystem(authenticationHandler, promise));
- super.initialize(ch, promise);
- } catch (final IOException e) {
- throw new RuntimeException(e);
- }
+ // ssh handler has to be the first handler in pipeline
+ ch.pipeline().addFirst(AsyncSshHandler.createForNetconfSubsystem(authenticationHandler, promise));
+ super.initialize(ch, promise);
}
@Override
@Override
public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress,
final SocketAddress localAddress,
- final ChannelPromise channelPromise) throws Exception {
+ final ChannelPromise channelPromise) {
connectPromise = channelPromise;
ChannelPromise tcpConnectFuture = new DefaultChannelPromise(ch);
}
@Override
- public void channelActive(ChannelHandlerContext ctx) throws Exception {
+ public void channelActive(ChannelHandlerContext ctx) {
ctx.pipeline().replace(this, "sslHandler", sslHandlerFactory.createSslHandler())
.fireChannelActive();
}
import io.netty.util.concurrent.Promise;
import java.net.SocketAddress;
import java.util.Set;
-import org.opendaylight.netconf.api.NetconfDocumentedException;
import org.opendaylight.netconf.api.NetconfServerSessionPreferences;
import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
final Channel channel, final Promise<NetconfServerSession> promise) {
final long sessionId = idProvider.getNextSessionId();
- NetconfServerSessionPreferences proposal;
- try {
- proposal = new NetconfServerSessionPreferences(createHelloMessage(sessionId, monitoringService), sessionId);
- } catch (final NetconfDocumentedException e) {
- LOG.error("Unable to create hello message for session {} with {}", sessionId, monitoringService);
- throw new IllegalStateException(e);
- }
+ NetconfServerSessionPreferences proposal =
+ new NetconfServerSessionPreferences(createHelloMessage(sessionId, monitoringService), sessionId);
return new NetconfServerSessionNegotiator(proposal, promise, channel, timer,
getListener(Long.toString(sessionId), channel.parent().localAddress()), connectionTimeoutMillis);
}
private NetconfHelloMessage createHelloMessage(
- final long sessionId, final NetconfMonitoringService capabilityProvider) throws NetconfDocumentedException {
+ final long sessionId, final NetconfMonitoringService capabilityProvider) {
return NetconfHelloMessage.createServerHello(Sets.union(transformCapabilities(capabilityProvider
.getCapabilities()), baseCapabilities), sessionId);
}
@Override
protected Element handleWithNoSubsequentOperations(final Document document,
- final XmlElement operationElement) throws DocumentedException {
+ final XmlElement operationElement) {
final Element getSchemaResult = document.createElementNS(
XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);
LOG.trace("{} operation successful", START_EXI);
*/
package org.opendaylight.netconf.impl.mapping.operations;
-import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
@Override
protected Element handleWithNoSubsequentOperations(Document document,
- XmlElement operationElement) throws DocumentedException {
+ XmlElement operationElement) {
LOG.debug("Received stop-exi message {} ", XmlUtil.toString(operationElement));
netconfSession.stopExiCommunication();
}
@Override
- public synchronized void close() throws Exception {
+ public synchronized void close() {
listeners.clear();
capabilities.clear();
}
}
@Override
- public void close() throws Exception {
+ public void close() {
capabilityMonitoring.close();
sessionMonitoring.close();
}
}
@Override
- public void close() throws Exception {
+ public void close() {
netconfOperationServiceSnapshot.close();
}
- private static DocumentedException handleUnexpectedEx(final String message, final Exception exception) throws
- DocumentedException {
+ private static DocumentedException handleUnexpectedEx(final String message, final Exception exception) {
LOG.error("{}", message, exception);
return new DocumentedException("Unexpected error",
DocumentedException.ErrorType.APPLICATION,
}
return new AutoCloseable() {
@Override
- public void close() throws Exception {
+ public void close() {
listeners.remove(listener);
}
};
}
@Override
- public synchronized void close() throws Exception {
+ public synchronized void close() {
stopUpdateSessionStats();
listeners.clear();
sessions.clear();
private static final Logger LOG = LoggerFactory.getLogger(DeserializerExceptionHandler.class);
@Override
- public void handlerAdded(final ChannelHandlerContext ctx) throws Exception {
+ public void handlerAdded(final ChannelHandlerContext ctx) {
// NOOP
}
@Override
- public void handlerRemoved(final ChannelHandlerContext ctx) throws Exception {
+ public void handlerRemoved(final ChannelHandlerContext ctx) {
// NOOP
}
@Override
- public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
+ public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
LOG.warn("An exception occurred during message handling", cause);
handleDeserializerException(ctx, cause);
}
}
@Override
- public Document execute(Document requestMessage) throws DocumentedException {
+ public Document execute(Document requestMessage) {
throw new IllegalStateException("This execution represents the termination point in operation execution "
+ "and cannot be executed itself");
}
@Override
protected Element handle(final Document document, final XmlElement message,
- final NetconfOperationChainedExecution subsequentOperation)
- throws DocumentedException {
+ final NetconfOperationChainedExecution subsequentOperation) {
throw new UnsupportedOperationException("Never gets called");
}
}
channel.close().addListener(new GenericFutureListener<ChannelFuture>() {
@Override
- public void operationComplete(final ChannelFuture future) throws Exception {
+ public void operationComplete(final ChannelFuture future) {
if (future.isSuccess()) {
LOG.debug("Channel {} closed: success", future.channel());
} else {
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
-import org.opendaylight.netconf.api.NetconfDocumentedException;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
@Override
@VisibleForTesting
public void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out)
- throws IOException, SAXException, NetconfDocumentedException {
+ throws IOException, SAXException {
if (in.readableBytes() == 0) {
LOG.debug("No more content in incoming buffer.");
return;
}
}
- private static NetconfMessage getNetconfMessage(final String additionalHeader, final Document doc)
- throws NetconfDocumentedException {
+ private static NetconfMessage getNetconfMessage(final String additionalHeader, final Document doc) {
NetconfMessage msg = new NetconfMessage(doc);
if (NetconfHelloMessage.isHelloMessage(msg)) {
if (additionalHeader != null) {
private GenericFutureListener negotiationFutureListener;
public AsyncSshHandler(final AuthenticationHandler authenticationHandler, final SshClient sshClient,
- final Future<?> negotiationFuture) throws IOException {
+ final Future<?> negotiationFuture) {
this(authenticationHandler, sshClient);
this.negotiationFuture = negotiationFuture;
}
*
* @param authenticationHandler authentication handler
* @param sshClient started SshClient
- * @throws IOException if the I/O operation fails
*/
public AsyncSshHandler(final AuthenticationHandler authenticationHandler,
- final SshClient sshClient) throws IOException {
+ final SshClient sshClient) {
this.authenticationHandler = Preconditions.checkNotNull(authenticationHandler);
this.sshClient = Preconditions.checkNotNull(sshClient);
}
- public static AsyncSshHandler createForNetconfSubsystem(final AuthenticationHandler authenticationHandler)
- throws IOException {
+ public static AsyncSshHandler createForNetconfSubsystem(final AuthenticationHandler authenticationHandler) {
return new AsyncSshHandler(authenticationHandler, DEFAULT_CLIENT);
}
* @param authenticationHandler authentication handler
* @param negotiationFuture negotiation future
* @return {@code AsyncSshHandler}
- * @throws IOException if the I/O operation fails
*/
public static AsyncSshHandler createForNetconfSubsystem(final AuthenticationHandler authenticationHandler,
- final Future<?> negotiationFuture) throws IOException {
+ final Future<?> negotiationFuture) {
return new AsyncSshHandler(authenticationHandler, DEFAULT_CLIENT, negotiationFuture);
}
}
@Override
- public void close(final ChannelHandlerContext ctx, final ChannelPromise promise) throws Exception {
+ public void close(final ChannelHandlerContext ctx, final ChannelPromise promise) {
disconnect(ctx, promise);
}
@Override
protected Element handle(final Document document, final XmlElement message,
- final NetconfOperationChainedExecution subsequentOperation)
- throws DocumentedException {
+ final NetconfOperationChainedExecution subsequentOperation) {
throw new UnsupportedOperationException("Never gets called");
}
}
@Override
- public void close() throws Exception {
+ public void close() {
}
}
private NetconfNotificationManager netconfNotificationManager;
@Override
- public void start(final BundleContext context) throws Exception {
+ public void start(final BundleContext context) {
netconfNotificationManager = new NetconfNotificationManager();
// Add properties to autowire with netconf-impl instance for cfg subsystem
final Dictionary<String, String> props = new Hashtable<>();
}
@Override
- public void stop(final BundleContext context) throws Exception {
+ public void stop(final BundleContext context) {
if (netconfNotificationCollectorServiceRegistration != null) {
netconfNotificationCollectorServiceRegistration.unregister();
netconfNotificationCollectorServiceRegistration = null;
import org.apache.sshd.server.keyprovider.AbstractGeneratorHostKeyProvider;
import org.opendaylight.netconf.auth.AuthProvider;
import org.opendaylight.netconf.util.NetconfConfiguration;
-import org.osgi.framework.InvalidSyntaxException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// Called via blueprint
@SuppressWarnings("unused")
- public void init() throws IOException, InvalidSyntaxException {
+ public void init() throws IOException {
minaTimerExecutor = Executors.newScheduledThreadPool(POOL_SIZE,
runnable -> new Thread(runnable, "netconf-ssh-server-mina-timers"));
clientGroup = new NioEventLoopGroup();
}
private SshProxyServer startSSHServer()
- throws IOException, InvalidSyntaxException {
+ throws IOException {
final InetSocketAddress sshSocketAddress = netconfConfiguration.getSshServerAddress();
LOG.info("Starting netconf SSH server at {}", sshSocketAddress);
import io.netty.channel.local.LocalAddress;
import io.netty.channel.local.LocalChannel;
import io.netty.util.concurrent.GenericFutureListener;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
}
@Override
- public void start(final Environment env) throws IOException {
+ public void start(final Environment env) {
LOG.trace("Establishing internal connection to netconf server for client: {}", getClientAddress());
final Bootstrap clientBootstrap = new Bootstrap();
clientBootstrap.handler(new ChannelInitializer<LocalChannel>() {
@Override
- public void initChannel(final LocalChannel ch) throws Exception {
+ public void initChannel(final LocalChannel ch) {
ch.pipeline()
.addLast(new SshProxyClientHandler(in, out, netconfHelloMessageAdditionalHeader, callback));
}
clientChannelFuture.addListener(new GenericFutureListener<ChannelFuture>() {
@Override
- public void operationComplete(final ChannelFuture future) throws Exception {
+ public void operationComplete(final ChannelFuture future) {
if (future.isSuccess()) {
clientChannel = clientChannelFuture.channel();
} else {
clientChannel.close().addListener(new GenericFutureListener<ChannelFuture>() {
@Override
- public void operationComplete(final ChannelFuture future) throws Exception {
+ public void operationComplete(final ChannelFuture future) {
if (!future.isSuccess()) {
LOG.warn("Unable to release internal connection to netconf server on channel: {}",
clientChannel);
}
@Override
- public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception {
+ public void channelRead(final ChannelHandlerContext ctx, final Object msg) {
asyncSshHandlerWriter.write(ctx, msg, ctx.newPromise());
}
}
@Override
- public void close() throws Exception {
+ public void close() {
if (tcpServer.isDone()) {
tcpServer.channel().close();
} else {
import java.net.InetSocketAddress;
import org.opendaylight.netconf.tcp.netty.ProxyServer;
import org.opendaylight.netconf.util.NetconfConfiguration;
-import org.osgi.framework.InvalidSyntaxException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// Called via blueprint
@SuppressWarnings("unused")
- public void init() throws InvalidSyntaxException {
+ public void init() {
final InetSocketAddress address = netconfConfiguration.getTcpServerAddress();
if (address.getAddress().isAnyLocalAddress()) {
.handler(new LoggingHandler(LogLevel.DEBUG))
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
- public void initChannel(SocketChannel ch) throws Exception {
+ public void initChannel(SocketChannel ch) {
ch.pipeline().addLast(new ProxyServerHandler(clientBootstrap, localAddress));
}
});
final ProxyClientHandler clientHandler = new ProxyClientHandler(remoteCtx);
clientBootstrap.handler(new ChannelInitializer<LocalChannel>() {
@Override
- public void initChannel(LocalChannel ch) throws Exception {
+ public void initChannel(LocalChannel ch) {
ch.pipeline().addLast(clientHandler);
}
});
}
@Override
- public void close() throws Exception {
+ public void close() {
if (!closed.compareAndSet(false, true)) {
return;
}
future.onComplete(new OnComplete<Object>() {
@Override
- public void onComplete(final Throwable failure, final Object success) throws Throwable {
+ public void onComplete(final Throwable failure, final Object success) {
if (failure != null) {
LOG.error("Failed to refresh master actor data: {}", failure);
return;
scalaFuture.onComplete(new OnComplete<Object>() {
@Override
- public void onComplete(final Throwable failure, final Object success) throws Throwable {
+ public void onComplete(final Throwable failure, final Object success) {
if (failure != null) {
promise.failure(failure);
return;
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
- public void handleReceive(final Object message) throws Exception {
+ public void handleReceive(final Object message) {
LOG.debug("{}: received message {}", id, message);
if (message instanceof CreateInitialMasterActorData) { // master
}
@SuppressWarnings("checkstyle:IllegalThrows")
- public void handle(final Object message, final ActorRef sender, final ActorRef self) throws Throwable {
+ public void handle(final Object message, final ActorRef sender, final ActorRef self) {
if (message instanceof ReadRequest) {
final ReadRequest readRequest = (ReadRequest) message;
}
@Override
- public void onReceive(final Object message) throws Throwable {
+ public void onReceive(final Object message) {
if (message instanceof ReadActorMessage) {
readAdapter.handle(message, sender(), self());
} else {
}
@Override
- public void onReceive(final Object message) throws Throwable {
+ public void onReceive(final Object message) {
if (message instanceof ReadActorMessage) {
readAdapter.handle(message, sender(), self());
} else if (message instanceof WriteActorMessage) {
}
@Override
- public void onReceive(final Object message) throws Throwable {
+ public void onReceive(final Object message) {
if (message instanceof WriteActorMessage) {
writeAdapter.handle(message, sender(), context(), self());
} else if (message instanceof ReceiveTimeout) {
}
@Override
- public void close() throws Exception {
+ public void close() {
if (communicator != null) {
communicator.close();
}
package org.opendaylight.netconf.topology.singleton.messages;
import java.io.Externalizable;
-import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
}
@Override
- public void writeExternal(final ObjectOutput out) throws IOException {
+ public void writeExternal(final ObjectOutput out) {
SerializationUtils.serializePathAndNode(getIdentifier(), node, out);
}
@Override
- public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
+ public void readExternal(final ObjectInput in) {
SerializationUtils.deserializePathAndNode(in, this, APPLIER);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
- public void handleReceive(Object message) throws Exception {
+ public void handleReceive(Object message) {
CompletableFuture dropFuture = messagesToDrop.remove(message.getClass());
if (dropFuture != null) {
dropFuture.complete(message);
}
@Override
- public void close() throws Exception {
+ public void close() {
// close all existing connectors, delete whole topology in datastore?
for (final NetconfConnectorDTO connectorDTO : activeConnectors.values()) {
connectorDTO.close();
}
}
- public static Collection<String> extractCapabilitiesFromHello(final Document doc)
- throws NetconfDocumentedException {
+ public static Collection<String> extractCapabilitiesFromHello(final Document doc) {
XmlElement responseElement = XmlElement.fromDomDocument(doc);
// Extract child element <capabilities> from <hello> with or without(fallback) the same namespace
Optional<XmlElement> capabilitiesElement = responseElement
}
@Override
- public void operationComplete(final ChannelFuture channelFuture) throws Exception {
+ public void operationComplete(final ChannelFuture channelFuture) {
Preconditions.checkState(channelFuture.isSuccess(), "Unable to send exception %s", sendErrorException,
channelFuture.cause());
}
}
@Override
- public DeviceSources call() throws Exception {
+ public DeviceSources call() {
final NetconfDeviceSchemas availableSchemas =
stateSchemasResolver.resolve(deviceRpc, remoteSessionCapabilities, id);
LOG.debug("{}: Schemas exposed by ietf-netconf-monitoring: {}", id,
}
@Override
- public void close() throws Exception {
+ public void close() {
mountInstance.close();
if (topologyDatastoreAdapter != null) {
topologyDatastoreAdapter.close();
}
@Override
- public synchronized void close() throws Exception {
+ public synchronized void close() {
onTopologyDeviceDisconnected();
}
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import javax.annotation.Nonnull;
}
@Override
- public InputStream openStream() throws IOException {
+ public InputStream openStream() {
return new ByteArrayInputStream(schemaString.get().getBytes(StandardCharsets.UTF_8));
}
}
}
@Override
- public Response onCompleted(Response response) throws Exception {
+ public Response onCompleted(Response response) {
semaphore.release();
return response;
}
}
@Override
- public Void call() throws Exception {
+ public Void call() {
if (invokeAsync) {
this.invokeAsync();
} else {
}
private SshProxyServerConfiguration getSshConfiguration(final InetSocketAddress bindingAddress,
- final LocalAddress tcpLocalAddress, final KeyPairProvider keyPairProvider) throws IOException {
+ final LocalAddress tcpLocalAddress, final KeyPairProvider keyPairProvider) {
return new SshProxyServerConfigurationBuilder()
.setBindingAddress(bindingAddress)
.setLocalAddress(tcpLocalAddress)
}
@Override
- public InputStream openStream() throws IOException {
+ public InputStream openStream() {
return getClass().getResourceAsStream(resource);
}
}), PotentialSchemaSource.create(sourceId, YangTextSchemaSource.class,
private static class TimeoutGuard implements Callable<Void> {
@Override
- public Void call() throws Exception {
+ public Void call() {
resultsLog.warn("Timeout for scale test reached after: {} ..aborting", STOPWATCH);
root.warn("Timeout for scale test reached after: {} ..aborting", STOPWATCH);
System.exit(0);
}
@Override
- public T call() throws Exception {
+ public T call() {
try {
return theCallable.call();
} catch (Exception e) {
}
@Override
- public Response onCompleted(Response response) throws Exception {
+ public Response onCompleted(Response response) {
semaphore.release();
return response;
}
}
@Override
- public Void call() throws Exception {
+ public Void call() {
executionStrategy.invoke();
asyncHttpClient.closeAsynchronously();
return null;
}
- public static void main(String[] args) throws IOException {
+ public static void main(String[] args) {
Parameters parameters = parseArgs(args, Parameters.getParser());
parameters.validate();
}
@Override
- public Boolean call() throws Exception {
+ public Boolean call() {
executionStrategy.invoke();
netconfClientSession.close();
return Boolean.TRUE;
}
@Override
- public HandlingPriority canHandle(final Document message) throws DocumentedException {
+ public HandlingPriority canHandle(final Document message) {
return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.increasePriority(1000);
}
package org.opendaylight.netconf.test.tool.rpc;
import com.google.common.base.Optional;
-import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
}
@Override
- protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
- throws DocumentedException {
+ protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) {
return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
}
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlRootElement;
-import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
}
@Override
- protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
- throws DocumentedException {
+ protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) {
long delayAggregator = 0;
for (final Map.Entry<Notification, NetconfMessage> notification : notifications.entrySet()) {
package org.opendaylight.netconf.test.tool.rpc;
import com.google.common.base.Optional;
-import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
}
@Override
- protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
- throws DocumentedException {
+ protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) {
return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
}
package org.opendaylight.netconf.test.tool.rpc;
import com.google.common.base.Optional;
-import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
}
@Override
- protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
- throws DocumentedException {
+ protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) {
final Element element = XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.absent());
for (final XmlElement e : storage.getConfigList()) {
import java.io.File;
import java.io.IOException;
import java.util.List;
-import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
}
@Override
- protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
- throws DocumentedException {
+ protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) {
final Element element = XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.absent());
for (final XmlElement e : storage.getConfigList()) {
package org.opendaylight.netconf.test.tool.rpc;
import com.google.common.base.Optional;
-import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
}
@Override
- protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
- throws DocumentedException {
+ protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) {
return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
}
package org.opendaylight.netconf.test.tool.rpc;
import com.google.common.base.Optional;
-import org.opendaylight.netconf.api.DocumentedException;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
}
@Override
- protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
- throws DocumentedException {
+ protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement) {
return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
}
}
@Override
- public HandlingPriority canHandle(final Document message) throws DocumentedException {
+ public HandlingPriority canHandle(final Document message) {
return HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.increasePriority(1000);
}
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
}
@Override
- public InputStream openStream() throws IOException {
+ public InputStream openStream() {
return TestToolUtils.getDataAsStream(cachedSource);
}
};
}
@Override
- public void operationComplete(final ChannelFuture cf) throws Exception {
+ public void operationComplete(final ChannelFuture cf) {
synchronized (lock) {
LOG.debug("Promise {} connection resolved", lock);
}
@Override
- public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
+ public void channelInactive(final ChannelHandlerContext ctx) {
// This is the ultimate channel inactive handler, not forwarding
if (promise.isCancelled()) {
return;
*/
package org.opendaylight.netconf.md.sal.rest.schema;
-import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@Override
public void writeTo(final SchemaExportContext context, final Class<?> type, final Type genericType,
final Annotation[] annotations, final MediaType mediaType,
- final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException,
- WebApplicationException {
+ final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws
+ WebApplicationException {
try {
YinExportUtils.writeModuleAsYinText(context.getModule(), entityStream);
} catch (final XMLStreamException e) {
@Override
public NormalizedNodeContext readFrom(final Class<NormalizedNodeContext> type, final Type genericType,
final Annotation[] annotations, final MediaType mediaType,
- final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream) throws IOException,
- WebApplicationException {
+ final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream) throws
+ WebApplicationException {
try {
return readFrom(getInstanceIdentifierContext(), entityStream, isPost());
} catch (final Exception e) {
public PatchContext readFrom(final Class<PatchContext> type, final Type genericType,
final Annotation[] annotations, final MediaType mediaType,
final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream)
- throws IOException, WebApplicationException {
+ throws WebApplicationException {
try {
return readFrom(getInstanceIdentifierContext(), entityStream);
} catch (final Exception e) {
package org.opendaylight.netconf.sal.rest.impl;
-import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
public void writeTo(final PatchStatusContext patchStatusContext, final Class<?> type, final Type genericType,
final Annotation[] annotations, final MediaType mediaType,
final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream)
- throws IOException, WebApplicationException {
+ throws WebApplicationException {
try {
final XMLStreamWriter xmlWriter =
}
private static void writeDocument(final XMLStreamWriter writer, final PatchStatusContext context)
- throws XMLStreamException, IOException {
+ throws XMLStreamException {
writer.writeStartElement("", "yang-patch-status", "urn:ietf:params:xml:ns:yang:ietf-yang-patch");
writer.writeStartElement("patch-id");
writer.writeCharacters(context.getPatchId());
}
private static void reportErrors(final List<RestconfError> errors, final XMLStreamWriter writer)
- throws IOException, XMLStreamException {
+ throws XMLStreamException {
writer.writeStartElement("errors");
for (final RestconfError restconfError : errors) {
@Override
public NormalizedNodeContext readFrom(final Class<NormalizedNodeContext> type, final Type genericType,
final Annotation[] annotations, final MediaType mediaType,
- final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream) throws IOException,
- WebApplicationException {
+ final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream) throws
+ WebApplicationException {
try {
return readFrom(entityStream);
} catch (final RestconfDocumentedException e) {
public PatchContext readFrom(final Class<PatchContext> type, final Type genericType,
final Annotation[] annotations, final MediaType mediaType,
final MultivaluedMap<String, String> httpHeaders, final InputStream entityStream)
- throws IOException, WebApplicationException {
+ throws WebApplicationException {
try {
final InstanceIdentifierContext<?> path = getInstanceIdentifierContext();
}
@Override
- public final void close() throws Exception {
+ public final void close() {
this.registration.close();
this.registration = null;
unregister();
import io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker;
import io.netty.handler.codec.http.websocketx.WebSocketServerHandshakerFactory;
import io.netty.util.CharsetUtil;
-import java.io.IOException;
import java.util.List;
import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
import org.opendaylight.netconf.sal.streams.listeners.ListenerAdapter;
private WebSocketServerHandshaker handshaker;
@Override
- protected void channelRead0(final ChannelHandlerContext ctx, final Object msg) throws Exception {
+ protected void channelRead0(final ChannelHandlerContext ctx, final Object msg) {
if (msg instanceof FullHttpRequest) {
handleHttpRequest(ctx, (FullHttpRequest) msg);
} else if (msg instanceof WebSocketFrame) {
* @param req
* FullHttpRequest
*/
- private void handleHttpRequest(final ChannelHandlerContext ctx, final FullHttpRequest req) throws Exception {
+ private void handleHttpRequest(final ChannelHandlerContext ctx, final FullHttpRequest req) {
// Handle a bad request.
if (!req.getDecoderResult().isSuccess()) {
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, BAD_REQUEST));
* @param frame
* {@link WebSocketFrame}
*/
- private void handleWebSocketFrame(final ChannelHandlerContext ctx, final WebSocketFrame frame) throws IOException {
+ private void handleWebSocketFrame(final ChannelHandlerContext ctx, final WebSocketFrame frame) {
if (frame instanceof CloseWebSocketFrame) {
this.handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
final String streamName = Notificator.createStreamNameFromUri(((CloseWebSocketFrame) frame).reasonText());
}
@Override
- public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
+ public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
ctx.close();
}
public class WebSocketServerInitializer extends ChannelInitializer<SocketChannel> {
@Override
- protected void initChannel(final SocketChannel ch) throws Exception {
+ protected void initChannel(final SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("codec-http", new HttpServerCodec());
pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
import java.io.File;
import java.io.FileNotFoundException;
-import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import javax.ws.rs.WebApplicationException;
try {
normalizedNodeContext = this.jsonBodyReader.readFrom(null, null, null,
this.mediaType, null, inputStream);
- } catch (WebApplicationException | IOException e) {
+ } catch (WebApplicationException e) {
// TODO Auto-generated catch block
}
import com.google.common.collect.Iterables;
import com.google.gson.stream.JsonReader;
-import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
protected NormalizedNodeContext readBody(final InstanceIdentifierContext<?> path, final InputStream entityStream)
- throws IOException, WebApplicationException {
+ throws WebApplicationException {
try {
return readFrom(path, entityStream, isPost());
} catch (final Exception e) {
}
public static NormalizedNodeContext readFrom(
- final InstanceIdentifierContext<?> path, final InputStream entityStream, final boolean isPost)
- throws IOException {
+ final InstanceIdentifierContext<?> path, final InputStream entityStream, final boolean isPost) {
final NormalizedNodeResult resultHolder = new NormalizedNodeResult();
final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder);
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
protected NormalizedNodeContext readBody(final InstanceIdentifierContext<?> path, final InputStream entityStream)
- throws IOException, WebApplicationException {
+ throws WebApplicationException {
try {
final Document doc = UntrustedXML.newDocumentBuilder().parse(entityStream);
return parse(path,doc);
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
protected PatchContext readBody(final InstanceIdentifierContext<?> path, final InputStream entityStream)
- throws IOException, WebApplicationException {
+ throws WebApplicationException {
try {
return readFrom(path, entityStream);
} catch (final Exception e) {
package org.opendaylight.restconf.nb.rfc8040.jersey.providers.patch;
-import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
public void writeTo(final PatchStatusContext patchStatusContext, final Class<?> type, final Type genericType,
final Annotation[] annotations, final MediaType mediaType,
final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream)
- throws IOException, WebApplicationException {
+ throws WebApplicationException {
try {
final XMLStreamWriter xmlWriter =
}
private static void writeDocument(final XMLStreamWriter writer, final PatchStatusContext context)
- throws XMLStreamException, IOException {
+ throws XMLStreamException {
writer.writeStartElement("", "yang-patch-status", "urn:ietf:params:xml:ns:yang:ietf-yang-patch");
writer.writeStartElement("patch-id");
writer.writeCharacters(context.getPatchId());
}
private static void reportErrors(final List<RestconfError> errors, final XMLStreamWriter writer)
- throws IOException, XMLStreamException {
+ throws XMLStreamException {
writer.writeStartElement("errors");
for (final RestconfError restconfError : errors) {
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
protected PatchContext readBody(final InstanceIdentifierContext<?> path, final InputStream entityStream)
- throws IOException, WebApplicationException {
+ throws WebApplicationException {
try {
final Document doc = UntrustedXML.newDocumentBuilder().parse(entityStream);
return parse(path, doc);
*/
package org.opendaylight.restconf.nb.rfc8040.jersey.providers.schema;
-import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@Override
public void writeTo(final SchemaExportContext context, final Class<?> type, final Type genericType,
final Annotation[] annotations, final MediaType mediaType,
- final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException,
- WebApplicationException {
+ final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws
+ WebApplicationException {
try {
YinExportUtils.writeModuleAsYinText(context.getModule(), entityStream);
} catch (final XMLStreamException e) {
protected abstract T emptyBody(InstanceIdentifierContext<?> path);
protected abstract T readBody(InstanceIdentifierContext<?> path, InputStream entityStream)
- throws IOException, WebApplicationException;
+ throws WebApplicationException;
private String getIdentifier() {
}
final InputStream entityStream = new ByteArrayInputStream(payload.getBytes(StandardCharsets.UTF_8));
- try {
- return JsonNormalizedNodeBodyReader.readFrom(instanceIdentifierContext, entityStream, isPost);
- } catch (final IOException e) {
- propagateExceptionAs(uriPath, e, "GET");
- return null;
- }
+ return JsonNormalizedNodeBodyReader.readFrom(instanceIdentifierContext, entityStream, isPost);
}
private String toJson(final PatchStatusContext patchStatusContext) throws IOException {
import io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker;
import io.netty.handler.codec.http.websocketx.WebSocketServerHandshakerFactory;
import io.netty.util.CharsetUtil;
-import java.io.IOException;
import java.util.List;
import org.opendaylight.restconf.nb.rfc8040.streams.listeners.ListenerAdapter;
import org.opendaylight.restconf.nb.rfc8040.streams.listeners.NotificationListenerAdapter;
private WebSocketServerHandshaker handshaker;
@Override
- protected void channelRead0(final ChannelHandlerContext ctx, final Object msg) throws Exception {
+ protected void channelRead0(final ChannelHandlerContext ctx, final Object msg) {
if (msg instanceof FullHttpRequest) {
handleHttpRequest(ctx, (FullHttpRequest) msg);
} else if (msg instanceof WebSocketFrame) {
* @param req
* FullHttpRequest
*/
- private void handleHttpRequest(final ChannelHandlerContext ctx, final FullHttpRequest req) throws Exception {
+ private void handleHttpRequest(final ChannelHandlerContext ctx, final FullHttpRequest req) {
// Handle a bad request.
if (!req.getDecoderResult().isSuccess()) {
sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, BAD_REQUEST));
* @param frame
* {@link WebSocketFrame}
*/
- private void handleWebSocketFrame(final ChannelHandlerContext ctx, final WebSocketFrame frame) throws IOException {
+ private void handleWebSocketFrame(final ChannelHandlerContext ctx, final WebSocketFrame frame) {
if (frame instanceof CloseWebSocketFrame) {
this.handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame.retain());
final String streamName = Notificator.createStreamNameFromUri(((CloseWebSocketFrame) frame).reasonText());
}
@Override
- public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
+ public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
ctx.close();
}
public class WebSocketServerInitializer extends ChannelInitializer<SocketChannel> {
@Override
- protected void initChannel(final SocketChannel ch) throws Exception {
+ protected void initChannel(final SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("codec-http", new HttpServerCodec());
pipeline.addLast("aggregator", new HttpObjectAggregator(65536));