/** * 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 void removeEdgeFromCache(Edge edge) { this.edgeStore.remove(edge.getUuid()); }
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 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; }
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; }
/** * 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); }
public boolean isEdgeLswToLswType(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: edgeIsLswToLswType: edge not in cache: {}", edge.getUuid().getValue()); return false; } if (this.findEdgeType(edgeInfo) == LogicalEdgeType.LSW_LSW) { return true; } return false; }
public boolean isEdgeLrToLswType(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: isEdgeLrToLswType: edge not in cache: {}", edge.getUuid().getValue()); return false; } if (this.findEdgeType(edgeInfo) == LogicalEdgeType.LR_LSW) { return true; } return false; }
public void addRequestRemoveEdge(Edge edge) { Uuid edgeId = edge.getUuid(); EdgeMappingInfo info = this.edgeStore.get(edgeId); if (info == null) { LOG.error("FABMGR: ERROR: removeEdge: info is null"); return; } info.markDeleted(); }
/** * To cache an edge. * @param edge to be cached. */ public void cacheEdge(Edge edge) { if (!this.isEdgeAlreadyCached(edge)) { this.edgeStore.put(edge.getUuid(), new EdgeMappingInfo(edge)); } }
/** * Check if an Edge has been rendered. * @param edge - the edge to be checked. * @return true if rendered. false otherwise. */ public boolean isEdgeRendered(Edge edge) { if (!this.isEdgeAlreadyCached(edge)) { return false; } return this.edgeStore.get(edge.getUuid()).hasServiceBeenRendered(); }
public void addLrLswEdgeToLsw(LogicalSwitch lsw, Edge edge) { Uuid edgeId = edge.getUuid(); Uuid lswId = lsw.getUuid(); LogicalSwitchMappingInfo info = this.lswStore.get(lswId); if (info == null) { LOG.error("FABMGR: ERROR: addLrLswEdgeToLsw: info is null: {}", lswId.getValue()); return; } info.addLrLswEdge(edgeId); }
public void addLrLswEdgeToPort(Port port, Edge edge) { Uuid edgeId = edge.getUuid(); Uuid portId = port.getUuid(); PortMappingInfo info = this.portStore.get(portId); if (info == null) { LOG.error("FABMGR: ERROR: addLrLswEdgeToPort: info is null: {}", portId.getValue()); return; } info.addLrLswEdge(edgeId); }
public void addLrLswEdgeToLr(LogicalRouter lr, Edge edge) { Uuid edgeId = edge.getUuid(); Uuid lrId = lr.getUuid(); LogicalRouterMappingInfo info = this.lrStore.get(lrId); if (info == null) { LOG.error("FABMGR: ERROR: addLrLswEdgeToLr: info is null: {}", lrId.getValue()); return; } info.addLrLswEdge(edgeId); }
public void removeLrLswEdgeFromLsw(LogicalSwitch lsw, Edge edge) { Uuid edgeId = edge.getUuid(); Uuid lswId = lsw.getUuid(); LogicalSwitchMappingInfo info = this.lswStore.get(lswId); if (info == null) { LOG.error("FABMGR: ERROR: removeLrLswEdgeFromLsw: info is null: {}", lswId.getValue()); return; } info.removeLrLswEdge(edgeId); }
public void removeLrLswEdgeFromPort(Port port, Edge edge) { Uuid edgeId = edge.getUuid(); Uuid portId = port.getUuid(); PortMappingInfo info = this.portStore.get(portId); if (info == null) { LOG.error("FABMGR: ERROR: removeLrLswEdgeFromPort: info is null: {}", portId.getValue()); return; } info.removeLrLswEdge(edgeId); }
public void removeLrLswEdgeFromLr(LogicalRouter lr, Edge edge) { Uuid edgeId = edge.getUuid(); Uuid lrId = lr.getUuid(); LogicalRouterMappingInfo info = this.lrStore.get(lrId); if (info == null) { LOG.error("FABMGR: ERROR: removeLrLswEdgeFromLr: info is null: {}", lrId.getValue()); return; } info.removeLrLswEdge(edgeId); }
/** * Find the edge connects the given port. * @param port - the target port. * @return the Endge connects the given port. */ @Nonnull public EdgeMappingInfo findTheEdge(PortMappingInfo port) { for (Entry<Uuid, EdgeMappingInfo> entry : this.edgeStore.entrySet()) { EdgeMappingInfo edge = entry.getValue(); if (edge.getEdge().getUuid().equals(port.getPort().getEdgeId())) { return edge; } } return null; }
public void executeEvent(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) { // Create for (DataObject dao : change.getCreatedData().values()) { if (dao instanceof Edge) { LOG.debug("FABMGR: Create Edge event: {}", ((Edge) dao).getUuid().getValue()); UserLogicalNetworkManager.getUlnMapper().handleEdgeCreateEvent((Edge) dao); } } // Update Map<InstanceIdentifier<?>, DataObject> dao = change.getUpdatedData(); for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : dao.entrySet()) { if (entry.getValue() instanceof Edge) { LOG.debug("FABMGR: Update Edge event: {}", ((Edge) entry.getValue()).getUuid().getValue()); UserLogicalNetworkManager.getUlnMapper().handleEdgeUpdateEvent((Edge) entry.getValue()); } } // Remove for (InstanceIdentifier<?> iid : change.getRemovedPaths()) { DataObject old = change.getOriginalData().get(iid); if (old == null) { continue; } if (old instanceof Edge) { LOG.debug("FABMGR: Remove Edge event: {}", ((Edge) old).getUuid().getValue()); UserLogicalNetworkManager.getUlnMapper().handleEdgeRemoveEvent((Edge) old); } } }
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()); } }