/* * Copyright (C) 2013 Red Hat, Inc. * * 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 * * Authors : Madhu Venugopal, Brent Salisbury */ package org.opendaylight.ovsdb.plugin.api; import org.opendaylight.ovsdb.lib.OvsdbClient; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Connection { private Node node; private String identifier; private OvsdbClient client; public Long getIdCounter() { return idCounter; } public void setIdCounter(Long idCounter) { this.idCounter = idCounter; } private Long idCounter; private static final Logger logger = LoggerFactory.getLogger(Connection.class); public Connection(String identifier, OvsdbClient client) { super(); this.identifier = identifier; this.client = client; this.idCounter = 0L; NodeId nodeId = new NodeId("OVS" + "|" + identifier); NodeKey nodeKey = new NodeKey(nodeId); node = new NodeBuilder() .setId(nodeId) .setKey(nodeKey) .build(); } public String getIdentifier() { return identifier; } public void setIdentifier(String identifier) { this.identifier = identifier; } public OvsdbClient getClient() { return this.client; } public void setClient(OvsdbClient client) { this.client = client; } public Node getNode() { return node; } public void setNode(Node node) { this.node = node; } public void disconnect() { client.disconnect(); } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((identifier == null) ? 0 : identifier.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } Connection other = (Connection) obj; if (identifier == null) { if (other.identifier != null) { return false; } } else if (!identifier.equals(other.identifier)) { return false; } return true; } }