KLALB
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package org.kne.cloud.network.klalb;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public class KLALBBlock implements Comparable<KLALBBlock>{
|
||||
volatile byte[]data;
|
||||
volatile int size;
|
||||
volatile long number;
|
||||
|
||||
|
||||
volatile long time=-1;
|
||||
volatile Thread thread;
|
||||
public KLALBBlock(byte[] b, int size,long number) {
|
||||
data=b;
|
||||
this.size=size;
|
||||
this.number=number;
|
||||
}
|
||||
public KLALBBlock() {
|
||||
// TODO 自动生成的构造函数存根
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
if(number>0) {
|
||||
return "DATA"+number+":"+size;
|
||||
}else {
|
||||
return "ACK"+(-number);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(number);
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
KLALBBlock other = (KLALBBlock) obj;
|
||||
return number == other.number;
|
||||
}
|
||||
@Override
|
||||
public int compareTo(KLALBBlock o) {
|
||||
if(time>o.time) {
|
||||
return 1;
|
||||
}else if(time<o.time){
|
||||
return -1;
|
||||
}else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user