From: Chi-Vien Ly Date: Thu, 22 Aug 2013 03:53:25 +0000 (+0000) Subject: Merge "1. Controller switchEvents queue should be priority based. The queue holds... X-Git-Tag: releasepom-0.1.0~188 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=c22c58ddd80d33523482ae75c233bbd6df069959;hp=78ef04c45c5a7fbee9bbb9ae77ecb1882add8623 Merge "1. Controller switchEvents queue should be priority based. The queue holds switch up, down, error and message events. Assign higher priority to switch up/down events. 2. When switch is going to disconnect, SwitchHandler can clean up some internal states to speed up the process in order to avoid unnecessary messages backing up in the queue. 3. In SwitchManager, don't send additional port down notifications after node down event is received. 4. Fixed an issue where links are not recovered when the switch is reconnected to the controller. 5. Fixed TLS exception@java.security.ProviderException." --- diff --git a/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java index 5db7d32745..0304af493d 100644 --- a/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java +++ b/opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java @@ -72,7 +72,7 @@ public class FlowConfig implements Serializable { private static final long serialVersionUID = 1L; private static final Logger log = LoggerFactory.getLogger(FlowConfig.class); private static final String NAMEREGEX = "^[a-zA-Z0-9]+$"; - private static final String STATICFLOWGROUP = "__StaticFlows__"; + public static final String STATICFLOWGROUP = "__StaticFlows__"; public static final String INTERNALSTATICFLOWGROUP = "__InternalStaticFlows__"; public static final String INTERNALSTATICFLOWBEGIN = "__"; public static final String INTERNALSTATICFLOWEND = "__"; diff --git a/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java index 57f3e8eb36..19b045b217 100644 --- a/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java +++ b/opendaylight/forwardingrulesmanager/implementation/src/main/java/org/opendaylight/controller/forwardingrulesmanager/internal/ForwardingRulesManager.java @@ -91,6 +91,7 @@ public class ForwardingRulesManager implements IForwardingRulesManager, PortGrou private static final String NODEDOWN = "Node is Down"; private static final String SUCCESS = StatusCode.SUCCESS.toString(); private static final Logger log = LoggerFactory.getLogger(ForwardingRulesManager.class); + private static final String PORTREMOVED = "Port removed"; private String frmFileName; private String portGroupFileName; private ConcurrentMap staticFlows; @@ -1926,6 +1927,32 @@ public class ForwardingRulesManager implements IForwardingRulesManager, PortGrou } } + private boolean doesFlowContainNodeConnector(Flow flow, NodeConnector nc) { + if (nc == null) { + return false; + } + + Match match = flow.getMatch(); + if (match.isPresent(MatchType.IN_PORT)) { + NodeConnector matchPort = (NodeConnector) match.getField(MatchType.IN_PORT).getValue(); + if (matchPort.equals(nc)) { + return true; + } + } + List actionsList = flow.getActions(); + if (actionsList != null) { + for (Action action : actionsList) { + if (action instanceof Output) { + NodeConnector actionPort = ((Output) action).getPort(); + if (actionPort.equals(nc)) { + return true; + } + } + } + } + return false; + } + @Override public void notifyNode(Node node, UpdateType type, Map propMap) { this.pendingEvents.offer(new NodeUpdateEvent(type, node)); @@ -2269,10 +2296,66 @@ public class ForwardingRulesManager implements IForwardingRulesManager, PortGrou } @Override - public void nodeConnectorUpdated(String containerName, NodeConnector p, UpdateType t) { + public void nodeConnectorUpdated(String containerName, NodeConnector nc, UpdateType t) { if (!container.getName().equals(containerName)) { return; } + + boolean updateStaticFlowCluster = false; + + switch (t) { + case REMOVED: + + List nodeFlowEntries = nodeFlows.get(nc.getNode()); + if (nodeFlowEntries == null) { + return; + } + for (FlowEntryInstall fei : new ArrayList(nodeFlowEntries)) { + if (doesFlowContainNodeConnector(fei.getInstall().getFlow(), nc)) { + Status status = this.removeEntryInternal(fei, true); + if (!status.isSuccess()) { + continue; + } + /* + * If the flow entry is a static flow, then update its + * configuration + */ + if (fei.getGroupName().equals(FlowConfig.STATICFLOWGROUP)) { + FlowConfig flowConfig = getStaticFlow(fei.getFlowName(), fei.getNode()); + if (flowConfig != null) { + flowConfig.setStatus(PORTREMOVED); + updateStaticFlowCluster = true; + } + } + } + } + if (updateStaticFlowCluster) { + refreshClusterStaticFlowsStatus(nc.getNode()); + } + break; + case ADDED: + List flowConfigForNode = getStaticFlows(nc.getNode()); + for (FlowConfig flowConfig : flowConfigForNode) { + if (doesFlowContainNodeConnector(flowConfig.getFlow(), nc)) { + if (flowConfig.installInHw()) { + Status status = this.installFlowEntry(flowConfig.getFlowEntry()); + if (!status.isSuccess()) { + flowConfig.setStatus(status.getDescription()); + } else { + flowConfig.setStatus(SUCCESS); + } + updateStaticFlowCluster = true; + } + } + } + if (updateStaticFlowCluster) { + refreshClusterStaticFlowsStatus(nc.getNode()); + } + break; + case CHANGED: + break; + default: + } } @Override diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/RestMessages.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/RestMessages.java index ebe36a9d78..668efbc7ee 100644 --- a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/RestMessages.java +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/RestMessages.java @@ -9,17 +9,13 @@ package org.opendaylight.controller.northbound.commons; public enum RestMessages { - SUCCESS("Success"), NOCONTAINER("Container does not exist"), NOFLOWSPEC( - "Flow Spec does not exist"), NOSUBNET("Subnet does not exist"), NOSTATICROUTE( - "Static Route does not exist"), NOHOST("Host does not exist"), NOFLOW( - "Flow does not exist"), NONODE("Node does not exist"), NOPOLICY( - "Policy does not exist"), NORESOURCE("Resource does not exist"), RESOURCECONFLICT( - "Operation failed due to Resource Conflict"), NODEFAULT( - "Container default is not a custom container"), DEFAULTDISABLED( + SUCCESS("Success"), NOCONTAINER("Container does not exist"), NOSUBNET("Subnet does not exist"), NOSTATICROUTE( + "Static Route does not exist"), NOHOST("Host does not exist"), NOFLOW("Flow does not exist"), NONODE( + "Node does not exist"), NOPOLICY("Policy does not exist"), NORESOURCE("Resource does not exist"), RESOURCECONFLICT( + "Operation failed due to Resource Conflict"), NODEFAULT("Container default is not a custom container"), DEFAULTDISABLED( "Container(s) are configured. Container default is not operational"), NOTALLOWEDONDEFAULT( - "Container default is a static resource, no modification allowed on it"), UNKNOWNACTION( - "Unknown action"), INVALIDJSON("JSON message is invalid"), INVALIDADDRESS( - "invalid InetAddress"), AVAILABLESOON( + "Container default is a static resource, no modification allowed on it"), UNKNOWNACTION("Unknown action"), INVALIDJSON( + "JSON message is invalid"), INVALIDADDRESS("invalid InetAddress"), AVAILABLESOON( "Resource is not implemented yet"), INTERNALERROR("Internal Error"), SERVICEUNAVAILABLE( "Service is not available. Could be down for maintanence"), INVALIDDATA( "Data is invalid or conflicts with URI"); @@ -30,6 +26,7 @@ public enum RestMessages { message = msg; } + @Override public String toString() { return message; } diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/exception/BadRequestException.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/exception/BadRequestException.java new file mode 100644 index 0000000000..c1b832d3c6 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/exception/BadRequestException.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2013 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.exception; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +/** + * Status Code 400 (Bad Request) + * + * The request could not be understood by the server due to malformed syntax. + * The client SHOULD NOT repeat the request without modifications. + */ +public class BadRequestException extends WebApplicationException { + private static final long serialVersionUID = 1L; + + public BadRequestException(String string) { + super(Response.status(Response.Status.BAD_REQUEST).entity(string).type(MediaType.TEXT_PLAIN).build()); + } +} diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/exception/NotImplemented.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/exception/NotImplemented.java new file mode 100644 index 0000000000..16d0cd6e29 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/exception/NotImplemented.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2013 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.exception; + +import javax.ws.rs.core.Response; + +/** + * Implementation of StatusType for error 501 as in: + * http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.6 + */ +public class NotImplemented implements Response.StatusType { + @Override + public int getStatusCode() { + return 501; + } + + @Override + public String getReasonPhrase() { + return "Not Implemented"; + } + + @Override + public Response.Status.Family getFamily() { + return Response.Status.Family.SERVER_ERROR; + } +} \ No newline at end of file diff --git a/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/exception/NotImplementedException.java b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/exception/NotImplementedException.java new file mode 100644 index 0000000000..5c931d2b47 --- /dev/null +++ b/opendaylight/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/exception/NotImplementedException.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2013 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.exception; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +/** + * Status Code 501 (Not Implemented) + * + * The server does not support the functionality required to fulfill the + * request. This is the appropriate response when the server does not recognize + * the request method and is not capable of supporting it for any resource. + */ +public class NotImplementedException extends WebApplicationException { + private static final long serialVersionUID = 1L; + + public NotImplementedException(String string) { + super(Response.status(new NotImplemented()).entity(string).type(MediaType.TEXT_PLAIN).build()); + } +} diff --git a/opendaylight/web/devices/src/main/resources/js/page.js b/opendaylight/web/devices/src/main/resources/js/page.js index 824d2e9b85..6916be6798 100644 --- a/opendaylight/web/devices/src/main/resources/js/page.js +++ b/opendaylight/web/devices/src/main/resources/js/page.js @@ -74,6 +74,7 @@ one.f.switchmanager.nodesLearnt = { }, modal: { modal: "one_f_switchmanager_nodesLearnt_id_modal_modal", + configure: "one_f_switchmanager_nodesLearnt_id_modal_configure", ports: "one_f_switchmanager_nodesLearnt_id_modal_ports", save: "one_f_switchmanager_nodesLearnt_id_modal_save", datagrid: "one_f_switchmanager_nodesLearnt_id_modal_datagrid", @@ -137,7 +138,7 @@ one.f.switchmanager.nodesLearnt = { h3 = 'Node Information'; } - var $modal = one.lib.modal.spawn(one.f.switchmanager.nodesLearnt.id.modal.modal, h3, "", footer); + var $modal = one.lib.modal.spawn(one.f.switchmanager.nodesLearnt.id.modal.configure, h3, "", footer); // bind save button $('#' + one.f.switchmanager.nodesLearnt.id.modal.save, $modal).click(function() { one.f.switchmanager.nodesLearnt.modal.save($modal); @@ -166,7 +167,8 @@ one.f.switchmanager.nodesLearnt = { searchable: true, filterable: false, pagination: true, - flexibleRowsPerPage: true + flexibleRowsPerPage: true, + popout: true }, "table-striped table-condensed"); one.lib.modal.inject.body($modal, $gridHTML); $modal.on("shown", function() { @@ -222,7 +224,8 @@ one.f.switchmanager.nodesLearnt = { searchable: true, filterable: false, pagination: true, - flexibleRowsPerPage: true + flexibleRowsPerPage: true, + popout: true }, "table-striped table-condensed"); one.lib.modal.inject.body($modal, $gridHTML); // attach to shown event of modal diff --git a/opendaylight/web/flows/src/main/resources/js/page.js b/opendaylight/web/flows/src/main/resources/js/page.js index 2a2dbf5b4d..0f1eabb859 100644 --- a/opendaylight/web/flows/src/main/resources/js/page.js +++ b/opendaylight/web/flows/src/main/resources/js/page.js @@ -343,11 +343,13 @@ one.f.flows = { $tr = $(tr); $span = $("td span", $tr); var flowstatus = $span.data("flowstatus"); - var installInHw = $span.data("installinhw").toString(); - if(installInHw == "true" && flowstatus == "Success") { - $tr.addClass("success"); - } else { - $tr.addClass("warning"); + if($span.data("installinhw") != null) { + var installInHw = $span.data("installinhw").toString(); + if(installInHw == "true" && flowstatus == "Success") { + $tr.addClass("success"); + } else { + $tr.addClass("warning"); + } } // attach mouseover to show pointer cursor $tr.mouseover(function() { diff --git a/opendaylight/web/root/src/main/resources/js/lib.js b/opendaylight/web/root/src/main/resources/js/lib.js index 9c71262745..90fd49772a 100644 --- a/opendaylight/web/root/src/main/resources/js/lib.js +++ b/opendaylight/web/root/src/main/resources/js/lib.js @@ -99,7 +99,7 @@ one.lib.dashlet = { $headerth.append(one.lib.dashlet.datagrid._searchable()); } if(options.flexibleRowsPerPage == true) { - $footerth.append(one.lib.dashlet.datagrid._rowsPerPage()); + $footerth.append(one.lib.dashlet.datagrid._rowsPerPage(options.popout)); } if(options.pagination == true) { $footerth.append(one.lib.dashlet.datagrid._pagination()); @@ -120,8 +120,12 @@ one.lib.dashlet = { var html = ''; return html; }, - _rowsPerPage: function() { - var html = ''; + _rowsPerPage: function(popout) { + if(popout) { + var html = ''; + } else { + var html = ''; + } return html; } },