From 88c698b10693af594e4b07ac619d1231fab267dc Mon Sep 17 00:00:00 2001 From: Prasanna Huddar Date: Thu, 16 Jan 2014 18:18:40 +0530 Subject: [PATCH] removing the old FRM code Signed-off-by: Prasanna Huddar Change-Id: I43c97b6b0e430f7085c81b855e343c9c7b8e60ce --- .../consumer/impl/FRMConsumerImpl.java | 162 ------- .../consumer/impl/FRMUtil.java | 402 ------------------ .../consumer/impl/FlowConsumerImpl.java | 365 ---------------- .../consumer/impl/GroupConsumerImpl.java | 323 -------------- .../impl/IForwardingRulesManager.java | 33 -- .../consumer/impl/MeterConsumerImpl.java | 337 --------------- .../impl/TableFeaturesConsumerImpl.java | 193 --------- 7 files changed, 1815 deletions(-) delete mode 100644 opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FRMConsumerImpl.java delete mode 100644 opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FRMUtil.java delete mode 100644 opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FlowConsumerImpl.java delete mode 100644 opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/GroupConsumerImpl.java delete mode 100644 opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/IForwardingRulesManager.java delete mode 100644 opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/MeterConsumerImpl.java delete mode 100644 opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/TableFeaturesConsumerImpl.java diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FRMConsumerImpl.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FRMConsumerImpl.java deleted file mode 100644 index bbe771fd9c..0000000000 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FRMConsumerImpl.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2013 Ericsson , 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.forwardingrulesmanager.consumer.impl; - -import org.eclipse.osgi.framework.console.CommandProvider; -import org.opendaylight.controller.clustering.services.IClusterContainerServices; -import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; -import org.opendaylight.controller.sal.binding.api.NotificationService; -import org.opendaylight.controller.sal.binding.api.data.DataBrokerService; -import org.opendaylight.controller.sal.binding.api.data.DataProviderService; -import org.opendaylight.controller.sal.core.IContainer; -import org.opendaylight.controller.sal.utils.ServiceHelper; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FRMConsumerImpl extends AbstractBindingAwareProvider implements CommandProvider { - protected static final Logger logger = LoggerFactory.getLogger(FRMConsumerImpl.class); - private static ProviderContext p_session; - private static DataBrokerService dataBrokerService; - private static NotificationService notificationService; - private FlowConsumerImpl flowImplRef; - private GroupConsumerImpl groupImplRef; - private MeterConsumerImpl meterImplRef; - private static DataProviderService dataProviderService; - private static IClusterContainerServices clusterContainerService = null; - private static IContainer container; - - @Override - public void onSessionInitiated(ProviderContext session) { - FRMConsumerImpl.p_session = session; - - if (!getDependentModule()) { - logger.error("Unable to fetch handlers for dependent modules"); - System.out.println("Unable to fetch handlers for dependent modules"); - return; - } - - if (null != session) { - notificationService = session.getSALService(NotificationService.class); - - if (null != notificationService) { - dataBrokerService = session.getSALService(DataBrokerService.class); - - if (null != dataBrokerService) { - dataProviderService = session.getSALService(DataProviderService.class); - - if (null != dataProviderService) { - flowImplRef = new FlowConsumerImpl(); - groupImplRef = new GroupConsumerImpl(); - meterImplRef = new MeterConsumerImpl(); - registerWithOSGIConsole(); - } else { - logger.error("Data Provider Service is down or NULL. " - + "Accessing data from configuration data store will not be possible"); - System.out.println("Data Broker Service is down or NULL."); - } - - } else { - logger.error("Data Broker Service is down or NULL."); - System.out.println("Data Broker Service is down or NULL."); - } - } else { - logger.error("Notification Service is down or NULL."); - System.out.println("Notification Service is down or NULL."); - } - } else { - logger.error("Consumer session is NULL. Please check if provider is registered"); - System.out.println("Consumer session is NULL. Please check if provider is registered"); - } - - } - - public static IClusterContainerServices getClusterContainerService() { - return clusterContainerService; - } - - public static void setClusterContainerService(IClusterContainerServices clusterContainerService) { - FRMConsumerImpl.clusterContainerService = clusterContainerService; - } - - public static IContainer getContainer() { - return container; - } - - public static void setContainer(IContainer container) { - FRMConsumerImpl.container = container; - } - - private void registerWithOSGIConsole() { - BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); - bundleContext.registerService(CommandProvider.class.getName(), this, null); - } - - private boolean getDependentModule() { - do { - clusterContainerService = (IClusterContainerServices) ServiceHelper.getGlobalInstance( - IClusterContainerServices.class, this); - try { - Thread.sleep(4); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } while (clusterContainerService == null); - - do { - - container = (IContainer) ServiceHelper.getGlobalInstance(IContainer.class, this); - try { - Thread.sleep(5); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } while (container == null); - - return true; - } - - public static DataProviderService getDataProviderService() { - return dataProviderService; - } - - public FlowConsumerImpl getFlowImplRef() { - return flowImplRef; - } - - public GroupConsumerImpl getGroupImplRef() { - return groupImplRef; - } - - public static ProviderContext getProviderSession() { - return p_session; - } - - public static NotificationService getNotificationService() { - return notificationService; - } - - public static DataBrokerService getDataBrokerService() { - return dataBrokerService; - } - - /* - * OSGI COMMANDS - */ - @Override - public String getHelp() { - StringBuffer help = new StringBuffer(); - return help.toString(); - } - -} diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FRMUtil.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FRMUtil.java deleted file mode 100644 index ab2e19e9d4..0000000000 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FRMUtil.java +++ /dev/null @@ -1,402 +0,0 @@ -package org.opendaylight.controller.forwardingrulesmanager.consumer.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType; -import org.opendaylight.controller.sal.utils.IPProtocols; -import org.opendaylight.controller.sal.utils.NetUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction; - -public class FRMUtil { - protected static final Logger logger = LoggerFactory.getLogger(FRMUtil.class); - private static final String NAMEREGEX = "^[a-zA-Z0-9]+$"; - - public static enum operation { - ADD, DELETE, UPDATE, GET - }; - - private enum EtherIPType { - ANY, V4, V6; - }; - - public static boolean isNameValid(String name) { - - // Name validation - if (name == null || name.trim().isEmpty() || !name.matches(NAMEREGEX)) { - return false; - } - return true; - - } - - public static boolean validateMatch(Flow flow) { - EtherIPType etype = EtherIPType.ANY; - EtherIPType ipsrctype = EtherIPType.ANY; - EtherIPType ipdsttype = EtherIPType.ANY; - - Match match = flow.getMatch(); - if (match != null) { - EthernetMatch ethernetmatch = match.getEthernetMatch(); - IpMatch ipmatch = match.getIpMatch(); - Layer3Match layer3match = match.getLayer3Match(); - VlanMatch vlanmatch = match.getVlanMatch(); - match.getIcmpv4Match(); - - if (ethernetmatch != null) { - if ((ethernetmatch.getEthernetSource() != null) - && !isL2AddressValid(ethernetmatch.getEthernetSource().getAddress().getValue())) { - - logger.error("Ethernet source address is not valid. Example: 00:05:b9:7c:81:5f", - ethernetmatch.getEthernetSource()); - return false; - } - - if ((ethernetmatch.getEthernetDestination() != null) - && !isL2AddressValid(ethernetmatch.getEthernetDestination().getAddress().getValue())) { - logger.error("Ethernet destination address is not valid. Example: 00:05:b9:7c:81:5f", - ethernetmatch.getEthernetDestination()); - return false; - } - - if (ethernetmatch.getEthernetType() != null) { - long type = ethernetmatch.getEthernetType().getType().getValue().longValue(); - if ((type < 0) || (type > 0xffff)) { - logger.error("Ethernet type is not valid"); - return false; - } else { - if (type == 0x0800) { - etype = EtherIPType.V4; - } else if (type == 0x86dd) { - etype = EtherIPType.V6; - } - } - - } - } - - if (layer3match != null) { - if (layer3match instanceof Ipv4Match) { - if (((Ipv4Match) layer3match).getIpv4Source() != null) { - if (NetUtils.isIPv4AddressValid(((Ipv4Match) layer3match).getIpv4Source().getValue())) { - ipsrctype = EtherIPType.V4; - } else { - logger.error("IP source address is not valid"); - return false; - } - - } else if (((Ipv4Match) layer3match).getIpv4Destination() != null) { - if (NetUtils.isIPv4AddressValid(((Ipv4Match) layer3match).getIpv4Destination().getValue())) { - ipdsttype = EtherIPType.V4; - } else { - logger.error("IP Destination address is not valid"); - return false; - } - - } - } else if (layer3match instanceof Ipv6Match) { - if (((Ipv6Match) layer3match).getIpv6Source() != null) { - if (NetUtils.isIPv6AddressValid(((Ipv6Match) layer3match).getIpv6Source().getValue())) { - ipsrctype = EtherIPType.V6; - } else { - logger.error("IPv6 source address is not valid"); - return false; - } - - } else if (((Ipv6Match) layer3match).getIpv6Destination() != null) { - if (NetUtils.isIPv6AddressValid(((Ipv6Match) layer3match).getIpv6Destination().getValue())) { - ipdsttype = EtherIPType.V6; - } else { - logger.error("IPv6 Destination address is not valid"); - return false; - } - - } - - } - - if (etype != EtherIPType.ANY) { - if ((ipsrctype != EtherIPType.ANY) && (ipsrctype != etype)) { - logger.error("Type mismatch between Ethernet & Src IP"); - return false; - } - if ((ipdsttype != EtherIPType.ANY) && (ipdsttype != etype)) { - logger.error("Type mismatch between Ethernet & Dst IP"); - return false; - } - } - if (ipsrctype != ipdsttype) { - if (!((ipsrctype == EtherIPType.ANY) || (ipdsttype == EtherIPType.ANY))) { - logger.error("IP Src Dest Type mismatch"); - return false; - } - } - } - - if (ipmatch != null) { - if (ipmatch.getIpProtocol() != null && !(isProtocolValid(ipmatch.getIpProtocol().toString()))) { - logger.error("Protocol is not valid"); - return false; - } - - } - - if (vlanmatch != null) { - if (vlanmatch.getVlanId() != null - && !(isVlanIdValid(vlanmatch.getVlanId().getVlanId().getValue().toString()))) { - logger.error("Vlan ID is not in the range 0 - 4095"); - return false; - } - - if (vlanmatch.getVlanPcp() != null - && !(isVlanPriorityValid(vlanmatch.getVlanPcp().getValue().toString()))) { - logger.error("Vlan priority is not in the range 0 - 7"); - return false; - } - } - - } - - return true; - - } - - public static boolean validateActions(List actions) { - - if (actions == null || actions.isEmpty()) { - logger.error("Actions value is null or empty"); - return false; - } - - for (Action curaction : actions) { - org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = curaction - .getAction(); - if (action instanceof ControllerActionCase) { - Integer length = ((ControllerActionCase) action).getControllerAction().getMaxLength(); - if (length < 0 || length > 65294) { - logger.error("Controller: MaxLength is not valid"); - return false; - } - } else if (action instanceof OutputActionCase) { - Integer length = ((OutputActionCase) action).getOutputAction().getMaxLength(); - Uri outputnodeconnector = ((OutputActionCase) action).getOutputAction().getOutputNodeConnector(); - if (length < 0 || length > 65294) { - logger.error("OutputAction: MaxLength is not valid"); - return false; - } - if (outputnodeconnector != null) { - if (!outputnodeconnector.getValue().equals(NodeConnectorIDType.ALL) - || !outputnodeconnector.getValue().equals(NodeConnectorIDType.CONTROLLER) - || !outputnodeconnector.getValue().equals(NodeConnectorIDType.HWPATH) - || !outputnodeconnector.getValue().equals(NodeConnectorIDType.ONEPK) - || !outputnodeconnector.getValue().equals(NodeConnectorIDType.ONEPK2OPENFLOW) - || !outputnodeconnector.getValue().equals(NodeConnectorIDType.ONEPK2PCEP) - || !outputnodeconnector.getValue().equals(NodeConnectorIDType.OPENFLOW) - || !outputnodeconnector.getValue().equals(NodeConnectorIDType.OPENFLOW2ONEPK) - || !outputnodeconnector.getValue().equals(NodeConnectorIDType.OPENFLOW2PCEP) - || !outputnodeconnector.getValue().equals(NodeConnectorIDType.PCEP) - || !outputnodeconnector.getValue().equals(NodeConnectorIDType.PCEP2ONEPK) - || !outputnodeconnector.getValue().equals(NodeConnectorIDType.PCEP2OPENFLOW) - || !outputnodeconnector.getValue().equals(NodeConnectorIDType.PRODUCTION) - || !outputnodeconnector.getValue().equals(NodeConnectorIDType.SWSTACK)) { - logger.error("Output Action: NodeConnector Type is not valid"); - return false; - } - - } - } else if (action instanceof PushMplsActionCase) { - Integer ethertype = ((PushMplsActionCase) action).getPushMplsAction().getEthernetType(); - if (ethertype != null && ethertype != 0x8847 && ethertype != 0x8848) { - logger.error("Ether Type is not valid for PushMplsAction"); - return false; - } - } else if (action instanceof PushPbbActionCase) { - Integer ethertype = ((PushPbbActionCase) action).getPushPbbAction().getEthernetType(); - if (ethertype != null && ethertype != 0x88E7) { - logger.error("Ether type is not valid for PushPbbAction"); - return false; - } - } else if (action instanceof PushVlanActionCase) { - Integer ethertype = ((PushVlanActionCase) action).getPushVlanAction().getEthernetType(); - if (ethertype != null && ethertype != 0x8100 && ethertype != 0x88a8) { - logger.error("Ether Type is not valid for PushVlanAction"); - return false; - } - } else if (action instanceof SetDlDstActionCase || action instanceof SetDlSrcActionCase) { - MacAddress address = ((SetDlDstActionCase) action).getSetDlDstAction().getAddress(); - if (address != null && !isL2AddressValid(address.getValue())) { - logger.error("SetDlDstAction: Address not valid"); - return false; - } - } else if (action instanceof SetDlSrcActionCase) { - MacAddress address = ((SetDlSrcActionCase) action).getSetDlSrcAction().getAddress(); - if (address != null && !isL2AddressValid(address.getValue())) { - logger.error("SetDlSrcAction: Address not valid"); - return false; - } - } else if (action instanceof SetQueueActionCase) { - String queue = ((SetQueueActionCase) action).getSetQueueAction().getQueue(); - if (queue != null && !isQueueValid(queue)) { - logger.error("Queue Id not valid"); - return false; - } - } else if (action instanceof SetTpDstActionCase) { - PortNumber port = ((SetTpDstActionCase) action).getSetTpDstAction().getPort(); - if (port != null && !isPortValid(port)) { - logger.error("Port not valid"); - } - } else if (action instanceof SetTpSrcActionCase) { - PortNumber port = ((SetTpSrcActionCase) action).getSetTpSrcAction().getPort(); - if (port != null && !isPortValid(port)) { - logger.error("Port not valid"); - } - } else if (action instanceof SetVlanIdActionCase) { - VlanId vlanid = ((SetVlanIdActionCase) action).getSetVlanIdAction().getVlanId(); - if (vlanid != null && !isVlanIdValid(vlanid.toString())) { - logger.error("Vlan ID %s is not in the range 0 - 4095"); - return false; - } - } else if (action instanceof SetVlanPcpActionCase) { - VlanPcp vlanpcp = ((SetVlanPcpActionCase) action).getSetVlanPcpAction().getVlanPcp(); - if (vlanpcp != null && !isVlanPriorityValid(vlanpcp.toString())) { - logger.error("Vlan priority %s is not in the range 0 - 7"); - return false; - } - } - } - return true; - - } - - public static boolean validateInstructions(Flow flow) { - List instructionsList = new ArrayList<>(); - Instructions instructions = flow.getInstructions(); - if (instructions == null) { - return false; - } - instructionsList = instructions.getInstruction(); - - for (Instruction instruction : instructionsList) { - org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction - .getInstruction(); - if (curInstruction instanceof GoToTableCase) { - - Short tableid = ((GoToTableCase) curInstruction).getGoToTable().getTableId(); - if (tableid < 0) { - logger.error("table id is not valid"); - return false; - } - } - - else if (curInstruction instanceof WriteActionsCase) { - - List action = ((WriteActionsCase) curInstruction).getWriteActions().getAction(); - validateActions(action); - - } - - else if (curInstruction instanceof ApplyActionsCase) { - List action = ((ApplyActionsCase) curInstruction).getApplyActions().getAction(); - validateActions(action); - } - - else if (curInstruction instanceof ClearActionsCase) { - List action = ((ClearActionsCase) curInstruction).getClearActions().getAction(); - validateActions(action); - } - - else if (curInstruction instanceof MeterCase) { - - MeterId meter = ((MeterCase) curInstruction).getMeter().getMeterId(); - if (meter != null && !isValidMeter(meter)) { - logger.error("Meter Id is not valid"); - return false; - } - } - - } - - return true; - } - - public static boolean isValidMeter(MeterId meter) { - // TODO - return true; - } - - public static boolean isQueueValid(String queue) { - // TODO - return true; - } - - public static boolean isPortValid(PortNumber port) { - // TODO - return true; - } - - public static boolean isL2AddressValid(String mac) { - if (mac == null) { - return false; - } - - Pattern macPattern = Pattern.compile("([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}"); - Matcher mm = macPattern.matcher(mac); - if (!mm.matches()) { - logger.debug("Ethernet address {} is not valid. Example: 00:05:b9:7c:81:5f", mac); - return false; - } - return true; - } - - public static boolean isProtocolValid(String protocol) { - IPProtocols proto = IPProtocols.fromString(protocol); - return (proto != null); - } - - public static boolean isVlanIdValid(String vlanId) { - int vlan = Integer.decode(vlanId); - return ((vlan >= 0) && (vlan < 4096)); - } - - public static boolean isVlanPriorityValid(String vlanPriority) { - int pri = Integer.decode(vlanPriority); - return ((pri >= 0) && (pri < 8)); - } -} diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FlowConsumerImpl.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FlowConsumerImpl.java deleted file mode 100644 index d2f2420a7c..0000000000 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/FlowConsumerImpl.java +++ /dev/null @@ -1,365 +0,0 @@ -package org.opendaylight.controller.forwardingrulesmanager.consumer.impl; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; - -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction; -import org.opendaylight.controller.md.sal.common.api.data.DataModification; -import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.Flows; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.config.rev131024.Tables; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.config.rev131024.tables.Table; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.config.rev131024.tables.TableBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.config.rev131024.tables.TableKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableRef; -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.NotificationListener; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FlowConsumerImpl { - protected static final Logger logger = LoggerFactory.getLogger(FlowConsumerImpl.class); - private final FlowEventListener flowEventListener = new FlowEventListener(); - private Registration listener1Reg; - private SalFlowService flowService; - // private FlowDataListener listener; - private FlowDataCommitHandler commitHandler; - - public FlowConsumerImpl() { - InstanceIdentifier path = InstanceIdentifier.builder(Flows.class).toInstance(); - flowService = FRMConsumerImpl.getProviderSession().getRpcService(SalFlowService.class); - - if (null == flowService) { - logger.error("Consumer SAL Service is down or NULL. FRM may not function as intended"); - return; - } - - // For switch events - listener1Reg = FRMConsumerImpl.getNotificationService().registerNotificationListener(flowEventListener); - - if (null == listener1Reg) { - logger.error("Listener to listen on flow data modifcation events"); - return; - } - // addFlowTest(); - commitHandler = new FlowDataCommitHandler(); - FRMConsumerImpl.getDataProviderService().registerCommitHandler(path, commitHandler); - } - - /** - * Adds flow to the southbound plugin and our internal database - * - * @param path - * @param dataObject - */ - private void addFlow(InstanceIdentifier path, Flow dataObject) { - - AddFlowInputBuilder input = new AddFlowInputBuilder(); - input.fieldsFrom(dataObject); - input.setNode((dataObject).getNode()); - input.setFlowTable(new FlowTableRef(createTableInstance(dataObject.getId(), dataObject.getNode()))); - // We send flow to the sounthbound plugin - flowService.addFlow(input.build()); - } - - /** - * Removes flow to the southbound plugin and our internal database - * - * @param path - * @param dataObject - */ - private void removeFlow(InstanceIdentifier path, Flow dataObject) { - - RemoveFlowInputBuilder input = new RemoveFlowInputBuilder(); - input.fieldsFrom(dataObject); - input.setNode((dataObject).getNode()); - input.setTableId(dataObject.getTableId()); - input.setFlowTable(new FlowTableRef(createTableInstance((long)dataObject.getTableId(), (dataObject).getNode()))); - // We send flow to the sounthbound plugin - flowService.removeFlow(input.build()); - } - - /** - * Update flow to the southbound plugin and our internal database - * - * @param path - * @param dataObject - */ - private void updateFlow(InstanceIdentifier path, Flow updatedFlow, Flow originalFlow) { - - UpdateFlowInputBuilder input = new UpdateFlowInputBuilder(); - UpdatedFlowBuilder updatedflowbuilder = new UpdatedFlowBuilder(); - updatedflowbuilder.fieldsFrom(updatedFlow); - input.setNode(updatedFlow.getNode()); - input.setUpdatedFlow(updatedflowbuilder.build()); - OriginalFlowBuilder ofb = new OriginalFlowBuilder(originalFlow); - input.setOriginalFlow(ofb.build()); - // We send flow to the sounthbound plugin - flowService.updateFlow(input.build()); - } - - private void commitToPlugin(internalTransaction transaction) { - Set, DataObject>> createdEntries = transaction.getModification() - .getCreatedConfigurationData().entrySet(); - - /* - * This little dance is because updatedEntries contains both created and - * modified entries The reason I created a new HashSet is because the - * collections we are returned are immutable. - */ - Set, DataObject>> updatedEntries = new HashSet, DataObject>>(); - updatedEntries.addAll(transaction.getModification().getUpdatedConfigurationData().entrySet()); - updatedEntries.removeAll(createdEntries); - - Set> removeEntriesInstanceIdentifiers = transaction.getModification() - .getRemovedConfigurationData(); - transaction.getModification().getOriginalConfigurationData(); - for (Entry, DataObject> entry : createdEntries) { - if (entry.getValue() instanceof Flow) { - logger.debug("Coming add cc in FlowDatacommitHandler"); - Flow flow = (Flow) entry.getValue(); - boolean status = validate(flow); - if (!status) { - return; - } - addFlow(entry.getKey(), (Flow) entry.getValue()); - } - } - - for (Entry, DataObject> entry : updatedEntries) { - if (entry.getValue() instanceof Flow) { - logger.debug("Coming update cc in FlowDatacommitHandler"); - Flow updatedFlow = (Flow) entry.getValue(); - Flow originalFlow = (Flow) transaction.modification.getOriginalConfigurationData().get(entry.getKey()); - boolean status = validate(updatedFlow); - if (!status) { - return; - } - updateFlow(entry.getKey(), updatedFlow, originalFlow); - } - } - - for (InstanceIdentifier instanceId : removeEntriesInstanceIdentifiers) { - DataObject removeValue = transaction.getModification().getOriginalConfigurationData().get(instanceId); - if (removeValue instanceof Flow) { - logger.debug("Coming remove cc in FlowDatacommitHandler"); - Flow flow = (Flow) removeValue; - boolean status = validate(flow); - - if (!status) { - return; - } - - removeFlow(instanceId, (Flow) removeValue); - } - } - } - - private final class FlowDataCommitHandler implements DataCommitHandler, DataObject> { - - @SuppressWarnings("unchecked") - public DataCommitTransaction, DataObject> requestCommit(DataModification, DataObject> modification) { - // We should verify transaction - logger.debug("Coming in FlowDatacommitHandler"); - internalTransaction transaction = new internalTransaction(modification); - transaction.prepareUpdate(); - return transaction; - } - } - - private final class internalTransaction implements DataCommitTransaction, DataObject> { - - private final DataModification, DataObject> modification; - - @Override - public DataModification, DataObject> getModification() { - return modification; - } - - public internalTransaction(DataModification, DataObject> modification) { - this.modification = modification; - } - - /** - * We create a plan which flows will be added, which will be updated and - * which will be removed based on our internal state. - * - */ - void prepareUpdate() { - - } - - /** - * We are OK to go with execution of plan - * - */ - @Override - public RpcResult finish() throws IllegalStateException { - commitToPlugin(this); - return Rpcs.getRpcResult(true, null, Collections. emptySet()); - } - - /** - * - * We should rollback our preparation - * - */ - @Override - public RpcResult rollback() throws IllegalStateException { - rollBackFlows(modification); - return Rpcs.getRpcResult(true, null, Collections. emptySet()); - - } - } - - private void rollBackFlows(DataModification, DataObject> modification) { - Set, DataObject>> createdEntries = modification.getCreatedConfigurationData().entrySet(); - - /* - * This little dance is because updatedEntries contains both created and modified entries - * The reason I created a new HashSet is because the collections we are returned are immutable. - */ - Set, DataObject>> updatedEntries = new HashSet, DataObject>>(); - updatedEntries.addAll(modification.getUpdatedConfigurationData().entrySet()); - updatedEntries.removeAll(createdEntries); - - Set> removeEntriesInstanceIdentifiers = modification.getRemovedConfigurationData(); - for (Entry, DataObject> entry : createdEntries) { - if(entry.getValue() instanceof Flow) { - removeFlow(entry.getKey(),(Flow) entry.getValue()); // because we are rolling back, remove what we would have added. - } - } - - for (Entry, DataObject> entry : updatedEntries) { - if(entry.getValue() instanceof Flow) { - Flow updatedFlow = (Flow) entry.getValue(); - Flow originalFlow = (Flow) modification.getOriginalConfigurationData().get(entry.getKey()); - updateFlow(entry.getKey(), updatedFlow ,originalFlow);// because we are rolling back, replace the updated with the original - } - } - - for (InstanceIdentifier instanceId : removeEntriesInstanceIdentifiers ) { - DataObject removeValue = (Flow) modification.getOriginalConfigurationData().get(instanceId); - if(removeValue instanceof Flow) { - addFlow(instanceId,(Flow) removeValue);// because we are rolling back, add what we would have removed. - - } - } -} - final class FlowEventListener implements SalFlowListener { - - List addedFlows = new ArrayList<>(); - List removedFlows = new ArrayList<>(); - List updatedFlows = new ArrayList<>(); - - @Override - public void onFlowAdded(FlowAdded notification) { - addedFlows.add(notification); - } - - @Override - public void onFlowRemoved(FlowRemoved notification) { - removedFlows.add(notification); - } - - @Override - public void onFlowUpdated(FlowUpdated notification) { - updatedFlows.add(notification); - } - - @Override - public void onNodeErrorNotification(NodeErrorNotification notification) { - // TODO Auto-generated method stub - - } - - @Override - public void onNodeExperimenterErrorNotification(NodeExperimenterErrorNotification notification) { - // TODO Auto-generated method stub - - } - - @Override - public void onSwitchFlowRemoved(SwitchFlowRemoved notification) { - // TODO Auto-generated method stub - - } - } - - public boolean validate(Flow flow) { - String msg = ""; // Specific part of warn/error log - - boolean result = true; - // flow Name validation - if (!FRMUtil.isNameValid(flow.getFlowName())) { - msg = "Invalid Flow name"; - result = false; - } - - // Node Validation - if (result == true && flow.getNode() == null) { - msg = "Node is null"; - result = false; - } - - // TODO: Validate we are seeking to program a flow against a valid - // Node - - if (result == true && flow.getPriority() != null) { - if (flow.getPriority() < 0 || flow.getPriority() > 65535) { - msg = String.format("priority %s is not in the range 0 - 65535", flow.getPriority()); - result = false; - } - } - - if (!FRMUtil.validateMatch(flow)) { - logger.error("Not a valid Match"); - result = false; - } - if (!FRMUtil.validateInstructions(flow)) { - logger.error("Not a valid Instruction"); - result = false; - } - if (result == false) { - logger.warn("Invalid Configuration for flow {}. The failure is {}", flow, msg); - logger.error("Invalid Configuration ({})", msg); - } - return result; - } - - private InstanceIdentifier createTableInstance(Long tableId, NodeRef nodeRef) { - Table table; - InstanceIdentifier tableInstance; - TableBuilder builder = new TableBuilder(); - builder.setId(tableId); - builder.setKey(new TableKey(tableId, nodeRef)); - table = builder.build(); - tableInstance = InstanceIdentifier.builder(Tables.class).child(Table.class, table.getKey()).toInstance(); - return tableInstance; - } -} \ No newline at end of file diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/GroupConsumerImpl.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/GroupConsumerImpl.java deleted file mode 100644 index f4064f22ce..0000000000 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/GroupConsumerImpl.java +++ /dev/null @@ -1,323 +0,0 @@ -package org.opendaylight.controller.forwardingrulesmanager.consumer.impl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import org.opendaylight.controller.clustering.services.CacheConfigException; -import org.opendaylight.controller.clustering.services.CacheExistException; -import org.opendaylight.controller.clustering.services.IClusterContainerServices; -import org.opendaylight.controller.clustering.services.IClusterServices; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction; -import org.opendaylight.controller.md.sal.common.api.data.DataModification; -import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.controller.sal.core.IContainer; -import org.opendaylight.controller.sal.core.Node; -import org.opendaylight.controller.sal.utils.GlobalConstants; -import org.opendaylight.controller.sal.utils.Status; -import org.opendaylight.controller.sal.utils.StatusCode; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.config.rev131024.Groups; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.config.rev131024.groups.Group; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.config.rev131024.groups.GroupKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupAdded; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemoved; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdated; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupListener; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroupBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket; -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.NotificationListener; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@SuppressWarnings("unused") -public class GroupConsumerImpl { - - protected static final Logger logger = LoggerFactory.getLogger(GroupConsumerImpl.class); - private final GroupEventListener groupEventListener = new GroupEventListener(); - private Registration groupListener; - private SalGroupService groupService; - private GroupDataCommitHandler groupCommitHandler; - - private IContainer container; - - public GroupConsumerImpl() { - - InstanceIdentifier path = InstanceIdentifier.builder(Groups.class).toInstance(); - groupService = FRMConsumerImpl.getProviderSession().getRpcService(SalGroupService.class); - - if (null == groupService) { - logger.error("Consumer SAL Group Service is down or NULL. FRM may not function as intended"); - System.out.println("Consumer SAL Group Service is down or NULL."); - return; - } - - // For switch events - groupListener = FRMConsumerImpl.getNotificationService().registerNotificationListener(groupEventListener); - - if (null == groupListener) { - logger.error("Listener to listen on group data modifcation events"); - System.out.println("Listener to listen on group data modifcation events."); - return; - } - - groupCommitHandler = new GroupDataCommitHandler(); - FRMConsumerImpl.getDataProviderService().registerCommitHandler(path, groupCommitHandler); - } - - public Status validateGroup(Group group) { - String groupName; - Iterator bucketIterator; - boolean returnResult; - Buckets groupBuckets; - - if (null != group) { - groupName = group.getGroupName(); - if (!FRMUtil.isNameValid(groupName)) { - logger.error("Group Name is invalid %s" + groupName); - return new Status(StatusCode.BADREQUEST, "Group Name is invalid"); - } - - if (!(group.getGroupType().getIntValue() >= GroupTypes.GroupAll.getIntValue() && group.getGroupType() - .getIntValue() <= GroupTypes.GroupFf.getIntValue())) { - logger.error("Invalid Group type %d" + group.getGroupType().getIntValue()); - return new Status(StatusCode.BADREQUEST, "Invalid Group type"); - } - - groupBuckets = group.getBuckets(); - - if (null != groupBuckets && null != groupBuckets.getBucket()) { - bucketIterator = groupBuckets.getBucket().iterator(); - - while (bucketIterator.hasNext()) { - if (!(FRMUtil.validateActions(bucketIterator.next().getAction()))) { - logger.error("Error in action bucket"); - return new Status(StatusCode.BADREQUEST, "Invalid Group bucket contents"); - } - } - } - } - - return new Status(StatusCode.SUCCESS); - } - - /** - * Update Group entries to the southbound plugin/inventory and our internal - * database - * - * @param path - * @param dataObject - */ - private void updateGroup(InstanceIdentifier path, - Group updatedGroupDataObject, Group originalGroupDataObject) { - UpdatedGroupBuilder updateGroupBuilder = null; - Status groupOperationStatus = validateGroup(updatedGroupDataObject); - - if (!groupOperationStatus.isSuccess()) { - logger.error("Group data object validation failed %s" + updatedGroupDataObject.getGroupName()); - return; - } - - UpdateGroupInputBuilder groupInputBuilder = new UpdateGroupInputBuilder(); - updateGroupBuilder = new UpdatedGroupBuilder(updatedGroupDataObject); - updateGroupBuilder.setGroupId(new GroupId(updatedGroupDataObject.getId())); - groupInputBuilder.setNode(updatedGroupDataObject.getNode()); - groupInputBuilder.setUpdatedGroup(updateGroupBuilder.build()); - OriginalGroupBuilder originalGroupBuilder = new OriginalGroupBuilder(originalGroupDataObject); - groupInputBuilder.setOriginalGroup(originalGroupBuilder.build()); - groupService.updateGroup(groupInputBuilder.build()); - return; - } - - /** - * Adds Group to the southbound plugin and our internal database - * - * @param path - * @param dataObject - */ - private void addGroup(InstanceIdentifier path, Group groupAddDataObject) { - GroupKey groupKey = groupAddDataObject.getKey(); - Status groupOperationStatus = validateGroup(groupAddDataObject); - - if (!groupOperationStatus.isSuccess()) { - logger.error("Group data object validation failed %s" + groupAddDataObject.getGroupName()); - return; - } - - AddGroupInputBuilder groupData = new AddGroupInputBuilder(); - groupData.fieldsFrom(groupAddDataObject); - groupData.setGroupId(new GroupId(groupAddDataObject.getId())); - groupData.setNode(groupAddDataObject.getNode()); - groupService.addGroup(groupData.build()); - return; - } - - /** - * Remove Group to the southbound plugin and our internal database - * - * @param path - * @param dataObject - */ - private void removeGroup(InstanceIdentifier path, Group groupRemoveDataObject) { - GroupKey groupKey = groupRemoveDataObject.getKey(); - Status groupOperationStatus = validateGroup(groupRemoveDataObject); - - if (!groupOperationStatus.isSuccess()) { - logger.error("Group data object validation failed %s" + groupRemoveDataObject.getGroupName()); - return; - } - - RemoveGroupInputBuilder groupData = new RemoveGroupInputBuilder(); - groupData.fieldsFrom(groupRemoveDataObject); - groupData.setGroupId(new GroupId(groupRemoveDataObject.getId())); - groupData.setNode(groupRemoveDataObject.getNode()); - groupService.removeGroup(groupData.build()); - return; - } - - private RpcResult commitToPlugin(InternalTransaction transaction) { - DataModification, DataObject> modification = transaction.modification; - //get created entries - Set, DataObject>> createdEntries = - modification.getCreatedConfigurationData().entrySet(); - - //get updated entries - Set, DataObject>> updatedEntries = - new HashSet, DataObject>>(); - - updatedEntries.addAll(modification.getUpdatedConfigurationData().entrySet()); - updatedEntries.removeAll(createdEntries); - - //get removed entries - Set> removeEntriesInstanceIdentifiers = - modification.getRemovedConfigurationData(); - - for (Entry, DataObject> entry : createdEntries) { - if(entry.getValue() instanceof Group) { - addGroup(entry.getKey(), (Group)entry.getValue()); - } - } - - for (Entry, DataObject> entry : updatedEntries) { - if(entry.getValue() instanceof Group) { - Group originalGroup = (Group) modification.getOriginalConfigurationData().get(entry.getKey()); - Group updatedGroup = (Group) entry.getValue(); - updateGroup(entry.getKey(), originalGroup, updatedGroup); - } - } - - for (InstanceIdentifier instanceId : removeEntriesInstanceIdentifiers ) { - DataObject removeValue = modification.getOriginalConfigurationData().get(instanceId); - if(removeValue instanceof Group) { - removeGroup(instanceId, (Group)removeValue); - } - } - - return Rpcs.getRpcResult(true, null, Collections.emptySet()); - } - - private final class GroupDataCommitHandler implements DataCommitHandler, DataObject> { - - @Override - public DataCommitTransaction, DataObject> requestCommit( - DataModification, DataObject> modification) { - InternalTransaction transaction = new InternalTransaction(modification); - transaction.prepareUpdate(); - return transaction; - } - } - - private final class InternalTransaction implements DataCommitTransaction, DataObject> { - - private final DataModification, DataObject> modification; - - public InternalTransaction(DataModification, DataObject> modification) { - this.modification = modification; - } - - /** - * We create a plan which flows will be added, which will be updated and - * which will be removed based on our internal state. - * - */ - void prepareUpdate() { - - } - - /** - * We are OK to go with execution of plan - * - */ - @Override - public RpcResult finish() throws IllegalStateException { - - RpcResult rpcStatus = commitToPlugin(this); - return rpcStatus; - } - - /** - * - * We should rollback our preparation - * - */ - @Override - public RpcResult rollback() throws IllegalStateException { - - ///needs to be implemented as per gerrit 3314 - return Rpcs.getRpcResult(true, null, Collections.emptySet()); - } - - @Override - public DataModification, DataObject> getModification() { - return modification; - } - - } - - final class GroupEventListener implements SalGroupListener { - - List addedGroups = new ArrayList<>(); - List removedGroups = new ArrayList<>(); - List updatedGroups = new ArrayList<>(); - - @Override - public void onGroupAdded(GroupAdded notification) { - addedGroups.add(notification); - } - - @Override - public void onGroupRemoved(GroupRemoved notification) { - // TODO Auto-generated method stub - - } - - @Override - public void onGroupUpdated(GroupUpdated notification) { - // TODO Auto-generated method stub - - } - } - } diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/IForwardingRulesManager.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/IForwardingRulesManager.java deleted file mode 100644 index 85ed8d4844..0000000000 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/IForwardingRulesManager.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.opendaylight.controller.forwardingrulesmanager.consumer.impl; - -import java.util.List; - -import org.opendaylight.controller.sal.core.Node; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * Interface that describes methods for accessing the flows database. - */ -public interface IForwardingRulesManager { - - /** - * Returns the specifications of all the flows configured for all the - * switches on the current container - * - * @return the list of flow configurations present in the database - */ - public List get(); - - /** - * Returns the specification of the flow configured for the given network - * node on the current container - * - * @param name - * the flow name - * @param n - * the network node identifier - * @return the {@code FlowConfig} object - */ - public DataObject getWithName(String name, Node n); - -} diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/MeterConsumerImpl.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/MeterConsumerImpl.java deleted file mode 100644 index bf8c8b7f05..0000000000 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/MeterConsumerImpl.java +++ /dev/null @@ -1,337 +0,0 @@ -package org.opendaylight.controller.forwardingrulesmanager.consumer.impl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import org.opendaylight.controller.clustering.services.CacheConfigException; -import org.opendaylight.controller.clustering.services.CacheExistException; -import org.opendaylight.controller.clustering.services.IClusterContainerServices; -import org.opendaylight.controller.clustering.services.IClusterServices; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction; -import org.opendaylight.controller.md.sal.common.api.data.DataModification; -import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.controller.sal.core.IContainer; -import org.opendaylight.controller.sal.core.Node; -import org.opendaylight.controller.sal.utils.GlobalConstants; -import org.opendaylight.controller.sal.utils.Status; -import org.opendaylight.controller.sal.utils.StatusCode; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroupBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.config.rev131024.Meters; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.config.rev131024.meters.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.config.rev131024.meters.MeterKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterAdded; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterRemoved; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdated; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterListener; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.OriginalMeterBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.BandType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemark; -import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter; -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.NotificationListener; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MeterConsumerImpl { - protected static final Logger logger = LoggerFactory.getLogger(MeterConsumerImpl.class); - private final MeterEventListener meterEventListener = new MeterEventListener(); - private Registration meterListener; - private SalMeterService meterService; - private MeterDataCommitHandler commitHandler; - - public MeterConsumerImpl() { - InstanceIdentifier path = InstanceIdentifier.builder(Meters.class).toInstance(); - meterService = FRMConsumerImpl.getProviderSession().getRpcService(SalMeterService.class); - - if (null == meterService) { - logger.error("Consumer SAL Meter Service is down or NULL. FRM may not function as intended"); - System.out.println("Consumer SAL Meter Service is down or NULL."); - return; - } - - // For switch/plugin events - meterListener = FRMConsumerImpl.getNotificationService().registerNotificationListener(meterEventListener); - - if (null == meterListener) { - logger.error("Listener to listen on meter data modifcation events"); - System.out.println("Listener to listen on meter data modifcation events."); - return; - } - - commitHandler = new MeterDataCommitHandler(); - FRMConsumerImpl.getDataProviderService().registerCommitHandler(path, commitHandler); - } - - /** - * Adds Meter to the southbound plugin and our internal database - * - * @param path - * @param dataObject - */ - private Status addMeter(InstanceIdentifier path, Meter meterAddDataObject) { - MeterKey meterKey = meterAddDataObject.getKey(); - - if (null != meterKey && validateMeter(meterAddDataObject).isSuccess()) { - AddMeterInputBuilder meterBuilder = new AddMeterInputBuilder(); - meterBuilder.fieldsFrom(meterAddDataObject); - meterBuilder.setMeterId(new MeterId(meterAddDataObject.getId())); - meterBuilder.setNode(meterAddDataObject.getNode()); - meterService.addMeter(meterBuilder.build()); - } else { - return new Status(StatusCode.BADREQUEST, "Meter Key or attribute validation failed"); - } - - return new Status(StatusCode.SUCCESS); - } - - /* - * Update Meter to the southbound plugin and our internal database - * - * @param path - * - * @param dataObject - */ - private Status updateMeter(InstanceIdentifier path, - Meter updatedMeter, Meter originalMeter) { - UpdatedMeterBuilder updateMeterBuilder = null; - - if (validateMeter(updatedMeter).isSuccess()) { - UpdateMeterInputBuilder updateMeterInputBuilder = new UpdateMeterInputBuilder(); - updateMeterInputBuilder.setNode(updatedMeter.getNode()); - updateMeterBuilder = new UpdatedMeterBuilder(); - updateMeterBuilder.fieldsFrom(updatedMeter); - updateMeterBuilder.setMeterId(new MeterId(updatedMeter.getId())); - updateMeterInputBuilder.setUpdatedMeter(updateMeterBuilder.build()); - OriginalMeterBuilder originalMeterBuilder = new OriginalMeterBuilder(originalMeter); - updateMeterInputBuilder.setOriginalMeter(originalMeterBuilder.build()); - meterService.updateMeter(updateMeterInputBuilder.build()); - } else { - return new Status(StatusCode.BADREQUEST, "Meter Key or attribute validation failed"); - } - - return new Status(StatusCode.SUCCESS); - } - - /* - * Remove Meter to the southbound plugin and our internal database - * - * @param path - * - * @param dataObject - */ - private Status removeMeter(InstanceIdentifier path, Meter meterRemoveDataObject) { - MeterKey meterKey = meterRemoveDataObject.getKey(); - - if (null != meterKey && validateMeter(meterRemoveDataObject).isSuccess()) { - RemoveMeterInputBuilder meterBuilder = new RemoveMeterInputBuilder(); - meterBuilder.fieldsFrom(meterRemoveDataObject); - meterBuilder.setNode(meterRemoveDataObject.getNode()); - meterBuilder.setMeterId(new MeterId(meterRemoveDataObject.getId())); - meterService.removeMeter(meterBuilder.build()); - } else { - return new Status(StatusCode.BADREQUEST, "Meter Key or attribute validation failed"); - } - - return new Status(StatusCode.SUCCESS); - } - - public Status validateMeter(Meter meter) { - String meterName; - Status returnStatus = null; - - if (null != meter) { - meterName = meter.getMeterName(); - if (!FRMUtil.isNameValid(meterName)) { - logger.error("Meter Name is invalid %s" + meterName); - returnStatus = new Status(StatusCode.BADREQUEST, "Meter Name is invalid"); - return returnStatus; - } - - for (int i = 0; i < meter.getMeterBandHeaders().getMeterBandHeader().size(); i++) { - if (null != meter.getFlags() && !meter.getFlags().isMeterBurst()) { - if (0 < meter.getMeterBandHeaders().getMeterBandHeader().get(i).getBurstSize()) { - logger.error("Burst size should only be associated when Burst FLAG is set"); - returnStatus = new Status(StatusCode.BADREQUEST, - "Burst size should only be associated when Burst FLAG is set"); - break; - } - } - } - - if (null != returnStatus && !returnStatus.isSuccess()) { - return returnStatus; - } else if (null != meter.getMeterBandHeaders()) { - BandType setBandType = null; - DscpRemark dscpRemark = null; - for (int i = 0; i < meter.getMeterBandHeaders().getMeterBandHeader().size(); i++) { - setBandType = meter.getMeterBandHeaders().getMeterBandHeader().get(i).getBandType(); - if (setBandType instanceof DscpRemark) { - dscpRemark = (DscpRemark) setBandType; - if (0 > dscpRemark.getRate()) { - - } - } else if (setBandType instanceof Drop) { - if (0 < dscpRemark.getPercLevel()) { - logger.error("Number of drop Precedence level"); - } - } else if (setBandType instanceof Experimenter) { - - } - } - } - } - return new Status(StatusCode.SUCCESS); - } - - private RpcResult commitToPlugin(InternalTransaction transaction) { - DataModification, DataObject> modification = transaction.modification; - //get created entries - Set, DataObject>> createdEntries = - modification.getCreatedConfigurationData().entrySet(); - - //get updated entries - Set, DataObject>> updatedEntries = - new HashSet, DataObject>>(); - - updatedEntries.addAll(modification.getUpdatedConfigurationData().entrySet()); - updatedEntries.removeAll(createdEntries); - - //get removed entries - Set> removeEntriesInstanceIdentifiers = - modification.getRemovedConfigurationData(); - - for (Entry, DataObject> entry : createdEntries) { - if(entry.getValue() instanceof Meter) { - addMeter(entry.getKey(), (Meter)entry.getValue()); - } - } - - for (Entry, DataObject> entry : updatedEntries) { - if(entry.getValue() instanceof Meter) { - Meter originalMeter = (Meter) modification.getOriginalConfigurationData().get(entry.getKey()); - Meter updatedMeter = (Meter) entry.getValue(); - updateMeter(entry.getKey(), originalMeter, updatedMeter); - } - } - - for (InstanceIdentifier instanceId : removeEntriesInstanceIdentifiers ) { - DataObject removeValue = modification.getOriginalConfigurationData().get(instanceId); - if(removeValue instanceof Meter) { - removeMeter(instanceId, (Meter)removeValue); - } - } - - return Rpcs.getRpcResult(true, null, Collections.emptySet()); - } - - final class InternalTransaction implements DataCommitTransaction, DataObject> { - - private final DataModification, DataObject> modification; - - @Override - public DataModification, DataObject> getModification() { - return modification; - } - - public InternalTransaction(DataModification, DataObject> modification) { - this.modification = modification; - } - - /** - * We create a plan which flows will be added, which will be updated and - * which will be removed based on our internal state. - * - */ - void prepareUpdate() { - - } - - /** - * We are OK to go with execution of plan - * - */ - @Override - public RpcResult finish() throws IllegalStateException { - - RpcResult rpcStatus = commitToPlugin(this); - return rpcStatus; - } - - /** - * - * We should rollback our preparation - * - */ - @Override - public RpcResult rollback() throws IllegalStateException { - return Rpcs.getRpcResult(true, null, Collections.emptySet()); - - } - - } - - private final class MeterDataCommitHandler implements DataCommitHandler, DataObject> { - @Override - public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction, DataObject> requestCommit( - DataModification, DataObject> modification) { - // We should verify transaction - InternalTransaction transaction = new InternalTransaction(modification); - transaction.prepareUpdate(); - return transaction; - } - } - - final class MeterEventListener implements SalMeterListener { - - List addedMeter = new ArrayList<>(); - List removeMeter = new ArrayList<>(); - List updatedMeter = new ArrayList<>(); - - @Override - public void onMeterAdded(MeterAdded notification) { - // TODO Auto-generated method stub - - } - - @Override - public void onMeterRemoved(MeterRemoved notification) { - // TODO Auto-generated method stub - - } - - @Override - public void onMeterUpdated(MeterUpdated notification) { - // TODO Auto-generated method stub - - } - } -} diff --git a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/TableFeaturesConsumerImpl.java b/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/TableFeaturesConsumerImpl.java deleted file mode 100644 index 11d1189573..0000000000 --- a/opendaylight/md-sal/forwardingrules-manager/src/main/java/org/opendaylight/controller/forwardingrulesmanager/consumer/impl/TableFeaturesConsumerImpl.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.opendaylight.controller.forwardingrulesmanager.consumer.impl; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.opendaylight.controller.clustering.services.IClusterContainerServices; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction; -import org.opendaylight.controller.md.sal.common.api.data.DataModification; -import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.controller.sal.core.IContainer; -import org.opendaylight.controller.sal.utils.ServiceHelper; -import org.opendaylight.controller.sal.utils.Status; -import org.opendaylight.controller.sal.utils.StatusCode; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.config.rev131024.Tables; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.config.rev131024.tables.Table; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TableFeaturesConsumerImpl { - protected static final Logger logger = LoggerFactory.getLogger(TableFeaturesConsumerImpl.class); - private SalTableService tableService; - private TableDataCommitHandler commitHandler; - private final IClusterContainerServices clusterContainerService = null; - private IContainer container; - private static final String NAMEREGEX = "^[a-zA-Z0-9]+$"; - private boolean inContainerMode; // being used by global instance only - - public TableFeaturesConsumerImpl() { - InstanceIdentifier path = InstanceIdentifier.builder(Tables.class).toInstance(); - tableService = FRMConsumerImpl.getProviderSession().getRpcService(SalTableService.class); - - if (null == tableService) { - logger.error("Consumer SAL Service is down or NULL. FRM may not function as intended"); - System.out.println("Consumer SAL Service is down or NULL."); - return; - } - - System.out.println("-------------------------------------------------------------------"); - commitHandler = new TableDataCommitHandler(); - FRMConsumerImpl.getDataProviderService().registerCommitHandler(path, commitHandler); - container = (IContainer) ServiceHelper.getGlobalInstance(IContainer.class, this); - } - - /** - * Updates TableFeatures to the southbound plugin and our internal database - * - * @param path - * @param dataObject - */ - private void updateTableFeatures(InstanceIdentifier path, TableFeatures dataObject) { - - UpdateTableInputBuilder input = new UpdateTableInputBuilder(); - UpdatedTableBuilder updatedtablebuilder = new UpdatedTableBuilder(); - updatedtablebuilder.fieldsFrom(dataObject); - List features = updatedtablebuilder.build().getTableFeatures(); - for (TableFeatures feature : features) { - if (feature != null && feature.getMaxEntries() != null) { - logger.error("Max Entries field is read-only, cannot be changed"); - return; - } - } - input.setUpdatedTable(updatedtablebuilder.build()); - - // We send table feature update request to the sounthbound plugin - tableService.updateTable(input.build()); - } - - @SuppressWarnings("unchecked") - private void commitToPlugin(internalTransaction transaction) { - - for (@SuppressWarnings("unused") - Entry, TableFeatures> entry : transaction.updates.entrySet()) { - System.out.println("Coming update cc in TableDatacommitHandler"); - updateTableFeatures(entry.getKey(), entry.getValue()); - } - - } - - private final class TableDataCommitHandler implements DataCommitHandler, DataObject> { - - @SuppressWarnings("unchecked") - @Override - public DataCommitTransaction requestCommit(DataModification, DataObject> modification) { - // We should verify transaction - System.out.println("Coming in TableFeaturesDatacommitHandler"); - internalTransaction transaction = new internalTransaction(modification); - transaction.prepareUpdate(); - return transaction; - } - } - - private final class internalTransaction implements DataCommitTransaction, DataObject> { - - private final DataModification, DataObject> modification; - - @Override - public DataModification, DataObject> getModification() { - return modification; - } - - public internalTransaction(DataModification, DataObject> modification) { - this.modification = modification; - } - - Map, TableFeatures> updates = new HashMap<>(); - Map, TableFeatures> createdEntries = new HashMap<>(); - - /** - * We create a plan which table features will be updated. - * - */ - void prepareUpdate() { - Set, DataObject>> createdEntries = modification.getCreatedConfigurationData().entrySet(); - - Set, DataObject>> puts = modification.getUpdatedConfigurationData().entrySet(); - for (Entry, DataObject> entry : puts) { - - // validating the DataObject - - Status status = validate(container, (TableFeatures) entry); - if (!status.isSuccess()) { - logger.warn("Invalid Configuration for table features The failure is {}", entry, - status.getDescription()); - String error = "Invalid Configuration (" + status.getDescription() + ")"; - logger.error(error); - return; - } - if (entry.getValue() instanceof TableFeatures) { - TableFeatures tablefeatures = (TableFeatures) entry.getValue(); - preparePutEntry(entry.getKey(), tablefeatures); - } - - } - } - - private void preparePutEntry(InstanceIdentifier key, TableFeatures tablefeatures) { - if (tablefeatures != null) { - // Updating the Map - System.out.println("Coming update in TableFeaturesDatacommitHandler"); - updates.put(key, tablefeatures); - } - } - - /** - * We are OK to go with execution of plan - * - */ - @Override - public RpcResult finish() throws IllegalStateException { - - commitToPlugin(this); - // We return true if internal transaction is successful. - // return Rpcs.getRpcResult(true, null, Collections.emptySet()); - return Rpcs.getRpcResult(true, null, null); - } - - /** - * - * We should rollback our preparation - * - */ - @Override - public RpcResult rollback() throws IllegalStateException { - // NOOP - we did not modified any internal state during - // requestCommit phase - // return Rpcs.getRpcResult(true, null, Collections.emptySet()); - return Rpcs.getRpcResult(true, null, null); - - } - - public Status validate(IContainer container, TableFeatures dataObject) { - - String tablename = dataObject.getName(); - if (tablename == null || tablename.trim().isEmpty() || !tablename.matches(NAMEREGEX) - || tablename.length() != 32) { - return new Status(StatusCode.BADREQUEST, "Invalid table name"); - } - - return new Status(StatusCode.SUCCESS); - } - } -} -- 2.36.6