return new Function<DataReader<P, D>, D>() {
@Override
public D apply(DataReader<P, D> input) {
- return input.readConfigurationData(path);
+ return input.readOperationalData(path);
}
};
}
package org.opendaylight.controller.sal.core.api.mount;
import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
+import org.opendaylight.controller.sal.core.api.data.DataProviderService;
import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService;
-public interface MountProvisionInstance extends MountInstance, NotificationPublishService, RpcProvisionRegistry {
+public interface MountProvisionInstance extends //
+ MountInstance,//
+ NotificationPublishService, //
+ RpcProvisionRegistry,//
+ DataProviderService {
}
*/
package org.opendaylight.controller.sal.core.api.mount;
+import org.opendaylight.controller.sal.core.api.BrokerService;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-public interface MountService {
+public interface MountService extends BrokerService {
MountInstance getMountPoint(InstanceIdentifier path);
}
import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
import org.opendaylight.controller.sal.core.api.data.DataProviderService;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
+import org.opendaylight.controller.sal.core.api.mount.MountService;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
private ServiceRegistration<DataProviderService> dataProviderReg;
private SchemaServiceImpl schemaService;
private DataBrokerImpl dataService;
+ private MountPointManagerImpl mountService;
+ private ServiceRegistration<MountService> mountReg;
+ private ServiceRegistration<MountProvisionService> mountProviderReg;
@Override
public void start(BundleContext context) throws Exception {
dataReg = context.registerService(DataBrokerService.class, dataService, emptyProperties);
dataProviderReg = context.registerService(DataProviderService.class, dataService, emptyProperties);
+ mountService = new MountPointManagerImpl();
+ mountService.setDataBroker(dataService);
+ mountReg = context.registerService(MountService.class, mountService, emptyProperties);
+ mountProviderReg = context.registerService(MountProvisionService.class, mountService, emptyProperties);
}
@Override
package org.opendaylight.controller.sal.dom.broker;
+import java.util.List;
import java.util.Set;
import java.util.concurrent.Future;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
import org.opendaylight.controller.md.sal.common.api.data.DataReader;
+import org.opendaylight.controller.sal.common.DataStoreIdentifier;
import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.core.api.RpcImplementation;
import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration;
import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
import org.opendaylight.controller.sal.core.api.data.DataChangeListener;
import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction;
+import org.opendaylight.controller.sal.core.api.data.DataValidator;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
import org.opendaylight.controller.sal.core.api.notify.NotificationListener;
import org.opendaylight.controller.sal.dom.broker.impl.DataReaderRouter;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdentifierBuilder;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
public class MountPointImpl implements MountProvisionInstance {
- final RpcRouter rpcs;
- final DataReaderRouter dataReader;
- final NotificationRouter notificationRouter;
+ private final RpcRouter rpcs;
+ private final DataReaderRouter dataReader;
+ private final NotificationRouter notificationRouter;
+ private final DataReader<InstanceIdentifier,CompositeNode> readWrapper;
+
+
+ private final InstanceIdentifier mountPath;
public MountPointImpl(InstanceIdentifier path) {
+ this.mountPath = path;
rpcs = new RpcRouterImpl("");
dataReader = new DataReaderRouter();
notificationRouter = new NotificationRouterImpl();
+ readWrapper = new ReadWrapper();
+ }
+
+ public InstanceIdentifier getMountPath() {
+ return mountPath;
+ }
+
+ public DataReader<InstanceIdentifier, CompositeNode> getReadWrapper() {
+ return readWrapper;
}
@Override
@Override
public void sendNotification(CompositeNode notification) {
publish(notification);
+ }
+
+ @Override
+ public Registration<DataCommitHandler<InstanceIdentifier, CompositeNode>> registerCommitHandler(
+ InstanceIdentifier path, DataCommitHandler<InstanceIdentifier, CompositeNode> commitHandler) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void removeRefresher(DataStoreIdentifier store, DataRefresher refresher) {
+ // NOOP
+ }
+
+ @Override
+ public void addRefresher(DataStoreIdentifier store, DataRefresher refresher) {
+ // NOOP
+ }
+
+ @Override
+ public void addValidator(DataStoreIdentifier store, DataValidator validator) {
+ // NOOP
+ }
+ @Override
+ public void removeValidator(DataStoreIdentifier store, DataValidator validator) {
+ // NOOP
+ }
+
+ class ReadWrapper implements DataReader<InstanceIdentifier, CompositeNode> {
+
+
+ private InstanceIdentifier shortenPath(InstanceIdentifier path) {
+ InstanceIdentifier ret = null;
+ if(mountPath.contains(path)) {
+ List<PathArgument> newArgs = path.getPath().subList(mountPath.getPath().size(), path.getPath().size());
+ ret = new InstanceIdentifier(newArgs);
+ }
+ return ret;
+ }
+
+ @Override
+ public CompositeNode readConfigurationData(InstanceIdentifier path) {
+ InstanceIdentifier newPath = shortenPath(path);
+ if(newPath == null) {
+ return null;
+ }
+ return MountPointImpl.this.readConfigurationData(newPath);
+ }
+ @Override
+ public CompositeNode readOperationalData(InstanceIdentifier path) {
+ InstanceIdentifier newPath = shortenPath(path);
+ if(newPath == null) {
+ return null;
+ }
+ return MountPointImpl.this.readOperationalData(newPath);
+ }
}
}
import java.util.concurrent.ConcurrentMap
import java.util.concurrent.ConcurrentHashMap
import static com.google.common.base.Preconditions.*;
+import org.opendaylight.controller.sal.core.api.data.DataProviderService
class MountPointManagerImpl implements MountProvisionService {
+ @Property
+ DataProviderService dataBroker;
+
ConcurrentMap<InstanceIdentifier,MountPointImpl> mounts = new ConcurrentHashMap();
override createMountPoint(InstanceIdentifier path) {
checkState(!mounts.containsKey(path),"Mount already created");
val mount = new MountPointImpl(path);
+ registerMountPoint(mount);
mounts.put(path,mount);
+ return mount;
+ }
+
+ def registerMountPoint(MountPointImpl impl) {
+ dataBroker?.registerConfigurationReader(impl.mountPath,impl.readWrapper);
+ dataBroker?.registerOperationalReader(impl.mountPath,impl.readWrapper);
+
}
override getMountPoint(InstanceIdentifier path) {
mounts.get(path);
}
-
-
}
import org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
import org.opendaylight.yangtools.yang.data.api.CompositeNode
+import org.opendaylight.controller.md.sal.common.api.data.DataReader
class DataReaderRouter extends AbstractDataReadRouter<InstanceIdentifier, CompositeNode> {
--- /dev/null
+package org.opendaylight.controller.sal.dom.broker.osgi;
+
+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.yang.data.api.InstanceIdentifier;
+import org.osgi.framework.ServiceReference;
+
+public class MountProviderServiceProxy extends AbstractBrokerServiceProxy<MountProvisionService> implements MountProvisionService{
+
+
+ public MountProviderServiceProxy(ServiceReference<MountProvisionService> ref, MountProvisionService delegate) {
+ super(ref, delegate);
+ }
+
+ public MountProvisionInstance getMountPoint(InstanceIdentifier path) {
+ return getDelegate().getMountPoint(path);
+ }
+
+ public MountProvisionInstance createMountPoint(InstanceIdentifier path) {
+ return getDelegate().createMountPoint(path);
+ }
+
+ public MountProvisionInstance createOrGetMountPoint(InstanceIdentifier path) {
+ return getDelegate().createOrGetMountPoint(path);
+ }
+}
import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService
import org.opendaylight.controller.sal.core.api.notify.NotificationService
import org.opendaylight.controller.sal.core.api.model.SchemaService
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionService
class ProxyFactory {
new NotificationServiceProxy(ref as ServiceReference<NotificationService>, service);
}
+ private static def dispatch createProxyImpl(ServiceReference<?> ref, MountProvisionService service) {
+ new MountProviderServiceProxy(ref as ServiceReference<MountProvisionService>, service);
+ }
+
+
private static def dispatch createProxyImpl(ServiceReference<?> ref, SchemaService service) {
new SchemaServiceProxy(ref as ServiceReference<SchemaService>, service);
}