112 lines
3.4 KiB
Java
112 lines
3.4 KiB
Java
package org.kne.cloud.network.ipv6;
|
|
|
|
import java.net.Inet6Address;
|
|
import java.net.InetAddress;
|
|
import java.util.Objects;
|
|
|
|
|
|
import org.kne.cloud.network.ipv6.IPv6NetworkLink;
|
|
import org.kne.cloud.network.ipv6.Inet6AddressGroup;
|
|
import org.kne.cloud.network.monitor.DelayMonitorData;
|
|
import org.kne.cloud.network.monitor.MonitorData;
|
|
import org.kne.cloud.network.monitor.QueueingMonitorDataImpl;
|
|
|
|
public class RouteItem implements Comparable<RouteItem>{
|
|
private Inet6AddressGroup destination;
|
|
private Inet6Address nexthop;
|
|
private IPv6NetworkLink destlink;
|
|
private String proto;
|
|
private int pre;
|
|
private long cost;
|
|
private String flag;
|
|
private MonitorData monitor;
|
|
public String getFlag() {
|
|
return flag;
|
|
}
|
|
public MonitorData getMonitor() {
|
|
return monitor;
|
|
}
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hash(cost, destination, destlink, flag, nexthop, pre, proto);
|
|
}
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (this == obj)
|
|
return true;
|
|
if (obj == null)
|
|
return false;
|
|
if (getClass() != obj.getClass())
|
|
return false;
|
|
RouteItem other = (RouteItem) obj;
|
|
return cost == other.cost && Objects.equals(destination, other.destination)
|
|
&& Objects.equals(flag, other.flag)
|
|
&& pre == other.pre && Objects.equals(proto, other.proto);
|
|
}
|
|
public RouteItem(Inet6AddressGroup destination, Inet6Address nexthop, IPv6NetworkLink destlink, String proto, int pre,
|
|
long cost,String flag) {
|
|
super();
|
|
this.destination = destination;
|
|
this.nexthop = nexthop;
|
|
this.destlink = destlink;
|
|
this.proto = proto;
|
|
this.pre = pre;
|
|
this.cost = cost;
|
|
this.flag=flag;
|
|
}
|
|
public RouteItem(Inet6AddressGroup destination, Inet6Address nexthop, IPv6NetworkLink destlink, String proto, int pre,
|
|
long cost,MonitorData monitor,String flag) {
|
|
super();
|
|
this.destination = destination;
|
|
this.nexthop = nexthop;
|
|
this.destlink = destlink;
|
|
this.proto = proto;
|
|
this.pre = pre;
|
|
this.cost = cost;
|
|
this.monitor=monitor;
|
|
this.flag=flag;
|
|
}
|
|
public Inet6AddressGroup getDestination() {
|
|
return destination;
|
|
}
|
|
public Inet6Address getNexthop() {
|
|
return nexthop;
|
|
}
|
|
public IPv6NetworkLink getDestlink() {
|
|
return destlink;
|
|
}
|
|
public String getProto() {
|
|
return proto;
|
|
}
|
|
public int getPre() {
|
|
return pre;
|
|
}
|
|
@Override
|
|
public String toString() {
|
|
return getDestination()+"\t"+getProto()+"\t"+getPre()+"\t"+getCost()+"\t"+getFlag()+"\t"+getNexthop().getHostAddress()+"\t"+getDestlink().getName();
|
|
}
|
|
public long getCost() {
|
|
return cost;
|
|
}
|
|
public boolean checkMatch(Inet6Address ia) {
|
|
return destination.checkMatch(ia);
|
|
}
|
|
@Override
|
|
public int compareTo(RouteItem o) {
|
|
int v1=destination.compareTo(o.destination);
|
|
if(v1!=0)
|
|
return v1;
|
|
int v2=Integer.compare(pre, o.pre);
|
|
if(v2!=0)
|
|
return v2;
|
|
int v3=Long.compare(cost, o.cost);
|
|
if(v3!=0)
|
|
return v3;
|
|
if(monitor==null||o.monitor==null||(!(monitor instanceof DelayMonitorData))||(!(o.monitor instanceof DelayMonitorData)))
|
|
return v3;
|
|
if(!(monitor instanceof QueueingMonitorDataImpl)||!(o.monitor instanceof QueueingMonitorDataImpl))
|
|
return Long.compare(((DelayMonitorData)monitor).getOutDelay(), ((DelayMonitorData)o.monitor).getOutDelay());
|
|
return Long.compare(((DelayMonitorData)monitor).getOutDelay()+((QueueingMonitorDataImpl)monitor).getQueueingDelay(), ((DelayMonitorData)o.monitor).getOutDelay()+((QueueingMonitorDataImpl)o.monitor).getQueueingDelay());
|
|
}
|
|
}
|