2 * Copyright (C) 2013 Red Hat, Inc.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 * Authors : Madhu Venugopal, Brent Salisbury
10 package org.opendaylight.ovsdb.plugin;
12 import org.opendaylight.controller.sal.core.ConstructionException;
13 import org.opendaylight.controller.sal.core.Node;
14 import org.opendaylight.controller.sal.utils.Status;
15 import org.opendaylight.controller.sal.utils.StatusCode;
16 import org.opendaylight.ovsdb.lib.OvsdbClient;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 public class Connection {
22 private String identifier;
23 private OvsdbClient client;
25 public Long getIdCounter() {
29 public void setIdCounter(Long idCounter) {
30 this.idCounter = idCounter;
33 private Long idCounter;
35 private static final Logger logger = LoggerFactory.getLogger(Connection.class);
37 public Connection(String identifier, OvsdbClient client) {
41 this.identifier = identifier;
45 node = new Node("OVS", identifier);
46 } catch (ConstructionException e) {
47 logger.error("Error creating OVS node with identifier " + identifier, e);
51 public String getIdentifier() {
55 public void setIdentifier(String identifier) {
56 this.identifier = identifier;
59 public OvsdbClient getClient() {
63 public void setClient(OvsdbClient client) {
67 public Node getNode() {
71 public void setNode(Node node) {
75 public Status disconnect() {
76 return new Status(StatusCode.SUCCESS);
80 public int hashCode() {
83 result = prime * result + ((identifier == null) ? 0 : identifier.hashCode());
88 public boolean equals(Object obj) {
89 if (this == obj) return true;
90 if (obj == null) return false;
91 if (getClass() != obj.getClass()) return false;
92 Connection other = (Connection) obj;
93 if (identifier == null) {
94 if (other.identifier != null) return false;
95 } else if (!identifier.equals(other.identifier)) return false;