List of usage examples for org.apache.commons.lang3.tuple ImmutableTriple getRight
@Override
public R getRight()
From source file:ddf.catalog.transformer.csv.common.CsvTransformerTest.java
private void buildMetacardDataMap() { for (ImmutableTriple entry : ATTRIBUTE_DATA) { String attributeName = (String) entry.getLeft(); Serializable attributeValue = (Serializable) entry.getMiddle(); AttributeType attributeType = (AttributeType) entry.getRight(); Attribute attribute = new AttributeImpl(attributeName, attributeValue); metacardDataMap.put(attributeName, attribute); ATTRIBUTE_DESCRIPTOR_LIST.add(buildAttributeDescriptor(attributeName, attributeType)); }// www . j a v a 2s. co m }
From source file:com.telefonica.iot.cygnus.interceptors.NGSINameMappingsInterceptor.java
@Override public Event intercept(Event event) { if (invalidConfiguration) { return event; } // if// w w w .j a va2 s .c o m LOGGER.debug("[nmi] Event intercepted, id=" + event.hashCode()); // Casting to NGSIEvent NGSIEvent ngsiEvent = (NGSIEvent) event; // Get the original headers Map<String, String> headers = event.getHeaders(); // Get some original header values String originalService = headers.get(CommonConstants.HEADER_FIWARE_SERVICE); String originalServicePath = headers.get(CommonConstants.HEADER_FIWARE_SERVICE_PATH); // Create the mapped NotifyContextRequest ImmutableTriple<String, String, ContextElement> map = doMap(originalService, originalServicePath, ngsiEvent.getOriginalCE()); LOGGER.debug("[nmi] Mapped ContextElement: " + map.getRight().toString()); // Add the mapped ContextElement to the NGSIEvent ngsiEvent.setMappedCE(map.getRight()); // Add the bytes version of the mapped ContextElement to event's body byte[] originalCEBytes = ngsiEvent.getBody(); byte[] mappedCEBytes = map.getRight().toString().getBytes(); byte[] newBody = new byte[originalCEBytes.length + mappedCEBytes.length]; System.arraycopy(originalCEBytes, 0, newBody, 0, originalCEBytes.length); System.arraycopy(mappedCEBytes, 0, newBody, originalCEBytes.length, mappedCEBytes.length); ngsiEvent.setBody(newBody); LOGGER.debug("[nmi] New body: " + new String(newBody)); // Add the mapped service and service path to the headers headers.put(NGSIConstants.FLUME_HEADER_MAPPED_SERVICE, map.getLeft()); LOGGER.debug("[nmi] Header added to NGSI event (" + NGSIConstants.FLUME_HEADER_MAPPED_SERVICE + ": " + map.getLeft() + ")"); headers.put(NGSIConstants.FLUME_HEADER_MAPPED_SERVICE_PATH, map.getMiddle()); LOGGER.debug("[nmi] Header added to NGSI event (" + NGSIConstants.FLUME_HEADER_MAPPED_SERVICE_PATH + ": " + map.getMiddle() + ")"); // Return the intercepted event LOGGER.debug("[nmi] Event put in the channel, id=" + ngsiEvent.hashCode()); return ngsiEvent; }
From source file:io.lavagna.service.NotificationService.java
private void sendEmailToUser(User user, List<Event> events, MailConfig mailConfig) throws MustacheException, IOException { Set<Integer> userIds = new HashSet<>(); userIds.add(user.getId());//ww w .j a v a2 s. c om Set<Integer> cardIds = new HashSet<>(); Set<Integer> cardDataIds = new HashSet<>(); Set<Integer> columnIds = new HashSet<>(); for (Event e : events) { cardIds.add(e.getCardId()); userIds.add(e.getUserId()); addIfNotNull(userIds, e.getValueUser()); addIfNotNull(cardIds, e.getValueCard()); addIfNotNull(cardDataIds, e.getDataId()); addIfNotNull(cardDataIds, e.getPreviousDataId()); addIfNotNull(columnIds, e.getColumnId()); addIfNotNull(columnIds, e.getPreviousColumnId()); } final ImmutableTriple<String, String, String> subjectAndText = composeEmailForUser( new EventsContext(events, userRepository.findByIds(userIds), cardRepository.findAllByIds(cardIds), cardDataRepository.findDataByIds(cardDataIds), boardColumnRepository.findByIds(columnIds))); mailConfig.send(user.getEmail(), StringUtils.substring("Lavagna: " + subjectAndText.getLeft(), 0, 78), subjectAndText.getMiddle(), subjectAndText.getRight()); }
From source file:com.telefonica.iot.cygnus.interceptors.NGSINameMappingsInterceptorTest.java
/** * [NGSIGroupingInterceptor.doMap] -------- A mapped ContextElement can be * obtained from the Name Mappings.//w w w . j ava2 s . com */ @Test public void testDoMap() { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMap]") + "-------- A mapped ContextElement can be obtained from the Name Mappings"); NGSINameMappingsInterceptor nameMappingsInterceptor = new NGSINameMappingsInterceptor(null, false); nameMappingsInterceptor.loadNameMappings(nameMappingsStr); ContextElement originalCE; ContextElement expectedCE; try { originalCE = NGSIUtilsForTests.createJsonContextElement(originalCEStr); expectedCE = NGSIUtilsForTests.createJsonContextElement(expectedCEStr); } catch (Exception e) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMap]") + "- FAIL - There was some problem when parsing the ContextElements"); throw new AssertionError(e.getMessage()); } // try catch ImmutableTriple<String, String, ContextElement> map = nameMappingsInterceptor.doMap(originalService, originalServicePath, originalCE); ContextElement mappedCE = map.getRight(); boolean equals = true; if (!mappedCE.getId().equals(expectedCE.getId()) || !mappedCE.getType().equals(expectedCE.getType())) { equals = false; } else { for (int j = 0; j < mappedCE.getAttributes().size(); j++) { ContextAttribute mappedCA = mappedCE.getAttributes().get(j); ContextAttribute expectedCA = expectedCE.getAttributes().get(j); if (!mappedCA.getName().equals(expectedCA.getName()) || !mappedCA.getType().equals(expectedCA.getType())) { equals = false; break; } // if } // for } // if else try { assertTrue(equals); System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMap]") + "- OK - The mapped NotifyContextRequest is equals to the expected one"); } catch (AssertionError e) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMap]") + "- FAIL - The mapped NotifyContextRequest is not equals to the expected one"); throw e; } // try catch }
From source file:com.telefonica.iot.cygnus.interceptors.NGSINameMappingsInterceptorTest.java
/** * [NGSIGroupingInterceptor.doMapRegex] -------- A mapped ContextElement can * be obtained from the Name Mappings./*from w w w . j a v a 2 s. c o m*/ */ @Test public void testDoMapRegex() { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapRegex]") + "-------- A mapped ContextElement can be obtained from the Name Mappings"); NGSINameMappingsInterceptor nameMappingsInterceptor = new NGSINameMappingsInterceptor(null, false); nameMappingsInterceptor.loadNameMappings(nameMappingsRegexStr); ContextElement originalCE; ContextElement expectedCE; try { originalCE = NGSIUtilsForTests.createJsonContextElement(originalCEStr); expectedCE = NGSIUtilsForTests.createJsonContextElement(expectedCEStr); } catch (Exception e) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapRegex]") + "- FAIL - There was some problem when parsing the ContextElements"); throw new AssertionError(e.getMessage()); } // try catch ImmutableTriple<String, String, ContextElement> map = nameMappingsInterceptor.doMap(originalService, originalServicePath, originalCE); ContextElement mappedCE = map.getRight(); boolean equals = true; if (!mappedCE.getId().equals(expectedCE.getId()) || !mappedCE.getType().equals(expectedCE.getType())) { equals = false; } else { for (int j = 0; j < mappedCE.getAttributes().size(); j++) { ContextAttribute mappedCA = mappedCE.getAttributes().get(j); ContextAttribute expectedCA = expectedCE.getAttributes().get(j); if (!mappedCA.getName().equals(expectedCA.getName()) || !mappedCA.getType().equals(expectedCA.getType())) { equals = false; break; } // if } // for } // if else try { assertTrue(equals); System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapRegex]") + "- OK - The mapped NotifyContextRequest is equals to the expected one"); } catch (AssertionError e) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapRegex]") + "- FAIL - The mapped NotifyContextRequest is not equals to the expected one"); throw e; } // try catch }
From source file:com.telefonica.iot.cygnus.interceptors.NGSINameMappingsInterceptorTest.java
/** * [NGSIGroupingInterceptor.doMapConfig] -------- A mapped ContextElement * can be obtained from the Name Mappings. *//*from w ww .j a v a 2s. c o m*/ @Test public void testDoMapConfig() { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig]") + "-------- A mapped ContextElement can be obtained from the Name Mappings"); NGSINameMappingsInterceptor nameMappingsInterceptor = new NGSINameMappingsInterceptor(null, false); nameMappingsInterceptor.loadNameMappings(nameMappingsStrConfig); ContextElement originalCE; ContextElement expectedCE; try { originalCE = NGSIUtilsForTests.createJsonContextElement(originalCEStrConfig); expectedCE = NGSIUtilsForTests.createJsonContextElement(expectedCEStrConfig); } catch (Exception e) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig]") + "- FAIL - There was some problem when parsing the ContextElements"); throw new AssertionError(e.getMessage()); } // try catch ImmutableTriple<String, String, ContextElement> map = nameMappingsInterceptor.doMap(originalServiceConfig, originalServicePathConfig, originalCE); ContextElement mappedCE = map.getRight(); boolean equals = true; if (!mappedCE.getType().equals(expectedCE.getType()) || !expectedServicePathConfig.equals(map.getMiddle())) { equals = false; } else { for (int j = 0; j < mappedCE.getAttributes().size(); j++) { ContextAttribute mappedCA = mappedCE.getAttributes().get(j); ContextAttribute expectedCA = expectedCE.getAttributes().get(j); if (!mappedCA.getName().equals(expectedCA.getName()) || !mappedCA.getType().equals(expectedCA.getType())) { equals = false; break; } // if } // for } // if else try { assertTrue(equals); System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig]") + "- OK - The mapped NotifyContextRequest is equals to the expected one"); } catch (AssertionError e) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig]") + "- FAIL - The mapped NotifyContextRequest is not equals to the expected one"); throw e; } // try catch }
From source file:com.telefonica.iot.cygnus.interceptors.NGSINameMappingsInterceptorTest.java
/** * [NGSIGroupingInterceptor.doMapConfig2] -------- A mapped ContextElement * can be obtained from the Name Mappings. *//*from w w w. j av a 2 s. c o m*/ @Test public void testDoMapConfig2() { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig2]") + "-------- A mapped ContextElement can be obtained from the Name Mappings"); NGSINameMappingsInterceptor nameMappingsInterceptor = new NGSINameMappingsInterceptor(null, false); nameMappingsInterceptor.loadNameMappings(nameMappingsStrConfig2); ContextElement originalCE; ContextElement expectedCE; try { originalCE = NGSIUtilsForTests.createJsonContextElement(originalCEStrConfig2); expectedCE = NGSIUtilsForTests.createJsonContextElement(expectedCEStrConfig2); } catch (Exception e) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig2]") + "- FAIL - There was some problem when parsing the ContextElements"); throw new AssertionError(e.getMessage()); } // try catch ImmutableTriple<String, String, ContextElement> map = nameMappingsInterceptor.doMap(originalServiceConfig, originalServicePathConfig, originalCE); ContextElement mappedCE = map.getRight(); boolean equals = true; if (!mappedCE.getType().equals(expectedCE.getType()) || !expectedServicePathConfig2.equals(map.getMiddle())) { equals = false; } else { for (int j = 0; j < mappedCE.getAttributes().size(); j++) { ContextAttribute mappedCA = mappedCE.getAttributes().get(j); ContextAttribute expectedCA = expectedCE.getAttributes().get(j); if (!mappedCA.getName().equals(expectedCA.getName()) || !mappedCA.getType().equals(expectedCA.getType())) { equals = false; break; } // if } // for } // if else try { assertTrue(equals); System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig2]") + "- OK - The mapped NotifyContextRequest is equals to the expected one"); } catch (AssertionError e) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig2]") + "- FAIL - The mapped NotifyContextRequest is not equals to the expected one"); throw e; } // try catch }
From source file:com.telefonica.iot.cygnus.interceptors.NGSINameMappingsInterceptorTest.java
/** * [NGSIGroupingInterceptor.doMapConfig3] -------- A mapped ContextElement * can be obtained from the Name Mappings. */// ww w . jav a 2 s .com @Test public void testDoMapConfig3() { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig3]") + "-------- A mapped ContextElement can be obtained from the Name Mappings"); NGSINameMappingsInterceptor nameMappingsInterceptor = new NGSINameMappingsInterceptor(null, false); nameMappingsInterceptor.loadNameMappings(nameMappingsStrConfig3); ContextElement originalCE; ContextElement expectedCE; try { originalCE = NGSIUtilsForTests.createJsonContextElement(originalCEStrConfig2); expectedCE = NGSIUtilsForTests.createJsonContextElement(expectedCEStrConfig2); } catch (Exception e) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig3]") + "- FAIL - There was some problem when parsing the ContextElements"); throw new AssertionError(e.getMessage()); } // try catch ImmutableTriple<String, String, ContextElement> map = nameMappingsInterceptor.doMap(originalServiceConfig, originalServicePathConfig, originalCE); ContextElement mappedCE = map.getRight(); boolean equals = true; if (!mappedCE.getType().equals(expectedCE.getType()) || !expectedServicePathConfig2.equals(map.getMiddle())) { equals = false; } else { for (int j = 0; j < mappedCE.getAttributes().size(); j++) { ContextAttribute mappedCA = mappedCE.getAttributes().get(j); ContextAttribute expectedCA = expectedCE.getAttributes().get(j); if (!mappedCA.getName().equals(expectedCA.getName()) || !mappedCA.getType().equals(expectedCA.getType())) { equals = false; break; } // if } // for } // if else try { assertTrue(equals); System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig3]") + "- OK - The mapped NotifyContextRequest is equals to the expected one"); } catch (AssertionError e) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig3]") + "- FAIL - The mapped NotifyContextRequest is not equals to the expected one"); throw e; } // try catch }
From source file:com.telefonica.iot.cygnus.interceptors.NGSINameMappingsInterceptorTest.java
/** * [NGSIGroupingInterceptor.doMapConfig4] -------- Original fields can be * omitted./*from w w w .j a v a 2s . c o m*/ */ @Test public void testDoMapConfig4() { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig4]") + "-------- Original fields can be omitted"); NGSINameMappingsInterceptor nameMappingsInterceptor = new NGSINameMappingsInterceptor(null, false); nameMappingsInterceptor.loadNameMappings(nameMappingsStrConfig4); ContextElement originalCE; ContextElement expectedCE; try { originalCE = NGSIUtilsForTests.createJsonContextElement(originalCEStrConfig2); expectedCE = NGSIUtilsForTests.createJsonContextElement(expectedCEStrConfig4); } catch (Exception e) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig4]") + "- FAIL - There was some problem when parsing the ContextElements"); throw new AssertionError(e.getMessage()); } // try catch ImmutableTriple<String, String, ContextElement> map = nameMappingsInterceptor.doMap(originalServiceConfig, originalServicePathConfig, originalCE); ContextElement mappedCE = map.getRight(); boolean equals = true; if (!mappedCE.getType().equals(expectedCE.getType())) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig4]") + "- ERROR - The mapped type is not equal to the expected one"); equals = false; } else if (!expectedServicePathConfig2.equals(map.getMiddle())) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig4]") + "- ERROR - The mapped servicePath is not equal to the expected one"); equals = false; } else if (!mappedCE.getId().equals(expectedCE.getId())) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig4]") + "- ERROR - The mapped Id is not equal to the expected one"); equals = false; } else if (!map.getLeft().equals(expectedServiceConfig4)) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig4]") + "- ERROR - The Service tyepe is not equal to the expected one"); equals = false; } try { assertTrue(equals); System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig4]") + "- OK - The mapped NotifyContextRequest is equals to the expected one"); } catch (AssertionError e) { System.out.println(getTestTraceHead("[NGSIGroupingInterceptor.doMapConfig4]") + "- FAIL - The mapped NotifyContextRequest is not equals to the expected one"); throw e; } // try catch }
From source file:org.opendaylight.nemo.renderer.openflow.FlowUtils.java
/** * TODO/*from w ww. ja v a2 s . c o m*/ * * @author Zhigang Ji * @param packetReceived TODO * @param ingress TODO */ public void handleArp(PacketReceived packetReceived, NodeConnectorRef ingress) { byte[] payload = packetReceived.getPayload(); Ethernet ethernet = new Ethernet(); try { ethernet.deserialize(payload, 0, NetUtils.NumBitsInAByte * payload.length); } catch (PacketException exception) { LOG.error("Failed to decode the received packet to ethernet packet."); return; } ARP arp = new ARP(); try { arp.deserialize(ethernet.getRawPayload(), 0, NetUtils.NumBitsInAByte * ethernet.getRawPayload().length); } catch (PacketException exception) { LOG.error("Failed to decode the raw payload of ethernet packet to arp packet."); return; } ImmutableTriple<VirtualNetworkId, VirtualNodeId, VirtualPortId> mappingValueForExternalPhysicalPort = arpHandlerHelper .getMappingValueForExternalPhysicalPort(ingress); VirtualNetworkId virtualNetworkId = mappingValueForExternalPhysicalPort.getLeft(); VirtualNodeId ingressVirtualNodeId = mappingValueForExternalPhysicalPort.getMiddle(); VirtualPortId ingressVirtualPortId = mappingValueForExternalPhysicalPort.getRight(); IpAddress srcIpAddress = convertByteArray4ToIpAddress(arp.getSenderProtocolAddress()); IpAddress dstIpAddress = convertByteArray4ToIpAddress(arp.getTargetProtocolAddress()); VirtualNetworkHelper virtualNetworkHelper = virtualNetworkHelpers.get(virtualNetworkId); VirtualNode ingressVirtualNode = virtualNetworkHelper.getVirtualNode(ingressVirtualNodeId); VirtualArp virtualArp; switch (ingressVirtualNode.getNodeType()) { case Vswitch: virtualArp = virtualNetworkHelper.getVirtualArp(srcIpAddress); if (null == virtualArp) { virtualArp = new VirtualArpBuilder().setIpAddress(srcIpAddress) .setMacAddress(convertByteArray6ToMacAddress(arp.getSenderHardwareAddress())) .setNodeId(ingressVirtualNodeId).setPortId(ingressVirtualPortId).build(); virtualNetworkHelper.addVirtualArp(virtualArp); UserId userId = new UserId(virtualNetworkId.getValue()); Map<VirtualNodeId, Map.Entry<VirtualPort, VirtualLink>> connectedVirtualRouters = virtualNetworkHelper .getConnectedVirtualRouters(ingressVirtualNodeId); if (null != connectedVirtualRouters && !connectedVirtualRouters.isEmpty()) { VirtualLink virtualLink = virtualNetworkHelper.getVirtualLink( connectedVirtualRouters.keySet().iterator().next(), ingressVirtualNodeId); VnPnMappingResult vnPnMappingResult = getVnPnMappingResult( userVnPnMappings.get(userId).getVnPnMappingResult(), new VirtualResourceEntityId(virtualLink.getLinkId().getValue())); PhysicalPathId physicalPathId = new PhysicalPathId( vnPnMappingResult.getPhysicalResourceEntityId().getValue()); PhysicalPath physicalPath = physicalNetworkHelper.getPhysicalPath(physicalPathId); configArpTableEntry(userId, virtualArp, physicalPath); } PhysicalNodeId ingressPhysicalNodeId = convertNodeConnectorRefToPhysicalNodeId(ingress); PhysicalPortId ingressPhysicalPortId = convertNodeConnectorRefToPhysicalPortId(ingress); configMacTableEntry(userId, virtualArp.getMacAddress(), ingressPhysicalNodeId, ingressPhysicalPortId); Map<VirtualNodeId, Map.Entry<VirtualPort, VirtualLink>> connectedVirtualSwitches = virtualNetworkHelper .getConnectedVirtualSwitches(ingressVirtualNodeId); if (null != connectedVirtualSwitches && !connectedVirtualSwitches.isEmpty()) { List<VnPnMappingResult> vnPnMappingResults = userVnPnMappings.get(userId) .getVnPnMappingResult(); VirtualLink virtualLink; VnPnMappingResult vnPnMappingResult; PhysicalPathId physicalPathId; PhysicalPath physicalPath; for (VirtualNodeId virtualNodeId : connectedVirtualSwitches.keySet()) { virtualLink = virtualNetworkHelper.getVirtualLink(virtualNodeId, ingressVirtualNodeId); vnPnMappingResult = getVnPnMappingResult(vnPnMappingResults, new VirtualResourceEntityId(virtualLink.getLinkId().getValue())); physicalPathId = new PhysicalPathId( vnPnMappingResult.getPhysicalResourceEntityId().getValue()); physicalPath = physicalNetworkHelper.getPhysicalPath(physicalPathId); configMacTableEntry(userId, virtualArp.getMacAddress(), physicalPath); } } } if (ARP.REQUEST == arp.getOpCode()) { IpAddress gatewayIpAddress = getGatewayIpAddress(virtualNetworkId, ingressVirtualNode); if (dstIpAddress.equals(gatewayIpAddress)) { MacAddress gatewayMacAddress = getGatewayMacAddress(virtualNetworkId, ingressVirtualNode); byte[] targetProtocolAddress = arp.getTargetProtocolAddress(); arp.setTargetHardwareAddress(arp.getSenderHardwareAddress()); arp.setTargetProtocolAddress(arp.getSenderProtocolAddress()); arp.setSenderHardwareAddress(convertMacAddressToByteArray6(gatewayMacAddress)); arp.setSenderProtocolAddress(targetProtocolAddress); arp.setOpCode(ARP.REPLY); ethernet.setSourceMACAddress(arp.getSenderHardwareAddress()); ethernet.setDestinationMACAddress(arp.getTargetHardwareAddress()); sendPacketOut(createArpPacket(ethernet, arp), ingress, ingress); break; } virtualArp = virtualNetworkHelper.getVirtualArp(dstIpAddress); if (null != virtualArp) { byte[] targetProtocolAddress = arp.getTargetProtocolAddress(); arp.setTargetHardwareAddress(arp.getSenderHardwareAddress()); arp.setTargetProtocolAddress(arp.getSenderProtocolAddress()); arp.setSenderHardwareAddress(convertMacAddressToByteArray6(virtualArp.getMacAddress())); arp.setSenderProtocolAddress(targetProtocolAddress); arp.setOpCode(ARP.REPLY); ethernet.setSourceMACAddress(arp.getSenderHardwareAddress()); ethernet.setDestinationMACAddress(arp.getTargetHardwareAddress()); sendPacketOut(createArpPacket(ethernet, arp), ingress, ingress); break; } Map<VirtualNodeId, Map.Entry<VirtualPort, VirtualLink>> connectedVirtualSwitches = virtualNetworkHelper .getConnectedVirtualSwitches(ingressVirtualNodeId); if (null != connectedVirtualSwitches && !connectedVirtualSwitches.isEmpty()) { UserId userId = new UserId(virtualNetworkId.getValue()); UserVnPnMapping userVnPnMapping = userVnPnMappings.get(userId); List<VnPnMappingResult> vnPnMappingResults = userVnPnMapping.getVnPnMappingResult(); VirtualPort layer2ExternalVirtualPort; VnPnMappingResult vnPnMappingResult; PhysicalNodeId physicalNodeId; PhysicalPortId physicalPortId; for (VirtualNodeId virtualNodeId : connectedVirtualSwitches.keySet()) { layer2ExternalVirtualPort = virtualNetworkHelper .getLayer2ExternalVirtualPort(virtualNodeId); if (null != layer2ExternalVirtualPort) { vnPnMappingResult = getVnPnMappingResult(vnPnMappingResults, new VirtualResourceEntityId(layer2ExternalVirtualPort.getPortId().getValue())); physicalNodeId = new PhysicalNodeId( vnPnMappingResult.getParentPhysicalResourceEntityId().getValue()); physicalPortId = new PhysicalPortId( vnPnMappingResult.getPhysicalResourceEntityId().getValue()); sendPacketOut(payload, ingress, createNodeConnectorRef(physicalNodeId, physicalPortId)); } } } } else { virtualArp = virtualNetworkHelper.getVirtualArp(dstIpAddress); if (null != virtualArp) { UserId userId = new UserId(virtualNetworkId.getValue()); UserVnPnMapping userVnPnMapping = userVnPnMappings.get(userId); List<VnPnMappingResult> vnPnMappingResults = userVnPnMapping.getVnPnMappingResult(); VnPnMappingResult vnPnMappingResult = getVnPnMappingResult(vnPnMappingResults, new VirtualResourceEntityId(virtualArp.getPortId().getValue())); PhysicalNodeId physicalNodeId = new PhysicalNodeId( vnPnMappingResult.getParentPhysicalResourceEntityId().getValue()); PhysicalPortId physicalPortId = new PhysicalPortId( vnPnMappingResult.getPhysicalResourceEntityId().getValue()); sendPacketOut(payload, ingress, createNodeConnectorRef(physicalNodeId, physicalPortId)); } } break; case Vrouter: VirtualPort ingressVirtualPort = virtualNetworkHelper.getVirtualPort(ingressVirtualNodeId, ingressVirtualPortId); if (virtualNetworkHelper.isLayer2ExternalVirtualPort(ingressVirtualPort)) { virtualArp = virtualNetworkHelper.getVirtualArp(srcIpAddress); if (null == virtualArp) { virtualArp = new VirtualArpBuilder().setIpAddress(srcIpAddress) .setMacAddress(convertByteArray6ToMacAddress(arp.getSenderHardwareAddress())) .setNodeId(ingressVirtualNodeId).setPortId(ingressVirtualPortId).build(); virtualNetworkHelper.addVirtualArp(virtualArp); UserId userId = new UserId(virtualNetworkId.getValue()); PhysicalNodeId ingressPhysicalNodeId = convertNodeConnectorRefToPhysicalNodeId(ingress); PhysicalPortId ingressPhysicalPortId = convertNodeConnectorRefToPhysicalPortId(ingress); configArpTableEntry(userId, virtualArp, ingressPhysicalNodeId, ingressPhysicalPortId); } if (ARP.REQUEST == arp.getOpCode()) { IpAddress gatewayIpAddress = getGatewayIpAddress(virtualNetworkId, ingressVirtualNode); if (dstIpAddress.equals(gatewayIpAddress)) { MacAddress gatewayMacAddress = getGatewayMacAddress(virtualNetworkId, ingressVirtualNode); byte[] targetProtocolAddress = arp.getTargetProtocolAddress(); arp.setTargetHardwareAddress(arp.getSenderHardwareAddress()); arp.setTargetProtocolAddress(arp.getSenderProtocolAddress()); arp.setSenderHardwareAddress(convertMacAddressToByteArray6(gatewayMacAddress)); arp.setSenderProtocolAddress(targetProtocolAddress); arp.setOpCode(ARP.REPLY); ethernet.setSourceMACAddress(arp.getSenderHardwareAddress()); ethernet.setDestinationMACAddress(arp.getTargetHardwareAddress()); sendPacketOut(createArpPacket(ethernet, arp), ingress, ingress); } } } break; default: break; } return; }