package org.opendaylight.controller.config.yang.config.groupbasedpolicy.sxp_mapper;
-import org.opendaylight.groupbasedpolicy.sxp.mapper.SxpMapperProviderImpl;
+import org.opendaylight.groupbasedpolicy.sxp.mapper.impl.SxpMapperProviderImpl;
/**
* sxp-mapper impl module
+++ /dev/null
-/*
- * Copyright (c) 2016 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.groupbasedpolicy.sxp.mapper;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-
-/**
- * SxpMapper provider implementation.
- */
-public class SxpMapperProviderImpl implements AutoCloseable {
-
- private final DataBroker dataBrokerDependency;
- private final RpcProviderRegistry rpcRegistryDependency;
-
- public SxpMapperProviderImpl(final DataBroker dataBrokerDependency, final RpcProviderRegistry rpcRegistryDependency) {
- this.dataBrokerDependency = dataBrokerDependency;
- this.rpcRegistryDependency = rpcRegistryDependency;
- }
-
- @Override
- public void close() throws Exception {
- //TODO: stub
- }
-}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.groupbasedpolicy.sxp.mapper.api;
+
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+
+/**
+ * Purpose: provide listener capability to EB templates
+ */
+public interface EPTemplateListener extends DataChangeListener, AutoCloseable {
+ //NOBODY
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.groupbasedpolicy.sxp.mapper.api;
+
+/**
+ * Purpose: provides storing of L3 endpoints
+ */
+public interface L3EndpointDao {
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.groupbasedpolicy.sxp.mapper.api;
+
+/**
+ * Purpose: TODO!
+ */
+public interface SxpMapperReactor {
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.groupbasedpolicy.sxp.mapper.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.groupbasedpolicy.sxp.mapper.api.EPTemplateListener;
+import org.opendaylight.groupbasedpolicy.sxp.mapper.api.SxpMapperReactor;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Purpose: listens to EP forwarding template and propagates change events for further processing
+ */
+public class EPForwardingTemplateListenerImpl implements EPTemplateListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(EPForwardingTemplateListenerImpl.class);
+ private final SxpMapperReactor sxpMapperReactor;
+ private final ListenerRegistration<DataChangeListener> listenerRegistration;
+ private final InstanceIdentifier<?> templatePath;
+
+ public EPForwardingTemplateListenerImpl(final DataBroker dataBroker, final SxpMapperReactor sxpMapperReactor) {
+ this.sxpMapperReactor = sxpMapperReactor;
+
+ // TODO: get template path
+ templatePath = null;
+ listenerRegistration = dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, templatePath,
+ this, AsyncDataBroker.DataChangeScope.BASE);
+ LOG.debug("started listening to {}", templatePath);
+ }
+
+ @Override
+ public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> asyncDataChangeEvent) {
+ // sxpMapperReactor.process(template)
+ }
+
+ @Override
+ public void close() throws Exception {
+ LOG.debug("closing listener registration to {}", templatePath);
+ listenerRegistration.close();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.groupbasedpolicy.sxp.mapper.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.groupbasedpolicy.sxp.mapper.api.EPTemplateListener;
+import org.opendaylight.groupbasedpolicy.sxp.mapper.api.SxpMapperReactor;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Purpose: listens to EP policy template and propagates change events for further processing
+ */
+public class EPPolicyTemplateListenerImpl implements EPTemplateListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(EPPolicyTemplateListenerImpl.class);
+ private final ListenerRegistration<DataChangeListener> listenerRegistration;
+ private final InstanceIdentifier<?> templatePath;
+
+ public EPPolicyTemplateListenerImpl(final DataBroker dataBroker, final SxpMapperReactor sxpMapperReactor) {
+ // TODO: get template path
+ templatePath = null;
+ listenerRegistration = dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, templatePath,
+ this, AsyncDataBroker.DataChangeScope.BASE);
+ LOG.debug("started listening to {}", templatePath);
+ }
+
+ @Override
+ public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> asyncDataChangeEvent) {
+ // sxpMapperReactor.process(template)
+ }
+
+ @Override
+ public void close() throws Exception {
+ LOG.debug("closing listener registration to {}", templatePath);
+ listenerRegistration.close();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.groupbasedpolicy.sxp.mapper.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.groupbasedpolicy.sxp.mapper.api.L3EndpointDao;
+
+/**
+ * Purpose: stores L3 endpoints to DS
+ */
+public class L3EndpointDaoImpl implements L3EndpointDao {
+ private final DataBroker dataBroker;
+
+ public L3EndpointDaoImpl(final DataBroker dataBroker) {
+ this.dataBroker = dataBroker;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.groupbasedpolicy.sxp.mapper.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.groupbasedpolicy.sxp.mapper.api.SxpMapperReactor;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * listens to sxp master database and propagates change events for further processing
+ */
+public class SxpDatabaseListenerImpl implements DataChangeListener, AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SxpDatabaseListenerImpl.class);
+ private final SxpMapperReactor sxpMapperReactor;
+
+ private final ListenerRegistration<DataChangeListener> listenerRegistration;
+ private final InstanceIdentifier<?> sxpDbPath;
+
+ public SxpDatabaseListenerImpl(final DataBroker dataBroker, final SxpMapperReactor sxpMapperReactor) {
+ this.sxpMapperReactor = sxpMapperReactor;
+
+ // TODO: get db path
+ sxpDbPath = null;
+ listenerRegistration = dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, sxpDbPath,
+ this, AsyncDataBroker.DataChangeScope.BASE);
+ LOG.debug("started listening to {}", sxpDbPath);
+ }
+
+ @Override
+ public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> asyncDataChangeEvent) {
+ // sxpMapperReactor.process(template)
+ }
+
+ @Override
+ public void close() throws Exception {
+ LOG.debug("closing listener registration to {}", sxpDbPath);
+ listenerRegistration.close();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.groupbasedpolicy.sxp.mapper.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.groupbasedpolicy.sxp.mapper.api.EPTemplateListener;
+import org.opendaylight.groupbasedpolicy.sxp.mapper.api.L3EndpointDao;
+import org.opendaylight.groupbasedpolicy.sxp.mapper.api.SxpMapperReactor;
+
+/**
+ * SxpMapper provider implementation.
+ */
+public class SxpMapperProviderImpl implements AutoCloseable {
+
+ private final DataBroker dataBrokerDependency;
+ private final RpcProviderRegistry rpcRegistryDependency;
+ private final SxpDatabaseListenerImpl sxpDatabaseListener;
+ private final SxpMapperReactor sxpMapperReactor;
+ private final EPTemplateListener epPolicyTemplateListener;
+ private final EPTemplateListener epForwardingTemplateListener;
+
+ public SxpMapperProviderImpl(final DataBroker dataBroker, final RpcProviderRegistry rpcRegistryDependency) {
+ this.dataBrokerDependency = dataBroker;
+ this.rpcRegistryDependency = rpcRegistryDependency;
+
+ final L3EndpointDao l3EndpointDao = new L3EndpointDaoImpl(dataBroker);
+ sxpMapperReactor = new SxpMapperReactorImpl(l3EndpointDao);
+ sxpDatabaseListener = new SxpDatabaseListenerImpl(dataBroker, sxpMapperReactor);
+ epPolicyTemplateListener = new EPPolicyTemplateListenerImpl(dataBroker, sxpMapperReactor);
+ epForwardingTemplateListener = new EPForwardingTemplateListenerImpl(dataBroker, sxpMapperReactor);
+
+ }
+
+ // register listeners to ip/sgt and EP-templates (by SGT, by subnet) -> 3x
+ // exclusively write L3-EP to DS upon DataChangeEvent
+
+ @Override
+ public void close() throws Exception {
+ //TODO: stub
+ sxpDatabaseListener.close();
+ epPolicyTemplateListener.close();
+ epForwardingTemplateListener.close();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.groupbasedpolicy.sxp.mapper.impl;
+
+import org.opendaylight.groupbasedpolicy.sxp.mapper.api.L3EndpointDao;
+import org.opendaylight.groupbasedpolicy.sxp.mapper.api.SxpMapperReactor;
+
+/**
+ * Purpose: exclusively processes sxp master database changes and EGP templates changes
+ */
+public class SxpMapperReactorImpl implements SxpMapperReactor {
+ private final L3EndpointDao l3EndpointDao;
+
+ public SxpMapperReactorImpl(final L3EndpointDao l3EndpointDao) {
+ this.l3EndpointDao = l3EndpointDao;
+ }
+}