本文整理汇总了Java中org.onosproject.net.HostId类的典型用法代码示例。如果您正苦于以下问题:Java HostId类的具体用法?Java HostId怎么用?Java HostId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HostId类属于org.onosproject.net包,在下文中一共展示了HostId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: activate
import org.onosproject.net.HostId; //导入依赖的package包/类
@Activate
public void activate() {
KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder()
.register(KryoNamespaces.API);
hostsConsistentMap = storageService.<HostId, DefaultHost>consistentMapBuilder()
.withName("onos-hosts")
.withRelaxedReadConsistency()
.withSerializer(Serializer.using(hostSerializer.build()))
.build();
hosts = hostsConsistentMap.asJavaMap();
prevHosts.putAll(hosts);
hostsConsistentMap.addListener(hostLocationTracker);
log.info("Started");
}
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:DistributedHostStore.java
示例2: parseHost
import org.onosproject.net.HostId; //导入依赖的package包/类
/**
* Creates and adds new host based on given data and returns its host ID.
*
* @param node JsonNode containing host information
* @return host ID of new host created
*/
private HostId parseHost(JsonNode node) {
MacAddress mac = MacAddress.valueOf(node.get("mac").asText());
VlanId vlanId = VlanId.vlanId((short) node.get("vlan").asInt(VlanId.UNTAGGED));
JsonNode locationNode = node.get("location");
String deviceAndPort = locationNode.get("elementId").asText() + "/" +
locationNode.get("port").asText();
HostLocation hostLocation = new HostLocation(ConnectPoint.deviceConnectPoint(deviceAndPort), 0);
Iterator<JsonNode> ipStrings = node.get("ipAddresses").elements();
Set<IpAddress> ips = new HashSet<>();
while (ipStrings.hasNext()) {
ips.add(IpAddress.valueOf(ipStrings.next().asText()));
}
// try to remove elements from json node after reading them
SparseAnnotations annotations = annotations(removeElements(node, REMOVAL_KEYS));
// Update host inventory
HostId hostId = HostId.hostId(mac, vlanId);
DefaultHostDescription desc = new DefaultHostDescription(mac, vlanId, hostLocation, ips, annotations);
hostProviderService.hostDetected(hostId, desc, false);
return hostId;
}
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:HostsWebResource.java
示例3: testBadGet
import org.onosproject.net.HostId; //导入依赖的package包/类
/**
* Tests that a fetch of a non-existent object throws an exception.
*/
@Test
public void testBadGet() {
expect(mockHostService.getHost(HostId.hostId("00:00:11:00:00:01/1")))
.andReturn(null)
.anyTimes();
replay(mockHostService);
WebTarget wt = target();
try {
wt.path("hosts/00:00:11:00:00:01/1").request().get(String.class);
fail("Fetch of non-existent host did not throw an exception");
} catch (NotFoundException ex) {
assertThat(ex.getMessage(),
containsString("HTTP 404 Not Found"));
}
}
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:HostResourceTest.java
示例4: decode
import org.onosproject.net.HostId; //导入依赖的package包/类
@Override
public HostToHostIntent decode(ObjectNode json, CodecContext context) {
HostToHostIntent.Builder builder = HostToHostIntent.builder();
IntentCodec.intentAttributes(json, context, builder);
ConnectivityIntentCodec.intentAttributes(json, context, builder);
String one = nullIsIllegal(json.get(ONE),
ONE + IntentCodec.MISSING_MEMBER_MESSAGE).asText();
builder.one(HostId.hostId(one));
String two = nullIsIllegal(json.get(TWO),
TWO + IntentCodec.MISSING_MEMBER_MESSAGE).asText();
builder.two(HostId.hostId(two));
return builder.build();
}
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:HostToHostIntentCodec.java
示例5: createHost
import org.onosproject.net.HostId; //导入依赖的package包/类
/**
* Creates a default host connected at the given edge device and port. Note
* that an identifying hex character ("a" - "f") should be supplied. This
* will be included in the MAC address of the host (and equivalent value
* as last byte in IP address).
*
* @param device edge device
* @param port port number
* @param hexChar identifying hex character
* @return host connected at that location
*/
protected static Host createHost(Device device, int port, String hexChar) {
DeviceId deviceId = device.id();
String devNum = deviceId.toString().substring(1);
MacAddress mac = MacAddress.valueOf(HOST_MAC_PREFIX + devNum + hexChar);
HostId hostId = hostId(String.format("%s/-1", mac));
int ipByte = Integer.valueOf(hexChar, 16);
if (ipByte < 10 || ipByte > 15) {
throw new IllegalArgumentException("hexChar must be a-f");
}
HostLocation loc = new HostLocation(deviceId, portNumber(port), 0);
IpAddress ip = ip("10." + devNum + ".0." + ipByte);
return new DefaultHost(ProviderId.NONE, hostId, mac, VlanId.NONE,
loc, ImmutableSet.of(ip));
}
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:AbstractTopoModelTest.java
示例6: activate
import org.onosproject.net.HostId; //导入依赖的package包/类
@Activate
protected void activate() {
allocationMap = storageService.<HostId, IpAssignment>consistentMapBuilder()
.withName("onos-dhcp-assignedIP")
.withSerializer(Serializer.using(
new KryoNamespace.Builder()
.register(KryoNamespaces.API)
.register(IpAssignment.class,
IpAssignment.AssignmentStatus.class,
Date.class,
long.class,
Ip4Address.class)
.build()))
.build();
freeIPPool = storageService.<Ip4Address>setBuilder()
.withName("onos-dhcp-freeIP")
.withSerializer(Serializer.using(KryoNamespaces.API))
.build()
.asDistributedSet();
log.info("Started");
}
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:DistributedDhcpStore.java
示例7: programInterfacesSet
import org.onosproject.net.HostId; //导入依赖的package包/类
private void programInterfacesSet(Set<RouterInterface> interfacesSet,
Objective.Operation operation) {
int subnetVmNum = 0;
for (RouterInterface r : interfacesSet) {
// Get all the host of the subnet
Map<HostId, Host> hosts = hostsOfSubnet.get(r.subnetId());
if (hosts != null && hosts.size() > 0) {
subnetVmNum++;
if (subnetVmNum >= SUBNET_NUM) {
TenantRouter tenantRouter = TenantRouter
.tenantRouter(r.tenantId(), r.routerId());
routerInfFlagOfTenantRouter.put(tenantRouter, true);
interfacesSet.stream().forEach(f -> {
programRouterInterface(f, operation);
});
break;
}
}
}
}
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:VtnManager.java
示例8: createHost
import org.onosproject.net.HostId; //导入依赖的package包/类
private Host createHost() {
MacAddress mac = MacAddress.valueOf("00:00:11:00:00:01");
VlanId vlan = VlanId.vlanId((short) 10);
HostLocation loc = new HostLocation(
DeviceId.deviceId("of:foo"),
PortNumber.portNumber(100),
123L
);
Set<IpAddress> ipset = Sets.newHashSet(
IpAddress.valueOf("10.0.0.1"),
IpAddress.valueOf("10.0.0.2")
);
HostId hid = HostId.hostId(mac, vlan);
return new DefaultHost(
new ProviderId("of", "foo"), hid, mac, vlan, loc, ipset);
}
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:HostEventTest.java
示例9: getGatewayMac
import org.onosproject.net.HostId; //导入依赖的package包/类
@Override
public MacAddress getGatewayMac(HostId hostId) {
checkNotNull(hostId, "hostId cannot be null");
Host host = hostService.getHost(hostId);
String ifaceId = host.annotations().value(IFACEID);
VirtualPortId hPortId = VirtualPortId.portId(ifaceId);
VirtualPort hPort = virtualPortService.getPort(hPortId);
SubnetId subnetId = hPort.fixedIps().iterator().next().subnetId();
Subnet subnet = subnetService.getSubnet(subnetId);
IpAddress gatewayIp = subnet.gatewayIp();
Iterable<VirtualPort> virtualPorts = virtualPortService.getPorts();
MacAddress macAddress = null;
for (VirtualPort port : virtualPorts) {
Set<FixedIp> fixedIpSet = port.fixedIps();
for (FixedIp fixedIp : fixedIpSet) {
if (fixedIp.ip().equals(gatewayIp)) {
macAddress = port.macAddress();
}
}
}
return macAddress;
}
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:VtnRscManager.java
示例10: handleArpRequest
import org.onosproject.net.HostId; //导入依赖的package包/类
private void handleArpRequest(DeviceId deviceId, ConnectPoint inPort, Ethernet payload) {
ARP arpRequest = (ARP) payload.getPayload();
VlanId vlanId = VlanId.vlanId(payload.getVlanID());
HostId targetHostId = HostId.hostId(MacAddress.valueOf(
arpRequest.getTargetHardwareAddress()),
vlanId);
// ARP request for router. Send ARP reply.
if (isArpForRouter(deviceId, arpRequest)) {
Ip4Address targetAddress = Ip4Address.valueOf(arpRequest.getTargetProtocolAddress());
sendArpResponse(arpRequest, config.getRouterMacForAGatewayIp(targetAddress), vlanId);
} else {
Host targetHost = srManager.hostService.getHost(targetHostId);
// ARP request for known hosts. Send proxy ARP reply on behalf of the target.
if (targetHost != null) {
removeVlanAndForward(payload, targetHost.location());
// ARP request for unknown host in the subnet. Flood in the subnet.
} else {
removeVlanAndFlood(payload, inPort);
}
}
}
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:ArpHandler.java
示例11: encode
import org.onosproject.net.HostId; //导入依赖的package包/类
@Override
public ObjectNode encode(ConnectPoint point, CodecContext context) {
checkNotNull(point, "Connect point cannot be null");
ObjectNode root = context.mapper().createObjectNode()
.put(PORT, point.port().toString());
if (point.elementId() instanceof DeviceId) {
root.put(ELEMENT_DEVICE, point.deviceId().toString());
} else if (point.elementId() instanceof HostId) {
root.put(ELEMENT_HOST, point.hostId().toString());
}
return root;
}
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:ConnectPointCodec.java
示例12: getPaths
import org.onosproject.net.HostId; //导入依赖的package包/类
@Override
public Set<Path> getPaths(ElementId src, ElementId dst) {
Set<Path> result = new HashSet<>();
String[] allHops = new String[pathHops.length];
if (src.toString().endsWith(pathHops[0])) {
System.arraycopy(pathHops, 0, allHops, 0, pathHops.length);
} else {
System.arraycopy(reversePathHops, 0, allHops, 0, pathHops.length);
}
result.add(createPath(src instanceof HostId, dst instanceof HostId, allHops));
return result;
}
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:IntentTestsMocks.java
示例13: testReplyToRequestFromUsIpv6
import org.onosproject.net.HostId; //导入依赖的package包/类
/**
* Test NDP request from internal network to an external host.
*/
@Test
public void testReplyToRequestFromUsIpv6() {
Ip6Address ourIp = Ip6Address.valueOf("1000::1");
MacAddress ourMac = MacAddress.valueOf(1L);
Ip6Address theirIp = Ip6Address.valueOf("1000::100");
expect(hostService.getHostsByIp(theirIp)).andReturn(Collections.emptySet());
expect(interfaceService.getInterfacesByIp(ourIp))
.andReturn(Collections.singleton(new Interface(getLocation(1),
Collections.singletonList(new InterfaceIpAddress(
ourIp,
IpPrefix.valueOf("1000::1/64"))),
ourMac,
VLAN1)));
expect(hostService.getHost(HostId.hostId(ourMac, VLAN1))).andReturn(null);
replay(hostService);
replay(interfaceService);
// This is a request from something inside our network (like a BGP
// daemon) to an external host.
Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION,
ourMac,
MacAddress.valueOf("33:33:ff:00:00:01"),
ourIp,
theirIp);
proxyArp.reply(ndpRequest, getLocation(5));
assertEquals(1, packetService.packets.size());
verifyPacketOut(ndpRequest, getLocation(1), packetService.packets.get(0));
// The same request from a random external port should fail
packetService.packets.clear();
proxyArp.reply(ndpRequest, getLocation(2));
assertEquals(0, packetService.packets.size());
}
开发者ID:shlee89,项目名称:athena,代码行数:39,代码来源:ProxyArpManagerTest.java
示例14: getHost
import org.onosproject.net.HostId; //导入依赖的package包/类
@Override
public Host getHost(HostId hostId) {
if (HOST_A_ID.equals(hostId)) {
return HOST_A;
}
if (HOST_B_ID.equals(hostId)) {
return HOST_B;
}
return null;
}
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:NodeSelectionTest.java
示例15: edgeToEdgeDirect
import org.onosproject.net.HostId; //导入依赖的package包/类
@Test
public void edgeToEdgeDirect() {
HostId src = hid("12:34:56:78:90:ab/1");
HostId dst = hid("12:34:56:78:90:ef/1");
fakeHostMgr.hosts.put(src, host("12:34:56:78:90:ab/1", "edge"));
fakeHostMgr.hosts.put(dst, host("12:34:56:78:90:ef/1", "edge"));
Set<Path> paths = service.getPaths(src, dst);
validatePaths(paths, 1, 2, src, dst);
}
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:PathManagerTest.java
示例16: isIntentRelevantToHosts
import org.onosproject.net.HostId; //导入依赖的package包/类
private boolean isIntentRelevantToHosts(HostToHostIntent intent, Iterable<Host> hosts) {
for (Host host : hosts) {
HostId id = host.id();
// Bail if intent does not involve this host.
if (!id.equals(intent.one()) && !id.equals(intent.two())) {
return false;
}
}
return true;
}
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:TopoIntentFilter.java
示例17: readInitialConfig
import org.onosproject.net.HostId; //导入依赖的package包/类
private void readInitialConfig() {
networkConfigRegistry.getSubjects(HostId.class).forEach(hostId -> {
MacAddress mac = hostId.mac();
VlanId vlan = hostId.vlanId();
BasicHostConfig hostConfig =
networkConfigRegistry.getConfig(hostId, BasicHostConfig.class);
Set<IpAddress> ipAddresses = hostConfig.ipAddresses();
ConnectPoint location = hostConfig.location();
HostLocation hloc = new HostLocation(location, System.currentTimeMillis());
addHost(mac, vlan, hloc, ipAddresses);
});
}
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:NetworkConfigHostProvider.java
示例18: removeIp
import org.onosproject.net.HostId; //导入依赖的package包/类
@Override
public HostEvent removeIp(HostId hostId, IpAddress ipAddress) {
hosts.compute(hostId, (id, existingHost) -> {
if (existingHost != null) {
checkState(Objects.equals(hostId.mac(), existingHost.mac()),
"Existing and new MAC addresses differ.");
checkState(Objects.equals(hostId.vlanId(), existingHost.vlan()),
"Existing and new VLANs differ.");
Set<IpAddress> addresses = existingHost.ipAddresses();
if (addresses != null && addresses.contains(ipAddress)) {
addresses = new HashSet<>(existingHost.ipAddresses());
addresses.remove(ipAddress);
return new DefaultHost(existingHost.providerId(),
hostId,
existingHost.mac(),
existingHost.vlan(),
existingHost.location(),
ImmutableSet.copyOf(addresses),
existingHost.annotations());
} else {
return existingHost;
}
}
return null;
});
return null;
}
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:DistributedHostStore.java
示例19: hostSet
import org.onosproject.net.HostId; //导入依赖的package包/类
/**
* Returns the set of UI hosts with the given identifiers.
*
* @param hostIds host identifiers
* @return set of matching UI host instances
*/
Set<UiHost> hostSet(Set<HostId> hostIds) {
Set<UiHost> uiHosts = new HashSet<>();
for (HostId id : hostIds) {
UiHost h = hostLookup.get(id);
if (h != null) {
uiHosts.add(h);
} else {
log.warn(E_UNMAPPED, "host", id);
}
}
return uiHosts;
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:UiTopology.java
示例20: hostDetected
import org.onosproject.net.HostId; //导入依赖的package包/类
@Override
public void hostDetected(HostId hostId, HostDescription hostDescription, boolean replaceIps) {
DeviceId descr = hostDescription.location().deviceId();
if (added == null) {
added = descr;
} else if ((moved == null) && !descr.equals(added)) {
moved = descr;
} else {
spine = descr;
}
}
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:OvsdbHostProviderTest.java
注:本文中的org.onosproject.net.HostId类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论