import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
-import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider;
-import org.opendaylight.controller.netconf.mapping.api.Capability;
-import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
-import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceSnapshot;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
+import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider;
+import org.opendaylight.controller.netconf.mapping.api.Capability;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceSnapshot;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class CapabilityProviderImpl implements CapabilityProvider {
private final NetconfOperationServiceSnapshot netconfOperationServiceSnapshot;
private final Set<String> capabilityURIs;
- private static final Logger logger = LoggerFactory.getLogger(DefaultCommitNotificationProducer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(CapabilityProviderImpl.class);
public CapabilityProviderImpl(NetconfOperationServiceSnapshot netconfOperationServiceSnapshot) {
this.netconfOperationServiceSnapshot = netconfOperationServiceSnapshot;
for (Capability cap : caps) {
if(capabilityMap.containsKey(cap.getCapabilityUri())) {
- logger.debug("Duplicate capability {} from service {}", cap.getCapabilityUri(), netconfOperationService);
+ LOG.debug("Duplicate capability {} from service {}", cap.getCapabilityUri(), netconfOperationService);
}
capabilityMap.put(cap.getCapabilityUri(), cap);
package org.opendaylight.controller.netconf.impl;
-import org.opendaylight.controller.netconf.api.jmx.CommitJMXNotification;
-import org.opendaylight.controller.netconf.api.jmx.DefaultCommitOperationMXBean;
-import org.opendaylight.controller.netconf.api.jmx.NetconfJMXNotification;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Element;
-
+import java.util.Set;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanRegistrationException;
import javax.management.NotCompliantMBeanException;
import javax.management.NotificationBroadcasterSupport;
import javax.management.ObjectName;
-import java.util.Set;
+import org.opendaylight.controller.netconf.api.jmx.CommitJMXNotification;
+import org.opendaylight.controller.netconf.api.jmx.DefaultCommitOperationMXBean;
+import org.opendaylight.controller.netconf.api.jmx.NetconfJMXNotification;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
public class DefaultCommitNotificationProducer extends NotificationBroadcasterSupport implements
DefaultCommitOperationMXBean, AutoCloseable {
- private static final Logger logger = LoggerFactory.getLogger(DefaultCommitNotificationProducer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DefaultCommitNotificationProducer.class);
private final MBeanServer mbeanServer;
public DefaultCommitNotificationProducer(MBeanServer mBeanServer) {
this.mbeanServer = mBeanServer;
- logger.debug("Registering to JMX under {}", on);
+ LOG.debug("Registering to JMX under {}", on);
registerMBean(this, mbeanServer, on);
}
public void sendCommitNotification(String message, Element cfgSnapshot, Set<String> capabilities) {
CommitJMXNotification notif = NetconfJMXNotification.afterCommit(this, message, cfgSnapshot, capabilities);
- logger.debug("Notification about commit {} sent", notif);
+ LOG.debug("Notification about commit {} sent", notif);
sendNotification(notif);
}
try {
mbeanServer.unregisterMBean(on);
} catch (InstanceNotFoundException | MBeanRegistrationException e) {
- logger.warn("Ignoring exception while unregistering {} as {}", this, on, e);
+ LOG.warn("Ignoring exception while unregistering {} as {}", this, on, e);
}
}
}
public final class NetconfServerSession extends AbstractNetconfSession<NetconfServerSession, NetconfServerSessionListener> implements NetconfManagementSession {
- private static final Logger logger = LoggerFactory.getLogger(NetconfServerSession.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSession.class);
private final NetconfHelloMessageAdditionalHeader header;
NetconfHelloMessageAdditionalHeader header) {
super(sessionListener, channel, sessionId);
this.header = header;
- logger.debug("Session {} created", toString());
+ LOG.debug("Session {} created", toString());
}
@Override
private Class<? extends Transport> getTransportForString(String transport) {
switch(transport) {
- case "ssh" : return NetconfSsh.class;
- case "tcp" : return NetconfTcp.class;
- default: throw new IllegalArgumentException("Unknown transport type " + transport);
+ case "ssh" :
+ return NetconfSsh.class;
+ case "tcp" :
+ return NetconfTcp.class;
+ default:
+ throw new IllegalArgumentException("Unknown transport type " + transport);
}
}
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.api.NetconfSessionListener;
public class NetconfServerSessionListener implements NetconfSessionListener<NetconfServerSession> {
- static final Logger logger = LoggerFactory.getLogger(NetconfServerSessionListener.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSessionListener.class);
private final SessionMonitoringService monitoringService;
private final NetconfOperationRouter operationRouter;
private final AutoCloseable onSessionDownCloseable;
@Override
public void onSessionDown(NetconfServerSession netconfNetconfServerSession, Exception cause) {
- logger.debug("Session {} down, reason: {}", netconfNetconfServerSession, cause.getMessage());
+ LOG.debug("Session {} down, reason: {}", netconfNetconfServerSession, cause.getMessage());
onDown(netconfNetconfServerSession);
}
try {
operationRouter.close();
} catch (Exception closingEx) {
- logger.debug("Ignoring exception while closing operationRouter", closingEx);
+ LOG.debug("Ignoring exception while closing operationRouter", closingEx);
}
try {
onSessionDownCloseable.close();
} catch(Exception ex){
- logger.debug("Ignoring exception while closing onSessionDownCloseable", ex);
+ LOG.debug("Ignoring exception while closing onSessionDownCloseable", ex);
}
}
@Override
public void onSessionTerminated(NetconfServerSession netconfNetconfServerSession,
NetconfTerminationReason netconfTerminationReason) {
- logger.debug("Session {} terminated, reason: {}", netconfNetconfServerSession,
+ LOG.debug("Session {} terminated, reason: {}", netconfNetconfServerSession,
netconfTerminationReason.getErrorMessage());
onDown(netconfNetconfServerSession);
}
// schemas
final NetconfMessage message = processDocument(netconfMessage,
session);
- logger.debug("Responding with message {}", XmlUtil.toString(message.getDocument()));
+ LOG.debug("Responding with message {}", XmlUtil.toString(message.getDocument()));
session.sendMessage(message);
if (isCloseSession(netconfMessage)) {
} catch (final RuntimeException e) {
// TODO: should send generic error or close session?
- logger.error("Unexpected exception", e);
+ LOG.error("Unexpected exception", e);
session.onIncommingRpcFail();
throw new IllegalStateException("Unable to process incoming message " + netconfMessage, e);
} catch (NetconfDocumentedException e) {
- logger.trace("Error occurred while processing message",e);
+ LOG.trace("Error occurred while processing message",e);
session.onOutgoingRpcError();
session.onIncommingRpcFail();
SendErrorExceptionUtil.sendErrorMessage(session, e, netconfMessage);
private void closeNetconfSession(NetconfServerSession session) {
// destroy NetconfOperationService
session.close();
- logger.info("Session {} closed successfully", session.getSessionId());
+ LOG.info("Session {} closed successfully", session.getSessionId());
}
}
private void checkMessageId(Node rootNode) throws NetconfDocumentedException {
- NamedNodeMap attributes = rootNode.getAttributes();
+
+ NamedNodeMap attributes = rootNode.getAttributes();
+
if(attributes.getNamedItemNS(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.MESSAGE_ID)!=null) {
return;
}
throw new NetconfDocumentedException("Missing attribute" + rootNode.getNodeName(),
NetconfDocumentedException.ErrorType.protocol, NetconfDocumentedException.ErrorTag.missing_attribute,
- NetconfDocumentedException.ErrorSeverity.error, ImmutableMap.of(NetconfDocumentedException.ErrorTag.missing_attribute.toString(),
- XmlNetconfConstants.MESSAGE_ID));
+ NetconfDocumentedException.ErrorSeverity.error,
+ ImmutableMap.of(NetconfDocumentedException.ErrorTag.missing_attribute.toString(),
+ XmlNetconfConstants.MESSAGE_ID));
}
private static boolean isCloseSession(final NetconfMessage incomingDocument) {
package org.opendaylight.controller.netconf.impl;
-import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouter;
import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider;
+import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouter;
import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouterImpl;
import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceSnapshot;
import io.netty.channel.local.LocalAddress;
import io.netty.util.Timer;
import io.netty.util.concurrent.Promise;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.AbstractMap;
+import java.util.Map;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.NetconfServerSessionPreferences;
import org.opendaylight.controller.netconf.nettyutil.AbstractNetconfSessionNegotiator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.util.AbstractMap;
-import java.util.Map;
-
public class NetconfServerSessionNegotiator
extends
AbstractNetconfSessionNegotiator<NetconfServerSessionPreferences, NetconfServerSession, NetconfServerSessionListener> {
- static final Logger logger = LoggerFactory
- .getLogger(NetconfServerSessionNegotiator.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSessionNegotiator.class);
+
private static final String UNKNOWN = "unknown";
protected NetconfServerSessionNegotiator(
}
- logger.debug("Additional header from hello parsed as {} from {}",
+ LOG.debug("Additional header from hello parsed as {} from {}",
parsedHeader, additionalHeader);
return new NetconfServerSession(sessionListener, channel,
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
-
+import com.google.common.collect.Sets;
+import io.netty.channel.Channel;
+import io.netty.util.Timer;
+import io.netty.util.concurrent.Promise;
import java.util.Set;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.NetconfServerSessionPreferences;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.protocol.framework.SessionListenerFactory;
import org.opendaylight.protocol.framework.SessionNegotiator;
import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
-
-import com.google.common.collect.Sets;
-
-import io.netty.channel.Channel;
-import io.netty.util.Timer;
-import io.netty.util.concurrent.Promise;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final long connectionTimeoutMillis;
private final DefaultCommitNotificationProducer commitNotificationProducer;
private final SessionMonitoringService monitoringService;
- private static final Logger logger = LoggerFactory.getLogger(NetconfServerSessionNegotiatorFactory.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSessionNegotiatorFactory.class);
private final Set<String> baseCapabilities;
// TODO too many params, refactor
proposal = new NetconfServerSessionPreferences(
createHelloMessage(sessionId, capabilityProvider), sessionId);
} catch (NetconfDocumentedException e) {
- logger.error("Unable to create hello mesage for session {} with capability provider {}", sessionId,capabilityProvider);
+ LOG.error("Unable to create hello mesage for session {} with capability provider {}", sessionId,capabilityProvider);
throw new IllegalStateException(e);
}
* See <a href="http://tools.ietf.org/html/rfc6241#section-6">rfc6241</a> for details.
*/
public class SubtreeFilter {
- private static final Logger logger = LoggerFactory.getLogger(SubtreeFilter.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SubtreeFilter.class);
static Document applySubtreeFilter(Document requestDocument, Document rpcReply) throws NetconfDocumentedException {
// FIXME: rpcReply document must be reread otherwise some nodes do not inherit namespaces. (services/service)
try {
rpcReply = XmlUtil.readXmlToDocument(XmlUtil.toString(rpcReply, true));
} catch (SAXException | IOException e) {
- logger.error("Cannot transform document", e);
+ LOG.error("Cannot transform document", e);
throw new NetconfDocumentedException("Cannot transform document");
}
XmlNetconfConstants.FILTER, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
if (maybeFilter.isPresent() && (
"subtree".equals(maybeFilter.get().getAttribute("type"))||
- "subtree".equals(maybeFilter.get().getAttribute("type", XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0))
- )) {
+ "subtree".equals(maybeFilter.get().getAttribute("type", XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0)))
+ ) {
// do
if (result == null) {
result = MatchingResult.NO_MATCH;
}
- logger.debug("Matching {} to {} resulted in {}", src, filter, result);
+ LOG.debug("Matching {} to {} resulted in {}", src, filter, result);
return result;
}
package org.opendaylight.controller.netconf.impl.mapping;
import com.google.common.base.Optional;
-
import java.util.Set;
public interface CapabilityProvider {
package org.opendaylight.controller.netconf.impl.mapping.operations;
+import com.google.common.base.Optional;
+import java.util.Collections;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.mapping.AbstractSingletonNetconfOperation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import com.google.common.base.Optional;
-
-import java.util.Collections;
-
public class DefaultCloseSession extends AbstractSingletonNetconfOperation {
public static final String CLOSE_SESSION = "close-session";
private final AutoCloseable sessionResources;
+ getNetconfSessionIdForReporting(), NetconfDocumentedException.ErrorType.application,
NetconfDocumentedException.ErrorTag.operation_failed,
NetconfDocumentedException.ErrorSeverity.error, Collections.singletonMap(
- NetconfDocumentedException.ErrorSeverity.error.toString(), e.getMessage()));
+ NetconfDocumentedException.ErrorSeverity.error.toString(), e.getMessage()));
}
return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
}
package org.opendaylight.controller.netconf.impl.mapping.operations;
import com.google.common.base.Preconditions;
-
+import java.io.InputStream;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
-import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouter;
import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider;
+import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouter;
import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
import org.opendaylight.controller.netconf.util.mapping.AbstractNetconfOperation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import java.io.InputStream;
-
public class DefaultCommit extends AbstractNetconfOperation {
- private static final Logger logger = LoggerFactory.getLogger(DefaultCommit.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DefaultCommit.class);
private static final String NOTIFY_ATTR = "notify";
"Subsequent netconf operation expected by %s", this);
if (isCommitWithoutNotification(requestMessage)) {
- logger.debug("Skipping commit notification");
+ LOG.debug("Skipping commit notification");
} else {
// Send commit notification if commit was not issued by persister
removePersisterAttributes(requestMessage);
Element cfgSnapshot = getConfigSnapshot(operationRouter);
- logger.debug("Config snapshot retrieved successfully {}", cfgSnapshot);
+ LOG.debug("Config snapshot retrieved successfully {}", cfgSnapshot);
notificationProducer.sendCommitNotification("ok", cfgSnapshot, cap.getCapabilities());
}
xmlElement = XmlElement.fromDomElementWithExpected(message.getDocumentElement(),
XmlNetconfConstants.RPC_KEY, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
} catch (NetconfDocumentedException e) {
- logger.trace("Commit operation is not valid due to {}",e);
+ LOG.trace("Commit operation is not valid due to ",e);
return false;
}
if (attr == null || attr.equals("")){
return false;
} else if (attr.equals(Boolean.toString(false))) {
- logger.debug("Commit operation received with notify=false attribute {}", message);
+ LOG.debug("Commit operation received with notify=false attribute {}", message);
return true;
} else {
return false;
import com.google.common.base.Optional;
import com.google.common.collect.Maps;
-
+import java.util.Map;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import java.util.Map;
-
public final class DefaultGetSchema extends AbstractLastNetconfOperation {
public static final String GET_SCHEMA = "get-schema";
public static final String IDENTIFIER = "identifier";
public static final String VERSION = "version";
- private static final Logger logger = LoggerFactory.getLogger(DefaultGetSchema.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DefaultGetSchema.class);
private final CapabilityProvider cap;
public DefaultGetSchema(CapabilityProvider cap, String netconfSessionIdForReporting) {
} catch (IllegalStateException e) {
Map<String, String> errorInfo = Maps.newHashMap();
errorInfo.put(entry.identifier, e.getMessage());
- logger.warn("Rpc error: {}", NetconfDocumentedException.ErrorTag.operation_failed, e);
+ LOG.warn("Rpc error: {}", NetconfDocumentedException.ErrorTag.operation_failed, e);
throw new NetconfDocumentedException(e.getMessage(), NetconfDocumentedException.ErrorType.application,
NetconfDocumentedException.ErrorTag.operation_failed,
NetconfDocumentedException.ErrorSeverity.error, errorInfo);
Element getSchemaResult;
getSchemaResult = XmlUtil.createTextElement(document, XmlNetconfConstants.DATA_KEY, schema,
Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_YANG_IETF_NETCONF_MONITORING));
- logger.trace("{} operation successful", GET_SCHEMA);
+ LOG.trace("{} operation successful", GET_SCHEMA);
return getSchemaResult;
}
try {
identifierElement = getSchemaElement.getOnlyChildElementWithSameNamespace(IDENTIFIER);
} catch (MissingNameSpaceException e) {
- logger.trace("Can't get identifier element as only child element with same namespace due to {}",e);
+ LOG.trace("Can't get identifier element as only child element with same namespace due to ",e);
throw NetconfDocumentedException.wrap(e);
}
identifier = identifierElement.getTextContent();
import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorSeverity;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorTag;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorType;
-import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.impl.NetconfServerSession;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
import org.opendaylight.controller.netconf.util.mapping.AbstractSingletonNetconfOperation;
public class DefaultStartExi extends AbstractSingletonNetconfOperation implements DefaultNetconfOperation {
public static final String START_EXI = "start-exi";
- private static final Logger logger = LoggerFactory.getLogger(DefaultStartExi.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DefaultStartExi.class);
private NetconfServerSession netconfSession;
public DefaultStartExi(String netconfSessionIdForReporting) {
@Override
public Document handle(Document message,
NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException {
- logger.debug("Received start-exi message {} ", XmlUtil.toString(message));
+ LOG.debug("Received start-exi message {} ", XmlUtil.toString(message));
try {
netconfSession.startExiCommunication(new NetconfMessage(message));
@Override
protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException {
Element getSchemaResult = document.createElementNS( XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);
- logger.trace("{} operation successful", START_EXI);
+ LOG.trace("{} operation successful", START_EXI);
return getSchemaResult;
}
public static final String STOP_EXI = "stop-exi";
private NetconfServerSession netconfSession;
- private static final Logger logger = LoggerFactory
- .getLogger(DefaultStartExi.class);
+ private static final Logger LOG = LoggerFactory
+ .getLogger(DefaultStopExi.class);
public DefaultStopExi(String netconfSessionIdForReporting) {
super(netconfSessionIdForReporting);
@Override
protected Element handleWithNoSubsequentOperations(Document document, XmlElement operationElement) throws NetconfDocumentedException {
- logger.debug("Received stop-exi message {} ", XmlUtil.toString(operationElement));
+ LOG.debug("Received stop-exi message {} ", XmlUtil.toString(operationElement));
netconfSession.stopExiCommunication();
Element getSchemaResult = document.createElementNS( XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.OK);
- logger.trace("{} operation successful", STOP_EXI);
+ LOG.trace("{} operation successful", STOP_EXI);
return getSchemaResult;
}
public class NetconfImplActivator implements BundleActivator {
- private static final Logger logger = LoggerFactory.getLogger(NetconfImplActivator.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfImplActivator.class);
private NetconfOperationServiceFactoryTracker factoriesTracker;
private DefaultCommitNotificationProducer commitNot;
NetconfServerDispatcher dispatch = new NetconfServerDispatcher(serverChannelInitializer, eventLoopGroup, eventLoopGroup);
LocalAddress address = NetconfConfigUtil.getNetconfLocalAddress();
- logger.trace("Starting local netconf server at {}", address);
+ LOG.trace("Starting local netconf server at {}", address);
dispatch.createLocalServer(address);
context.registerService(NetconfOperationProvider.class, factoriesListener, null);
@Override
public void stop(final BundleContext context) {
- logger.info("Shutting down netconf because YangStoreService service was removed");
+ LOG.info("Shutting down netconf because YangStoreService service was removed");
commitNot.close();
eventLoopGroup.shutdownGracefully(0, 1, TimeUnit.SECONDS);
public class NetconfMonitoringServiceImpl implements NetconfMonitoringService, SessionMonitoringService {
- private static final Logger logger = LoggerFactory.getLogger(NetconfMonitoringServiceImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfMonitoringServiceImpl.class);
private final Set<NetconfManagementSession> sessions = new ConcurrentSet<>();
private final NetconfOperationProvider netconfOperationProvider;
@Override
public void onSessionUp(NetconfManagementSession session) {
- logger.debug("Session {} up", session);
+ LOG.debug("Session {} up", session);
Preconditions.checkState(!sessions.contains(session), "Session %s was already added", session);
sessions.add(session);
}
@Override
public void onSessionDown(NetconfManagementSession session) {
- logger.debug("Session {} down", session);
+ LOG.debug("Session {} down", session);
Preconditions.checkState(sessions.contains(session), "Session %s not present", session);
sessions.remove(session);
}
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.Set;
+import java.util.TreeMap;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
import org.opendaylight.controller.netconf.impl.NetconfServerSession;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.NavigableMap;
-import java.util.Set;
-import java.util.TreeMap;
-
public class NetconfOperationRouterImpl implements NetconfOperationRouter {
- private static final Logger logger = LoggerFactory.getLogger(NetconfOperationRouterImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfOperationRouterImpl.class);
private final NetconfOperationServiceSnapshot netconfOperationServiceSnapshot;
private Set<NetconfOperation> allNetconfOperations;
messageAsString = XmlUtil.toString(message);
netconfOperationExecution = getNetconfOperationWithHighestPriority(message, session);
} catch (IllegalArgumentException | IllegalStateException e) {
- logger.warn("Unable to handle rpc {} on session {}", messageAsString, session, e);
+ LOG.warn("Unable to handle rpc {} on session {}", messageAsString, session, e);
String errorMessage = String.format("Unable to handle rpc %s on session %s", messageAsString, session);
Map<String, String> errorInfo = Maps.newHashMap();
}
private NetconfDocumentedException handleUnexpectedEx(String s, Exception e) throws NetconfDocumentedException {
- logger.error(s, e);
+ LOG.error(s, e);
Map<String, String> info = Maps.newHashMap();
info.put(NetconfDocumentedException.ErrorSeverity.error.toString(), e.toString());
private Document executeOperationWithHighestPriority(Document message,
NetconfOperationExecution netconfOperationExecution, String messageAsString)
throws NetconfDocumentedException {
- logger.debug("Forwarding netconf message {} to {}", messageAsString, netconfOperationExecution.netconfOperation);
+ LOG.debug("Forwarding netconf message {} to {}", messageAsString, netconfOperationExecution.netconfOperation);
return netconfOperationExecution.execute(message);
}
*/
package org.opendaylight.controller.netconf.impl.osgi;
-import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
-import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
-
import java.util.HashSet;
import java.util.Set;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
+import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
public class NetconfOperationServiceFactoryListenerImpl implements NetconfOperationServiceFactoryListener,
NetconfOperationProvider {
package org.opendaylight.controller.netconf.impl.osgi;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceSnapshot;
import org.opendaylight.controller.netconf.util.CloseableUtil;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
public class NetconfOperationServiceSnapshotImpl implements NetconfOperationServiceSnapshot {
private final Set<NetconfOperationService> services;
import com.google.common.collect.Maps;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
+import java.util.Map;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.util.messages.SendErrorExceptionUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Map;
-
-public final class
- DeserializerExceptionHandler implements ChannelHandler {
-
- private static final Logger logger = LoggerFactory.getLogger(DeserializerExceptionHandler.class);
+public final class DeserializerExceptionHandler implements ChannelHandler {
+ private static final Logger LOG = LoggerFactory.getLogger(DeserializerExceptionHandler.class);
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
- logger.warn("An exception occurred during message handling", cause);
+ LOG.warn("An exception occurred during message handling", cause);
handleDeserializerException(ctx, cause);
}
package org.opendaylight.controller.netconf.impl;
import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
-
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.HashedWheelTimer;
import io.netty.util.concurrent.GlobalEventExecutor;
-
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicLong;
-
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl;
import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener;
+import org.opendaylight.controller.netconf.client.TestingNetconfClient;
import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration;
import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder;
-import org.opendaylight.controller.netconf.client.TestingNetconfClient;
import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
import org.opendaylight.controller.netconf.mapping.api.Capability;
@RunWith(Parameterized.class)
public class ConcurrentClientsTest {
- private static final Logger logger = LoggerFactory.getLogger(ConcurrentClientsTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ConcurrentClientsTest.class);
private static ExecutorService clientExecutor;
@Parameterized.Parameters()
public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][]{
- {4, TestingNetconfClientRunnable.class, NetconfServerSessionNegotiatorFactory.DEFAULT_BASE_CAPABILITIES},
- {1, TestingNetconfClientRunnable.class, NetconfServerSessionNegotiatorFactory.DEFAULT_BASE_CAPABILITIES},
- // empty set of capabilities = only base 1.0 netconf capability
- {4, TestingNetconfClientRunnable.class, Collections.emptySet()},
- {4, TestingNetconfClientRunnable.class, getOnlyExiServerCaps()},
- {4, TestingNetconfClientRunnable.class, getOnlyChunkServerCaps()},
-
- {4, BlockingClientRunnable.class, getOnlyExiServerCaps()},
- {1, BlockingClientRunnable.class, getOnlyExiServerCaps()},
+ return Arrays.asList(new Object[][]{{4, TestingNetconfClientRunnable.class, NetconfServerSessionNegotiatorFactory.DEFAULT_BASE_CAPABILITIES},
+ {1, TestingNetconfClientRunnable.class, NetconfServerSessionNegotiatorFactory.DEFAULT_BASE_CAPABILITIES},
+ // empty set of capabilities = only base 1.0 netconf capability
+ {4, TestingNetconfClientRunnable.class, Collections.emptySet()},
+ {4, TestingNetconfClientRunnable.class, getOnlyExiServerCaps()},
+ {4, TestingNetconfClientRunnable.class, getOnlyChunkServerCaps()},
+ {4, BlockingClientRunnable.class, getOnlyExiServerCaps()},
+ {1, BlockingClientRunnable.class, getOnlyExiServerCaps()},
});
}
try {
nettyGroup.shutdownGracefully().get();
} catch (InterruptedException | ExecutionException e) {
- logger.warn("Ignoring exception while cleaning up after test", e);
+ LOG.warn("Ignoring exception while cleaning up after test", e);
}
}
} catch (InterruptedException e) {
throw new IllegalStateException(e);
} catch (ExecutionException e) {
- logger.error("Thread for testing client failed", e);
+ LOG.error("Thread for testing client failed", e);
fail("Client failed: " + e.getMessage());
}
}
@Override
public Document handle(Document requestMessage, NetconfOperationChainedExecution subsequentOperation) throws NetconfDocumentedException {
try {
- logger.info("Handling netconf message from test {}", XmlUtil.toString(requestMessage));
+ LOG.info("Handling netconf message from test {}", XmlUtil.toString(requestMessage));
counter.getAndIncrement();
return XmlUtil.readXmlToDocument("<test/>");
} catch (Exception e) {
while (sb.toString().endsWith("]]>]]>") == false) {
sb.append((char) inFromServer.read());
}
- logger.info(sb.toString());
+ LOG.info(sb.toString());
outToServer.write(IOUtils.toByteArray(clientHello));
outToServer.write("]]>]]>".getBytes());
while (sb.toString().endsWith("]]>]]>") == false) {
sb.append((char) inFromServer.read());
}
- logger.info(sb.toString());
+ LOG.info(sb.toString());
clientSocket.close();
}
}
final TestingNetconfClient netconfClient =
new TestingNetconfClient(Thread.currentThread().getName(), netconfClientDispatcher, getClientConfig());
long sessionId = netconfClient.getSessionId();
- logger.info("Client with session id {}: hello exchanged", sessionId);
+ LOG.info("Client with session id {}: hello exchanged", sessionId);
final NetconfMessage getMessage = XmlFileLoader
.xmlFileToNetconfMessage("netconfMessages/getConfig.xml");
NetconfMessage result = netconfClient.sendRequest(getMessage).get();
- logger.info("Client with session id {}: got result {}", sessionId, result);
+ LOG.info("Client with session id {}: got result {}", sessionId, result);
Preconditions.checkState(NetconfMessageUtil.isErrorMessage(result) == false,
"Received error response: " + XmlUtil.toString(result.getDocument()) + " to request: "
+ XmlUtil.toString(getMessage.getDocument()));
netconfClient.close();
- logger.info("Client with session id {}: ended", sessionId);
+ LOG.info("Client with session id {}: ended", sessionId);
} catch (final Exception e) {
throw new IllegalStateException(Thread.currentThread().getName(), e);
}
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.HashedWheelTimer;
+import java.lang.management.ManagementFactory;
+import java.net.InetSocketAddress;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
-import java.lang.management.ManagementFactory;
-import java.net.InetSocketAddress;
-
public class NetconfDispatcherImplTest {
private EventLoopGroup nettyGroup;
package org.opendaylight.controller.netconf.impl;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opendaylight.controller.netconf.api.monitoring.NetconfManagementSession;
-import org.opendaylight.controller.netconf.impl.NetconfServerSession;
-import org.opendaylight.controller.netconf.impl.NetconfServerSessionListener;
import org.opendaylight.controller.netconf.impl.osgi.NetconfMonitoringServiceImpl;
import org.opendaylight.controller.netconf.mapping.api.Capability;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceSnapshot;
import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.*;
-
public class NetconfMonitoringServiceImplTest {
private NetconfMonitoringServiceImpl service;
@RunWith(value = Parameterized.class)
public class SubtreeFilterTest {
- private static final Logger logger = LoggerFactory.getLogger(SubtreeFilterTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SubtreeFilterTest.class);
private final int directoryIndex;
Document preFilterDocument = getDocument("pre-filter.xml");
Document postFilterDocument = getDocument("post-filter.xml");
Document actualPostFilterDocument = SubtreeFilter.applySubtreeFilter(requestDocument, preFilterDocument);
- logger.info("Actual document: {}", XmlUtil.toString(actualPostFilterDocument));
+ LOG.info("Actual document: {}", XmlUtil.toString(actualPostFilterDocument));
Diff diff = XMLUnit.compareXML(postFilterDocument, actualPostFilterDocument);
assertTrue(diff.toString(), diff.similar());
package org.opendaylight.controller.netconf.impl.mapping.operations;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
import org.junit.Test;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.w3c.dom.Document;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
public class DefaultCloseSessionTest {
@Test
package org.opendaylight.controller.netconf.impl.mapping.operations;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anySetOf;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
import com.google.common.collect.Sets;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.mockito.Mockito.*;
-
public class DefaultCommitTest {
private NetconfOperationChainedExecution operation;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
+
import com.google.common.base.Optional;
import org.junit.Before;
import org.junit.Test;
package org.opendaylight.controller.netconf.impl.mapping.operations;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.*;
-
public class DefaultStopExiTest {
@Test
public void testHandleWithNoSubsequentOperations() throws Exception {
package org.opendaylight.controller.netconf.impl.osgi;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
import java.util.Arrays;
import java.util.Dictionary;
import org.junit.Before;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
public class NetconfImplActivatorTest {
@Mock
package org.opendaylight.controller.netconf.impl.osgi;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.osgi.framework.Filter;
import org.osgi.framework.ServiceReference;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-
public class NetconfOperationServiceFactoryTrackerTest {
@Mock
package org.opendaylight.controller.netconf.impl.util;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import org.junit.Before;
import org.junit.Test;
-import static org.mockito.Mockito.*;
-
public class DeserializerExceptionHandlerTest {
private DeserializerExceptionHandler handler;