import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
import org.slf4j.Logger;
NodeId nodeId = nodeIdFromDatapathId(datapathId);
ModelDrivenSwitchImpl ofSwitch = new ModelDrivenSwitchImpl(nodeId, identifier, context);
LLDPSpeaker.getInstance().addModelDrivenSwitch(identifier, ofSwitch);
- ofSwitch.register(providerContext);
+ CompositeObjectRegistration<ModelDrivenSwitch> registration = ofSwitch.register(providerContext);
+ context.setProviderRegistration(registration);
LOG.debug("ModelDrivenSwitch for {} registered to MD-SAL.", datapathId.toString());
NodeRef nodeRef = new NodeRef(identifier);
NodeRemoved nodeRemoved = nodeRemoved(nodeRef);
LLDPSpeaker.getInstance().removeModelDrivenSwitch(identifier);
- LOG.debug("ModelDrivenSwitch for {} unregistred from MD-SAL.", datapathId.toString());
+ CompositeObjectRegistration<ModelDrivenSwitch> registration = context.getProviderRegistration();
+ registration.close();
+
+ LOG.debug("ModelDrivenSwitch for {} unregistered from MD-SAL.", datapathId.toString());
publishService.publish(nodeRemoved);
}
import java.util.Set;
import com.google.common.cache.Cache;
+
+import org.opendaylight.openflowplugin.openflow.md.ModelDrivenSwitch;
import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
+import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
/**
* @author mirehak
/**
* @return primary connection wrapper
*/
- public ConnectionConductor getPrimaryConductor();
+ ConnectionConductor getPrimaryConductor();
/**
* @return the features of corresponding switch
*/
- public GetFeaturesOutput getFeatures();
+ GetFeaturesOutput getFeatures();
/**
* @param auxiliaryKey
* key under which the auxiliary conductor is stored
* @return list of auxiliary connection wrappers
*/
- public ConnectionConductor getAuxiliaryConductor(
+ ConnectionConductor getAuxiliaryConductor(
SwitchConnectionDistinguisher auxiliaryKey);
/**
* @return entries of all auxiliary connections wrapped in conductors in this session
*/
- public Set<Entry<SwitchConnectionDistinguisher, ConnectionConductor>> getAuxiliaryConductors();
+ Set<Entry<SwitchConnectionDistinguisher, ConnectionConductor>> getAuxiliaryConductors();
/**
* register new auxiliary connection wrapped in {@link ConnectionConductor}
* @param auxiliaryKey
* @param conductor
*/
- public void addAuxiliaryConductor(SwitchConnectionDistinguisher auxiliaryKey,
+ void addAuxiliaryConductor(SwitchConnectionDistinguisher auxiliaryKey,
ConnectionConductor conductor);
/**
* @param connectionCookie
* @return removed connectionConductor
*/
- public ConnectionConductor removeAuxiliaryConductor(
+ ConnectionConductor removeAuxiliaryConductor(
SwitchConnectionDistinguisher connectionCookie);
/**
* @return true if this session is valid
*/
- public boolean isValid();
+ boolean isValid();
/**
* @param valid the valid to set
*/
- public void setValid(boolean valid);
+ void setValid(boolean valid);
/**
* @return the sessionKey
*/
- public SwitchConnectionDistinguisher getSessionKey();
+ SwitchConnectionDistinguisher getSessionKey();
/**
* Returns a map containing all OFPhysicalPorts of this switch.
* @return The Map of OFPhysicalPort
*/
- public Map<Long, PortGrouping> getPhysicalPorts();
+ Map<Long, PortGrouping> getPhysicalPorts();
/**
* Returns a map containing all bandwidths for all OFPorts of this switch.
* @return The Map of bandwidths for all OFPorts
*/
- public Map<Long, Boolean> getPortsBandwidth();
+ Map<Long, Boolean> getPortsBandwidth();
/**
* Returns a Set containing all port IDs of this switch.
* @return The Set of port ID
*/
- public Set<Long> getPorts();
+ Set<Long> getPorts();
/**
* @return the Object for this session xId
*/
- public Cache<TransactionKey, Object> getbulkTransactionCache();
+ Cache<TransactionKey, Object> getbulkTransactionCache();
/**
* Returns OFPhysicalPort of the specified portNumber of this switch.
* @param portNumber The port ID
* @return OFPhysicalPort for the specified PortNumber
*/
- public PortGrouping getPhysicalPort(Long portNumber);
+ PortGrouping getPhysicalPort(Long portNumber);
/**
* Returns the bandwidth of the specified portNumber of this switch.
* @param portNumber the port ID
* @return bandwidth
*/
- public Boolean getPortBandwidth(Long portNumber);
+ Boolean getPortBandwidth(Long portNumber);
/**
* Returns True if the port is enabled,
* @param portNumber
* @return True if the port is enabled
*/
- public boolean isPortEnabled(long portNumber);
+ boolean isPortEnabled(long portNumber);
/**
* Returns True if the port is enabled.
* @param port
* @return True if the port is enabled
*/
- public boolean isPortEnabled(PortGrouping port);
+ boolean isPortEnabled(PortGrouping port);
/**
* Returns a list containing all enabled ports of this switch.
* @return List containing all enabled ports of this switch
*/
- public List<PortGrouping> getEnabledPorts();
+ List<PortGrouping> getEnabledPorts();
// TODO:: add listeners here, manager will set them and conductor use them
*
* @return the message service
*/
- public IMessageDispatchService getMessageDispatchService();
+ IMessageDispatchService getMessageDispatchService();
/**
* @return the unique xid for this session
*/
- public Long getNextXid();
-
+ Long getNextXid();
+ /**
+ * @param registration provider composite registration
+ */
+ void setProviderRegistration(CompositeObjectRegistration<ModelDrivenSwitch> registration);
+ /**
+ * @return provider composite registration
+ */
+ CompositeObjectRegistration<ModelDrivenSwitch> getProviderRegistration();
}
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
+
import java.util.concurrent.TimeUnit;
+
+import org.opendaylight.openflowplugin.openflow.md.ModelDrivenSwitch;
import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
+import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
/**
* @author mirehak
private final Map<Long, PortGrouping> physicalPorts;
private final Map<Long, Boolean> portBandwidth;
public static Cache<TransactionKey, Object> bulkTransactionCache = CacheBuilder.newBuilder().expireAfterWrite(10000, TimeUnit.MILLISECONDS).concurrencyLevel(1).build();
+ private CompositeObjectRegistration<ModelDrivenSwitch> providerRegistration;
/**
}
return result;
}
+
+ @Override
+ public void setProviderRegistration(
+ CompositeObjectRegistration<ModelDrivenSwitch> providerRegistration) {
+ this.providerRegistration = providerRegistration;
+ }
+
+ @Override
+ public CompositeObjectRegistration<ModelDrivenSwitch> getProviderRegistration() {
+ return providerRegistration;
+ }
}
import junit.framework.Assert;
-import com.google.common.cache.Cache;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;
+import org.opendaylight.openflowplugin.openflow.md.ModelDrivenSwitch;
import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
import org.opendaylight.openflowplugin.openflow.md.core.ErrorHandler;
import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener;
+import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import com.google.common.cache.Cache;
+
public class MessageDispatchServiceImplTest {
MockSessionContext session;
private Map<SwitchConnectionDistinguisher, ConnectionConductor> map;
private IMessageDispatchService messageService;
private boolean isValid = true;
+ private CompositeObjectRegistration<ModelDrivenSwitch> registration;
MockSessionContext(int conductorNum) {
conductor = new MockConnectionConductor(conductorNum);
return null;
}
+ @Override
+ public CompositeObjectRegistration<ModelDrivenSwitch> getProviderRegistration() {
+ return registration;
+ }
+
+ @Override
+ public void setProviderRegistration(
+ CompositeObjectRegistration<ModelDrivenSwitch> registration) {
+ this.registration = registration;
+ }
}
class MockConnectionConductor implements ConnectionConductor {