public EdgeBuilder(Edge base) { if (base.getKey() == null) { this._key = new EdgeKey( base.getUuid() ); this._uuid = base.getUuid(); } else { this._key = base.getKey(); this._uuid = _key.getUuid(); this._description = base.getDescription(); this._leftPortId = base.getLeftPortId(); this._name = base.getName(); this._qosAttributes = base.getQosAttributes(); this._rightPortId = base.getRightPortId(); this._status = base.getStatus(); this._tenantId = base.getTenantId(); this._adminStateUp = base.isAdminStateUp(); if (base instanceof EdgeImpl) { EdgeImpl impl = (EdgeImpl) base;
public static void removeEdgeFromDsIfExists(Uuid tenantId, Uuid edgeId) { Optional<Edge> oldOptional = removeIfExists(UlnIidFactory.edgeIid(tenantId, edgeId)); /* * Make sure other logical network nodes links are updated as well */ if (oldOptional.isPresent()) { Edge edge = oldOptional.get(); if (edge.getLeftPortId() != null) { removePortFromDsIfExists(tenantId, edge.getLeftPortId()); } if (edge.getRightPortId() != null) { removePortFromDsIfExists(tenantId, edge.getRightPortId()); } } }
/** * Check if an edge object has been cached. * @param edge to be cached. * @return true if found, false otherwise. */ public boolean isEdgeAlreadyCached(Edge edge) { Uuid edgeId = edge.getUuid(); return this.edgeStore.get(edgeId) != null; }
public static void submitEdgeToDs(Edge edge) { if (edge.getLeftPortId() == null || edge.getRightPortId() == null) { LOG.error("Trying to Subnit an edge Edge with less than two ports -- Ignored Request"); return; } Port lport = UlnDatastoreApi.readPortFromDs(edge.getTenantId(), edge.getLeftPortId()); if (lport != null && lport.getEdgeId() != null && !edge.getUuid().equals(lport.getEdgeId())) { LOG.error( "Trying to Submit Edge {} that references Port {}, but that Port already references Edge {}. Ignored Request.", edge.getUuid().getValue(), lport.getUuid().getValue(), lport.getEdgeId().getValue()); return; } Port rport = UlnDatastoreApi.readPortFromDs(edge.getTenantId(), edge.getRightPortId()); if (rport != null && rport.getEdgeId() != null && !edge.getUuid().equals(rport.getEdgeId())) { LOG.error( "Trying to Submit Edge {} that references Port {}, but that Port already references Edge {}. Ignored Request.", edge.getUuid().getValue(), rport.getUuid().getValue(), rport.getEdgeId().getValue()); return; } WriteTransaction t = UlnMapperDatastoreDependency.getDataProvider().newWriteOnlyTransaction(); t.put(logicalDatastoreType, UlnIidFactory.edgeIid(edge.getTenantId(), edge.getUuid()), edge, true); if (submitToDs(t)) { LOG.debug("Wrote logical edge {} to datastore.", edge.getUuid().getValue()); } else { LOG.error("Failed to write logical edge {} to datastore.", edge.getUuid().getValue()); } }
public synchronized void handleEdgeUpdateEvent(Edge edge) { Uuid tenantId = edge.getTenantId(); if (this.isUlnAlreadyInCache(tenantId) == false) { LOG.error("FABMGR: ERROR: handleEdgeUpdateEvent: this is update; ULN is supposed to be in cache: {}", tenantId.getValue()); return; } UserLogicalNetworkCache uln = this.ulnStore.get(tenantId); if (uln == null) { LOG.error("FABMGR: ERROR: handleEdgeUpdateEvent: uln is null"); return; } if (!uln.isEdgeAlreadyCached(edge)) { LOG.error("FABMGR: ERROR: handleEdgeUpdateEvent: edge should have been cached"); // fall through. Treat this case as create event } else { if (uln.isEdgeRendered(edge)) { LOG.error("FABMGR: ERROR: handleEdgeUpdateEvent: edge has already been rendered: {}", edge.getUuid().getValue()); return; } else { uln.removeEdgeFromCache(edge); } } /* * Now we can treat update event as a new create event. */ this.handleEdgeCreateEvent(edge); }
/** * Find the left port. * @param edge - the edge to be searched. * @return the left port. */ public PortMappingInfo findLeftPortOnEdge(Edge edge) { Uuid leftPortId = edge.getLeftPortId(); return this.portStore.get(leftPortId); }
/** * Find the right port. * @param edge - the edge to be searched. * @return the right port. */ public PortMappingInfo findRightPortOnEdge(Edge edge) { Uuid rightPortId = edge.getRightPortId(); return this.portStore.get(rightPortId); }
public synchronized void handleEdgeRemoveEvent(Edge edge) { Uuid tenantId = edge.getTenantId(); UserLogicalNetworkCache uln = this.ulnStore.get(tenantId); if (uln == null) { LOG.error("FABMGR: ERROR: handleEdgeRemoveEvent: uln is null"); return; } if (uln.isEdgeAlreadyCached(edge) == false) { LOG.error("FABMGR: ERROR: handleEdgeRemoveEvent: edge not in cache"); return; } uln.addRequestRemoveEdge(edge); /* * Notify worker thread to start work */ this.workerThreadLock.release(); }
public PortMappingInfo findLswPortOnEdge(EdgeMappingInfo edge) { Uuid leftPortId = edge.getEdge().getLeftPortId(); if (this.isPortLswType(leftPortId)) { return this.portStore.get(leftPortId); } Uuid rightPortId = edge.getEdge().getRightPortId(); if (this.isPortLswType(rightPortId)) { return this.portStore.get(rightPortId); } return null; }
public void removeEdgeFromCache(Edge edge) { this.edgeStore.remove(edge.getUuid()); }
public synchronized void handleEdgeCreateEvent(Edge edge) { Uuid tenantId = edge.getTenantId(); this.createUlnCacheIfNotExist(tenantId); UserLogicalNetworkCache uln = this.ulnStore.get(tenantId); if (uln == null) { LOG.error("FABMGR: ERROR: handleEdgeCreateEvent: uln is null"); return; } if (uln.isEdgeAlreadyCached(edge)) { LOG.error("FABMGR: ERROR: handleEdgeCreateEvent: edge already exist"); return; } uln.cacheEdge(edge); this.workerThreadLock.release(); }
if (!Objects.equals(_description, other.getDescription())) { return false; if (!Objects.equals(_key, other.getKey())) { return false; if (!Objects.equals(_leftPortId, other.getLeftPortId())) { return false; if (!Objects.equals(_name, other.getName())) { return false; if (!Objects.equals(_qosAttributes, other.getQosAttributes())) { return false; if (!Objects.equals(_rightPortId, other.getRightPortId())) { return false; if (!Objects.equals(_status, other.getStatus())) { return false; if (!Objects.equals(_tenantId, other.getTenantId())) { return false; if (!Objects.equals(_uuid, other.getUuid())) { return false; if (!Objects.equals(_adminStateUp, other.isAdminStateUp())) { return false;
public PortMappingInfo findLrPortOnEdge(EdgeMappingInfo edge) { Uuid leftPortId = edge.getEdge().getLeftPortId(); if (this.isPortLrType(leftPortId)) { return this.portStore.get(leftPortId); } Uuid rightPortId = edge.getEdge().getRightPortId(); if (this.isPortLrType(rightPortId)) { return this.portStore.get(rightPortId); } return null; }
public boolean isEdgeSubnetToEpLocationType(Edge edge) { EdgeMappingInfo edgeInfo = this.edgeStore.get(edge.getUuid()); if (edgeInfo == null) { // edge should already be cached when this function is called. LOG.error("FABMGR: ERROR: edgeIsSubnetToEpLocationType: edge not in cache: {}", edge.getUuid().getValue()); return false; } if (this.findEdgeType(edgeInfo) == LogicalEdgeType.SUBNET_EPLOCATION) { return true; } return false; }
public PortMappingInfo findSubnetPortInEdge(EdgeMappingInfo edge, Uuid subnetId) { PortMappingInfo subnetPort = null; Uuid leftPortId = edge.getEdge().getLeftPortId(); Uuid rightPortId = edge.getEdge().getRightPortId(); if (this.isPortInSubnet(leftPortId, subnetId) == true) { subnetPort = this.portStore.get(leftPortId); } else if (this.isPortInSubnet(rightPortId, subnetId) == true) { subnetPort = this.portStore.get(rightPortId); } return subnetPort; }
public boolean isEdgeLrToLrType(Edge edge) { EdgeMappingInfo edgeInfo = this.edgeStore.get(edge.getUuid()); if (edgeInfo == null) { // edge should already be cached when this function is called. LOG.error("FABMGR: ERROR: isEdgeLrToLrType: edge not in cache: {}", edge.getUuid().getValue()); return false; } if (this.findEdgeType(edgeInfo) == LogicalEdgeType.LR_LR) { return true; } return false; }
public PortMappingInfo findSubnetPortOnEdge(EdgeMappingInfo edge) { Uuid leftPortId = edge.getEdge().getLeftPortId(); if (this.isPortSubnetType(leftPortId) == true) { return this.portStore.get(leftPortId); } Uuid rightPortId = edge.getEdge().getRightPortId(); if (this.isPortSubnetType(rightPortId) == true) { return this.portStore.get(rightPortId); } return null; }
public boolean isEdgeLswToSubnetType(Edge edge) { EdgeMappingInfo edgeInfo = this.edgeStore.get(edge.getUuid()); if (edgeInfo == null) { // edge should already be cached when this function is called. LOG.error("FABMGR: ERROR: edgeIsLswToSubnetType: edge not in cache: {}", edge.getUuid().getValue()); return false; } if (this.findEdgeType(edgeInfo) == LogicalEdgeType.LSW_SUBNET) { return true; } return false; }
/** * Given an edge and one port, find the other port. * @param epEdge - the edge. * @param epPortId - one known port. * @return the other port. */ public PortMappingInfo findOtherPortInEdge(EdgeMappingInfo epEdge, Uuid epPortId) { Uuid leftPortId = epEdge.getEdge().getLeftPortId(); Uuid rightPortId = epEdge.getEdge().getRightPortId(); Uuid otherPortId; if (leftPortId.equals(epPortId)) { otherPortId = rightPortId; } else if (rightPortId.equals(epPortId)) { otherPortId = leftPortId; } else { LOG.error("FABMGR: ERROR: findOtherPortInEdge: port id is wrong: ep={}, left={}, right={}", epPortId.getValue(), leftPortId.getValue(), rightPortId.getValue()); return null; } return this.portStore.get(otherPortId); }
/** * To mark an edge as rendered. * @param edge rendered object. */ public void markEdgeAsRendered(Edge edge) { Uuid edgeId = edge.getUuid(); this.edgeStore.get(edgeId).setServiceHasBeenRendered(true); }