osgi.noShutdown=true
# Clean any cached data on restart of the framework
osgi.clean=true
+
+# https://bugs.eclipse.org/bugs/show_bug.cgi?id=325578
# Extend the framework to avoid the resources to be presented with
# a URL of type bundleresource: but to be presented as file:
osgi.hook.configurators.include=org.eclipse.virgo.kernel.equinox.extensions.hooks.ExtensionsHookConfigurator
+
# Directory from where the fileinstall will monitor for new bundles
felix.fileinstall.dir=./plugins
# Immediately learn new bundles at startup
SET debugport=8000
SET consoleport=2400
SET jmxport=1088
+SET jvmMaxMemory=
SET extraJVMOpts=
SET consoleOpts=-console -consoleLog
SET PID=
)
GOTO :EOF
)
+ IF "!CARG:~0,4!"=="-Xmx" (
+ SET jvmMaxMemory=!CARG!
+ SHIFT
+ GOTO :LOOP
+ )
IF "!CARG:~0,2!"=="-D" (
SET extraJVMOpts=%extraJVMOpts% !CARG!
SHIFT
REM ECHO "DEBUG enabled suspended"
SET extraJVMOpts=%extraJVMOpts% -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%debugport%
)
+
+IF "%jvmMaxMemory%"=="" (
+ SET jvmMaxMemory=-Xmx1G
+ ECHO *****************************************************************
+ ECHO JVM maximum memory was not defined. Setting maximum memory to 1G.
+ ECHO To define the maximum memory, specify the -Xmx setting on the
+ ECHO command line.
+ ECHO e.g. run.bat -Xmx1G
+ ECHO *****************************************************************"
+)
+
+SET extraJVMOpts=%extraJVMOpts% %jvmMaxMemory%
+
IF "%jmxEnabled%" NEQ "" (
REM ECHO "JMX enabled "
SET extraJVMOpts=%extraJVMOpts% -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=%jmxport% -Dcom.sun.management.jmxremote
statusdaemon=0
consolestart=1
dohelp=0
+jvmMaxMemory=""
extraJVMOpts=""
agentPath=""
unknown_option=0
-status) statusdaemon=1; shift ;;
-console) shift ;;
-help) dohelp=1; shift;;
+ -Xmx*) jvmMaxMemory="$1"; shift;;
-D*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
-X*) extraJVMOpts="${extraJVMOpts} $1"; shift;;
-agentpath:*) agentPath="$1"; shift;;
usage
fi
+if [ "${jvmMaxMemory}"=="" ]; then
+ jvmMaxMemory="-Xmx1G"
+ echo "*****************************************************************"
+ echo "JVM maximum memory was not defined. Setting maximum memory to 1G."
+ echo "To define the maximum memory, specify the -Xmx setting on the"
+ echo "command line. "
+ echo " e.g. ./run.sh -Xmx1G"
+ echo "*****************************************************************"
+fi
+
+extraJVMOpts="${extraJVMOpts} ${jvmMaxMemory}"
+
# Validate debug port
if [[ "${debugport}" -lt 1024 ]] || [[ "${debugport}" -gt 65535 ]]; then
echo "Debug Port not in the range [1024,65535] ${debugport}"
* 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.sal.binding.impl;\r
-\r
+package org.opendaylight.controller.sal.binding.impl;
+
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
+import org.opendaylight.controller.md.sal.common.api.data.DataReader;
+import org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter;
import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataBroker;
import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.controller.sal.binding.impl.util.BindingAwareDataReaderRouter;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.util.DataObjectReadingUtil;
import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Maps;
-\r
-\r
-public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier<? extends DataObject>, DataObject, DataChangeListener> //\r
- implements DataProviderService, AutoCloseable {\r
-\r
+
+public class DataBrokerImpl extends
+ AbstractDataBroker<InstanceIdentifier<? extends DataObject>, DataObject, DataChangeListener> //
+ implements DataProviderService, AutoCloseable {
+
private final static class ContainsWildcarded implements Predicate<InstanceIdentifier<? extends DataObject>> {
- private final InstanceIdentifier<? extends DataObject> key;
+ private final InstanceIdentifier<? extends DataObject> key;
- public ContainsWildcarded(InstanceIdentifier<? extends DataObject> key) {
+ public ContainsWildcarded(final InstanceIdentifier<? extends DataObject> key) {
this.key = key;
}
@Override
- public boolean apply(InstanceIdentifier<? extends DataObject> input) {
+ public boolean apply(final InstanceIdentifier<? extends DataObject> input) {
return key.containsWildcarded(input);
}
}
private final static class IsContainedWildcarded implements Predicate<InstanceIdentifier<? extends DataObject>> {
- private final InstanceIdentifier<? extends DataObject> key;
+ private final InstanceIdentifier<? extends DataObject> key;
- public IsContainedWildcarded(InstanceIdentifier<? extends DataObject> key) {
+ public IsContainedWildcarded(final InstanceIdentifier<? extends DataObject> key) {
this.key = key;
}
@Override
- public boolean apply(InstanceIdentifier<? extends DataObject> input) {
+ public boolean apply(final InstanceIdentifier<? extends DataObject> input) {
return input.containsWildcarded(key);
}
}
- private final AtomicLong nextTransaction = new AtomicLong();\r
- private final AtomicLong createdTransactionsCount = new AtomicLong();\r
-\r
- public AtomicLong getCreatedTransactionsCount() {\r
- return createdTransactionsCount;\r
- }\r
-\r
- public DataBrokerImpl() {\r
- setDataReadRouter(new BindingAwareDataReaderRouter());\r
- }\r
-\r
- @Override\r
- public DataTransactionImpl beginTransaction() {\r
- String transactionId = "BA-" + nextTransaction.getAndIncrement();\r
- createdTransactionsCount.getAndIncrement();\r
- return new DataTransactionImpl(transactionId,this);\r
- }\r
-\r
- @Override\r
- public void close() {\r
-\r
+ private final AtomicLong nextTransaction = new AtomicLong();
+ private final AtomicLong createdTransactionsCount = new AtomicLong();
+ private final DelegatingDataReadRouter router = new DelegatingDataReadRouter();
+ private DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> rootCommitHandler;
+
+ public DataBrokerImpl() {
+ setDataReadRouter(router);
+ }
+
+ public void setDataReadDelegate(final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate) {
+ router.setDelegate(delegate);
+ }
+
+ public AtomicLong getCreatedTransactionsCount() {
+ return createdTransactionsCount;
+ }
+
+ @Override
+ public DataTransactionImpl beginTransaction() {
+ String transactionId = "BA-" + nextTransaction.getAndIncrement();
+ createdTransactionsCount.getAndIncrement();
+ return new DataTransactionImpl(transactionId, this);
}
@Override
- protected Predicate<InstanceIdentifier<? extends DataObject>> createContainsPredicate(final
- InstanceIdentifier<? extends DataObject> key) {
+ public void close() {
+
+ }
+
+ @Override
+ protected Predicate<InstanceIdentifier<? extends DataObject>> createContainsPredicate(
+ final InstanceIdentifier<? extends DataObject> key) {
return new ContainsWildcarded(key);
}
@Override
- protected Predicate<InstanceIdentifier<? extends DataObject>> createIsContainedPredicate(final
- InstanceIdentifier<? extends DataObject> key) {
+ protected Predicate<InstanceIdentifier<? extends DataObject>> createIsContainedPredicate(
+ final InstanceIdentifier<? extends DataObject> key) {
return new IsContainedWildcarded(key);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected Map<InstanceIdentifier<? extends DataObject>, DataObject> deepGetBySubpath(
- Map<InstanceIdentifier<? extends DataObject>, DataObject> dataSet,
- InstanceIdentifier<? extends DataObject> path) {
+ final Map<InstanceIdentifier<? extends DataObject>, DataObject> dataSet,
+ final InstanceIdentifier<? extends DataObject> path) {
Builder<InstanceIdentifier<? extends DataObject>, DataObject> builder = ImmutableMap.builder();
- Map<InstanceIdentifier<? extends DataObject>, DataObject> potential = Maps.filterKeys(dataSet, createIsContainedPredicate(path));
- for(Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry : potential.entrySet()) {
+ Map<InstanceIdentifier<? extends DataObject>, DataObject> potential = Maps.filterKeys(dataSet,
+ createIsContainedPredicate(path));
+ for (Entry<InstanceIdentifier<? extends DataObject>, DataObject> entry : potential.entrySet()) {
try {
- builder.putAll(DataObjectReadingUtil.readData(entry.getValue(),(InstanceIdentifier)entry.getKey(),path));
+ builder.putAll(DataObjectReadingUtil.readData(entry.getValue(), (InstanceIdentifier) entry.getKey(),
+ path));
} catch (Exception e) {
// FIXME : Log exception;
}
return builder.build();
}
-\r
+
+ public class DelegatingDataReadRouter extends
+ AbstractDataReadRouter<InstanceIdentifier<? extends DataObject>, DataObject> {
+
+ private DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate;
+
+ @Override
+ public DataObject readConfigurationData(final InstanceIdentifier<? extends DataObject> path) {
+ return delegate.readConfigurationData(path);
+ }
+
+ public void setDelegate(final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public DataObject readOperationalData(final InstanceIdentifier<? extends DataObject> path) {
+ return delegate.readOperationalData(path);
+ }
+
+ @Override
+ protected DataObject merge(final InstanceIdentifier<? extends DataObject> path, final Iterable<DataObject> data) {
+ throw new UnsupportedOperationException("Not supported");
+ }
+
+ @Override
+ public Registration<DataReader<InstanceIdentifier<? extends DataObject>, DataObject>> registerConfigurationReader(
+ final InstanceIdentifier<? extends DataObject> path,
+ final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> reader) {
+ throw new UnsupportedOperationException("Not supported");
+ }
+
+ @Override
+ public Registration<DataReader<InstanceIdentifier<? extends DataObject>, DataObject>> registerOperationalReader(
+ final InstanceIdentifier<? extends DataObject> path,
+ final DataReader<InstanceIdentifier<? extends DataObject>, DataObject> reader) {
+ throw new UnsupportedOperationException("Not supported");
+ }
+ }
+
+ @Override
+ protected ImmutableList<DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject>> affectedCommitHandlers(
+ final Set<InstanceIdentifier<? extends DataObject>> paths) {
+ ImmutableList.Builder<DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject>> handlersBuilder = ImmutableList.builder();
+ return handlersBuilder //
+ .add(rootCommitHandler) //
+ .addAll(super.affectedCommitHandlers(paths)) //
+ .build();
+ }
+
+ public void setRootCommitHandler(final DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> commitHandler) {
+ rootCommitHandler = commitHandler;
+ }
+
}
super(rpcRegistry, notificationBroker, dataBroker);
this.identifier = identifier;
}
+
+ // Needed only for BI Connector
+ public DataBrokerImpl getDataBrokerImpl() {
+ return (DataBrokerImpl) getDataBroker();
+ }
@Override
public InstanceIdentifier<?> getIdentifier() {
import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration;
import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.controller.md.sal.common.api.data.DataReader;
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.api.routing.RouteChangePublisher;
import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider;
import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
+import org.opendaylight.controller.sal.binding.impl.DataBrokerImpl;
+import org.opendaylight.controller.sal.binding.impl.MountPointManagerImpl.BindingMountPointImpl;
import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;
import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl.GlobalRpcRegistrationListener;
import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl.RouterInstantiationListener;
private final Logger LOG = LoggerFactory.getLogger(BindingIndependentConnector.class);
- @SuppressWarnings("deprecation")
- private static final InstanceIdentifier<? extends DataObject> ROOT = InstanceIdentifier.builder().toInstance();
private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier ROOT_BI = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
.builder().toInstance();
};
- private Registration<DataReader<InstanceIdentifier<? extends DataObject>, DataObject>> baDataReaderRegistration;
-
private boolean rpcForwarding = false;
private boolean dataForwarding = false;
dataForwarding = true;
return;
}
- checkState(!dataForwarding, "Connector is already forwarding data.");
- baDataReaderRegistration = baDataService.registerDataReader(ROOT, this);
- baCommitHandlerRegistration = baDataService.registerCommitHandler(ROOT, bindingToDomCommitHandler);
- biCommitHandlerRegistration = biDataService.registerCommitHandler(ROOT_BI, domToBindingCommitHandler);
- baDataService.registerCommitHandlerListener(domToBindingCommitHandler);
+
+ final DataProviderService baData;
+ if (baDataService instanceof BindingMountPointImpl) {
+ baData = ((BindingMountPointImpl)baDataService).getDataBrokerImpl();
+ LOG.debug("Extracted BA Data provider {} from mount point {}", baData, baDataService);
+ } else {
+ baData = baDataService;
+ }
+
+ if (baData instanceof DataBrokerImpl) {
+ checkState(!dataForwarding, "Connector is already forwarding data.");
+ ((DataBrokerImpl) baData).setDataReadDelegate(this);
+ ((DataBrokerImpl) baData).setRootCommitHandler(bindingToDomCommitHandler);
+ biCommitHandlerRegistration = biDataService.registerCommitHandler(ROOT_BI, domToBindingCommitHandler);
+ baDataService.registerCommitHandlerListener(domToBindingCommitHandler);
+ }
+
dataForwarding = true;
}
import static com.google.common.base.Preconditions.checkState;
import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.opendaylight.controller.md.sal.dom.store.impl.tree.NodeModification;
import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreMetadataNode;
import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+/*
+ * FIXME: the thread safety of concurrent write/delete/read/seal operations
+ * needs to be evaluated.
+ */
class MutableDataTree {
-
- private static final Logger log = LoggerFactory.getLogger(MutableDataTree.class);
-
- final DataAndMetadataSnapshot snapshot;
- final NodeModification rootModification;
- final ModificationApplyOperation strategyTree;
-
- private boolean sealed = false;
+ private static final Logger LOG = LoggerFactory.getLogger(MutableDataTree.class);
+ private final AtomicBoolean sealed = new AtomicBoolean();
+ private final ModificationApplyOperation strategyTree;
+ private final DataAndMetadataSnapshot snapshot;
+ private final NodeModification rootModification;
private MutableDataTree(final DataAndMetadataSnapshot snapshot, final ModificationApplyOperation strategyTree) {
this.snapshot = snapshot;
return NormalizedNodeUtils.findNode(modification.getKey(), data, path);
}
return Optional.absent();
-
}
private Optional<StoreMetadataNode> resolveSnapshot(
return resolveModificationStrategy(path).apply(modification, modification.getOriginal(),
StoreUtils.increase(snapshot.getMetadataTree().getSubtreeVersion()));
} catch (Exception e) {
- log.error("Could not create snapshot for {}", path,e);
+ LOG.error("Could not create snapshot for {}", path,e);
throw e;
}
}
private ModificationApplyOperation resolveModificationStrategy(final InstanceIdentifier path) {
- log.trace("Resolving modification apply strategy for {}", path);
+ LOG.trace("Resolving modification apply strategy for {}", path);
return TreeNodeUtils.findNodeChecked(strategyTree, path);
}
}
public void seal() {
- sealed = true;
+ final boolean success = sealed.compareAndSet(false, true);
+ Preconditions.checkState(success, "Attempted to seal an already-sealed Data Tree.");
rootModification.seal();
}
private void checkSealed() {
- checkState(!sealed, "Data Tree is sealed. No further modifications allowed.");
+ checkState(!sealed.get(), "Data Tree is sealed. No further modifications allowed.");
}
protected NodeModification getRootModification() {
public String toString() {
return "MutableDataTree [modification=" + rootModification + "]";
}
-
-
}
public final class StoreUtils {
private final static Function<Identifiable<Object>, Object> EXTRACT_IDENTIFIER = new Function<Identifiable<Object>, Object>() {
-
@Override
public Object apply(final Identifiable<Object> input) {
return input.getIdentifier();
return new InitialDataChangeEvent(path, data.getData());
}
+ /*
+ * Suppressing warnings here allows us to fool the compiler enough
+ * such that we can reuse a single function for all applicable types
+ * and present it in a type-safe manner to our users.
+ */
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <V> Function<Identifiable<V>, V> identifierExtractor() {
return (Function) EXTRACT_IDENTIFIER;
public NormalizedNode<?, ?> getUpdatedSubtree() {
return data;
}
-
}
public static <V> Set<V> toIdentifierSet(final Iterable<? extends Identifiable<V>> children) {
StringBuilder builder = new StringBuilder();
toStringTree(builder, metaNode, 0);
return builder.toString();
-
}
private static void toStringTree(final StringBuilder builder, final StoreMetadataNode metaNode, final int offset) {
builder.append(prefix).append(toStringTree(metaNode.getIdentifier()));
NormalizedNode<?, ?> dataNode = metaNode.getData();
if (dataNode instanceof NormalizedNodeContainer<?, ?, ?>) {
- builder.append(" {").append("\n");
+ builder.append(" {\n");
for (StoreMetadataNode child : metaNode.getChildren()) {
toStringTree(builder, child, offset + 4);
}
- builder.append(prefix).append("}");
+ builder.append(prefix).append('}');
} else {
- builder.append(" ").append(dataNode.getValue());
+ builder.append(' ').append(dataNode.getValue());
}
- builder.append("\n");
+ builder.append('\n');
}
private static String toStringTree(final PathArgument identifier) {
import java.util.LinkedHashMap;
import java.util.Map;
+import javax.annotation.concurrent.GuardedBy;
+
import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
private final Map<PathArgument, NodeModification> childModification;
+ @GuardedBy("this")
private boolean sealed = false;
protected NodeModification(final PathArgument identifier, final Optional<StoreMetadataNode> original) {
this.value = value;
}
+ @GuardedBy("this")
private void checkSealed() {
checkState(!sealed, "Node Modification is sealed. No further changes allowed.");
}
return !childModification.isEmpty();
}
- public void updateModificationType(final ModificationType type) {
+ @GuardedBy("this")
+ private void updateModificationType(final ModificationType type) {
modificationType = type;
clearSnapshot();
}
public static <T extends StoreTreeNode<T>> T findNodeChecked(final T tree, final InstanceIdentifier path) {
T current = tree;
- List<PathArgument> nested = new ArrayList<>(path.getPath());
+ List<PathArgument> nested = new ArrayList<>(path.getPath().size());
for(PathArgument pathArg : path.getPath()) {
Optional<T> potential = current.getChild(pathArg);
nested.add(pathArg);
final InstanceIdentifier currentPath = new InstanceIdentifier(path.getPath().subList(0, nesting));
return new SimpleEntry<InstanceIdentifier,T>(currentPath,current.get());
}
- // Nesting minus one is safe, since current is allways present when nesting = 0
- // so this prat of code is never triggered, in cases nesting == 0;
+
+ /*
+ * Subtracting 1 from nesting level at this point is safe, because we
+ * cannot reach here with nesting == 0: that would mean the above check
+ * for current.isPresent() failed, which it cannot, as current is always
+ * present. At any rate we check state just to be on the safe side.
+ */
+ Preconditions.checkState(nesting > 0);
final InstanceIdentifier parentPath = new InstanceIdentifier(path.getPath().subList(0, nesting - 1));
- return new SimpleEntry<InstanceIdentifier,T>(parentPath,parent.get());
+ return new SimpleEntry<InstanceIdentifier,T>(parentPath,parent.get());
}
public static <T extends StoreTreeNode<T>> Optional<T> getChild(final Optional<T> parent,final PathArgument child) {
<http pattern="/css/**" security="none" />
<http pattern="/js/**" security="none" />
- <http pattern="/images/**" security="none" />
+ <http pattern="/img/**" security="none" />
<http pattern="/favicon.ico" security="none" />
<http pattern="/controller/web/css/**" security="none" />
<http pattern="/controller/web/js/**" security="none" />
- <http pattern="/controller/web/images/**" security="none" />
+ <http pattern="/controller/web/img/**" security="none" />
<http auto-config="false" authentication-manager-ref="authenticationManager"
<web-resource-collection>
<web-resource-name>free access</web-resource-name>
<url-pattern>/js/*</url-pattern>
- <url-pattern>/images/*</url-pattern>
+ <url-pattern>/img/*</url-pattern>
<url-pattern>/css/*</url-pattern>
<url-pattern>/favicon.ico</url-pattern>
<url-pattern>/versionProperty/*</url-pattern>