From: Tony Tkacik Date: Mon, 30 Jun 2014 11:24:19 +0000 (+0000) Subject: Merge "Remove remoterpc dead code." X-Git-Tag: release/helium~584 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=5135f2d97f0886632f3ad3b7160a3be54909810f;hp=3b301f14027755f8924714c25d888132080f6b54 Merge "Remove remoterpc dead code." --- diff --git a/features/base/pom.xml b/features/base/pom.xml index 922b2d6bdf..d925f51b94 100644 --- a/features/base/pom.xml +++ b/features/base/pom.xml @@ -22,6 +22,24 @@ + + org.apache.karaf.tooling + karaf-maven-plugin + ${karaf.version} + true + + + features-create-kar + + features-create-kar + + + ${project.build.directory}/classes/${features.file} + + + + + org.apache.maven.plugins maven-resources-plugin diff --git a/features/base/src/main/resources/features.xml b/features/base/src/main/resources/features.xml index dd6eec8222..60286175c1 100644 --- a/features/base/src/main/resources/features.xml +++ b/features/base/src/main/resources/features.xml @@ -121,6 +121,7 @@ mvn:orbit/org.apache.juli.extras/7.0.32.v201211081135 mvn:orbit/org.apache.tomcat.api/7.0.32.v201211081135 mvn:orbit/org.apache.tomcat.util/7.0.32.v201211201952 + wrap:mvn:virgomirror/org.eclipse.jdt.core.compiler.batch/3.8.0.I20120518-2145 mvn:org.ow2.asm/asm-all/${asm.version} diff --git a/opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/ARPReply.java b/opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/ARPReply.java index a6ee60f65d..1a446b83db 100644 --- a/opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/ARPReply.java +++ b/opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/ARPReply.java @@ -23,14 +23,17 @@ public class ARPReply extends ARPEvent { private final byte[] tMac; private final byte[] sMac; private final InetAddress sIP; + private final short vlan; @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); + result = prime * result + ((port == null) ? 0 : port.hashCode()); result = prime * result + ((sIP == null) ? 0 : sIP.hashCode()); result = prime * result + Arrays.hashCode(sMac); result = prime * result + Arrays.hashCode(tMac); + result = prime * result + vlan; return result; } @@ -39,13 +42,20 @@ public class ARPReply extends ARPEvent { if (this == obj) { return true; } - if (obj == null) { + if (!super.equals(obj)) { return false; } if (!(obj instanceof ARPReply)) { return false; } ARPReply other = (ARPReply) obj; + if (port == null) { + if (other.port != null) { + return false; + } + } else if (!port.equals(other.port)) { + return false; + } if (sIP == null) { if (other.sIP != null) { return false; @@ -59,23 +69,28 @@ public class ARPReply extends ARPEvent { if (!Arrays.equals(tMac, other.tMac)) { return false; } + if (vlan != other.vlan) { + return false; + } return true; } - public ARPReply(NodeConnector port, InetAddress sIP, byte[] sMAC, InetAddress tIP, byte[] tMAC) { + public ARPReply(NodeConnector port, InetAddress sIP, byte[] sMAC, InetAddress tIP, byte[] tMAC, short vlan) { super(tIP); this.tMac = tMAC; this.sIP = sIP; this.sMac = sMAC; this.port = port; + this.vlan = vlan; } - public ARPReply(InetAddress tIP, byte[] tMAC) { + public ARPReply(InetAddress tIP, byte[] tMAC, short vlan) { super(tIP); this.tMac = tMAC; this.sIP = null; this.sMac = null; this.port = null; + this.vlan = vlan; } public byte[] getTargetMac() { @@ -94,6 +109,10 @@ public class ARPReply extends ARPEvent { return port; } + public short getVlan() { + return vlan; + } + /* * (non-Javadoc) * @@ -122,6 +141,10 @@ public class ARPReply extends ARPEvent { builder.append("sIP=") .append(sIP); } + if (vlan != 0) { + builder.append(", vlan=") + .append(vlan); + } builder.append("]"); return builder.toString(); } diff --git a/opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/internal/ArpHandler.java b/opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/internal/ArpHandler.java index e549182439..fe456f3f8e 100644 --- a/opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/internal/ArpHandler.java +++ b/opendaylight/arphandler/src/main/java/org/opendaylight/controller/arphandler/internal/ArpHandler.java @@ -49,12 +49,12 @@ import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.packet.ARP; import org.opendaylight.controller.sal.packet.Ethernet; import org.opendaylight.controller.sal.packet.IDataPacketService; +import org.opendaylight.controller.sal.packet.IEEE8021Q; import org.opendaylight.controller.sal.packet.IListenDataPacket; import org.opendaylight.controller.sal.packet.IPv4; import org.opendaylight.controller.sal.packet.Packet; import org.opendaylight.controller.sal.packet.PacketResult; import org.opendaylight.controller.sal.packet.RawPacket; -import org.opendaylight.controller.sal.routing.IRouting; import org.opendaylight.controller.sal.utils.EtherTypes; import org.opendaylight.controller.sal.utils.HexEncode; import org.opendaylight.controller.sal.utils.NetUtils; @@ -96,7 +96,6 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA private ISwitchManager switchManager; private ITopologyManager topologyManager; private IDataPacketService dataPacketService; - private IRouting routing; private IClusterContainerServices clusterContainerService; private IConnectionManager connectionManager; private Set hostListeners = new CopyOnWriteArraySet(); @@ -182,7 +181,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA } } - protected void sendARPReply(NodeConnector p, byte[] sMAC, InetAddress sIP, byte[] tMAC, InetAddress tIP) { + protected void sendARPReply(NodeConnector p, byte[] sMAC, InetAddress sIP, byte[] tMAC, InetAddress tIP, short vlan) { byte[] senderIP = sIP.getAddress(); byte[] targetIP = tIP.getAddress(); ARP arp = createARP(ARP.REPLY, sMAC, senderIP, tMAC, targetIP); @@ -193,7 +192,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA sIP, HexEncode.bytesToHexString(tMAC), tIP, p); } - Ethernet ethernet = createEthernet(sMAC, tMAC, arp); + Ethernet ethernet = createEthernet(sMAC, tMAC, arp, vlan); RawPacket destPkt = this.dataPacketService.encodeDataPacket(ethernet); destPkt.setOutgoingNodeConnector(p); @@ -201,26 +200,24 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA this.dataPacketService.transmitDataPacket(destPkt); } - private void logArpPacket(ARP pkt, NodeConnector p) { + private void logArpPacket(ARP pkt, NodeConnector p, short vlan) { try { - if (pkt.getOpCode() == ARP.REQUEST) { - log.trace("Received Arp Request with srcMac {} - srcIp {} - dstMac {} - dstIp {} - inport {}", HexEncode.bytesToHexString(pkt.getSenderHardwareAddress()), - InetAddress.getByAddress(pkt.getSenderProtocolAddress()), HexEncode.bytesToHexString(pkt.getTargetHardwareAddress()), - InetAddress.getByAddress(pkt.getTargetProtocolAddress()), p); - } else if(pkt.getOpCode() == ARP.REPLY) { - log.trace("Received Arp Reply with srcMac {} - srcIp {} - dstMac {} - dstIp {} - inport {}", HexEncode.bytesToHexString(pkt.getSenderHardwareAddress()), - InetAddress.getByAddress(pkt.getSenderProtocolAddress()), HexEncode.bytesToHexString(pkt.getTargetHardwareAddress()), - InetAddress.getByAddress(pkt.getTargetProtocolAddress()), p); - } - } catch(UnknownHostException e) { + log.trace("Received Arp {} with srcMac {} - srcIp {} - dstMac {} - dstIp {} - inport {} {}", + ((pkt.getOpCode() == ARP.REQUEST) ? "Request" : "Reply"), + HexEncode.bytesToHexString(pkt.getSenderHardwareAddress()), + InetAddress.getByAddress(pkt.getSenderProtocolAddress()), + HexEncode.bytesToHexString(pkt.getTargetHardwareAddress()), + InetAddress.getByAddress(pkt.getTargetProtocolAddress()), p, (vlan != 0 ? "on vlan " + vlan : "")); + + } catch (UnknownHostException e) { log.warn("Illegal Ip Address in the ARP packet", e); } } - protected void handleARPPacket(Ethernet eHeader, ARP pkt, NodeConnector p) { + protected void handleARPPacket(Ethernet eHeader, ARP pkt, NodeConnector p, short vlan) { if(log.isTraceEnabled()) { - logArpPacket(pkt, p); + logArpPacket(pkt, p, vlan); } byte[] sourceMAC = eHeader.getSourceMACAddress(); @@ -264,7 +261,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA HostNodeConnector requestor = null; if (NetUtils.isUnicastMACAddr(sourceMAC) && p.getNode() != null) { try { - requestor = new HostNodeConnector(sourceMAC, sourceIP, p, subnet.getVlan()); + requestor = new HostNodeConnector(sourceMAC, sourceIP, p, vlan); } catch (ConstructionException e) { log.debug("Received ARP packet with invalid MAC: {}", HexEncode.bytesToHexString(sourceMAC)); return; @@ -294,7 +291,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA // the true value indicates we should generate replies to requestors // across the cluster log.trace("Received ARP reply packet from {}, reply to all requestors.", sourceIP); - arpRequestReplyEvent.put(new ARPReply(sourceIP, sourceMAC), true); + arpRequestReplyEvent.put(new ARPReply(sourceIP, sourceMAC, vlan), true); return; } @@ -315,11 +312,11 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA log.trace("Received local ARP req. for default gateway. Replying with controller MAC: {}", HexEncode.bytesToHexString(getControllerMAC())); } - sendARPReply(p, getControllerMAC(), targetIP, pkt.getSenderHardwareAddress(), sourceIP); + sendARPReply(p, getControllerMAC(), targetIP, pkt.getSenderHardwareAddress(), sourceIP, vlan); } else { log.trace("Received non-local ARP req. for default gateway. Raising reply event"); arpRequestReplyEvent.put( - new ARPReply(p, targetIP, getControllerMAC(), sourceIP, pkt.getSenderHardwareAddress()), false); + new ARPReply(p, targetIP, getControllerMAC(), sourceIP, pkt.getSenderHardwareAddress(), vlan), false); } return; } @@ -353,10 +350,10 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA log.trace("Received ARP req. for known host {}, sending reply...", targetIP); if (connectionManager.getLocalityStatus(p.getNode()) == ConnectionLocality.LOCAL) { sendARPReply(p, host.getDataLayerAddressBytes(), host.getNetworkAddress(), - pkt.getSenderHardwareAddress(), sourceIP); + pkt.getSenderHardwareAddress(), sourceIP, vlan); } else { arpRequestReplyEvent.put(new ARPReply(p, host.getNetworkAddress(), host.getDataLayerAddressBytes(), - sourceIP, pkt.getSenderHardwareAddress()), false); + sourceIP, pkt.getSenderHardwareAddress(), vlan), false); } } else { /* @@ -404,7 +401,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA } byte[] destMACAddress = NetUtils.getBroadcastMACAddr(); - Ethernet ethernet = createEthernet(getControllerMAC(), destMACAddress, arp); + Ethernet ethernet = createEthernet(getControllerMAC(), destMACAddress, arp, (short)0); // TODO For now send port-by-port, see how to optimize to // send to multiple ports at once @@ -416,9 +413,9 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA } /** - * Send a unicast ARP Request to the known host on a specific switch/port as - * defined in the host. The sender IP is the networkAddress of the subnet - * The sender MAC is the controller's MAC + * Send a unicast ARP Request to the known host on specific (switch/port, + * vlan) as defined in the host. The sender IP is the networkAddress of the + * subnet The sender MAC is the controller's MAC */ protected void sendUcastARPRequest(HostNodeConnector host, Subnet subnet) { log.trace("sendUcastARPRequest host:{} subnet:{}", host, subnet); @@ -440,7 +437,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA outPort); } - Ethernet ethernet = createEthernet(getControllerMAC(), targetMAC, arp); + Ethernet ethernet = createEthernet(getControllerMAC(), targetMAC, arp, host.getVlan()); RawPacket destPkt = this.dataPacketService.encodeDataPacket(ethernet); destPkt.setOutgoingNodeConnector(outPort); @@ -498,7 +495,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA * @param pkt * @param p */ - protected void handlePuntedIPPacket(IPv4 pkt, NodeConnector p) { + protected void handlePuntedIPPacket(IPv4 pkt, NodeConnector p, short vlan) { InetAddress dIP = NetUtils.getInetAddress(pkt.getDestinationAddress()); if (dIP == null) { @@ -653,13 +650,19 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA log.trace("Received a frame of size: {}", inPkt.getPacketData().length); Packet formattedPak = this.dataPacketService.decodeDataPacket(inPkt); if (formattedPak instanceof Ethernet) { - Object nextPak = formattedPak.getPayload(); + Packet nextPak = formattedPak.getPayload(); + short vlan = 0; + if (nextPak instanceof IEEE8021Q) { + vlan = ((IEEE8021Q) nextPak).getVid(); + log.trace("Moved after the dot1Q header"); + nextPak = ((IEEE8021Q) nextPak).getPayload(); + } if (nextPak instanceof IPv4) { log.trace("Handle IP packet: {}", formattedPak); - handlePuntedIPPacket((IPv4) nextPak, inPkt.getIncomingNodeConnector()); + handlePuntedIPPacket((IPv4) nextPak, inPkt.getIncomingNodeConnector(), vlan); } else if (nextPak instanceof ARP) { log.trace("Handle ARP packet: {}", formattedPak); - handleARPPacket((Ethernet) formattedPak, (ARP) nextPak, inPkt.getIncomingNodeConnector()); + handleARPPacket((Ethernet) formattedPak, (ARP) nextPak, inPkt.getIncomingNodeConnector(), vlan); } } return PacketResult.IGNORED; @@ -680,12 +683,21 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA return arp; } - private Ethernet createEthernet(byte[] sourceMAC, byte[] targetMAC, ARP arp) { + private Ethernet createEthernet(byte[] sourceMAC, byte[] targetMAC, ARP arp, short vlan) { Ethernet ethernet = new Ethernet(); ethernet.setSourceMACAddress(sourceMAC); ethernet.setDestinationMACAddress(targetMAC); - ethernet.setEtherType(EtherTypes.ARP.shortValue()); - ethernet.setPayload(arp); + if (vlan == 0) { + ethernet.setEtherType(EtherTypes.ARP.shortValue()); + ethernet.setPayload(arp); + } else { + IEEE8021Q dot1q = new IEEE8021Q(); + dot1q.setVid(vlan); + dot1q.setEtherType(EtherTypes.ARP.shortValue()); + dot1q.setPayload(arp); + ethernet.setEtherType(EtherTypes.VLANTAGGED.shortValue()); + ethernet.setPayload(dot1q); + } return ethernet; } @@ -731,7 +743,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA } } - private void generateAndSendReply(InetAddress sourceIP, byte[] sourceMAC) { + private void generateAndSendReply(InetAddress sourceIP, byte[] sourceMAC, short vlan) { if (log.isTraceEnabled()) { log.trace("generateAndSendReply called with params sourceIP:{} sourceMAC:{}", sourceIP, HexEncode.bytesToHexString(sourceMAC)); @@ -745,13 +757,14 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA for (HostNodeConnector host : hosts) { if (log.isTraceEnabled()) { log.trace( - "Sending ARP Reply with src {}/{}, target {}/{}", + "Sending ARP Reply with src {}/{}, target {}/{} {}", new Object[] { HexEncode.bytesToHexString(sourceMAC), sourceIP, - HexEncode.bytesToHexString(host.getDataLayerAddressBytes()), host.getNetworkAddress() }); + HexEncode.bytesToHexString(host.getDataLayerAddressBytes()), host.getNetworkAddress(), + (vlan != 0 ? "on vlan " + vlan : "") }); } if (connectionManager.getLocalityStatus(host.getnodeconnectorNode()) == ConnectionLocality.LOCAL) { sendARPReply(host.getnodeConnector(), sourceMAC, sourceIP, host.getDataLayerAddressBytes(), - host.getNetworkAddress()); + host.getNetworkAddress(), vlan); } else { /* * In the remote event a requestor moved to another controller @@ -760,7 +773,7 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA */ arpRequestReplyEvent.put( new ARPReply(host.getnodeConnector(), sourceIP, sourceMAC, host.getNetworkAddress(), host - .getDataLayerAddressBytes()), false); + .getDataLayerAddressBytes(), vlan), false); } } } @@ -822,12 +835,12 @@ public class ArpHandler implements IHostFinder, IListenDataPacket, ICacheUpdateA // requestors across the cluster if (ev.isNewReply()) { log.trace("Trigger a generateAndSendReply in response to {}", rep); - generateAndSendReply(rep.getTargetIP(), rep.getTargetMac()); + generateAndSendReply(rep.getTargetIP(), rep.getTargetMac(), rep.getVlan()); // Otherwise, a specific reply. If local, send out. } else if (connectionManager.getLocalityStatus(rep.getPort().getNode()) == ConnectionLocality.LOCAL) { log.trace("ARPCacheEventHandler - sendUcatARPReply locally in response to {}", rep); sendARPReply(rep.getPort(), rep.getSourceMac(), rep.getSourceIP(), rep.getTargetMac(), - rep.getTargetIP()); + rep.getTargetIP(), rep.getVlan()); } } } catch (InterruptedException e) { diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index 17cb9f4034..de8caa0e67 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -2,11 +2,13 @@ 4.0.0 - org.opendaylight.controller - commons.parent - 1.0.2-SNAPSHOT - ../parent + org.opendaylight.odlparent + odlparent + 1.4.2-SNAPSHOT + + + org.opendaylight.controller commons.opendaylight 1.4.2-SNAPSHOT pom @@ -15,6 +17,7 @@ + 2.3.2 1.0.0 0.4.2-SNAPSHOT @@ -48,7 +51,6 @@ 2.4 7.0.32.v201211201952 7.0.32.v201211081135 - 2.6 3.1 0.0.2-SNAPSHOT 3.0.1 @@ -59,6 +61,7 @@ 7.0.32.v201211081135 7.0.32.v201211201952 2.3.2 + 0.1.2-SNAPSHOT 0.5.2-SNAPSHOT 0.2.5-SNAPSHOT 0.4.3-SNAPSHOT @@ -69,8 +72,6 @@ 0.5.2-SNAPSHOT 0.5.2-SNAPSHOT 0.0.2-SNAPSHOT - 7.0.42 - 0.2.0 0.4.2-SNAPSHOT 1.1.0-SNAPSHOT 2.5.0 @@ -80,13 +81,8 @@ 3.0.0 + 0000.0002.0038.0 - 2.15 - 1.0.1 - 3.0.1 - 3.1.0 - 3.1.6 - 4.2.0 1.4.2-SNAPSHOT 2.4.0 0.4.2-SNAPSHOT @@ -95,9 +91,6 @@ 0.4.2-SNAPSHOT 0.4.2-SNAPSHOT 0.6.0-SNAPSHOT - 2.2.0.RELEASE - 2.2.4 - 14.0.1 0.5.2-SNAPSHOT 0.5.2-SNAPSHOT 0.4.2-SNAPSHOT @@ -108,20 +101,7 @@ 2013.10.19.1-SNAPSHOT 2013.10.21.2-SNAPSHOT 2010.09.24.4-SNAPSHOT - 2.3.2 - 0.6.2.201302030002 - 2.4 - 1.7 - 1.7 - 3.17.1-GA - 1.2 2.0-beta-2 - - 1.17 - 1.17 - 4.0 - 2.8 - 1.3.3 src/main/yang-gen-config 0.0.2-SNAPSHOT 1.1.4 @@ -135,15 +115,9 @@ 1.0.0 1.0.9 0.4.2-SNAPSHOT - 2.5.1 - - 1.7 - 1.7 3.0.5 1.1-SNAPSHOT - 1.9.5 0.2.5-SNAPSHOT - 4.0.19.Final 0.0.3-SNAPSHOT 0.4.2-SNAPSHOT 0.4.2-SNAPSHOT @@ -154,18 +128,11 @@ 1.4.2-SNAPSHOT 1.4.2-SNAPSHOT 2013.08.27.4-SNAPSHOT - 20080701 0.0.2-SNAPSHOT - 5.0.0 - 5.0.0 - UTF-8 - UTF-8 - 2.6 1.0-alpha-2 0.5.0-SNAPSHOT 0.4.2-SNAPSHOT 0.4.2-SNAPSHOT - 2.3.2 0.4.2-SNAPSHOT 0.1.2-SNAPSHOT 0.4.2-SNAPSHOT @@ -179,19 +146,12 @@ 2.11 0.4.2-SNAPSHOT dav:http://nexus.opendaylight.org/content/sites/site - 3.2 - 1.7.2 ${user.name}-private-view https://sonar.opendaylight.org/ jacoco java org.openflow.openflowj,net.sf.jung2 - 1.0.0 - 1.2.1 - 3.1.4.RELEASE - 3.1.3.RELEASE - 3.1.3.RELEASE 0.4.2-SNAPSHOT 0.4.2-SNAPSHOT 0.5.1-SNAPSHOT @@ -205,14 +165,11 @@ 0.4.2-SNAPSHOT 0.4.2-SNAPSHOT 0.4.2-SNAPSHOT - 1.5.0 0.4.2-SNAPSHOT 0.0.2-SNAPSHOT 0.4.2-SNAPSHOT - 3.6.0.RELEASE 0.4.2-SNAPSHOT src/main/xtend-gen - 2.4.3 2013.09.07.4-SNAPSHOT 1.0.0-SNAPSHOT 0.6.2-SNAPSHOT @@ -220,7 +177,7 @@ - + ${project.groupId} ietf-netconf-monitoring @@ -1039,12 +996,12 @@ netconf-client ${netconf.version} - - org.opendaylight.controller - netconf-client - ${netconf.version} - test-jar - + + org.opendaylight.controller + netconf-client + ${netconf.version} + test-jar + @@ -1711,18 +1668,6 @@ org.osgi.core ${osgi.core.version} - - - org.ow2.asm - asm-all - 4.1 - - - - org.ow2.chameleon.management - chameleon-mbeans - 1.0.0 - org.reflections reflections @@ -1754,95 +1699,12 @@ slf4j-simple ${slf4j.version} - - org.springframework - org.springframework.aop - ${spring.version} - - - org.springframework - org.springframework.asm - ${spring.version} - - - org.springframework - org.springframework.beans - ${spring.version} - - - org.springframework - org.springframework.context - ${spring.version} - - - org.springframework - org.springframework.context.support - ${spring.version} - - - org.springframework - org.springframework.core - ${spring.version} - - - org.springframework - org.springframework.expression - ${spring.version} - - - org.springframework - org.springframework.transaction - ${spring-security.version} - - - org.springframework - org.springframework.web - ${spring.version} - - - org.springframework - org.springframework.web.servlet - ${spring.version} - - - - - org.springframework.security - spring-security-config - ${spring-security.version} - - - org.springframework.security - spring-security-core - ${spring-security.version} - - - org.springframework.security - spring-security-taglibs - ${spring-security.version} - - - org.springframework.security - spring-security-web - ${spring-security.version} - - - virgomirror - org.eclipse.jdt.core.compiler.batch - 3.8.0.I20120518-2145 - junit junit ${junit.version} test - - org.mockito - mockito-all - ${mockito.version} - test - org.opendaylight.controller commons.logback_settings @@ -1868,44 +1730,6 @@ ${yangtools.version} test - - - org.ops4j.pax.exam - pax-exam-container-native - ${exam.version} - test - - - org.ops4j.pax.exam - pax-exam-junit4 - ${exam.version} - test - - - org.ops4j.pax.exam - pax-exam-link-mvn - ${exam.version} - test - - - org.ops4j.pax.url - pax-url-aether - ${url.version} - test - - - - org.springframework.osgi - spring-osgi-mock - ${spring-osgi.version} - test - - - xmlunit - xmlunit - 1.5 - test - @@ -2164,6 +1988,21 @@ + + + org.codehaus.mojo + javacc-maven-plugin + [0.0,) + + javacc + + + + + false + + + @@ -2396,7 +2235,7 @@ opendaylight-mirror opendaylight-mirror - ${nexusproxy}/groups/public/ + http://nexus.opendaylight.org/content/groups/public/ @@ -2408,7 +2247,7 @@ opendaylight-snapshot opendaylight-snapshot - ${nexusproxy}/repositories/${nexus.repository.snapshot}/ + http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ @@ -2424,7 +2263,7 @@ opendaylight-mirror opendaylight-mirror - ${nexusproxy}/groups/public/ + http://nexus.opendaylight.org/content/groups/public/ @@ -2436,19 +2275,19 @@ opendaylight-snapshot opendaylight-snapshot - ${nexusproxy}/repositories/${nexus.repository.snapshot}/ + http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ opendaylight-release - ${nexusproxy}/repositories/${nexus.repository.release}/ + http://nexus.opendaylight.org/content/repositories/opendaylight.release/ opendaylight-snapshot - ${nexusproxy}/repositories/${nexus.repository.snapshot}/ + http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ diff --git a/opendaylight/config/config-persister-api/src/main/java/org/opendaylight/controller/config/persist/api/ConfigSnapshotHolder.java b/opendaylight/config/config-persister-api/src/main/java/org/opendaylight/controller/config/persist/api/ConfigSnapshotHolder.java index c00b26d9ce..ba13ebb8f0 100644 --- a/opendaylight/config/config-persister-api/src/main/java/org/opendaylight/controller/config/persist/api/ConfigSnapshotHolder.java +++ b/opendaylight/config/config-persister-api/src/main/java/org/opendaylight/controller/config/persist/api/ConfigSnapshotHolder.java @@ -12,13 +12,14 @@ import java.util.SortedSet; public interface ConfigSnapshotHolder { /** - * Get part of get-config document that contains just + * Get XML node that should be pushed to netconf's edit-config */ String getConfigSnapshot(); /** * Get only required capabilities referenced by the snapshot. + * If no value is specified, return empty set instead of null */ SortedSet getCapabilities(); diff --git a/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/ConfigSnapshot.java b/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/ConfigSnapshot.java index d13052a7e2..7c069dab6b 100644 --- a/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/ConfigSnapshot.java +++ b/opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/ConfigSnapshot.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.config.persist.storage.file.xml.model; +import java.util.TreeSet; import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; import javax.xml.bind.annotation.XmlAnyElement; @@ -22,7 +23,7 @@ public class ConfigSnapshot { public static final String SNAPSHOT_ROOT_ELEMENT_NAME = "snapshot"; private String configSnapshot; - private SortedSet capabilities; + private SortedSet capabilities = new TreeSet<>(); ConfigSnapshot(String configXml, SortedSet capabilities) { this.configSnapshot = configXml; diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsModuleGeneratedObjectFactory.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsModuleGeneratedObjectFactory.java index aa06cb97d7..6eda364af0 100644 --- a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsModuleGeneratedObjectFactory.java +++ b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsModuleGeneratedObjectFactory.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory; +import static com.google.common.base.Preconditions.checkState; import static java.lang.String.format; import com.google.common.base.Joiner; @@ -212,7 +213,7 @@ public class AbsModuleGeneratedObjectFactory { "}\n", moduleField.getName(), osgi); } else { str = format( - "%1$sDependency = dependencyResolver.resolveInstance(%2$s.class, %1$s, %1$sJmxAttribute);", + "%1$sDependency = dependencyResolver.resolveInstance(%2$s.class, %1$s, %1$sJmxAttribute);\n", moduleField.getName(), osgi); } resolveDependenciesMap.put(moduleField, str); @@ -222,7 +223,8 @@ public class AbsModuleGeneratedObjectFactory { // wrap each field resolvation statement with if !=null when dependency is not mandatory for (Map.Entry entry : resolveDependenciesMap.entrySet()) { if (entry.getKey().getDependency().isMandatory() == false) { - result += format("if (%s!=null) {\n%s;\n}", entry.getKey().getName(), entry.getValue()); + checkState(entry.getValue().endsWith(";\n")); + result += format("if (%s!=null) {\n%s}\n", entry.getKey().getName(), entry.getValue()); } else { result += entry.getValue(); } @@ -401,7 +403,7 @@ public class AbsModuleGeneratedObjectFactory { parameters.put(ModuleIdentifier.class.getCanonicalName(), "identifier"); parameters.put(DependencyResolver.class.getCanonicalName(), "dependencyResolver"); - String setToNulls = "this.oldInstance=null;\n;" + + String setToNulls = "this.oldInstance=null;\n" + "this.oldModule=null;\n"; return getConstructorStart(abstractFQN, parameters, setToNulls); } diff --git a/opendaylight/distribution/opendaylight-karaf/pom.xml b/opendaylight/distribution/opendaylight-karaf/pom.xml index 7970b3aa00..8a23a6b5e6 100644 --- a/opendaylight/distribution/opendaylight-karaf/pom.xml +++ b/opendaylight/distribution/opendaylight-karaf/pom.xml @@ -38,13 +38,11 @@ xml runtime - org.opendaylight.controller base-features ${project.version} - pom + kar runtime diff --git a/opendaylight/distribution/opendaylight-karaf/src/main/resources/etc/custom.properties b/opendaylight/distribution/opendaylight-karaf/src/main/resources/etc/custom.properties index 502e1a261c..6c1ca421c2 100644 --- a/opendaylight/distribution/opendaylight-karaf/src/main/resources/etc/custom.properties +++ b/opendaylight/distribution/opendaylight-karaf/src/main/resources/etc/custom.properties @@ -1,11 +1,17 @@ # Extra packages to import from the boot class loader org.osgi.framework.system.packages.extra=org.apache.karaf.branding,sun.reflect,sun.reflect.misc,sun.misc,sun.nio.ch +# 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 # Embedded Tomcat configuration File org.eclipse.gemini.web.tomcat.config.path=configuration/tomcat-server.xml org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true +# Use Equinox as default OSGi Framework Implementation +karaf.framework=equinox # Netconf startup configuration netconf.tcp.address=127.0.0.1 diff --git a/opendaylight/distribution/opendaylight-karaf/src/main/resources/etc/startup.properties b/opendaylight/distribution/opendaylight-karaf/src/main/resources/etc/startup.properties index 288fe629f8..ca8c83c380 100644 --- a/opendaylight/distribution/opendaylight-karaf/src/main/resources/etc/startup.properties +++ b/opendaylight/distribution/opendaylight-karaf/src/main/resources/etc/startup.properties @@ -7,7 +7,7 @@ mvn\:org.ops4j.pax.swissbox/pax-swissbox-bnd/1.7.0 = 5 mvn\:org.ops4j.pax.url/pax-url-maven-commons/1.6.0 = 5 mvn\:org.ops4j.pax.url/pax-url-aether/1.6.0 = 5 mvn\:org.ops4j.pax.url/pax-url-wrap/1.6.0 = 5 -#mvn\:javax.annotation/javax.annotation-api/1.2 = 5 +mvn\:javax.annotation/javax.annotation-api/1.2 = 5 mvn\:org.ops4j.pax.logging/pax-logging-api/1.7.2 = 8 mvn\:org.ops4j.pax.logging/pax-logging-service/1.7.2 = 8 mvn\:org.apache.karaf.service/org.apache.karaf.service.guard/3.0.1 = 10 diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index b9cfb0f7a6..ef3b5f4fd9 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -988,6 +988,11 @@ org.opendaylight.controller sal-core-spi + + org.opendaylight.controller + sal-inmemory-datastore + 1.1-SNAPSHOT + org.opendaylight.controller sal-netconf-connector diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml index 8b07ce3a33..7b1df98247 100644 --- a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml +++ b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/01-md-sal.xml @@ -15,6 +15,7 @@ prefix:schema-service-singleton yang-schema-service + prefix:runtime-generated-mapping runtime-mapping-singleton @@ -36,6 +37,25 @@ + + + prefix:inmemory-config-datastore-provider + config-store-service + + dom:schema-service + yang-schema-service + + + + + prefix:inmemory-operational-datastore-provider + operational-store-service + + dom:schema-service + yang-schema-service + + + + + + + + + + + + prefix:netconf-client-dispatcher + global-netconf-dispatcher + + prefix:netty-threadgroup + global-boss-group + + + prefix:netty-threadgroup + global-worker-group + + + prefix:netty-timer + global-timer + + + + + + prefix:threadfactory-naming + global-netconf-processing-executor-threadfactory + remote-connector-processing-executor + + + + prefix:threadpool-flexible + global-netconf-processing-executor + 1 + 4 + 600000 + + prefix:threadfactory + global-netconf-processing-executor-threadfactory + + + + + + + prefix:netconf-client-dispatcher + + global-netconf-dispatcher + /modules/module[type='netconf-client-dispatcher'][name='global-netconf-dispatcher'] + + + + prefix:threadfactory + + global-netconf-processing-executor-threadfactory + /modules/module[type='threadfactory-naming'][name='global-netconf-processing-executor-threadfactory'] + + + + prefix:threadpool + + global-netconf-processing-executor + /modules/module[type='threadpool-flexible'][name='global-netconf-processing-executor'] + + + + + + + + urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher?module=odl-netconfig-client-cfg&revision=2014-04-08 + urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&revision=2013-04-05 + urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible?module=threadpool-impl-flexible&revision=2013-12-01 + + diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/99-netconf-connector.xml b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/99-netconf-connector.xml index b4b433dbca..7155eb8883 100644 --- a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/99-netconf-connector.xml +++ b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/99-netconf-connector.xml @@ -11,43 +11,6 @@ - - - - prefix:netconf-client-dispatcher - global-netconf-dispatcher - - prefix:netty-threadgroup - global-boss-group - - - prefix:netty-threadgroup - global-worker-group - - - prefix:netty-timer - global-timer - - - - - - prefix:threadfactory-naming - global-netconf-processing-executor-threadfactory - remote-connector-processing-executor - - - prefix:threadpool-flexible - global-netconf-processing-executor - 1 - 4 - 600000 - - prefix:threadfactory - global-netconf-processing-executor-threadfactory - - - prefix:sal-netconf-connector @@ -79,37 +42,9 @@ - - - - prefix:netconf-client-dispatcher - - global-netconf-dispatcher - /modules/module[type='netconf-client-dispatcher'][name='global-netconf-dispatcher'] - - - - prefix:threadfactory - - global-netconf-processing-executor-threadfactory - /modules/module[type='threadfactory-naming'][name='global-netconf-processing-executor-threadfactory'] - - - - prefix:threadpool - - global-netconf-processing-executor - /modules/module[type='threadpool-flexible'][name='global-netconf-processing-executor'] - - - - urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf?module=odl-sal-netconf-connector-cfg&revision=2013-10-28 - urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher?module=odl-netconfig-client-cfg&revision=2014-04-08 - urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&revision=2013-04-05 - urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible?module=threadpool-impl-flexible&revision=2013-12-01 diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.java index ba68d523af..d71858e5c3 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.java @@ -83,6 +83,7 @@ public class ComponentActivator extends ComponentActivatorAbstractBase { @Override protected void init() { + // TODO: deprecated, should be removed soon NodeIDType.registerIDType(NodeMapping.MD_SAL_TYPE, String.class); NodeConnectorIDType.registerIDType(NodeMapping.MD_SAL_TYPE, String.class, NodeMapping.MD_SAL_TYPE); } @@ -232,8 +233,8 @@ public class ComponentActivator extends ComponentActivatorAbstractBase { private Dictionary properties() { final Hashtable props = new Hashtable(); - props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), NodeMapping.MD_SAL_TYPE); - props.put("protocolName", NodeMapping.MD_SAL_TYPE); + props.put(GlobalConstants.PROTOCOLPLUGINTYPE.toString(), NodeIDType.OPENFLOW); + props.put("protocolName", NodeIDType.OPENFLOW); return props; } } diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.java index ba7377e8ff..acb54ba51a 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.java @@ -247,7 +247,8 @@ public class FlowProgrammerAdapter implements IPluginInFlowProgrammerService, Sa flowId = UUID.randomUUID(); cache.put(flow, flowId); - return this.writeFlowAsync(MDFlowMapping.toMDFlow(flow, flowId.toString()), new NodeKey(new NodeId(node.getNodeIDString()))); + return this.writeFlowAsync(MDFlowMapping.toMDFlow(flow, flowId.toString()), new NodeKey( + new NodeId(NodeMapping.OPENFLOW_ID_PREFIX + node.getID()))); } private Future> internalModifyFlowAsync(final Node node, final Flow oldFlow, final Flow newFlow, final long rid) { @@ -261,7 +262,8 @@ public class FlowProgrammerAdapter implements IPluginInFlowProgrammerService, Sa } cache.put(newFlow, flowId); - return this.writeFlowAsync(MDFlowMapping.toMDFlow(newFlow, flowId.toString()), new NodeKey(new NodeId(node.getNodeIDString()))); + return this.writeFlowAsync(MDFlowMapping.toMDFlow(newFlow, flowId.toString()), new NodeKey( + new NodeId(NodeMapping.OPENFLOW_ID_PREFIX + node.getID()))); } private Future> internalRemoveFlowAsync(final Node node, final Flow adflow, final long rid) { @@ -275,7 +277,8 @@ public class FlowProgrammerAdapter implements IPluginInFlowProgrammerService, Sa final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow flow = MDFlowMapping.toMDFlow(adflow, flowId.toString()); final DataModificationTransaction modification = this.dataBrokerService.beginTransaction(); - modification.removeConfigurationData(flowPath(flow, new NodeKey(new NodeId(node.getNodeIDString())))); + modification.removeConfigurationData(flowPath(flow, new NodeKey( + new NodeId(NodeMapping.OPENFLOW_ID_PREFIX + node.getID())))); return modification.commit(); } diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.java index 2830165425..5959d23366 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/InventoryAndReadAdapter.java @@ -26,6 +26,7 @@ import org.opendaylight.controller.sal.core.Edge; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.core.NodeTable; +import org.opendaylight.controller.sal.core.NodeTable.NodeTableIDType; import org.opendaylight.controller.sal.core.Property; import org.opendaylight.controller.sal.core.UpdateType; import org.opendaylight.controller.sal.inventory.IPluginInInventoryService; @@ -489,7 +490,7 @@ public class InventoryAndReadAdapter implements IPluginInReadService, IPluginInI } try { - final Node adNode = new Node(NodeMapping.MD_SAL_TYPE, NodeMapping.toADNodeId(node.getId())); + final Node adNode = NodeMapping.toADNode(node.getId()); props.put(adNode, perNodePropMap); } catch (ConstructionException e) { LOG.warn("Failed to construct node for {}, skipping it", node, e); @@ -572,7 +573,7 @@ public class InventoryAndReadAdapter implements IPluginInReadService, IPluginInI it.setLookupCount(tableStats.getPacketsLookedUp().getValue().longValue()); it.setMatchedCount(tableStats.getPacketsMatched().getValue().longValue()); it.setName(tableId.toString()); - it.setNodeTable(new NodeTable(NodeMapping.MD_SAL_TYPE, tableId, node)); + it.setNodeTable(new NodeTable(NodeTableIDType.OPENFLOW, tableId.byteValue(), node)); return it; } diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.java index 67af3e428f..9b5d0e8875 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.java @@ -357,7 +357,7 @@ public final class MDFlowMapping { } public static Uri toUri(final NodeConnector connector) { - return new NodeConnectorId(((String) connector.getID())); + return new NodeConnectorId(NodeMapping.OPENFLOW_ID_PREFIX + connector.getNode().getID() + ":" + (connector.getID())); } public static MacAddress toMacAddress(final byte[] bytes) { diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.java index f5701bfaf2..a700c86b9c 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/NodeMapping.java @@ -11,7 +11,6 @@ import java.math.BigInteger; import java.util.Date; import java.util.HashSet; import java.util.List; - import org.opendaylight.controller.sal.common.util.Arguments; import org.opendaylight.controller.sal.core.AdvertisedBandwidth; import org.opendaylight.controller.sal.core.Bandwidth; @@ -19,8 +18,10 @@ import org.opendaylight.controller.sal.core.Buffers; import org.opendaylight.controller.sal.core.Capabilities; import org.opendaylight.controller.sal.core.Config; import org.opendaylight.controller.sal.core.ConstructionException; +import org.opendaylight.controller.sal.core.Description; import org.opendaylight.controller.sal.core.MacAddress; import org.opendaylight.controller.sal.core.Name; +import org.opendaylight.controller.sal.core.Node.NodeIDType; import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType; import org.opendaylight.controller.sal.core.PeerBandwidth; import org.opendaylight.controller.sal.core.Property; @@ -44,6 +45,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.fl import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated; @@ -56,12 +58,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.No 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.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.base.Objects; import com.google.common.base.Preconditions; public final class NodeMapping { - public final static String MD_SAL_TYPE = "MD_SAL"; + + private static final Logger LOG = LoggerFactory + .getLogger(NodeMapping.class); + + /** openflow id prefix */ + public static final String OPENFLOW_ID_PREFIX = "openflow:"; + + public final static String MD_SAL_TYPE = "MD_SAL_DEPRECATED"; private final static Class NODE_CLASS = Node.class; @@ -77,8 +88,19 @@ public final class NodeMapping { } public static org.opendaylight.controller.sal.core.Node toADNode(final NodeId id) throws ConstructionException { - String aDNodeId = NodeMapping.toADNodeId(id); - return new org.opendaylight.controller.sal.core.Node(NodeMapping.MD_SAL_TYPE, aDNodeId); + Long aDNodeId = openflowFullNodeIdToLong(NodeMapping.toADNodeId(id)); + return new org.opendaylight.controller.sal.core.Node(NodeIDType.OPENFLOW, aDNodeId); + } + + /** + * @param adNodeId + * @return + */ + private static Long openflowFullNodeIdToLong(String adNodeId) { + if (adNodeId == null) { + return null; + } + return Long.valueOf(adNodeId.replaceFirst("^.*:", "")); } public static NodeId toNodeId(final InstanceIdentifier id) { @@ -87,7 +109,14 @@ public final class NodeMapping { return key.getId(); } + /** + * @param nodeId containing "<NodeTypeString>:<plainIntegerId>" + * @return adNodeId form + */ public static String toADNodeId(final NodeId nodeId) { + if (nodeId == null) { + return null; + } return nodeId.getValue(); } @@ -104,6 +133,28 @@ public final class NodeMapping { return new org.opendaylight.controller.sal.core.NodeConnector(nodeConnectorType, aDNodeConnectorId, aDNode); } + /** + * @param ncid nodeConnector identifier, e.g.: OF:21 or CTRL + * @param node + * @return nodeConnector attached to given node + * @throws ConstructionException + */ + public static org.opendaylight.controller.sal.core.NodeConnector toADNodeConnector( + final NodeConnectorId ncid, final org.opendaylight.controller.sal.core.Node aDNode) throws ConstructionException { + NodeId nid = NodeMapping.toNodeId(aDNode); + String nodeConnectorType = NodeMapping.toNodeConnectorType(ncid, nid); + Object aDNodeConnectorId = NodeMapping.toADNodeConnectorId(ncid, nid); + return new org.opendaylight.controller.sal.core.NodeConnector(nodeConnectorType, aDNodeConnectorId, aDNode); + } + + /** + * @param aDNode + * @return + */ + private static NodeId toNodeId(org.opendaylight.controller.sal.core.Node aDNode) { + return new NodeId(aDNode.getType() + ":" +String.valueOf(aDNode.getID())); + } + public static String toNodeConnectorType(final NodeConnectorId ncId, final NodeId nodeId) { if (ncId.equals(toLocalNodeConnectorId(nodeId))) { return NodeConnectorIDType.SWSTACK; @@ -112,7 +163,7 @@ public final class NodeMapping { } else if (ncId.equals(toControllerNodeConnectorId(nodeId))) { return NodeConnectorIDType.CONTROLLER; } - return MD_SAL_TYPE; + return NodeConnectorIDType.OPENFLOW; } public static Object toADNodeConnectorId(final NodeConnectorId nodeConnectorId, final NodeId nodeId) { @@ -121,7 +172,18 @@ public final class NodeMapping { nodeConnectorId.equals(toControllerNodeConnectorId(nodeId))) { return org.opendaylight.controller.sal.core.NodeConnector.SPECIALNODECONNECTORID; } - return nodeConnectorId.getValue(); + + String nodeConnectorIdStripped = nodeConnectorId.getValue().replaceFirst("^.*:", ""); + if (nodeConnectorIdStripped.matches("[0-9]+")) { + Short nodeConnectorIdVal = null; + try { + nodeConnectorIdVal = Short.valueOf(nodeConnectorIdStripped); + } catch (NumberFormatException e) { + LOG.warn("nodeConnectorId not supported (short): {}", nodeConnectorIdStripped, e); + } + return nodeConnectorIdVal; + } + return nodeConnectorIdStripped; } public static NodeId toAdNodeId(final NodeConnectorId nodeConnectorId) { @@ -133,21 +195,21 @@ public final class NodeMapping { } public static NodeConnectorId toControllerNodeConnectorId(final NodeId node) { - return new NodeConnectorId(node.getValue() + ":" + 4294967293L); + return new NodeConnectorId(node.getValue() + ":" + OutputPortValues.CONTROLLER.toString()); } public static NodeConnectorId toLocalNodeConnectorId(final NodeId node) { - return new NodeConnectorId(node.getValue() + ":" + 4294967294L); + return new NodeConnectorId(node.getValue() + ":" + OutputPortValues.LOCAL.toString()); } public static NodeConnectorId toNormalNodeConnectorId(final NodeId node) { - return new NodeConnectorId(node.getValue() + ":" + 4294967290L); + return new NodeConnectorId(node.getValue() + ":" + OutputPortValues.NORMAL.toString()); } public static NodeRef toNodeRef(final org.opendaylight.controller.sal.core.Node node) { - Preconditions.checkArgument(MD_SAL_TYPE.equals(node.getType())); - final String nodeId = Arguments.checkInstanceOf(node.getID(), String.class); - final NodeKey nodeKey = new NodeKey(new NodeId(nodeId)); + Preconditions.checkArgument(NodeIDType.OPENFLOW.equals(node.getType())); + final Long nodeId = Arguments.checkInstanceOf(node.getID(), Long.class); + final NodeKey nodeKey = new NodeKey(new NodeId(OPENFLOW_ID_PREFIX+nodeId)); final InstanceIdentifier nodePath = InstanceIdentifier.builder(Nodes.class).child(NODE_CLASS, nodeKey).toInstance(); return new NodeRef(nodePath); } @@ -170,7 +232,8 @@ public final class NodeMapping { nodeConnectorId = toControllerNodeConnectorId(nodeId); } } else { - nodeConnectorId = new NodeConnectorId(Arguments.checkInstanceOf(nodeConnector.getID(), String.class)); + nodeConnectorId = new NodeConnectorId(OPENFLOW_ID_PREFIX + + Arguments.checkInstanceOf(nodeConnector.getID(), Short.class)); } final NodeConnectorKey connectorKey = new NodeConnectorKey(nodeConnectorId); final InstanceIdentifier path = nodePath.child(NODECONNECTOR_CLASS, connectorKey); @@ -184,11 +247,27 @@ public final class NodeMapping { public static HashSet toADNodeConnectorProperties(final NodeConnectorUpdated nc) { final FlowCapableNodeConnectorUpdated fcncu = nc.getAugmentation(FlowCapableNodeConnectorUpdated.class); if (!Objects.equal(fcncu, null)) { - return NodeMapping.toADNodeConnectorProperties(fcncu); + HashSet adNodeConnectorProperties = NodeMapping.toADNodeConnectorProperties(fcncu); + return adNodeConnectorProperties; } return new HashSet(); } + /** + * @param id + * @return node description in AD form, e.g.: OF|00:00:00:...:01 + */ + private static Description toADDescription(NodeRef nodeRef) { + Description desc; + try { + desc = new Description(toADNode(nodeRef).toString()); + } catch (ConstructionException e) { + desc = new Description("none"); + LOG.warn("node description extraction failed: {}", nodeRef); + } + return desc; + } + public static HashSet toADNodeConnectorProperties(final NodeConnector nc) { final FlowCapableNodeConnector fcnc = nc.getAugmentation(FlowCapableNodeConnector.class); if (!Objects.equal(fcnc, null)) { @@ -303,7 +382,9 @@ public final class NodeMapping { public static HashSet toADNodeProperties(final NodeUpdated nu) { final FlowCapableNodeUpdated fcnu = nu.getAugmentation(FlowCapableNodeUpdated.class); if (fcnu != null) { - return toADNodeProperties(fcnu, nu.getId()); + HashSet adNodeProperties = toADNodeProperties(fcnu, nu.getId()); + adNodeProperties.add(toADDescription(nu.getNodeRef())); + return adNodeProperties; } return new HashSet(); } @@ -342,7 +423,7 @@ public final class NodeMapping { } public static MacAddress toADMacAddress(final NodeId id) { - final String nodeId = id.getValue().replaceAll("openflow:", ""); + final String nodeId = id.getValue().replaceAll(OPENFLOW_ID_PREFIX, ""); BigInteger nodeIdRaw = new BigInteger(nodeId); long lNodeId = nodeIdRaw.longValue(); byte[] bytesFromDpid = ToSalConversionsUtils.bytesFromDpid(lNodeId); diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java index 97a25bf71c..7bbf7f10e0 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java @@ -208,7 +208,8 @@ public class ToSalConversionsUtils { Uri nodeConnector = ((OutputActionCase) sourceAction).getOutputAction().getOutputNodeConnector(); if (nodeConnector != null) { //for (Uri uri : nodeConnectors) { - targetAction.add(new Output(fromNodeConnectorRef(nodeConnector, node))); + Uri fullNodeConnector = new Uri(node.getType()+":"+node.getID()+":"+nodeConnector.getValue()); + targetAction.add(new Output(fromNodeConnectorRef(fullNodeConnector, node))); //} } } else if (sourceAction instanceof PopMplsActionCase) { @@ -376,12 +377,19 @@ public class ToSalConversionsUtils { return null; } - private static NodeConnector fromNodeConnectorRef(Uri uri, Node node) { + /** + * @param openflow nodeConnector uri + * @param node + * @return assembled nodeConnector + */ + public static NodeConnector fromNodeConnectorRef(Uri uri, Node node) { NodeConnector nodeConnector = null; try { - nodeConnector = new NodeConnector(NodeMapping.MD_SAL_TYPE,node.getNodeIDString()+":"+uri.getValue(),node); + NodeConnectorId nodeConnectorId = new NodeConnectorId(uri.getValue()); + nodeConnector = NodeMapping.toADNodeConnector(nodeConnectorId, node); } catch (ConstructionException e) { - e.printStackTrace(); + LOG.warn("nodeConnector creation failed at node: {} with nodeConnectorUri: {}", + node, uri.getValue()); } return nodeConnector; } diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.java index 476a71a4ac..6bc669f60b 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyMapping.java @@ -18,7 +18,9 @@ import org.opendaylight.controller.sal.compatibility.NodeMapping; import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.core.Edge; import org.opendaylight.controller.sal.core.Node; +import org.opendaylight.controller.sal.core.Node.NodeIDType; import org.opendaylight.controller.sal.core.NodeConnector; +import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType; import org.opendaylight.controller.sal.core.Property; import org.opendaylight.controller.sal.core.UpdateType; import org.opendaylight.controller.sal.topology.TopoEdgeUpdate; @@ -93,20 +95,20 @@ public final class TopologyMapping { } public static String toADNodeId(final NodeId nodeId) { - return nodeId.getValue(); + return nodeId.getValue().replaceFirst("^.*:", ""); } public static NodeConnector toADNodeConnector(final TpId source, final NodeId nodeId) throws ConstructionException { checkNotNull(source); - return new NodeConnector(NodeMapping.MD_SAL_TYPE, toADNodeConnectorId(source), toADNode(nodeId)); + return new NodeConnector(NodeConnectorIDType.OPENFLOW, Short.valueOf(toADNodeConnectorId(source)), toADNode(nodeId)); } public static String toADNodeConnectorId(final TpId nodeConnectorId) { - return nodeConnectorId.getValue(); + return nodeConnectorId.getValue().replaceFirst("^.*:", ""); } public static Node toADNode(final NodeId nodeId) throws ConstructionException { checkNotNull(nodeId); - return new Node(NodeMapping.MD_SAL_TYPE, toADNodeId(nodeId)); + return new Node(NodeIDType.OPENFLOW, Long.valueOf(toADNodeId(nodeId))); } } diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/MDFlowMappingTest.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/MDFlowMappingTest.java new file mode 100644 index 0000000000..4e5f318d4c --- /dev/null +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/MDFlowMappingTest.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2014 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.compatibility.test; + +import junit.framework.Assert; + +import org.junit.Test; +import org.opendaylight.controller.sal.compatibility.MDFlowMapping; +import org.opendaylight.controller.sal.core.ConstructionException; +import org.opendaylight.controller.sal.core.Node; +import org.opendaylight.controller.sal.core.Node.NodeIDType; +import org.opendaylight.controller.sal.core.NodeConnector; +import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; + +/** + * test for {@link MDFlowMapping} + */ +public class MDFlowMappingTest { + + /** + * Test method for {@link org.opendaylight.controller.sal.compatibility.MDFlowMapping#toUri(org.opendaylight.controller.sal.core.NodeConnector)}. + * @throws ConstructionException + */ + @Test + public void testToUri() throws ConstructionException { + Node node = new Node(NodeIDType.OPENFLOW, 41L); + NodeConnector connector = new NodeConnector(NodeConnectorIDType.OPENFLOW, (short) 42, node); + Uri observed = MDFlowMapping.toUri(connector ); + + Assert.assertEquals("openflow:41:42", observed.getValue()); + } + +} diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/NodeMappingTest.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/NodeMappingTest.java index b418e6dc25..8a23ebc933 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/NodeMappingTest.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/NodeMappingTest.java @@ -10,9 +10,18 @@ package org.opendaylight.controller.sal.compatibility.test; import org.junit.Assert; import org.junit.Test; import org.opendaylight.controller.sal.compatibility.NodeMapping; +import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.core.MacAddress; +import org.opendaylight.controller.sal.core.Node.NodeIDType; +import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey; +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.yangtools.yang.binding.InstanceIdentifier; /** * test of {@link NodeMapping} utility class @@ -67,8 +76,118 @@ public class NodeMappingTest { observed = NodeMapping.toAdNodeId(null); Assert.assertNull(observed); - observed = NodeMapping.toAdNodeId(new NodeConnectorId("MD_SAL|openflow:5:2")); - Assert.assertEquals("MD_SAL|openflow:5", observed.getValue()); + observed = NodeMapping.toAdNodeId(new NodeConnectorId("openflow:5:2")); + Assert.assertEquals("openflow:5", observed.getValue()); } + /** + * Test method for + * {@link org.opendaylight.controller.sal.compatibility.NodeMapping#toADNode(NodeId)} + * . + */ + @Test + public void testToAdNode1() { + org.opendaylight.controller.sal.core.Node observed; + try { + observed = NodeMapping.toADNode((NodeId) null); + } catch (NullPointerException | ConstructionException e) { + //expected + } + + NodeId nodeId = new NodeId("openflow:1"); + try { + observed = NodeMapping.toADNode(nodeId); + Assert.assertEquals("OF|00:00:00:00:00:00:00:01", observed.toString()); + } catch (ConstructionException e) { + Assert.fail("should succeed to construct Node: "+e.getMessage()); + } + } + + /** + * Test method for + * {@link org.opendaylight.controller.sal.compatibility.NodeMapping#toNodeConnectorType(NodeConnectorId, NodeId)} + * . + */ + @Test + public void testToNodeConnectorType() { + NodeConnectorId ncId; + NodeId nodeId = buildNodeId("1"); + + ncId = buildNodeConnectorId("1", "42"); + Assert.assertEquals(NodeConnectorIDType.OPENFLOW, NodeMapping.toNodeConnectorType(ncId, nodeId )); + + ncId = buildNodeConnectorId("1", OutputPortValues.CONTROLLER.toString()); + Assert.assertEquals(NodeConnectorIDType.CONTROLLER, NodeMapping.toNodeConnectorType(ncId, nodeId )); + + ncId = buildNodeConnectorId("1", OutputPortValues.NORMAL.toString()); + Assert.assertEquals(NodeConnectorIDType.HWPATH, NodeMapping.toNodeConnectorType(ncId, nodeId )); + + ncId = buildNodeConnectorId("1", OutputPortValues.LOCAL.toString()); + Assert.assertEquals(NodeConnectorIDType.SWSTACK, NodeMapping.toNodeConnectorType(ncId, nodeId )); + } + + /** + * Test method for + * {@link org.opendaylight.controller.sal.compatibility.NodeMapping#toADNodeConnectorId(NodeConnectorId, NodeId)} + * . + */ + @Test + public void testToAdNodeConnectorId() { + NodeConnectorId nodeConnectorId = buildNodeConnectorId("1", "2"); + NodeId nodeId = buildNodeId("1"); + Assert.assertEquals(Short.valueOf((short) 2), NodeMapping.toADNodeConnectorId(nodeConnectorId , nodeId)); + } + + /** + * Test method for + * {@link org.opendaylight.controller.sal.compatibility.NodeMapping#toNodeRef(Node)} + * . + * @throws ConstructionException + */ + @Test + public void testToNodeRef() throws ConstructionException { + org.opendaylight.controller.sal.core.Node node = new org.opendaylight.controller.sal.core.Node(NodeIDType.OPENFLOW, 42L); + InstanceIdentifier nodePath = NodeMapping.toNodeRef(node).getValue(); + + String observedId = nodePath.firstKeyOf(Node.class, NodeKey.class).getId().getValue(); + Assert.assertEquals("openflow:42", observedId); + } + + /** + * Test method for + * {@link org.opendaylight.controller.sal.compatibility.NodeMapping#toNodeConnectorRef(org.opendaylight.controller.sal.core.NodeConnector)} + * . + * @throws ConstructionException + */ + @Test + public void testToNodeConnectorRef() throws ConstructionException { + org.opendaylight.controller.sal.core.Node node = new org.opendaylight.controller.sal.core.Node(NodeIDType.OPENFLOW, 42L); + org.opendaylight.controller.sal.core.NodeConnector nodeConnector = + new org.opendaylight.controller.sal.core.NodeConnector( + NodeConnectorIDType.OPENFLOW, (short) 1, node); + + InstanceIdentifier nodeConnectorPath = NodeMapping.toNodeConnectorRef(nodeConnector ).getValue(); + String observedNodeId = nodeConnectorPath.firstKeyOf(Node.class, NodeKey.class).getId().getValue(); + Assert.assertEquals("openflow:42", observedNodeId); + + String observedNodeConnectorId = nodeConnectorPath.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue(); + Assert.assertEquals("openflow:1", observedNodeConnectorId); + } + + /** + * @param nodeId + * @param portId + * @return nodeConnectorId + */ + public static NodeConnectorId buildNodeConnectorId(String nodeId, String portId) { + return new NodeConnectorId(NodeConnectorIDType.OPENFLOW+"|" + nodeId + ":" + portId); + } + + /** + * @param id + * @return nodeId + */ + public static NodeId buildNodeId(String id) { + return new NodeId(NodeConnectorIDType.OPENFLOW+"|" + id); + } } diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java index 4d3509769c..0157bc0c64 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java @@ -22,6 +22,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import junit.framework.Assert; + import org.junit.Test; import org.opendaylight.controller.sal.action.Flood; import org.opendaylight.controller.sal.action.FloodAll; @@ -47,6 +49,7 @@ import org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils; import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.Node.NodeIDType; +import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.flowprogrammer.Flow; import org.opendaylight.controller.sal.match.MatchType; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; @@ -182,6 +185,17 @@ public class TestToSalConversionsUtils { checkSalFlow(salFlow); } + /** + * test of {@link ToSalConversionsUtils#fromNodeConnectorRef(Uri, Node)} + * @throws ConstructionException + */ + @Test + public void testFromNodeConnectorRef() throws ConstructionException { + Node node = new Node(NodeIDType.OPENFLOW, 42L); + NodeConnector nodeConnector = ToSalConversionsUtils.fromNodeConnectorRef(new Uri("1"), node); + Assert.assertEquals("OF|1@OF|00:00:00:00:00:00:00:2a", nodeConnector.toString()); + } + private void checkSalMatch(org.opendaylight.controller.sal.match.Match match, MtchType mt) { switch (mt) { case other: diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/topology/test/TopologyMappingTest.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/topology/test/TopologyMappingTest.java new file mode 100644 index 0000000000..b76370a538 --- /dev/null +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/topology/test/TopologyMappingTest.java @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2014 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.compatibility.topology.test; + +import junit.framework.Assert; + +import org.junit.Test; +import org.opendaylight.controller.sal.compatibility.topology.TopologyMapping; +import org.opendaylight.controller.sal.core.ConstructionException; +import org.opendaylight.controller.sal.core.Node; +import org.opendaylight.controller.sal.core.NodeConnector; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId; + +/** + * test for {@link TopologyMapping} + */ +public class TopologyMappingTest { + + /** + * Test method for {@link org.opendaylight.controller.sal.compatibility.topology.TopologyMapping#toADNodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)}. + */ + @Test + public void testToADNodeId() { + NodeId nodeId = new NodeId("openflow:1"); + String observedNodeId = TopologyMapping.toADNodeId(nodeId); + + Assert.assertEquals("1", observedNodeId); + } + + /** + * Test method for {@link org.opendaylight.controller.sal.compatibility.topology.TopologyMapping#toADNodeConnector(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId, org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)}. + * @throws ConstructionException + */ + @Test + public void testToADNodeConnector() throws ConstructionException { + NodeId nodeId = new NodeId("openflow:1"); + TpId source = new TpId("foo:2"); + NodeConnector observedNodeConnector = TopologyMapping.toADNodeConnector(source, nodeId); + + Assert.assertEquals("OF|2@OF|00:00:00:00:00:00:00:01", observedNodeConnector.toString()); + } + + /** + * Test method for {@link org.opendaylight.controller.sal.compatibility.topology.TopologyMapping#toADNodeConnectorId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)}. + */ + @Test + public void testToADNodeConnectorId() { + TpId source = new TpId("foo:2"); + String observedNodeConnectorId = TopologyMapping.toADNodeConnectorId(source); + + Assert.assertEquals("2", observedNodeConnectorId); + } + + /** + * Test method for {@link org.opendaylight.controller.sal.compatibility.topology.TopologyMapping#toADNode(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)}. + * @throws ConstructionException + */ + @Test + public void testToADNode() throws ConstructionException { + NodeId nodeId = new NodeId("openflow:1"); + Node observedNode = TopologyMapping.toADNode(nodeId); + + Assert.assertEquals("OF|00:00:00:00:00:00:00:01", observedNode.toString()); + } + +} diff --git a/opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-match-types.yang b/opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-match-types.yang index efe1ce3e3a..deff6f1798 100644 --- a/opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-match-types.yang +++ b/opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-match-types.yang @@ -275,6 +275,17 @@ module opendaylight-match-types { } } + grouping "tunnel-ipv4-match-fields" { + leaf tunnel-ipv4-source { + description "IPv4 source tunnel endpoint address."; + type inet:ipv4-prefix; + } + leaf tunnel-ipv4-destination { + description "IPv4 destination tunnel endpoint address."; + type inet:ipv4-prefix; + } + } + grouping match { leaf in-port { type inv:node-connector-id; @@ -321,6 +332,9 @@ module opendaylight-match-types { case "arp-match" { uses "arp-match-fields"; } + case "tunnel-ipv4-match" { + uses "tunnel-ipv4-match-fields"; + } } choice layer-4-match { diff --git a/opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-port-types.yang b/opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-port-types.yang index f1cbd8dc29..9e88098752 100644 --- a/opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-port-types.yang +++ b/opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-port-types.yang @@ -62,7 +62,10 @@ module opendaylight-port-types { grouping common-port { leaf port-number { - type uint32; + type union { + type uint32; + type string; + } } leaf hardware-address { diff --git a/opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-table-types.yang b/opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-table-types.yang index c271f8f4d0..393f6db9fe 100644 --- a/opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-table-types.yang +++ b/opendaylight/md-sal/model/model-flow-base/src/main/yang/opendaylight-table-types.yang @@ -192,6 +192,14 @@ module opendaylight-table-types { base match-field; description "TCP Flag Match"; } + identity tunnel_ipv4_dst { + base match-field; + description "IPv4 destination tunnel endpoint address."; + } + identity tunnel_ipv4_src { + base match-field; + description "IPv4 source tunnel endpoint address."; + } grouping set-field-match { list set-field-match { diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index 174f635a13..24dcfad02b 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -57,8 +57,14 @@ sal-rest-docgen - - feature + + sal-inmemory-datastore + + + sal-protocolbuffer-encoding + + + feature diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataBroker.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataBroker.java similarity index 51% rename from opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataBroker.java rename to opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataBroker.java index 7eee5c8b62..0b3658a6a6 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataBroker.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataBroker.java @@ -13,17 +13,23 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public interface BindingDataBroker extends AsyncDataBroker, DataObject, BindingDataChangeListener>, BindingService { +/** + * Provides access to a conceptual data tree store and also provides the ability to + * subscribe for changes to data under a given branch of the tree. + *

+ * For more information on usage, please see the documentation in {@link AsyncDataBroker}. + */ +public interface DataBroker extends AsyncDataBroker, DataObject, DataChangeListener>, BindingService { @Override - BindingDataReadTransaction newReadOnlyTransaction(); + ReadOnlyTransaction newReadOnlyTransaction(); @Override - BindingDataReadWriteTransaction newReadWriteTransaction(); + ReadWriteTransaction newReadWriteTransaction(); @Override - BindingDataWriteTransaction newWriteOnlyTransaction(); + WriteTransaction newWriteOnlyTransaction(); @Override - ListenerRegistration registerDataChangeListener(LogicalDatastoreType store, - InstanceIdentifier path, BindingDataChangeListener listener, DataChangeScope triggeringScope); + ListenerRegistration registerDataChangeListener(LogicalDatastoreType store, + InstanceIdentifier path, DataChangeListener listener, DataChangeScope triggeringScope); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataChangeListener.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataChangeListener.java similarity index 87% rename from opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataChangeListener.java rename to opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataChangeListener.java index 94ac2d21a3..65257a328a 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataChangeListener.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/DataChangeListener.java @@ -12,7 +12,7 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListene import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public interface BindingDataChangeListener extends AsyncDataChangeListener, DataObject> { +public interface DataChangeListener extends AsyncDataChangeListener, DataObject> { @Override void onDataChanged(AsyncDataChangeEvent, DataObject> change); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadOnlyTransaction.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadOnlyTransaction.java new file mode 100644 index 0000000000..f3b42b96f0 --- /dev/null +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadOnlyTransaction.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2014 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.md.sal.binding.api; + +import org.opendaylight.controller.md.sal.common.api.data.AsyncReadOnlyTransaction; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +/** + * A transaction that provides a stateful read-only view of the data tree. + *

+ * For more information on usage and examples, please see the documentation in + * {@link org.opendaylight.controller.md.sal.common.api.data.AsyncReadTransaction}. + */ +public interface ReadOnlyTransaction extends ReadTransaction, AsyncReadOnlyTransaction, DataObject> { + +} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataReadTransaction.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadTransaction.java similarity index 88% rename from opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataReadTransaction.java rename to opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadTransaction.java index 93df3eb1e2..a7b5f32957 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataReadTransaction.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadTransaction.java @@ -15,7 +15,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import com.google.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; -public interface BindingDataReadTransaction extends AsyncReadTransaction, DataObject> { +public interface ReadTransaction extends AsyncReadTransaction, DataObject> { @Override ListenableFuture> read(LogicalDatastoreType store, InstanceIdentifier path); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataReadWriteTransaction.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadWriteTransaction.java similarity index 64% rename from opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataReadWriteTransaction.java rename to opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadWriteTransaction.java index 0dcf020c37..9fbbbe5a73 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataReadWriteTransaction.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/ReadWriteTransaction.java @@ -12,9 +12,10 @@ import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** - * Logical capture of a combination of both {@link BindingDataReadTransaction} and - * {@link BindingDataWriteTransaction}. + * A transaction that enables combined read/write capabilities. + *

+ * For more information on usage and examples, please see the documentation in {@link AsyncReadWriteTransaction}. */ -public interface BindingDataReadWriteTransaction extends BindingDataReadTransaction, BindingDataWriteTransaction, AsyncReadWriteTransaction, DataObject> { +public interface ReadWriteTransaction extends ReadTransaction, WriteTransaction, AsyncReadWriteTransaction, DataObject> { } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataWriteTransaction.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/WriteTransaction.java similarity index 74% rename from opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataWriteTransaction.java rename to opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/WriteTransaction.java index e989f73f39..0cef81d359 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/BindingDataWriteTransaction.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/md/sal/binding/api/WriteTransaction.java @@ -12,7 +12,12 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public interface BindingDataWriteTransaction extends AsyncWriteTransaction, DataObject> { +/** + * A transaction that provides mutation capabilities on a data tree. + *

+ * For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}. + */ +public interface WriteTransaction extends AsyncWriteTransaction, DataObject> { @Override void put(LogicalDatastoreType store, InstanceIdentifier path, DataObject data); diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java index 6e8bda56d8..46e372aea6 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java @@ -7,7 +7,7 @@ */ package org.opendaylight.controller.sal.binding.api; -import org.opendaylight.yangtools.concepts.Registration; +import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.Notification; public interface NotificationService extends BindingAwareService { @@ -16,9 +16,9 @@ public interface NotificationService extends BindingAwareService { * * @param notificationType * @param listener - * @return Registration for listener. To unregister listener invoke {@link Registration#close()} method. + * @return Registration for listener. To unregister listener invoke {@link ListenerRegistration#close()} method. */ - Registration> registerNotificationListener( + ListenerRegistration> registerNotificationListener( Class notificationType, NotificationListener listener); /** @@ -27,8 +27,8 @@ public interface NotificationService extends BindingAwareService { * Listener is registered for all notifications present in implemented interfaces. * * @param listener - * @return Registration for listener. To unregister listener invoke {@link Registration#close()} method. + * @return Registration for listener. To unregister listener invoke {@link ListenerRegistration#close()} method. */ - Registration registerNotificationListener( + ListenerRegistration registerNotificationListener( org.opendaylight.yangtools.yang.binding.NotificationListener listener); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java index b09cd1c80a..f24809de45 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedDataBroker.java @@ -14,7 +14,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import org.opendaylight.controller.md.sal.binding.api.BindingDataChangeListener; +import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -83,8 +83,8 @@ public abstract class AbstractForwardedDataBroker implements Delegator registerDataChangeListener(final LogicalDatastoreType store, - final InstanceIdentifier path, final BindingDataChangeListener listener, + public ListenerRegistration registerDataChangeListener(final LogicalDatastoreType store, + final InstanceIdentifier path, final DataChangeListener listener, final DataChangeScope triggeringScope) { DOMDataChangeListener domDataChangeListener = new TranslatingDataChangeInvoker(store, path, listener, triggeringScope); @@ -143,13 +143,13 @@ public abstract class AbstractForwardedDataBroker implements Delegator path; private final DataChangeScope triggeringScope; public TranslatingDataChangeInvoker(final LogicalDatastoreType store, final InstanceIdentifier path, - final BindingDataChangeListener bindingDataChangeListener, final DataChangeScope triggeringScope) { + final DataChangeListener bindingDataChangeListener, final DataChangeScope triggeringScope) { this.store = store; this.path = path; this.bindingDataChangeListener = bindingDataChangeListener; @@ -250,10 +250,10 @@ public abstract class AbstractForwardedDataBroker implements Delegator { + private static class ListenerRegistrationImpl extends AbstractListenerRegistration { private final ListenerRegistration registration; - public ListenerRegistrationImpl(final BindingDataChangeListener listener, + public ListenerRegistrationImpl(final DataChangeListener listener, final ListenerRegistration registration) { super(listener); this.registration = registration; diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java index a935a33a5e..3fac0dc93a 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/AbstractForwardedTransaction.java @@ -180,8 +180,8 @@ public class AbstractForwardedTransaction> doRead(final DOMDataReadTransaction readTransaction, diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java index bf18454f4d..49d04d04b3 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBackwardsCompatibleDataBroker.java @@ -18,7 +18,6 @@ import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; -import org.opendaylight.controller.md.sal.binding.api.BindingDataChangeListener; import org.opendaylight.controller.md.sal.common.api.RegistrationListener; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; @@ -113,11 +112,11 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat final InstanceIdentifier path, final DataChangeListener listener) { - BindingDataChangeListener asyncOperListener = new BackwardsCompatibleOperationalDataChangeInvoker(listener); - BindingDataChangeListener asyncCfgListener = new BackwardsCompatibleConfigurationDataChangeInvoker(listener); + org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncOperListener = new BackwardsCompatibleOperationalDataChangeInvoker(listener); + org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncCfgListener = new BackwardsCompatibleConfigurationDataChangeInvoker(listener); - ListenerRegistration cfgReg = registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, asyncCfgListener, DataChangeScope.SUBTREE); - ListenerRegistration operReg = registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, path, asyncOperListener, DataChangeScope.SUBTREE); + ListenerRegistration cfgReg = registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, asyncCfgListener, DataChangeScope.SUBTREE); + ListenerRegistration operReg = registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, path, asyncOperListener, DataChangeScope.SUBTREE); return new LegacyListenerRegistration(listener,cfgReg,operReg); } @@ -387,12 +386,12 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat private static final class LegacyListenerRegistration implements ListenerRegistration { private final DataChangeListener instance; - private final ListenerRegistration cfgReg; - private final ListenerRegistration operReg; + private final ListenerRegistration cfgReg; + private final ListenerRegistration operReg; public LegacyListenerRegistration(final DataChangeListener listener, - final ListenerRegistration cfgReg, - final ListenerRegistration operReg) { + final ListenerRegistration cfgReg, + final ListenerRegistration operReg) { this.instance = listener; this.cfgReg = cfgReg; this.operReg = operReg; @@ -411,7 +410,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat } - private static class BackwardsCompatibleOperationalDataChangeInvoker implements BindingDataChangeListener, Delegator { + private static class BackwardsCompatibleOperationalDataChangeInvoker implements org.opendaylight.controller.md.sal.binding.api.DataChangeListener, Delegator { private final org.opendaylight.controller.md.sal.common.api.data.DataChangeListener delegate; @@ -436,7 +435,7 @@ public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDat } - private static class BackwardsCompatibleConfigurationDataChangeInvoker implements BindingDataChangeListener, Delegator { + private static class BackwardsCompatibleConfigurationDataChangeInvoker implements org.opendaylight.controller.md.sal.binding.api.DataChangeListener, Delegator { private final org.opendaylight.controller.md.sal.common.api.data.DataChangeListener delegate; public BackwardsCompatibleConfigurationDataChangeInvoker(final DataChangeListener listener) { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBindingDataBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBindingDataBroker.java index 5ab088e20e..5b008ad4bc 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBindingDataBroker.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ForwardedBindingDataBroker.java @@ -7,15 +7,16 @@ */ package org.opendaylight.controller.md.sal.binding.impl; -import org.opendaylight.controller.md.sal.binding.api.BindingDataBroker; -import org.opendaylight.controller.md.sal.binding.api.BindingDataReadTransaction; -import org.opendaylight.controller.md.sal.binding.api.BindingDataReadWriteTransaction; -import org.opendaylight.controller.md.sal.binding.api.BindingDataWriteTransaction; + +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; +import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.controller.sal.core.api.model.SchemaService; @@ -40,24 +41,25 @@ import com.google.common.util.concurrent.ListenableFuture; * NormalizedNode once the MappingService is updated * */ -public class ForwardedBindingDataBroker extends AbstractForwardedDataBroker implements BindingDataBroker { +public class ForwardedBindingDataBroker extends AbstractForwardedDataBroker implements DataBroker { public ForwardedBindingDataBroker(final DOMDataBroker domDataBroker, final BindingIndependentMappingService mappingService, final SchemaService schemaService) { super(domDataBroker, mappingService,schemaService); } @Override - public BindingDataReadTransaction newReadOnlyTransaction() { + + public ReadOnlyTransaction newReadOnlyTransaction() { return new BindingDataReadTransactionImpl(getDelegate().newReadOnlyTransaction(),getCodec()); } @Override - public BindingDataReadWriteTransaction newReadWriteTransaction() { + public ReadWriteTransaction newReadWriteTransaction() { return new BindingDataReadWriteTransactionImpl(getDelegate().newReadWriteTransaction(),getCodec()); } @Override - public BindingDataWriteTransaction newWriteOnlyTransaction() { + public WriteTransaction newWriteOnlyTransaction() { return new BindingDataWriteTransactionImpl(getDelegate().newWriteOnlyTransaction(),getCodec()); } @@ -73,17 +75,13 @@ public class ForwardedBindingDataBroker extends AbstractForwardedDataBroker impl return getDelegate().getIdentifier(); } - @Override - public void close() { - getDelegate().close(); - } - } - private class BindingDataReadTransactionImpl extends AbstractBindingTransaction implements - BindingDataReadTransaction { - protected BindingDataReadTransactionImpl(final DOMDataReadTransaction delegate, + private class BindingDataReadTransactionImpl extends AbstractBindingTransaction implements + ReadOnlyTransaction { + + protected BindingDataReadTransactionImpl(final DOMDataReadOnlyTransaction delegate, final BindingToNormalizedNodeCodec codec) { super(delegate, codec); } @@ -93,10 +91,15 @@ public class ForwardedBindingDataBroker extends AbstractForwardedDataBroker impl final InstanceIdentifier path) { return doRead(getDelegate(), store, path); } + + @Override + public void close() { + getDelegate().close(); + } } private class BindingDataWriteTransactionImpl extends - AbstractBindingTransaction implements BindingDataWriteTransaction { + AbstractBindingTransaction implements WriteTransaction { protected BindingDataWriteTransactionImpl(final T delegate, final BindingToNormalizedNodeCodec codec) { super(delegate, codec); @@ -104,8 +107,8 @@ public class ForwardedBindingDataBroker extends AbstractForwardedDataBroker impl } @Override - public void cancel() { - doCancel(getDelegate()); + public boolean cancel() { + return doCancel(getDelegate()); } @Override @@ -130,7 +133,7 @@ public class ForwardedBindingDataBroker extends AbstractForwardedDataBroker impl } private class BindingDataReadWriteTransactionImpl extends - BindingDataWriteTransactionImpl implements BindingDataReadWriteTransaction { + BindingDataWriteTransactionImpl implements ReadWriteTransaction { protected BindingDataReadWriteTransactionImpl(final DOMDataReadWriteTransaction delegate, final BindingToNormalizedNodeCodec codec) { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java index 8acad1b2d7..d810149c70 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.sal.binding.impl; import static com.google.common.base.Preconditions.checkState; -import org.opendaylight.controller.md.sal.binding.api.BindingDataBroker; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.util.AbstractBindingSalProviderInstance; import org.opendaylight.controller.md.sal.binding.util.BindingContextUtils; import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener; @@ -54,7 +54,7 @@ public class RootBindingAwareBroker implements // private DataProviderService legacyDataBroker; - private BindingDataBroker dataBroker; + private DataBroker dataBroker; private MountPointManagerImpl mountManager; @@ -124,7 +124,7 @@ public class RootBindingAwareBroker implements // consBuilder.put(DataBrokerService.class, getRoot()); consBuilder.put(RpcConsumerRegistry.class, getRoot()); if(dataBroker != null) { - consBuilder.put(BindingDataBroker.class, dataBroker); + consBuilder.put(DataBroker.class, dataBroker); } consBuilder.put(MountService.class, mountManager).build(); supportedConsumerServices = consBuilder.build(); @@ -183,7 +183,7 @@ public class RootBindingAwareBroker implements // } } - public void setDataBroker(final BindingDataBroker asyncDataBroker) { + public void setDataBroker(final DataBroker asyncDataBroker) { dataBroker = asyncDataBroker; } } diff --git a/opendaylight/md-sal/sal-binding-config/src/main/yang/opendaylight-md-sal-binding.yang b/opendaylight/md-sal/sal-binding-config/src/main/yang/opendaylight-md-sal-binding.yang index 4a2ec8a063..8636ff613b 100644 --- a/opendaylight/md-sal/sal-binding-config/src/main/yang/opendaylight-md-sal-binding.yang +++ b/opendaylight/md-sal/sal-binding-config/src/main/yang/opendaylight-md-sal-binding.yang @@ -25,7 +25,7 @@ module opendaylight-md-sal-binding { identity binding-async-data-broker { base "config:service-type"; - config:java-class "org.opendaylight.controller.md.sal.binding.api.BindingDataBroker"; + config:java-class "org.opendaylight.controller.md.sal.binding.api.DataBroker"; } identity binding-data-consumer-broker { diff --git a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ListProcessingAndOrderingTest.java b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ListProcessingAndOrderingTest.java index 800c1b4cc4..667887ac80 100644 --- a/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ListProcessingAndOrderingTest.java +++ b/opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/md/sal/binding/data/ListProcessingAndOrderingTest.java @@ -20,7 +20,7 @@ import java.util.concurrent.ExecutionException; import org.junit.Test; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.store.rev140422.Lists; @@ -139,7 +139,7 @@ public class ListProcessingAndOrderingTest extends AbstractDataServiceTest { private NormalizedNode resolveDataAsserted( final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath) { - try (DOMDataReadTransaction readTx = testContext.getDomAsyncDataBroker().newReadOnlyTransaction()){ + try (DOMDataReadOnlyTransaction readTx = testContext.getDomAsyncDataBroker().newReadOnlyTransaction()){ ListenableFuture>> data = readTx.read(LogicalDatastoreType.OPERATIONAL, domPath); Optional> potential = data.get(); assertTrue(potential.isPresent()); diff --git a/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java b/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java index a15c711e2d..5ede600d97 100644 --- a/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java +++ b/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java @@ -119,7 +119,7 @@ public class TestHelper { mavenBundle(CONTROLLER, "sal-common-util").versionAsInProject(), // // - + mavenBundle(CONTROLLER, "sal-inmemory-datastore").versionAsInProject(), // / mavenBundle(CONTROLLER, "sal-broker-impl").versionAsInProject(), // // mavenBundle(CONTROLLER, "sal-core-spi").versionAsInProject().update(), // diff --git a/opendaylight/md-sal/sal-binding-it/src/test/resources/controller.xml b/opendaylight/md-sal/sal-binding-it/src/test/resources/controller.xml index 37ef257224..63a921d6f3 100644 --- a/opendaylight/md-sal/sal-binding-it/src/test/resources/controller.xml +++ b/opendaylight/md-sal/sal-binding-it/src/test/resources/controller.xml @@ -20,7 +20,6 @@ urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24 - urn:ietf:params:netconf:capability:rollback-on-error:1.0 urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24 diff --git a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java b/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java index 7d7e56dae0..53abd39cde 100644 --- a/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java +++ b/opendaylight/md-sal/sal-binding-util/src/main/java/org/opendaylight/controller/md/sal/binding/util/AbstractBindingSalConsumerInstance.java @@ -14,7 +14,6 @@ import org.opendaylight.controller.sal.binding.api.data.DataBrokerService; import org.opendaylight.controller.sal.binding.api.data.DataChangeListener; import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction; import org.opendaylight.yangtools.concepts.ListenerRegistration; -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.Notification; @@ -72,13 +71,13 @@ public abstract class AbstractBindingSalConsumerInstance Registration> registerNotificationListener( + public ListenerRegistration> registerNotificationListener( Class notificationType, NotificationListener listener) { return getNotificationBrokerChecked().registerNotificationListener(notificationType, listener); } @Override - public Registration registerNotificationListener( + public ListenerRegistration registerNotificationListener( org.opendaylight.yangtools.yang.binding.NotificationListener listener) { return getNotificationBrokerChecked().registerNotificationListener(listener); } diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataBroker.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataBroker.java index fb429e5fd1..3a68092f07 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataBroker.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataBroker.java @@ -12,14 +12,11 @@ import org.opendaylight.yangtools.concepts.Path; /** * - * Provides access to a conceptual data tree store. + * Base interface that provides access to a conceptual data tree store and also provides the ability to + * subscribe for changes to data under a given branch of the tree. * *

- * Also provides the ability to subscribe for changes to data under a given - * branch of the tree. - * - *

- * All operations on data tree are performed via one of the transactions: + * All operations on the data tree are performed via one of the transactions: *

    *
  • Read-Only - allocated using {@link #newReadOnlyTransaction()} *
  • Write-Only - allocated using {@link #newWriteOnlyTransaction()} @@ -133,7 +130,7 @@ public interface AsyncDataBroker

    , D, L extends AsyncDataChange * {@inheritDoc} */ @Override - public AsyncReadTransaction newReadOnlyTransaction(); + public AsyncReadOnlyTransaction newReadOnlyTransaction(); /** * {@inheritDoc} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataTransactionFactory.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataTransactionFactory.java index cedd883b22..a558b96b2d 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataTransactionFactory.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncDataTransactionFactory.java @@ -72,7 +72,7 @@ public interface AsyncDataTransactionFactory

    , D> { * * @return new read-only transaction */ - AsyncReadTransaction newReadOnlyTransaction(); + AsyncReadOnlyTransaction newReadOnlyTransaction(); /** * Allocates new read-write transaction which provides a mutable view of the data diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadOnlyTransaction.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadOnlyTransaction.java new file mode 100644 index 0000000000..4beb5c62e3 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadOnlyTransaction.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014 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.md.sal.common.api.data; + +import org.opendaylight.yangtools.concepts.Path; + +/** + * Read-only transaction, which provides stable view of data + * and is {@link AutoCloseable} resource. + * + * @see AsyncReadTransaction + * +* @param

    + * Type of path (subtree identifier), which represents location in + * tree + * @param + * Type of data (payload), which represents data payload + */ +public interface AsyncReadOnlyTransaction

    , D> extends AsyncReadTransaction, AutoCloseable { + + /** + * Closes this transaction and releases all resources associated with it. + * + */ + @Override + public void close(); +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadTransaction.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadTransaction.java index 6cf5a5b532..e1cd4a712a 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadTransaction.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadTransaction.java @@ -14,7 +14,7 @@ import com.google.common.util.concurrent.ListenableFuture; /** * - * Provides a stateful read-only view of the data tree. + * Provides a stateful read view of the data tree. * *

    * View of the data tree is a stable point-in-time snapshot of the current data tree state when @@ -25,8 +25,8 @@ import com.google.common.util.concurrent.ListenableFuture; * Implementation Note: This interface is not intended to be implemented * by users of MD-SAL, but only to be consumed by them. * - *

    Transaction isolation example

    Lest assume initial state of data tree - * for PATH is A. + *

    Transaction isolation example

    + * Lets assume initial state of data tree for PATH is A. * *
      * txRead = broker.newReadOnlyTransaction();   // read Transaction is snapshot of data
    diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadWriteTransaction.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadWriteTransaction.java
    index 34101366c8..16b4ed4fe2 100644
    --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadWriteTransaction.java
    +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncReadWriteTransaction.java
    @@ -124,6 +124,8 @@ import org.opendaylight.yangtools.concepts.Path;
      * or other functions from {@link com.google.common.util.concurrent.Futures} to
      * register more specific listeners.
      *
    + * @see AsyncReadTransaction
    + * @see AsyncWriteTransaction
      *
      * @param 

    * Type of path (subtree identifier), which represents location in diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncTransaction.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncTransaction.java index c7cc91528b..08ddfe6898 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncTransaction.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncTransaction.java @@ -29,15 +29,10 @@ import org.opendaylight.yangtools.concepts.Path; * @param Type of data (payload), which represents data payload */ public interface AsyncTransaction

    ,D> extends // - Identifiable, - AutoCloseable { + Identifiable { @Override public Object getIdentifier(); - /** - * Closes transaction and releases all resources associated with it. - */ - @Override - public void close(); + } diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncWriteTransaction.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncWriteTransaction.java index e2734eaddc..f7eae27320 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncWriteTransaction.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncWriteTransaction.java @@ -53,13 +53,19 @@ public interface AsyncWriteTransaction

    , D> extends AsyncTransa * {@link TransactionStatus#NEW} or {@link TransactionStatus#SUBMITED} * * Invoking cancel() on {@link TransactionStatus#FAILED} or - * {@link TransactionStatus#CANCELED} will have no effect. + * {@link TransactionStatus#CANCELED} will have no effect, and transaction + * is considered cancelled. * - * @throws IllegalStateException - * If transaction status is {@link TransactionStatus#COMMITED} + * Invoking cancel() on finished transaction (future returned by {@link #commit()} + * already completed with {@link TransactionStatus#COMMITED}) will always + * fail (return false). + * + * @return false if the task could not be cancelled, + * typically because it has already completed normally; + * true otherwise * */ - public void cancel(); + public boolean cancel(); /** * Store a piece of data at specified path. This acts as an add / replace @@ -141,20 +147,6 @@ public interface AsyncWriteTransaction

    , D> extends AsyncTransa */ public void delete(LogicalDatastoreType store, P path); - /** - * - * Closes transaction and resources allocated to the transaction. - * - * This call does not change Transaction status. Client SHOULD explicitly - * {@link #commit()} or {@link #cancel()} transaction. - * - * @throws IllegalStateException - * if the transaction has not been updated by invoking - * {@link #commit()} or {@link #cancel()}. - */ - @Override - public void close(); - /** * Submits transaction to be applied to update logical data tree. *

    diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChain.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChain.java index e7e0eb0ff8..940559ef89 100644 --- a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChain.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/TransactionChain.java @@ -27,7 +27,7 @@ public interface TransactionChain

    , D> extends AutoCloseable, A * @throws TransactionChainClosedException if the chain has been closed. */ @Override - public AsyncReadTransaction newReadOnlyTransaction(); + public AsyncReadOnlyTransaction newReadOnlyTransaction(); /** diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java index c120508f87..613cf1bfe2 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataBroker.java @@ -29,7 +29,7 @@ public interface DOMDataBroker extends * {@inheritDoc} */ @Override - DOMDataReadTransaction newReadOnlyTransaction(); + DOMDataReadOnlyTransaction newReadOnlyTransaction(); /** * {@inheritDoc} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java new file mode 100644 index 0000000000..18fb988661 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMDataReadOnlyTransaction.java @@ -0,0 +1,9 @@ +package org.opendaylight.controller.md.sal.dom.api; + +import org.opendaylight.controller.md.sal.common.api.data.AsyncReadOnlyTransaction; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; + +public interface DOMDataReadOnlyTransaction extends DOMDataReadTransaction, AsyncReadOnlyTransaction> { + +} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMTransactionChain.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMTransactionChain.java index b894911ffa..73a0c28465 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMTransactionChain.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMTransactionChain.java @@ -24,7 +24,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public interface DOMTransactionChain extends TransactionChain> { @Override - DOMDataReadTransaction newReadOnlyTransaction(); + DOMDataReadOnlyTransaction newReadOnlyTransaction(); @Override DOMDataReadWriteTransaction newReadWriteTransaction(); diff --git a/opendaylight/md-sal/sal-dom-broker/pom.xml b/opendaylight/md-sal/sal-dom-broker/pom.xml index bac9146bf5..022882fceb 100644 --- a/opendaylight/md-sal/sal-dom-broker/pom.xml +++ b/opendaylight/md-sal/sal-dom-broker/pom.xml @@ -42,6 +42,12 @@ org.opendaylight.controller sal-core-spi + + org.opendaylight.controller + sal-inmemory-datastore + 1.1-SNAPSHOT + + org.opendaylight.yangtools util @@ -88,8 +94,6 @@ org.opendaylight.controller.config.yang.md.sal.dom.statistics, org.opendaylight.controller.md.sal.dom.broker.impl, org.opendaylight.controller.md.sal.dom.broker.impl.*, - org.opendaylight.controller.md.sal.dom.store.impl, - org.opendaylight.controller.md.sal.dom.store.impl.*, org.opendaylight.yangtools.yang.util, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.dom.impl.rev131028.* * diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java index ad0de54bc0..d3852d28c5 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java @@ -7,9 +7,9 @@ */ package org.opendaylight.controller.config.yang.md.sal.dom.impl; -import java.util.Hashtable; -import java.util.concurrent.Executors; - +import com.google.common.collect.ImmutableMap; +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl; @@ -17,9 +17,8 @@ import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; import org.opendaylight.controller.sal.core.spi.data.DOMStore; import org.osgi.framework.BundleContext; -import com.google.common.collect.ImmutableMap; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; +import java.util.Hashtable; +import java.util.concurrent.Executors; /** * @@ -49,8 +48,22 @@ public final class DomInmemoryDataBrokerModule extends @Override public java.lang.AutoCloseable createInstance() { ListeningExecutorService storeExecutor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(2)); - InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("DOM-OPER", storeExecutor); - InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("DOM-CFG", storeExecutor); + //Initializing Operational DOM DataStore defaulting to InMemoryDOMDataStore if one is not configured + DOMStore operStore = getOperationalDataStoreDependency(); + if(operStore == null){ + //we will default to InMemoryDOMDataStore creation + operStore = new InMemoryDOMDataStore("DOM-OPER", storeExecutor); + //here we will register the SchemaContext listener + getSchemaServiceDependency().registerSchemaServiceListener((InMemoryDOMDataStore)operStore); + } + + DOMStore configStore = getConfigDataStoreDependency(); + if(configStore == null){ + //we will default to InMemoryDOMDataStore creation + configStore = new InMemoryDOMDataStore("DOM-CFG", storeExecutor); + //here we will register the SchemaContext listener + getSchemaServiceDependency().registerSchemaServiceListener((InMemoryDOMDataStore)configStore); + } ImmutableMap datastores = ImmutableMap . builder().put(LogicalDatastoreType.OPERATIONAL, operStore) .put(LogicalDatastoreType.CONFIGURATION, configStore).build(); @@ -59,8 +72,6 @@ public final class DomInmemoryDataBrokerModule extends getBundleContext().registerService(DOMDataBroker.class, newDataBroker, new Hashtable()); - getSchemaServiceDependency().registerSchemaServiceListener(operStore); - getSchemaServiceDependency().registerSchemaServiceListener(configStore); return newDataBroker; } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java index 0c07b0684c..0be4327f7a 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMForwardedCompositeTransaction.java @@ -75,8 +75,7 @@ abstract class AbstractDOMForwardedCompositeTransaction builder = ImmutableMap.builder(); for (Entry store : storeTxFactories.entrySet()) { diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadOnlyTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadOnlyTransaction.java index d2543f02bc..f207783c29 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadOnlyTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedReadOnlyTransaction.java @@ -8,7 +8,7 @@ package org.opendaylight.controller.md.sal.dom.broker.impl; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; @@ -26,7 +26,7 @@ import com.google.common.util.concurrent.ListenableFuture; */ class DOMForwardedReadOnlyTransaction extends AbstractDOMForwardedCompositeTransaction implements - DOMDataReadTransaction { + DOMDataReadOnlyTransaction { protected DOMForwardedReadOnlyTransaction(final Object identifier, final ImmutableMap backingTxs) { @@ -39,4 +39,9 @@ class DOMForwardedReadOnlyTransaction extends return getSubtransaction(store).read(path); } + @Override + public void close() { + closeSubtransactions(); + } + } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java index eeb345e9ce..f791522a2a 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMForwardedWriteTransaction.java @@ -50,13 +50,31 @@ import com.google.common.util.concurrent.ListenableFuture; class DOMForwardedWriteTransaction extends AbstractDOMForwardedCompositeTransaction implements DOMDataWriteTransaction { + /** + * Implementation of real commit. + * + * Transaction can not be commited if commitImpl is null, + * so this seting this property to null is also used to + * prevent write to + * already commited / canceled transaction {@link #checkNotCanceled() + * + * + */ @GuardedBy("this") - private DOMDataCommitImplementation commitImpl; - - @GuardedBy("this") - private boolean canceled; + private volatile DOMDataCommitImplementation commitImpl; + + /** + * + * Future task of transaction commit. + * + * This value is initially null, and is once updated if transaction + * is commited {@link #commit()}. + * If this future exists, transaction MUST not be commited again + * and all modifications should fail. See {@link #checkNotCommited()}. + * + */ @GuardedBy("this") - private ListenableFuture> commitFuture; + private volatile ListenableFuture> commitFuture; protected DOMForwardedWriteTransaction(final Object identifier, final ImmutableMap backingTxs, final DOMDataCommitImplementation commitImpl) { @@ -83,15 +101,19 @@ class DOMForwardedWriteTransaction extends } @Override - public synchronized void cancel() { - checkState(!canceled, "Transaction was canceled."); - if (commitFuture != null) { - // FIXME: Implement cancelation of commit future - // when Broker impl will support cancelation. - throw new UnsupportedOperationException("Not implemented yet."); + public synchronized boolean cancel() { + // Transaction is already canceled, we are safe to return true + final boolean cancelationResult; + if (commitImpl == null && commitFuture != null) { + // Transaction is submitted, we try to cancel future. + cancelationResult = commitFuture.cancel(false); + } else if(commitImpl == null) { + return true; + } else { + cancelationResult = true; + commitImpl = null; } - canceled = true; - commitImpl = null; + return cancelationResult; } @@ -105,20 +127,26 @@ class DOMForwardedWriteTransaction extends } ImmutableList cohorts = cohortsBuilder.build(); commitFuture = commitImpl.commit(this, cohorts); + + /* + *We remove reference to Commit Implementation in order + *to prevent memory leak + */ + commitImpl = null; return commitFuture; } private void checkNotReady() { - checkNotCanceled(); checkNotCommited(); + checkNotCanceled(); } private void checkNotCanceled() { - Preconditions.checkState(!canceled, "Transaction was canceled."); + Preconditions.checkState(commitImpl != null, "Transaction was canceled."); } private void checkNotCommited() { - checkState(commitFuture == null, "Transaction was already commited."); + checkState(commitFuture == null, "Transaction was already submited."); } } \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleTransaction.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleTransaction.java index 29f2af511e..b3fb7b6da8 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleTransaction.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/compat/BackwardsCompatibleTransaction.java @@ -24,6 +24,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException; import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation; import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction; @@ -55,10 +56,10 @@ public abstract class BackwardsCompatibleTransaction readOnlyTransaction(final DOMDataReadTransaction readTx, + public static BackwardsCompatibleTransaction readOnlyTransaction(final DOMDataReadOnlyTransaction readTx, final DataNormalizer normalizer) { - return new BackwardsCompatibleTransaction(readTx, normalizer) { + return new BackwardsCompatibleTransaction(readTx, normalizer) { @Override public TransactionStatus getStatus() { diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ConflictingModificationAppliedException.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ConflictingModificationAppliedException.java deleted file mode 100644 index 3625d3356a..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ConflictingModificationAppliedException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree; - -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; - -/** - * Exception thrown when a proposed change fails validation before being - * applied into the Data Tree because the Data Tree has been modified - * in way that a conflicting - * node is present. - */ -public class ConflictingModificationAppliedException extends DataValidationFailedException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public ConflictingModificationAppliedException(final InstanceIdentifier path, final String message, final Throwable cause) { - super(path, message, cause); - } - - public ConflictingModificationAppliedException(final InstanceIdentifier path, final String message) { - super(path, message); - } - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTree.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTree.java deleted file mode 100644 index 4807e15653..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTree.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree; - -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * Interface representing a data tree which can be modified in an MVCC fashion. - */ -public interface DataTree { - /** - * Take a read-only point-in-time snapshot of the tree. - * - * @return Data tree snapshot. - */ - DataTreeSnapshot takeSnapshot(); - - /** - * Make the data tree use a new schema context. The context will be used - * only by subsequent operations. - * - * @param newSchemaContext new SchemaContext - * @throws IllegalArgumentException if the new context is incompatible - */ - void setSchemaContext(SchemaContext newSchemaContext); - - /** - * Validate whether a particular modification can be applied to the data tree. - */ - void validate(DataTreeModification modification) throws DataValidationFailedException; - - /** - * Prepare a modification for commit. - * - * @param modification - * @return candidate data tree - */ - DataTreeCandidate prepare(DataTreeModification modification); - - /** - * Commit a data tree candidate. - * - * @param candidate data tree candidate - */ - void commit(DataTreeCandidate candidate); -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeCandidate.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeCandidate.java deleted file mode 100644 index d860dfc064..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeCandidate.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree; - -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; - -/** - * An encapsulation of a validated data tree modification. This candidate - * is ready for atomic commit to the datastore. It allows access to before- - * and after-state as it will be seen in to subsequent commit. This capture - * can be accessed for reference, but cannot be modified and the content - * is limited to nodes which were affected by the modification from which - * this instance originated. - */ -public interface DataTreeCandidate { - /** - * Get the candidate tree root node. - * - * @return Candidate tree root node - */ - DataTreeCandidateNode getRootNode(); - - /** - * Get the candidate tree root path. This is the path of the root node - * relative to the root of InstanceIdentifier namespace. - * - * @return Relative path of the root node - */ - InstanceIdentifier getRootPath(); -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeCandidateNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeCandidateNode.java deleted file mode 100644 index 528419d235..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeCandidateNode.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree; - -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -import com.google.common.base.Optional; - -/** - * A single node within a {@link DataTreeCandidate}. The nodes are organized - * in tree hierarchy, reflecting the modification from which this candidate - * was created. The node itself exposes the before- and after-image of the - * tree restricted to the modified nodes. - */ -public interface DataTreeCandidateNode { - /** - * Get the node identifier. - * - * @return The node identifier. - */ - PathArgument getIdentifier(); - - /** - * Get an unmodifiable iterable of modified child nodes. - * - * @return Unmodifiable iterable of modified child nodes. - */ - Iterable getChildNodes(); - - /** - * Return the type of modification this node is undergoing. - * - * @return Node modification type. - */ - ModificationType getModificationType(); - - /** - * Return the before-image of data corresponding to the node. - * - * @return Node data as they were present in the tree before - * the modification was applied. - */ - Optional> getDataAfter(); - - /** - * Return the after-image of data corresponding to the node. - * - * @return Node data as they will be present in the tree after - * the modification is applied. - */ - Optional> getDataBefore(); -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeModification.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeModification.java deleted file mode 100644 index e4370c46a0..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeModification.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree; - -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * Class encapsulation of set of modifications to a base tree. This tree is backed - * by a read-only snapshot and tracks modifications on top of that. The modification - * has the ability to rebase itself to a new snapshot. - */ -public interface DataTreeModification extends DataTreeSnapshot { - /** - * Delete the node at specified path. - * - * @param path Node path - */ - void delete(InstanceIdentifier path); - - /** - * Merge the specified data with the currently-present data - * at specified path. - * - * @param path Node path - * @param data Data to be merged - */ - void merge(InstanceIdentifier path, NormalizedNode data); - - /** - * Replace the data at specified path with supplied data. - * - * @param path Node path - * @param data New node data - */ - void write(InstanceIdentifier path, NormalizedNode data); - - /** - * Finish creation of a modification, making it ready for application - * to the data tree. Any calls to this object's methods will result - * in undefined behavior, possibly with an - * {@link IllegalStateException} being thrown. - */ - void ready(); -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeSnapshot.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeSnapshot.java deleted file mode 100644 index a94acc5658..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeSnapshot.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree; - -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -import com.google.common.base.Optional; - -/** - * Read-only snapshot of a {@link DataTree}. The snapshot is stable and isolated, - * e.g. data tree changes occurring after the snapshot has been taken are not - * visible through the snapshot. - */ -public interface DataTreeSnapshot { - /** - * Read a particular node from the snapshot. - * - * @param path Path of the node - * @return Optional result encapsulating the presence and value of the node - */ - Optional> readNode(InstanceIdentifier path); - - /** - * Create a new data tree modification based on this snapshot, using the - * specified data application strategy. - * - * @param strategy data modification strategy - * @return A new data tree modification - */ - DataTreeModification newModification(); -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataValidationFailedException.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataValidationFailedException.java deleted file mode 100644 index 3683240f57..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataValidationFailedException.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree; - -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; - -import com.google.common.base.Preconditions; - -/** - * Exception thrown when a proposed change fails validation before being - * applied into the datastore. This can have multiple reasons, for example - * the datastore has been concurrently modified such that a conflicting - * node is present, or the modification is structurally incorrect. - */ -public class DataValidationFailedException extends Exception { - private static final long serialVersionUID = 1L; - private final InstanceIdentifier path; - - /** - * Create a new instance. - * - * @param path Object path which caused this exception - * @param message Specific message describing the failure - */ - public DataValidationFailedException(final InstanceIdentifier path, final String message) { - this(path, message, null); - } - /** - * Create a new instance, initializing - * - * @param path Object path which caused this exception - * @param message Specific message describing the failure - * @param cause Exception which triggered this failure, may be null - */ - public DataValidationFailedException(final InstanceIdentifier path, final String message, final Throwable cause) { - super(message, cause); - this.path = Preconditions.checkNotNull(path); - } - - /** - * Returns the offending object path. - * - * @return Path of the offending object - */ - public InstanceIdentifier getPath() { - return path; - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/IncorrectDataStructureException.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/IncorrectDataStructureException.java deleted file mode 100644 index 87482a9156..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/IncorrectDataStructureException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree; - -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; - -/** - * Exception thrown when a proposed change fails validation before being - * applied into the datastore because of incorrect structure of user supplied - * data. - * - */ -public class IncorrectDataStructureException extends DataValidationFailedException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public IncorrectDataStructureException(final InstanceIdentifier path, final String message, final Throwable cause) { - super(path, message, cause); - } - - public IncorrectDataStructureException(final InstanceIdentifier path, final String message) { - super(path, message); - } - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ModificationType.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ModificationType.java deleted file mode 100644 index b9a26f5c00..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ModificationType.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree; - -/** - * Enumeration of all possible node modification states. These are used in - * data tree modification context to quickly assess what sort of modification - * the node is undergoing. - */ -public enum ModificationType { - /** - * Node is currently unmodified. - */ - UNMODIFIED, - - /** - * A child node, either direct or indirect, has been modified. This means - * that the data representation of this node has potentially changed. - */ - SUBTREE_MODIFIED, - - /** - * This node has been placed into the tree, potentially completely replacing - * pre-existing contents. - */ - WRITE, - - /** - * This node has been deleted along with any of its child nodes. - */ - DELETE, - - /** - * Node has been written into the tree, but instead of replacing pre-existing - * contents, it has been merged. This means that any incoming nodes which - * were present in the tree have been replaced, but their child nodes have - * been retained. - */ - MERGE, -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreTreeNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreTreeNode.java deleted file mode 100644 index d714f1cc85..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreTreeNode.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree; - -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; - -import com.google.common.base.Optional; - -/** - * A tree node which has references to its child leaves. This are typically - * internal non-data leaves, such as containers, lists, etc. - * - * @param Final node type - */ -public interface StoreTreeNode> { - - /** - * Returns a direct child of the node - * - * @param child Identifier of child - * @return Optional with node if the child is existing, {@link Optional#absent()} otherwise. - */ - Optional getChild(PathArgument child); -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreUtils.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreUtils.java deleted file mode 100644 index b634866856..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/StoreUtils.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree; - -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer; - -import com.google.common.base.Strings; - -/** - * Data store tree manipulation utilities. - */ -public final class StoreUtils { - private static final int STRINGTREE_INDENT = 4; - - private StoreUtils() { - throw new UnsupportedOperationException("Utility class should not be instantiated"); - } - - /** - * Convert a data subtree under a node into a human-readable string format. - * - * @param node Data subtree root - * @return String containing a human-readable form of the subtree. - */ - public static String toStringTree(final NormalizedNode node) { - final StringBuilder builder = new StringBuilder(); - toStringTree(builder, node, 0); - return builder.toString(); - } - - private static void toStringTree(final StringBuilder builder, final NormalizedNode node, final int offset) { - final String prefix = Strings.repeat(" ", offset); - - builder.append(prefix).append(toStringTree(node.getIdentifier())); - if (node instanceof NormalizedNodeContainer) { - final NormalizedNodeContainer container = (NormalizedNodeContainer) node; - - builder.append(" {\n"); - for (NormalizedNode child : container.getValue()) { - toStringTree(builder, child, offset + STRINGTREE_INDENT); - } - - builder.append(prefix).append('}'); - } else { - builder.append(' ').append(node.getValue()); - } - builder.append('\n'); - } - - private static String toStringTree(final PathArgument identifier) { - if (identifier instanceof NodeIdentifierWithPredicates) { - StringBuilder builder = new StringBuilder(); - builder.append(identifier.getNodeType().getLocalName()); - builder.append(((NodeIdentifierWithPredicates) identifier).getKeyValues().values()); - return builder.toString(); - } else if (identifier instanceof AugmentationIdentifier) { - return "augmentation"; - } - return identifier.getNodeType().getLocalName(); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/TreeNodeUtils.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/TreeNodeUtils.java deleted file mode 100644 index fe98468b5c..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/TreeNodeUtils.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree; - -import java.util.AbstractMap.SimpleEntry; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; - -/** - * A set of utility methods for interacting with {@link org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode} objects. - */ -public final class TreeNodeUtils { - private TreeNodeUtils() { - throw new UnsupportedOperationException("Utility class should not be instantiated"); - } - - /** - * Finds a node in tree - * - * @param tree Data Tree - * @param path Path to the node - * @return Optional with node if the node is present in tree, {@link Optional#absent()} otherwise. - */ - public static > Optional findNode(final T tree, final InstanceIdentifier path) { - Optional current = Optional. of(tree); - Iterator pathIter = path.getPath().iterator(); - while (current.isPresent() && pathIter.hasNext()) { - current = current.get().getChild(pathIter.next()); - } - return current; - } - - public static > T findNodeChecked(final T tree, final InstanceIdentifier path) { - T current = tree; - List nested = new ArrayList<>(path.getPath().size()); - for(PathArgument pathArg : path.getPath()) { - Optional potential = current.getChild(pathArg); - nested.add(pathArg); - Preconditions.checkArgument(potential.isPresent(),"Child %s is not present in tree.",nested); - current = potential.get(); - } - return current; - } - - /** - * Finds a node or closest parent in the tree - * - * @param tree Data Tree - * @param path Path to the node - * @return Map.Entry Entry with key which is path to closest parent and value is parent node. - * - */ - public static > Map.Entry findClosest(final T tree, final InstanceIdentifier path) { - return findClosestsOrFirstMatch(tree, path, Predicates.alwaysFalse()); - } - - public static > Map.Entry findClosestsOrFirstMatch(final T tree, final InstanceIdentifier path, final Predicate predicate) { - Optional parent = Optional.of(tree); - Optional current = Optional. of(tree); - - int nesting = 0; - Iterator pathIter = path.getPath().iterator(); - while (current.isPresent() && pathIter.hasNext() && !predicate.apply(current.get())) { - parent = current; - current = current.get().getChild(pathIter.next()); - nesting++; - } - if(current.isPresent()) { - final InstanceIdentifier currentPath = new InstanceIdentifier(path.getPath().subList(0, nesting)); - return new SimpleEntry(currentPath,current.get()); - } - - /* - * 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(parentPath,parent.get()); - } - - public static > Optional getChild(final Optional parent,final PathArgument child) { - if(parent.isPresent()) { - return parent.get().getChild(child); - } - return Optional.absent(); - } - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/AbstractDataTreeCandidate.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/AbstractDataTreeCandidate.java deleted file mode 100644 index cddda5ccc5..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/AbstractDataTreeCandidate.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidate; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; - -import com.google.common.base.Preconditions; - -abstract class AbstractDataTreeCandidate implements DataTreeCandidate { - private final InstanceIdentifier rootPath; - - protected AbstractDataTreeCandidate(final InstanceIdentifier rootPath) { - this.rootPath = Preconditions.checkNotNull(rootPath); - } - - @Override - public final InstanceIdentifier getRootPath() { - return rootPath; - } - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/AlwaysFailOperation.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/AlwaysFailOperation.java deleted file mode 100644 index c09a1a38b5..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/AlwaysFailOperation.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.opendaylight.controller.md.sal.dom.store.impl.tree.data; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; - -import com.google.common.base.Optional; - -/** - * An implementation of apply operation which fails to do anything, - * consistently. An instance of this class is used by the data tree - * if it does not have a SchemaContext attached and hence cannot - * perform anything meaningful. - */ -final class AlwaysFailOperation implements ModificationApplyOperation { - @Override - public Optional apply(final ModifiedNode modification, - final Optional storeMeta, final Version version) { - throw new IllegalStateException("Schema Context is not available."); - } - - @Override - public void checkApplicable(final InstanceIdentifier path,final NodeModification modification, final Optional storeMetadata) { - throw new IllegalStateException("Schema Context is not available."); - } - - @Override - public Optional getChild(final PathArgument child) { - throw new IllegalStateException("Schema Context is not available."); - } - - @Override - public void verifyStructure(final ModifiedNode modification) { - throw new IllegalStateException("Schema Context is not available."); - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/DataNodeContainerModificationStrategy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/DataNodeContainerModificationStrategy.java deleted file mode 100644 index dc891482ab..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/DataNodeContainerModificationStrategy.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ExecutionException; - -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListEntryNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.AugmentationSchemaProxy; -import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; -import org.opendaylight.yangtools.yang.model.api.AugmentationTarget; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; - -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; - -/** - * Base strategy for applying changes to a ContainerNode, irrespective of its - * actual type. - * - * @param Type of the container node - */ -abstract class DataNodeContainerModificationStrategy extends NormalizedNodeContainerModificationStrategy { - - private final T schema; - private final LoadingCache childCache = CacheBuilder.newBuilder() - .build(CacheLoader.from(new Function() { - - @Override - public ModificationApplyOperation apply(final PathArgument identifier) { - if (identifier instanceof AugmentationIdentifier && schema instanceof AugmentationTarget) { - return from(schema, (AugmentationTarget) schema, (AugmentationIdentifier) identifier); - } - - DataSchemaNode child = schema.getDataChildByName(identifier.getNodeType()); - if (child == null) { - return null; - } - return from(child); - } - })); - - protected DataNodeContainerModificationStrategy(final T schema, - final Class> nodeClass) { - super(nodeClass); - this.schema = schema; - } - - protected T getSchema() { - return schema; - } - - @Override - public Optional getChild(final PathArgument identifier) { - try { - return Optional. fromNullable(childCache.get(identifier)); - } catch (ExecutionException e) { - return Optional.absent(); - } - } - - @Override - @SuppressWarnings("rawtypes") - protected abstract DataContainerNodeBuilder createBuilder(NormalizedNode original); - - @Override - public String toString() { - return getClass().getSimpleName() + " [" + schema + "]"; - } - - public static class AugmentationModificationStrategy extends DataNodeContainerModificationStrategy { - - protected AugmentationModificationStrategy(final AugmentationSchema schema, final DataNodeContainer resolved) { - super(createAugmentProxy(schema,resolved), AugmentationNode.class); - } - - @Override - @SuppressWarnings("rawtypes") - protected DataContainerNodeBuilder createBuilder(final NormalizedNode original) { - checkArgument(original instanceof AugmentationNode); - return ImmutableAugmentationNodeBuilder.create((AugmentationNode) original); - } - - - private static AugmentationSchema createAugmentProxy(final AugmentationSchema schema, final DataNodeContainer resolved) { - Set realChildSchemas = new HashSet<>(); - for(DataSchemaNode augChild : schema.getChildNodes()) { - realChildSchemas.add(resolved.getDataChildByName(augChild.getQName())); - } - return new AugmentationSchemaProxy(schema, realChildSchemas); - } - } - - public static class ContainerModificationStrategy extends DataNodeContainerModificationStrategy { - - public ContainerModificationStrategy(final ContainerSchemaNode schemaNode) { - super(schemaNode, ContainerNode.class); - } - - @Override - @SuppressWarnings("rawtypes") - protected DataContainerNodeBuilder createBuilder(final NormalizedNode original) { - checkArgument(original instanceof ContainerNode); - return ImmutableContainerNodeBuilder.create((ContainerNode) original); - } - } - - public static class ListEntryModificationStrategy extends DataNodeContainerModificationStrategy { - - protected ListEntryModificationStrategy(final ListSchemaNode schema) { - super(schema, MapEntryNode.class); - } - - @Override - @SuppressWarnings("rawtypes") - protected final DataContainerNodeBuilder createBuilder(final NormalizedNode original) { - checkArgument(original instanceof MapEntryNode); - return ImmutableMapEntryNodeBuilder.create((MapEntryNode) original); - } - } - - public static class UnkeyedListItemModificationStrategy extends DataNodeContainerModificationStrategy { - - public UnkeyedListItemModificationStrategy(final ListSchemaNode schemaNode) { - super(schemaNode, UnkeyedListEntryNode.class); - } - - @Override - @SuppressWarnings("rawtypes") - protected DataContainerNodeBuilder createBuilder(final NormalizedNode original) { - checkArgument(original instanceof UnkeyedListEntryNode); - return ImmutableUnkeyedListEntryNodeBuilder.create((UnkeyedListEntryNode) original); - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTree.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTree.java deleted file mode 100644 index 803105f264..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTree.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTree; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidate; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeModification; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataValidationFailedException; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreUtils; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -/** - * Read-only snapshot of the data tree. - */ -final class InMemoryDataTree implements DataTree { - private static final Logger LOG = LoggerFactory.getLogger(InMemoryDataTree.class); - private static final InstanceIdentifier PUBLIC_ROOT_PATH = InstanceIdentifier.builder().build(); - - private final ReadWriteLock rwLock = new ReentrantReadWriteLock(true); - private ModificationApplyOperation applyOper = new AlwaysFailOperation(); - private SchemaContext currentSchemaContext; - private TreeNode rootNode; - - public InMemoryDataTree(final TreeNode rootNode, final SchemaContext schemaContext) { - this.rootNode = Preconditions.checkNotNull(rootNode); - - if (schemaContext != null) { - // Also sets applyOper - setSchemaContext(schemaContext); - } - } - - @Override - public synchronized void setSchemaContext(final SchemaContext newSchemaContext) { - Preconditions.checkNotNull(newSchemaContext); - - LOG.info("Attepting to install schema context {}", newSchemaContext); - - /* - * FIXME: we should walk the schema contexts, both current and new and see - * whether they are compatible here. Reject incompatible changes. - */ - - // Instantiate new apply operation, this still may fail - final ModificationApplyOperation newApplyOper = SchemaAwareApplyOperation.from(newSchemaContext); - - // Ready to change the context now, make sure no operations are running - rwLock.writeLock().lock(); - try { - this.applyOper = newApplyOper; - this.currentSchemaContext = newSchemaContext; - } finally { - rwLock.writeLock().unlock(); - } - } - - @Override - public InMemoryDataTreeSnapshot takeSnapshot() { - rwLock.readLock().lock(); - try { - return new InMemoryDataTreeSnapshot(currentSchemaContext, rootNode, applyOper); - } finally { - rwLock.readLock().unlock(); - } - } - - @Override - public void validate(final DataTreeModification modification) throws DataValidationFailedException { - Preconditions.checkArgument(modification instanceof InMemoryDataTreeModification, "Invalid modification class %s", modification.getClass()); - - final InMemoryDataTreeModification m = (InMemoryDataTreeModification)modification; - m.getStrategy().checkApplicable(PUBLIC_ROOT_PATH, m.getRootModification(), Optional.of(rootNode)); - } - - @Override - public synchronized DataTreeCandidate prepare(final DataTreeModification modification) { - Preconditions.checkArgument(modification instanceof InMemoryDataTreeModification, "Invalid modification class %s", modification.getClass()); - - final InMemoryDataTreeModification m = (InMemoryDataTreeModification)modification; - final ModifiedNode root = m.getRootModification(); - - if (root.getType() == ModificationType.UNMODIFIED) { - return new NoopDataTreeCandidate(PUBLIC_ROOT_PATH, root); - } - - rwLock.writeLock().lock(); - try { - final Optional newRoot = m.getStrategy().apply(m.getRootModification(), - Optional.of(rootNode), rootNode.getSubtreeVersion().next()); - Preconditions.checkState(newRoot.isPresent(), "Apply strategy failed to produce root node"); - return new InMemoryDataTreeCandidate(PUBLIC_ROOT_PATH, root, rootNode, newRoot.get()); - } finally { - rwLock.writeLock().unlock(); - } - } - - @Override - public synchronized void commit(final DataTreeCandidate candidate) { - if (candidate instanceof NoopDataTreeCandidate) { - return; - } - - Preconditions.checkArgument(candidate instanceof InMemoryDataTreeCandidate, "Invalid candidate class %s", candidate.getClass()); - final InMemoryDataTreeCandidate c = (InMemoryDataTreeCandidate)candidate; - - LOG.debug("Updating datastore from {} to {}", rootNode, c.getAfterRoot()); - - if (LOG.isTraceEnabled()) { - LOG.trace("Data Tree is {}", StoreUtils.toStringTree(c.getAfterRoot().getData())); - } - - // Ready to change the context now, make sure no operations are running - rwLock.writeLock().lock(); - try { - Preconditions.checkState(c.getBeforeRoot() == rootNode, - String.format("Store tree %s and candidate base %s differ.", rootNode, c.getBeforeRoot())); - this.rootNode = c.getAfterRoot(); - } finally { - rwLock.writeLock().unlock(); - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeCandidate.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeCandidate.java deleted file mode 100644 index bafea6bd97..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeCandidate.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.opendaylight.controller.md.sal.dom.store.impl.tree.data; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidateNode; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.Iterables; - -final class InMemoryDataTreeCandidate extends AbstractDataTreeCandidate { - private static abstract class AbstractNode implements DataTreeCandidateNode { - private final ModifiedNode mod; - private final TreeNode newMeta; - private final TreeNode oldMeta; - - protected AbstractNode(final ModifiedNode mod, - final TreeNode oldMeta, final TreeNode newMeta) { - this.newMeta = newMeta; - this.oldMeta = oldMeta; - this.mod = Preconditions.checkNotNull(mod); - } - - protected final ModifiedNode getMod() { - return mod; - } - - protected final TreeNode getNewMeta() { - return newMeta; - } - - protected final TreeNode getOldMeta() { - return oldMeta; - } - - private static final TreeNode childMeta(final TreeNode parent, final PathArgument id) { - if (parent != null) { - return parent.getChild(id).orNull(); - } else { - return null; - } - } - - @Override - public Iterable getChildNodes() { - return Iterables.transform(mod.getChildren(), new Function() { - @Override - public DataTreeCandidateNode apply(final ModifiedNode input) { - final PathArgument id = input.getIdentifier(); - return new ChildNode(input, childMeta(oldMeta, id), childMeta(newMeta, id)); - } - }); - } - - @Override - public ModificationType getModificationType() { - return mod.getType(); - } - - private Optional> optionalData(final TreeNode meta) { - if (meta != null) { - return Optional.>of(meta.getData()); - } else { - return Optional.absent(); - } - } - - @Override - public Optional> getDataAfter() { - return optionalData(newMeta); - } - - @Override - public Optional> getDataBefore() { - return optionalData(oldMeta); - } - } - - private static final class ChildNode extends AbstractNode { - public ChildNode(final ModifiedNode mod, final TreeNode oldMeta, final TreeNode newMeta) { - super(mod, oldMeta, newMeta); - } - - @Override - public PathArgument getIdentifier() { - return getMod().getIdentifier(); - } - } - - private static final class RootNode extends AbstractNode { - public RootNode(final ModifiedNode mod, final TreeNode oldMeta, final TreeNode newMeta) { - super(mod, oldMeta, newMeta); - } - - @Override - public PathArgument getIdentifier() { - throw new IllegalStateException("Attempted to get identifier of the root node"); - } - } - - private final RootNode root; - - InMemoryDataTreeCandidate(final InstanceIdentifier rootPath, final ModifiedNode modificationRoot, - final TreeNode beforeRoot, final TreeNode afterRoot) { - super(rootPath); - this.root = new RootNode(modificationRoot, beforeRoot, afterRoot); - } - - TreeNode getAfterRoot() { - return root.getNewMeta(); - } - - TreeNode getBeforeRoot() { - return root.getOldMeta(); - } - - @Override - public DataTreeCandidateNode getRootNode() { - return root; - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeFactory.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeFactory.java deleted file mode 100644 index 4640be43e7..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.opendaylight.controller.md.sal.dom.store.impl.tree.data; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeFactory; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNodeFactory; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.Builders; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -/** - * A factory for creating in-memory data trees. - */ -public final class InMemoryDataTreeFactory implements DataTreeFactory { - private static final InMemoryDataTreeFactory INSTANCE = new InMemoryDataTreeFactory(); - - private InMemoryDataTreeFactory() { - // Never instantiated externally - } - - @Override - public InMemoryDataTree create() { - final NodeIdentifier root = new NodeIdentifier(SchemaContext.NAME); - final NormalizedNode data = Builders.containerBuilder().withNodeIdentifier(root).build(); - - return new InMemoryDataTree(TreeNodeFactory.createTreeNode(data, Version.initial()), null); - } - - /** - * Get an instance of this factory. This method cannot fail. - * - * @return Data tree factory instance. - */ - public static final InMemoryDataTreeFactory getInstance() { - return INSTANCE; - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java deleted file mode 100644 index 39ff4f0aa0..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeModification.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import java.util.Map.Entry; - -import javax.annotation.concurrent.GuardedBy; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeModification; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.TreeNodeUtils; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer; -import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; - -final class InMemoryDataTreeModification implements DataTreeModification { - private static final Logger LOG = LoggerFactory.getLogger(InMemoryDataTreeModification.class); - private final ModificationApplyOperation strategyTree; - private final InMemoryDataTreeSnapshot snapshot; - private final ModifiedNode rootNode; - - @GuardedBy("this") - private boolean sealed = false; - - InMemoryDataTreeModification(final InMemoryDataTreeSnapshot snapshot, final ModificationApplyOperation resolver) { - this.snapshot = Preconditions.checkNotNull(snapshot); - this.strategyTree = Preconditions.checkNotNull(resolver); - this.rootNode = ModifiedNode.createUnmodified(snapshot.getRootNode()); - } - - ModifiedNode getRootModification() { - return rootNode; - } - - ModificationApplyOperation getStrategy() { - return strategyTree; - } - - @Override - public synchronized void write(final InstanceIdentifier path, final NormalizedNode value) { - checkSealed(); - resolveModificationFor(path).write(value); - } - - @Override - public synchronized void merge(final InstanceIdentifier path, final NormalizedNode data) { - checkSealed(); - mergeImpl(resolveModificationFor(path),data); - } - - private void mergeImpl(final OperationWithModification op,final NormalizedNode data) { - - if(data instanceof NormalizedNodeContainer) { - @SuppressWarnings({ "rawtypes", "unchecked" }) - NormalizedNodeContainer> dataContainer = (NormalizedNodeContainer) data; - for(NormalizedNode child : dataContainer.getValue()) { - PathArgument childId = child.getIdentifier(); - mergeImpl(op.forChild(childId), child); - } - } - op.merge(data); - } - - @Override - public synchronized void delete(final InstanceIdentifier path) { - checkSealed(); - resolveModificationFor(path).delete(); - } - - @Override - public synchronized Optional> readNode(final InstanceIdentifier path) { - /* - * Walk the tree from the top, looking for the first node between root and - * the requested path which has been modified. If no such node exists, - * we use the node itself. - */ - final Entry entry = TreeNodeUtils.findClosestsOrFirstMatch(rootNode, path, ModifiedNode.IS_TERMINAL_PREDICATE); - final InstanceIdentifier key = entry.getKey(); - final ModifiedNode mod = entry.getValue(); - - final Optional result = resolveSnapshot(key, mod); - if (result.isPresent()) { - NormalizedNode data = result.get().getData(); - return NormalizedNodeUtils.findNode(key, data, path); - } else { - return Optional.absent(); - } - } - - private Optional resolveSnapshot(final InstanceIdentifier path, - final ModifiedNode modification) { - final Optional> potentialSnapshot = modification.getSnapshotCache(); - if(potentialSnapshot.isPresent()) { - return potentialSnapshot.get(); - } - - try { - return resolveModificationStrategy(path).apply(modification, modification.getOriginal(), - snapshot.getRootNode().getSubtreeVersion().next()); - } catch (Exception e) { - LOG.error("Could not create snapshot for {}:{}", path,modification,e); - throw e; - } - } - - private ModificationApplyOperation resolveModificationStrategy(final InstanceIdentifier path) { - LOG.trace("Resolving modification apply strategy for {}", path); - return TreeNodeUtils.findNodeChecked(strategyTree, path); - } - - private OperationWithModification resolveModificationFor(final InstanceIdentifier path) { - ModifiedNode modification = rootNode; - // We ensure strategy is present. - ModificationApplyOperation operation = resolveModificationStrategy(path); - for (PathArgument pathArg : path.getPath()) { - modification = modification.modifyChild(pathArg); - } - return OperationWithModification.from(operation, modification); - } - - @Override - public synchronized void ready() { - Preconditions.checkState(!sealed, "Attempted to seal an already-sealed Data Tree."); - sealed = true; - rootNode.seal(); - } - - @GuardedBy("this") - private void checkSealed() { - Preconditions.checkState(!sealed, "Data Tree is sealed. No further modifications allowed."); - } - - @Override - public String toString() { - return "MutableDataTree [modification=" + rootNode + "]"; - } - - @Override - public synchronized DataTreeModification newModification() { - Preconditions.checkState(sealed, "Attempted to chain on an unsealed modification"); - - if(rootNode.getType() == ModificationType.UNMODIFIED) { - return snapshot.newModification(); - } - - /* - * FIXME: Add advanced transaction chaining for modification of not rebased - * modification. - * - * Current computation of tempRoot may yeld incorrect subtree versions - * if there are multiple concurrent transactions, which may break - * versioning preconditions for modification of previously occured write, - * directly nested under parent node, since node version is derived from - * subtree version. - * - * For deeper nodes subtree version is derived from their respective metadata - * nodes, so this incorrect root subtree version is not affecting us. - */ - TreeNode originalSnapshotRoot = snapshot.getRootNode(); - Optional tempRoot = strategyTree.apply(rootNode, Optional.of(originalSnapshotRoot), originalSnapshotRoot.getSubtreeVersion().next()); - - InMemoryDataTreeSnapshot tempTree = new InMemoryDataTreeSnapshot(snapshot.getSchemaContext(), tempRoot.get(), strategyTree); - return tempTree.newModification(); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeSnapshot.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeSnapshot.java deleted file mode 100644 index ee91e62518..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/InMemoryDataTreeSnapshot.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.opendaylight.controller.md.sal.dom.store.impl.tree.data; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeSnapshot; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeUtils; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; - -final class InMemoryDataTreeSnapshot implements DataTreeSnapshot { - private final ModificationApplyOperation applyOper; - private final SchemaContext schemaContext; - private final TreeNode rootNode; - - InMemoryDataTreeSnapshot(final SchemaContext schemaContext, final TreeNode rootNode, - final ModificationApplyOperation applyOper) { - this.schemaContext = Preconditions.checkNotNull(schemaContext); - this.rootNode = Preconditions.checkNotNull(rootNode); - this.applyOper = Preconditions.checkNotNull(applyOper); - } - - TreeNode getRootNode() { - return rootNode; - } - - SchemaContext getSchemaContext() { - return schemaContext; - } - - @Override - public Optional> readNode(final InstanceIdentifier path) { - return NormalizedNodeUtils.findNode(rootNode.getData(), path); - } - - @Override - public InMemoryDataTreeModification newModification() { - return new InMemoryDataTreeModification(this, applyOper); - } - - @Override - public String toString() { - return rootNode.getSubtreeVersion().toString(); - } - -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModificationApplyOperation.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModificationApplyOperation.java deleted file mode 100644 index f72d575194..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModificationApplyOperation.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataValidationFailedException; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreTreeNode; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; - -import com.google.common.base.Optional; - -/** - * - * Operation responsible for applying {@link ModifiedNode} on tree. - * - * Operation is composite - operation on top level node consists of - * suboperations on child nodes. This allows to walk operation hierarchy and - * invoke suboperations independently. - * - * Implementation notes - *

      - *
    • - * Implementations MUST expose all nested suboperations which operates on child - * nodes expose via {@link #getChild(PathArgument)} method. - *
    • Same suboperations SHOULD be used when invoked via - * {@link #apply(ModifiedNode, Optional)} if applicable. - * - * - * Hierarchical composite operation which is responsible for applying - * modification on particular subtree and creating updated subtree - * - * - */ -interface ModificationApplyOperation extends StoreTreeNode { - - /** - * - * Implementation of this operation must be stateless and must not change - * state of this object. - * - * @param modification - * NodeModification to be applied - * @param storeMeta - * Store Metadata Node on which NodeModification should be - * applied - * @param version New subtree version of parent node - * @throws IllegalArgumentException - * If it is not possible to apply Operation on provided Metadata - * node - * @return new {@link StoreMetadataNode} if operation resulted in updating - * node, {@link Optional#absent()} if {@link ModifiedNode} - * resulted in deletion of this node. - */ - Optional apply(ModifiedNode modification, Optional storeMeta, Version version); - - /** - * - * Performs structural verification of NodeModification, such as writen values / types - * uses right structural elements. - * - * @param modification to be verified. - * @throws IllegalArgumentException If provided NodeModification does not adhere to the structure. - */ - void verifyStructure(ModifiedNode modification) throws IllegalArgumentException; - - /** - * Returns a suboperation for specified tree node - * - * @return Reference to suboperation for specified tree node, {@link Optional#absent()} - * if suboperation is not supported for specified tree node. - */ - @Override - Optional getChild(PathArgument child); - - /** - * - * Checks if provided node modification could be applied to current metadata node. - * - * @param modification Modification - * @param current Metadata Node to which modification should be applied - * @return true if modification is applicable - * false if modification is no applicable - * @throws DataValidationFailedException - */ - void checkApplicable(InstanceIdentifier path, NodeModification modification, Optional current) throws DataValidationFailedException; -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModifiedNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModifiedNode.java deleted file mode 100644 index f83ea1a2de..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModifiedNode.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import java.util.LinkedHashMap; -import java.util.Map; - -import javax.annotation.concurrent.GuardedBy; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreTreeNode; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode; -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -import com.google.common.base.Optional; -import com.google.common.base.Predicate; - -/** - * Node Modification Node and Tree - * - * Tree which structurally resembles data tree and captures client modifications - * to the data store tree. - * - * This tree is lazily created and populated via {@link #modifyChild(PathArgument)} - * and {@link StoreMetadataNode} which represents original state {@link #getOriginal()}. - */ -final class ModifiedNode implements StoreTreeNode, Identifiable, NodeModification { - - public static final Predicate IS_TERMINAL_PREDICATE = new Predicate() { - @Override - public boolean apply(final ModifiedNode input) { - switch (input.getType()) { - case DELETE: - case MERGE: - case WRITE: - return true; - case SUBTREE_MODIFIED: - case UNMODIFIED: - return false; - } - - throw new IllegalArgumentException(String.format("Unhandled modification type %s", input.getType())); - } - }; - - private final Map children = new LinkedHashMap<>(); - private final Optional original; - private final PathArgument identifier; - private ModificationType modificationType = ModificationType.UNMODIFIED; - private Optional snapshotCache; - private NormalizedNode value; - - private ModifiedNode(final PathArgument identifier, final Optional original) { - this.identifier = identifier; - this.original = original; - } - - /** - * - * - * @return - */ - public NormalizedNode getWrittenValue() { - return value; - } - - @Override - public PathArgument getIdentifier() { - return identifier; - } - - /** - * - * Returns original store metadata - * @return original store metadata - */ - @Override - public Optional getOriginal() { - return original; - } - - /** - * Returns modification type - * - * @return modification type - */ - @Override - public ModificationType getType() { - return modificationType; - } - - /** - * - * Returns child modification if child was modified - * - * @return Child modification if direct child or it's subtree - * was modified. - * - */ - @Override - public Optional getChild(final PathArgument child) { - return Optional. fromNullable(children.get(child)); - } - - /** - * - * Returns child modification if child was modified, creates {@link ModifiedNode} - * for child otherwise. - * - * If this node's {@link ModificationType} is {@link ModificationType#UNMODIFIED} - * changes modification type to {@link ModificationType#SUBTREE_MODIFIED} - * - * @param child - * @return {@link ModifiedNode} for specified child, with {@link #getOriginal()} - * containing child metadata if child was present in original data. - */ - public ModifiedNode modifyChild(final PathArgument child) { - clearSnapshot(); - if (modificationType == ModificationType.UNMODIFIED) { - updateModificationType(ModificationType.SUBTREE_MODIFIED); - } - final ModifiedNode potential = children.get(child); - if (potential != null) { - return potential; - } - - final Optional currentMetadata; - if (original.isPresent()) { - final TreeNode orig = original.get(); - currentMetadata = orig.getChild(child); - } else { - currentMetadata = Optional.absent(); - } - - ModifiedNode newlyCreated = new ModifiedNode(child, currentMetadata); - children.put(child, newlyCreated); - return newlyCreated; - } - - /** - * - * Returns all recorded direct child modification - * - * @return all recorded direct child modifications - */ - @Override - public Iterable getChildren() { - return children.values(); - } - - /** - * - * Records a delete for associated node. - * - */ - public void delete() { - clearSnapshot(); - updateModificationType(ModificationType.DELETE); - children.clear(); - this.value = null; - } - - /** - * - * Records a write for associated node. - * - * @param value - */ - public void write(final NormalizedNode value) { - clearSnapshot(); - updateModificationType(ModificationType.WRITE); - children.clear(); - this.value = value; - } - - public void merge(final NormalizedNode data) { - clearSnapshot(); - updateModificationType(ModificationType.MERGE); - // FIXME: Probably merge with previous value. - this.value = data; - } - - void seal() { - clearSnapshot(); - for (ModifiedNode child : children.values()) { - child.seal(); - } - } - - private void clearSnapshot() { - snapshotCache = null; - } - - public Optional storeSnapshot(final Optional snapshot) { - snapshotCache = snapshot; - return snapshot; - } - - public Optional> getSnapshotCache() { - return Optional.fromNullable(snapshotCache); - } - - @GuardedBy("this") - private void updateModificationType(final ModificationType type) { - modificationType = type; - clearSnapshot(); - } - - @Override - public String toString() { - return "NodeModification [identifier=" + identifier + ", modificationType=" - + modificationType + ", childModification=" + children + "]"; - } - - public static ModifiedNode createUnmodified(final TreeNode metadataTree) { - return new ModifiedNode(metadataTree.getIdentifier(), Optional.of(metadataTree)); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NodeModification.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NodeModification.java deleted file mode 100644 index e7e79f8916..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NodeModification.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode; -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; - -import com.google.common.base.Optional; - -/** - * Internal interface representing a modification action of a particular node. - * It is used by the validation code to allow for a read-only view of the - * modification tree as we should never modify that during validation. - */ -interface NodeModification extends Identifiable { - /** - * Get the type of modification. - * - * @return Modification type. - */ - ModificationType getType(); - - /** - * Get the original tree node to which the modification is to be applied. - * - * @return The original node, or {@link Optional#absent()} if the node is - * a new node. - */ - Optional getOriginal(); - - /** - * Get a read-only view of children nodes. - * - * @return Iterable of all children nodes. - */ - Iterable getChildren(); -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NoopDataTreeCandidate.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NoopDataTreeCandidate.java deleted file mode 100644 index 227684ae35..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NoopDataTreeCandidate.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import java.util.Collections; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidateNode; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; - -/** - * Internal utility class for an empty candidate. We instantiate this class - * for empty modifications, saving memory and processing speed. Instances - * of this class are explicitly recognized and processing of them is skipped. - */ -final class NoopDataTreeCandidate extends AbstractDataTreeCandidate { - private static final DataTreeCandidateNode ROOT = new DataTreeCandidateNode() { - @Override - public ModificationType getModificationType() { - return ModificationType.UNMODIFIED; - } - - @Override - public Iterable getChildNodes() { - return Collections.emptyList(); - } - - @Override - public PathArgument getIdentifier() { - throw new IllegalStateException("Attempted to read identifier of the no-operation change"); - } - - @Override - public Optional> getDataAfter() { - return Optional.absent(); - } - - @Override - public Optional> getDataBefore() { - return Optional.absent(); - } - }; - - protected NoopDataTreeCandidate(final InstanceIdentifier rootPath, final ModifiedNode modificationRoot) { - super(rootPath); - Preconditions.checkArgument(modificationRoot.getType() == ModificationType.UNMODIFIED); - } - - @Override - public DataTreeCandidateNode getRootNode() { - return ROOT; - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NormalizedNodeContainerModificationStrategy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NormalizedNodeContainerModificationStrategy.java deleted file mode 100644 index 1d10ab6ea5..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/NormalizedNodeContainerModificationStrategy.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.Map; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataValidationFailedException; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.DataNodeContainerModificationStrategy.ListEntryModificationStrategy; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.ValueNodeModificationStrategy.LeafSetEntryModificationStrategy; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.MutableTreeNode; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNodeFactory; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer; -import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode; -import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedLeafSetNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedMapNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; -import org.opendaylight.yangtools.yang.model.api.ChoiceNode; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; - -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; - -abstract class NormalizedNodeContainerModificationStrategy extends SchemaAwareApplyOperation { - - private final Class> nodeClass; - - protected NormalizedNodeContainerModificationStrategy(final Class> nodeClass) { - this.nodeClass = nodeClass; - } - - @Override - public void verifyStructure(final ModifiedNode modification) throws IllegalArgumentException { - if (modification.getType() == ModificationType.WRITE) { - - } - for (ModifiedNode childModification : modification.getChildren()) { - resolveChildOperation(childModification.getIdentifier()).verifyStructure(childModification); - } - } - - @Override - protected void checkWriteApplicable(final InstanceIdentifier path, final NodeModification modification, - final Optional current) throws DataValidationFailedException { - // FIXME: Implement proper write check for replacement of node container - // prerequisite is to have transaction chain available for clients - // otherwise this will break chained writes to same node. - } - - @SuppressWarnings("rawtypes") - @Override - protected void verifyWrittenStructure(final NormalizedNode writtenValue) { - checkArgument(nodeClass.isInstance(writtenValue), "Node should must be of type %s", nodeClass); - checkArgument(writtenValue instanceof NormalizedNodeContainer); - - NormalizedNodeContainer container = (NormalizedNodeContainer) writtenValue; - for (Object child : container.getValue()) { - checkArgument(child instanceof NormalizedNode); - - /* - * FIXME: fail-fast semantics: - * - * We can validate the data structure here, aborting the commit - * before it ever progresses to being committed. - */ - } - } - - @Override - protected TreeNode applyWrite(final ModifiedNode modification, - final Optional currentMeta, final Version version) { - final NormalizedNode newValue = modification.getWrittenValue(); - final TreeNode newValueMeta = TreeNodeFactory.createTreeNode(newValue, version); - - if (Iterables.isEmpty(modification.getChildren())) { - return newValueMeta; - } - - /* - * This is where things get interesting. The user has performed a write and - * then she applied some more modifications to it. So we need to make sense - * of that an apply the operations on top of the written value. We could have - * done it during the write, but this operation is potentially expensive, so - * we have left it out of the fast path. - * - * As it turns out, once we materialize the written data, we can share the - * code path with the subtree change. So let's create an unsealed TreeNode - * and run the common parts on it -- which end with the node being sealed. - */ - final MutableTreeNode mutable = newValueMeta.mutable(); - mutable.setSubtreeVersion(version); - - @SuppressWarnings("rawtypes") - final NormalizedNodeContainerBuilder dataBuilder = createBuilder(newValue); - - return mutateChildren(mutable, dataBuilder, version, modification.getChildren()); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - private TreeNode mutateChildren(final MutableTreeNode meta, final NormalizedNodeContainerBuilder data, - final Version nodeVersion, final Iterable modifications) { - - for (ModifiedNode mod : modifications) { - final PathArgument id = mod.getIdentifier(); - final Optional cm = meta.getChild(id); - - Optional result = resolveChildOperation(id).apply(mod, cm, nodeVersion); - if (result.isPresent()) { - final TreeNode tn = result.get(); - meta.addChild(tn); - data.addChild(tn.getData()); - } else { - meta.removeChild(id); - data.removeChild(id); - } - } - - meta.setData(data.build()); - return meta.seal(); - } - - @Override - protected TreeNode applyMerge(final ModifiedNode modification, final TreeNode currentMeta, - final Version version) { - // For Node Containers - merge is same as subtree change - we only replace children. - return applySubtreeChange(modification, currentMeta, version); - } - - @Override - public TreeNode applySubtreeChange(final ModifiedNode modification, - final TreeNode currentMeta, final Version version) { - final MutableTreeNode newMeta = currentMeta.mutable(); - newMeta.setSubtreeVersion(version); - - @SuppressWarnings("rawtypes") - NormalizedNodeContainerBuilder dataBuilder = createBuilder(currentMeta.getData()); - - return mutateChildren(newMeta, dataBuilder, version, modification.getChildren()); - } - - @Override - protected void checkSubtreeModificationApplicable(final InstanceIdentifier path, final NodeModification modification, - final Optional current) throws DataValidationFailedException { - checkConflicting(path, current.isPresent(), "Node was deleted by other transaction."); - checkChildPreconditions(path, modification, current); - } - - private void checkChildPreconditions(final InstanceIdentifier path, final NodeModification modification, final Optional current) throws DataValidationFailedException { - final TreeNode currentMeta = current.get(); - for (NodeModification childMod : modification.getChildren()) { - final PathArgument childId = childMod.getIdentifier(); - final Optional childMeta = currentMeta.getChild(childId); - - InstanceIdentifier childPath = path.node(childId); - resolveChildOperation(childId).checkApplicable(childPath, childMod, childMeta); - } - } - - @Override - protected void checkMergeApplicable(final InstanceIdentifier path, final NodeModification modification, - final Optional current) throws DataValidationFailedException { - if(current.isPresent()) { - checkChildPreconditions(path, modification,current); - } - } - - @SuppressWarnings("rawtypes") - protected abstract NormalizedNodeContainerBuilder createBuilder(NormalizedNode original); - - public static class ChoiceModificationStrategy extends NormalizedNodeContainerModificationStrategy { - - private final Map childNodes; - - public ChoiceModificationStrategy(final ChoiceNode schemaNode) { - super(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode.class); - ImmutableMap.Builder child = ImmutableMap.builder(); - - for (ChoiceCaseNode caze : schemaNode.getCases()) { - for (DataSchemaNode cazeChild : caze.getChildNodes()) { - SchemaAwareApplyOperation childNode = from(cazeChild); - child.put(new NodeIdentifier(cazeChild.getQName()), childNode); - } - } - childNodes = child.build(); - } - - @Override - public Optional getChild(final PathArgument child) { - return Optional.fromNullable(childNodes.get(child)); - } - - @Override - @SuppressWarnings("rawtypes") - protected DataContainerNodeBuilder createBuilder(final NormalizedNode original) { - checkArgument(original instanceof org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode); - return ImmutableChoiceNodeBuilder.create((org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) original); - } - } - - public static class OrderedLeafSetModificationStrategy extends NormalizedNodeContainerModificationStrategy { - - private final Optional entryStrategy; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected OrderedLeafSetModificationStrategy(final LeafListSchemaNode schema) { - super((Class) LeafSetNode.class); - entryStrategy = Optional. of(new LeafSetEntryModificationStrategy(schema)); - } - - @SuppressWarnings("rawtypes") - @Override - protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode original) { - checkArgument(original instanceof OrderedLeafSetNode); - return ImmutableOrderedLeafSetNodeBuilder.create((OrderedLeafSetNode) original); - } - - @Override - public Optional getChild(final PathArgument identifier) { - if (identifier instanceof NodeWithValue) { - return entryStrategy; - } - return Optional.absent(); - } - } - - public static class OrderedMapModificationStrategy extends NormalizedNodeContainerModificationStrategy { - - private final Optional entryStrategy; - - protected OrderedMapModificationStrategy(final ListSchemaNode schema) { - super(OrderedMapNode.class); - entryStrategy = Optional. of(new ListEntryModificationStrategy(schema)); - } - - @SuppressWarnings("rawtypes") - @Override - protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode original) { - checkArgument(original instanceof OrderedMapNode); - return ImmutableOrderedMapNodeBuilder.create((OrderedMapNode) original); - } - - @Override - public Optional getChild(final PathArgument identifier) { - if (identifier instanceof NodeIdentifierWithPredicates) { - return entryStrategy; - } - return Optional.absent(); - } - - @Override - public String toString() { - return "OrderedMapModificationStrategy [entry=" + entryStrategy + "]"; - } - } - - public static class UnorderedLeafSetModificationStrategy extends NormalizedNodeContainerModificationStrategy { - - private final Optional entryStrategy; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected UnorderedLeafSetModificationStrategy(final LeafListSchemaNode schema) { - super((Class) LeafSetNode.class); - entryStrategy = Optional. of(new LeafSetEntryModificationStrategy(schema)); - } - - @SuppressWarnings("rawtypes") - @Override - protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode original) { - checkArgument(original instanceof LeafSetNode); - return ImmutableLeafSetNodeBuilder.create((LeafSetNode) original); - } - - @Override - public Optional getChild(final PathArgument identifier) { - if (identifier instanceof NodeWithValue) { - return entryStrategy; - } - return Optional.absent(); - } - } - - public static class UnorderedMapModificationStrategy extends NormalizedNodeContainerModificationStrategy { - - private final Optional entryStrategy; - - protected UnorderedMapModificationStrategy(final ListSchemaNode schema) { - super(MapNode.class); - entryStrategy = Optional. of(new ListEntryModificationStrategy(schema)); - } - - @SuppressWarnings("rawtypes") - @Override - protected NormalizedNodeContainerBuilder createBuilder(final NormalizedNode original) { - checkArgument(original instanceof MapNode); - return ImmutableMapNodeBuilder.create((MapNode) original); - } - - @Override - public Optional getChild(final PathArgument identifier) { - if (identifier instanceof NodeIdentifierWithPredicates) { - return entryStrategy; - } - return Optional.absent(); - } - - @Override - public String toString() { - return "UnorderedMapModificationStrategy [entry=" + entryStrategy + "]"; - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/OperationWithModification.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/OperationWithModification.java deleted file mode 100644 index e1cc1a17e5..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/OperationWithModification.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -import com.google.common.base.Optional; - -final class OperationWithModification { - - private final ModifiedNode modification; - - private final ModificationApplyOperation applyOperation; - - private OperationWithModification(final ModificationApplyOperation op, final ModifiedNode mod) { - this.modification = mod; - this.applyOperation = op; - } - - public OperationWithModification write(final NormalizedNode value) { - modification.write(value); - applyOperation.verifyStructure(modification); - return this; - } - - public OperationWithModification delete() { - modification.delete(); - return this; - } - - public ModifiedNode getModification() { - return modification; - } - - public ModificationApplyOperation getApplyOperation() { - return applyOperation; - } - - public Optional apply(final Optional data, final Version version) { - return applyOperation.apply(modification, data, version); - } - - public static OperationWithModification from(final ModificationApplyOperation operation, - final ModifiedNode modification) { - return new OperationWithModification(operation, modification); - - } - - public void merge(final NormalizedNode data) { - modification.merge(data); - applyOperation.verifyStructure(modification); - - } - - public OperationWithModification forChild(final PathArgument childId) { - ModifiedNode childMod = modification.modifyChild(childId); - Optional childOp = applyOperation.getChild(childId); - return from(childOp.get(),childMod); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/SchemaAwareApplyOperation.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/SchemaAwareApplyOperation.java deleted file mode 100644 index f6006359af..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/SchemaAwareApplyOperation.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.List; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.ConflictingModificationAppliedException; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataValidationFailedException; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.IncorrectDataStructureException; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.DataNodeContainerModificationStrategy.ContainerModificationStrategy; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.DataNodeContainerModificationStrategy.UnkeyedListItemModificationStrategy; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.NormalizedNodeContainerModificationStrategy.ChoiceModificationStrategy; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.NormalizedNodeContainerModificationStrategy.OrderedLeafSetModificationStrategy; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.NormalizedNodeContainerModificationStrategy.OrderedMapModificationStrategy; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.NormalizedNodeContainerModificationStrategy.UnorderedLeafSetModificationStrategy; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.ValueNodeModificationStrategy.LeafModificationStrategy; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNodeFactory; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; -import org.opendaylight.yangtools.yang.model.api.AugmentationTarget; -import org.opendaylight.yangtools.yang.model.api.ChoiceNode; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; - -abstract class SchemaAwareApplyOperation implements ModificationApplyOperation { - private static final Logger LOG = LoggerFactory.getLogger(SchemaAwareApplyOperation.class); - - public static SchemaAwareApplyOperation from(final DataSchemaNode schemaNode) { - if (schemaNode instanceof ContainerSchemaNode) { - return new ContainerModificationStrategy((ContainerSchemaNode) schemaNode); - } else if (schemaNode instanceof ListSchemaNode) { - return fromListSchemaNode((ListSchemaNode) schemaNode); - } else if (schemaNode instanceof ChoiceNode) { - return new ChoiceModificationStrategy((ChoiceNode) schemaNode); - } else if (schemaNode instanceof LeafListSchemaNode) { - return fromLeafListSchemaNode((LeafListSchemaNode) schemaNode); - } else if (schemaNode instanceof LeafSchemaNode) { - return new LeafModificationStrategy((LeafSchemaNode) schemaNode); - } - throw new IllegalArgumentException("Not supported schema node type for " + schemaNode.getClass()); - } - - public static SchemaAwareApplyOperation from(final DataNodeContainer resolvedTree, - final AugmentationTarget augSchemas, final AugmentationIdentifier identifier) { - AugmentationSchema augSchema = null; - - allAugments: - for (AugmentationSchema potential : augSchemas.getAvailableAugmentations()) { - for (DataSchemaNode child : potential.getChildNodes()) { - if (identifier.getPossibleChildNames().contains(child.getQName())) { - augSchema = potential; - break allAugments; - } - } - } - - if (augSchema != null) { - return new DataNodeContainerModificationStrategy.AugmentationModificationStrategy(augSchema, resolvedTree); - } - return null; - } - - public static boolean checkConflicting(final InstanceIdentifier path, final boolean condition, final String message) throws ConflictingModificationAppliedException { - if(!condition) { - throw new ConflictingModificationAppliedException(path, message); - } - return condition; - } - - private static SchemaAwareApplyOperation fromListSchemaNode(final ListSchemaNode schemaNode) { - List keyDefinition = schemaNode.getKeyDefinition(); - if (keyDefinition == null || keyDefinition.isEmpty()) { - return new UnkeyedListModificationStrategy(schemaNode); - } - if (schemaNode.isUserOrdered()) { - return new OrderedMapModificationStrategy(schemaNode); - } - - return new NormalizedNodeContainerModificationStrategy.UnorderedMapModificationStrategy(schemaNode); - } - - private static SchemaAwareApplyOperation fromLeafListSchemaNode(final LeafListSchemaNode schemaNode) { - if(schemaNode.isUserOrdered()) { - return new OrderedLeafSetModificationStrategy(schemaNode); - } else { - return new UnorderedLeafSetModificationStrategy(schemaNode); - } - } - - private static final void checkNotConflicting(final InstanceIdentifier path, final TreeNode original, final TreeNode current) throws ConflictingModificationAppliedException { - checkConflicting(path, original.getVersion().equals(current.getVersion()), - "Node was replaced by other transaction."); - checkConflicting(path, original.getSubtreeVersion().equals(current.getSubtreeVersion()), - "Node children was modified by other transaction"); - } - - protected final ModificationApplyOperation resolveChildOperation(final PathArgument child) { - Optional potential = getChild(child); - checkArgument(potential.isPresent(), "Operation for child %s is not defined.", child); - return potential.get(); - } - - @Override - public void verifyStructure(final ModifiedNode modification) throws IllegalArgumentException { - if (modification.getType() == ModificationType.WRITE) { - verifyWrittenStructure(modification.getWrittenValue()); - } - } - - @Override - public final void checkApplicable(final InstanceIdentifier path,final NodeModification modification, final Optional current) throws DataValidationFailedException { - switch (modification.getType()) { - case DELETE: - checkDeleteApplicable(modification, current); - case SUBTREE_MODIFIED: - checkSubtreeModificationApplicable(path, modification, current); - return; - case WRITE: - checkWriteApplicable(path, modification, current); - return; - case MERGE: - checkMergeApplicable(path, modification, current); - return; - case UNMODIFIED: - return; - default: - throw new UnsupportedOperationException("Suplied modification type "+ modification.getType()+ "is not supported."); - } - - } - - protected void checkMergeApplicable(final InstanceIdentifier path, final NodeModification modification, final Optional current) throws DataValidationFailedException { - Optional original = modification.getOriginal(); - if (original.isPresent() && current.isPresent()) { - /* - * We need to do conflict detection only and only if the value of leaf changed - * before two transactions. If value of leaf is unchanged between two transactions - * it should not cause transaction to fail, since result of this merge - * leads to same data. - */ - if(!original.get().getData().equals(current.get().getData())) { - checkNotConflicting(path, original.get(), current.get()); - } - } - } - - protected void checkWriteApplicable(final InstanceIdentifier path, final NodeModification modification, final Optional current) throws DataValidationFailedException { - Optional original = modification.getOriginal(); - if (original.isPresent() && current.isPresent()) { - checkNotConflicting(path, original.get(), current.get()); - } else if(original.isPresent()) { - throw new ConflictingModificationAppliedException(path,"Node was deleted by other transaction."); - } - } - - private void checkDeleteApplicable(final NodeModification modification, final Optional current) { - // Delete is always applicable, we do not expose it to subclasses - if (current.isPresent()) { - LOG.trace("Delete operation turned to no-op on missing node {}", modification); - } - } - - @Override - public final Optional apply(final ModifiedNode modification, - final Optional currentMeta, final Version version) { - - switch (modification.getType()) { - case DELETE: - return modification.storeSnapshot(Optional. absent()); - case SUBTREE_MODIFIED: - Preconditions.checkArgument(currentMeta.isPresent(), "Metadata not available for modification", - modification); - return modification.storeSnapshot(Optional.of(applySubtreeChange(modification, currentMeta.get(), - version))); - case MERGE: - if(currentMeta.isPresent()) { - return modification.storeSnapshot(Optional.of(applyMerge(modification,currentMeta.get(), version))); - } // Fallback to write is intentional - if node is not preexisting merge is same as write - case WRITE: - return modification.storeSnapshot(Optional.of(applyWrite(modification, currentMeta, version))); - case UNMODIFIED: - return currentMeta; - default: - throw new IllegalArgumentException("Provided modification type is not supported."); - } - } - - protected abstract TreeNode applyMerge(ModifiedNode modification, - TreeNode currentMeta, Version version); - - protected abstract TreeNode applyWrite(ModifiedNode modification, - Optional currentMeta, Version version); - - protected abstract TreeNode applySubtreeChange(ModifiedNode modification, - TreeNode currentMeta, Version version); - - /** - * - * Checks is supplied {@link NodeModification} is applicable for Subtree Modification. - * - * @param path Path to current node - * @param modification Node modification which should be applied. - * @param current Current state of data tree - * @throws ConflictingModificationAppliedException If subtree was changed in conflicting way - * @throws IncorrectDataStructureException If subtree modification is not applicable (e.g. leaf node). - */ - protected abstract void checkSubtreeModificationApplicable(InstanceIdentifier path, final NodeModification modification, - final Optional current) throws DataValidationFailedException; - - protected abstract void verifyWrittenStructure(NormalizedNode writtenValue); - - public static class UnkeyedListModificationStrategy extends SchemaAwareApplyOperation { - - private final Optional entryStrategy; - - protected UnkeyedListModificationStrategy(final ListSchemaNode schema) { - entryStrategy = Optional. of(new UnkeyedListItemModificationStrategy(schema)); - } - - @Override - protected TreeNode applyMerge(final ModifiedNode modification, final TreeNode currentMeta, - final Version version) { - return applyWrite(modification, Optional.of(currentMeta), version); - } - - @Override - protected TreeNode applySubtreeChange(final ModifiedNode modification, - final TreeNode currentMeta, final Version version) { - throw new UnsupportedOperationException("UnkeyedList does not support subtree change."); - } - - @Override - protected TreeNode applyWrite(final ModifiedNode modification, - final Optional currentMeta, final Version version) { - return TreeNodeFactory.createTreeNode(modification.getWrittenValue(), version); - } - - @Override - public Optional getChild(final PathArgument child) { - if (child instanceof NodeIdentifier) { - return entryStrategy; - } - return Optional.absent(); - } - - @Override - protected void verifyWrittenStructure(final NormalizedNode writtenValue) { - - } - - @Override - protected void checkSubtreeModificationApplicable(final InstanceIdentifier path, final NodeModification modification, - final Optional current) throws IncorrectDataStructureException { - throw new IncorrectDataStructureException(path, "Subtree modification is not allowed."); - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ValueNodeModificationStrategy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ValueNodeModificationStrategy.java deleted file mode 100644 index 900fa320a1..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ValueNodeModificationStrategy.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import static com.google.common.base.Preconditions.checkArgument; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.IncorrectDataStructureException; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNode; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNodeFactory; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.LeafNode; -import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; - -import com.google.common.base.Optional; - -abstract class ValueNodeModificationStrategy extends SchemaAwareApplyOperation { - - private final T schema; - private final Class> nodeClass; - - protected ValueNodeModificationStrategy(final T schema, final Class> nodeClass) { - super(); - this.schema = schema; - this.nodeClass = nodeClass; - } - - @Override - protected void verifyWrittenStructure(final NormalizedNode writtenValue) { - checkArgument(nodeClass.isInstance(writtenValue), "Node should must be of type %s", nodeClass); - } - - @Override - public Optional getChild(final PathArgument child) { - throw new UnsupportedOperationException("Node " + schema.getPath() - + "is leaf type node. Child nodes not allowed"); - } - - @Override - protected TreeNode applySubtreeChange(final ModifiedNode modification, - final TreeNode currentMeta, final Version version) { - throw new UnsupportedOperationException("Node " + schema.getPath() - + "is leaf type node. Subtree change is not allowed."); - } - - @Override - protected TreeNode applyMerge(final ModifiedNode modification, final TreeNode currentMeta, - final Version version) { - // Just overwrite whatever was there - return applyWrite(modification, null, version); - } - - @Override - protected TreeNode applyWrite(final ModifiedNode modification, - final Optional currentMeta, final Version version) { - return TreeNodeFactory.createTreeNode(modification.getWrittenValue(), version); - } - - @Override - protected void checkSubtreeModificationApplicable(final InstanceIdentifier path, final NodeModification modification, - final Optional current) throws IncorrectDataStructureException { - throw new IncorrectDataStructureException(path, "Subtree modification is not allowed."); - } - - public static class LeafSetEntryModificationStrategy extends ValueNodeModificationStrategy { - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected LeafSetEntryModificationStrategy(final LeafListSchemaNode schema) { - super(schema, (Class) LeafSetEntryNode.class); - } - } - - public static class LeafModificationStrategy extends ValueNodeModificationStrategy { - @SuppressWarnings({ "unchecked", "rawtypes" }) - protected LeafModificationStrategy(final LeafSchemaNode schema) { - super(schema, (Class) LeafNode.class); - } - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/AbstractTreeNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/AbstractTreeNode.java deleted file mode 100644 index 522bf3c84d..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/AbstractTreeNode.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.spi; - -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -import com.google.common.base.Preconditions; - -/** - * A very basic data tree node. - */ -abstract class AbstractTreeNode implements TreeNode { - private final NormalizedNode data; - private final Version version; - - protected AbstractTreeNode(final NormalizedNode data, final Version version) { - this.data = Preconditions.checkNotNull(data); - this.version = Preconditions.checkNotNull(version); - } - - @Override - public PathArgument getIdentifier() { - return data.getIdentifier(); - } - - @Override - public final Version getVersion() { - return version; - } - - @Override - public final NormalizedNode getData() { - return data; - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/ContainerNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/ContainerNode.java deleted file mode 100644 index 3ca8db2405..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/ContainerNode.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.spi; - -import java.util.HashMap; -import java.util.Map; - -import org.opendaylight.yangtools.util.MapAdaptor; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer; -import org.opendaylight.yangtools.yang.data.api.schema.OrderedNodeContainer; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; - -/** - * A TreeNode capable of holding child nodes. The fact that any of the children - * changed is tracked by the subtree version. - */ -final class ContainerNode extends AbstractTreeNode { - private final Map children; - private final Version subtreeVersion; - - protected ContainerNode(final NormalizedNode data, final Version version, - final Map children, final Version subtreeVersion) { - super(data, version); - this.children = Preconditions.checkNotNull(children); - this.subtreeVersion = Preconditions.checkNotNull(subtreeVersion); - } - - @Override - public Version getSubtreeVersion() { - return subtreeVersion; - } - - @Override - public Optional getChild(final PathArgument key) { - return Optional.fromNullable(children.get(key)); - } - - @Override - public MutableTreeNode mutable() { - return new Mutable(this); - } - - private static final class Mutable implements MutableTreeNode { - private final Version version; - private Map children; - private NormalizedNode data; - private Version subtreeVersion; - - private Mutable(final ContainerNode parent) { - this.data = parent.getData(); - this.children = MapAdaptor.getDefaultInstance().takeSnapshot(parent.children); - this.subtreeVersion = parent.getSubtreeVersion(); - this.version = parent.getVersion(); - } - - @Override - public Optional getChild(final PathArgument child) { - return Optional.fromNullable(children.get(child)); - } - - @Override - public void setSubtreeVersion(final Version subtreeVersion) { - this.subtreeVersion = Preconditions.checkNotNull(subtreeVersion); - } - - @Override - public void addChild(final TreeNode child) { - children.put(child.getIdentifier(), child); - } - - @Override - public void removeChild(final PathArgument id) { - children.remove(id); - } - - @Override - public TreeNode seal() { - final TreeNode ret = new ContainerNode(data, version, MapAdaptor.getDefaultInstance().optimize(children), subtreeVersion); - - // This forces a NPE if this class is accessed again. Better than corruption. - children = null; - return ret; - } - - @Override - public void setData(final NormalizedNode data) { - this.data = Preconditions.checkNotNull(data); - } - } - - private static ContainerNode create(final Version version, final NormalizedNode data, - final Iterable> children) { - - final Map map = new HashMap<>(); - for (NormalizedNode child : children) { - map.put(child.getIdentifier(), TreeNodeFactory.createTreeNode(child, version)); - } - - return new ContainerNode(data, version, map, version); - } - - public static ContainerNode create(final Version version, final NormalizedNodeContainer> container) { - return create(version, container, container.getValue()); - } - - public static ContainerNode create(final Version version, final OrderedNodeContainer> container) { - return create(version, container, container.getValue()); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/MutableTreeNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/MutableTreeNode.java deleted file mode 100644 index 087f4de666..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/MutableTreeNode.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.spi; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreTreeNode; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * A mutable tree node. This is a transient view materialized from a pre-existing - * node. Modifications are isolated. Once this object is {@link #seal()}-ed, - * any interactions with it will result in undefined behavior. - */ -public interface MutableTreeNode extends StoreTreeNode { - /** - * Set the data component of the node. - * - * @param data New data component, may not be null. - */ - void setData(NormalizedNode data); - - /** - * Set the new subtree version. This is typically invoked when the user - * has modified some of this node's children. - * - * @param subtreeVersion New subtree version. - */ - void setSubtreeVersion(Version subtreeVersion); - - /** - * Add a new child node. This acts as add-or-replace operation, e.g. it - * succeeds even if a conflicting child is already present. - * - * @param child New child node. - */ - void addChild(TreeNode child); - - /** - * Remove a child node. This acts as delete-or-nothing operation, e.g. it - * succeeds even if the corresponding child is not present. - * - * @param id Child identificator. - */ - void removeChild(PathArgument id); - - /** - * Finish node modification and return a read-only view of this node. After - * this method is invoked, any further calls to this object's method result - * in undefined behavior. - * - * @return Read-only view of this node. - */ - TreeNode seal(); -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/TreeNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/TreeNode.java deleted file mode 100644 index def1958123..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/TreeNode.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.spi; - -import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreTreeNode; -import org.opendaylight.yangtools.concepts.Identifiable; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; - -/** - * A very basic data tree node. It has a version (when it was last modified), - * a subtree version (when any of its children were modified) and some read-only - * data. - */ -public interface TreeNode extends Identifiable, StoreTreeNode { - /** - * Get the data node version. - * - * @return Current data node version. - */ - Version getVersion(); - - /** - * Get the subtree version. - * - * @return Current subtree version. - */ - Version getSubtreeVersion(); - - /** - * Get a read-only view of the underlying data. - * - * @return Unmodifiable view of the underlying data. - */ - NormalizedNode getData(); - - /** - * Get a mutable, isolated copy of the node. - * - * @return Mutable copy - */ - MutableTreeNode mutable(); -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/TreeNodeFactory.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/TreeNodeFactory.java deleted file mode 100644 index 9547628ae9..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/TreeNodeFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.spi; - -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer; -import org.opendaylight.yangtools.yang.data.api.schema.OrderedNodeContainer; - -/** - * Public entrypoint for other packages. Allows instantiating a tree node - * with specified version. - */ -public final class TreeNodeFactory { - private TreeNodeFactory() { - throw new UnsupportedOperationException("Utility class should not be instantiated"); - } - - /** - * Create a new AbstractTreeNode from a data node, descending recursively as needed. - * This method should only ever be used for new data. - * - * @param data data node - * @param version data node version - * @return new AbstractTreeNode instance, covering the data tree provided - */ - public static final TreeNode createTreeNode(final NormalizedNode data, final Version version) { - if (data instanceof NormalizedNodeContainer) { - @SuppressWarnings("unchecked") - NormalizedNodeContainer> container = (NormalizedNodeContainer>) data; - return ContainerNode.create(version, container); - - } - if (data instanceof OrderedNodeContainer) { - @SuppressWarnings("unchecked") - OrderedNodeContainer> container = (OrderedNodeContainer>) data; - return ContainerNode.create(version, container); - } - - return new ValueNode(data, version); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/ValueNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/ValueNode.java deleted file mode 100644 index d89928b51e..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/ValueNode.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.spi; - -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Optional; - -/** - * Concretization of AbstractTreeNode for leaf nodes which only contain data. - * Instances of this class report all children as absent, subtree version - * equal to this node's version and do not support mutable view. - */ -final class ValueNode extends AbstractTreeNode { - private static final Logger LOG = LoggerFactory.getLogger(ValueNode.class); - - protected ValueNode(final NormalizedNode data, final Version version) { - super(data, version); - } - - @Override - public Optional getChild(final PathArgument childId) { - LOG.warn("Attempted to access child {} of value-node {}", childId, this); - return Optional.absent(); - } - - @Override - public Version getSubtreeVersion() { - return getVersion(); - } - - @Override - public MutableTreeNode mutable() { - /** - * Value nodes can only we read/written/delete, which does a straight - * replace. That means they don't haver need to be made mutable. - */ - throw new UnsupportedOperationException(String.format("Attempted to mutate value-node %s", this)); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/Version.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/Version.java deleted file mode 100644 index 09a35d3b1a..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/spi/Version.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.spi; - -/** - * The concept of a version, either node version, or a subtree version. The - * only interface contract this class has is that no two versions are the - * same. - */ -public final class Version { - private Version() { - - } - - /** - * Create a new version, distinct from any other version. - * - * @return a new version. - */ - public Version next() { - return new Version(); - } - - /** - * Create an initial version. - * - * @return a new version. - */ - public static final Version initial() { - return new Version(); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DOMDataBrokerProxy.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DOMDataBrokerProxy.java index b0ccfb995d..4f44f361d5 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DOMDataBrokerProxy.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/osgi/DOMDataBrokerProxy.java @@ -4,7 +4,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.api.DOMDataChangeListener; -import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; @@ -19,7 +19,7 @@ public class DOMDataBrokerProxy extends AbstractBrokerServiceProxy> thirdDeleteTxFuture = thirdDeleteTx.commit(); - /** * We commit first transaction * */ assertCommitSuccessful(firstWriteTxFuture); - // Alocates store transaction + /** + * + * Allocates transaction from data store. + * + */ DOMDataReadTransaction storeReadTx = domBroker.newReadOnlyTransaction(); + /** * We verify transaction is commited to store, container should exists * in datastore. */ assertTestContainerExists(storeReadTx); + /** - * We commit third transaction - * + * third transaction is sealed and commited */ + ListenableFuture> thirdDeleteTxFuture = thirdDeleteTx.commit(); assertCommitSuccessful(thirdDeleteTxFuture); /** diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java deleted file mode 100644 index 413d81d029..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java +++ /dev/null @@ -1,250 +0,0 @@ -package org.opendaylight.controller.md.sal.dom.store.impl; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.concurrent.ExecutionException; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.MoreExecutors; - -public class InMemoryDataStoreTest { - - private SchemaContext schemaContext; - private InMemoryDOMDataStore domStore; - - @Before - public void setupStore() { - domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.sameThreadExecutor()); - schemaContext = TestModel.createTestContext(); - domStore.onGlobalContextUpdated(schemaContext); - - } - - @Test - public void testTransactionIsolation() throws InterruptedException, ExecutionException { - - assertNotNull(domStore); - - DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction(); - assertNotNull(readTx); - - DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); - assertNotNull(writeTx); - /** - * - * Writes /test in writeTx - * - */ - writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - - /** - * - * Reads /test from writeTx Read should return container. - * - */ - ListenableFuture>> writeTxContainer = writeTx.read(TestModel.TEST_PATH); - assertTrue(writeTxContainer.get().isPresent()); - - /** - * - * Reads /test from readTx Read should return Absent. - * - */ - ListenableFuture>> readTxContainer = readTx.read(TestModel.TEST_PATH); - assertFalse(readTxContainer.get().isPresent()); - } - - @Test - public void testTransactionCommit() throws InterruptedException, ExecutionException { - - DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); - assertNotNull(writeTx); - /** - * - * Writes /test in writeTx - * - */ - writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - - /** - * - * Reads /test from writeTx Read should return container. - * - */ - ListenableFuture>> writeTxContainer = writeTx.read(TestModel.TEST_PATH); - assertTrue(writeTxContainer.get().isPresent()); - - DOMStoreThreePhaseCommitCohort cohort = writeTx.ready(); - - assertThreePhaseCommit(cohort); - - Optional> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH) - .get(); - assertTrue(afterCommitRead.isPresent()); - } - - @Test - public void testTransactionAbort() throws InterruptedException, ExecutionException { - - DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); - assertNotNull(writeTx); - - assertTestContainerWrite(writeTx); - - DOMStoreThreePhaseCommitCohort cohort = writeTx.ready(); - - assertTrue(cohort.canCommit().get().booleanValue()); - cohort.preCommit().get(); - cohort.abort().get(); - - Optional> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH) - .get(); - assertFalse(afterCommitRead.isPresent()); - } - - @Test - public void testTransactionChain() throws InterruptedException, ExecutionException { - DOMStoreTransactionChain txChain = domStore.createTransactionChain(); - assertNotNull(txChain); - - /** - * We alocate new read-write transaction and write /test - * - * - */ - DOMStoreReadWriteTransaction firstTx = txChain.newReadWriteTransaction(); - assertTestContainerWrite(firstTx); - - /** - * First transaction is marked as ready, we are able to allocate chained - * transactions - */ - DOMStoreThreePhaseCommitCohort firstWriteTxCohort = firstTx.ready(); - - /** - * We alocate chained transaction - read transaction, note first one is - * still not commited to datastore. - */ - DOMStoreReadTransaction secondReadTx = txChain.newReadOnlyTransaction(); - - /** - * - * We test if we are able to read data from tx, read should not fail - * since we are using chained transaction. - * - * - */ - assertTestContainerExists(secondReadTx); - - /** - * - * We alocate next transaction, which is still based on first one, but - * is read-write. - * - */ - DOMStoreReadWriteTransaction thirdDeleteTx = txChain.newReadWriteTransaction(); - - /** - * We test existence of /test in third transaction container should - * still be visible from first one (which is still uncommmited). - * - * - */ - assertTestContainerExists(thirdDeleteTx); - - /** - * We delete node in third transaction - */ - thirdDeleteTx.delete(TestModel.TEST_PATH); - - /** - * third transaction is sealed. - */ - DOMStoreThreePhaseCommitCohort thirdDeleteTxCohort = thirdDeleteTx.ready(); - - /** - * We commit first transaction - * - */ - assertThreePhaseCommit(firstWriteTxCohort); - - // Alocates store transacion - DOMStoreReadTransaction storeReadTx = domStore.newReadOnlyTransaction(); - /** - * We verify transaction is commited to store, container should exists - * in datastore. - */ - assertTestContainerExists(storeReadTx); - /** - * We commit third transaction - * - */ - assertThreePhaseCommit(thirdDeleteTxCohort); - } - - @Test - @Ignore - public void testTransactionConflict() throws InterruptedException, ExecutionException { - DOMStoreReadWriteTransaction txOne = domStore.newReadWriteTransaction(); - DOMStoreReadWriteTransaction txTwo = domStore.newReadWriteTransaction(); - assertTestContainerWrite(txOne); - assertTestContainerWrite(txTwo); - - /** - * Commits transaction - */ - assertThreePhaseCommit(txOne.ready()); - - /** - * Asserts that txTwo could not be commited - */ - assertFalse(txTwo.ready().canCommit().get()); - } - - private static void assertThreePhaseCommit(final DOMStoreThreePhaseCommitCohort cohort) - throws InterruptedException, ExecutionException { - assertTrue(cohort.canCommit().get().booleanValue()); - cohort.preCommit().get(); - cohort.commit().get(); - } - - private static Optional> assertTestContainerWrite(final DOMStoreReadWriteTransaction writeTx) - throws InterruptedException, ExecutionException { - /** - * - * Writes /test in writeTx - * - */ - writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - - return assertTestContainerExists(writeTx); - } - - /** - * - * Reads /test from readTx Read should return container. - * - */ - private static Optional> assertTestContainerExists(DOMStoreReadTransaction readTx) - throws InterruptedException, ExecutionException { - - ListenableFuture>> writeTxContainer = readTx.read(TestModel.TEST_PATH); - assertTrue(writeTxContainer.get().isPresent()); - return writeTxContainer.get(); - } - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java index 2c965047db..91aa57c259 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java @@ -7,16 +7,16 @@ */ package org.opendaylight.controller.md.sal.dom.store.impl; -import java.io.InputStream; -import java.util.Collections; -import java.util.Set; - import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; +import java.io.InputStream; +import java.util.Collections; +import java.util.Set; + public class TestModel { public static final QName TEST_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModificationMetadataTreeTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModificationMetadataTreeTest.java deleted file mode 100644 index 4fb190fc82..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/ModificationMetadataTreeTest.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.ID_QNAME; -import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.INNER_LIST_QNAME; -import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.NAME_QNAME; -import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.OUTER_LIST_PATH; -import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.OUTER_LIST_QNAME; -import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.TEST_PATH; -import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.TEST_QNAME; -import static org.opendaylight.controller.md.sal.dom.store.impl.TestModel.VALUE_QNAME; -import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry; -import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder; -import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder; - -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.md.sal.dom.store.impl.TestModel; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTree; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeModification; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.TreeNodeFactory; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.spi.Version; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode; -import org.opendaylight.yangtools.yang.data.api.schema.MapNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -import com.google.common.base.Optional; - -/** - * - * Schema structure of document is - * - *
      - * container root { 
      - *      list list-a {
      - *              key leaf-a;
      - *              leaf leaf-a;
      - *              choice choice-a {
      - *                      case one {
      - *                              leaf one;
      - *                      }
      - *                      case two-three {
      - *                              leaf two;
      - *                              leaf three;
      - *                      }
      - *              }
      - *              list list-b {
      - *                      key leaf-b;
      - *                      leaf leaf-b;
      - *              }
      - *      }
      - * }
      - * 
      - * - */ -public class ModificationMetadataTreeTest { - - private static final Short ONE_ID = 1; - private static final Short TWO_ID = 2; - private static final String TWO_ONE_NAME = "one"; - private static final String TWO_TWO_NAME = "two"; - - private static final InstanceIdentifier OUTER_LIST_1_PATH = InstanceIdentifier.builder(OUTER_LIST_PATH) - .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, ONE_ID) // - .build(); - - private static final InstanceIdentifier OUTER_LIST_2_PATH = InstanceIdentifier.builder(OUTER_LIST_PATH) - .nodeWithKey(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) // - .build(); - - private static final InstanceIdentifier TWO_TWO_PATH = InstanceIdentifier.builder(OUTER_LIST_2_PATH) - .node(INNER_LIST_QNAME) // - .nodeWithKey(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME) // - .build(); - - private static final InstanceIdentifier TWO_TWO_VALUE_PATH = InstanceIdentifier.builder(TWO_TWO_PATH) - .node(VALUE_QNAME) // - .build(); - - private static final MapEntryNode BAR_NODE = mapEntryBuilder(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) // - .withChild(mapNodeBuilder(INNER_LIST_QNAME) // - .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) // - .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) // - .build()) // - .build(); - - private SchemaContext schemaContext; - private ModificationApplyOperation applyOper; - - @Before - public void prepare() { - schemaContext = TestModel.createTestContext(); - assertNotNull("Schema context must not be null.", schemaContext); - applyOper = SchemaAwareApplyOperation.from(schemaContext); - } - - /** - * Returns a test document - * - *
      -     * test
      -     *     outer-list
      -     *          id 1
      -     *     outer-list
      -     *          id 2
      -     *          inner-list
      -     *                  name "one"
      -     *          inner-list
      -     *                  name "two"
      -     *
      -     * 
      - * - * @return - */ - public NormalizedNode createDocumentOne() { - return ImmutableContainerNodeBuilder - .create() - .withNodeIdentifier(new NodeIdentifier(schemaContext.getQName())) - .withChild(createTestContainer()).build(); - - } - - private ContainerNode createTestContainer() { - return ImmutableContainerNodeBuilder - .create() - .withNodeIdentifier(new NodeIdentifier(TEST_QNAME)) - .withChild( - mapNodeBuilder(OUTER_LIST_QNAME) - .withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)) - .withChild(BAR_NODE).build()).build(); - } - - @Test - public void basicReadWrites() { - DataTreeModification modificationTree = new InMemoryDataTreeModification(new InMemoryDataTreeSnapshot(schemaContext, - TreeNodeFactory.createTreeNode(createDocumentOne(), Version.initial()), applyOper), - new SchemaAwareApplyOperationRoot(schemaContext)); - Optional> originalBarNode = modificationTree.readNode(OUTER_LIST_2_PATH); - assertTrue(originalBarNode.isPresent()); - assertSame(BAR_NODE, originalBarNode.get()); - - // writes node to /outer-list/1/inner_list/two/value - modificationTree.write(TWO_TWO_VALUE_PATH, ImmutableNodes.leafNode(VALUE_QNAME, "test")); - - // reads node to /outer-list/1/inner_list/two/value - // and checks if node is already present - Optional> barTwoCModified = modificationTree.readNode(TWO_TWO_VALUE_PATH); - assertTrue(barTwoCModified.isPresent()); - assertEquals(ImmutableNodes.leafNode(VALUE_QNAME, "test"), barTwoCModified.get()); - - // delete node to /outer-list/1/inner_list/two/value - modificationTree.delete(TWO_TWO_VALUE_PATH); - Optional> barTwoCAfterDelete = modificationTree.readNode(TWO_TWO_VALUE_PATH); - assertFalse(barTwoCAfterDelete.isPresent()); - } - - - public DataTreeModification createEmptyModificationTree() { - /** - * Creates empty Snapshot with associated schema context. - */ - DataTree t = InMemoryDataTreeFactory.getInstance().create(); - t.setSchemaContext(schemaContext); - - /** - * - * Creates Mutable Data Tree based on provided snapshot and schema - * context. - * - */ - return t.takeSnapshot().newModification(); - } - - @Test - public void createFromEmptyState() { - - DataTreeModification modificationTree = createEmptyModificationTree(); - /** - * Writes empty container node to /test - * - */ - modificationTree.write(TEST_PATH, ImmutableNodes.containerNode(TEST_QNAME)); - - /** - * Writes empty list node to /test/outer-list - */ - modificationTree.write(OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(OUTER_LIST_QNAME).build()); - - /** - * Reads list node from /test/outer-list - */ - Optional> potentialOuterList = modificationTree.readNode(OUTER_LIST_PATH); - assertTrue(potentialOuterList.isPresent()); - - /** - * Reads container node from /test and verifies that it contains test - * node - */ - Optional> potentialTest = modificationTree.readNode(TEST_PATH); - ContainerNode containerTest = assertPresentAndType(potentialTest, ContainerNode.class); - - /** - * - * Gets list from returned snapshot of /test and verifies it contains - * outer-list - * - */ - assertPresentAndType(containerTest.getChild(new NodeIdentifier(OUTER_LIST_QNAME)), MapNode.class); - - } - - @Test - public void writeSubtreeReadChildren() { - DataTreeModification modificationTree = createEmptyModificationTree(); - modificationTree.write(TEST_PATH, createTestContainer()); - Optional> potential = modificationTree.readNode(TWO_TWO_PATH); - assertPresentAndType(potential, MapEntryNode.class); - } - - @Test - public void writeSubtreeDeleteChildren() { - DataTreeModification modificationTree = createEmptyModificationTree(); - modificationTree.write(TEST_PATH, createTestContainer()); - - // We verify data are present - Optional> potentialBeforeDelete = modificationTree.readNode(TWO_TWO_PATH); - assertPresentAndType(potentialBeforeDelete, MapEntryNode.class); - - modificationTree.delete(TWO_TWO_PATH); - Optional> potentialAfterDelete = modificationTree.readNode(TWO_TWO_PATH); - assertFalse(potentialAfterDelete.isPresent()); - - } - - private static T assertPresentAndType(final Optional potential, final Class type) { - assertNotNull(potential); - assertTrue(potential.isPresent()); - assertTrue(type.isInstance(potential.get())); - return type.cast(potential.get()); - } - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/SchemaAwareApplyOperationRoot.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/SchemaAwareApplyOperationRoot.java deleted file mode 100644 index 03ece2f5e0..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/data/SchemaAwareApplyOperationRoot.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2014 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.md.sal.dom.store.impl.tree.data; - -import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public class SchemaAwareApplyOperationRoot extends DataNodeContainerModificationStrategy { - private final SchemaContext context; - - public SchemaAwareApplyOperationRoot(final SchemaContext context) { - super(context,ContainerNode.class); - this.context = context; - } - - public SchemaContext getContext() { - return context; - } - - @Override - public String toString() { - return "SchemaAwareApplyOperationRoot [context=" + context + "]"; - } - - @Override - @SuppressWarnings("rawtypes") - protected DataContainerNodeBuilder createBuilder(NormalizedNode original) { - return ImmutableContainerNodeBuilder.create((ContainerNode) original); - } -} diff --git a/opendaylight/md-sal/sal-dom-spi/pom.xml b/opendaylight/md-sal/sal-dom-spi/pom.xml index 660a67923f..88ac86a45e 100644 --- a/opendaylight/md-sal/sal-dom-spi/pom.xml +++ b/opendaylight/md-sal/sal-dom-spi/pom.xml @@ -15,6 +15,39 @@ sal-core-api + + + + org.opendaylight.yangtools + yang-maven-plugin + + + config + + generate-sources + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + ${jmxGeneratorPath} + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + ${salGeneratorPath} + + + true + + + + + + + scm:git:ssh://git.opendaylight.org:29418/controller.git scm:git:ssh://git.opendaylight.org:29418/controller.git diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/yang/opendaylight-config-dom-datastore.yang b/opendaylight/md-sal/sal-dom-spi/src/main/yang/opendaylight-config-dom-datastore.yang new file mode 100644 index 0000000000..9a3ab181e0 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-spi/src/main/yang/opendaylight-config-dom-datastore.yang @@ -0,0 +1,22 @@ +module opendaylight-config-dom-datastore { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store"; + prefix "config-dom-store-spi"; + + import config { prefix config; revision-date 2013-04-05; } + + description + "DOM Service Provider Interface definition for MD-SAL config store"; + + revision "2014-06-17" { + description + "Initial revision"; + } + + identity config-dom-datastore { + base "config:service-type"; + config:java-class "org.opendaylight.controller.sal.core.spi.data.DOMStore"; + + } + +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/yang/opendaylight-operational-dom-datastore.yang b/opendaylight/md-sal/sal-dom-spi/src/main/yang/opendaylight-operational-dom-datastore.yang new file mode 100644 index 0000000000..fd408840bb --- /dev/null +++ b/opendaylight/md-sal/sal-dom-spi/src/main/yang/opendaylight-operational-dom-datastore.yang @@ -0,0 +1,22 @@ +module opendaylight-operational-dom-datastore { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store"; + prefix "operational-dom-store-spi"; + + import config { prefix config; revision-date 2013-04-05; } + + description + "DOM Service Provider Interface definition for MD-SAL operational store"; + + revision "2014-06-17" { + description + "Initial revision"; + } + + identity operational-dom-datastore { + base "config:service-type"; + config:java-class "org.opendaylight.controller.sal.core.spi.data.DOMStore"; + + } + +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-inmemory-datastore/pom.xml b/opendaylight/md-sal/sal-inmemory-datastore/pom.xml new file mode 100644 index 0000000000..dadef821eb --- /dev/null +++ b/opendaylight/md-sal/sal-inmemory-datastore/pom.xml @@ -0,0 +1,191 @@ + + + 4.0.0 + + org.opendaylight.controller + sal-parent + 1.1-SNAPSHOT + + + sal-inmemory-datastore + + bundle + + + + com.google.guava + guava + + + + + + org.opendaylight.controller + config-api + + + + org.opendaylight.controller + sal-binding-api + + + + org.opendaylight.controller + sal-binding-config + + + + org.opendaylight.controller + sal-common-api + + + + org.opendaylight.controller + sal-common-util + + + + org.opendaylight.controller + sal-core-api + + + org.opendaylight.controller + sal-core-spi + + + + org.opendaylight.yangtools + concepts + + + + org.opendaylight.yangtools + util + + + + org.opendaylight.yangtools + yang-binding + + + + org.opendaylight.yangtools + yang-common + + + + org.opendaylight.yangtools + yang-data-api + + + org.opendaylight.yangtools + yang-data-impl + + + org.opendaylight.yangtools + yang-parser-impl + + + + org.osgi + org.osgi.core + + + + org.slf4j + slf4j-api + + + + + junit + junit + test + + + org.slf4j + slf4j-simple + ${slf4j.version} + test + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.groupId}.${project.artifactId} + + org.opendaylight.controller.md.sal.dom.store.impl.* + + * + + + + + org.jacoco + jacoco-maven-plugin + + + org.opendaylight.controller.* + + false + + + + pre-test + + prepare-agent + + + + post-test + + report + + test + + + + + org.opendaylight.yangtools + yang-maven-plugin + + + config + + generate-sources + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + ${jmxGeneratorPath} + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + ${salGeneratorPath} + + + true + + + + + + + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + HEAD + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Architecture:Clustering + + + diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java new file mode 100644 index 0000000000..3ed02dfb41 --- /dev/null +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java @@ -0,0 +1,27 @@ +package org.opendaylight.controller.config.yang.inmemory_datastore_provider; + +import com.google.common.util.concurrent.MoreExecutors; +import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; + +public class InMemoryConfigDataStoreProviderModule extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryConfigDataStoreProviderModule { + public InMemoryConfigDataStoreProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public InMemoryConfigDataStoreProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.inmemory_datastore_provider.InMemoryConfigDataStoreProviderModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + InMemoryDOMDataStore ids = new InMemoryDOMDataStore("DOM-CFG", MoreExecutors.sameThreadExecutor()); + getSchemaServiceDependency().registerSchemaServiceListener(ids); + return ids; + } + +} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModuleFactory.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModuleFactory.java new file mode 100644 index 0000000000..1931c14347 --- /dev/null +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: opendaylight-inmemory-datastore-provider yang module local name: inmemory-config-datastore-provider +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Thu Jun 19 17:10:42 PDT 2014 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.controller.config.yang.inmemory_datastore_provider; +public class InMemoryConfigDataStoreProviderModuleFactory extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryConfigDataStoreProviderModuleFactory { + +} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java new file mode 100644 index 0000000000..eea95990a1 --- /dev/null +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java @@ -0,0 +1,27 @@ +package org.opendaylight.controller.config.yang.inmemory_datastore_provider; + +import com.google.common.util.concurrent.MoreExecutors; +import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; + +public class InMemoryOperationalDataStoreProviderModule extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryOperationalDataStoreProviderModule { + public InMemoryOperationalDataStoreProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public InMemoryOperationalDataStoreProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.inmemory_datastore_provider.InMemoryOperationalDataStoreProviderModule oldModule, java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void customValidation() { + // add custom validation form module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + InMemoryDOMDataStore ids = new InMemoryDOMDataStore("DOM-OPER", MoreExecutors.sameThreadExecutor()); + getSchemaServiceDependency().registerSchemaServiceListener(ids); + return ids; + } + +} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModuleFactory.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModuleFactory.java new file mode 100644 index 0000000000..49bc6a2064 --- /dev/null +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: opendaylight-inmemory-datastore-provider yang module local name: inmemory-operational-datastore-provider +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Thu Jun 19 17:10:42 PDT 2014 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.controller.config.yang.inmemory_datastore_provider; +public class InMemoryOperationalDataStoreProviderModuleFactory extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryOperationalDataStoreProviderModuleFactory { + +} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDOMStoreTransaction.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDOMStoreTransaction.java similarity index 100% rename from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDOMStoreTransaction.java rename to opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDOMStoreTransaction.java diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java similarity index 100% rename from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java rename to opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java similarity index 100% rename from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java rename to opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java similarity index 100% rename from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java rename to opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java similarity index 95% rename from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java rename to opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java index b0c4274fa5..bef37980e5 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java @@ -7,27 +7,25 @@ */ package org.opendaylight.controller.md.sal.dom.store.impl; -import static com.google.common.base.Preconditions.checkState; - -import java.util.Collections; -import java.util.concurrent.Callable; -import java.util.concurrent.atomic.AtomicLong; - -import javax.annotation.concurrent.GuardedBy; - +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.ListeningExecutorService; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.md.sal.dom.store.impl.SnapshotBackedWriteTransaction.TransactionReadyPrototype; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.ConflictingModificationAppliedException; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTree; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidate; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeModification; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeSnapshot; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataValidationFailedException; +import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException; import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.data.InMemoryDataTreeFactory; +import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory; import org.opendaylight.controller.sal.core.spi.data.DOMStore; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; @@ -44,12 +42,12 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; +import javax.annotation.concurrent.GuardedBy; +import java.util.Collections; +import java.util.concurrent.Callable; +import java.util.concurrent.atomic.AtomicLong; + +import static com.google.common.base.Preconditions.checkState; /** * In-memory DOM Data Store @@ -61,12 +59,13 @@ import com.google.common.util.concurrent.ListeningExecutorService; * */ public class InMemoryDOMDataStore implements DOMStore, Identifiable, SchemaContextListener, - TransactionReadyPrototype { + TransactionReadyPrototype,AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataStore.class); private final DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(); private final ListenerTree listenerTree = ListenerTree.create(); private final AtomicLong txCounter = new AtomicLong(0); private final ListeningExecutorService executor; + private final String name; public InMemoryDOMDataStore(final String name, final ListeningExecutorService executor) { @@ -104,6 +103,10 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch dataTree.setSchemaContext(ctx); } + @Override + public void close(){ + executor.shutdownNow(); + } @Override public >> ListenerRegistration registerChangeListener( final InstanceIdentifier path, final L listener, final DataChangeScope scope) { @@ -218,6 +221,8 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable, Sch @Override public void close() { + executor.shutdownNow(); + } protected synchronized void onTransactionFailed(final SnapshotBackedWriteTransaction transaction, diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java similarity index 98% rename from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java rename to opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java index 5021d070e1..71a3534c81 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java @@ -7,26 +7,18 @@ */ package org.opendaylight.controller.md.sal.dom.store.impl; -import static org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.builder; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; -import java.util.concurrent.Callable; - +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.google.common.collect.Multimap; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.Builder; import org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.SimpleEventFactory; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidate; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.DataTreeCandidateNode; import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree; import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree.Node; import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree.Walker; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; @@ -34,15 +26,22 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; +import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode; +import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -import com.google.common.collect.Multimap; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; +import java.util.concurrent.Callable; + +import static org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.builder; /** * Resolve Data Change Events based on modifications and listeners @@ -94,7 +93,7 @@ final class ResolveDataChangeEventsTask implements Callable, Identifiable { diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang b/opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang new file mode 100644 index 0000000000..03220a3e5d --- /dev/null +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/yang/opendaylight-inmemory-datastore-provider.yang @@ -0,0 +1,71 @@ + +module opendaylight-inmemory-datastore-provider { + + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:inmemory-datastore-provider"; + prefix "inmemory-datastore-provider"; + + import config { prefix config; revision-date 2013-04-05; } + import rpc-context { prefix rpcx; revision-date 2013-06-17; } + import opendaylight-config-dom-datastore {prefix config-dom-store-spi;} + import opendaylight-operational-dom-datastore {prefix operational-dom-store-spi;} + import opendaylight-md-sal-dom {prefix sal;} + + description + "InMemory datastore provider implementation for config & operational datastore"; + + revision "2014-06-17" { + description + "Initial revision."; + } + + // This is the definition of the service implementation as a module identity. + identity inmemory-config-datastore-provider { + base config:module-type; + config:provided-service config-dom-store-spi:config-dom-datastore; + config:java-name-prefix InMemoryConfigDataStoreProvider; + } + + // This is the definition of the service implementation as a module identity. + + identity inmemory-operational-datastore-provider { + base config:module-type; + config:provided-service operational-dom-store-spi:operational-dom-datastore; + config:java-name-prefix InMemoryOperationalDataStoreProvider; + } + + + // Augments the 'configuration' choice node under modules/module. + augment "/config:modules/config:module/config:configuration" { + case inmemory-config-datastore-provider { + when "/config:modules/config:module/config:type = 'inmemory-config-datastore-provider'"; + + container schema-service { + uses config:service-ref { + refine type { + mandatory false; + config:required-identity sal:schema-service; + } + } + } + } + } + + + + // Augments the 'configuration' choice node under modules/module. + augment "/config:modules/config:module/config:configuration" { + case inmemory-operational-datastore-provider { + when "/config:modules/config:module/config:type = 'inmemory-operational-datastore-provider'"; + + container schema-service { + uses config:service-ref { + refine type { + mandatory false; + config:required-identity sal:schema-service; + } + } + } + } + } +} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java new file mode 100644 index 0000000000..369a7da138 --- /dev/null +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java @@ -0,0 +1,248 @@ +package org.opendaylight.controller.md.sal.dom.store.impl; + +import com.google.common.base.Optional; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; + +import java.util.concurrent.ExecutionException; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + + +public class InMemoryDataStoreTest { + + private SchemaContext schemaContext; + private InMemoryDOMDataStore domStore; + + @Before + public void setupStore() { + domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.sameThreadExecutor()); + schemaContext = TestModel.createTestContext(); + domStore.onGlobalContextUpdated(schemaContext); + + } + + @Test + public void testTransactionIsolation() throws InterruptedException, ExecutionException { + + assertNotNull(domStore); + + DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction(); + assertNotNull(readTx); + + DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); + assertNotNull(writeTx); + /** + * + * Writes /test in writeTx + * + */ + writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); + + /** + * + * Reads /test from writeTx Read should return container. + * + */ + ListenableFuture>> writeTxContainer = writeTx.read(TestModel.TEST_PATH); + assertTrue(writeTxContainer.get().isPresent()); + + /** + * + * Reads /test from readTx Read should return Absent. + * + */ + ListenableFuture>> readTxContainer = readTx.read(TestModel.TEST_PATH); + assertFalse(readTxContainer.get().isPresent()); + } + + @Test + public void testTransactionCommit() throws InterruptedException, ExecutionException { + + DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); + assertNotNull(writeTx); + /** + * + * Writes /test in writeTx + * + */ + writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); + + /** + * + * Reads /test from writeTx Read should return container. + * + */ + ListenableFuture>> writeTxContainer = writeTx.read(TestModel.TEST_PATH); + assertTrue(writeTxContainer.get().isPresent()); + + DOMStoreThreePhaseCommitCohort cohort = writeTx.ready(); + + assertThreePhaseCommit(cohort); + + Optional> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH) + .get(); + assertTrue(afterCommitRead.isPresent()); + } + + @Test + public void testTransactionAbort() throws InterruptedException, ExecutionException { + + DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); + assertNotNull(writeTx); + + assertTestContainerWrite(writeTx); + + DOMStoreThreePhaseCommitCohort cohort = writeTx.ready(); + + assertTrue(cohort.canCommit().get().booleanValue()); + cohort.preCommit().get(); + cohort.abort().get(); + + Optional> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH) + .get(); + assertFalse(afterCommitRead.isPresent()); + } + + @Test + public void testTransactionChain() throws InterruptedException, ExecutionException { + DOMStoreTransactionChain txChain = domStore.createTransactionChain(); + assertNotNull(txChain); + + /** + * We alocate new read-write transaction and write /test + * + * + */ + DOMStoreReadWriteTransaction firstTx = txChain.newReadWriteTransaction(); + assertTestContainerWrite(firstTx); + + /** + * First transaction is marked as ready, we are able to allocate chained + * transactions + */ + DOMStoreThreePhaseCommitCohort firstWriteTxCohort = firstTx.ready(); + + /** + * We alocate chained transaction - read transaction, note first one is + * still not commited to datastore. + */ + DOMStoreReadTransaction secondReadTx = txChain.newReadOnlyTransaction(); + + /** + * + * We test if we are able to read data from tx, read should not fail + * since we are using chained transaction. + * + * + */ + assertTestContainerExists(secondReadTx); + + /** + * + * We alocate next transaction, which is still based on first one, but + * is read-write. + * + */ + DOMStoreReadWriteTransaction thirdDeleteTx = txChain.newReadWriteTransaction(); + + /** + * We test existence of /test in third transaction container should + * still be visible from first one (which is still uncommmited). + * + * + */ + assertTestContainerExists(thirdDeleteTx); + + /** + * We delete node in third transaction + */ + thirdDeleteTx.delete(TestModel.TEST_PATH); + + /** + * third transaction is sealed. + */ + DOMStoreThreePhaseCommitCohort thirdDeleteTxCohort = thirdDeleteTx.ready(); + + /** + * We commit first transaction + * + */ + assertThreePhaseCommit(firstWriteTxCohort); + + // Alocates store transacion + DOMStoreReadTransaction storeReadTx = domStore.newReadOnlyTransaction(); + /** + * We verify transaction is commited to store, container should exists + * in datastore. + */ + assertTestContainerExists(storeReadTx); + /** + * We commit third transaction + * + */ + assertThreePhaseCommit(thirdDeleteTxCohort); + } + + @Test + @Ignore + public void testTransactionConflict() throws InterruptedException, ExecutionException { + DOMStoreReadWriteTransaction txOne = domStore.newReadWriteTransaction(); + DOMStoreReadWriteTransaction txTwo = domStore.newReadWriteTransaction(); + assertTestContainerWrite(txOne); + assertTestContainerWrite(txTwo); + + /** + * Commits transaction + */ + assertThreePhaseCommit(txOne.ready()); + + /** + * Asserts that txTwo could not be commited + */ + assertFalse(txTwo.ready().canCommit().get()); + } + + private static void assertThreePhaseCommit(final DOMStoreThreePhaseCommitCohort cohort) + throws InterruptedException, ExecutionException { + assertTrue(cohort.canCommit().get().booleanValue()); + cohort.preCommit().get(); + cohort.commit().get(); + } + + private static Optional> assertTestContainerWrite(final DOMStoreReadWriteTransaction writeTx) + throws InterruptedException, ExecutionException { + /** + * + * Writes /test in writeTx + * + */ + writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); + + return assertTestContainerExists(writeTx); + } + + /** + * Reads /test from readTx Read should return container. + */ + private static Optional> assertTestContainerExists(DOMStoreReadTransaction readTx) + throws InterruptedException, ExecutionException { + + ListenableFuture>> writeTxContainer = readTx.read(TestModel.TEST_PATH); + assertTrue(writeTxContainer.get().isPresent()); + return writeTxContainer.get(); + } + +} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java new file mode 100644 index 0000000000..3feeb29672 --- /dev/null +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014 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.md.sal.dom.store.impl; + +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; + +import java.io.InputStream; +import java.util.Collections; +import java.util.Set; + +public class TestModel { + + public static final QName TEST_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", + "test"); + public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list"); + public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list"); + public static final QName OUTER_CHOICE_QNAME = QName.create(TEST_QNAME, "outer-choice"); + public static final QName ID_QNAME = QName.create(TEST_QNAME, "id"); + public static final QName NAME_QNAME = QName.create(TEST_QNAME, "name"); + public static final QName VALUE_QNAME = QName.create(TEST_QNAME, "value"); + private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang"; + + public static final InstanceIdentifier TEST_PATH = InstanceIdentifier.of(TEST_QNAME); + public static final InstanceIdentifier OUTER_LIST_PATH = InstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build(); + public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two"); + public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three"); + + + public static final InputStream getDatastoreTestInputStream() { + return getInputStream(DATASTORE_TEST_YANG); + } + + private static InputStream getInputStream(final String resourceName) { + return TestModel.class.getResourceAsStream(DATASTORE_TEST_YANG); + } + + public static SchemaContext createTestContext() { + YangParserImpl parser = new YangParserImpl(); + Set modules = parser.parseYangModelsFromStreams(Collections.singletonList(getDatastoreTestInputStream())); + return parser.resolveSchemaContext(modules); + } +} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/resources/odl-datastore-test.yang b/opendaylight/md-sal/sal-inmemory-datastore/src/test/resources/odl-datastore-test.yang new file mode 100644 index 0000000000..17541fecab --- /dev/null +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/resources/odl-datastore-test.yang @@ -0,0 +1,42 @@ +module odl-datastore-test { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test"; + prefix "store-test"; + + revision "2014-03-13" { + description "Initial revision."; + } + + container test { + list outer-list { + key id; + leaf id { + type uint16; + } + choice outer-choice { + case one { + leaf one { + type string; + } + } + case two-three { + leaf two { + type string; + } + leaf three { + type string; + } + } + } + list inner-list { + key name; + leaf name { + type string; + } + leaf value { + type string; + } + } + } + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java index f73d9cc72f..037bfb4a82 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java @@ -12,13 +12,10 @@ import static org.opendaylight.controller.config.api.JmxAttributeValidationExcep import java.io.File; import java.io.InputStream; -import java.net.InetAddress; import java.net.InetSocketAddress; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import org.opendaylight.controller.netconf.client.NetconfClientDispatcher; -import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl; import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration; import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfiguration; import org.opendaylight.controller.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder; @@ -33,19 +30,16 @@ import org.opendaylight.controller.sal.core.api.Broker; import org.opendaylight.protocol.framework.ReconnectStrategy; import org.opendaylight.protocol.framework.ReconnectStrategyFactory; import org.opendaylight.protocol.framework.TimedReconnectStrategy; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Host; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; import org.opendaylight.yangtools.yang.model.util.repo.AbstractCachingSchemaSourceProvider; import org.opendaylight.yangtools.yang.model.util.repo.FilesystemSchemaCachingProvider; import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider; import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProviders; import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Preconditions; -import com.google.common.net.InetAddresses; -import io.netty.util.HashedWheelTimer; - /** * */ @@ -67,6 +61,7 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co @Override protected void customValidation() { checkNotNull(getAddress(), addressJmxAttribute); + checkCondition(isHostAddressPresent(getAddress()), "Host address not present in " + getAddress(), addressJmxAttribute); checkNotNull(getPort(), portJmxAttribute); checkNotNull(getDomRegistry(), portJmxAttribute); checkNotNull(getDomRegistry(), domRegistryJmxAttribute); @@ -77,11 +72,9 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co checkNotNull(getBetweenAttemptsTimeoutMillis(), betweenAttemptsTimeoutMillisJmxAttribute); checkCondition(getBetweenAttemptsTimeoutMillis() > 0, "must be > 0", betweenAttemptsTimeoutMillisJmxAttribute); - // FIXME BUG-944 remove backwards compatibility - if(getClientDispatcher() == null) { - checkCondition(getBossThreadGroup() != null, "Client dispatcher was not set, thread groups have to be set instead", bossThreadGroupJmxAttribute); - checkCondition(getWorkerThreadGroup() != null, "Client dispatcher was not set, thread groups have to be set instead", workerThreadGroupJmxAttribute); - } + checkNotNull(getClientDispatcher(), clientDispatcherJmxAttribute); + checkNotNull(getBindingRegistry(), bindingRegistryJmxAttribute); + checkNotNull(getProcessingExecutor(), processingExecutorJmxAttribute); // Check username + password in case of ssh if(getTcpOnly() == false) { @@ -89,33 +82,21 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co checkNotNull(getPassword(), passwordJmxAttribute); } - // FIXME BUG 944 remove this warning - if(getBindingRegistry() == null) { - logger.warn("Configuration property: \"binding-registry\" not set for sal-netconf-connector (" + getIdentifier() + "). " + - "Netconf-connector now requires a dependency on \"binding-broker-osgi-registry\". " + - "The dependency is optional for now to preserve backwards compatibility, but will be mandatory in the future. " + - "Please set the property as in \"01-netconf-connector\" initial config file. " + - "The service will be retrieved from OSGi service registry now."); - } + } - // FIXME BUG 944 remove this warning - if(getProcessingExecutor() == null) { - logger.warn("Configuration property: \"processing-executor\" not set for sal-netconf-connector (" + getIdentifier() + "). " + - "Netconf-connector now requires a dependency on \"threadpool\". " + - "The dependency is optional for now to preserve backwards compatibility, but will be mandatory in the future. " + - "Please set the property as in \"01-netconf-connector\" initial config file. " + - "New instance will be created for the executor."); - } + private boolean isHostAddressPresent(Host address) { + return address.getDomainName() != null || + address.getIpAddress() != null && (address.getIpAddress().getIpv4Address() != null || address.getIpAddress().getIpv6Address() != null); } @Override public java.lang.AutoCloseable createInstance() { final RemoteDeviceId id = new RemoteDeviceId(getIdentifier()); - final ExecutorService globalProcessingExecutor = getGlobalProcessingExecutor(); + final ExecutorService globalProcessingExecutor = getProcessingExecutorDependency().getExecutor(); final Broker domBroker = getDomRegistryDependency(); - final BindingAwareBroker bindingBroker = getBindingRegistryBackwards(); + final BindingAwareBroker bindingBroker = getBindingRegistryDependency(); final RemoteDeviceHandler salFacade = new NetconfDeviceSalFacade(id, domBroker, bindingBroker, bundleContext, globalProcessingExecutor); final NetconfDevice device = @@ -123,8 +104,7 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co final NetconfDeviceCommunicator listener = new NetconfDeviceCommunicator(id, device); final NetconfReconnectingClientConfiguration clientConfig = getClientConfig(listener); - // FIXME BUG-944 remove backwards compatibility - final NetconfClientDispatcher dispatcher = getClientDispatcher() == null ? createDispatcher() : getClientDispatcherDependency(); + final NetconfClientDispatcher dispatcher = getClientDispatcherDependency(); listener.initializeRemoteConnection(dispatcher, clientConfig); return new AutoCloseable() { @@ -136,30 +116,6 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co }; } - private BindingAwareBroker getBindingRegistryBackwards() { - if(getBindingRegistry() != null) { - return getBindingRegistryDependency(); - } else { - // FIXME BUG 944 remove backwards compatibility - final ServiceReference serviceReference = bundleContext.getServiceReference(BindingAwareBroker.class); - Preconditions - .checkNotNull( - serviceReference, - "Unable to retrieve %s from OSGi service registry, use binding-registry config property to inject %s with config subsystem", - BindingAwareBroker.class, BindingAwareBroker.class); - return bundleContext.getService(serviceReference); - } - } - - private ExecutorService getGlobalProcessingExecutor() { - if(getProcessingExecutor() != null) { - return getProcessingExecutorDependency().getExecutor(); - } else { - // FIXME BUG 944 remove backwards compatibility - return Executors.newCachedThreadPool(); - } - } - private synchronized AbstractCachingSchemaSourceProvider getGlobalNetconfSchemaProvider() { if(GLOBAL_NETCONF_SOURCE_PROVIDER == null) { final String storageFile = "cache/schema"; @@ -171,16 +127,6 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co return GLOBAL_NETCONF_SOURCE_PROVIDER; } - // FIXME BUG-944 remove backwards compatibility - /** - * @deprecated Use getClientDispatcherDependency method instead to retrieve injected dispatcher. - * This one creates new instance of NetconfClientDispatcher and will be removed in near future. - */ - @Deprecated - private NetconfClientDispatcher createDispatcher() { - return new NetconfClientDispatcherImpl(getBossThreadGroupDependency(), getWorkerThreadGroupDependency(), new HashedWheelTimer()); - } - public void setBundleContext(final BundleContext bundleContext) { this.bundleContext = bundleContext; } @@ -226,15 +172,12 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co } private InetSocketAddress getSocketAddress() { - /* - * Uncomment after Switch to IP Address - if(getAddress().getIpv4Address() != null) { - addressValue = getAddress().getIpv4Address().getValue(); + if(getAddress().getDomainName() != null) { + return new InetSocketAddress(getAddress().getDomainName().getValue(), getPort().getValue()); } else { - addressValue = getAddress().getIpv6Address().getValue(); + IpAddress ipAddress = getAddress().getIpAddress(); + String ip = ipAddress.getIpv4Address() != null ? ipAddress.getIpv4Address().getValue() : ipAddress.getIpv6Address().getValue(); + return new InetSocketAddress(ip, getPort().getValue()); } - */ - final InetAddress inetAddress = InetAddresses.forString(getAddress()); - return new InetSocketAddress(inetAddress, getPort().intValue()); } } diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceCommitHandler.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceCommitHandler.java index 457b8c36b9..8b6ac7d567 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceCommitHandler.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceCommitHandler.java @@ -48,7 +48,7 @@ public final class NetconfDeviceCommitHandler implements DataCommitHandlerabsent(), Optional.of(value))); + sendEditRpc(createEditConfigStructure(key, Optional.absent(), Optional.of(value)), Optional.absent()); } private void sendDelete(final InstanceIdentifier toDelete) throws InterruptedException, ExecutionException { - sendEditRpc(createEditConfigStructure(toDelete, Optional.of("delete"), Optional.absent())); + // FIXME use org.opendaylight.yangtools.yang.data.api.ModifyAction instead of strings + // TODO add string lowercase value to ModifyAction enum entries + sendEditRpc(createEditConfigStructure(toDelete, Optional.of("delete"), Optional.absent()), Optional.of("none")); } - private void sendEditRpc(final CompositeNode editStructure) throws InterruptedException, ExecutionException { - final ImmutableCompositeNode editConfigRequest = createEditConfigRequest(editStructure); + private void sendEditRpc(final CompositeNode editStructure, final Optional defaultOperation) throws InterruptedException, ExecutionException { + final ImmutableCompositeNode editConfigRequest = createEditConfigRequest(editStructure, defaultOperation); final RpcResult rpcResult = rpc.invokeRpc(NETCONF_EDIT_CONFIG_QNAME, editConfigRequest).get(); - // TODO 874 add default operation when sending delete // Check result if(rpcResult.isSuccessful() == false) { @@ -106,16 +108,26 @@ final class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransact } } - private ImmutableCompositeNode createEditConfigRequest(final CompositeNode editStructure) { + private ImmutableCompositeNode createEditConfigRequest(final CompositeNode editStructure, Optional defaultOperation) { final CompositeNodeBuilder ret = ImmutableCompositeNode.builder(); + // Target final Node targetWrapperNode = ImmutableCompositeNode.create(NETCONF_TARGET_QNAME, ImmutableList.>of(targetNode)); ret.add(targetWrapperNode); + // Default operation + if(defaultOperation.isPresent()) { + SimpleNode defOp = NodeFactory.createImmutableSimpleNode(NETCONF_DEFAULT_OPERATION_QNAME, null, defaultOperation.get()); + ret.add(defOp); + } + + // Error option if(rollbackSupported) { ret.addLeaf(NETCONF_ERROR_OPTION_QNAME, ROLLBACK_ON_ERROR_OPTION); } + ret.setQName(NETCONF_EDIT_CONFIG_QNAME); + // Edit content ret.add(editStructure); return ret.toInstance(); } diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java index 2adc1be79e..21f94474f8 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/schema/mapping/NetconfMessageTransformer.java @@ -70,6 +70,8 @@ public class NetconfMessageTransformer implements MessageTransformer> RUNNING = Collections.> singletonList(new SimpleNodeTOImpl<>(NETCONF_RUNNING_QNAME, - null, null)); + static List> RUNNING = Collections.> singletonList(new SimpleNodeTOImpl<>(NETCONF_RUNNING_QNAME, null, null)); public static QName NETCONF_SOURCE_QNAME = QName.create(NETCONF_QNAME, "source"); public static CompositeNode CONFIG_SOURCE_RUNNING = new CompositeNodeTOImpl(NETCONF_SOURCE_QNAME, null, RUNNING); public static QName NETCONF_CANDIDATE_QNAME = QName.create(NETCONF_QNAME, "candidate"); @@ -65,6 +63,7 @@ public class NetconfMessageTransformUtil { public static QName NETCONF_CONFIG_QNAME = QName.create(NETCONF_QNAME, "config"); public static QName NETCONF_COMMIT_QNAME = QName.create(NETCONF_QNAME, "commit"); public static QName NETCONF_OPERATION_QNAME = QName.create(NETCONF_QNAME, "operation"); + public static QName NETCONF_DEFAULT_OPERATION_QNAME = QName.create(NETCONF_OPERATION_QNAME, "default-operation"); public static QName NETCONF_EDIT_CONFIG_QNAME = QName.create(NETCONF_QNAME, "edit-config"); public static QName NETCONF_GET_CONFIG_QNAME = QName.create(NETCONF_QNAME, "get-config"); public static QName NETCONF_TYPE_QNAME = QName.create(NETCONF_QNAME, "type"); diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/yang/odl-sal-netconf-connector-cfg.yang b/opendaylight/md-sal/sal-netconf-connector/src/main/yang/odl-sal-netconf-connector-cfg.yang index c59c41c437..6bad4798c2 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/yang/odl-sal-netconf-connector-cfg.yang +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/yang/odl-sal-netconf-connector-cfg.yang @@ -9,6 +9,7 @@ module odl-sal-netconf-connector-cfg { import opendaylight-md-sal-dom {prefix dom;} import opendaylight-md-sal-binding {prefix md-sal-binding; revision-date 2013-10-28;} import odl-netconf-cfg { prefix cfg-net; revision-date 2014-04-08; } + import ietf-inet-types {prefix inet; revision-date "2010-09-24";} description "Service definition for Binding Aware MD-SAL."; @@ -38,11 +39,11 @@ module odl-sal-netconf-connector-cfg { when "/config:modules/config:module/config:type = 'sal-netconf-connector'"; leaf address { - type string; + type inet:host; } leaf port { - type uint32; + type inet:port-number; } leaf tcp-only { @@ -69,40 +70,16 @@ module odl-sal-netconf-connector-cfg { container binding-registry { uses config:service-ref { refine type { - // FIXME BUG-944 make mandatory (remove backwards compatibility) - mandatory false; + mandatory true; config:required-identity md-sal-binding:binding-broker-osgi-registry; } } } - // FIXME BUG-944 remove backwards compatibility - // Deprecated, replaced by client dispatcher. - // This dependency will be removed in near future and all configurations of netconf-connector need to be changed to use dispatcher dependency. - container boss-thread-group { - uses config:service-ref { - refine type { - mandatory false; - config:required-identity netty:netty-threadgroup; - } - } - } - - // FIXME BUG-944 remove backwards compatibility - // Deprecated, replaced by client dispatcher. - // This dependency will be removed in near future and all configurations of netconf-connector need to be changed to use dispatcher dependency. - container worker-thread-group { - uses config:service-ref { - refine type { - mandatory false; - config:required-identity netty:netty-threadgroup; - } - } - } - container event-executor { uses config:service-ref { refine type { + mandatory true; config:required-identity netty:netty-event-executor; } } @@ -111,8 +88,7 @@ module odl-sal-netconf-connector-cfg { container processing-executor { uses config:service-ref { refine type { - // FIXME BUG-944 make mandatory (remove backwards compatibility) - mandatory false; + mandatory true; config:required-identity th:threadpool; } } @@ -120,7 +96,6 @@ module odl-sal-netconf-connector-cfg { description "Makes up for flaws in netty threading design"; } - // Replaces thread group dependencies container client-dispatcher { uses config:service-ref { refine type { diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/README-FIRST b/opendaylight/md-sal/sal-protocolbuffer-encoding/README-FIRST new file mode 100644 index 0000000000..778d8c6162 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/README-FIRST @@ -0,0 +1,23 @@ +Instructions on generating the protocol buffer Java source files + +These instructions are developers who are planning to generate the protocolbuffer java source files. + +1. We are using protocol buffer version 2.5.0 - you need to install the exact same version on your box. +The download link is https://code.google.com/p/protobuf/downloads/list. Download .tar/zip based on +your OS. + +2. Once downloaded the tar/zip and extracted follow the README instructions to compile protoc on your +machine + +3. Create your .proto (IDL) file in resources folder. Give appropriate package name so that the source + get generation in proper packages. For more information check + https://developers.google.com/protocol-buffers/docs/javatutorial + + For detailed information https://developers.google.com/protocol-buffers/docs/reference/java-generated + +4. To generate the java source files execute in sal-protocolbuffer-encoding directory + just run.sh in sal-protocolbuffer-encoding or execute the following command + + protoc --proto_path=src/main/resources --java_out=src/main/java src/main/resources/*.proto + +5. Run mvn clean install and resolve any trailing spaces issues & build the .jar diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/pom.xml b/opendaylight/md-sal/sal-protocolbuffer-encoding/pom.xml new file mode 100644 index 0000000000..671a9441d8 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + + org.opendaylight.controller + sal-parent + 1.1-SNAPSHOT + + + sal-protocolbuffer-encoding + + bundle + + + + com.google.protobuf + protobuf-java + 2.5.0 + + + junit + junit + test + + + + diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/run.sh b/opendaylight/md-sal/sal-protocolbuffer-encoding/run.sh new file mode 100755 index 0000000000..72e2c87ecb --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/run.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +##################################################################################################### +#Instructions on generating the protocol buffer Java source files +# +#These instructions are developers who are planning to generate the protocolbuffer java source files. +# +#1. We are using protocol buffer version 2.5.0 - you need to install the exact same version on your box. +#The download link is https://code.google.com/p/protobuf/downloads/list. Download .tar/zip based on +#your OS. +# +#2. Once downloaded the tar/zip and extracted follow the README instructions to compile protoc on your +#machine +# +#3. Create your .proto (IDL) file in resources folder. Give appropriate package name so that the source +# get generation in proper packages. For more information check +# https://developers.google.com/protocol-buffers/docs/javatutorial +# +# For detailed information https://developers.google.com/protocol-buffers/docs/reference/java-generated +# +#4. To generate the java source files execute in sal-protocolbuffer-encoding execute ./run.sh i.e. this script +# or run command +# protoc --proto_path=src/main/resources --java_out=src/main/java src/main/resources/*.proto +# +#5. Run mvn clean install and resolve any trailing spaces issues & build the .jar +######################################################################################################## + +protoc --proto_path=src/main/resources --java_out=src/main/java src/main/resources/*.proto + +echo "Done generating Java source files." \ No newline at end of file diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/registration/ListenerRegistrationMessages.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/registration/ListenerRegistrationMessages.java new file mode 100644 index 0000000000..afcb455c97 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/registration/ListenerRegistrationMessages.java @@ -0,0 +1,681 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ListenerRegistration.proto + +package org.opendaylight.controller.cluster.datastore.registration; + +public final class ListenerRegistrationMessages { + private ListenerRegistrationMessages() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface CloseOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.Close} + */ + public static final class Close extends + com.google.protobuf.GeneratedMessage + implements CloseOrBuilder { + // Use Close.newBuilder() to construct. + private Close(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Close(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Close defaultInstance; + public static Close getDefaultInstance() { + return defaultInstance; + } + + public Close getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Close( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_Close_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_Close_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close.class, org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Close parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Close(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.Close} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_Close_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_Close_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close.class, org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_Close_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close build() { + org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close buildPartial() { + org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close result = new org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close other) { + if (other == org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.Close) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.Close) + } + + static { + defaultInstance = new Close(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.Close) + } + + public interface CloseReplyOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseReply} + */ + public static final class CloseReply extends + com.google.protobuf.GeneratedMessage + implements CloseReplyOrBuilder { + // Use CloseReply.newBuilder() to construct. + private CloseReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CloseReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CloseReply defaultInstance; + public static CloseReply getDefaultInstance() { + return defaultInstance; + } + + public CloseReply getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CloseReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply.class, org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CloseReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CloseReply(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply.class, org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.internal_static_org_opendaylight_controller_mdsal_CloseReply_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply build() { + org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply buildPartial() { + org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply result = new org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply other) { + if (other == org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.registration.ListenerRegistrationMessages.CloseReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CloseReply) + } + + static { + defaultInstance = new CloseReply(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CloseReply) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_Close_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_Close_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CloseReply_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CloseReply_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\032ListenerRegistration.proto\022!org.openda" + + "ylight.controller.mdsal\"\007\n\005Close\"\014\n\nClos" + + "eReplyBZ\n:org.opendaylight.controller.cl" + + "uster.datastore.registrationB\034ListenerRe" + + "gistrationMessages" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_org_opendaylight_controller_mdsal_Close_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_org_opendaylight_controller_mdsal_Close_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_Close_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_CloseReply_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_org_opendaylight_controller_mdsal_CloseReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CloseReply_descriptor, + new java.lang.String[] { }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/shard/ShardManagerMessages.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/shard/ShardManagerMessages.java new file mode 100644 index 0000000000..a8f1bf0373 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/shard/ShardManagerMessages.java @@ -0,0 +1,1172 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ShardManager.proto + +package org.opendaylight.controller.cluster.datastore.shard; + +public final class ShardManagerMessages { + private ShardManagerMessages() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface FindPrimaryOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string shardName = 1; + /** + * required string shardName = 1; + */ + boolean hasShardName(); + /** + * required string shardName = 1; + */ + java.lang.String getShardName(); + /** + * required string shardName = 1; + */ + com.google.protobuf.ByteString + getShardNameBytes(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.FindPrimary} + */ + public static final class FindPrimary extends + com.google.protobuf.GeneratedMessage + implements FindPrimaryOrBuilder { + // Use FindPrimary.newBuilder() to construct. + private FindPrimary(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private FindPrimary(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final FindPrimary defaultInstance; + public static FindPrimary getDefaultInstance() { + return defaultInstance; + } + + public FindPrimary getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private FindPrimary( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + shardName_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_FindPrimary_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_FindPrimary_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary.class, org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public FindPrimary parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new FindPrimary(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string shardName = 1; + public static final int SHARDNAME_FIELD_NUMBER = 1; + private java.lang.Object shardName_; + /** + * required string shardName = 1; + */ + public boolean hasShardName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string shardName = 1; + */ + public java.lang.String getShardName() { + java.lang.Object ref = shardName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + shardName_ = s; + } + return s; + } + } + /** + * required string shardName = 1; + */ + public com.google.protobuf.ByteString + getShardNameBytes() { + java.lang.Object ref = shardName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + shardName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + shardName_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasShardName()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getShardNameBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getShardNameBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.FindPrimary} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimaryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_FindPrimary_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_FindPrimary_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary.class, org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + shardName_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_FindPrimary_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary build() { + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary buildPartial() { + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary result = new org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.shardName_ = shardName_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary other) { + if (other == org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary.getDefaultInstance()) return this; + if (other.hasShardName()) { + bitField0_ |= 0x00000001; + shardName_ = other.shardName_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasShardName()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.FindPrimary) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string shardName = 1; + private java.lang.Object shardName_ = ""; + /** + * required string shardName = 1; + */ + public boolean hasShardName() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string shardName = 1; + */ + public java.lang.String getShardName() { + java.lang.Object ref = shardName_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + shardName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string shardName = 1; + */ + public com.google.protobuf.ByteString + getShardNameBytes() { + java.lang.Object ref = shardName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + shardName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string shardName = 1; + */ + public Builder setShardName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + shardName_ = value; + onChanged(); + return this; + } + /** + * required string shardName = 1; + */ + public Builder clearShardName() { + bitField0_ = (bitField0_ & ~0x00000001); + shardName_ = getDefaultInstance().getShardName(); + onChanged(); + return this; + } + /** + * required string shardName = 1; + */ + public Builder setShardNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + shardName_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.FindPrimary) + } + + static { + defaultInstance = new FindPrimary(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.FindPrimary) + } + + public interface PrimaryFoundOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.PrimaryFound} + */ + public static final class PrimaryFound extends + com.google.protobuf.GeneratedMessage + implements PrimaryFoundOrBuilder { + // Use PrimaryFound.newBuilder() to construct. + private PrimaryFound(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private PrimaryFound(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final PrimaryFound defaultInstance; + public static PrimaryFound getDefaultInstance() { + return defaultInstance; + } + + public PrimaryFound getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PrimaryFound( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_PrimaryFound_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_PrimaryFound_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound.class, org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public PrimaryFound parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PrimaryFound(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.PrimaryFound} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFoundOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_PrimaryFound_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_PrimaryFound_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound.class, org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_PrimaryFound_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound build() { + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound buildPartial() { + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound result = new org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound other) { + if (other == org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryFound) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.PrimaryFound) + } + + static { + defaultInstance = new PrimaryFound(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.PrimaryFound) + } + + public interface PrimaryNotFoundOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.PrimaryNotFound} + */ + public static final class PrimaryNotFound extends + com.google.protobuf.GeneratedMessage + implements PrimaryNotFoundOrBuilder { + // Use PrimaryNotFound.newBuilder() to construct. + private PrimaryNotFound(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private PrimaryNotFound(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final PrimaryNotFound defaultInstance; + public static PrimaryNotFound getDefaultInstance() { + return defaultInstance; + } + + public PrimaryNotFound getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PrimaryNotFound( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_PrimaryNotFound_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_PrimaryNotFound_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound.class, org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public PrimaryNotFound parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PrimaryNotFound(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.PrimaryNotFound} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFoundOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_PrimaryNotFound_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_PrimaryNotFound_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound.class, org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.internal_static_org_opendaylight_controller_mdsal_PrimaryNotFound_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound build() { + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound buildPartial() { + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound result = new org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound other) { + if (other == org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages.PrimaryNotFound) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.PrimaryNotFound) + } + + static { + defaultInstance = new PrimaryNotFound(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.PrimaryNotFound) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_FindPrimary_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_FindPrimary_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_PrimaryFound_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_PrimaryFound_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_PrimaryNotFound_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_PrimaryNotFound_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\022ShardManager.proto\022!org.opendaylight.c" + + "ontroller.mdsal\" \n\013FindPrimary\022\021\n\tshardN" + + "ame\030\001 \002(\t\"\016\n\014PrimaryFound\"\021\n\017PrimaryNotF" + + "oundBK\n3org.opendaylight.controller.clus" + + "ter.datastore.shardB\024ShardManagerMessage" + + "s" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_org_opendaylight_controller_mdsal_FindPrimary_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_org_opendaylight_controller_mdsal_FindPrimary_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_FindPrimary_descriptor, + new java.lang.String[] { "ShardName", }); + internal_static_org_opendaylight_controller_mdsal_PrimaryFound_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_org_opendaylight_controller_mdsal_PrimaryFound_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_PrimaryFound_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_PrimaryNotFound_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_org_opendaylight_controller_mdsal_PrimaryNotFound_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_PrimaryNotFound_descriptor, + new java.lang.String[] { }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/transaction/ShardTransactionChainMessages.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/transaction/ShardTransactionChainMessages.java new file mode 100644 index 0000000000..5de32c8a66 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/transaction/ShardTransactionChainMessages.java @@ -0,0 +1,1493 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ShardTransactionChainMessages.proto + +package org.opendaylight.controller.cluster.datastore.transaction; + +public final class ShardTransactionChainMessages { + private ShardTransactionChainMessages() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface CloseTransactionChainOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseTransactionChain} + */ + public static final class CloseTransactionChain extends + com.google.protobuf.GeneratedMessage + implements CloseTransactionChainOrBuilder { + // Use CloseTransactionChain.newBuilder() to construct. + private CloseTransactionChain(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CloseTransactionChain(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CloseTransactionChain defaultInstance; + public static CloseTransactionChain getDefaultInstance() { + return defaultInstance; + } + + public CloseTransactionChain getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CloseTransactionChain( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CloseTransactionChain parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CloseTransactionChain(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseTransactionChain} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain build() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain buildPartial() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain result = new org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain other) { + if (other == org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChain) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CloseTransactionChain) + } + + static { + defaultInstance = new CloseTransactionChain(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CloseTransactionChain) + } + + public interface CloseTransactionChainReplyOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseTransactionChainReply} + */ + public static final class CloseTransactionChainReply extends + com.google.protobuf.GeneratedMessage + implements CloseTransactionChainReplyOrBuilder { + // Use CloseTransactionChainReply.newBuilder() to construct. + private CloseTransactionChainReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CloseTransactionChainReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CloseTransactionChainReply defaultInstance; + public static CloseTransactionChainReply getDefaultInstance() { + return defaultInstance; + } + + public CloseTransactionChainReply getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CloseTransactionChainReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CloseTransactionChainReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CloseTransactionChainReply(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseTransactionChainReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply build() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply buildPartial() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply result = new org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply other) { + if (other == org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CloseTransactionChainReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CloseTransactionChainReply) + } + + static { + defaultInstance = new CloseTransactionChainReply(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CloseTransactionChainReply) + } + + public interface CreateTransactionChainOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CreateTransactionChain} + */ + public static final class CreateTransactionChain extends + com.google.protobuf.GeneratedMessage + implements CreateTransactionChainOrBuilder { + // Use CreateTransactionChain.newBuilder() to construct. + private CreateTransactionChain(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CreateTransactionChain(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CreateTransactionChain defaultInstance; + public static CreateTransactionChain getDefaultInstance() { + return defaultInstance; + } + + public CreateTransactionChain getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CreateTransactionChain( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionChain_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionChain_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CreateTransactionChain parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CreateTransactionChain(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CreateTransactionChain} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionChain_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionChain_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionChain_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain build() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain buildPartial() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain result = new org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain other) { + if (other == org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChain) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CreateTransactionChain) + } + + static { + defaultInstance = new CreateTransactionChain(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CreateTransactionChain) + } + + public interface CreateTransactionChainReplyOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string transactionChainPath = 1; + /** + * required string transactionChainPath = 1; + */ + boolean hasTransactionChainPath(); + /** + * required string transactionChainPath = 1; + */ + java.lang.String getTransactionChainPath(); + /** + * required string transactionChainPath = 1; + */ + com.google.protobuf.ByteString + getTransactionChainPathBytes(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CreateTransactionChainReply} + */ + public static final class CreateTransactionChainReply extends + com.google.protobuf.GeneratedMessage + implements CreateTransactionChainReplyOrBuilder { + // Use CreateTransactionChainReply.newBuilder() to construct. + private CreateTransactionChainReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CreateTransactionChainReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CreateTransactionChainReply defaultInstance; + public static CreateTransactionChainReply getDefaultInstance() { + return defaultInstance; + } + + public CreateTransactionChainReply getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CreateTransactionChainReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + transactionChainPath_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionChainReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionChainReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CreateTransactionChainReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CreateTransactionChainReply(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string transactionChainPath = 1; + public static final int TRANSACTIONCHAINPATH_FIELD_NUMBER = 1; + private java.lang.Object transactionChainPath_; + /** + * required string transactionChainPath = 1; + */ + public boolean hasTransactionChainPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string transactionChainPath = 1; + */ + public java.lang.String getTransactionChainPath() { + java.lang.Object ref = transactionChainPath_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + transactionChainPath_ = s; + } + return s; + } + } + /** + * required string transactionChainPath = 1; + */ + public com.google.protobuf.ByteString + getTransactionChainPathBytes() { + java.lang.Object ref = transactionChainPath_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + transactionChainPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + transactionChainPath_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasTransactionChainPath()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getTransactionChainPathBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getTransactionChainPathBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CreateTransactionChainReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionChainReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionChainReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + transactionChainPath_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionChainReply_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply build() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply buildPartial() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply result = new org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.transactionChainPath_ = transactionChainPath_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply other) { + if (other == org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply.getDefaultInstance()) return this; + if (other.hasTransactionChainPath()) { + bitField0_ |= 0x00000001; + transactionChainPath_ = other.transactionChainPath_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasTransactionChainPath()){ + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionChainMessages.CreateTransactionChainReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string transactionChainPath = 1; + private java.lang.Object transactionChainPath_ = ""; + /** + * required string transactionChainPath = 1; + */ + public boolean hasTransactionChainPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string transactionChainPath = 1; + */ + public java.lang.String getTransactionChainPath() { + java.lang.Object ref = transactionChainPath_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + transactionChainPath_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string transactionChainPath = 1; + */ + public com.google.protobuf.ByteString + getTransactionChainPathBytes() { + java.lang.Object ref = transactionChainPath_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + transactionChainPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string transactionChainPath = 1; + */ + public Builder setTransactionChainPath( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + transactionChainPath_ = value; + onChanged(); + return this; + } + /** + * required string transactionChainPath = 1; + */ + public Builder clearTransactionChainPath() { + bitField0_ = (bitField0_ & ~0x00000001); + transactionChainPath_ = getDefaultInstance().getTransactionChainPath(); + onChanged(); + return this; + } + /** + * required string transactionChainPath = 1; + */ + public Builder setTransactionChainPathBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + transactionChainPath_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CreateTransactionChainReply) + } + + static { + defaultInstance = new CreateTransactionChainReply(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CreateTransactionChainReply) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CreateTransactionChain_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CreateTransactionChain_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CreateTransactionChainReply_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CreateTransactionChainReply_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n#ShardTransactionChainMessages.proto\022!o" + + "rg.opendaylight.controller.mdsal\"\027\n\025Clos" + + "eTransactionChain\"\034\n\032CloseTransactionCha" + + "inReply\"\030\n\026CreateTransactionChain\";\n\033Cre" + + "ateTransactionChainReply\022\034\n\024transactionC" + + "hainPath\030\001 \002(\tBZ\n9org.opendaylight.contr" + + "oller.cluster.datastore.transactionB\035Sha" + + "rdTransactionChainMessages" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CloseTransactionChain_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CloseTransactionChainReply_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_CreateTransactionChain_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_org_opendaylight_controller_mdsal_CreateTransactionChain_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CreateTransactionChain_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_CreateTransactionChainReply_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_org_opendaylight_controller_mdsal_CreateTransactionChainReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CreateTransactionChainReply_descriptor, + new java.lang.String[] { "TransactionChainPath", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/transaction/ShardTransactionMessages.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/transaction/ShardTransactionMessages.java new file mode 100644 index 0000000000..3a226db3bc --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/java/org/opendaylight/controller/cluster/datastore/transaction/ShardTransactionMessages.java @@ -0,0 +1,3606 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ShardTransactionMessages.proto + +package org.opendaylight.controller.cluster.datastore.transaction; + +public final class ShardTransactionMessages { + private ShardTransactionMessages() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface CloseTransactionOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseTransaction} + */ + public static final class CloseTransaction extends + com.google.protobuf.GeneratedMessage + implements CloseTransactionOrBuilder { + // Use CloseTransaction.newBuilder() to construct. + private CloseTransaction(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CloseTransaction(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CloseTransaction defaultInstance; + public static CloseTransaction getDefaultInstance() { + return defaultInstance; + } + + public CloseTransaction getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CloseTransaction( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CloseTransaction parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CloseTransaction(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseTransaction} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransaction_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction build() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction buildPartial() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction result = new org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction other) { + if (other == org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransaction) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CloseTransaction) + } + + static { + defaultInstance = new CloseTransaction(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CloseTransaction) + } + + public interface CloseTransactionReplyOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseTransactionReply} + */ + public static final class CloseTransactionReply extends + com.google.protobuf.GeneratedMessage + implements CloseTransactionReplyOrBuilder { + // Use CloseTransactionReply.newBuilder() to construct. + private CloseTransactionReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CloseTransactionReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CloseTransactionReply defaultInstance; + public static CloseTransactionReply getDefaultInstance() { + return defaultInstance; + } + + public CloseTransactionReply getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CloseTransactionReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CloseTransactionReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CloseTransactionReply(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CloseTransactionReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CloseTransactionReply_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply build() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply buildPartial() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply result = new org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply other) { + if (other == org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CloseTransactionReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CloseTransactionReply) + } + + static { + defaultInstance = new CloseTransactionReply(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CloseTransactionReply) + } + + public interface CreateTransactionOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CreateTransaction} + */ + public static final class CreateTransaction extends + com.google.protobuf.GeneratedMessage + implements CreateTransactionOrBuilder { + // Use CreateTransaction.newBuilder() to construct. + private CreateTransaction(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CreateTransaction(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CreateTransaction defaultInstance; + public static CreateTransaction getDefaultInstance() { + return defaultInstance; + } + + public CreateTransaction getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CreateTransaction( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CreateTransaction parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CreateTransaction(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CreateTransaction} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransaction_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction build() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction buildPartial() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction result = new org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction other) { + if (other == org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransaction) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CreateTransaction) + } + + static { + defaultInstance = new CreateTransaction(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CreateTransaction) + } + + public interface CreateTransactionReplyOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string transactionPath = 1; + /** + * required string transactionPath = 1; + */ + boolean hasTransactionPath(); + /** + * required string transactionPath = 1; + */ + java.lang.String getTransactionPath(); + /** + * required string transactionPath = 1; + */ + com.google.protobuf.ByteString + getTransactionPathBytes(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CreateTransactionReply} + */ + public static final class CreateTransactionReply extends + com.google.protobuf.GeneratedMessage + implements CreateTransactionReplyOrBuilder { + // Use CreateTransactionReply.newBuilder() to construct. + private CreateTransactionReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private CreateTransactionReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final CreateTransactionReply defaultInstance; + public static CreateTransactionReply getDefaultInstance() { + return defaultInstance; + } + + public CreateTransactionReply getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private CreateTransactionReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + transactionPath_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public CreateTransactionReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CreateTransactionReply(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string transactionPath = 1; + public static final int TRANSACTIONPATH_FIELD_NUMBER = 1; + private java.lang.Object transactionPath_; + /** + * required string transactionPath = 1; + */ + public boolean hasTransactionPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string transactionPath = 1; + */ + public java.lang.String getTransactionPath() { + java.lang.Object ref = transactionPath_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + transactionPath_ = s; + } + return s; + } + } + /** + * required string transactionPath = 1; + */ + public com.google.protobuf.ByteString + getTransactionPathBytes() { + java.lang.Object ref = transactionPath_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + transactionPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + transactionPath_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasTransactionPath()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getTransactionPathBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getTransactionPathBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.CreateTransactionReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + transactionPath_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply build() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply buildPartial() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply result = new org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.transactionPath_ = transactionPath_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply other) { + if (other == org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply.getDefaultInstance()) return this; + if (other.hasTransactionPath()) { + bitField0_ |= 0x00000001; + transactionPath_ = other.transactionPath_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasTransactionPath()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.CreateTransactionReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string transactionPath = 1; + private java.lang.Object transactionPath_ = ""; + /** + * required string transactionPath = 1; + */ + public boolean hasTransactionPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string transactionPath = 1; + */ + public java.lang.String getTransactionPath() { + java.lang.Object ref = transactionPath_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + transactionPath_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string transactionPath = 1; + */ + public com.google.protobuf.ByteString + getTransactionPathBytes() { + java.lang.Object ref = transactionPath_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + transactionPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string transactionPath = 1; + */ + public Builder setTransactionPath( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + transactionPath_ = value; + onChanged(); + return this; + } + /** + * required string transactionPath = 1; + */ + public Builder clearTransactionPath() { + bitField0_ = (bitField0_ & ~0x00000001); + transactionPath_ = getDefaultInstance().getTransactionPath(); + onChanged(); + return this; + } + /** + * required string transactionPath = 1; + */ + public Builder setTransactionPathBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + transactionPath_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.CreateTransactionReply) + } + + static { + defaultInstance = new CreateTransactionReply(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.CreateTransactionReply) + } + + public interface ReadyTransactionOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.ReadyTransaction} + */ + public static final class ReadyTransaction extends + com.google.protobuf.GeneratedMessage + implements ReadyTransactionOrBuilder { + // Use ReadyTransaction.newBuilder() to construct. + private ReadyTransaction(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private ReadyTransaction(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final ReadyTransaction defaultInstance; + public static ReadyTransaction getDefaultInstance() { + return defaultInstance; + } + + public ReadyTransaction getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ReadyTransaction( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadyTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadyTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public ReadyTransaction parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ReadyTransaction(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.ReadyTransaction} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadyTransaction_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadyTransaction_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadyTransaction_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction build() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction buildPartial() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction result = new org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction other) { + if (other == org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransaction) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.ReadyTransaction) + } + + static { + defaultInstance = new ReadyTransaction(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.ReadyTransaction) + } + + public interface ReadyTransactionReplyOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string actorPath = 1; + /** + * required string actorPath = 1; + */ + boolean hasActorPath(); + /** + * required string actorPath = 1; + */ + java.lang.String getActorPath(); + /** + * required string actorPath = 1; + */ + com.google.protobuf.ByteString + getActorPathBytes(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.ReadyTransactionReply} + */ + public static final class ReadyTransactionReply extends + com.google.protobuf.GeneratedMessage + implements ReadyTransactionReplyOrBuilder { + // Use ReadyTransactionReply.newBuilder() to construct. + private ReadyTransactionReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private ReadyTransactionReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final ReadyTransactionReply defaultInstance; + public static ReadyTransactionReply getDefaultInstance() { + return defaultInstance; + } + + public ReadyTransactionReply getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ReadyTransactionReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + actorPath_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadyTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadyTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public ReadyTransactionReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ReadyTransactionReply(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string actorPath = 1; + public static final int ACTORPATH_FIELD_NUMBER = 1; + private java.lang.Object actorPath_; + /** + * required string actorPath = 1; + */ + public boolean hasActorPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string actorPath = 1; + */ + public java.lang.String getActorPath() { + java.lang.Object ref = actorPath_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + actorPath_ = s; + } + return s; + } + } + /** + * required string actorPath = 1; + */ + public com.google.protobuf.ByteString + getActorPathBytes() { + java.lang.Object ref = actorPath_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + actorPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + actorPath_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasActorPath()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getActorPathBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getActorPathBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.ReadyTransactionReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadyTransactionReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadyTransactionReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + actorPath_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadyTransactionReply_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply build() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply buildPartial() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply result = new org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.actorPath_ = actorPath_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply other) { + if (other == org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply.getDefaultInstance()) return this; + if (other.hasActorPath()) { + bitField0_ |= 0x00000001; + actorPath_ = other.actorPath_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasActorPath()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadyTransactionReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string actorPath = 1; + private java.lang.Object actorPath_ = ""; + /** + * required string actorPath = 1; + */ + public boolean hasActorPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string actorPath = 1; + */ + public java.lang.String getActorPath() { + java.lang.Object ref = actorPath_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + actorPath_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string actorPath = 1; + */ + public com.google.protobuf.ByteString + getActorPathBytes() { + java.lang.Object ref = actorPath_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + actorPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string actorPath = 1; + */ + public Builder setActorPath( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + actorPath_ = value; + onChanged(); + return this; + } + /** + * required string actorPath = 1; + */ + public Builder clearActorPath() { + bitField0_ = (bitField0_ & ~0x00000001); + actorPath_ = getDefaultInstance().getActorPath(); + onChanged(); + return this; + } + /** + * required string actorPath = 1; + */ + public Builder setActorPathBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + actorPath_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.ReadyTransactionReply) + } + + static { + defaultInstance = new ReadyTransactionReply(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.ReadyTransactionReply) + } + + public interface DeleteDataOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string instanceIdentifierPath = 1; + /** + * required string instanceIdentifierPath = 1; + */ + boolean hasInstanceIdentifierPath(); + /** + * required string instanceIdentifierPath = 1; + */ + java.lang.String getInstanceIdentifierPath(); + /** + * required string instanceIdentifierPath = 1; + */ + com.google.protobuf.ByteString + getInstanceIdentifierPathBytes(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.DeleteData} + */ + public static final class DeleteData extends + com.google.protobuf.GeneratedMessage + implements DeleteDataOrBuilder { + // Use DeleteData.newBuilder() to construct. + private DeleteData(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private DeleteData(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final DeleteData defaultInstance; + public static DeleteData getDefaultInstance() { + return defaultInstance; + } + + public DeleteData getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DeleteData( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + instanceIdentifierPath_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_DeleteData_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_DeleteData_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public DeleteData parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DeleteData(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string instanceIdentifierPath = 1; + public static final int INSTANCEIDENTIFIERPATH_FIELD_NUMBER = 1; + private java.lang.Object instanceIdentifierPath_; + /** + * required string instanceIdentifierPath = 1; + */ + public boolean hasInstanceIdentifierPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string instanceIdentifierPath = 1; + */ + public java.lang.String getInstanceIdentifierPath() { + java.lang.Object ref = instanceIdentifierPath_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + instanceIdentifierPath_ = s; + } + return s; + } + } + /** + * required string instanceIdentifierPath = 1; + */ + public com.google.protobuf.ByteString + getInstanceIdentifierPathBytes() { + java.lang.Object ref = instanceIdentifierPath_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + instanceIdentifierPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + instanceIdentifierPath_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasInstanceIdentifierPath()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getInstanceIdentifierPathBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getInstanceIdentifierPathBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.DeleteData} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_DeleteData_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_DeleteData_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + instanceIdentifierPath_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_DeleteData_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData build() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData buildPartial() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData result = new org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.instanceIdentifierPath_ = instanceIdentifierPath_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData other) { + if (other == org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData.getDefaultInstance()) return this; + if (other.hasInstanceIdentifierPath()) { + bitField0_ |= 0x00000001; + instanceIdentifierPath_ = other.instanceIdentifierPath_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasInstanceIdentifierPath()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteData) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string instanceIdentifierPath = 1; + private java.lang.Object instanceIdentifierPath_ = ""; + /** + * required string instanceIdentifierPath = 1; + */ + public boolean hasInstanceIdentifierPath() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string instanceIdentifierPath = 1; + */ + public java.lang.String getInstanceIdentifierPath() { + java.lang.Object ref = instanceIdentifierPath_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + instanceIdentifierPath_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string instanceIdentifierPath = 1; + */ + public com.google.protobuf.ByteString + getInstanceIdentifierPathBytes() { + java.lang.Object ref = instanceIdentifierPath_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + instanceIdentifierPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string instanceIdentifierPath = 1; + */ + public Builder setInstanceIdentifierPath( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + instanceIdentifierPath_ = value; + onChanged(); + return this; + } + /** + * required string instanceIdentifierPath = 1; + */ + public Builder clearInstanceIdentifierPath() { + bitField0_ = (bitField0_ & ~0x00000001); + instanceIdentifierPath_ = getDefaultInstance().getInstanceIdentifierPath(); + onChanged(); + return this; + } + /** + * required string instanceIdentifierPath = 1; + */ + public Builder setInstanceIdentifierPathBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + instanceIdentifierPath_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.DeleteData) + } + + static { + defaultInstance = new DeleteData(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.DeleteData) + } + + public interface DeleteDataReplyOrBuilder + extends com.google.protobuf.MessageOrBuilder { + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.DeleteDataReply} + */ + public static final class DeleteDataReply extends + com.google.protobuf.GeneratedMessage + implements DeleteDataReplyOrBuilder { + // Use DeleteDataReply.newBuilder() to construct. + private DeleteDataReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private DeleteDataReply(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final DeleteDataReply defaultInstance; + public static DeleteDataReply getDefaultInstance() { + return defaultInstance; + } + + public DeleteDataReply getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DeleteDataReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_DeleteDataReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_DeleteDataReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public DeleteDataReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DeleteDataReply(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private void initFields() { + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.DeleteDataReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_DeleteDataReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_DeleteDataReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_DeleteDataReply_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply build() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply buildPartial() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply result = new org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply(this); + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply other) { + if (other == org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.DeleteDataReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.DeleteDataReply) + } + + static { + defaultInstance = new DeleteDataReply(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.DeleteDataReply) + } + + public interface ReadDataOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string intanceIdentifier = 1; + /** + * required string intanceIdentifier = 1; + */ + boolean hasIntanceIdentifier(); + /** + * required string intanceIdentifier = 1; + */ + java.lang.String getIntanceIdentifier(); + /** + * required string intanceIdentifier = 1; + */ + com.google.protobuf.ByteString + getIntanceIdentifierBytes(); + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.ReadData} + */ + public static final class ReadData extends + com.google.protobuf.GeneratedMessage + implements ReadDataOrBuilder { + // Use ReadData.newBuilder() to construct. + private ReadData(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private ReadData(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final ReadData defaultInstance; + public static ReadData getDefaultInstance() { + return defaultInstance; + } + + public ReadData getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private ReadData( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + intanceIdentifier_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadData_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadData_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public ReadData parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ReadData(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string intanceIdentifier = 1; + public static final int INTANCEIDENTIFIER_FIELD_NUMBER = 1; + private java.lang.Object intanceIdentifier_; + /** + * required string intanceIdentifier = 1; + */ + public boolean hasIntanceIdentifier() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string intanceIdentifier = 1; + */ + public java.lang.String getIntanceIdentifier() { + java.lang.Object ref = intanceIdentifier_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + intanceIdentifier_ = s; + } + return s; + } + } + /** + * required string intanceIdentifier = 1; + */ + public com.google.protobuf.ByteString + getIntanceIdentifierBytes() { + java.lang.Object ref = intanceIdentifier_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + intanceIdentifier_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + intanceIdentifier_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasIntanceIdentifier()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getIntanceIdentifierBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getIntanceIdentifierBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code org.opendaylight.controller.mdsal.ReadData} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadDataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadData_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadData_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData.class, org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData.Builder.class); + } + + // Construct using org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + intanceIdentifier_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.internal_static_org_opendaylight_controller_mdsal_ReadData_descriptor; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData getDefaultInstanceForType() { + return org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData.getDefaultInstance(); + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData build() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData buildPartial() { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData result = new org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.intanceIdentifier_ = intanceIdentifier_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData) { + return mergeFrom((org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData other) { + if (other == org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData.getDefaultInstance()) return this; + if (other.hasIntanceIdentifier()) { + bitField0_ |= 0x00000001; + intanceIdentifier_ = other.intanceIdentifier_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasIntanceIdentifier()) { + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.opendaylight.controller.cluster.datastore.transaction.ShardTransactionMessages.ReadData) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string intanceIdentifier = 1; + private java.lang.Object intanceIdentifier_ = ""; + /** + * required string intanceIdentifier = 1; + */ + public boolean hasIntanceIdentifier() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string intanceIdentifier = 1; + */ + public java.lang.String getIntanceIdentifier() { + java.lang.Object ref = intanceIdentifier_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + intanceIdentifier_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string intanceIdentifier = 1; + */ + public com.google.protobuf.ByteString + getIntanceIdentifierBytes() { + java.lang.Object ref = intanceIdentifier_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + intanceIdentifier_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string intanceIdentifier = 1; + */ + public Builder setIntanceIdentifier( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + intanceIdentifier_ = value; + onChanged(); + return this; + } + /** + * required string intanceIdentifier = 1; + */ + public Builder clearIntanceIdentifier() { + bitField0_ = (bitField0_ & ~0x00000001); + intanceIdentifier_ = getDefaultInstance().getIntanceIdentifier(); + onChanged(); + return this; + } + /** + * required string intanceIdentifier = 1; + */ + public Builder setIntanceIdentifierBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + intanceIdentifier_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:org.opendaylight.controller.mdsal.ReadData) + } + + static { + defaultInstance = new ReadData(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:org.opendaylight.controller.mdsal.ReadData) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CloseTransaction_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CloseTransaction_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CloseTransactionReply_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CloseTransactionReply_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CreateTransaction_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CreateTransaction_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_ReadyTransaction_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_ReadyTransaction_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_ReadyTransactionReply_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_ReadyTransactionReply_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_DeleteData_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_DeleteData_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_DeleteDataReply_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_DeleteDataReply_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_org_opendaylight_controller_mdsal_ReadData_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_org_opendaylight_controller_mdsal_ReadData_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\036ShardTransactionMessages.proto\022!org.op" + + "endaylight.controller.mdsal\"\022\n\020CloseTran" + + "saction\"\027\n\025CloseTransactionReply\"\023\n\021Crea" + + "teTransaction\"1\n\026CreateTransactionReply\022" + + "\027\n\017transactionPath\030\001 \002(\t\"\022\n\020ReadyTransac" + + "tion\"*\n\025ReadyTransactionReply\022\021\n\tactorPa" + + "th\030\001 \002(\t\",\n\nDeleteData\022\036\n\026instanceIdenti" + + "fierPath\030\001 \002(\t\"\021\n\017DeleteDataReply\"%\n\010Rea" + + "dData\022\031\n\021intanceIdentifier\030\001 \002(\tBU\n9org." + + "opendaylight.controller.cluster.datastor", + "e.transactionB\030ShardTransactionMessages" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_org_opendaylight_controller_mdsal_CloseTransaction_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_org_opendaylight_controller_mdsal_CloseTransaction_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CloseTransaction_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_CloseTransactionReply_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_org_opendaylight_controller_mdsal_CloseTransactionReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CloseTransactionReply_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_CreateTransaction_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_org_opendaylight_controller_mdsal_CreateTransaction_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CreateTransaction_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_CreateTransactionReply_descriptor, + new java.lang.String[] { "TransactionPath", }); + internal_static_org_opendaylight_controller_mdsal_ReadyTransaction_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_org_opendaylight_controller_mdsal_ReadyTransaction_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_ReadyTransaction_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_ReadyTransactionReply_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_org_opendaylight_controller_mdsal_ReadyTransactionReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_ReadyTransactionReply_descriptor, + new java.lang.String[] { "ActorPath", }); + internal_static_org_opendaylight_controller_mdsal_DeleteData_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_org_opendaylight_controller_mdsal_DeleteData_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_DeleteData_descriptor, + new java.lang.String[] { "InstanceIdentifierPath", }); + internal_static_org_opendaylight_controller_mdsal_DeleteDataReply_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_org_opendaylight_controller_mdsal_DeleteDataReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_DeleteDataReply_descriptor, + new java.lang.String[] { }); + internal_static_org_opendaylight_controller_mdsal_ReadData_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_org_opendaylight_controller_mdsal_ReadData_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_org_opendaylight_controller_mdsal_ReadData_descriptor, + new java.lang.String[] { "IntanceIdentifier", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ListenerRegistration.proto b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ListenerRegistration.proto new file mode 100644 index 0000000000..ec8046f557 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ListenerRegistration.proto @@ -0,0 +1,13 @@ +package org.opendaylight.controller.mdsal; + +option java_package = "org.opendaylight.controller.cluster.datastore.registration"; +option java_outer_classname = "ListenerRegistrationMessages"; + +message Close { + +} + +message CloseReply{ + +} + diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardManager.proto b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardManager.proto new file mode 100644 index 0000000000..31e8c58b13 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardManager.proto @@ -0,0 +1,14 @@ +package org.opendaylight.controller.mdsal; + +option java_package = "org.opendaylight.controller.cluster.datastore.shard"; +option java_outer_classname = "ShardManagerMessages"; + +message FindPrimary { + required string shardName = 1; +} + +message PrimaryFound { +} + +message PrimaryNotFound { +} diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransaction.proto b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransaction.proto new file mode 100644 index 0000000000..0b260c8071 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransaction.proto @@ -0,0 +1,39 @@ +package org.opendaylight.controller.mdsal; + +option java_package = "org.opendaylight.controller.cluster.datastore.transaction"; +option java_outer_classname = "ShardTransactionMessages"; + +message CloseTransaction{ +} + +message CloseTransactionReply{ + +} + +message CreateTransaction{ + +} + +message CreateTransactionReply{ +required string transactionPath = 1; + +} + +message ReadyTransaction{ + +} + +message ReadyTransactionReply{ +required string actorPath = 1; +} + +message DeleteData { +required string instanceIdentifierPath = 1; +} + +message DeleteDataReply{ + +} +message ReadData { +required string intanceIdentifier=1; +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransactionChain.proto b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransactionChain.proto new file mode 100644 index 0000000000..73a9aa11c8 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/main/resources/ShardTransactionChain.proto @@ -0,0 +1,23 @@ +package org.opendaylight.controller.mdsal; + +option java_package = "org.opendaylight.controller.cluster.datastore.transaction"; +option java_outer_classname = "ShardTransactionChainMessages"; + +message CloseTransactionChain { + +} + +message CloseTransactionChainReply{ + + +} + +message CreateTransactionChain { + +} + +message CreateTransactionChainReply{ +required string transactionChainPath = 1; + +} + diff --git a/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/messages/ShardManagerMessagesTest.java b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/messages/ShardManagerMessagesTest.java new file mode 100644 index 0000000000..f57cfc9f10 --- /dev/null +++ b/opendaylight/md-sal/sal-protocolbuffer-encoding/src/test/java/org/opendaylight/controller/cluster/datastore/messages/ShardManagerMessagesTest.java @@ -0,0 +1,43 @@ +package org.opendaylight.controller.cluster.datastore.messages; + +/** + * This test case is present to ensure that if others have + * used proper version of protocol buffer. + * + * If a different version of protocol buffer is used then it would + * generate different java sources and would result in + * breaking of this test case. + * + * @author: syedbahm + * Date: 6/20/14 + * + */ + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.cluster.datastore.shard.ShardManagerMessages; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; + +public class ShardManagerMessagesTest { + + @Test + public void verifySerialization()throws Exception{ + ShardManagerMessages.FindPrimary.Builder builder = ShardManagerMessages.FindPrimary.newBuilder(); + builder.setShardName("Inventory"); + File testFile = new File("./test"); + FileOutputStream output = new FileOutputStream(testFile); + builder.build().writeTo(output); + output.close(); + + //Here we will read the same and check we got back what we had saved + ShardManagerMessages.FindPrimary findPrimary + = ShardManagerMessages.FindPrimary.parseFrom(new FileInputStream(testFile)); + Assert.assertEquals("Inventory", findPrimary.getShardName()); + + testFile.delete(); + + } +} diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java index 1e5bfbd6b9..696bf71535 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/impl/JsonMapper.java @@ -9,15 +9,15 @@ package org.opendaylight.controller.sal.rest.impl; import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.base.Preconditions; +import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.net.URI; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; - import javax.activation.UnsupportedDataTypeException; - import org.opendaylight.controller.sal.core.api.mount.MountInstance; import org.opendaylight.controller.sal.restconf.impl.ControllerContext; import org.opendaylight.controller.sal.restconf.impl.IdentityValuesDTO; @@ -29,6 +29,7 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.Node; import org.opendaylight.yangtools.yang.data.api.SimpleNode; +import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode; import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; import org.opendaylight.yangtools.yang.model.api.ChoiceNode; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; @@ -48,13 +49,8 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Preconditions; -import com.google.gson.stream.JsonWriter; - class JsonMapper { - private final Set foundLeafLists = new HashSet<>(); - private final Set foundLists = new HashSet<>(); private MountInstance mountPoint; private final Logger logger = LoggerFactory.getLogger(JsonMapper.class); @@ -77,15 +73,14 @@ class JsonMapper { } writer.endObject(); - - foundLeafLists.clear(); - foundLists.clear(); } private void writeChildrenOfParent(final JsonWriter writer, final CompositeNode parent, final DataNodeContainer parentSchema) throws IOException { checkNotNull(parent); + final Set foundLists = new HashSet<>(); + Set parentSchemaChildNodes = parentSchema == null ? Collections.emptySet() : parentSchema.getChildNodes(); @@ -98,59 +93,88 @@ class JsonMapper { logger.debug( "No schema found for data node \"" + child.getNodeType() ); - handleNoSchemaFound( writer, child, parent ); + if( !foundLists.contains( child.getNodeType() ) ) { + handleNoSchemaFound( writer, child, parent ); + + // Since we don't have a schema, we don't know which nodes are supposed to be + // lists so treat every one as a potential list to avoid outputting duplicates. + + foundLists.add( child.getNodeType() ); + } } else if (childSchema instanceof ContainerSchemaNode) { Preconditions.checkState(child instanceof CompositeNode, "Data representation of Container should be CompositeNode - " + child.getNodeType()); writeContainer(writer, (CompositeNode) child, (ContainerSchemaNode) childSchema); } else if (childSchema instanceof ListSchemaNode) { - if (!foundLists.contains(childSchema)) { + if (!foundLists.contains( child.getNodeType() ) ) { Preconditions.checkState(child instanceof CompositeNode, "Data representation of List should be CompositeNode - " + child.getNodeType()); - foundLists.add((ListSchemaNode) childSchema); + foundLists.add( child.getNodeType() ); writeList(writer, parent, (CompositeNode) child, (ListSchemaNode) childSchema); } } else if (childSchema instanceof LeafListSchemaNode) { - if (!foundLeafLists.contains(childSchema)) { + if (!foundLists.contains( child.getNodeType() ) ) { Preconditions.checkState(child instanceof SimpleNode, "Data representation of LeafList should be SimpleNode - " + child.getNodeType()); - foundLeafLists.add((LeafListSchemaNode) childSchema); + foundLists.add( child.getNodeType() ); writeLeafList(writer, parent, (SimpleNode) child, (LeafListSchemaNode) childSchema); } } else if (childSchema instanceof LeafSchemaNode) { Preconditions.checkState(child instanceof SimpleNode, "Data representation of LeafList should be SimpleNode - " + child.getNodeType()); writeLeaf(writer, (SimpleNode) child, (LeafSchemaNode) childSchema); + } else if (childSchema instanceof AnyXmlSchemaNode) { + if( child instanceof CompositeNode ) { + writeContainer(writer, (CompositeNode) child, null); + } + else { + handleNoSchemaFound( writer, child, parent ); + } } else { throw new UnsupportedDataTypeException("Schema can be ContainerSchemaNode, ListSchemaNode, " + "LeafListSchemaNode, or LeafSchemaNode. Other types are not supported yet."); } } + } - for (Node child : parent.getValue()) { - DataSchemaNode childSchema = findFirstSchemaForNode(child, parentSchemaChildNodes); - if (childSchema instanceof LeafListSchemaNode) { - foundLeafLists.remove(childSchema); - } else if (childSchema instanceof ListSchemaNode) { - foundLists.remove(childSchema); - } + private void writeValue( final JsonWriter writer, Object value ) throws IOException { + if( value != null ) { + writer.value( String.valueOf( value ) ); + } + else { + writer.value( "" ); } } private void handleNoSchemaFound( final JsonWriter writer, final Node node, final CompositeNode parent ) throws IOException { if( node instanceof SimpleNode ) { - writeName( node, null, writer ); - Object value = node.getValue(); - if( value != null ) { - writer.value( String.valueOf( value ) ); + List> nodeLeafList = parent.getSimpleNodesByName( node.getNodeType() ); + if( nodeLeafList.size() == 1 ) { + writeName( node, null, writer ); + writeValue( writer, node.getValue() ); + } + else { // more than 1, write as a json array + writeName( node, null, writer ); + writer.beginArray(); + for( SimpleNode leafNode: nodeLeafList ) { + writeValue( writer, leafNode.getValue() ); + } + + writer.endArray(); } } else { // CompositeNode Preconditions.checkState( node instanceof CompositeNode, "Data representation of Container should be CompositeNode - " + node.getNodeType() ); - writeContainer( writer, (CompositeNode) node, null ); + List nodeList = parent.getCompositesByName( node.getNodeType() ); + if( nodeList.size() == 1 ) { + writeContainer( writer, (CompositeNode) node, null ); + } + else { // more than 1, write as a json array + writeList( writer, parent, (CompositeNode) node, null ); + } } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java index b0916f4500..6330c0a479 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/ControllerContext.java @@ -36,6 +36,7 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdent import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; +import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode; import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; import org.opendaylight.yangtools.yang.model.api.ChoiceNode; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; @@ -804,7 +805,8 @@ public class ControllerContext implements SchemaContextListener { public boolean isInstantiatedDataSchema( final DataSchemaNode node ) { return node instanceof LeafSchemaNode || node instanceof LeafListSchemaNode || - node instanceof ContainerSchemaNode || node instanceof ListSchemaNode; + node instanceof ContainerSchemaNode || node instanceof ListSchemaNode || + node instanceof AnyXmlSchemaNode; } private void addKeyValue( final HashMap map, final DataSchemaNode node, diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java index 9700d48bc2..4716a02be2 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java @@ -56,6 +56,7 @@ import org.opendaylight.yangtools.yang.data.api.Node; import org.opendaylight.yangtools.yang.data.api.SimpleNode; import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode; import org.opendaylight.yangtools.yang.data.impl.NodeFactory; +import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode; import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; @@ -1044,97 +1045,127 @@ public class RestconfImpl implements RestconfService { } } - if ((nodeBuilder instanceof CompositeNodeWrapper)) { - final List> children = ((CompositeNodeWrapper) nodeBuilder).getValues(); - for (final NodeWrapper child : children) { - final List potentialSchemaNodes = - this.controllerContext.findInstanceDataChildrenByName( - ((DataNodeContainer) schema), child.getLocalName()); + if ( nodeBuilder instanceof CompositeNodeWrapper ) { + if( schema instanceof DataNodeContainer ) { + normalizeCompositeNode( (CompositeNodeWrapper)nodeBuilder, (DataNodeContainer)schema, + mountPoint, currentAugment ); + } + else if( schema instanceof AnyXmlSchemaNode ) { + normalizeAnyXmlNode( (CompositeNodeWrapper)nodeBuilder, (AnyXmlSchemaNode)schema ); + } + } + else if ( nodeBuilder instanceof SimpleNodeWrapper ) { + normalizeSimpleNode( (SimpleNodeWrapper) nodeBuilder, schema, mountPoint ); + } + else if ((nodeBuilder instanceof EmptyNodeWrapper)) { + normalizeEmptyNode( (EmptyNodeWrapper) nodeBuilder, schema ); + } + } - if (potentialSchemaNodes.size() > 1 && child.getNamespace() == null) { - StringBuilder builder = new StringBuilder(); - for (final DataSchemaNode potentialSchemaNode : potentialSchemaNodes) { - builder.append(" ").append(potentialSchemaNode.getQName().getNamespace().toString()) - .append("\n"); - } + private void normalizeAnyXmlNode( CompositeNodeWrapper compositeNode, AnyXmlSchemaNode schema ) { + List> children = compositeNode.getValues(); + for( NodeWrapper child : children ) { + child.setNamespace( schema.getQName().getNamespace() ); + if( child instanceof CompositeNodeWrapper ) { + normalizeAnyXmlNode( (CompositeNodeWrapper)child, schema ); + } + } + } - throw new RestconfDocumentedException( - "Node \"" + child.getLocalName() + - "\" is added as augment from more than one module. " + - "Therefore node must have namespace (XML format) or module name (JSON format)." + - "\nThe node is added as augment from modules with namespaces:\n" + builder, - ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE ); - } + private void normalizeEmptyNode( EmptyNodeWrapper emptyNodeBuilder, DataSchemaNode schema ) { + if ((schema instanceof LeafSchemaNode)) { + emptyNodeBuilder.setComposite(false); + } + else { + if ((schema instanceof ContainerSchemaNode)) { + // FIXME: Add presence check + emptyNodeBuilder.setComposite(true); + } + } + } + + private void normalizeSimpleNode( SimpleNodeWrapper simpleNode, DataSchemaNode schema, + MountInstance mountPoint ) { + final Object value = simpleNode.getValue(); + Object inputValue = value; + TypeDefinition typeDefinition = this.typeDefinition(schema); + if ((typeDefinition instanceof IdentityrefTypeDefinition)) { + if ((value instanceof String)) { + inputValue = new IdentityValuesDTO( simpleNode.getNamespace().toString(), + (String) value, null, (String) value ); + } // else value is already instance of IdentityValuesDTO + } + + Object outputValue = inputValue; + + if( typeDefinition != null ) { + Codec codec = RestCodec.from(typeDefinition, mountPoint); + outputValue = codec == null ? null : codec.deserialize(inputValue); + } + + simpleNode.setValue(outputValue); + } - boolean rightNodeSchemaFound = false; + private void normalizeCompositeNode( CompositeNodeWrapper compositeNodeBuilder, + DataNodeContainer schema, MountInstance mountPoint, + QName currentAugment ) { + final List> children = compositeNodeBuilder.getValues(); + for (final NodeWrapper child : children) { + final List potentialSchemaNodes = + this.controllerContext.findInstanceDataChildrenByName( + schema, child.getLocalName()); + + if (potentialSchemaNodes.size() > 1 && child.getNamespace() == null) { + StringBuilder builder = new StringBuilder(); for (final DataSchemaNode potentialSchemaNode : potentialSchemaNodes) { - if (!rightNodeSchemaFound) { - final QName potentialCurrentAugment = - this.normalizeNodeName(child, potentialSchemaNode, currentAugment, mountPoint); - if (child.getQname() != null ) { - this.normalizeNode(child, potentialSchemaNode, potentialCurrentAugment, mountPoint); - rightNodeSchemaFound = true; - } - } + builder.append(" ").append(potentialSchemaNode.getQName().getNamespace().toString()) + .append("\n"); } - if (!rightNodeSchemaFound) { - throw new RestconfDocumentedException( - "Schema node \"" + child.getLocalName() + "\" was not found in module.", - ErrorType.APPLICATION, ErrorTag.UNKNOWN_ELEMENT ); - } + throw new RestconfDocumentedException( + "Node \"" + child.getLocalName() + + "\" is added as augment from more than one module. " + + "Therefore node must have namespace (XML format) or module name (JSON format)." + + "\nThe node is added as augment from modules with namespaces:\n" + builder, + ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE ); } - if ((schema instanceof ListSchemaNode)) { - final List listKeys = ((ListSchemaNode) schema).getKeyDefinition(); - for (final QName listKey : listKeys) { - boolean foundKey = false; - for (final NodeWrapper child : children) { - if (Objects.equal(child.unwrap().getNodeType().getLocalName(), listKey.getLocalName())) { - foundKey = true; - } - } - - if (!foundKey) { - throw new RestconfDocumentedException( - "Missing key in URI \"" + listKey.getLocalName() + - "\" of list \"" + schema.getQName().getLocalName() + "\"", - ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE ); + boolean rightNodeSchemaFound = false; + for (final DataSchemaNode potentialSchemaNode : potentialSchemaNodes) { + if (!rightNodeSchemaFound) { + final QName potentialCurrentAugment = + this.normalizeNodeName(child, potentialSchemaNode, currentAugment, mountPoint); + if (child.getQname() != null ) { + this.normalizeNode(child, potentialSchemaNode, potentialCurrentAugment, mountPoint); + rightNodeSchemaFound = true; } } } - } - else { - if ((nodeBuilder instanceof SimpleNodeWrapper)) { - final SimpleNodeWrapper simpleNode = ((SimpleNodeWrapper) nodeBuilder); - final Object value = simpleNode.getValue(); - Object inputValue = value; - TypeDefinition typeDefinition = this.typeDefinition(schema); - if ((typeDefinition instanceof IdentityrefTypeDefinition)) { - if ((value instanceof String)) { - inputValue = new IdentityValuesDTO( nodeBuilder.getNamespace().toString(), - (String) value, null, (String) value ); - } // else value is already instance of IdentityValuesDTO - } - Codec codec = RestCodec.from(typeDefinition, mountPoint); - Object outputValue = codec == null ? null : codec.deserialize(inputValue); - - simpleNode.setValue(outputValue); + if (!rightNodeSchemaFound) { + throw new RestconfDocumentedException( + "Schema node \"" + child.getLocalName() + "\" was not found in module.", + ErrorType.APPLICATION, ErrorTag.UNKNOWN_ELEMENT ); } - else { - if ((nodeBuilder instanceof EmptyNodeWrapper)) { - final EmptyNodeWrapper emptyNodeBuilder = ((EmptyNodeWrapper) nodeBuilder); - if ((schema instanceof LeafSchemaNode)) { - emptyNodeBuilder.setComposite(false); - } - else { - if ((schema instanceof ContainerSchemaNode)) { - // FIXME: Add presence check - emptyNodeBuilder.setComposite(true); - } + } + + if ((schema instanceof ListSchemaNode)) { + ListSchemaNode listSchemaNode = (ListSchemaNode)schema; + final List listKeys = listSchemaNode.getKeyDefinition(); + for (final QName listKey : listKeys) { + boolean foundKey = false; + for (final NodeWrapper child : children) { + if (Objects.equal(child.unwrap().getNodeType().getLocalName(), listKey.getLocalName())) { + foundKey = true; } } + + if (!foundKey) { + throw new RestconfDocumentedException( + "Missing key in URI \"" + listKey.getLocalName() + + "\" of list \"" + listSchemaNode.getQName().getLocalName() + "\"", + ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE ); + } } } } @@ -1237,6 +1268,9 @@ public class RestconfImpl implements RestconfService { else if (node instanceof LeafSchemaNode) { return _typeDefinition((LeafSchemaNode)node); } + else if (node instanceof AnyXmlSchemaNode) { + return null; + } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.asList(node).toString()); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonBasicDataTypesTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonBasicDataTypesTest.java index 1ec7253b8d..93d32a1499 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonBasicDataTypesTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/json/test/CnSnToJsonBasicDataTypesTest.java @@ -116,6 +116,75 @@ public class CnSnToJsonBasicDataTypesTest extends YangAndXmlAndDataSchemaLoader } + static class ComplexAnyXmlVerifier extends LeafVerifier { + + ComplexAnyXmlVerifier() { + super( null, JsonToken.BEGIN_OBJECT ); + } + + @Override + void verify( JsonReader reader, String keyName ) throws IOException { + + reader.beginObject(); + String innerKey = reader.nextName(); + assertEquals( "Json reader child key for " + keyName, "data", innerKey ); + assertEquals( "Json token type for key " + innerKey, JsonToken.BEGIN_OBJECT, reader.peek() ); + + reader.beginObject(); + verifyLeaf( reader, innerKey, "leaf1", "leaf1-value" ); + verifyLeaf( reader, innerKey, "leaf2", "leaf2-value" ); + + String nextName = reader.nextName(); + assertEquals( "Json reader child key for " + innerKey, "leaf-list", nextName ); + reader.beginArray(); + assertEquals( "Json value for key " + nextName, "leaf-list-value1", reader.nextString() ); + assertEquals( "Json value for key " + nextName, "leaf-list-value2", reader.nextString() ); + reader.endArray(); + + nextName = reader.nextName(); + assertEquals( "Json reader child key for " + innerKey, "list", nextName ); + reader.beginArray(); + verifyNestedLists( reader, 1 ); + verifyNestedLists( reader, 3 ); + reader.endArray(); + + reader.endObject(); + reader.endObject(); + } + + void verifyNestedLists( JsonReader reader, int leafNum ) throws IOException { + reader.beginObject(); + + String nextName = reader.nextName(); + assertEquals( "Json reader next name", "nested-list", nextName ); + + reader.beginArray(); + + reader.beginObject(); + verifyLeaf( reader, "nested-list", "nested-leaf", "nested-value" + leafNum++ ); + reader.endObject(); + + reader.beginObject(); + verifyLeaf( reader, "nested-list", "nested-leaf", "nested-value" + leafNum ); + reader.endObject(); + + reader.endArray(); + reader.endObject(); + } + + void verifyLeaf( JsonReader reader, String parent, String name, String value ) throws IOException { + String nextName = reader.nextName(); + assertEquals( "Json reader child key for " + parent, name, nextName ); + assertEquals( "Json token type for key " + parent, JsonToken.STRING, reader.peek() ); + assertEquals( "Json value for key " + nextName, value, reader.nextString() ); + } + + @Override + Object getActualValue( JsonReader reader ) throws IOException { + return null; + } + } + @BeforeClass public static void initialize() { dataLoad("/cnsn-to-json/simple-data-types"); @@ -208,6 +277,9 @@ public class CnSnToJsonBasicDataTypesTest extends YangAndXmlAndDataSchemaLoader expectedMap.put( "lfunion14", new StringVerifier( "zero" ) ); expectedMap.put( "lfempty", new EmptyVerifier() ); expectedMap.put( "identityref1", new StringVerifier( "simple-data-types:iden" ) ); + expectedMap.put( "complex-any", new ComplexAnyXmlVerifier() ); + expectedMap.put( "simple-any", new StringVerifier( "simple" ) ); + expectedMap.put( "empty-any", new StringVerifier( "" ) ); while (jReader.hasNext()) { String keyName = jReader.nextName(); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java index 22b34a4420..19a7eff480 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/DummyFuture.java @@ -11,16 +11,14 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; - -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.yangtools.yang.common.RpcResult; -public class DummyFuture implements Future> { +public class DummyFuture implements Future> { private final boolean cancel; private final boolean isCancelled; private final boolean isDone; - private final RpcResult result; + private final RpcResult result; public DummyFuture() { cancel = false; @@ -29,16 +27,13 @@ public class DummyFuture implements Future> { result = null; } - private DummyFuture(final Builder builder) { + private DummyFuture(final Builder builder) { cancel = builder.cancel; isCancelled = builder.isCancelled; isDone = builder.isDone; result = builder.result; } - public static Builder builder() { - return new DummyFuture.Builder(); - } @Override public boolean cancel(final boolean mayInterruptIfRunning) { @@ -56,45 +51,45 @@ public class DummyFuture implements Future> { } @Override - public RpcResult get() throws InterruptedException, ExecutionException { + public RpcResult get() throws InterruptedException, ExecutionException { return result; } @Override - public RpcResult get(final long timeout, final TimeUnit unit) throws InterruptedException, + public RpcResult get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return result; } - public static class Builder { + public static class Builder { private boolean cancel; private boolean isCancelled; private boolean isDone; - private RpcResult result; + private RpcResult result; - public Builder cancel(final boolean cancel) { + public Builder cancel(final boolean cancel) { this.cancel = cancel; return this; } - public Builder isCancelled(final boolean isCancelled) { + public Builder isCancelled(final boolean isCancelled) { this.isCancelled = isCancelled; return this; } - public Builder isDone(final boolean isDone) { + public Builder isDone(final boolean isDone) { this.isDone = isDone; return this; } - public Builder rpcResult(final RpcResult result) { + public Builder rpcResult(final RpcResult result) { this.result = result; return this; } - public Future> build() { - return new DummyFuture(this); + public Future> build() { + return new DummyFuture(this); } } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java index 56a58eeadd..e8cbf3140f 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestDeleteOperationTest.java @@ -17,11 +17,9 @@ import java.io.FileNotFoundException; import java.io.UnsupportedEncodingException; import java.util.Set; import java.util.concurrent.Future; - import javax.ws.rs.core.Application; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.junit.BeforeClass; @@ -85,7 +83,7 @@ public class RestDeleteOperationTest extends JerseyTest { private Future> createFuture(TransactionStatus statusName) { RpcResult rpcResult = new DummyRpcResult.Builder().result(statusName).build(); - return DummyFuture.builder().rpcResult(rpcResult).build(); + return new DummyFuture.Builder().rpcResult(rpcResult).build(); } } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java index cfbc9fdb76..5b36fd52f7 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPostOperationTest.java @@ -15,25 +15,29 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.XML; +import com.google.common.util.concurrent.Futures; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; import java.text.ParseException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; import java.util.Set; import java.util.concurrent.Future; - import javax.ws.rs.client.Entity; import javax.ws.rs.core.Application; import javax.ws.rs.core.MediaType; - import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.junit.BeforeClass; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.opendaylight.controller.md.sal.common.api.TransactionStatus; +import org.opendaylight.controller.sal.common.util.RpcErrors; import org.opendaylight.controller.sal.core.api.mount.MountInstance; import org.opendaylight.controller.sal.core.api.mount.MountService; import org.opendaylight.controller.sal.rest.api.Draft02; @@ -47,14 +51,15 @@ import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper; import org.opendaylight.controller.sal.restconf.impl.ControllerContext; import org.opendaylight.controller.sal.restconf.impl.RestconfImpl; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; +import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; 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.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import com.google.common.util.concurrent.Futures; - public class RestPostOperationTest extends JerseyTest { private static String xmlDataAbsolutePath; @@ -102,12 +107,12 @@ public class RestPostOperationTest extends JerseyTest { resourceConfig = resourceConfig.registerInstances(restconfImpl, StructuredDataToXmlProvider.INSTANCE, StructuredDataToJsonProvider.INSTANCE, XmlToCompositeNodeProvider.INSTANCE, JsonToCompositeNodeProvider.INSTANCE); - resourceConfig.registerClasses( RestconfDocumentedExceptionMapper.class ); + resourceConfig.registerClasses(RestconfDocumentedExceptionMapper.class); return resourceConfig; } @Test - public void postOperationsStatusCodes() throws UnsupportedEncodingException { + public void postOperationsStatusCodes() throws IOException { controllerContext.setSchemas(schemaContextTestModule); mockInvokeRpc(cnSnDataOutput, true); String uri = "/operations/test-module:rpc-test"; @@ -119,6 +124,12 @@ public class RestPostOperationTest extends JerseyTest { mockInvokeRpc(null, false); assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput)); + List rpcErrors = new ArrayList<>(); + rpcErrors.add( RpcErrors.getRpcError("applicationTag1", "tag1", "info1", ErrorSeverity.ERROR, "message1", ErrorType.RPC, null)); + rpcErrors.add( RpcErrors.getRpcError("applicationTag2", "tag2", "info2", ErrorSeverity.WARNING, "message2", ErrorType.PROTOCOL, null)); + mockInvokeRpc(null, false, rpcErrors); + assertEquals(500,post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput)); + uri = "/operations/test-module:rpc-wrongtest"; assertEquals(400, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput)); } @@ -150,7 +161,7 @@ public class RestPostOperationTest extends JerseyTest { mockCommitConfigurationDataPostMethod(TransactionStatus.FAILED); assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath)); - assertEquals( 400, post(uri, MediaType.APPLICATION_JSON, "" )); + assertEquals(400, post(uri, MediaType.APPLICATION_JSON, "")); } @Test @@ -158,7 +169,8 @@ public class RestPostOperationTest extends JerseyTest { controllerContext.setSchemas(schemaContextYangsIetf); RpcResult rpcResult = new DummyRpcResult.Builder().result( TransactionStatus.COMMITED).build(); - Future> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build(); + Future> dummyFuture = new DummyFuture.Builder().rpcResult( + rpcResult).build(); when( brokerFacade.commitConfigurationDataPostBehindMountPoint(any(MountInstance.class), any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture); @@ -175,14 +187,23 @@ public class RestPostOperationTest extends JerseyTest { uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont"; assertEquals(204, post(uri, Draft02.MediaTypes.DATA + XML, xmlData3)); - assertEquals( 400, post(uri, MediaType.APPLICATION_JSON, "" )); + assertEquals(400, post(uri, MediaType.APPLICATION_JSON, "")); } - private void mockInvokeRpc(CompositeNode result, boolean sucessful) { - RpcResult rpcResult = new DummyRpcResult.Builder().result(result) - .isSuccessful(sucessful).build(); + private void mockInvokeRpc(CompositeNode result, boolean sucessful, Collection errors) { + + DummyRpcResult.Builder builder = new DummyRpcResult.Builder().result(result) + .isSuccessful(sucessful); + if (!errors.isEmpty()) { + builder.errors(errors); + } + RpcResult rpcResult = builder.build(); when(brokerFacade.invokeRpc(any(QName.class), any(CompositeNode.class))) - .thenReturn(Futures.>immediateFuture( rpcResult )); + .thenReturn(Futures.> immediateFuture(rpcResult)); + } + + private void mockInvokeRpc(CompositeNode result, boolean sucessful) { + mockInvokeRpc(result, sucessful, Collections. emptyList()); } private void mockCommitConfigurationDataPostMethod(TransactionStatus statusName) { @@ -190,9 +211,9 @@ public class RestPostOperationTest extends JerseyTest { .build(); Future> dummyFuture = null; if (statusName != null) { - dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build(); + dummyFuture = new DummyFuture.Builder().rpcResult(rpcResult).build(); } else { - dummyFuture = DummyFuture.builder().build(); + dummyFuture = new DummyFuture.Builder().build(); } when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class))) @@ -204,7 +225,8 @@ public class RestPostOperationTest extends JerseyTest { initMocking(); RpcResult rpcResult = new DummyRpcResult.Builder().result( TransactionStatus.COMMITED).build(); - Future> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build(); + Future> dummyFuture = new DummyFuture.Builder().rpcResult( + rpcResult).build(); when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class))) .thenReturn(dummyFuture); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java index 77b39b7352..44b5f491d6 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestPutOperationTest.java @@ -18,12 +18,10 @@ import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URISyntaxException; import java.util.concurrent.Future; - import javax.ws.rs.client.Entity; import javax.ws.rs.core.Application; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.junit.BeforeClass; @@ -88,7 +86,7 @@ public class RestPutOperationTest extends JerseyTest { resourceConfig = resourceConfig.registerInstances(restconfImpl, StructuredDataToXmlProvider.INSTANCE, StructuredDataToJsonProvider.INSTANCE, XmlToCompositeNodeProvider.INSTANCE, JsonToCompositeNodeProvider.INSTANCE); - resourceConfig.registerClasses( RestconfDocumentedExceptionMapper.class ); + resourceConfig.registerClasses(RestconfDocumentedExceptionMapper.class); return resourceConfig; } @@ -104,14 +102,15 @@ public class RestPutOperationTest extends JerseyTest { mockCommitConfigurationDataPutMethod(TransactionStatus.FAILED); assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData)); - assertEquals( 400, put(uri, MediaType.APPLICATION_JSON, "" )); + assertEquals(400, put(uri, MediaType.APPLICATION_JSON, "")); } @Test public void putConfigStatusCodesEmptyBody() throws UnsupportedEncodingException { String uri = "/config/ietf-interfaces:interfaces/interface/eth0"; - Response resp = target(uri).request( MediaType.APPLICATION_JSON).put(Entity.entity( "", MediaType.APPLICATION_JSON)); - assertEquals( 400, put(uri, MediaType.APPLICATION_JSON, "" )); + Response resp = target(uri).request(MediaType.APPLICATION_JSON).put( + Entity.entity("", MediaType.APPLICATION_JSON)); + assertEquals(400, put(uri, MediaType.APPLICATION_JSON, "")); } @Test @@ -120,7 +119,8 @@ public class RestPutOperationTest extends JerseyTest { RpcResult rpcResult = new DummyRpcResult.Builder().result( TransactionStatus.COMMITED).build(); - Future> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build(); + Future> dummyFuture = new DummyFuture.Builder().rpcResult( + rpcResult).build(); when( brokerFacade.commitConfigurationDataPutBehindMountPoint(any(MountInstance.class), any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture); @@ -143,7 +143,8 @@ public class RestPutOperationTest extends JerseyTest { public void putDataMountPointIntoHighestElement() throws UnsupportedEncodingException, URISyntaxException { RpcResult rpcResult = new DummyRpcResult.Builder().result( TransactionStatus.COMMITED).build(); - Future> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build(); + Future> dummyFuture = new DummyFuture.Builder().rpcResult( + rpcResult).build(); when( brokerFacade.commitConfigurationDataPutBehindMountPoint(any(MountInstance.class), any(InstanceIdentifier.class), any(CompositeNode.class))).thenReturn(dummyFuture); @@ -166,7 +167,8 @@ public class RestPutOperationTest extends JerseyTest { private void mockCommitConfigurationDataPutMethod(TransactionStatus statusName) { RpcResult rpcResult = new DummyRpcResult.Builder().result(statusName) .build(); - Future> dummyFuture = DummyFuture.builder().rpcResult(rpcResult).build(); + Future> dummyFuture = new DummyFuture.Builder().rpcResult( + rpcResult).build(); when(brokerFacade.commitConfigurationDataPut(any(InstanceIdentifier.class), any(CompositeNode.class))) .thenReturn(dummyFuture); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfDocumentedExceptionMapperTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfDocumentedExceptionMapperTest.java index e146cf8f4f..c5c4596189 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfDocumentedExceptionMapperTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfDocumentedExceptionMapperTest.java @@ -9,6 +9,7 @@ package org.opendaylight.controller.sal.restconf.impl.test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -18,6 +19,12 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.when; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.google.common.io.ByteStreams; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -29,7 +36,8 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; - +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.ws.rs.core.Application; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -41,7 +49,6 @@ import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathFactory; - import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.junit.Before; @@ -63,13 +70,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import com.google.common.io.ByteStreams; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; - /** * Unit tests for RestconfDocumentedExceptionMapper. * @@ -842,6 +842,14 @@ public class RestconfDocumentedExceptionMapperTest extends JerseyTest { errorListEntrySet.iterator().next().getKey() ); assertTrue( "\"error\" Json element is not an Array", errorListElement.isJsonArray() ); + // As a final check, make sure there aren't multiple "error" array elements. Unfortunately, + // the call above to getAsJsonObject().entrySet() will out duplicate "error" elements. So + // we'll use regex on the json string to verify this. + + Matcher matcher = Pattern.compile( "\"error\"[ ]*:[ ]*\\[", Pattern.DOTALL ).matcher( bos.toString() ); + assertTrue( "Expected 1 \"error\" element", matcher.find() ); + assertFalse( "Found multiple \"error\" elements", matcher.find() ); + return errorListElement.getAsJsonArray(); } @@ -850,7 +858,6 @@ public class RestconfDocumentedExceptionMapperTest extends JerseyTest { final ErrorInfoVerifier errorInfoVerifier ) { JsonElement errorInfoElement = null; - Map actualErrorInfo = null; Map leafMap = Maps.newHashMap(); for( Entry entry: errorEntryElement.getAsJsonObject().entrySet() ) { String leafName = entry.getKey(); diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/structures/LstItem.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/structures/LstItem.java index 9b382d210e..3617ed9fb0 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/structures/LstItem.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/structures/LstItem.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.sal.restconf.impl.test.structures; +import static org.junit.Assert.assertFalse; import java.util.HashMap; import java.util.Map; @@ -56,10 +57,14 @@ public class LstItem { } public void addLfLst(LfLst lfLst) { + assertFalse( "Found multiple leaf list elements for " + lfLst.getName(), + lfLsts.containsKey( lfLst.getName() ) ); lfLsts.put(lfLst.getName(), lfLst); } public void addLst(Lst lst) { + assertFalse( "Found multiple list elements for " + lst.getName(), + lsts.containsKey( lst.getName() ) ); lsts.put(lst.getName(), lst); } diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/simple-data-types.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/simple-data-types.yang index 9bdea81579..cf6e513b30 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/simple-data-types.yang +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/simple-data-types.yang @@ -269,6 +269,10 @@ module simple-data-types { } } - + anyxml complex-any; + + anyxml simple-any; + + anyxml empty-any; } } \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/xml/data.xml b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/xml/data.xml index 28d355dbab..ed02ca35f6 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/xml/data.xml +++ b/opendaylight/md-sal/sal-rest-connector/src/test/resources/cnsn-to-json/simple-data-types/xml/data.xml @@ -23,7 +23,6 @@ enum3 bit3 bit2 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz - 324 33.3 55 @@ -38,5 +37,35 @@ false b1 zero + x:iden - \ No newline at end of file + + + leaf1-value + leaf2-value + + leaf-list-value1 + leaf-list-value2 + + + + nested-value1 + + + nested-value2 + + + + + + nested-value3 + + + nested-value4 + + + + + simple + + diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java index 1069858b47..f5fe089d4d 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java @@ -95,8 +95,10 @@ public class NetconfOperationServiceImpl implements NetconfOperationService { Set capabilities = new HashSet<>(); // [RFC6241] 8.3. Candidate Configuration Capability capabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:candidate:1.0")); + + // TODO rollback on error not supported EditConfigXmlParser:100 // [RFC6241] 8.5. Rollback-on-Error Capability - capabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:rollback-on-error:1.0")); + // capabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:rollback-on-error:1.0")); Set modules = yangStoreSnapshot.getModules(); for (Module module : modules) { diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java index 8d85a35bc7..eddad8b4c7 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/ConfigPusher.java @@ -8,6 +8,11 @@ package org.opendaylight.controller.netconf.persist.impl; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.Function; +import com.google.common.base.Stopwatch; +import com.google.common.collect.Collections2; import java.io.IOException; import java.io.InputStream; import java.util.Collection; @@ -16,11 +21,10 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map.Entry; import java.util.Set; +import java.util.SortedSet; import java.util.TreeMap; import java.util.concurrent.TimeUnit; - import javax.annotation.concurrent.Immutable; - import org.opendaylight.controller.config.api.ConflictingVersionException; import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; @@ -41,11 +45,6 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; -import com.google.common.base.Function; -import com.google.common.base.Preconditions; -import com.google.common.base.Stopwatch; -import com.google.common.collect.Collections2; - @Immutable public class ConfigPusher { private static final Logger logger = LoggerFactory.getLogger(ConfigPusher.class); @@ -84,7 +83,11 @@ public class ConfigPusher { ConflictingVersionException lastException; Stopwatch stopwatch = new Stopwatch().start(); do { - try (NetconfOperationService operationService = getOperationServiceWithRetries(configSnapshotHolder.getCapabilities(), configSnapshotHolder.toString())) { + String idForReporting = configSnapshotHolder.toString(); + SortedSet expectedCapabilities = checkNotNull(configSnapshotHolder.getCapabilities(), + "Expected capabilities must not be null - %s, check %s", idForReporting, + configSnapshotHolder.getClass().getName()); + try (NetconfOperationService operationService = getOperationServiceWithRetries(expectedCapabilities, idForReporting)) { return pushConfig(configSnapshotHolder, operationService); } catch (ConflictingVersionException e) { lastException = e; @@ -252,7 +255,7 @@ public class ConfigPusher { private static NetconfMessage createEditConfigMessage(Element dataElement) throws NetconfDocumentedException { String editConfigResourcePath = "/netconfOp/editConfig.xml"; try (InputStream stream = ConfigPersisterNotificationHandler.class.getResourceAsStream(editConfigResourcePath)) { - Preconditions.checkNotNull(stream, "Unable to load resource " + editConfigResourcePath); + checkNotNull(stream, "Unable to load resource " + editConfigResourcePath); Document doc = XmlUtil.readXmlToDocument(stream); @@ -274,7 +277,7 @@ public class ConfigPusher { private static NetconfMessage getCommitMessage() { String resource = "/netconfOp/commit.xml"; try (InputStream stream = ConfigPusher.class.getResourceAsStream(resource)) { - Preconditions.checkNotNull(stream, "Unable to load resource " + resource); + checkNotNull(stream, "Unable to load resource " + resource); return new NetconfMessage(XmlUtil.readXmlToDocument(stream)); } catch (SAXException | IOException e) { // error reading the xml file bundled into the jar diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java index 148b0446e3..f7091beba5 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java @@ -143,8 +143,8 @@ public class NetconfConfigPersisterITTest extends AbstractNetconfConfigTest { } notificationVerifier.assertNotificationCount(2); - notificationVerifier.assertNotificationContent(0, 0, 0, 9); - notificationVerifier.assertNotificationContent(1, 4, 3, 9); + notificationVerifier.assertNotificationContent(0, 0, 0, 8); + notificationVerifier.assertNotificationContent(1, 4, 3, 8); mockedAggregator.assertSnapshotCount(2); // Capabilities are stripped for persister diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClientAdapter.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClientAdapter.java index cf4ec213c2..ad8b25ff21 100644 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClientAdapter.java +++ b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/SshClientAdapter.java @@ -52,15 +52,8 @@ public class SshClientAdapter implements Runnable { } public void run() { - SshSession session; - try { - session = sshClient.openSession(); - } catch (IOException e) { - logger.error("Cannot establish session", e); - sshClient.close(); - return; - } try { + SshSession session = sshClient.openSession(); invoker.invoke(session); InputStream stdOut = session.getStdout(); session.getStderr(); @@ -90,6 +83,8 @@ public class SshClientAdapter implements Runnable { } catch (VirtualSocketException e) { // Netty closed connection prematurely. + // Or maybe tried to open ganymed connection without having initialized session + // (ctx.channel().remoteAddress() is null) // Just pass and move on. } catch (Exception e) { logger.error("Unexpected exception", e); @@ -117,6 +112,7 @@ public class SshClientAdapter implements Runnable { private void writeImpl(ByteBuf message) throws IOException { message.getBytes(0, stdIn, message.readableBytes()); + message.release(); stdIn.flush(); } diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/virtualsocket/VirtualSocketException.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/virtualsocket/VirtualSocketException.java index d97990a5e6..626ebe937e 100644 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/virtualsocket/VirtualSocketException.java +++ b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/virtualsocket/VirtualSocketException.java @@ -11,6 +11,7 @@ package org.opendaylight.controller.netconf.nettyutil.handler.ssh.virtualsocket; /** * Exception class which provides notification about exceptional situations at the virtual socket layer. */ +// FIXME: Switch to checked exception, create a runtime exception to workaround Socket API public class VirtualSocketException extends RuntimeException { private static final long serialVersionUID = 1L; } diff --git a/opendaylight/northbound/commons/pom.xml b/opendaylight/northbound/commons/pom.xml index 09c075735a..a2d2dac112 100644 --- a/opendaylight/northbound/commons/pom.xml +++ b/opendaylight/northbound/commons/pom.xml @@ -12,7 +12,6 @@ 0.4.2-SNAPSHOT bundle - com.fasterxml.jackson.core jackson-databind @@ -65,6 +64,13 @@ org.opendaylight.controller usermanager + + + ch.qos.logback + logback-classic + test + + @@ -78,6 +84,7 @@ org.opendaylight.controller.northbound.commons.exception, org.opendaylight.controller.northbound.commons.types, org.opendaylight.controller.northbound.commons.utils, + org.opendaylight.controller.northbound.commons.query, org.opendaylight.controller.northbound.commons javax.ws.rs, javax.ws.rs.ext, @@ -105,6 +112,40 @@ ${project.basedir}/META-INF + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + + add-source + + generate-sources + + + ${project.build.directory}/generated-sources/javacc + + + + + + + + org.codehaus.mojo + javacc-maven-plugin + 2.6 + + + javacc + + javacc + + + + + diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/NorthboundApplication.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/NorthboundApplication.java index 4393b79f64..87f51364ba 100644 --- a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/NorthboundApplication.java +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/NorthboundApplication.java @@ -20,6 +20,7 @@ import javax.xml.bind.JAXBException; import javax.xml.bind.annotation.XmlRootElement; import org.opendaylight.controller.northbound.bundlescanner.IBundleScanService; +import org.opendaylight.controller.northbound.commons.query.QueryContextProvider; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleReference; @@ -58,6 +59,7 @@ public class NorthboundApplication extends Application { } ); _singletons.add(getJsonProvider()); _singletons.add(new JacksonJsonProcessingExceptionMapper()); + _singletons.add(new QueryContextProvider()); } //////////////////////////////////////////////////////////////// diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Accessor.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Accessor.java new file mode 100644 index 0000000000..2d910edc6d --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Accessor.java @@ -0,0 +1,55 @@ +package org.opendaylight.controller.northbound.commons.query; + +import java.lang.annotation.Annotation; +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Type; + +/*package*/ class Accessor { + protected final AccessibleObject _accessorObj; + + public Accessor(AccessibleObject accessor) { + _accessorObj = accessor; + _accessorObj.setAccessible(true); + } + + public AccessibleObject getAccessibleObject() { + return _accessorObj; + } + + public Annotation[] getAnnotations() { + return _accessorObj.getAnnotations(); + } + + public Object getValue(Object parent) throws QueryException { + try { + if (_accessorObj instanceof Field) { + return ((Field)_accessorObj).get(parent); + } else { + // assume method + return ((Method)_accessorObj).invoke(parent); + } + } catch (Exception e) { + throw new QueryException("Failure in retrieving value", e); + } + } + public Type getGenericType() { + if (_accessorObj instanceof Field) { + return ((Field)_accessorObj).getGenericType(); + } else { + // assume method + return ((Method)_accessorObj).getGenericReturnType(); + } + } + public Class getType() { + + if (_accessorObj instanceof Field) { + return ((Field)_accessorObj).getType(); + } else { + // assume method + return ((Method)_accessorObj).getReturnType(); + } + } + +} diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/CompareExpression.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/CompareExpression.java new file mode 100644 index 0000000000..6b972e641c --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/CompareExpression.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +/*package*/ class CompareExpression implements Expression { + + public static enum OP { RE, EQ, NE, GT, GE, LT, LE }; + + private final OP _operation; + private final String _selector; + private final String _arg; + + public CompareExpression(OP op, String selector, String arg) { + _operation = op; + _selector = selector; + _arg = unQuote(arg); + } + + + public OP getOperator() { + return _operation; + } + + public String getSelector() { + return _selector; + } + + public String getArgument() { + return _arg; + } + + @Override + public boolean accept(Visitor visitor) throws QueryException { + return visitor.visit(this); + } + + @Override + public String toString() { + return "[" + _selector + " " + _operation + " " + _arg + "]"; + } + + private static String unQuote(String s) { + if (s.startsWith("\"") && s.endsWith("\"")) { + s = s.substring(1, s.length()-1); + } else if (s.startsWith("\'") && s.endsWith("\'")) { + s = s.substring(1, s.length()-1); + } + return s; + } + +} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeFactory.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Expression.java similarity index 53% rename from opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeFactory.java rename to opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Expression.java index c6dd25c76b..fbc22a016d 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataTreeFactory.java +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Expression.java @@ -1,20 +1,12 @@ -/* +/** * Copyright (c) 2014 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.md.sal.dom.store.impl.tree; +package org.opendaylight.controller.northbound.commons.query; -/** - * Factory interface for creating data trees. - */ -public interface DataTreeFactory { - /** - * Create a new data tree. - * - * @return A data tree instance. - */ - DataTree create(); +/*package*/ interface Expression { + boolean accept(Visitor visitor) throws QueryException; } diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/ExpressionBuilder.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/ExpressionBuilder.java new file mode 100644 index 0000000000..f1b2999b77 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/ExpressionBuilder.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +import java.util.Stack; + +/*package*/ class ExpressionBuilder { + private final Stack _stack = new Stack(); + private LogicalExpression.OP _lastOp = null; + + public ExpressionBuilder() {} + + public ExpressionBuilder withAnd() { + _lastOp = LogicalExpression.OP.AND; + return this; + } + + public ExpressionBuilder withOr() { + _lastOp = LogicalExpression.OP.OR; + return this; + } + + public ExpressionBuilder withTerm(Expression exp) { + if (_lastOp != null) { + exp = new LogicalExpression(_lastOp, _stack.pop(), exp); + _lastOp = null; + } + _stack.push(exp); + return this; + } + + public Expression build() { + return _stack.pop(); + } + +} diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/IteratableTypeInfo.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/IteratableTypeInfo.java new file mode 100644 index 0000000000..3977837c7f --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/IteratableTypeInfo.java @@ -0,0 +1,67 @@ +package org.opendaylight.controller.northbound.commons.query; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +/** + */ +/*package*/ class IteratableTypeInfo extends TypeInfo { + + public IteratableTypeInfo(String name, Accessor accessor) { + super(name, accessor.getType(), accessor); + } + + @Override + public Object retrieve(Object target, String[] query, int index) throws QueryException { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("retrieve collection: {}/{} type:{}", index, query.length, + target.getClass()); + } + explore(); + Collection c = (Collection) target; + Iterator it = c.iterator(); + List objects = new ArrayList(); + while (it.hasNext()) { + Object item = it.next(); + for (TypeInfo child : _types.values()) { + Object val = child.retrieve(item, query, index); + if (val != null) objects.add(val); + } + } + return objects; + + } + + @Override + public synchronized void explore() { + if (_explored) return; + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("exploring iteratable type: {} gtype: {}", _class, + _accessor.getGenericType()); + } + Type t = _accessor.getGenericType(); + if (t instanceof ParameterizedType) { + Type[] pt = ((ParameterizedType) t).getActualTypeArguments(); + // First type is a child, ignore rest + if (pt.length > 0) { + _types.put(_name, new TypeInfo(_name, (Class)pt[0], null)); + } + } + _explored = true; + } + + @Override + public TypeInfo getCollectionChild(Class childType) { + explore(); + for (TypeInfo ti : _types.values()) { + if (ti.getType().equals(childType)) { + return ti; + } + } + return null; + } +} diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/LogicalExpression.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/LogicalExpression.java new file mode 100644 index 0000000000..4e99820983 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/LogicalExpression.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +/*package*/ class LogicalExpression implements Expression { + + public static enum OP { AND, OR } + + private final OP _op; + private final Expression _arg1; + private final Expression _arg2; + + public LogicalExpression(OP op, Expression first, Expression second) { + _op = op; + _arg1 = first; + _arg2 = second; + } + + public OP getOperator() { + return _op; + } + + public Expression getFirst() { + return _arg1; + } + + public Expression getSecond() { + return _arg2; + } + + @Override + public boolean accept(Visitor visitor) throws QueryException { + return visitor.visit(this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(_arg1.toString()) + .append(_op.toString()) + .append(_arg2.toString()); + return sb.toString(); + } + +} diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Query.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Query.java new file mode 100644 index 0000000000..15dcaebe27 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Query.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +import java.util.Collection; +import java.util.List; + + +/** + * Represents a parsed query used in filtering of collections. + */ +public interface Query { + + /** + * Find items in the given collection and return them as a new list. The + * original collection is not changed. + * + * @param collection to search in. + * @return list of items which match the query. + * @throws QueryException + */ + public List find(Collection collection) throws QueryException; + + /** + * Apply the query on the given collection. Note that this method will modify + * the given object by removing any items which don't match the query criteria. + * If the collection is 'singleton' or unmodifiable, invocation will result in + * an exception. + * + * @param collection + * @return the number matched items + * @throws QueryException + */ + public int filter(Collection collection) throws QueryException; + + /** + * Search the given root for a child collection and them apply the query on. + * Note that this method will modify the given object by removing any items + * which don't match the query criteria. + * + * @param root - top level object to search in + * @param childType - the child type which represents the collection. + * @return the number of matched items + * @throws QueryException + */ + public int filter(T root, Class childType) throws QueryException; +} diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContext.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContext.java new file mode 100644 index 0000000000..59a78ac113 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContext.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +/** + * Query context + */ +public interface QueryContext { + + /** + * Create a Query + * @param queryString - query string to parse + * @param clazz - The class which represents the top level jaxb object + * @return a query object + * @throws QueryException if the query cannot be parsed. + */ + Query createQuery(String queryString, Class clazz) + throws QueryException; + +} diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContextImpl.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContextImpl.java new file mode 100644 index 0000000000..13d70b1cb0 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContextImpl.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/*package*/ class QueryContextImpl implements QueryContext { + + private static final Logger LOGGER = LoggerFactory.getLogger(QueryContext.class); + + @Override + public Query createQuery(String queryString, Class type) throws QueryException { + if (queryString == null || queryString.trim().length() == 0) return null; + try { + if (LOGGER.isDebugEnabled()) LOGGER.debug("Processing query: {}", queryString); + // FiqlParser is a parser generated by javacc + Expression expression = FiqlParser.parse(queryString); + if (LOGGER.isDebugEnabled()) LOGGER.debug("Query expression: {}", expression); + // create Query and return; + return new QueryImpl(type, expression); + } catch (Exception ex) { + if (LOGGER.isDebugEnabled()) LOGGER.error("Query processing failed = {}", + queryString, ex); + throw new QueryException("Unable to parse query.", ex); + } + } +} \ No newline at end of file diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContextProvider.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContextProvider.java new file mode 100644 index 0000000000..65a232c245 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContextProvider.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +import javax.ws.rs.ext.ContextResolver; +import javax.ws.rs.ext.Provider; + +/** + * A provider for getting hold of the QueryContext. + */ +@Provider +public class QueryContextProvider implements ContextResolver { + + // Singleton Query Context instance + private static final QueryContext queryContext = new QueryContextImpl(); + + @Override + public QueryContext getContext(Class type) { + return queryContext; + } + +} diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryException.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryException.java new file mode 100644 index 0000000000..9ff78eddfc --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryException.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +/** + * Signals that an error happened during the parsing or processing of a query. + */ +public class QueryException extends WebApplicationException { + + private static final long serialVersionUID = 1L; + + public QueryException(String msg) { + super(Response.status(Response.Status.BAD_REQUEST) + .entity(msg).type(MediaType.TEXT_PLAIN).build()); + } + + public QueryException(String msg, Throwable cause) { + super(cause, Response.status(Response.Status.BAD_REQUEST) + .entity(msg).type(MediaType.TEXT_PLAIN).build()); + } +} diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryImpl.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryImpl.java new file mode 100644 index 0000000000..a520f98fc0 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryImpl.java @@ -0,0 +1,237 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.regex.Pattern; + +import org.opendaylight.controller.northbound.commons.query.CompareExpression.OP; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + */ +/*package*/ class QueryImpl implements Query { + public static final Logger LOGGER = LoggerFactory.getLogger(QueryImpl.class); + private static final boolean ALLOW_OBJECT_STRING_COMPARE = true; + + private final Expression expression; + private final TypeInfo rootType ; + /** + * Set the expression and cache + * @param type + * @param expression + */ + public QueryImpl(Class type, Expression expression) { + this.expression = expression; + this.rootType = TypeInfo.createRoot(null, type); + } + + @Override + public List find(Collection collection) throws QueryException { + // new arraylist for result + List result = new ArrayList(); + for (T item : collection) { + if (match(item, rootType)) { + result.add(item); + } + } + return result; + } + + @Override + public int filter(Collection collection) throws QueryException { + // find items + List matched = new ArrayList(); + for (T item : collection) { + if (match(item, rootType)) { + matched.add(item); + } + } + collection.clear(); + collection.addAll(matched); + return matched.size(); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public int filter(T rootObject, Class childClass) throws QueryException { + // retrieve underlying collection + TypeInfo childType = rootType.getCollectionChild(childClass); + if (childType == null || !(childType instanceof IteratableTypeInfo)) { + return 0; + } + Collection collection = (Collection) + childType.getAccessor().getValue(rootObject); + // get the child type of the collection type + TypeInfo ti = childType.getCollectionChild(childClass); + List matched = new ArrayList(); + for (Object item : collection) { + if (match(item, ti)) { + matched.add(item); + } + } + collection.clear(); + collection.addAll(matched); + return matched.size(); + } + + private boolean match(final Object object, final TypeInfo rootType) + throws QueryException { + return expression.accept(new Visitor () { + @Override + public boolean visit(LogicalExpression le) throws QueryException { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Logical exp {}|{}|{}", le.getOperator(), le.getFirst(), + le.getSecond()); + } + return (le.getOperator() == LogicalExpression.OP.AND) ? + le.getFirst().accept(this) && le.getSecond().accept(this) : + le.getFirst().accept(this) || le.getSecond().accept(this); + } + + @Override + public boolean visit(CompareExpression ce) throws QueryException { + boolean result = visitInternal(ce); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("=== Compare exp {}|{}|{} == {}", ce.getOperator(), + ce.getSelector(), ce.getArgument(), result); + } + return result; + } + + public boolean visitInternal(CompareExpression ce) throws QueryException { + String[] selector = ce.getSelector().split("\\."); + if (!rootType.getName().equals(selector[0])) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Root name mismatch: {} != {}", + rootType.getName(), selector[0]); + } + return false; + } + Object value = rootType.retrieve(object, selector, 1); + if(value == null){ // nothing to compare against + return false; + } + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Comparing [{}] {} [{}]", ce.getArgument(), + ce.getOperator(), value.toString()); + } + if (value instanceof Collection) { + Collection collection = (Collection) value; + if(collection.size() == 0 && ce.getOperator() == OP.NE) { + // collection doesn't contain query string + return true; + } + // If there are elements iterate + Iterator it = collection.iterator(); + OP operator = ce.getOperator(); + if (operator == OP.NE) { + // negate the operator + operator = OP.EQ; + } + while (it.hasNext()) { + Object item = it.next(); + if (compare(parse(ce.getArgument(), item), item, operator)) { + // if match found check the operator and return false for NE + return (ce.getOperator() != OP.NE); + } + } + // return true for NE and false for rest + return (ce.getOperator() == OP.NE); + } else { + return compare(parse(ce.getArgument(), value), value, + ce.getOperator()); + } + } + + }); + } + + private boolean compare(Object valueToMatch, Object actualValue, OP operator) { + if (valueToMatch == null || actualValue == null) return false; + if (ALLOW_OBJECT_STRING_COMPARE && (valueToMatch instanceof String) + && !(actualValue instanceof String)) { + actualValue = actualValue.toString(); + } + + int compareResult = -1; + if (valueToMatch instanceof Comparable) { + compareResult = ((Comparable)actualValue).compareTo(valueToMatch); + } else { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Not a comparable type: {} {}", + valueToMatch.getClass().getName(), + actualValue.getClass().getName()); + } + return false; + } + switch(operator) { + case EQ : + return compareResult == 0; + case RE : + // Regex match, + if (valueToMatch instanceof String) { + return Pattern.matches((String)valueToMatch, actualValue.toString()); + } else { + return compareResult == 0; + } + case NE: + return compareResult != 0; + case GT : + return compareResult > 0; + case GE : + return compareResult >= 0; + case LT : + return compareResult < 0; + case LE : + return compareResult <= 0; + default: + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Unrecognized comparator - {}", operator); + } + return false; + } + } + private Object parse(String arg, Object value) { + if (value == null) return null; + + try { + if (value instanceof String) { + return arg; + } else if (value instanceof Byte) { + return Byte.decode(arg); + } else if (value instanceof Double) { + return Double.parseDouble(arg); + } else if (value instanceof Float) { + return Float.parseFloat(arg); + } else if (value instanceof Integer) { + return Integer.parseInt(arg); + } else if (value instanceof Long) { + return Long.parseLong(arg); + } else if (value instanceof Short) { + return Short.parseShort(arg); + } + } catch (NumberFormatException ignore) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Exception parsing {}", arg, value); + } + } + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Using string comparision for type - {}", + value.getClass().getName()); + } + // Not a number or string. Convert to a string and compare as last resort + return ALLOW_OBJECT_STRING_COMPARE ? arg.toString() : null; + } + +} diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/TypeInfo.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/TypeInfo.java new file mode 100644 index 0000000000..91f01d8ad7 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/TypeInfo.java @@ -0,0 +1,294 @@ +package org.opendaylight.controller.northbound.commons.query; + +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; +import javax.xml.bind.annotation.XmlType; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A wrapper over a JAXB type to allow traversal of the object graph and + * search for specific values in the object tree. + */ +/*package*/ class TypeInfo { + + public static final Logger LOGGER = LoggerFactory.getLogger(TypeInfo.class); + public static final String DEFAULT_NAME = "##default"; + + protected final String _name; // the jaxb name + protected Class _class; // jaxb type class + protected final XmlAccessType _accessType; // jaxb access type + protected final Accessor _accessor; // accessor to access object value + protected Map _types = new HashMap(); + protected volatile boolean _explored = false; + /** + * Create a TypeInfo with a name and a class type. The accessor will be null + * for a root node. + */ + protected TypeInfo(String name, Class clz, Accessor accessor) { + _name = name; + _class = clz; + _accessor = accessor; + XmlAccessorType accessorType = null; + if(clz == null) { + throw new NullPointerException("Type class can not be null"); + } + accessorType = clz.getAnnotation(XmlAccessorType.class); + _accessType = (accessorType == null ? + XmlAccessType.PUBLIC_MEMBER : accessorType.value()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Created type info name:{} type:{}", _name, _class); + } + } + + /** + * @return the Accessor to access the value + */ + public final Accessor getAccessor() { + return _accessor; + } + + /** + * @return get the child by name + */ + public final TypeInfo getChild(String name) { + return _types.get(name); + } + + public TypeInfo getCollectionChild(Class childType) { + explore(); + for (TypeInfo ti : _types.values()) { + if (Collection.class.isAssignableFrom(ti.getType())) { + ParameterizedType p = (ParameterizedType) + ti.getAccessor().getGenericType(); + Type[] pts = p.getActualTypeArguments(); + if (pts.length == 1 && pts[0].equals(childType)) { + return ti; + } + } + } + return null; + } + + public Class getType() { + return _class; + } + + public String getName() { + return _name; + } + + /** + * @return the object value by a selector query + */ + public Object retrieve(Object target, String[] query, int index) + throws QueryException { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("retrieve: {}/{} type:{}", index, query.length, target.getClass()); + } + if (index >= query.length) return null; + explore(); + if (!target.getClass().equals(_class)) { + if (_class.isAssignableFrom(target.getClass())) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Handling subtype {} of {} ", target.getClass(), _class); + } + // explore the subtype + TypeInfo subTypeInfo = new TypeInfo(getRootName(target.getClass()), + target.getClass(), _accessor); + return subTypeInfo.retrieve(target, query, index); + } else { + // non compatible object; bail out + return null; + } + } + TypeInfo child = getChild(query[index]); + if (child == null) return null; + target = child.getAccessor().getValue(target); + if (index+1 == query.length) { + // match found + return target; + } + return child.retrieve(target, query, index+1); + } + + /** + * Explore the type info for children. + */ + public synchronized void explore() { + if (_explored) return; + for (Class c = _class; c != null; c = c.getSuperclass()) { + if (c.equals(Object.class)) break; + // Currently only fields and methods annotated with JAXB annotations are + // considered as valid for search purposes. + //check methods first + for (Method m : c.getDeclaredMethods()) { + String tn = getTypeName(m, _accessType); + if (tn != null) { + if (LOGGER.isDebugEnabled()) LOGGER.debug( + "exploring type: {} name: {} method: {}", + _class.getSimpleName(), tn, m); + _types.put(tn, createTypeInfo(tn, new Accessor(m))); + } + } + for (Field f : c.getDeclaredFields()) { + String tn = getTypeName(f, _accessType); + if (tn != null) { + if (LOGGER.isDebugEnabled()) LOGGER.debug( + "exploring type: {} name: {} field: {}", + _class.getSimpleName(), tn, f); + _types.put(tn, createTypeInfo(tn, new Accessor(f))); + } + } + } + _explored = true; + } + + public static final String getTypeName(Field f, XmlAccessType access) { + // ignore static, transient and xmltransient fields + if (Modifier.isTransient(f.getModifiers()) || + Modifier.isStatic(f.getModifiers()) || + f.getAnnotation(XmlTransient.class) != null ) { + return null; + } + // try to read annotation + String name = getTypeName(f.getAnnotations(), f.getName()); + if (name != null) return name; + // no annotation present check accesstype + else if (access == XmlAccessType.NONE) { // none return name + return name; + } else if (access == XmlAccessType.FIELD) { + // return field name if no annotation present + return f.getName(); + } else if (access == XmlAccessType.PUBLIC_MEMBER + && Modifier.isPublic(f.getModifiers())) { // look for public access + return f.getName(); + } + // return annotated name ( if any ) + return null; + } + + public static final String getTypeName(Method m, XmlAccessType access) { + // ignore static, transient and xmltransient fields + if (Modifier.isStatic(m.getModifiers()) || + m.getAnnotation(XmlTransient.class) != null ) { + return null; + } + // try to read annotation + String name = getTypeName(m.getAnnotations(), m.getName()); + if (name != null) return name; + //check acces type + else if (access == XmlAccessType.NONE) { // none return name + return name; + } else if (access == XmlAccessType.PROPERTY) { + // return bean property name if no annotation present + return getBeanPropertyName(m); + } else if (access == XmlAccessType.PUBLIC_MEMBER + && Modifier.isPublic(m.getModifiers())) { // look for public access + return getBeanPropertyName(m); + } + return null; + } + + private static String getBeanPropertyName(Method m){ + try + { + Class clazz=m.getDeclaringClass(); + BeanInfo info = Introspector.getBeanInfo(clazz); + PropertyDescriptor[] props = info.getPropertyDescriptors(); + for (PropertyDescriptor pd : props) + { + if (m.equals(pd.getReadMethod())) return pd.getName(); + } + } + catch (IntrospectionException e) + { + LOGGER.error("Could not read bean property name for method = {}", + m.getName(), e); + } + return null; + } + + public static TypeInfo createRoot(String name, Class clz) { + // root is always a composite type + // FIXME assert its a JAXB type + XmlRootElement root = clz.getAnnotation(XmlRootElement.class); + if (root == null) throw new IllegalArgumentException("Not a JAXB type: " + clz); + if (name == null) name = getRootName(clz); + return new TypeInfo(name, clz, null); + } + + public static TypeInfo createTypeInfo(String name, Accessor accessor) { + if (accessor.getAccessibleObject().getAnnotation(XmlElementWrapper.class) != null) { + //XmlElementWrapperType + return new WrapperTypeInfo(name, accessor); + } else if (Collection.class.isAssignableFrom(accessor.getType())) { + // collection type + return new IteratableTypeInfo(name, accessor); + } + return new TypeInfo(name, accessor.getType(), accessor); + } + + public static String getRootName(Class cls) { + XmlRootElement root = cls.getAnnotation(XmlRootElement.class); + if (root == null) return null; + String rootName = root.name(); + if (DEFAULT_NAME.equals(rootName)) { + String clsName = cls.getSimpleName(); + rootName = Character.toLowerCase(clsName.charAt(0)) + clsName.substring(1); + } + return rootName; + } + + protected static String getTypeName(Annotation[] annotations, String dflt) { + String name = null; + for (Annotation a : annotations) { + if (a.annotationType() == XmlAttribute.class) { + name = ((XmlAttribute)a).name(); + } else if (a.annotationType() == XmlElement.class) { + name = ((XmlElement)a).name(); + } else if (a.annotationType() == XmlElementRef.class) { + name = ((XmlElementRef)a).name(); + } else if (a.annotationType() == XmlElementWrapper.class) { + name = ((XmlElementWrapper)a).name(); + // break the loop as we don't want name to be overwritten by XmlElement + break; + } else if (a.annotationType() == XmlType.class) { + name = ((XmlType)a).name(); + } else if (a.annotationType() == XmlTransient.class) { + // transient type + return null; + } + } + if (DEFAULT_NAME.equals(name)) return dflt; + return name; + } + + @Override + public String toString() { + return " TypeInfo [_name=" + _name + ", _class=" + _class + + ", _accessType=" + _accessType + ", _accessor=" + _accessor + + ", _types=" + _types + ", _explored=" + _explored + " ] "; + } +} diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Visitor.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Visitor.java new file mode 100644 index 0000000000..0c1d2be236 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/Visitor.java @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +/*package*/ interface Visitor { + + boolean visit(LogicalExpression exp) throws QueryException; + + boolean visit(CompareExpression exp) throws QueryException; + +} diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/WrapperTypeInfo.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/WrapperTypeInfo.java new file mode 100644 index 0000000000..a8172f2add --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/WrapperTypeInfo.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import javax.xml.bind.annotation.XmlElement; + +public class WrapperTypeInfo extends TypeInfo { + + protected WrapperTypeInfo(String name, Accessor accessor) { + super(name, accessor.getType(), accessor); + } + + @Override + public Object retrieve(Object target, String[] query, int index) throws QueryException { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("retrieve collection: {}/{}", index, query.length); + } + if (index >= query.length) return null; + explore(); + TypeInfo child = getChild(query[index]); + if (child == null) return null; + if (query.length == index+1) { // skipping this node + return target; + }else { // if list of list go to next node to get value + return child.retrieve(target, query, index+1); + } + } + + @Override + public synchronized void explore() { + if (_explored) return; + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("exploring wrapper type: {} gtype: {}", _class, + _accessor.getGenericType()); + } + String tn = null; + AccessibleObject accessibleObject = _accessor.getAccessibleObject(); + XmlElement xmlElement = accessibleObject.getAnnotation(XmlElement.class); + if (accessibleObject instanceof Field) { + Field f = (Field) accessibleObject; + tn = DEFAULT_NAME.equals(xmlElement.name())?f.getName() : xmlElement.name(); + }else if (accessibleObject instanceof Method) { + Method m = (Method) accessibleObject; + tn = DEFAULT_NAME.equals(xmlElement.name())?m.getName() : xmlElement.name(); + } + this._types.put(tn, new IteratableTypeInfo(tn, this._accessor)); + _explored = true; + } + +} diff --git a/opendaylight/northbound/commons/src/main/javacc/fiql.jj b/opendaylight/northbound/commons/src/main/javacc/fiql.jj new file mode 100644 index 0000000000..b447a32a54 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/javacc/fiql.jj @@ -0,0 +1,124 @@ + +options { + STATIC = false; +} + +PARSER_BEGIN(FiqlParser) +package org.opendaylight.controller.northbound.commons.query; + +import java.util.regex.*; + +/*package*/ class FiqlParser { + public static Expression parse(String query) throws ParseException { + FiqlParser parser = new FiqlParser(new java.io.StringReader(query)); + return parser.START(); + } +} + +PARSER_END(FiqlParser) + +/* whitespace */ +SKIP : +{ + " " | "\t" +} + +TOKEN : { + <#ALPHA : ( ["a"-"z", "A"-"Z", "0"-"9"] )+ > +} + +TOKEN : { + + | + + | + +} + +/* comparision ops */ +TOKEN : { + + | + ") > + | + =") > +} + +/* ops */ +TOKEN : { + + | + +} + +/* strings */ +TOKEN : { + ", "!", "~", " "] )+ > + | + + | + +} + +/* Root production */ +Expression START() : +{ + Expression e; +} +{ + e = EXPR() + + { + return e; + } +} + +Expression EXPR(): +{ + ExpressionBuilder builder = new ExpressionBuilder(); + Expression t; +} +{ + t = TERM() { builder.withTerm(t); } + ( + ( t = TERM()) { builder.withAnd().withTerm(t); } + | + ( t = TERM() ) { builder.withOr().withTerm(t); } + )* + { + return builder.build(); + } +} + +Expression TERM() : +{ + Token selector, arg; + Expression exp; + CompareExpression.OP op; +} +{ + selector = + ( + ( {op=CompareExpression.OP.EQ;} | + {op=CompareExpression.OP.RE;} | + {op=CompareExpression.OP.NE;} | + {op=CompareExpression.OP.LT;} | + {op=CompareExpression.OP.LE;} | + {op=CompareExpression.OP.GT;} | + {op=CompareExpression.OP.GE;} + ) + ( arg = | arg = | arg = | arg = ) + ) { return new CompareExpression(op, selector.image, arg.image); } + | + ( + exp = EXPR() + ) { return exp; } +} diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/BookBean.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/BookBean.java new file mode 100644 index 0000000000..5d518f684d --- /dev/null +++ b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/BookBean.java @@ -0,0 +1,92 @@ +package org.opendaylight.controller.northbound.commons.query; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +import org.opendaylight.controller.northbound.commons.types.StringList; + +/** + */ + +@XmlRootElement(name="book") +public class BookBean { + + @XmlElement(name="name") + private String _name; // simple type + + private String _isbn; // method annotation + + @XmlElement(name="author") + private PersonBean _author; // composite type + + @XmlElementWrapper//for XMLWrapper iterative composite types + @XmlElement(name="review") + private final List reviews = new ArrayList(); + + @XmlElement + private List soldBy; //Iterative Type + + @XmlElementWrapper(name="test") + @XmlElement + private final List testList = new ArrayList(); //XMLWrapper list of list + + @XmlElementWrapper(name="parent") + @XmlElement(name="child") + private final List wrapperList = new ArrayList(); // XMLWrapper of XMLWrapper + + public BookBean(){} + + public BookBean(String name, String id, PersonBean person) { + _name = name; + _isbn = id; + _author = person; + soldBy = new ArrayList(); + } + + public BookBean addReview(ReviewBean review) { + reviews.add(review); + return this; + } + + public void setSellerInfo(List sellers) { + soldBy = new ArrayList(sellers); + } + + public void addWrapperList(WrapperList list){ + wrapperList.add(list); + } + + public void addToTestList(StringList testList){ + this.testList.add(testList); + } + public String getName() { + return "1"+_name; + } + + @XmlElement(name="isbn") + public String get_isbn() { + return "pre"+_isbn; + } + + public PersonBean getauthor() { + return _author; + } + + @Override + public String toString() { + return "BookBean [_name=" + _name + ", _isbn=" + _isbn + ", _author=" + + _author + ", reviews=" + reviews + ", soldBy=" + soldBy + + ", testList=" + testList + ", wrapperList=" + wrapperList + "]"; + } + +} + +class WrapperList { + @XmlElementWrapper(name="items") + @XmlElement + public List item = new ArrayList(); +} diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/ExpresssionTest.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/ExpresssionTest.java new file mode 100644 index 0000000000..3e2e1538e2 --- /dev/null +++ b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/ExpresssionTest.java @@ -0,0 +1,207 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.regex.Pattern; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.opendaylight.controller.northbound.commons.query.CompareExpression.OP; + +public class ExpresssionTest { + + private static final List people = new ArrayList(); + private static final ArrayList books = new ArrayList(); + + public static void p(String msg) { + //System.out.println("======= " + msg); + } + + public static boolean matches(Expression exp, final PersonBean person) throws Exception { + + boolean result = exp.accept(new Visitor() { + @Override + public boolean visit(LogicalExpression le) throws QueryException { + p("=== LE " + le.getOperator() + "|" + le.getFirst() + "|" + le.getSecond()); + return (le.getOperator() == LogicalExpression.OP.AND) ? + le.getFirst().accept(this) && le.getSecond().accept(this) : + le.getFirst().accept(this) || le.getSecond().accept(this); + } + + @Override + public boolean visit(CompareExpression ce) { + p("=== CE " + ce.getOperator() + "|" + ce.getSelector() + "|" + ce.getArgument()); + if (person == null) { + return false; + } + try { + // check if the selector matches any of the fields + Field field = PersonBean.class.getDeclaredField(ce.getSelector()); + if (field == null) { + p("No field found by name : " + ce.getSelector()); + return false; + } + Object value = field.get(person); + if (value instanceof String) { + p("Comparing [" + ce.getArgument() + "] "+ ce.getOperator() + " [" + value.toString() + "]"); + if (ce.getOperator() == OP.EQ) { + return ce.getArgument().equals(value.toString()); + } else if (ce.getOperator() == OP.RE) { + return Pattern.matches(ce.getArgument(), value.toString()); + } else if (ce.getOperator() == OP.NE) { + return !ce.getArgument().equals(value.toString()); + } else { + p("Comparator : " + ce.getOperator() + " cannot apply to Strings"); + return false; + } + } else { + // assume its a # + int valToMatch = Integer.parseInt(ce.getArgument()); + int actualValue = (Integer)value; + p("Comparing: " + valToMatch + " " + ce.getOperator() + " " + actualValue); + switch(ce.getOperator()) { + case EQ : + case RE : + return actualValue == valToMatch; + case NE : + return actualValue != valToMatch; + case GT : + return actualValue > valToMatch; + case GE : + return actualValue >= valToMatch; + case LT : + return actualValue < valToMatch; + case LE : + return actualValue <= valToMatch; + default: + p("Unrecognized compare operator: " + ce.getOperator()); + return false; + } + } + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + }); + p("RESULT: " + result); + return result; + } + + @BeforeClass + public static void load() { + System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "debug"); + + people.add(new PersonBean(100, "John", "Doe", "San Jose")); + people.add(new PersonBean(200, "Foo", "Bar", "San Francisco")); + people.add(new PersonBean(300, "A", "B", "San Francisco")); + people.add(new PersonBean(400, "X", "Y", "New York")); + + books.add(new BookBean("Book1", "A001", people.get(0))); + books.add(new BookBean("Book2", "A002", people.get(1))); + books.add(new BookBean("Book3", "A003", people.get(2))); + + ReviewBean review1 = new ReviewBean("cool", people.get(2)); + ReviewBean review2 = new ReviewBean("kewl", people.get(3)); + ReviewBean review3 = new ReviewBean("+++", people.get(0)); + ReviewBean review4 = new ReviewBean("---", people.get(1)); + + books.get(0).addReview(review1).addReview(review2).addReview(review3).addReview(review4); + books.get(1).addReview(review1).addReview(review2).addReview(review3).addReview(review4); + books.get(2).addReview(review1).addReview(review2).addReview(review3).addReview(review4); + } + + @Test + public void testCXFQueries() throws Exception { + // following queries copied from apache cxf + Assert.assertFalse(matches(parseQuery("id=gt=100;name=Fred"), null)); + Assert.assertFalse(matches(parseQuery("id=gt=100;name==Fred"), null)); + Assert.assertFalse(matches(parseQuery("id=lt=123"), null)); + Assert.assertFalse(matches(parseQuery("date=le=2010-03-11"), null)); + Assert.assertFalse(matches(parseQuery("time=le=2010-03-11T18:00:00"), null)); + Assert.assertFalse(matches(parseQuery("name==CXF;version=ge=2.2"), null)); + Assert.assertFalse(matches(parseQuery("(age=lt=25,age=gt=35);city==London"), null)); + Assert.assertFalse(matches(parseQuery("date=lt=2000-01-01;date=gt=1999-01-01;(sub==math,sub==physics)"), null)); + } + + public Expression parseQuery(String query) throws Exception { + p("PARSING query: " + query); + // FiqlParser is a parser generated by javacc + Expression exp = FiqlParser.parse(query); + p(exp.toString()); + return exp; + } + + public int find(String query) throws Exception { + int found = 0; + Expression exp = parseQuery(query); + TypeInfo.createRoot("person", PersonBean.class); + for (PersonBean person : people) { + if (matches(exp, person)) found++; + } + return found; + } + + @Test + public void testPeopleQueries() throws Exception { + Assert.assertTrue(find("id==200") == 1); + Assert.assertTrue(find("id!=100;(city='San.*')") == 2); + Assert.assertTrue(find("id>200;(city='San.*')") == 1); + Assert.assertTrue(find("city='San.*'") == 3); + } + + @Test + public void testTypeTree() throws Exception { + TypeInfo bookType = TypeInfo.createRoot("book", BookBean.class); + Assert.assertEquals("John", bookType.retrieve(books.get(0), + "book.author.firstName".split("\\."), 1)); + Object result = bookType.retrieve(books.get(0), + "book.reviews.review.comment".split("\\."), 1); + Assert.assertTrue( result instanceof List); + List commentList = (List) result; + Assert.assertTrue(commentList.contains("cool")); + } + + @Test + public void testQueryAPI() throws Exception { + QueryContext qc = new QueryContextImpl(); + + // find all books written by author with firstName "John" + Query q1 = qc.createQuery("book.author.firstName==John", BookBean.class); + Collection r1 = q1.find(books); + p("Filtered books: " + r1.size()); + Assert.assertEquals(1, r1.size()); + + // find all books reviewed by people in a city "San*" + Query q2 = qc.createQuery("book.reviews.review.reviewer.city=San.*", BookBean.class); + Collection r2 = q2.find(books); + + p("Filtered books: " + r2.size()); + Assert.assertEquals(3, r2.size()); + + // find all books reviewed by people in a city "San*" + Query q3 = qc.createQuery("book==foo", BookBean.class); + Collection r3 = q3.find(books); + Assert.assertEquals(0, r3.size()); + } + + @Test + public void testFilter() throws Exception { + Library library = new Library((List)books.clone()); + QueryContext qc = new QueryContextImpl(); + // find all books written by author with firstName "John" + Query q1 = qc.createQuery("book.author.firstName==John", Library.class); + int sizeBefore = library.getList().size(); + System.out.println(q1.filter(library, BookBean.class)); + Assert.assertEquals(1, library.getList().size()); + } +} diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/Library.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/Library.java new file mode 100644 index 0000000000..c54b0e719e --- /dev/null +++ b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/Library.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name="library") +public class Library { + + @XmlElement(name="book") + private final List _list; + + public Library(List list) { + _list = list; + } + + public List getList() { + return _list; + } + +} diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/PersonBean.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/PersonBean.java new file mode 100644 index 0000000000..b4b9ed5599 --- /dev/null +++ b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/PersonBean.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +import java.util.List; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name="person") + +public class PersonBean { + + @XmlElement + public String firstName; + @XmlElement + public String lastName; + @XmlElement + public String city; + @XmlElement + public int id; + + @XmlElementWrapper(name="emails") // ElementWrapper iteratable type + @XmlElement + public List email; + + public PersonBean(){} + public PersonBean(int n, String f, String l, String c) { + firstName = f; + lastName = l; + city = c; + id = n; + } + + public void setEmail(List emails){ + email = emails; + } + @Override + public String toString() { + return "PersonBean [firstName=" + firstName + ", lastName=" + lastName + + ", city=" + city + ", id=" + id + "]"; + } + +} diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/QueryContextTest.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/QueryContextTest.java new file mode 100644 index 0000000000..b6e582ba50 --- /dev/null +++ b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/QueryContextTest.java @@ -0,0 +1,269 @@ +/** + * Copyright (c) 2014 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.northbound.commons.query; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.opendaylight.controller.northbound.commons.types.StringList; + +public class QueryContextTest { + + protected static final List people = new ArrayList(); + protected static final List books = new ArrayList(); + + public static void p(String msg) { + System.out.println("=== " + msg); + } + + @BeforeClass + public static void load() { + people.add(new PersonBean(100, "John", "Doe", "San Jose")); + people.add(new PersonBean(200, "Foo", "Bar", "San Francisco")); + people.add(new PersonBean(300, "A", "B", "San Francisco")); + people.add(new PersonBean(400, "X", "Y", "New York")); + + books.add(new BookBean("Book1", "A001", people.get(0))); + books.add(new BookBean("Book2", "A002", people.get(1))); + books.add(new BookBean("Book3", "A003", people.get(2))); + + ReviewBean review1 = new ReviewBean("cool", people.get(2)); + ReviewBean review2 = new ReviewBean("kewl", people.get(3)); + + books.get(0).addReview(review1).addReview(review2); + books.get(1).addReview(review1); + books.get(2).addReview(review2).addReview(review1); + + } + + @Test + public void testQueryContext() { + QueryContext queryContext = new QueryContextImpl(); + Assert.assertNotNull(queryContext); + } + + @Test + public void testSimpleQuery() throws QueryException { + QueryContext queryContext = new QueryContextImpl(); + Query query = queryContext.createQuery( + "person.id==200", PersonBean.class); + Assert.assertNotNull(query); + + List found = query.find(people); + Assert.assertNotNull(found); + Assert.assertTrue(found.size() == 1); + Assert.assertEquals("Foo", found.get(0).firstName); + } + + @Test + public void testAndQuery() throws QueryException { + QueryContext queryContext = new QueryContextImpl(); + Query query = queryContext.createQuery( + "person.id!=200;(person.city='San.*')", PersonBean.class); + Assert.assertNotNull(query); + + List found = query.find(people); + Assert.assertNotNull(found); + Assert.assertTrue(found.size() == 2); + Assert.assertEquals("John", found.get(0).firstName); + Assert.assertEquals("A", found.get(1).firstName); + } + + @Test + public void testOrQuery() throws QueryException { + QueryContext queryContext = new QueryContextImpl(); + Query query = queryContext.createQuery( + "person.id==200,(person.city='San.*')", PersonBean.class); + Assert.assertNotNull(query); + + List found = query.find(people); + Assert.assertNotNull(found); + Assert.assertTrue(found.size() == 3); + Assert.assertEquals("John", found.get(0).firstName); + Assert.assertEquals("Foo", found.get(1).firstName); + Assert.assertEquals("A", found.get(2).firstName); + } + + @Test + public void testXmlElementWrapper() throws QueryException { + List emails = new ArrayList(); + emails.add("john@cisco.com"); + emails.add("john@gmail.com"); + people.get(0).setEmail(emails); + + p(toXml(people.get(0))); + QueryContext queryContext = new QueryContextImpl(); + Query query = queryContext.createQuery( + "person.emails.email==john@cisco.com", PersonBean.class); + Assert.assertNotNull(query); + + List found = query.find(people); + Assert.assertNotNull(found); + Assert.assertEquals(1,found.size()); + Assert.assertEquals("John", found.get(0).firstName); + } + + @Test + public void testXmlWrapperOfWrapper() throws QueryException{ + WrapperList wrapper = new WrapperList(); + wrapper.item.add("Test1"); + wrapper.item.add("Test2"); + + books.get(0).addWrapperList(wrapper); + books.get(1).addWrapperList(wrapper); + + System.out.println(toXml(books.get(0))); + QueryContext queryContext = new QueryContextImpl(); + Query query = queryContext.createQuery( + "book.parent.child.items.item==Test1", BookBean.class); + Assert.assertNotNull(query); + } + + @Test + public void testXmlElementWrapperListofList() throws QueryException { + // create Stringlist + List testList = new ArrayList(); + testList.add("A"); + testList.add("B"); + StringList itemList = new StringList(testList); + books.get(0).addToTestList(itemList); + + System.out.println(toXml(books.get(0))); + QueryContext queryContext = new QueryContextImpl(); + Query query = queryContext.createQuery( + "book.test.testList.item==A", BookBean.class); + Assert.assertNotNull(query); + } + + @Test + public void testPrimitiveIteratableTypes() throws QueryException { + // Load data for this test + List sellers = new ArrayList(); + sellers.add("Amazon"); + + books.get(0).setSellerInfo(sellers); + sellers.add("Barners & Nobles"); + books.get(1).setSellerInfo(sellers); + sellers.add("Borders"); + sellers.remove("Amazon"); + sellers.add("BookShop"); + books.get(2).setSellerInfo(sellers); + + System.out.println(toXml(books.get(0))); + + QueryContext queryContext = new QueryContextImpl(); + Query query = queryContext.createQuery( + "book.soldBy==Amazon", BookBean.class); + Assert.assertNotNull(query); + + List found = query.find(books); + Assert.assertNotNull(found); + Assert.assertEquals(2,found.size()); + Assert.assertEquals("John", found.get(0).getauthor().firstName); + + query = queryContext.createQuery( + "book.soldBy!=Amazon", BookBean.class); + Assert.assertNotNull(query); + + found = query.find(books); + System.out.println("books" +found); + Assert.assertNotNull(found); + Assert.assertEquals(1,found.size()); + Assert.assertEquals("A", found.get(0).getauthor().firstName); + } + + @Test + public void testCompositeIteratableTypes() throws QueryException { + QueryContext queryContext = new QueryContextImpl(); + Query query = queryContext.createQuery("book.reviews.review.reviewer.firstName==X", + BookBean.class); + Assert.assertNotNull(query); + + List found = query.find(books); + Assert.assertNotNull(found); + Assert.assertEquals(2, found.size()); + Assert.assertEquals("John", found.get(0).getauthor().firstName); + + query = queryContext.createQuery("book.reviews.review.comment==kewl", + BookBean.class); + Assert.assertNotNull(query); + + found = query.find(books); + Assert.assertNotNull(found); + Assert.assertEquals(2, found.size()); + p("Book 0" + found.get(0)); + Assert.assertEquals("John", found.get(0).getauthor().firstName); + + query = queryContext.createQuery("book.reviews.review.reviewer.id>300", + BookBean.class); + Assert.assertNotNull(query); + + found = query.find(books); + Assert.assertNotNull(found); + Assert.assertEquals(2, found.size()); + p("Book 0" + found.get(0)); + Assert.assertEquals("John", found.get(0).getauthor().firstName); + + query = queryContext.createQuery("book.reviews.review.reviewer.firstName!=X", + BookBean.class); + Assert.assertNotNull(query); + + found = query.find(books); + Assert.assertNotNull(found); + Assert.assertEquals(1, found.size()); + p("Book 0" + found.get(0)); + Assert.assertEquals("Foo", found.get(0).getauthor().firstName); + } + + @Test + public void testXMLAccessorType() { + //Assert.fail("implement"); + } + + @Test + public void testMethodAnnotation() throws QueryException { + System.out.println(toXml(books.get(0))); + QueryContext queryContext = new QueryContextImpl(); + Query query = queryContext.createQuery( + "book.isbn==preA003", BookBean.class); + Assert.assertNotNull(query); + + List found = query.find(books); + Assert.assertNotNull(found); + Assert.assertEquals(1,found.size()); + Assert.assertEquals("A", found.get(0).getauthor().firstName); + } + + public static String toXml(Object element) { + try { + JAXBContext jc = JAXBContext.newInstance(element.getClass()); + Marshaller marshaller = jc.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + marshaller.marshal(element, baos); + return baos.toString(); + } catch (Exception e) { + e.printStackTrace(); + } + return ""; + } + + @Test + public void testXMLElementWrapperForCompositeTypes(){ + //Assert.fail("implement"); + } + +} \ No newline at end of file diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/ReviewBean.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/ReviewBean.java new file mode 100644 index 0000000000..ea2f873ff6 --- /dev/null +++ b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/ReviewBean.java @@ -0,0 +1,41 @@ +package org.opendaylight.controller.northbound.commons.query; + +import java.util.Date; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + */ +@XmlRootElement(name="review") +public class ReviewBean { + @XmlElement(name="date") + private Date _publishedDate; + @XmlElement(name="comment") + private String _comment; + @XmlElement(name="reviewer") + private PersonBean _reviewer; + @XmlElement + private int _upVotes; + @XmlElement + private int _downVotes; + public ReviewBean(){} + + public ReviewBean(String comment, PersonBean user) { + _comment = comment; + _reviewer = user; + _publishedDate = new Date(); + } + + public void vote(int up, int down) { + _upVotes += up; + _downVotes += down; + } + + @Override + public String toString() { + return "ReviewBean " + _publishedDate + " " + + _comment + " " + _reviewer + " " + _upVotes + + " " + _downVotes + ""; + } +} diff --git a/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/XMLAccessorTypeTest.java b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/XMLAccessorTypeTest.java new file mode 100644 index 0000000000..25cb69214e --- /dev/null +++ b/opendaylight/northbound/commons/src/test/java/org/opendaylight/controller/northbound/commons/query/XMLAccessorTypeTest.java @@ -0,0 +1,374 @@ +package org.opendaylight.controller.northbound.commons.query; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +import org.junit.Assert; +import org.junit.Test; + +public class XMLAccessorTypeTest { + + @Test + public void testPublicAccessType() throws Exception { + // create bean + List testList = new ArrayList(); + testList.add(new PublicAccessBean("John", "Scott", "private", 1, + "transient", "elem1")); + testList.add(new PublicAccessBean("Foo", "Bar", "private1", 2, + "transient1", "elem2")); + QueryContextTest.p(QueryContextTest.toXml(testList.get(0))); + + QueryContext queryContext = new QueryContextImpl(); + Assert.assertNotNull(queryContext); + // search for public field + Query query = queryContext.createQuery( + "publicbean.firstName==Foo", PublicAccessBean.class); + Assert.assertNotNull(query); + + List found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(1, found.size()); + Assert.assertEquals("Foo", found.get(0).firstName); + + // search for public getter + query = queryContext.createQuery("publicbean.privateGetterField<2", + PublicAccessBean.class); + Assert.assertNotNull(query); + + found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(1, found.size()); + Assert.assertEquals("John", found.get(0).firstName); + + // test for transient field + query = queryContext.createQuery("publicbean.transientField='trans*'", + PublicAccessBean.class); + Assert.assertNotNull(query); + + found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(0, found.size()); + + // test for private field + query = queryContext.createQuery("publicbean.privateField==private", + PublicAccessBean.class); + Assert.assertNotNull(query); + + found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(0, found.size()); + + // test for XML Element + query = queryContext.createQuery("publicbean.element==elem1", + PublicAccessBean.class); + Assert.assertNotNull(query); + + found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(1, found.size()); + Assert.assertEquals("John", found.get(0).firstName); + } + + @Test + public void testFieldAccessType() throws QueryException { + // create bean + List testList = new ArrayList(); + testList.add(new FieldAccessBean("John", "Scott", "private", 1, "elem1")); + testList.add(new FieldAccessBean("Foo", "Bar", "private1", 2, "elem2")); + + QueryContextTest.p(QueryContextTest.toXml(testList.get(0))); + QueryContext queryContext = new QueryContextImpl(); + Assert.assertNotNull(queryContext); + // test private field + Query query = queryContext.createQuery( + "field.privateField==private", FieldAccessBean.class); + Assert.assertNotNull(query); + + List found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(1, found.size()); + Assert.assertEquals("John", found.get(0).firstName); + + // test public field + query = queryContext.createQuery("field.firstName==Foo", + FieldAccessBean.class); + Assert.assertNotNull(query); + + found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(1, found.size()); + Assert.assertEquals("Foo", found.get(0).firstName); + + // test annotated field + query = queryContext.createQuery("field.element==elem2", + FieldAccessBean.class); + Assert.assertNotNull(query); + + found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(1, found.size()); + Assert.assertEquals("Foo", found.get(0).firstName); + + // test annotated method + query = queryContext.createQuery("field.privateGetterField==11", + FieldAccessBean.class); + Assert.assertNotNull(query); + + found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(1, found.size()); + Assert.assertEquals("John", found.get(0).firstName); + } + + @Test + public void testPropertyAccessType() throws QueryException { + // create bean + List testList = new ArrayList(); + testList.add(new PropertyAccessBean("John", "Scott", "private", 1, "elem1", + "transient1")); + testList.add(new PropertyAccessBean("Foo", "Bar", "private1", 2, "elem2", + "transient2")); + + QueryContextTest.p(QueryContextTest.toXml(testList.get(0))); + QueryContext queryContext = new QueryContextImpl(); + Assert.assertNotNull(queryContext); + // test public getter public field + Query query = queryContext.createQuery( + "property.firstName==John", PropertyAccessBean.class); + Assert.assertNotNull(query); + + List found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(1, found.size()); + Assert.assertEquals("John", found.get(0).firstName); + + // test public field no getter + query = queryContext.createQuery("property.lastName==Bar", + PropertyAccessBean.class); + Assert.assertNotNull(query); + + found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(0, found.size()); + + // test annotated field + query = queryContext.createQuery("property.element==elem2", + PropertyAccessBean.class); + Assert.assertNotNull(query); + + found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(1, found.size()); + Assert.assertEquals("Foo", found.get(0).firstName); + + // test annotated method + query = queryContext.createQuery("property.field==private", + PropertyAccessBean.class); + Assert.assertNotNull(query); + + found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(1, found.size()); + Assert.assertEquals("John", found.get(0).firstName); + + // test transient method + query = queryContext.createQuery("property.transientField==transient1", + PropertyAccessBean.class); + Assert.assertNotNull(query); + + found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(0, found.size()); + } + + @Test + public void testNoneAccessType() throws QueryException { + // create bean + List testList = new ArrayList(); + testList.add(new NoneAccessBean("John", "Scott", "private")); + testList.add(new NoneAccessBean("Foo", "Bar", "private1")); + + QueryContextTest.p(QueryContextTest.toXml(testList.get(0))); + QueryContext queryContext = new QueryContextImpl(); + Assert.assertNotNull(queryContext); + // test annotated field + Query query = queryContext.createQuery( + "test.firstName==John", NoneAccessBean.class); + Assert.assertNotNull(query); + + List found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(1, found.size()); + Assert.assertEquals("John", found.get(0).getFirstName()); + // test unannotated field + query = queryContext + .createQuery("test.lastName==Bar", NoneAccessBean.class); + Assert.assertNotNull(query); + + found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(0, found.size()); + // test annotated method + query = queryContext.createQuery("test.testField==private", + NoneAccessBean.class); + Assert.assertNotNull(query); + + found = query.find(testList); + Assert.assertNotNull(found); + Assert.assertEquals(1, found.size()); + Assert.assertEquals("John", found.get(0).getFirstName()); + + } + +} + +// default ( public memeber ) +@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) +@XmlRootElement(name = "publicbean") +class PublicAccessBean { + + public String firstName; + public String lastName; + private String privateField; + private int privateGetterField; + @XmlTransient + public String transientField; + @XmlElement(name = "element") + private String xmlElem; + + public PublicAccessBean() { + } + + public PublicAccessBean(String firstName, String lastName, + String privateField, int privateGetterField, String transientField, + String xmlElem) { + this.firstName = firstName; + this.lastName = lastName; + this.privateField = privateField; + this.privateGetterField = privateGetterField; + this.transientField = transientField; + this.xmlElem = xmlElem; + } + + public int getPrivateGetterField() { + return privateGetterField; + } + + public void setPrivateGetterField(int field) { + this.privateGetterField = field; + } +} + +// default ( public memeber ) +@XmlAccessorType(XmlAccessType.FIELD) +@XmlRootElement(name = "field") +class FieldAccessBean { + + public String firstName; + public String lastName; + private String privateField; + private int test; + @XmlElement(name = "element") + private String xmlElem; + + public FieldAccessBean() { + } + + public FieldAccessBean(String firstName, String lastName, + String privateField, int privateGetterField, String xmlElem) { + this.firstName = firstName; + this.lastName = lastName; + this.privateField = privateField; + this.xmlElem = xmlElem; + this.test = privateGetterField; + } + + public String getPrivateField() { + return privateField; + } + + @XmlElement(name = "privateGetterField") + public int getPrivateGetterField() { + return test + 10; + } +} + +// default ( public memeber ) +@XmlAccessorType(XmlAccessType.PROPERTY) +@XmlRootElement(name = "property") +class PropertyAccessBean { + + public String firstName; + public String lastName; + private String privateField; + private int privateGetterField; + @XmlElement(name = "element") + private String xmlElem; + private String transientField; + + public PropertyAccessBean() { + } + + public PropertyAccessBean(String firstName, String lastName, + String privateField, int privateGetterField, String xmlElem, + String transientField) { + this.firstName = firstName; + this.lastName = lastName; + this.privateField = privateField; + this.privateGetterField = privateGetterField; + this.xmlElem = xmlElem; + this.transientField = transientField; + } + + public int getPrivateGetterField() { + return privateGetterField; + } + + @XmlElement(name = "field") + public String getPrivateField() { + return privateField; + } + + public String getFirstName() { + return firstName; + } + + @XmlTransient + public String getTransientField() { + return transientField; + } +} + +// default ( public memeber ) +@XmlAccessorType(XmlAccessType.NONE) +@XmlRootElement(name = "test") +class NoneAccessBean { + @XmlElement + private String firstName; + public String lastName; + private String testField; + + public NoneAccessBean() { + } + + public NoneAccessBean(String firstName, String lastName, String testField) { + this.firstName = firstName; + this.lastName = lastName; + this.testField = testField; + } + + @XmlElement(name = "testField") + public String getTestField() { + return testField; + } + + public String getFirstName() { + return firstName; + } +} diff --git a/opendaylight/northbound/commons/src/test/resources/logback.xml b/opendaylight/northbound/commons/src/test/resources/logback.xml new file mode 100644 index 0000000000..97e15deb94 --- /dev/null +++ b/opendaylight/northbound/commons/src/test/resources/logback.xml @@ -0,0 +1,16 @@ + + + + + %d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n + + + + + + + + + + + diff --git a/opendaylight/northbound/connectionmanager/pom.xml b/opendaylight/northbound/connectionmanager/pom.xml index a0940e3428..ad315ac008 100644 --- a/opendaylight/northbound/connectionmanager/pom.xml +++ b/opendaylight/northbound/connectionmanager/pom.xml @@ -54,11 +54,13 @@ org.opendaylight.controller.northbound.commons, org.opendaylight.controller.northbound.commons.exception, org.opendaylight.controller.northbound.commons.utils, + org.opendaylight.controller.northbound.commons.query, org.opendaylight.controller.sal.authorization, org.opendaylight.controller.connectionmanager, org.opendaylight.controller.sal.connection, org.slf4j, javax.ws.rs, + javax.ws.rs.ext, javax.ws.rs.core, javax.xml.bind.annotation, javax.xml.bind, diff --git a/opendaylight/northbound/connectionmanager/src/main/java/org/opendaylight/controller/connectionmanager/northbound/ConnectionManagerNorthbound.java b/opendaylight/northbound/connectionmanager/src/main/java/org/opendaylight/controller/connectionmanager/northbound/ConnectionManagerNorthbound.java index e2c1b32c4b..dde3210928 100644 --- a/opendaylight/northbound/connectionmanager/src/main/java/org/opendaylight/controller/connectionmanager/northbound/ConnectionManagerNorthbound.java +++ b/opendaylight/northbound/connectionmanager/src/main/java/org/opendaylight/controller/connectionmanager/northbound/ConnectionManagerNorthbound.java @@ -27,6 +27,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; +import javax.ws.rs.ext.ContextResolver; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; @@ -36,6 +37,7 @@ import org.opendaylight.controller.northbound.commons.exception.NotAcceptableExc import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException; import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException; +import org.opendaylight.controller.northbound.commons.query.QueryContext; import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils; import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.connection.ConnectionConstants; @@ -50,7 +52,14 @@ import org.opendaylight.controller.sal.utils.Status; @Path("/") public class ConnectionManagerNorthbound { private String username; + private QueryContext queryContext; + @Context + public void setQueryContext(ContextResolver queryCtxResolver) { + if (queryCtxResolver != null) { + queryContext = queryCtxResolver.getContext(QueryContext.class); + } + } @Context public void setSecurityContext(SecurityContext context) { if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName(); @@ -115,7 +124,8 @@ public class ConnectionManagerNorthbound { @ResponseCode(code = 406, condition = "Invalid Controller IP Address passed."), @ResponseCode(code = 503, condition = "Connection Manager Service not available")}) - public Nodes getNodes(@DefaultValue("") @QueryParam("controller") String controllerAddress) { + public Nodes getNodes(@DefaultValue("") @QueryParam("controller") String controllerAddress, + @QueryParam("_q") String queryString) { if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.READ, this)) { throw new UnauthorizedException("User is not authorized to perform this operation on container"); } @@ -140,7 +150,12 @@ public class ConnectionManagerNorthbound { } else { nodeSet = connectionManager.getLocalNodes(); } - return new Nodes(nodeSet); + Nodes nodes = new Nodes(nodeSet); + if (queryString != null) { + queryContext.createQuery(queryString, Nodes.class) + .filter(nodes, Node.class); + } + return nodes; } /** diff --git a/opendaylight/northbound/containermanager/pom.xml b/opendaylight/northbound/containermanager/pom.xml index 457b1bd6a4..2e6bb7d40c 100644 --- a/opendaylight/northbound/containermanager/pom.xml +++ b/opendaylight/northbound/containermanager/pom.xml @@ -56,8 +56,10 @@ org.opendaylight.controller.northbound.commons, org.opendaylight.controller.northbound.commons.exception, org.opendaylight.controller.northbound.commons.utils, + org.opendaylight.controller.northbound.commons.query, com.sun.jersey.spi.container.servlet, javax.ws.rs, + javax.ws.rs.ext, javax.ws.rs.core, javax.xml.bind.annotation, javax.xml.bind, diff --git a/opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthbound.java b/opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthbound.java index fe38361cca..754167814d 100644 --- a/opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthbound.java +++ b/opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthbound.java @@ -21,11 +21,13 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.UriInfo; +import javax.ws.rs.ext.ContextResolver; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; @@ -41,6 +43,7 @@ import org.opendaylight.controller.northbound.commons.exception.ResourceConflict import org.opendaylight.controller.northbound.commons.exception.ResourceForbiddenException; import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException; +import org.opendaylight.controller.northbound.commons.query.QueryContext; import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils; import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.authorization.UserLevel; @@ -68,6 +71,14 @@ import org.opendaylight.controller.usermanager.IUserManager; @Path("/") public class ContainerManagerNorthbound { private String username; + private QueryContext queryContext; + + @Context + public void setQueryContext(ContextResolver queryCtxResolver) { + if (queryCtxResolver != null) { + queryContext = queryCtxResolver.getContext(QueryContext.class); + } + } @Context public void setSecurityContext(SecurityContext context) { @@ -172,13 +183,18 @@ public class ContainerManagerNorthbound { @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"), @ResponseCode(code = 401, condition = "User is not authorized to perform this operation"), @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) - public ContainerConfigs viewAllContainers() { + public ContainerConfigs viewAllContainers(@QueryParam("_q") String queryString) { handleNetworkAuthorization(getUserName()); IContainerManager containerManager = getContainerManager(); - - return new ContainerConfigs(containerManager.getContainerConfigList()); + ContainerConfigs result = new ContainerConfigs( + containerManager.getContainerConfigList()); + if (queryString != null) { + queryContext.createQuery(queryString, ContainerConfigs.class) + .filter(result, ContainerConfig.class); + } + return result; } /** @@ -481,7 +497,8 @@ public class ContainerManagerNorthbound { @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"), @ResponseCode(code = 404, condition = "The container is not found"), @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) - public FlowSpecConfigs viewContainerFlowSpecs(@PathParam(value = "container") String container) { + public FlowSpecConfigs viewContainerFlowSpecs(@PathParam(value = "container") String container, + @QueryParam("_q") String queryString) { handleContainerAuthorization(container, getUserName()); handleForbiddenOnDefault(container); @@ -489,8 +506,13 @@ public class ContainerManagerNorthbound { handleContainerNotExists(container); IContainerManager containerManager = getContainerManager(); - - return new FlowSpecConfigs(containerManager.getContainerFlows(container)); + FlowSpecConfigs result = new FlowSpecConfigs( + containerManager.getContainerFlows(container)); + if (queryString != null) { + queryContext.createQuery(queryString, FlowSpecConfigs.class) + .filter(result, ContainerFlowConfig.class); + } + return result; } /** diff --git a/opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthboundRSApplication.java b/opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthboundRSApplication.java index b9d2200180..db3d543a69 100644 --- a/opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthboundRSApplication.java +++ b/opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthboundRSApplication.java @@ -11,8 +11,11 @@ package org.opendaylight.controller.containermanager.northbound; import java.util.HashSet; import java.util.Set; + import javax.ws.rs.core.Application; +import org.opendaylight.controller.northbound.commons.query.QueryContextProvider; + import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; /** @@ -28,6 +31,7 @@ public class ContainerManagerNorthboundRSApplication extends Application { Set> classes = new HashSet>(); classes.add(ContainerManagerNorthbound.class); classes.add(JacksonJaxbJsonProvider.class); + classes.add(QueryContextProvider.class); return classes; } } diff --git a/opendaylight/northbound/controllermanager/pom.xml b/opendaylight/northbound/controllermanager/pom.xml index 07d34cb6d4..89d2b99cad 100644 --- a/opendaylight/northbound/controllermanager/pom.xml +++ b/opendaylight/northbound/controllermanager/pom.xml @@ -67,8 +67,10 @@ org.opendaylight.controller.northbound.commons, org.opendaylight.controller.northbound.commons.exception, org.opendaylight.controller.northbound.commons.utils, + org.opendaylight.controller.northbound.commons.query, org.opendaylight.controller.sal.authorization, javax.ws.rs, + javax.ws.rs.ext, javax.ws.rs.core, javax.xml.bind.annotation, javax.xml.bind, diff --git a/opendaylight/northbound/controllermanager/src/main/java/org/opendaylight/controller/controllermanager/northbound/ControllerManagerNorthbound.java b/opendaylight/northbound/controllermanager/src/main/java/org/opendaylight/controller/controllermanager/northbound/ControllerManagerNorthbound.java index 003f8b3b95..aaf93d1f4b 100644 --- a/opendaylight/northbound/controllermanager/src/main/java/org/opendaylight/controller/controllermanager/northbound/ControllerManagerNorthbound.java +++ b/opendaylight/northbound/controllermanager/src/main/java/org/opendaylight/controller/controllermanager/northbound/ControllerManagerNorthbound.java @@ -25,6 +25,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.UriInfo; +import javax.ws.rs.ext.ContextResolver; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; @@ -36,6 +37,7 @@ import org.opendaylight.controller.northbound.commons.exception.BadRequestExcept import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException; import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException; +import org.opendaylight.controller.northbound.commons.query.QueryContext; import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils; import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.core.Property; @@ -55,6 +57,14 @@ import org.opendaylight.controller.switchmanager.ISwitchManager; public class ControllerManagerNorthbound { private String username; + private QueryContext queryContext; + + @Context + public void setQueryContext(ContextResolver queryCtxResolver) { + if (queryCtxResolver != null) { + queryContext = queryCtxResolver.getContext(QueryContext.class); + } + } @Context public void setSecurityContext(SecurityContext context) { @@ -122,7 +132,8 @@ public class ControllerManagerNorthbound { @ResponseCode(code = 404, condition = "The containerName or property is not found"), @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) public ControllerProperties getControllerProperties(@PathParam("containerName") String containerName, - @QueryParam("propertyName") String propertyName) { + @QueryParam("propertyName") String propertyName, + @QueryParam("_q") String queryString) { if (!isValidContainer(containerName)) { throw new ResourceNotFoundException("Container " + containerName + " does not exist."); @@ -147,8 +158,12 @@ public class ControllerManagerNorthbound { throw new ResourceNotFoundException("Unable to find property with name: " + propertyName); } properties.add(property); - - return new ControllerProperties(properties); + ControllerProperties result = new ControllerProperties(properties); + if (queryString != null) { + queryContext.createQuery(queryString, ControllerProperties.class) + .filter(result, Property.class); + } + return result; } diff --git a/opendaylight/northbound/flowprogrammer/pom.xml b/opendaylight/northbound/flowprogrammer/pom.xml index 205b68a91c..43797f5c65 100644 --- a/opendaylight/northbound/flowprogrammer/pom.xml +++ b/opendaylight/northbound/flowprogrammer/pom.xml @@ -57,11 +57,13 @@ org.opendaylight.controller.northbound.commons, org.opendaylight.controller.northbound.commons.exception, org.opendaylight.controller.northbound.commons.utils, + org.opendaylight.controller.northbound.commons.query, org.opendaylight.controller.sal.authorization, org.opendaylight.controller.usermanager, com.sun.jersey.spi.container.servlet, org.apache.catalina.filters, javax.ws.rs, + javax.ws.rs.ext, javax.ws.rs.core, javax.xml.bind.annotation, javax.xml.bind, diff --git a/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java b/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java index 4928ddef3b..42bd59ea45 100644 --- a/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java +++ b/opendaylight/northbound/flowprogrammer/src/main/java/org/opendaylight/controller/flowprogrammer/northbound/FlowProgrammerNorthbound.java @@ -19,10 +19,12 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; +import javax.ws.rs.ext.ContextResolver; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; @@ -37,6 +39,7 @@ import org.opendaylight.controller.northbound.commons.exception.NotAcceptableExc import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException; import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException; +import org.opendaylight.controller.northbound.commons.query.QueryContext; import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils; import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.core.Node; @@ -62,6 +65,14 @@ public class FlowProgrammerNorthbound { private String username; + private QueryContext queryContext; + @Context + public void setQueryContext(ContextResolver queryCtxResolver) { + if (queryCtxResolver != null) { + queryContext = queryCtxResolver.getContext(QueryContext.class); + } + } + @Context public void setSecurityContext(SecurityContext context) { if (context != null && context.getUserPrincipal() != null) { @@ -194,15 +205,21 @@ public class FlowProgrammerNorthbound { @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"), @ResponseCode(code = 401, condition = "User not authorized to perform this operation"), @ResponseCode(code = 404, condition = "The containerName is not found"), - @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) - public FlowConfigs getStaticFlows(@PathParam("containerName") String containerName) { + @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable"), + @ResponseCode(code = 400, condition = "Incorrect query syntex")}) + public FlowConfigs getStaticFlows(@PathParam("containerName") String containerName, + @QueryParam("_q") String queryString) { if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) { throw new UnauthorizedException("User is not authorized to perform this operation on container " + containerName); } - List flowConfigs = getStaticFlowsInternal(containerName, null); - return new FlowConfigs(flowConfigs); + FlowConfigs result = new FlowConfigs(getStaticFlowsInternal(containerName, null)); + if (queryString != null) { + queryContext.createQuery(queryString, FlowConfigs.class) + .filter(result, FlowConfig.class); + } + return result; } /** @@ -272,7 +289,8 @@ public class FlowProgrammerNorthbound { @ResponseCode(code = 404, condition = "The containerName or nodeId is not found"), @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) public FlowConfigs getStaticFlows(@PathParam("containerName") String containerName, - @PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId) { + @PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId, + @QueryParam("_q") String queryString) { if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) { throw new UnauthorizedException("User is not authorized to perform this operation on container " + containerName); @@ -281,8 +299,12 @@ public class FlowProgrammerNorthbound { if (node == null) { throw new ResourceNotFoundException(nodeId + " : " + RestMessages.NONODE.toString()); } - List flows = getStaticFlowsInternal(containerName, node); - return new FlowConfigs(flows); + FlowConfigs flows = new FlowConfigs(getStaticFlowsInternal(containerName, node)); + if (queryString != null) { + queryContext.createQuery(queryString, FlowConfigs.class) + .filter(flows, FlowConfig.class); + } + return flows; } /** diff --git a/opendaylight/northbound/hosttracker/pom.xml b/opendaylight/northbound/hosttracker/pom.xml index bf1b082cfe..c8415f8b4f 100644 --- a/opendaylight/northbound/hosttracker/pom.xml +++ b/opendaylight/northbound/hosttracker/pom.xml @@ -60,11 +60,13 @@ com.sun.jersey.spi.container.servlet, org.opendaylight.controller.northbound.commons, org.opendaylight.controller.northbound.commons.exception, + org.opendaylight.controller.northbound.commons.query, org.opendaylight.controller.northbound.commons.utils, org.opendaylight.controller.sal.authorization, org.opendaylight.controller.sal.packet.address, javax.ws.rs, javax.ws.rs.core, + javax.ws.rs.ext, javax.xml.bind.annotation, javax.xml.bind, org.slf4j, diff --git a/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java b/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java index 74c13d11f1..d7579c82e1 100644 --- a/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java +++ b/opendaylight/northbound/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/northbound/HostTrackerNorthbound.java @@ -21,11 +21,13 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.UriInfo; +import javax.ws.rs.ext.ContextResolver; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; @@ -39,6 +41,7 @@ import org.opendaylight.controller.northbound.commons.exception.ResourceConflict import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException; import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException; +import org.opendaylight.controller.northbound.commons.query.QueryContext; import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils; import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.core.Node; @@ -69,6 +72,14 @@ import org.opendaylight.controller.switchmanager.ISwitchManager; public class HostTrackerNorthbound { private String username; + private QueryContext queryContext; + + @Context + public void setQueryContext(ContextResolver queryCtxResolver) { + if (queryCtxResolver != null) { + queryContext = queryCtxResolver.getContext(QueryContext.class); + } + } @Context public void setSecurityContext(SecurityContext context) { @@ -107,7 +118,7 @@ public class HostTrackerNorthbound { return hostTracker; } - private Hosts convertHosts(Set hostNodeConnectors) { + private Set convertHosts(Set hostNodeConnectors) { if(hostNodeConnectors == null) { return null; } @@ -115,7 +126,7 @@ public class HostTrackerNorthbound { for(HostNodeConnector hnc : hostNodeConnectors) { hosts.add(HostConfig.convert(hnc)); } - return new Hosts(hosts); + return hosts; } /** @@ -194,14 +205,20 @@ public class HostTrackerNorthbound { @ResponseCode(code = 200, condition = "Operation successful"), @ResponseCode(code = 404, condition = "The containerName is not found"), @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) - public Hosts getActiveHosts(@PathParam("containerName") String containerName) { + public Hosts getActiveHosts(@PathParam("containerName") String containerName, + @QueryParam("_q") String queryString) { if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) { throw new UnauthorizedException("User is not authorized to perform this operation on container " + containerName); } IfIptoHost hostTracker = getIfIpToHostService(containerName); - return convertHosts(hostTracker.getAllHosts()); + Hosts hosts = new Hosts(convertHosts(hostTracker.getAllHosts())); + if (queryString != null) { + queryContext.createQuery(queryString, Hosts.class) + .filter(hosts, HostConfig.class); + } + return hosts; } /** @@ -281,13 +298,19 @@ public class HostTrackerNorthbound { @ResponseCode(code = 404, condition = "The containerName is not found"), @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) public Hosts getInactiveHosts( - @PathParam("containerName") String containerName) { + @PathParam("containerName") String containerName, + @QueryParam("_q") String queryString) { if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) { throw new UnauthorizedException("User is not authorized to perform this operation on container " + containerName); } IfIptoHost hostTracker = getIfIpToHostService(containerName); - return convertHosts(hostTracker.getInactiveStaticHosts()); + Hosts hosts = new Hosts(convertHosts(hostTracker.getInactiveStaticHosts())); + if (queryString != null) { + queryContext.createQuery(queryString, Hosts.class) + .filter(hosts, HostConfig.class); + } + return hosts; } /** diff --git a/opendaylight/northbound/staticrouting/pom.xml b/opendaylight/northbound/staticrouting/pom.xml index dd2a2e6223..83f8191e02 100644 --- a/opendaylight/northbound/staticrouting/pom.xml +++ b/opendaylight/northbound/staticrouting/pom.xml @@ -55,9 +55,11 @@ org.opendaylight.controller.northbound.commons, org.opendaylight.controller.northbound.commons.exception, org.opendaylight.controller.northbound.commons.utils, + org.opendaylight.controller.northbound.commons.query, org.opendaylight.controller.sal.authorization, org.slf4j, javax.ws.rs, + javax.ws.rs.ext, javax.ws.rs.core, javax.xml.bind.annotation, javax.xml.bind, diff --git a/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java b/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java index e765af524d..20f6cb40a5 100644 --- a/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java +++ b/opendaylight/northbound/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/northbound/StaticRoutingNorthbound.java @@ -19,11 +19,13 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.UriInfo; +import javax.ws.rs.ext.ContextResolver; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; @@ -37,6 +39,7 @@ import org.opendaylight.controller.northbound.commons.exception.NotAcceptableExc import org.opendaylight.controller.northbound.commons.exception.ResourceConflictException; import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException; +import org.opendaylight.controller.northbound.commons.query.QueryContext; import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils; import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.utils.GlobalConstants; @@ -74,6 +77,14 @@ import org.opendaylight.controller.sal.utils.Status; public class StaticRoutingNorthbound { private String username; + private QueryContext queryContext; + + @Context + public void setQueryContext(ContextResolver queryCtxResolver) { + if (queryCtxResolver != null) { + queryContext = queryCtxResolver.getContext(QueryContext.class); + } + } @Context public void setSecurityContext(SecurityContext context) { @@ -148,7 +159,8 @@ public class StaticRoutingNorthbound { @ResponseCode(code = 200, condition = "Operation successful"), @ResponseCode(code = 404, condition = "The containerName passed was not found") }) public StaticRoutes getStaticRoutes( - @PathParam("containerName") String containerName) { + @PathParam("containerName") String containerName, + @QueryParam("_q") String queryString) { if(!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.WRITE, this)){ @@ -156,7 +168,12 @@ public class StaticRoutingNorthbound { UnauthorizedException("User is not authorized to perform this operation on container " + containerName); } - return new StaticRoutes(getStaticRoutesInternal(containerName)); + StaticRoutes result = new StaticRoutes(getStaticRoutesInternal(containerName)); + if (queryString != null) { + queryContext.createQuery(queryString, StaticRoutes.class) + .filter(result, StaticRoute.class); + } + return result; } /** diff --git a/opendaylight/northbound/statistics/pom.xml b/opendaylight/northbound/statistics/pom.xml index 76ce062424..7e2919bc44 100644 --- a/opendaylight/northbound/statistics/pom.xml +++ b/opendaylight/northbound/statistics/pom.xml @@ -64,7 +64,9 @@ org.opendaylight.controller.northbound.commons, org.opendaylight.controller.northbound.commons.exception, org.opendaylight.controller.northbound.commons.utils, + org.opendaylight.controller.northbound.commons.query, javax.ws.rs, + javax.ws.rs.ext, javax.ws.rs.core, javax.xml.bind.annotation, javax.xml.bind, diff --git a/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java b/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java index 5338849a62..4175f1e3c4 100644 --- a/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java +++ b/opendaylight/northbound/statistics/src/main/java/org/opendaylight/controller/statistics/northbound/StatisticsNorthbound.java @@ -15,9 +15,11 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.SecurityContext; +import javax.ws.rs.ext.ContextResolver; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; @@ -29,6 +31,7 @@ import org.opendaylight.controller.northbound.commons.exception.ResourceConflict import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException; import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException; +import org.opendaylight.controller.northbound.commons.query.QueryContext; import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils; import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.core.Node; @@ -57,7 +60,14 @@ import org.opendaylight.controller.switchmanager.ISwitchManager; public class StatisticsNorthbound { private String username; + private QueryContext queryContext; + @Context + public void setQueryContext(ContextResolver queryCtxResolver) { + if (queryCtxResolver != null) { + queryContext = queryCtxResolver.getContext(QueryContext.class); + } + } @Context public void setSecurityContext(SecurityContext context) { if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName(); @@ -234,7 +244,8 @@ public class StatisticsNorthbound { @ResponseCode(code = 404, condition = "The containerName is not found"), @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) public AllFlowStatistics getFlowStatistics( - @PathParam("containerName") String containerName) { + @PathParam("containerName") String containerName, + @QueryParam("_q") String queryString) { if (!NorthboundUtils.isAuthorized( getUserName(), containerName, Privilege.READ, this)) { throw new UnauthorizedException( @@ -265,7 +276,12 @@ public class StatisticsNorthbound { FlowStatistics stat = new FlowStatistics(node, flowStats); statistics.add(stat); } - return new AllFlowStatistics(statistics); + AllFlowStatistics result = new AllFlowStatistics(statistics); + if (queryString != null) { + queryContext.createQuery(queryString, AllFlowStatistics.class) + .filter(result, FlowStatistics.class); + } + return result; } /** @@ -610,7 +626,8 @@ public class StatisticsNorthbound { @ResponseCode(code = 404, condition = "The containerName is not found"), @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) public AllPortStatistics getPortStatistics( - @PathParam("containerName") String containerName) { + @PathParam("containerName") String containerName, + @QueryParam("_q") String queryString) { if (!NorthboundUtils.isAuthorized( getUserName(), containerName, Privilege.READ, this)) { @@ -638,7 +655,13 @@ public class StatisticsNorthbound { PortStatistics portStat = new PortStatistics(node, stat); statistics.add(portStat); } - return new AllPortStatistics(statistics); + + AllPortStatistics result = new AllPortStatistics(statistics); + if (queryString != null) { + queryContext.createQuery(queryString, AllPortStatistics.class) + .filter(result, PortStatistics.class); + } + return result; } /** @@ -924,7 +947,8 @@ public class StatisticsNorthbound { @ResponseCode(code = 404, condition = "The containerName is not found"), @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) public AllTableStatistics getTableStatistics( - @PathParam("containerName") String containerName) { + @PathParam("containerName") String containerName, + @QueryParam("_q") String queryString) { if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) { throw new UnauthorizedException("User is not authorized to perform this operation on container " @@ -952,7 +976,12 @@ public class StatisticsNorthbound { TableStatistics tableStat = new TableStatistics(node, stat); statistics.add(tableStat); } - return new AllTableStatistics(statistics); + AllTableStatistics allstats = new AllTableStatistics(statistics); + if (queryString != null) { + queryContext.createQuery(queryString, AllTableStatistics.class) + .filter(allstats, TableStatistics.class); + } + return allstats; } /** diff --git a/opendaylight/northbound/subnets/pom.xml b/opendaylight/northbound/subnets/pom.xml index 5aa2f7f202..630221fcc2 100644 --- a/opendaylight/northbound/subnets/pom.xml +++ b/opendaylight/northbound/subnets/pom.xml @@ -53,12 +53,14 @@ org.opendaylight.controller.switchmanager, org.opendaylight.controller.northbound.commons, org.opendaylight.controller.northbound.commons.exception, + org.opendaylight.controller.northbound.commons.query, org.opendaylight.controller.northbound.commons.utils, com.sun.jersey.spi.container.servlet, org.opendaylight.controller.sal.authorization, org.opendaylight.controller.usermanager, javax.ws.rs, javax.ws.rs.core, + javax.ws.rs.ext, javax.xml.bind, javax.xml.bind.annotation, org.slf4j, diff --git a/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java b/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java index 3465dc95ad..b6274795df 100644 --- a/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java +++ b/opendaylight/northbound/subnets/src/main/java/org/opendaylight/controller/subnets/northbound/SubnetsNorthbound.java @@ -19,11 +19,13 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.UriInfo; +import javax.ws.rs.ext.ContextResolver; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; @@ -35,6 +37,7 @@ import org.opendaylight.controller.northbound.commons.exception.ResourceConflict import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException; import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException; +import org.opendaylight.controller.northbound.commons.query.QueryContext; import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils; import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.core.NodeConnector; @@ -63,6 +66,14 @@ public class SubnetsNorthbound { protected static final Logger logger = LoggerFactory.getLogger(SubnetsNorthbound.class); private String username; + private QueryContext queryContext; + + @Context + public void setQueryContext(ContextResolver queryCtxResolver) { + if (queryCtxResolver != null) { + queryContext = queryCtxResolver.getContext(QueryContext.class); + } + } @Context public void setSecurityContext(SecurityContext context) { @@ -160,9 +171,11 @@ public class SubnetsNorthbound { @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @StatusCodes({ @ResponseCode(code = 401, condition = "User not authorized to perform this operation"), @ResponseCode(code = 404, condition = "The containerName passed was not found"), - @ResponseCode(code = 503, condition = "Service unavailable") }) + @ResponseCode(code = 503, condition = "Service unavailable"), + @ResponseCode(code = 400, condition = "Incorrect query syntex") }) @TypeHint(SubnetConfigs.class) - public SubnetConfigs listSubnets(@PathParam("containerName") String containerName) { + public SubnetConfigs listSubnets(@PathParam("containerName") String containerName, + @QueryParam("_q") String queryString) { handleContainerDoesNotExist(containerName); if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) { @@ -174,7 +187,13 @@ public class SubnetsNorthbound { if (switchManager == null) { throw new ServiceUnavailableException("SwitchManager " + RestMessages.SERVICEUNAVAILABLE.toString()); } - return new SubnetConfigs(switchManager.getSubnetsConfigList()); + List subnets = switchManager.getSubnetsConfigList(); + if (queryString != null) { + subnets = queryContext.createQuery(queryString, SubnetConfig.class) + .find(subnets); + + } + return new SubnetConfigs(subnets); } /** diff --git a/opendaylight/northbound/switchmanager/pom.xml b/opendaylight/northbound/switchmanager/pom.xml index 590f0bb533..614ec88476 100644 --- a/opendaylight/northbound/switchmanager/pom.xml +++ b/opendaylight/northbound/switchmanager/pom.xml @@ -58,7 +58,9 @@ org.opendaylight.controller.northbound.commons.exception, org.opendaylight.controller.northbound.commons.utils, org.opendaylight.controller.sal.authorization, + org.opendaylight.controller.northbound.commons.query, javax.ws.rs, + javax.ws.rs.ext, javax.ws.rs.core, javax.xml.bind.annotation, javax.xml.bind, diff --git a/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java b/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java index e30dad24ab..dab5d7d1b2 100644 --- a/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java +++ b/opendaylight/northbound/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/northbound/SwitchNorthbound.java @@ -23,11 +23,13 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.UriInfo; +import javax.ws.rs.ext.ContextResolver; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; @@ -38,6 +40,7 @@ import org.opendaylight.controller.northbound.commons.exception.InternalServerEr import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException; import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException; +import org.opendaylight.controller.northbound.commons.query.QueryContext; import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils; import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.core.Node; @@ -60,6 +63,14 @@ import org.opendaylight.controller.switchmanager.SwitchConfig; public class SwitchNorthbound { private String username; + private QueryContext queryContext; + + @Context + public void setQueryContext(ContextResolver queryCtxResolver) { + if (queryCtxResolver != null) { + queryContext = queryCtxResolver.getContext(QueryContext.class); + } + } @Context public void setSecurityContext(SecurityContext context) { @@ -200,8 +211,9 @@ public class SwitchNorthbound { @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"), @ResponseCode(code = 401, condition = "User not authorized to perform this operation"), @ResponseCode(code = 404, condition = "The containerName is not found"), - @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) - public Nodes getNodes(@PathParam("containerName") String containerName) { + @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable"), + @ResponseCode(code = 400, condition = "Incorrect query syntex") }) + public Nodes getNodes(@PathParam("containerName") String containerName, @QueryParam("_q") String queryString) { if (!isValidContainer(containerName)) { throw new ResourceNotFoundException("Container " + containerName + " does not exist."); @@ -233,8 +245,12 @@ public class SwitchNorthbound { NodeProperties nodeProps = new NodeProperties(node, props); res.add(nodeProps); } - - return new Nodes(res); + Nodes result = new Nodes(res); + if (queryString != null) { + queryContext.createQuery(queryString, Nodes.class) + .filter(result, NodeProperties.class); + } + return result; } /** @@ -564,9 +580,11 @@ public class SwitchNorthbound { @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"), @ResponseCode(code = 401, condition = "User not authorized to perform this operation"), @ResponseCode(code = 404, condition = "The containerName is not found"), - @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) + @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable"), + @ResponseCode(code = 400, condition = "Incorrect query syntex") }) public NodeConnectors getNodeConnectors(@PathParam("containerName") String containerName, - @PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId) { + @PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId, + @QueryParam("_q") String queryString) { if (!isValidContainer(containerName)) { throw new ResourceNotFoundException("Container " + containerName + " does not exist."); @@ -598,8 +616,12 @@ public class SwitchNorthbound { NodeConnectorProperties ncProps = new NodeConnectorProperties(nc, props); res.add(ncProps); } - - return new NodeConnectors(res); + NodeConnectors result = new NodeConnectors(res); + if (queryString != null) { + queryContext.createQuery(queryString, NodeConnectors.class) + .filter(result, NodeConnectorProperties.class); + } + return result; } /** diff --git a/opendaylight/northbound/topology/pom.xml b/opendaylight/northbound/topology/pom.xml index 4a1142bb18..3f1a770110 100644 --- a/opendaylight/northbound/topology/pom.xml +++ b/opendaylight/northbound/topology/pom.xml @@ -51,6 +51,7 @@ org.opendaylight.controller.northbound.commons, org.opendaylight.controller.northbound.commons.exception, org.opendaylight.controller.northbound.commons.utils, + org.opendaylight.controller.northbound.commons.query, org.opendaylight.controller.sal.core, org.opendaylight.controller.sal.packet, org.opendaylight.controller.sal.authorization, @@ -62,6 +63,7 @@ com.sun.jersey.spi.container.servlet, com.fasterxml.jackson.annotation, javax.ws.rs, + javax.ws.rs.ext, javax.ws.rs.core, javax.xml.bind, javax.xml.bind.annotation, diff --git a/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java b/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java index 427aa1c1de..3773070504 100644 --- a/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java +++ b/opendaylight/northbound/topology/src/main/java/org/opendaylight/controller/topology/northbound/TopologyNorthboundJAXRS.java @@ -21,10 +21,12 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; +import javax.ws.rs.ext.ContextResolver; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; @@ -33,6 +35,7 @@ import org.opendaylight.controller.northbound.commons.RestMessages; import org.opendaylight.controller.northbound.commons.exception.InternalServerErrorException; import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException; +import org.opendaylight.controller.northbound.commons.query.QueryContext; import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils; import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.core.Edge; @@ -59,7 +62,14 @@ import org.opendaylight.controller.topologymanager.TopologyUserLinkConfig; public class TopologyNorthboundJAXRS { private String username; + private QueryContext queryContext; + @Context + public void setQueryContext(ContextResolver queryCtxResolver) { + if (queryCtxResolver != null) { + queryContext = queryCtxResolver.getContext(QueryContext.class); + } + } @Context public void setSecurityContext(SecurityContext context) { if (context != null && context.getUserPrincipal() != null) { @@ -240,7 +250,8 @@ public class TopologyNorthboundJAXRS { @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(Topology.class) @StatusCodes({ @ResponseCode(code = 404, condition = "The Container Name was not found") }) - public Topology getTopology(@PathParam("containerName") String containerName) { + public Topology getTopology(@PathParam("containerName") String containerName, + @QueryParam("_q") String queryString) { if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) { throw new UnauthorizedException("User is not authorized to perform this operation on container " @@ -253,16 +264,21 @@ public class TopologyNorthboundJAXRS { } Map> topo = topologyManager.getEdges(); - if (topo != null) { - List res = new ArrayList(); - for (Map.Entry> entry : topo.entrySet()) { - EdgeProperties el = new EdgeProperties(entry.getKey(), entry.getValue()); - res.add(el); - } - return new Topology(res); + if (topo == null) { + return null; + } + List res = new ArrayList(); + for (Map.Entry> entry : topo.entrySet()) { + EdgeProperties el = new EdgeProperties(entry.getKey(), entry.getValue()); + res.add(el); } + Topology result = new Topology(res); - return null; + if (queryString != null) { + queryContext.createQuery(queryString, Topology.class) + .filter(result, EdgeProperties.class); + } + return result; } /** @@ -311,7 +327,8 @@ public class TopologyNorthboundJAXRS { @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @TypeHint(TopologyUserLinks.class) @StatusCodes({ @ResponseCode(code = 404, condition = "The Container Name was not found") }) - public TopologyUserLinks getUserLinks(@PathParam("containerName") String containerName) { + public TopologyUserLinks getUserLinks(@PathParam("containerName") String containerName, + @QueryParam("_q") String queryString) { if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) { throw new UnauthorizedException("User is not authorized to perform this operation on container " @@ -324,12 +341,16 @@ public class TopologyNorthboundJAXRS { } ConcurrentMap userLinks = topologyManager.getUserLinks(); - if ((userLinks != null) && (userLinks.values() != null)) { - List res = new ArrayList(userLinks.values()); - return new TopologyUserLinks(res); + if ((userLinks == null) || (userLinks.values() == null)) { + return null; } - - return null; + TopologyUserLinks result = new TopologyUserLinks( + new ArrayList(userLinks.values())); + if (queryString != null) { + queryContext.createQuery(queryString, TopologyUserLinks.class) + .filter(result, TopologyUserLinkConfig.class); + } + return result; } /** diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java index 5c2af6d8b4..932ac4e20b 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DataPacketMuxDemux.java @@ -32,11 +32,15 @@ import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.core.Property; import org.opendaylight.controller.sal.core.UpdateType; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.packet.Ethernet; import org.opendaylight.controller.sal.packet.IPluginOutDataPacketService; +import org.opendaylight.controller.sal.packet.PacketException; import org.opendaylight.controller.sal.packet.PacketResult; import org.opendaylight.controller.sal.packet.RawPacket; import org.opendaylight.controller.sal.utils.GlobalConstants; import org.opendaylight.controller.sal.utils.HexEncode; +import org.opendaylight.controller.sal.utils.NetUtils; import org.openflow.protocol.OFMessage; import org.openflow.protocol.OFPacketIn; import org.openflow.protocol.OFPacketOut; @@ -169,12 +173,10 @@ public class DataPacketMuxDemux implements IContainerListener, @Override public void receive(ISwitch sw, OFMessage msg) { - if (sw == null || msg == null - || this.pluginOutDataPacketServices == null) { + if (sw == null || msg == null || this.pluginOutDataPacketServices == null) { // Something fishy, we cannot do anything - logger.debug( - "sw: {} and/or msg: {} and/or pluginOutDataPacketServices: {} is null!", - new Object[] { sw, msg, this.pluginOutDataPacketServices }); + logger.debug("sw: {} and/or msg: {} and/or pluginOutDataPacketServices: {} is null!", new Object[] { sw, + msg, this.pluginOutDataPacketServices }); return; } @@ -185,8 +187,7 @@ public class DataPacketMuxDemux implements IContainerListener, logger.debug("Connection service refused DataPacketMuxDemux receive {} {}", sw, msg); return; } - } - catch (Exception e) { + } catch (Exception e) { return; } @@ -204,63 +205,72 @@ public class DataPacketMuxDemux implements IContainerListener, // pass the parsed packet simply because once the // packet infra is settled all the packets will passed // around as parsed and read-only - for (int i = 0; i < this.iDataPacketListen.size(); i++) { - IDataPacketListen s = this.iDataPacketListen.get(i); - if (s.receiveDataPacket(dataPacket).equals( - PacketResult.CONSUME)) { + for (IDataPacketListen s : this.iDataPacketListen) { + if (s.receiveDataPacket(dataPacket).equals(PacketResult.CONSUME)) { logger.trace("Consumed locally data packet"); return; } } - // Now dispatch the packet toward SAL at least for - // default container, we need to revisit this in a general - // slicing architecture refresh - IPluginOutDataPacketService defaultOutService = this.pluginOutDataPacketServices - .get(GlobalConstants.DEFAULT.toString()); - if (defaultOutService != null) { - defaultOutService.receiveDataPacket(dataPacket); - if (logger.isTraceEnabled()) { - logger.trace( - "Dispatched to apps a frame of size: {} on " + - "container: {}: {}", new Object[] { - ofPacket.getPacketData().length, - GlobalConstants.DEFAULT.toString(), - HexEncode.bytesToHexString(dataPacket - .getPacketData()) }); - } - } + boolean dispatched_to_container = false; + // Now check the mapping between nodeConnector and // Container and later on optimally filter based on // flowSpec List containersRX = this.nc2Container.get(p); if (containersRX != null) { - for (int i = 0; i < containersRX.size(); i++) { - String container = containersRX.get(i); - IPluginOutDataPacketService s = this.pluginOutDataPacketServices - .get(container); - if (s != null) { - // TODO add filtering on a per-flowSpec base - s.receiveDataPacket(dataPacket); - if (logger.isTraceEnabled()) { - logger.trace( - "Dispatched to apps a frame of size: {}" + - " on container: {}: {}", new Object[] { - ofPacket.getPacketData().length, - container, - HexEncode.bytesToHexString(dataPacket - .getPacketData()) }); + Ethernet frame = new Ethernet(); + byte data[] = dataPacket.getPacketData(); + frame.deserialize(data, 0, data.length * NetUtils.NumBitsInAByte); + Match packetMatch = frame.getMatch(); + for (String container : containersRX) { + boolean notify = true; + List containerFlows = this.container2FlowSpecs.get(container); + if (containerFlows != null) { + notify = false; + for (ContainerFlow cFlow : containerFlows) { + if (cFlow.allowsMatch(packetMatch)) { + notify = true; + break; + } + } + if (notify) { + IPluginOutDataPacketService s = this.pluginOutDataPacketServices.get(container); + if (s != null) { + s.receiveDataPacket(dataPacket); + if (logger.isTraceEnabled()) { + logger.trace( + "Dispatched to apps a frame of size: {}" + " on container: {}: {}", + new Object[] { ofPacket.getPacketData().length, container, + HexEncode.bytesToHexString(dataPacket.getPacketData()) }); + } + } + dispatched_to_container = true; } } } } - + if (!dispatched_to_container) { + // Now dispatch the packet toward SAL for default container + IPluginOutDataPacketService defaultOutService = this.pluginOutDataPacketServices + .get(GlobalConstants.DEFAULT.toString()); + if (defaultOutService != null) { + defaultOutService.receiveDataPacket(dataPacket); + if (logger.isTraceEnabled()) { + logger.trace("Dispatched to apps a frame of size: {} on " + "container: {}: {}", + new Object[] { ofPacket.getPacketData().length, + GlobalConstants.DEFAULT.toString(), + HexEncode.bytesToHexString(dataPacket.getPacketData()) }); + } + } + } // This is supposed to be the catch all for all the // DataPacket hence we will assume it has been handled return; } catch (ConstructionException cex) { + } catch (PacketException e) { + logger.debug("Failed to deserialize raw packet: ", e.getMessage()); } - // If we reach this point something went wrong. return; } else { diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Match.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Match.java index cfe20a1fa2..4b8966c546 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Match.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6Match.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, @@ -69,6 +69,16 @@ public class V6Match extends OFMatch implements Cloneable { private static int IPV6_EXT_MIN_HDR_LEN = 36; + /** + * CFI bit in VLAN TCI field. + */ + private static final int VLAN_TCI_CFI = 1 << 12; + + /** + * Value of OFP_VLAN_NONE defined by OpenFlow 1.0. + */ + private static final short OFP_VLAN_NONE = (short) 0xffff; + private enum MatchFieldState { MATCH_ABSENT, MATCH_FIELD_ONLY, MATCH_FIELD_WITH_MASK } @@ -334,11 +344,15 @@ public class V6Match extends OFMatch implements Cloneable { private byte[] getVlanTCI(short dataLayerVirtualLanID, byte dataLayerVirtualLanPriorityCodePoint) { ByteBuffer vlan_tci = ByteBuffer.allocate(2); - int cfi = 1 << 12; // the cfi bit is in position 12 - int pcp = dataLayerVirtualLanPriorityCodePoint << 13; // the pcp fields - // have to move by - // 13 - int vlan_tci_int = pcp + cfi + dataLayerVirtualLanID; + int vlan_tci_int; + if (dataLayerVirtualLanID == OFP_VLAN_NONE) { + // Match only packets without VLAN tag. + vlan_tci_int = 0; + } else { + // the pcp fields have to move by 13 + int pcp = dataLayerVirtualLanPriorityCodePoint << 13; + vlan_tci_int = pcp + VLAN_TCI_CFI + dataLayerVirtualLanID; + } vlan_tci.put((byte) (vlan_tci_int >> 8)); // bits 8 to 15 vlan_tci.put((byte) vlan_tci_int); // bits 0 to 7 return vlan_tci.array(); @@ -542,7 +556,12 @@ public class V6Match extends OFMatch implements Cloneable { ethTypeState = MatchFieldState.MATCH_FIELD_ONLY; match_len += 6; } else if (values[0].equals(STR_DL_VLAN)) { - this.dataLayerVirtualLan = U16.t(Integer.valueOf(values[1])); + short vlan = U16.t(Integer.valueOf(values[1])); + if (this.dlVlanPCPState != MatchFieldState.MATCH_ABSENT && + vlan == OFP_VLAN_NONE) { + throw new IllegalArgumentException("DL_VLAN_PCP is set."); + } + this.dataLayerVirtualLan = vlan; this.dlVlanIDState = MatchFieldState.MATCH_FIELD_ONLY; // the variable dlVlanIDState is not really used as a flag // for serializing and deserializing. Rather it is used as a @@ -552,6 +571,9 @@ public class V6Match extends OFMatch implements Cloneable { if (this.dlVlanPCPState != MatchFieldState.MATCH_ABSENT) { this.dlVlanTCIState = MatchFieldState.MATCH_FIELD_ONLY; match_len -= 2; + } else if (this.dataLayerVirtualLan == OFP_VLAN_NONE) { + this.dlVlanTCIState = MatchFieldState.MATCH_FIELD_ONLY; + match_len += 6; } else { this.dlVlanTCIState = MatchFieldState.MATCH_FIELD_WITH_MASK; this.dataLayerVirtualLanTCIMask = 0x1fff; @@ -559,6 +581,11 @@ public class V6Match extends OFMatch implements Cloneable { } this.wildcards &= ~OFPFW_DL_VLAN; } else if (values[0].equals(STR_DL_VLAN_PCP)) { + if (this.dlVlanIDState != MatchFieldState.MATCH_ABSENT && + this.dataLayerVirtualLan == OFP_VLAN_NONE) { + throw new IllegalArgumentException + ("OFP_VLAN_NONE is specified to DL_VLAN."); + } this.dataLayerVirtualLanPriorityCodePoint = U8.t(Short .valueOf(values[1])); this.dlVlanPCPState = MatchFieldState.MATCH_FIELD_ONLY; @@ -858,12 +885,20 @@ public class V6Match extends OFMatch implements Cloneable { // get the vlan pcp byte firstByte = data.get(); byte secondByte = data.get(); - super.setDataLayerVirtualLanPriorityCodePoint(getVlanPCP(firstByte)); - super.setDataLayerVirtualLan(getVlanID(firstByte, secondByte)); + if (firstByte == 0 && secondByte == 0) { + // Match only packets without VLAN tag. + setDataLayerVirtualLan(OFP_VLAN_NONE); + } else if (((firstByte << 8) & VLAN_TCI_CFI) == 0) { + // Ignore invalid TCI field. + return; + } else { + super.setDataLayerVirtualLanPriorityCodePoint(getVlanPCP(firstByte)); + super.setDataLayerVirtualLan(getVlanID(firstByte, secondByte)); + this.wildcards ^= (1 << 20); + } this.dlVlanTCIState = MatchFieldState.MATCH_FIELD_ONLY; this.match_len += 6; this.wildcards ^= (1 << 1); // Sync with 0F 1.0 Match - this.wildcards ^= (1 << 20); } } } @@ -1241,7 +1276,6 @@ public class V6Match extends OFMatch implements Cloneable { * * @return */ - public Inet6Address getNetworkDest() { return this.nwDst; } @@ -1251,7 +1285,6 @@ public class V6Match extends OFMatch implements Cloneable { * * @return */ - public Inet6Address getNetworkSrc() { return this.nwSrc; } @@ -1316,7 +1349,19 @@ public class V6Match extends OFMatch implements Cloneable { } } + /** + * Set a value to VLAN ID match field. + * + * @param vlan A value to match for VLAN ID. + * @param mask A bitmask for VLAN ID. + */ public void setDataLayerVirtualLan(short vlan, short mask) { + if (vlan == OFP_VLAN_NONE + && this.dlVlanIDState != MatchFieldState.MATCH_ABSENT) { + throw new IllegalStateException + ("DL_VLAN_PCP is set."); + } + // mask is ignored as the code sets the appropriate mask super.dataLayerVirtualLan = vlan; this.dlVlanIDState = MatchFieldState.MATCH_FIELD_ONLY; @@ -1327,6 +1372,9 @@ public class V6Match extends OFMatch implements Cloneable { if (this.dlVlanPCPState != MatchFieldState.MATCH_ABSENT) { this.dlVlanTCIState = MatchFieldState.MATCH_FIELD_ONLY; match_len -= 2; + } else if (this.dataLayerVirtualLan == OFP_VLAN_NONE) { + this.dlVlanTCIState = MatchFieldState.MATCH_FIELD_ONLY; + match_len += 6; } else { this.dlVlanTCIState = MatchFieldState.MATCH_FIELD_WITH_MASK; this.dataLayerVirtualLanTCIMask = 0x1fff; @@ -1334,7 +1382,19 @@ public class V6Match extends OFMatch implements Cloneable { } } + /** + * Set a value to VLAN PCP match field. + * + * @param pcp A value to match for VLAN PCP. + * @param mask A bitmask for VLAN PCP. + */ public void setDataLayerVirtualLanPriorityCodePoint(byte pcp, byte mask) { + if (this.dlVlanIDState != MatchFieldState.MATCH_ABSENT + && this.dataLayerVirtualLan == OFP_VLAN_NONE) { + throw new IllegalStateException + ("OFP_VLAN_NONE is specified to DL_VLAN."); + } + // mask is ignored as the code sets the appropriate mask super.dataLayerVirtualLanPriorityCodePoint = pcp; this.dlVlanPCPState = MatchFieldState.MATCH_FIELD_ONLY; diff --git a/opendaylight/protocol_plugins/openflow/src/test/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6MatchTest.java b/opendaylight/protocol_plugins/openflow/src/test/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6MatchTest.java new file mode 100644 index 0000000000..fceaaf46c9 --- /dev/null +++ b/opendaylight/protocol_plugins/openflow/src/test/java/org/opendaylight/controller/protocol_plugin/openflow/vendorextension/v6extension/V6MatchTest.java @@ -0,0 +1,461 @@ +/* + * Copyright (c) 2014 NEC Corporation + * 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.protocol_plugin.openflow.vendorextension.v6extension; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.openflow.protocol.OFMatch.OFPFW_ALL; +import static org.openflow.protocol.OFMatch.OFPFW_DL_VLAN; +import static org.openflow.protocol.OFMatch.OFPFW_DL_VLAN_PCP; +import static org.openflow.protocol.OFMatch.OFPFW_IN_PORT; + +import java.nio.ByteBuffer; +import org.junit.Test; + +/** + * JUnit test for {@link V6Match}. + */ +public class V6MatchTest { + /** + * Header of a match entry for input port field without a mask. + * The vendor-specific value is 0, and the length of value is 2. + */ + private static int HEADER_INPUT_PORT = (0 << 9) | 2; + + /** + * Header of a match entry for VLAN TCI field without a mask. + * The vendor-specific value is 4, and the length of value is 2. + */ + private static int HEADER_VLAN_TCI= (4 << 9) | 2; + + /** + * Header of a match entry for VLAN TCI field with a mask. + * The vendor-specific value is 4, and the length of value is 4. + */ + private static int HEADER_VLAN_TCI_W = (4 << 9) | (1 << 8) | 4; + + /** + * Length of a match entry for input port field. + * Header (4 bytes) + value (2 bytes) = 6 bytes. + */ + private static short MATCH_LEN_INPUT_PORT = 6; + + /** + * Length of a match entry for VLAN TCI field without a mask. + * Header (4 bytes) + value (2 bytes) = 6 bytes. + */ + private static short MATCH_LEN_VLAN_TCI = 6; + + /** + * Length of a match entry for VLAN TCI field with a mask. + * Header (4 bytes) + value (2 bytes) + bitmask (2 bytes) = 8 bytes. + */ + private static short MATCH_LEN_VLAN_TCI_WITH_MASK = 8; + + /** + * Value of OFP_VLAN_NONE defined by OpenFlow 1.0. + */ + private static final short OFP_VLAN_NONE = (short)0xffff; + + /** + * CFI bit in VLAN TCI field. + */ + private static final int VLAN_TCI_CFI = 1 << 12; + + /** + * Test case for {@link V6Match#fromString(String)} about VLAN TCI field. + * This test passes values to "dl_vlan" and "dl_vpcp". + */ + @Test + public void testFromStringVlanTci() { + // Test for "dl_vlan" using non OFP_VLAN_NONE values. + short vlans[] = {1, 10, 1000, 4095}; + short mask = 0; + for (short vlan: vlans) { + V6Match match = new V6Match(); + match.fromString("dl_vlan=" + vlan); + assertEquals(MATCH_LEN_VLAN_TCI_WITH_MASK, match.getIPv6MatchLen()); + assertEquals(vlan, match.getDataLayerVirtualLan()); + int wildcards = OFPFW_ALL & ~OFPFW_DL_VLAN; + assertEquals(wildcards, match.getWildcards()); + } + + // Test for "dl_vpcp". + byte pcps[] = {1, 3, 7}; + for (byte pcp: pcps) { + V6Match match = new V6Match(); + match.fromString("dl_vpcp=" + pcp); + assertEquals(MATCH_LEN_VLAN_TCI_WITH_MASK, match.getIPv6MatchLen()); + assertEquals(pcp, match.getDataLayerVirtualLanPriorityCodePoint()); + int wildcards = OFPFW_ALL & ~OFPFW_DL_VLAN_PCP; + assertEquals(wildcards, match.getWildcards()); + } + + // Set "dl_vlan" field firstly, "dl_vpcp" field secondly. + for (short vlan: vlans) { + for (byte pcp: pcps) { + V6Match match = new V6Match(); + match.fromString("dl_vlan=" + vlan); + match.fromString("dl_vpcp=" + pcp); + assertEquals(MATCH_LEN_VLAN_TCI, match.getIPv6MatchLen()); + assertEquals(vlan, match.getDataLayerVirtualLan()); + assertEquals(pcp, + match.getDataLayerVirtualLanPriorityCodePoint()); + } + } + + // Set "dl_vpcp" field firstly, "dl_vlan" field secondly. + for (short vlan: vlans) { + for (byte pcp: pcps) { + V6Match match = new V6Match(); + match.fromString("dl_vpcp=" + pcp); + match.fromString("dl_vlan=" + vlan); + assertEquals(MATCH_LEN_VLAN_TCI, match.getIPv6MatchLen()); + assertEquals(vlan, match.getDataLayerVirtualLan()); + assertEquals(pcp, + match.getDataLayerVirtualLanPriorityCodePoint()); + } + } + + // Test for OFP_VLAN_NONE when VLAN PCP is not set. + V6Match match = new V6Match(); + match.fromString("dl_vlan=" + OFP_VLAN_NONE); + assertEquals(MATCH_LEN_VLAN_TCI, match.getIPv6MatchLen()); + assertEquals(OFP_VLAN_NONE, match.getDataLayerVirtualLan()); + + // Test for OFP_VLAN_NONE when VLAN PCP is set. + match = new V6Match(); + match.fromString("dl_vpcp=" + 1); + try { + match.fromString("dl_vlan=" + OFP_VLAN_NONE); + fail("Throwing exception was expected."); + } catch (IllegalArgumentException e) { + // Throwing exception was expected. + } + } + + /** + * Test case for {@link V6Match#writeTo(ByteBuffer)} for VLAN TCI field. + */ + @Test + public void testWriteToVlanTci() { + byte mask = 0; + + // Set only VLAN ID. + short vlans[] = {1, 10, 1000, 4095}; + for (short vlan: vlans) { + V6Match match = new V6Match(); + match.setDataLayerVirtualLan(vlan, mask); + ByteBuffer data = ByteBuffer.allocate(10); + match.writeTo(data); + assertEquals(MATCH_LEN_VLAN_TCI_WITH_MASK, data.position()); + data.flip(); + // Header + assertEquals(HEADER_VLAN_TCI_W, data.getInt()); + // Value + short expectedTci = (short) (VLAN_TCI_CFI | vlan); + assertEquals(expectedTci, data.getShort()); + // Mask + short expectedMask = 0x1fff; + assertEquals(expectedMask, data.getShort()); + } + + // Set only VLAN PCP. + byte pcps[] = {1, 3, 7}; + for (byte pcp: pcps) { + V6Match match = new V6Match(); + match.setDataLayerVirtualLanPriorityCodePoint(pcp, mask); + ByteBuffer data = ByteBuffer.allocate(10); + match.writeTo(data); + assertEquals(MATCH_LEN_VLAN_TCI_WITH_MASK, data.position()); + data.flip(); + // Header + assertEquals(HEADER_VLAN_TCI_W, data.getInt()); + // Value + short expectedTci = (short) (pcp << 13 | VLAN_TCI_CFI); + assertEquals(expectedTci, data.getShort()); + // Mask + short expectedMask = (short) 0xf000; + assertEquals(expectedMask, data.getShort()); + } + + // Set both VLAN ID and PCP. + for (short vlan: vlans) { + for (byte pcp: pcps) { + V6Match match = new V6Match(); + match.setDataLayerVirtualLan(vlan, mask); + match.setDataLayerVirtualLanPriorityCodePoint(pcp, mask); + ByteBuffer data = ByteBuffer.allocate(10); + match.writeTo(data); + assertEquals(MATCH_LEN_VLAN_TCI, data.position()); + data.flip(); + // Header + assertEquals(HEADER_VLAN_TCI, data.getInt()); + // Value + short expectedTci = (short) (pcp << 13 | VLAN_TCI_CFI | vlan); + assertEquals(expectedTci, data.getShort()); + } + } + + // Set OFP_VLAN_NONE. + V6Match match = new V6Match(); + match.setDataLayerVirtualLan(OFP_VLAN_NONE, mask); + ByteBuffer data = ByteBuffer.allocate(10); + match.writeTo(data); + assertEquals(MATCH_LEN_VLAN_TCI, data.position()); + data.flip(); + // Header + assertEquals(HEADER_VLAN_TCI, data.getInt()); + // Value + assertEquals(0, data.getShort()); + } + + /** + * Test case for {@link V6Match#writeTo(ByteBuffer)} for input port field. + */ + @Test + public void testWriteToInputPort() { + // Set input port. + short ports[] = {1, 10, 100, 1000}; + for (short port: ports) { + V6Match match = new V6Match(); + match.setInputPort(port, (short) 0); + ByteBuffer data = ByteBuffer.allocate(10); + match.writeTo(data); + assertEquals(MATCH_LEN_INPUT_PORT, data.position()); + data.flip(); + // Header + assertEquals(HEADER_INPUT_PORT, data.getInt()); + // Value + assertEquals(port, data.getShort()); + } + } + + /** + * Test case for {@link V6Match#readFrom(ByteBuffer)} for VLAN TCI field. + */ + @Test + public void testReadFromVlanTci() { + // Test for an exact match a TCI value with CFI=1. + // It matches packets that have an 802.1Q header with a specified + // VID and PCP. + short vlans[] = {1, 10, 1000, 4095}; + byte pcps[] = {1, 3, 7}; + for (short vlan: vlans) { + for (byte pcp: pcps) { + ByteBuffer data = ByteBuffer.allocate(MATCH_LEN_VLAN_TCI); + data.putInt(HEADER_VLAN_TCI); + short tci = (short) (pcp << 13 | VLAN_TCI_CFI | vlan); + data.putShort(tci); + data.flip(); + + V6Match match = new V6Match(); + match.readFrom(data); + assertEquals(MATCH_LEN_VLAN_TCI, match.getIPv6MatchLen()); + assertEquals(pcp, + match.getDataLayerVirtualLanPriorityCodePoint()); + assertEquals(vlan, match.getDataLayerVirtualLan()); + int wildcards = OFPFW_ALL & ~OFPFW_DL_VLAN_PCP & ~OFPFW_DL_VLAN; + assertEquals(wildcards, match.getWildcards()); + } + } + + // Test with a specific VID and CFI=1 with mask=0x1fff. + // It matches packets that have an 802.1Q header with that VID + // and any PCP. + for (short vlan: vlans) { + ByteBuffer data = ByteBuffer.allocate(MATCH_LEN_VLAN_TCI_WITH_MASK); + data.putInt(HEADER_VLAN_TCI_W); + short tci = (short) (VLAN_TCI_CFI | vlan); + data.putShort(tci); + short mask = (short) 0x1fff; + data.putShort(mask); + data.flip(); + + V6Match match = new V6Match(); + match.readFrom(data); + assertEquals(MATCH_LEN_VLAN_TCI_WITH_MASK, match.getIPv6MatchLen()); + assertEquals(vlan, match.getDataLayerVirtualLan()); + int wildcards = OFPFW_ALL & ~OFPFW_DL_VLAN; + assertEquals(wildcards, match.getWildcards()); + } + + // Test with a specific PCP and CFI=1 with mask=0xf000. + // It matches packets that have an 802.1Q header with that PCP + // and any VID. + for (byte pcp: pcps) { + ByteBuffer data = ByteBuffer.allocate(MATCH_LEN_VLAN_TCI_WITH_MASK); + data.putInt(HEADER_VLAN_TCI_W); + short tci = (short) (pcp << 13| VLAN_TCI_CFI); + data.putShort(tci); + short mask = (short) 0xf000; + data.putShort(mask); + data.flip(); + + V6Match match = new V6Match(); + match.readFrom(data); + assertEquals(MATCH_LEN_VLAN_TCI_WITH_MASK, match.getIPv6MatchLen()); + assertEquals(pcp, match.getDataLayerVirtualLanPriorityCodePoint()); + int wildcards = OFPFW_ALL & ~OFPFW_DL_VLAN_PCP; + assertEquals(wildcards, match.getWildcards()); + } + + // Test for an exact match with 0. + // It matches only packets without an 802.1Q header. + ByteBuffer data = ByteBuffer.allocate(MATCH_LEN_VLAN_TCI); + data.putInt(HEADER_VLAN_TCI); + short tci = 0; + data.putShort(tci); + data.flip(); + + V6Match match = new V6Match(); + match.readFrom(data); + assertEquals(MATCH_LEN_VLAN_TCI, match.getIPv6MatchLen()); + assertEquals(OFP_VLAN_NONE, match.getDataLayerVirtualLan()); + int wildcards = OFPFW_ALL & ~OFPFW_DL_VLAN; + assertEquals(wildcards, match.getWildcards()); + } + + /** + * Test case for {@link V6Match#readFrom(ByteBuffer)} for input port field. + */ + @Test + public void testReadFromInputPort() { + // Set input port. + short ports[] = {1, 10, 100, 1000}; + for (short port: ports) { + ByteBuffer data = ByteBuffer.allocate(MATCH_LEN_INPUT_PORT); + data.putInt(HEADER_INPUT_PORT); + data.putShort(port); + data.flip(); + + V6Match match = new V6Match(); + match.readFrom(data); + assertEquals(MATCH_LEN_INPUT_PORT, match.getIPv6MatchLen()); + assertEquals(port, match.getInputPort()); + int wildcards = OFPFW_ALL & ~OFPFW_IN_PORT; + assertEquals(wildcards, match.getWildcards()); + } + } + + /** + * Test case for {@link V6Match#setDataLayerVirtualLan(short, short)}. + */ + @Test + public void testSetDataLayerVirtualLan() { + short vlans[] = {1, 10, 1000, 4095}; + short mask = 0; + for (short vlan: vlans) { + V6Match match = new V6Match(); + match.setDataLayerVirtualLan(vlan, mask); + assertEquals(MATCH_LEN_VLAN_TCI_WITH_MASK, match.getIPv6MatchLen()); + assertEquals(vlan, match.getDataLayerVirtualLan()); + } + + // Test for OFP_VLAN_NONE. + V6Match match = new V6Match(); + match.setDataLayerVirtualLan(OFP_VLAN_NONE, mask); + assertEquals(MATCH_LEN_VLAN_TCI, match.getIPv6MatchLen()); + assertEquals(OFP_VLAN_NONE, match.getDataLayerVirtualLan()); + } + + /** + * Test case for + * {@link V6Match#setDataLayerVirtualLanPriorityCodePoint(byte, byte)}. + */ + @Test + public void testSetDataLayerVirtualLanPriorityCodePoint() { + byte pcps[] = {1, 3, 7}; + byte mask = 0; + for (byte pcp: pcps) { + V6Match match = new V6Match(); + match.setDataLayerVirtualLanPriorityCodePoint(pcp, mask); + assertEquals(MATCH_LEN_VLAN_TCI_WITH_MASK, match.getIPv6MatchLen()); + assertEquals(pcp, match.getDataLayerVirtualLanPriorityCodePoint()); + } + } + + /** + * Test case for setter methods for VLAN TCI field. + * + * This test case calls {@link V6Match#setDataLayerVirtualLan(short, short)} + * and {@link V6Match#setDataLayerVirtualLanPriorityCodePoint(byte, byte)}. + */ + @Test + public void testSetVlanTCI() { + short vlans[] = {1, 10, 1000, 4095}; + byte pcps[] = {1, 3, 7}; + byte mask = 0; + + // Call setDataLayerVirtualLan(short, short) firstly, + // and setDataLayerVirtualLanPriorityCodePoint(byte, byte) secondly, + for (short vlan: vlans) { + for (byte pcp: pcps) { + V6Match match = new V6Match(); + match.setDataLayerVirtualLan(vlan, mask); + match.setDataLayerVirtualLanPriorityCodePoint(pcp, mask); + assertEquals(MATCH_LEN_VLAN_TCI, match.getIPv6MatchLen()); + assertEquals(vlan, match.getDataLayerVirtualLan()); + assertEquals(pcp, + match.getDataLayerVirtualLanPriorityCodePoint()); + } + } + + // Call setDataLayerVirtualLanPriorityCodePoint(byte, byte) firstly, + // and setDataLayerVirtualLan(short, short) secondly. + for (short vlan: vlans) { + for (byte pcp: pcps) { + V6Match match = new V6Match(); + match.setDataLayerVirtualLanPriorityCodePoint(pcp, mask); + match.setDataLayerVirtualLan(vlan, mask); + assertEquals(MATCH_LEN_VLAN_TCI, match.getIPv6MatchLen()); + assertEquals(vlan, match.getDataLayerVirtualLan()); + assertEquals(pcp, + match.getDataLayerVirtualLanPriorityCodePoint()); + } + } + + // Test for setting OFP_VLAN_NONE when VLAN PCP is set. + for (byte pcp: pcps) { + V6Match match = new V6Match(); + match.setDataLayerVirtualLanPriorityCodePoint(pcp, mask); + try { + match.setDataLayerVirtualLan(OFP_VLAN_NONE, mask); + } catch (IllegalStateException e) { + // Throwing exception was expected. + } + } + + // Test for set VLAN PCP when OFP_VLAN_NONE is set to VLAN match. + for (byte pcp: pcps) { + V6Match match = new V6Match(); + match.setDataLayerVirtualLan(OFP_VLAN_NONE, mask); + try { + match.setDataLayerVirtualLanPriorityCodePoint(pcp, mask); + } catch (IllegalStateException e) { + // Throwing exception was expected. + } + } + } + + /** + * Test case for {@link V6Match#setInputPort(short, short)}. + */ + @Test + public void testSetInputPort() { + short ports[] = {1, 10, 100, 1000}; + for (short port: ports) { + V6Match match = new V6Match(); + match.setInputPort(port, (short) 0); + assertEquals(MATCH_LEN_INPUT_PORT, match.getIPv6MatchLen()); + assertEquals(port, match.getInputPort()); + } + } +} diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/ARP.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/ARP.java index 8fc0d625eb..21c17b366c 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/ARP.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/ARP.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, @@ -258,18 +258,23 @@ public class ARP extends Packet { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } ARP other = (ARP) obj; if (fieldValues == null) { - if (other.fieldValues != null) + if (other.fieldValues != null) { return false; - } else if (!fieldValues.equals(other.fieldValues)) + } + } else if (!fieldValues.equals(other.fieldValues)) { return false; + } return true; } } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Ethernet.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Ethernet.java index d0068564a9..235e71a760 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Ethernet.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Ethernet.java @@ -15,6 +15,8 @@ import java.util.Map; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.match.MatchType; import org.opendaylight.controller.sal.utils.EtherTypes; import org.opendaylight.controller.sal.utils.NetUtils; @@ -139,4 +141,10 @@ public class Ethernet extends Packet { return this; } + @Override + public void populateMatch(Match match) { + match.setField(MatchType.DL_SRC, this.getSourceMACAddress()); + match.setField(MatchType.DL_DST, this.getDestinationMACAddress()); + match.setField(MatchType.DL_TYPE, this.getEtherType()); + } } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IEEE8021Q.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IEEE8021Q.java index 39c7d386bc..9825d0eefb 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IEEE8021Q.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IEEE8021Q.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, @@ -13,6 +13,8 @@ import java.util.LinkedHashMap; import java.util.Map; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.match.MatchType; /** * Class that represents the IEEE 802.1Q objects @@ -148,4 +150,10 @@ public class IEEE8021Q extends Packet { return this; } + @Override + public void populateMatch(Match match) { + match.setField(MatchType.DL_VLAN, this.getVid()); + match.setField(MatchType.DL_VLAN_PR, this.getPcp()); + match.setField(MatchType.DL_TYPE, this.getEtherType()); + } } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPv4.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPv4.java index 559acd633a..3363f423d6 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPv4.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPv4.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, @@ -20,6 +20,8 @@ import java.util.Random; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.match.MatchType; import org.opendaylight.controller.sal.utils.IPProtocols; import org.opendaylight.controller.sal.utils.NetUtils; import org.slf4j.Logger; @@ -577,4 +579,12 @@ public class IPv4 extends Packet { corrupted = true; } } + + @Override + public void populateMatch(Match match) { + match.setField(MatchType.NW_SRC, NetUtils.getInetAddress(this.getSourceAddress())); + match.setField(MatchType.NW_DST, NetUtils.getInetAddress(this.getDestinationAddress())); + match.setField(MatchType.NW_PROTO, this.getProtocol()); + match.setField(MatchType.NW_TOS, this.getDiffServ()); + } } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDP.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDP.java index 6f5cf04a52..9b5dc082bb 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDP.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDP.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; + import org.opendaylight.controller.sal.utils.HexEncode; import org.opendaylight.controller.sal.utils.NetUtils; diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java index efb938e37f..35244ea697 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java @@ -151,18 +151,23 @@ public class LLDPTLV extends Packet { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } LLDPTLV other = (LLDPTLV) obj; if (fieldValues == null) { - if (other.fieldValues != null) + if (other.fieldValues != null) { return false; - } else if (!fieldValues.equals(other.fieldValues)) + } + } else if (!fieldValues.equals(other.fieldValues)) { return false; + } return true; } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java index 58b5d3914a..789aa12653 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, @@ -13,6 +13,7 @@ import java.util.Map; import java.util.Map.Entry; import org.apache.commons.lang3.tuple.Pair; +import org.opendaylight.controller.sal.match.Match; import org.opendaylight.controller.sal.utils.HexEncode; import org.opendaylight.controller.sal.utils.NetUtils; import org.slf4j.Logger; @@ -364,4 +365,31 @@ public abstract class Packet { return true; } + /** + * Adds to the passed Match this packet's header fields + * + * @param match + * The Match object to populate + */ + public void populateMatch(Match match) { + // To be overridden by derived packet classes which have well known + // header fields so that Packet.getMatch would return desired result + } + + /** + * Returns the Match object containing this packet and its payload + * encapsulated packets' header fields + * + * @return The Match containing the header fields of this packet and of its + * payload encapsulated packets + */ + public Match getMatch() { + Match match = new Match(); + Packet packet = this; + while (packet != null) { + packet.populateMatch(match); + packet = packet.getPayload(); + } + return match; + } } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/TCP.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/TCP.java index 8253ac46d3..d27494599c 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/TCP.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/TCP.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, @@ -15,6 +15,8 @@ import java.util.Map; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.match.MatchType; /** * Class that represents the TCP segment objects @@ -238,4 +240,9 @@ public class TCP extends Packet { return (BitBufferHelper.getShort(fieldValues.get(CHECKSUM))); } + @Override + public void populateMatch(Match match) { + match.setField(MatchType.TP_SRC, this.getSourcePort()); + match.setField(MatchType.TP_DST, this.getDestinationPort()); + } } diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/UDP.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/UDP.java index f82ed8fcae..069a277f89 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/UDP.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/UDP.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, @@ -15,6 +15,8 @@ import java.util.Map; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.match.MatchType; /** * Class that represents the UDP datagram objects @@ -156,4 +158,10 @@ public class UDP extends Packet { fieldValues.put(CHECKSUM, checksum); return this; } + + @Override + public void populateMatch(Match match) { + match.setField(MatchType.TP_SRC, this.getSourcePort()); + match.setField(MatchType.TP_DST, this.getDestinationPort()); + } } diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/ARPTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/ARPTest.java index a3ebd7ee0d..10bd535eb2 100644 --- a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/ARPTest.java +++ b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/ARPTest.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/EthernetTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/EthernetTest.java index 2494eb6b2d..494dd2abf2 100644 --- a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/EthernetTest.java +++ b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/EthernetTest.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, @@ -9,9 +9,14 @@ package org.opendaylight.controller.sal.packet; +import java.util.Arrays; + import junit.framework.Assert; import org.junit.Test; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.match.MatchType; +import org.opendaylight.controller.sal.utils.EtherTypes; public class EthernetTest { @@ -95,4 +100,22 @@ public class EthernetTest { } + @Test + public void testGetMatch() throws Exception { + Ethernet eth = new Ethernet(); + byte smac[] = { (byte) 0xf0, (byte) 0xde, (byte) 0xf1, (byte) 0x71, (byte) 0x72, (byte) 0x8d }; + byte dmac[] = { (byte) 0xde, (byte) 0x28, (byte) 0xdb, (byte) 0xb3, (byte) 0x7c, (byte) 0xf8 }; + short ethType = EtherTypes.IPv4.shortValue(); + eth.setDestinationMACAddress(dmac); + eth.setSourceMACAddress(smac); + eth.setEtherType(ethType); + + Match match = eth.getMatch(); + + Assert.assertTrue(Arrays.equals(smac, (byte[]) match.getField(MatchType.DL_SRC).getValue())); + Assert.assertTrue(Arrays.equals(dmac, (byte[]) match.getField(MatchType.DL_DST).getValue())); + Assert.assertEquals(ethType, (short) match.getField(MatchType.DL_TYPE).getValue()); + + } + } diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/IEEE8021QTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/IEEE8021QTest.java index a4c6c1fc4b..2443b491c7 100644 --- a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/IEEE8021QTest.java +++ b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/IEEE8021QTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, @@ -9,7 +9,11 @@ package org.opendaylight.controller.sal.packet; import junit.framework.Assert; + import org.junit.Test; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.match.MatchType; +import org.opendaylight.controller.sal.utils.EtherTypes; import org.opendaylight.controller.sal.utils.NetUtils; public class IEEE8021QTest { @@ -212,4 +216,21 @@ public class IEEE8021QTest { Assert.assertTrue(data[44] == (byte) 0x09); Assert.assertTrue(data[45] == (byte) 0xFE); } + + @Test + public void testGetMatchFullPacket() throws Exception { + IEEE8021Q dot1q = new IEEE8021Q(); + byte priority = 4; + short vlanId = 59; + short ethType = EtherTypes.IPv4.shortValue(); + dot1q.setPcp(priority); + dot1q.setVid(vlanId); + dot1q.setEtherType(ethType); + + Match match = dot1q.getMatch(); + + Assert.assertEquals(priority, (byte) match.getField(MatchType.DL_VLAN_PR).getValue()); + Assert.assertEquals(vlanId, (short) match.getField(MatchType.DL_VLAN).getValue()); + Assert.assertEquals(ethType, (short) match.getField(MatchType.DL_TYPE).getValue()); + } } diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/IPv4Test.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/IPv4Test.java index 5afcd8be7d..f5298711b6 100644 --- a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/IPv4Test.java +++ b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/IPv4Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, @@ -15,6 +15,8 @@ import java.util.Arrays; import junit.framework.Assert; import org.junit.Test; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.match.MatchType; import org.opendaylight.controller.sal.utils.EtherTypes; import org.opendaylight.controller.sal.utils.IPProtocols; import org.opendaylight.controller.sal.utils.NetUtils; @@ -452,4 +454,31 @@ public class IPv4Test { Assert.assertFalse(decIcmp.isCorrupted()); Assert.assertTrue(Arrays.equals(icmpRawPayload, decIcmp.getRawPayload())); } + + @Test + public void testGetMatch() throws Exception { + IPv4 ip = new IPv4(); + InetAddress sourceAddress = InetAddress.getByName("172.168.190.15"); + InetAddress destintationAddress = InetAddress.getByName("23.128.0.11"); + byte protocol = IPProtocols.TCP.byteValue(); + byte tos = 7; + ip.setVersion((byte) 4); + ip.setIdentification((short) 5); + ip.setDiffServ(tos); + ip.setECN((byte) 0); + ip.setTotalLength((short) 84); + ip.setFlags((byte) 2); + ip.setFragmentOffset((short) 0); + ip.setTtl((byte) 64); + ip.setProtocol(protocol); + ip.setDestinationAddress(destintationAddress); + ip.setSourceAddress(sourceAddress); + + Match match = ip.getMatch(); + + Assert.assertEquals(sourceAddress, match.getField(MatchType.NW_SRC).getValue()); + Assert.assertEquals(destintationAddress, match.getField(MatchType.NW_DST).getValue()); + Assert.assertEquals(protocol, (byte) match.getField(MatchType.NW_PROTO).getValue()); + Assert.assertEquals(tos, (byte) match.getField(MatchType.NW_TOS).getValue()); + } } diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/PacketTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/PacketTest.java index 8f3b283b2e..95eff32ef1 100644 --- a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/PacketTest.java +++ b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/PacketTest.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, @@ -9,11 +9,17 @@ package org.opendaylight.controller.sal.packet; +import java.net.InetAddress; +import java.util.Arrays; import java.util.Map; import junit.framework.Assert; import org.junit.Test; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.match.MatchType; +import org.opendaylight.controller.sal.utils.EtherTypes; +import org.opendaylight.controller.sal.utils.IPProtocols; public class PacketTest { @@ -120,9 +126,9 @@ public class PacketTest { eth.setSourceMACAddress(sMAC); eth.setEtherType(etherType); - dMACdata = (byte[]) fCValues.get("DestinationMACAddress"); - sMACdata = (byte[]) fCValues.get("SourceMACAddress"); - etherTypedata = (byte[]) fCValues.get("EtherType"); + dMACdata = fCValues.get("DestinationMACAddress"); + sMACdata = fCValues.get("SourceMACAddress"); + etherTypedata = fCValues.get("EtherType"); Assert.assertTrue(dMACdata[0] == 10); Assert.assertTrue(dMACdata[1] == 12); @@ -160,4 +166,62 @@ public class PacketTest { Assert.assertTrue(data[13] == 6); } + + @Test + public void testGetMatch() throws Exception { + TCP tcp = new TCP(); + short sport = (short) 11093; + short dport = (short) 23; + tcp.setSourcePort(sport); + tcp.setDestinationPort(dport); + + IPv4 ip = new IPv4(); + InetAddress sourceAddress = InetAddress.getByName("192.168.100.100"); + InetAddress destintationAddress = InetAddress.getByName("192.168.100.101"); + byte protocol = IPProtocols.TCP.byteValue(); + byte tos = 5; + ip.setVersion((byte) 4); + ip.setIdentification((short) 5); + ip.setDiffServ(tos); + ip.setECN((byte) 0); + ip.setTotalLength((short) 84); + ip.setFlags((byte) 2); + ip.setFragmentOffset((short) 0); + ip.setTtl((byte) 64); + ip.setProtocol(protocol); + ip.setDestinationAddress(destintationAddress); + ip.setSourceAddress(sourceAddress); + ip.setPayload(tcp); + + IEEE8021Q dot1q = new IEEE8021Q(); + byte priority = 4; + short vlanId = 59; + short ethType = EtherTypes.IPv4.shortValue(); + dot1q.setPcp(priority); + dot1q.setVid(vlanId); + dot1q.setEtherType(ethType); + dot1q.setPayload(ip); + + Ethernet eth = new Ethernet(); + byte smac[] = { (byte) 0xf0, (byte) 0xde, (byte) 0xf1, (byte) 0x71, (byte) 0x72, (byte) 0x8d }; + byte dmac[] = { (byte) 0xde, (byte) 0x28, (byte) 0xdb, (byte) 0xb3, (byte) 0x7c, (byte) 0xf8 }; + eth.setDestinationMACAddress(dmac); + eth.setSourceMACAddress(smac); + eth.setEtherType(EtherTypes.VLANTAGGED.shortValue()); + eth.setPayload(dot1q); + + Match match = eth.getMatch(); + + Assert.assertTrue(Arrays.equals(smac, (byte[]) match.getField(MatchType.DL_SRC).getValue())); + Assert.assertTrue(Arrays.equals(dmac, (byte[]) match.getField(MatchType.DL_DST).getValue())); + Assert.assertEquals(priority, (byte) match.getField(MatchType.DL_VLAN_PR).getValue()); + Assert.assertEquals(vlanId, (short) match.getField(MatchType.DL_VLAN).getValue()); + Assert.assertEquals(ethType, (short) match.getField(MatchType.DL_TYPE).getValue()); + Assert.assertEquals(sourceAddress, match.getField(MatchType.NW_SRC).getValue()); + Assert.assertEquals(destintationAddress, match.getField(MatchType.NW_DST).getValue()); + Assert.assertEquals(protocol, (byte) match.getField(MatchType.NW_PROTO).getValue()); + Assert.assertEquals(tos, (byte) match.getField(MatchType.NW_TOS).getValue()); + Assert.assertEquals(sport, (short) match.getField(MatchType.TP_SRC).getValue()); + Assert.assertEquals(dport, (short) match.getField(MatchType.TP_DST).getValue()); + } } diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/TCPTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/TCPTest.java index 3e18aedfdb..e56f41e5c1 100644 --- a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/TCPTest.java +++ b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/TCPTest.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, @@ -12,6 +12,8 @@ package org.opendaylight.controller.sal.packet; import junit.framework.Assert; import org.junit.Test; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.match.MatchType; public class TCPTest { @@ -113,4 +115,18 @@ public class TCPTest { short checksum = tcp.getChecksum(); Assert.assertTrue(checksum == 200); } + + @Test + public void testGetMatch() throws Exception { + TCP tcp = new TCP(); + short sport = (short) 52012; + short dport = (short) 40345; + tcp.setSourcePort(sport); + tcp.setDestinationPort(dport); + + Match match = tcp.getMatch(); + + Assert.assertEquals(sport, (short) match.getField(MatchType.TP_SRC).getValue()); + Assert.assertEquals(dport, (short) match.getField(MatchType.TP_DST).getValue()); + } } diff --git a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/UDPTest.java b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/UDPTest.java index 8d5be849a0..a3a597a82d 100644 --- a/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/UDPTest.java +++ b/opendaylight/sal/api/src/test/java/org/opendaylight/controller/sal/packet/UDPTest.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013-2014 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, @@ -12,6 +12,8 @@ package org.opendaylight.controller.sal.packet; import junit.framework.Assert; import org.junit.Test; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.match.MatchType; public class UDPTest { @@ -95,4 +97,19 @@ public class UDPTest { } + @Test + public void testGetMatch() throws Exception { + UDP udp = new UDP(); + short sport = (short) 33000; + short dport = (short) 843; + udp.setSourcePort(sport); + udp.setDestinationPort(dport); + + Match match = udp.getMatch(); + + Assert.assertEquals(sport, (short) match.getField(MatchType.TP_SRC).getValue()); + Assert.assertEquals(dport, (short) match.getField(MatchType.TP_DST).getValue()); + + } + }