<config.configfile.directory>etc/opendaylight/karaf</config.configfile.directory>
<config.clustering.configfile>05-clustering.xml</config.clustering.configfile>
<config.netty.configfile>00-netty.xml</config.netty.configfile>
- <config.mdsal.configfile>01-mdsal.xml</config.mdsal.configfile>
+ <config.mdsal.configfile>01-md-sal.xml</config.mdsal.configfile>
<config.xsql.configfile>04-xsql.xml</config.xsql.configfile>
<config.netconf.client.configfile>01-netconf.xml</config.netconf.client.configfile>
<config.toaster.configfile>03-toaster-sample.xml</config.toaster.configfile>
package org.opendaylight.controller.config.util;
import javax.management.ObjectName;
-
import org.opendaylight.controller.config.api.jmx.ConfigRegistryMXBean;
public interface ConfigRegistryClient extends ConfigRegistryMXBean {
*/
package org.opendaylight.controller.config.util;
-import org.opendaylight.controller.config.api.ConflictingVersionException;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.api.jmx.ConfigRegistryMXBean;
-import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
import javax.management.JMException;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.ReflectionException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import org.opendaylight.controller.config.api.ConflictingVersionException;
+import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.api.jmx.ConfigRegistryMXBean;
+import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
import org.opendaylight.controller.config.api.jmx.ServiceReferenceMXBean;
public class ConfigRegistryJMXClient implements ConfigRegistryClient {
import javax.management.Attribute;
import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
-
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.CommitStatus;
import java.util.Map;
import java.util.Set;
-
import javax.management.Attribute;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.CommitStatus;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
+
import com.google.common.collect.Sets;
import java.lang.management.ManagementFactory;
import java.util.HashMap;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
+import com.google.common.collect.Sets;
import java.lang.management.ManagementFactory;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
-
import javax.management.Attribute;
import javax.management.MBeanException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.opendaylight.controller.config.api.ValidationException.ExceptionMessageWithStackTrace;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import com.google.common.collect.Sets;
-
public class ConfigTransactionClientsTest {
private final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
private TestingConfigTransactionController transactionController;
@Ignore
public void testAssertVersion() {
jmxTransactionClient.assertVersion((int)jmxTransactionClient.getParentVersion(),
- (int)jmxTransactionClient.getVersion());
+ (int)jmxTransactionClient.getVersion());
}
@Test(expected = NullPointerException.class)
*/
package org.opendaylight.controller.config.util;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
+import java.lang.management.ManagementFactory;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.api.jmx.ConfigTransactionControllerMXBean;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.Method;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
public class LookupTest {
private TestingConfigRegistry testingRegistry;
*/
package org.opendaylight.controller.config.util;
+import com.google.common.collect.Sets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
-
import org.opendaylight.controller.config.api.ConflictingVersionException;
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.ConfigRegistryMXBean;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import com.google.common.collect.Sets;
-
public class TestingConfigRegistry implements ConfigRegistryMXBean {
static final ObjectName conf1, conf2, conf3, run1, run2, run3;
*/
package org.opendaylight.controller.config.util;
+import com.google.common.collect.Sets;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
-
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.ConfigTransactionControllerMXBean;
import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import com.google.common.collect.Sets;
-
public class TestingConfigTransactionController implements
ConfigTransactionControllerMXBean {
import java.io.File;
import java.util.List;
-
import org.opendaylight.controller.logback.config.loader.impl.LogbackConfigUtil;
import org.opendaylight.controller.logback.config.loader.impl.LogbackConfigurationLoader;
import org.osgi.framework.BundleActivator;
* logback configurations
*/
private static final String LOGBACK_CONFIG_D = "logback.config.d";
- private static Logger LOG = LoggerFactory.getLogger(Activator.class);
+ private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
@Override
public void start(BundleContext context) {
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
package org.opendaylight.controller.logback.config.loader.impl;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.joran.JoranConfigurator;
+import ch.qos.logback.core.joran.spi.JoranException;
+import ch.qos.logback.core.util.StatusPrinter;
import java.io.File;
import java.net.URL;
-
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.joran.JoranConfigurator;
-import ch.qos.logback.core.joran.spi.JoranException;
-import ch.qos.logback.core.util.StatusPrinter;
-
/**
* Logback configuration loader.
* Strategy:
import java.io.File;
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/** logback config root */
private static final String LOGBACK_D = "/logback.d";
- private static Logger LOG = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(LogbackConfigurationLoaderTest.class);
/**
*/
package org.opendaylight.controller.logback.config.loader.test;
-import java.util.ArrayList;
-import java.util.List;
-
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.Context;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;
import ch.qos.logback.core.status.Status;
+import java.util.ArrayList;
+import java.util.List;
/**
* dummy appender for collecting log messages
*/
public class Debugger {
- private static Logger LOG = LoggerFactory.getLogger(Debugger.class);
+ private static final Logger LOG = LoggerFactory.getLogger(Debugger.class);
/**
* all logging
*/
public class Errorer {
- private static Logger LOG = LoggerFactory.getLogger(Errorer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(Errorer.class);
/**
* all logging
*/
public class Informer {
- private static Logger LOG = LoggerFactory.getLogger(Informer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(Informer.class);
/**
* all logging
*/
public class Tracer {
- private static Logger LOG = LoggerFactory.getLogger(Tracer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(Tracer.class);
/**
* all logging
*/
public class Warner {
- private static Logger LOG = LoggerFactory.getLogger(Warner.class);
+ private static final Logger LOG = LoggerFactory.getLogger(Warner.class);
/**
* all logging
package test.mock.util;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.util.ListenerRegistry;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
-@SuppressWarnings("deprecation")
public final class MockSchemaService implements SchemaService, SchemaContextProvider {
private SchemaContext schemaContext;
</schema-service>
</inmemory-operational-datastore-provider>
</module>
+
+ <!-- PingPong broker -->
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:pingpong">prefix:pingpong-data-broker</type>
+ <name>pingpong-data-broker</name>
+ <data-broker>
+ <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type>
+ <name>inmemory-data-broker</name>
+ </data-broker>
+ </module>
+ <module>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-forwarded-data-broker</type>
+ <name>pingpong-binding-data-broker</name>
+ <binding-forwarded-data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+ <dom-async-broker>
+ <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type>
+ <name>pingpong-broker</name>
+ </dom-async-broker>
+ <schema-service>
+ <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+ <name>yang-schema-service</name>
+ </schema-service>
+ <binding-mapping-service>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
+ <name>runtime-mapping-singleton</name>
+ </binding-mapping-service>
+ </binding-forwarded-data-broker>
+ </module>
+
<!--
Tree-based in-memory data store. This is the data store which is currently
recommended for single-node deployments.
<name>binding-data-broker</name>
<provider>/modules/module[type='binding-forwarded-data-broker'][name='binding-async-data-broker']</provider>
</instance>
+ <instance>
+ <name>pingpong-binding-data-broker</name>
+ <provider>/modules/module[type='binding-forwarded-data-broker'][name='pingpong-binding-data-broker']</provider>
+ </instance>
</service>
<service>
<name>inmemory-data-broker</name>
<provider>/modules/module[type='dom-inmemory-data-broker'][name='inmemory-data-broker']</provider>
</instance>
+ <instance>
+ <name>pingpong-broker</name>
+ <provider>/modules/module[type='pingpong-data-broker'][name='pingpong-data-broker']</provider>
+ </instance>
</service>
</services>
</data>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:pingpong?module=opendaylight-pingpong-broker&revision=2014-11-07</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store?module=opendaylight-config-dom-datastore&revision=2014-06-17</capability>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@SuppressWarnings("deprecation")
+@Deprecated
public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDataBroker implements DataProviderService, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(ForwardedBackwardsCompatibleDataBroker.class);
package org.opendaylight.controller.sal.binding.test.util;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.util.ListenerRegistry;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
-@SuppressWarnings("deprecation")
public final class MockSchemaService implements SchemaService, SchemaContextProvider {
private SchemaContext schemaContext;
org.opendaylight.controller.sal.dom.broker.osgi,
org.opendaylight.controller.sal.dom.broker.util,
org.opendaylight.controller.config.yang.md.sal.dom.impl,
+ org.opendaylight.controller.config.yang.md.sal.dom.pingpong,
org.opendaylight.controller.config.yang.md.sal.dom.statistics,\
org.opendaylight.controller.md.sal.dom.broker.impl,
org.opendaylight.controller.md.sal.dom.broker.impl.*,
org.opendaylight.yangtools.yang.util,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.dom.impl.rev131028.*</Private-Package>
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.dom.impl.rev131028.*,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.dom.pingpong.rev141107.*
+ </Private-Package>
<Import-Package>*</Import-Package>
</instructions>
</configuration>
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.yang.md.sal.dom.pingpong;
+
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.md.sal.dom.broker.impl.PingPongDataBroker;
+
+public class PingpongDataBrokerModule extends AbstractPingpongDataBrokerModule {
+ public PingpongDataBrokerModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public PingpongDataBrokerModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver, final PingpongDataBrokerModule oldModule, final java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ return new PingPongDataBroker(getDataBrokerDependency());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.yang.md.sal.dom.pingpong;
+
+public class PingpongDataBrokerModuleFactory extends AbstractPingpongDataBrokerModuleFactory {
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.sal.dom.broker.impl;
+
+import com.google.common.base.Preconditions;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.spi.ForwardingDOMDataBroker;
+
+/**
+ * An implementation of a {@link DOMDataBroker}, which forwards most requests to a delegate.
+ *
+ * Its interpretation of the API contract is somewhat looser, specifically it does not
+ * guarantee transaction ordering between transactions allocated directly from the broker
+ * and its transaction chains.
+ */
+public final class PingPongDataBroker extends ForwardingDOMDataBroker implements AutoCloseable {
+ private final DOMDataBroker delegate;
+
+ /**
+ * Instantiate a new broker, backed by the the specified delegate
+ * {@link DOMDataBroker}.
+ *
+ * @param delegate Backend broker, may not be null.
+ */
+ public PingPongDataBroker(final @Nonnull DOMDataBroker delegate) {
+ this.delegate = Preconditions.checkNotNull(delegate);
+ }
+
+ @Override
+ protected DOMDataBroker delegate() {
+ return delegate;
+ }
+
+ @Override
+ public PingPongTransactionChain createTransactionChain(final TransactionChainListener listener) {
+ return new PingPongTransactionChain(delegate, listener);
+ }
+
+ @Override
+ public void close() {
+ // TODO Auto-generated method stub
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.sal.dom.broker.impl;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.AbstractCheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+
+/**
+ * A {@link Future} used to report the status of an future {@link java.util.concurrent.Future}.
+ */
+final class PingPongFuture extends AbstractCheckedFuture<Void, TransactionCommitFailedException> {
+ protected PingPongFuture(final ListenableFuture<Void> delegate) {
+ super(delegate);
+ }
+
+ @Override
+ protected TransactionCommitFailedException mapException(final Exception e) {
+ Preconditions.checkArgument(e instanceof TransactionCommitFailedException);
+ return (TransactionCommitFailedException) e;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.sal.dom.broker.impl;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+/**
+ * Transaction context. Tracks the relationship with the backend transaction.
+ * We never leak this class to the user and have it implement the {@link FutureCallback}
+ * interface so we have a simple way of propagating the result.
+ */
+final class PingPongTransaction implements FutureCallback<Void> {
+ private final CheckedFuture<Void, TransactionCommitFailedException> submitFuture;
+ private final ListenableFuture<RpcResult<TransactionStatus>> commitFuture;
+ private final DOMDataReadWriteTransaction delegate;
+ private final SettableFuture<Void> future;
+ private DOMDataReadWriteTransaction frontendTransaction;
+
+ PingPongTransaction(final DOMDataReadWriteTransaction delegate) {
+ this.delegate = Preconditions.checkNotNull(delegate);
+ future = SettableFuture.create();
+ submitFuture = new PingPongFuture(future);
+ commitFuture = AbstractDataTransaction.convertToLegacyCommitFuture(submitFuture);
+ }
+
+ DOMDataReadWriteTransaction getTransaction() {
+ return delegate;
+ }
+
+ DOMDataReadWriteTransaction getFrontendTransaction() {
+ return frontendTransaction;
+ }
+
+ CheckedFuture<Void, TransactionCommitFailedException> getSubmitFuture() {
+ return submitFuture;
+ }
+
+ ListenableFuture<RpcResult<TransactionStatus>> getCommitFuture() {
+ return commitFuture;
+ }
+
+ @Override
+ public void onSuccess(final Void result) {
+ future.set(result);
+ }
+
+ @Override
+ public void onFailure(final Throwable t) {
+ future.setException(t);
+ }
+
+ void recordFrontendTransaction(final DOMDataReadWriteTransaction tx) {
+ if (frontendTransaction != null) {
+ frontendTransaction = tx;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return addToStringAttributes(Objects.toStringHelper(this)).toString();
+ }
+
+ protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+ return toStringHelper.add("delegate", delegate);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.md.sal.dom.broker.impl;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.concurrent.GuardedBy;
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.controller.md.sal.dom.spi.ForwardingDOMDataReadWriteTransaction;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An implementation of {@link DOMTransactionChain}, which has a very specific
+ * behavior, which some users may find surprising. If keeps the general
+ * intent of the contract, but it makes sure there are never more than two
+ * transactions allocated at any given time: one of them is being committed,
+ * and while that is happening, the other one acts as the scratch pad. Once
+ * the committing transaction completes successfully, the scratch transaction
+ * is enqueued as soon as it is ready.
+ *
+ * This mode of operation means that there is no inherent isolation between
+ * the front-end transactions and transactions cannot be reasonably cancelled.
+ *
+ * It furthermore means that the transactions returned by {@link #newReadOnlyTransaction()}
+ * counts as an outstanding transaction and the user may not allocate multiple
+ * read-only transactions at the same time.
+ */
+public final class PingPongTransactionChain implements DOMTransactionChain {
+ private static final Logger LOG = LoggerFactory.getLogger(PingPongTransactionChain.class);
+ private final DOMTransactionChain delegate;
+
+ @GuardedBy("this")
+ private PingPongTransaction bufferTransaction;
+ @GuardedBy("this")
+ private PingPongTransaction inflightTransaction;
+ @GuardedBy("this")
+ private boolean haveLocked;
+ @GuardedBy("this")
+ private boolean failed;
+
+ PingPongTransactionChain(final DOMDataBroker broker, final TransactionChainListener listener) {
+ this.delegate = broker.createTransactionChain(new TransactionChainListener() {
+ @Override
+ public void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction, final Throwable cause) {
+ LOG.debug("Delegate chain {} reported failure in {}", chain, transaction, cause);
+
+ final DOMDataReadWriteTransaction frontend;
+ if (inflightTransaction == null) {
+ LOG.warn("Transaction chain {} failed with no pending transactions", chain);
+ frontend = null;
+ } else {
+ frontend = inflightTransaction.getFrontendTransaction();
+ }
+
+ listener.onTransactionChainFailed(PingPongTransactionChain.this, frontend , cause);
+ delegateFailed();
+ }
+
+ @Override
+ public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
+ listener.onTransactionChainSuccessful(PingPongTransactionChain.this);
+ }
+ });
+ }
+
+ private synchronized void delegateFailed() {
+ failed = true;
+ if (!haveLocked) {
+ processBuffer();
+ }
+ }
+
+ private synchronized PingPongTransaction allocateTransaction() {
+ Preconditions.checkState(!haveLocked, "Attempted to start a transaction while a previous one is still outstanding");
+ Preconditions.checkState(!failed, "Attempted to use a failed chain");
+
+ if (bufferTransaction == null) {
+ bufferTransaction = new PingPongTransaction(delegate.newReadWriteTransaction());
+ }
+
+ haveLocked = true;
+ return bufferTransaction;
+ }
+
+ @GuardedBy("this")
+ private void processBuffer() {
+ final PingPongTransaction tx = bufferTransaction;
+
+ if (tx != null) {
+ if (failed) {
+ LOG.debug("Cancelling transaction {}", tx);
+ tx.getTransaction().cancel();
+ bufferTransaction = null;
+ return;
+ }
+
+ LOG.debug("Submitting transaction {}", tx);
+ final CheckedFuture<Void, ?> f = tx.getTransaction().submit();
+ bufferTransaction = null;
+ inflightTransaction = tx;
+
+ Futures.addCallback(f, new FutureCallback<Void>() {
+ @Override
+ public void onSuccess(final Void result) {
+ transactionSuccessful(tx, result);
+ }
+
+ @Override
+ public void onFailure(final Throwable t) {
+ transactionFailed(tx, t);
+ }
+ });
+ }
+ }
+
+ private void transactionSuccessful(final PingPongTransaction tx, final Void result) {
+ LOG.debug("Transaction {} completed successfully", tx);
+
+ synchronized (this) {
+ Preconditions.checkState(inflightTransaction == tx, "Successful transaction %s while %s was submitted", tx, inflightTransaction);
+ inflightTransaction = null;
+
+ if (!haveLocked) {
+ processBuffer();
+ }
+ }
+
+ // Can run unsynchronized
+ tx.onSuccess(result);
+ }
+
+ private void transactionFailed(final PingPongTransaction tx, final Throwable t) {
+ LOG.debug("Transaction {} failed", tx, t);
+
+ synchronized (this) {
+ Preconditions.checkState(inflightTransaction == tx, "Failed transaction %s while %s was submitted", tx, inflightTransaction);
+ inflightTransaction = null;
+ }
+
+ tx.onFailure(t);
+ }
+
+ private synchronized void readyTransaction(final PingPongTransaction tx) {
+ Preconditions.checkState(haveLocked, "Attempted to submit transaction while it is not outstanding");
+ Preconditions.checkState(bufferTransaction == tx, "Attempted to submit transaction %s while we have %s", tx, bufferTransaction);
+
+ haveLocked = false;
+ LOG.debug("Transaction {} unlocked", bufferTransaction);
+
+ if (inflightTransaction == null) {
+ processBuffer();
+ }
+ }
+
+ @Override
+ public synchronized void close() {
+ Preconditions.checkState(!haveLocked, "Attempted to close chain while a transaction is outstanding");
+ processBuffer();
+ delegate.close();
+ }
+
+ @Override
+ public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
+ final PingPongTransaction tx = allocateTransaction();
+
+ return new DOMDataReadOnlyTransaction() {
+ @Override
+ public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
+ final YangInstanceIdentifier path) {
+ return tx.getTransaction().read(store, path);
+ }
+
+ @Override
+ public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
+ final YangInstanceIdentifier path) {
+ return tx.getTransaction().exists(store, path);
+ }
+
+ @Override
+ public Object getIdentifier() {
+ return tx.getTransaction().getIdentifier();
+ }
+
+ @Override
+ public void close() {
+ readyTransaction(tx);
+ }
+ };
+ }
+
+ @Override
+ public DOMDataReadWriteTransaction newReadWriteTransaction() {
+ final PingPongTransaction tx = allocateTransaction();
+ final DOMDataReadWriteTransaction ret = new ForwardingDOMDataReadWriteTransaction() {
+ @Override
+ protected DOMDataReadWriteTransaction delegate() {
+ return tx.getTransaction();
+ }
+
+ @Override
+ public CheckedFuture<Void, TransactionCommitFailedException> submit() {
+ readyTransaction(tx);
+ return tx.getSubmitFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<TransactionStatus>> commit() {
+ readyTransaction(tx);
+ return tx.getCommitFuture();
+ }
+
+ @Override
+ public boolean cancel() {
+ throw new UnsupportedOperationException("Transaction cancellation is not supported");
+ }
+ };
+
+ tx.recordFrontendTransaction(ret);
+ return ret;
+ }
+
+ @Override
+ public DOMDataWriteTransaction newWriteOnlyTransaction() {
+ return newReadWriteTransaction();
+ }
+}
import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService;
import org.opendaylight.controller.sal.dom.broker.impl.NotificationRouterImpl;
import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker;
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
import org.opendaylight.controller.sal.dom.broker.spi.NotificationRouter;
import org.opendaylight.controller.sal.dom.broker.util.ProxySchemaContext;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
@Deprecated
public class BackwardsCompatibleMountPoint implements MountProvisionInstance, SchemaContextProvider, SchemaService {
package org.opendaylight.controller.sal.dom.broker;
import static com.google.common.base.Preconditions.checkState;
-
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
-
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
-
import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.util.ListenerRegistry;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
import org.opendaylight.yangtools.yang.parser.repo.URLSchemaContextResolver;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.opendaylight.controller.sal.core.api.notify.NotificationListener;
import org.opendaylight.controller.sal.dom.broker.impl.NotificationRouterImpl;
import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker;
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
import org.opendaylight.controller.sal.dom.broker.spi.NotificationRouter;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
@Deprecated
public class MountPointImpl implements MountProvisionInstance, SchemaContextProvider {
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
-
import com.google.common.base.Preconditions;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-
import org.opendaylight.controller.md.sal.common.api.routing.RouteChange;
import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
import org.opendaylight.controller.md.sal.common.impl.routing.RoutingUtils;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.yangtools.concepts.Delegator;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
public class SchemaContextProviders {
- public static final SchemaContextProvider fromSchemaService(SchemaService schemaService) {
+ public static final SchemaContextProvider fromSchemaService(final SchemaService schemaService) {
if (schemaService instanceof SchemaContextProvider) {
return (SchemaContextProvider) schemaService;
}
private final SchemaService service;
- public SchemaServiceAdapter(SchemaService service) {
+ public SchemaServiceAdapter(final SchemaService service) {
super();
this.service = service;
}
--- /dev/null
+module opendaylight-pingpong-broker {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:pingpong";
+ prefix "pingpong";
+
+ import config { prefix config; revision-date 2013-04-05; }
+ import opendaylight-md-sal-dom {prefix sal;}
+ import opendaylight-md-sal-common {prefix common;}
+ import opendaylight-config-dom-datastore {prefix config-dom-store-spi;}
+ import opendaylight-operational-dom-datastore {prefix operational-dom-store-spi;}
+
+ description
+ "Service definition for Ping-Pong DOM broker";
+
+ revision "2014-11-07" {
+ description
+ "Initial revision";
+ }
+
+ identity pingpong-data-broker {
+ base config:module-type;
+ config:provided-service sal:dom-async-data-broker;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case pingpong-data-broker {
+ when "/config:modules/config:module/config:type = 'pingpong-data-broker'";
+
+ container data-broker {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity sal:dom-async-data-broker;
+ }
+ }
+ }
+ }
+ }
+}
import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer;
import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction;
import org.opendaylight.controller.sal.core.api.data.DataProviderService;
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package test.mock.util;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.util.ListenerRegistry;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
-@SuppressWarnings("deprecation")
public final class MockSchemaService implements SchemaService, SchemaContextProvider {
private SchemaContext schemaContext;
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;
public static final String LOOPBACK_ADDRESS = "127.0.0.1";
public static final int SERVER_CONNECTION_TIMEOUT_MILLIS = 5000;
- static ModuleFactory[] FACTORIES = { new TestImplModuleFactory(),
- new DepTestImplModuleFactory(), new NetconfTestImplModuleFactory(),
- new IdentityTestModuleFactory(), new MultipleDependenciesModuleFactory() };
+ static ModuleFactory[] FACTORIES = {new TestImplModuleFactory(),
+ new DepTestImplModuleFactory(),
+ new NetconfTestImplModuleFactory(),
+ new IdentityTestModuleFactory(),
+ new MultipleDependenciesModuleFactory() };
private EventLoopGroup nettyThreadgroup;
private HashedWheelTimer hashedWheelTimer;
return TCP_ADDRESS;
}
- static SessionMonitoringService getNetconfMonitoringListenerService(final Logger logger, final NetconfMonitoringServiceImpl monitor) {
+ static SessionMonitoringService getNetconfMonitoringListenerService(final Logger LOG, final NetconfMonitoringServiceImpl monitor) {
return new SessionMonitoringService() {
@Override
public void onSessionUp(final NetconfManagementSession session) {
- logger.debug("Management session up {}", session);
+ LOG.debug("Management session up {}", session);
monitor.onSessionUp(session);
}
@Override
public void onSessionDown(final NetconfManagementSession session) {
- logger.debug("Management session down {}", session);
+ LOG.debug("Management session down {}", session);
monitor.onSessionDown(session);
}
};
*/
package org.opendaylight.controller.netconf.it;
+import com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
-
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
-import com.google.common.base.Preconditions;
-
public final class SSLUtil {
private SSLUtil() {}
package org.opendaylight.controller.netconf.mapping.api;
import com.google.common.base.Optional;
-
import java.util.List;
/**
public class Get extends AbstractNetconfOperation {
- private static final Logger logger = LoggerFactory.getLogger(Get.class);
+ private static final Logger LOG = LoggerFactory.getLogger(Get.class);
private final NetconfMonitoringService netconfMonitor;
public Get(final NetconfMonitoringService netconfMonitor) {
return innerResult;
} catch (final RuntimeException e) {
final String errorMessage = "Get operation for netconf-state subtree failed";
- logger.warn(errorMessage, e);
+ LOG.warn(errorMessage, e);
throw new NetconfDocumentedException(errorMessage, NetconfDocumentedException.ErrorType.application,
NetconfDocumentedException.ErrorTag.operation_failed,
public class NetconfMonitoringActivator implements BundleActivator {
- private static final Logger logger = LoggerFactory.getLogger(NetconfMonitoringActivator.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfMonitoringActivator.class);
private NetconfMonitoringServiceTracker monitor;
try {
monitor.close();
} catch (Exception e) {
- logger.warn("Ignoring exception while closing {}", monitor, e);
+ LOG.warn("Ignoring exception while closing {}", monitor, e);
}
}
}
public class NetconfMonitoringServiceTracker extends ServiceTracker<NetconfMonitoringService, NetconfMonitoringService> {
- private static final Logger logger = LoggerFactory.getLogger(NetconfMonitoringServiceTracker.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfMonitoringServiceTracker.class);
private ServiceRegistration<NetconfOperationServiceFactory> reg;
try {
reg.unregister();
} catch (final Exception e) {
- logger.warn("Ignoring exception while unregistering {}", reg, e);
+ LOG.warn("Ignoring exception while unregistering {}", reg, e);
}
}
}
*/
package org.opendaylight.controller.netconf.monitoring.xml;
-import org.opendaylight.controller.netconf.monitoring.xml.model.NetconfState;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.transform.dom.DOMResult;
+import org.opendaylight.controller.netconf.monitoring.xml.model.NetconfState;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
public class JaxBSerializer {
res = new DOMResult();
marshaller.marshal(monitoringModel, res);
} catch (final JAXBException e) {
- throw new RuntimeException("Unable to serialize netconf state " + monitoringModel, e);
+ throw new RuntimeException("Unable to serialize netconf state " + monitoringModel, e);
}
return ((Document)res.getNode()).getDocumentElement();
}
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.Collections2;
+import java.util.Collection;
import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.Yang;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
-
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlElement;
-import java.util.Collection;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.Yang;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
final class MonitoringSchema {
*/
package org.opendaylight.controller.netconf.monitoring.xml.model;
+import com.google.common.base.Joiner;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
-
-import com.google.common.base.Joiner;
import org.opendaylight.controller.netconf.monitoring.MonitoringConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.extension.rev131210.Session1;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
+import java.util.Collection;
+import javax.annotation.Nullable;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
import org.opendaylight.controller.netconf.monitoring.MonitoringConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Schemas;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
-import javax.annotation.Nullable;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlRootElement;
-import java.util.Collection;
-
@XmlRootElement(name = MonitoringConstants.NETCONF_MONITORING_XML_ROOT_ELEMENT)
public final class NetconfState {
)
package org.opendaylight.controller.netconf.monitoring.xml.model;
-import org.opendaylight.controller.netconf.monitoring.MonitoringConstants;
-
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
-import javax.xml.bind.annotation.XmlSchema;
\ No newline at end of file
+import javax.xml.bind.annotation.XmlSchema;
+import org.opendaylight.controller.netconf.monitoring.MonitoringConstants;
\ No newline at end of file
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
package org.opendaylight.controller.netconf.monitoring.osgi;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+
import com.google.common.base.Optional;
import org.junit.Test;
import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
import org.opendaylight.controller.netconf.monitoring.MonitoringConstants;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-
public class NetconfMonitoringOperationServiceTest {
@Test
public void testGetters() throws Exception {
package org.opendaylight.controller.netconf.monitoring.osgi;
import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
+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.Hashtable;
import org.junit.Before;
import org.junit.Test;