public static final transient String TCP_LISTEN_HOST = "tcpListenHost";
public static final transient String MEMBER_NAME = "memberName";
- public static final transient byte[] TRIBES_MBR_BEGIN = new byte[] {84, 82, 73, 66, 69, 83, 45, 66};
- public static final transient byte[] TRIBES_MBR_END = new byte[] {84, 82, 73, 66, 69, 83, 45, 69};
+ public static final transient byte[] TRIBES_MBR_BEGIN = new byte[] {84, 82, 73, 66, 69, 83, 45, 66, 1, 0};
+ public static final transient byte[] TRIBES_MBR_END = new byte[] {84, 82, 73, 66, 69, 83, 45, 69, 1, 0};
/**
* The listen host for this member
* The tcp listen port for this member
*/
protected int port;
+ /**
+ * The udp listen port for this member
+ */
+ protected int udpPort = -1;
/**
* The tcp/SSL listen port for this member
8+ //alive time
4+ //port
4+ //secure port
+ 4+ //udp port
1+ //host length
host.length+ //host
4+ //command length
//alive - 8 bytes
//port - 4 bytes
//secure port - 4 bytes
+ //udp port - 4 bytes
//host length - 1 byte
//host - hl bytes
//clen - 4 bytes
//secure port
XByteBuffer.toBytes(securePort,data,pos);
pos += 4;
+ //udp port
+ XByteBuffer.toBytes(udpPort,data,pos);
+ pos += 4;
//host length
data[pos++] = hl;
//host
//alive - 8 bytes
//port - 4 bytes
//secure port - 4 bytes
+ //udp port - 4 bytes
//host length - 1 byte
//host - hl bytes
//clen - 4 bytes
int pos = offset;
if (XByteBuffer.firstIndexOf(data,offset,TRIBES_MBR_BEGIN)!=pos) {
- throw new IllegalArgumentException("Invalid package, should start with:"+org.apache.catalina.tribes.util.Arrays.toString(TRIBES_MBR_BEGIN)+" Possibly an incompatible client broadcasting on the same multicast address.");
+ throw new IllegalArgumentException("Invalid package, should start with:"+org.apache.catalina.tribes.util.Arrays.toString(TRIBES_MBR_BEGIN));
}
if ( length < (TRIBES_MBR_BEGIN.length+4) ) {
System.arraycopy(data, pos, sportd, 0, 4);
pos += 4;
+ byte[] uportd = new byte[4];
+ System.arraycopy(data, pos, uportd, 0, 4);
+ pos += 4;
byte hl = data[pos++];
member.setHost(addr);
member.setPort(XByteBuffer.toInt(portd, 0));
member.setSecurePort(XByteBuffer.toInt(sportd, 0));
+ member.setUdpPort(XByteBuffer.toInt(uportd, 0));
member.setMemberAliveTime(XByteBuffer.toLong(alived, 0));
member.setUniqueId(uniqueId);
member.payload = payload;
public int getSecurePort() {
return securePort;
}
+
+ public int getUdpPort() {
+ return udpPort;
+ }
public void setMemberAliveTime(long time) {
memberAliveTime=time;
public void setSecurePort(int securePort) {
this.securePort = securePort;
+ this.dataPkg = null;
+ }
+
+ public void setUdpPort(int port) {
+ this.udpPort = port;
+ this.dataPkg = null;
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
public class MemberSerialization extends TestCase {
MemberImpl m1, m2, p1,p2;
byte[] payload = null;
+ int udpPort = 3445;
protected void setUp() throws Exception {
super.setUp();
payload = new byte[333];
m2.setDomain(new byte[] {1,2,3,4,5,6,7,8,9});
m1.setCommand(new byte[] {1,2,4,5,6,7,8,9});
m2.setCommand(new byte[] {1,2,4,5,6,7,8,9});
+ m1.setUdpPort(udpPort);
+ m2.setUdpPort(m1.getUdpPort());
}
public void testCompare() throws Exception {
assertFalse(p1.equals(p2));
}
+ public void testUdpPort() throws Exception {
+ byte[] md1 = m1.getData();
+ byte[] md2 = m2.getData();
+
+ MemberImpl a1 = MemberImpl.getMember(md1);
+ MemberImpl a2 = MemberImpl.getMember(md2);
+
+ assertEquals(true, a1.getUdpPort()==a2.getUdpPort());
+ assertEquals(true,a1.getUdpPort()==udpPort);
+
+
+ }
+
public void testSerializationOne() throws Exception {
MemberImpl m = m1;
byte[] md1 = m.getData(false,true);