use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class BuffersTest method testRead3.
public void testRead3() throws Exception {
byte[] cookie = { 'b', 'e', 'l', 'a' };
IpAddress addr = new IpAddress(7500);
ByteArrayDataOutputStream out = new ByteArrayDataOutputStream();
addr.writeTo(out);
MockSocketChannel ch = new MockSocketChannel().bytesToRead(ByteBuffer.allocate(cookie.length + Global.SHORT_SIZE + out.position()).put(cookie).putShort(Version.version).put(out.buffer(), 0, out.position()).flip());
int remaining = ch.bytesToRead().remaining();
ch.bytesToRead().limit(remaining - 10);
Buffers bufs = new Buffers(ByteBuffer.allocate(cookie.length), ByteBuffer.allocate(Global.SHORT_SIZE), ByteBuffer.allocate(out.position()));
boolean rc = bufs.read(ch);
assert !rc;
ch.bytesToRead().limit(remaining - 2);
rc = bufs.read(ch);
assert !rc;
ch.bytesToRead().limit(remaining);
rc = bufs.read(ch);
assert rc;
readCookieVersionAndAddress(bufs, cookie, addr);
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class TLSTest method create.
private JChannel create(String name) throws Exception {
TCP transport = new TCP();
transport.setBindAddress(InetAddress.getLoopbackAddress());
transport.setBindPort(9600);
transport.setSocketFactory(sslContexts.containsKey(name) ? new DefaultSocketFactory(sslContexts.get(name)) : new DefaultSocketFactory());
TCPPING ping = new TCPPING();
ping.setInitialHosts2(Collections.singletonList(new IpAddress(transport.getBindAddress(), transport.getBindPort())));
return new JChannel(transport, ping, new NAKACK2(), new UNICAST3(), new STABLE(), new GMS()).name(name);
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class Util method readAddress.
public static Address readAddress(DataInput in) throws IOException, ClassNotFoundException {
byte flags = in.readByte();
if (Util.isFlagSet(flags, Address.NULL))
return null;
Address addr;
if (Util.isFlagSet(flags, Address.UUID_ADDR)) {
addr = new UUID();
addr.readFrom(in);
} else if (Util.isFlagSet(flags, Address.SITE_UUID)) {
addr = new SiteUUID();
addr.readFrom(in);
} else if (Util.isFlagSet(flags, Address.SITE_MASTER)) {
addr = new SiteMaster();
addr.readFrom(in);
} else if (Util.isFlagSet(flags, Address.IP_ADDR)) {
addr = new IpAddress();
addr.readFrom(in);
} else
addr = readOtherAddress(in);
return addr;
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class AUTHTest method testFixedMembershipTokenIPv4.
public void testFixedMembershipTokenIPv4() throws Exception {
FixedMembershipToken tok = new FixedMembershipToken();
tok.setMemberList("192.168.1.6,10.1.1.1/7500,localhost/7800");
assert !tok.isInMembersList(new IpAddress("192.168.1.3", 7500));
assert !tok.isInMembersList(new IpAddress("10.1.1.1", 7000));
assert tok.isInMembersList(new IpAddress("10.1.1.1", 7500));
// port is not matched
assert tok.isInMembersList(new IpAddress("192.168.1.6", 7500));
// port is not matched
assert tok.isInMembersList(new IpAddress("192.168.1.6", 0));
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class TCPGOSSIP method addInitialHost.
@ManagedOperation
public void addInitialHost(String hostname, int port) {
// if there is such a stub already, remove and destroy it
removeInitialHost(hostname, port);
// now re-add it
InetSocketAddress isa = new InetSocketAddress(hostname, port);
initial_hosts.add(isa);
stubManager.createAndRegisterStub(null, new IpAddress(isa.getAddress(), isa.getPort()));
// tries to connect all unconnected stubs
stubManager.connectStubs();
}
Aggregations