<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-common-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
</dependencies>
<packaging>bundle</packaging>
+/*
+ * Copyright (c) 2013 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.sal.common.util;
public class Arguments {
--- /dev/null
+package org.opendaylight.controller.sal.common.util;
+
+import java.util.Collections;
+
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
+import org.opendaylight.yangtools.concepts.Path;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+public class CommitHandlerTransactions {
+
+ private static class AllwaysSuccessfulTransaction<P extends Path<P>,D> implements DataCommitTransaction<P, D> {
+
+ private final DataModification<P, D> modification;
+
+ public AllwaysSuccessfulTransaction(DataModification<P, D> modification) {
+ this.modification = modification;
+ }
+ @Override
+ public RpcResult<Void> rollback() throws IllegalStateException {
+ return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
+ }
+ @Override
+ public RpcResult<Void> finish() throws IllegalStateException {
+ return Rpcs.<Void>getRpcResult(true, null, Collections.<RpcError>emptyList());
+ }
+
+ @Override
+ public DataModification<P, D> getModification() {
+ return modification;
+ }
+ }
+
+ public static final <P extends Path<P>,D> AllwaysSuccessfulTransaction<P, D> allwaysSuccessfulTransaction(DataModification<P, D> modification) {
+ return new AllwaysSuccessfulTransaction<>(modification);
+ }
+}
+/*
+ * Copyright (c) 2013 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.sal.common.util;
import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration;
import org.opendaylight.yangtools.yang.common.QName;
-public interface RpcProvisionRegistry {
+public interface RpcProvisionRegistry extends BrokerService {
/**
* Registers an implementation of the rpc.
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.controller.sal.core.api.mount;
import java.util.concurrent.Future;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-public interface MountInstance extends NotificationService, DataBrokerService {
+public interface MountInstance extends //
+ NotificationService, //
+ DataBrokerService {
Future<RpcResult<CompositeNode>> rpc(QName type, CompositeNode input);
-
+
SchemaContext getSchemaContext();
}
package org.opendaylight.controller.sal.core.api.mount;
+import java.util.EventListener;
+
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
public interface MountProvisionService extends MountService {
MountProvisionInstance createMountPoint(InstanceIdentifier path);
MountProvisionInstance createOrGetMountPoint(InstanceIdentifier path);
+
+ ListenerRegistration<MountProvisionListener> registerProvisionListener(MountProvisionListener listener);
+
+ public interface MountProvisionListener extends EventListener {
+
+ void onMountPointCreated(InstanceIdentifier path);
+
+ void onMountPointRemoved(InstanceIdentifier path);
+
+ }
}
--- /dev/null
+package org.opendaylight.controller.sal.dom.broker;
+
+public class $ModuleInfo {
+
+
+}
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import com.google.common.util.concurrent.MoreExecutors;
+
public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier, CompositeNode, DataChangeListener> implements
DataProviderService, AutoCloseable {
public DataBrokerImpl() {
setDataReadRouter(new DataReaderRouter());
+ setExecutor(MoreExecutors.sameThreadExecutor());
}
public AtomicLong getCreatedTransactionsCount() {
public class MountPointImpl implements MountProvisionInstance {
private final RpcRouter rpcs;
- private final DataReaderRouter dataReader;
+ private final DataBrokerImpl dataReader;
private final NotificationRouter notificationRouter;
private final DataReader<InstanceIdentifier,CompositeNode> readWrapper;
public MountPointImpl(InstanceIdentifier path) {
this.mountPath = path;
rpcs = new RpcRouterImpl("");
- dataReader = new DataReaderRouter();
+ dataReader = new DataBrokerImpl();
notificationRouter = new NotificationRouterImpl();
readWrapper = new ReadWrapper();
}
@Override
public DataModificationTransaction beginTransaction() {
- // TODO Auto-generated method stub
- return null;
+ return dataReader.beginTransaction();
}
@Override
public ListenerRegistration<DataChangeListener> registerDataChangeListener(InstanceIdentifier path,
DataChangeListener listener) {
- // TODO Auto-generated method stub
- return null;
+ return dataReader.registerDataChangeListener(path, listener);
}
@Override
@Override
public Registration<DataCommitHandler<InstanceIdentifier, CompositeNode>> registerCommitHandler(
InstanceIdentifier path, DataCommitHandler<InstanceIdentifier, CompositeNode> commitHandler) {
- // TODO Auto-generated method stub
- return null;
+ return dataReader.registerCommitHandler(path, commitHandler);
}
@Override
@Override
public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier, CompositeNode>>> registerCommitHandlerListener(
RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier, CompositeNode>> commitHandlerListener) {
- // TODO Auto-generated method stub
- return null;
+ return dataReader.registerCommitHandlerListener(commitHandlerListener);
}
}
import java.util.concurrent.ConcurrentHashMap
import static com.google.common.base.Preconditions.*;
import org.opendaylight.controller.sal.core.api.data.DataProviderService
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionService.MountProvisionListener
+import org.opendaylight.yangtools.concepts.util.ListenerRegistry
class MountPointManagerImpl implements MountProvisionService {
@Property
DataProviderService dataBroker;
+ val ListenerRegistry<MountProvisionListener> listeners = ListenerRegistry.create()
+
ConcurrentMap<InstanceIdentifier,MountPointImpl> mounts = new ConcurrentHashMap();
override createMountPoint(InstanceIdentifier path) {
val mount = new MountPointImpl(path);
registerMountPoint(mount);
mounts.put(path,mount);
+ notifyMountCreated(path);
return mount;
}
+ def notifyMountCreated(InstanceIdentifier identifier) {
+ for(listener : listeners) {
+ listener.instance.onMountPointCreated(identifier);
+ }
+ }
+
def registerMountPoint(MountPointImpl impl) {
dataBroker?.registerConfigurationReader(impl.mountPath,impl.readWrapper);
dataBroker?.registerOperationalReader(impl.mountPath,impl.readWrapper);
}
+ override registerProvisionListener(MountProvisionListener listener) {
+ listeners.register(listener)
+ }
+
override createOrGetMountPoint(InstanceIdentifier path) {
val mount = mounts.get(path);
import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
import org.osgi.framework.ServiceReference;
public MountProvisionInstance createOrGetMountPoint(InstanceIdentifier path) {
return getDelegate().createOrGetMountPoint(path);
}
+
+ @Override
+ public ListenerRegistration<MountProvisionListener> registerProvisionListener(MountProvisionListener listener) {
+ return getDelegate().registerProvisionListener(listener);
+ }
}