forked from KNEMC/KLALB
KLALB 3.6.0开发一半的状态
This commit is contained in:
@@ -1,14 +1,7 @@
|
||||
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.IPv6AddressGroup;
|
||||
import org.kne.cloud.network.monitor.DelayMonitorData;
|
||||
import org.kne.cloud.network.monitor.MonitorData;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class RouteItem implements Comparable<RouteItem>,Cloneable{
|
||||
private IPv6AddressGroup destination;
|
||||
@@ -18,14 +11,11 @@ public class RouteItem implements Comparable<RouteItem>,Cloneable{
|
||||
private int pre;
|
||||
private long cost;
|
||||
private String flag;
|
||||
private MonitorData monitor;
|
||||
private Supplier<Long> costSupplier;
|
||||
private boolean isLoopback;
|
||||
public String getFlag() {
|
||||
return flag;
|
||||
}
|
||||
public MonitorData getMonitor() {
|
||||
return monitor;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(cost, destination, destlink, flag, nexthop, pre, proto);
|
||||
@@ -56,7 +46,7 @@ public class RouteItem implements Comparable<RouteItem>,Cloneable{
|
||||
this.isLoopback=isLoopback;
|
||||
}
|
||||
public RouteItem(IPv6AddressGroup destination, IPv6Address nexthop, IPv6NetworkLink destlink, String proto, int pre,
|
||||
long cost,MonitorData monitor,String flag,boolean isLoopback) {
|
||||
long cost,Supplier<Long> costSupplier,String flag,boolean isLoopback) {
|
||||
super();
|
||||
this.destination = destination;
|
||||
this.nexthop = nexthop;
|
||||
@@ -64,7 +54,7 @@ public class RouteItem implements Comparable<RouteItem>,Cloneable{
|
||||
this.proto = proto;
|
||||
this.pre = pre;
|
||||
this.cost = cost;
|
||||
this.monitor=monitor;
|
||||
this.costSupplier=costSupplier;
|
||||
this.flag=flag;
|
||||
this.isLoopback=isLoopback;
|
||||
}
|
||||
@@ -99,6 +89,7 @@ public class RouteItem implements Comparable<RouteItem>,Cloneable{
|
||||
public boolean checkMatch(byte[] ia) {
|
||||
return destination.checkMatch(ia);
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public int compareTo(RouteItem o) {
|
||||
int v1=destination.compareTo(o.destination);
|
||||
@@ -110,22 +101,23 @@ public class RouteItem implements Comparable<RouteItem>,Cloneable{
|
||||
int v3=Long.compare(cost, o.cost);
|
||||
return v3;
|
||||
}
|
||||
public Supplier<Long> getCostSupplier() {
|
||||
return costSupplier;
|
||||
}
|
||||
@Override
|
||||
public Object clone() {
|
||||
try {
|
||||
RouteItem ri=(RouteItem) super.clone();
|
||||
if(monitor!=null)
|
||||
ri.monitor=(MonitorData) monitor.clone();
|
||||
return ri;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void preSort() {
|
||||
if(monitor!=null) {
|
||||
cost=((DelayMonitorData)monitor).getOutDelay();
|
||||
//在排序前调用,计算cost
|
||||
public void updateCost() {
|
||||
if(costSupplier!=null) {
|
||||
cost=costSupplier.get();
|
||||
}
|
||||
}
|
||||
public boolean ECMPequals(RouteItem prevr) {
|
||||
|
||||
Reference in New Issue
Block a user