use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class IpAddressTest method testConstructor.
public void testConstructor() throws Exception {
IpAddress tmp = new IpAddress("192.168.1.5:7800");
assert tmp.getPort() == 7800;
assert tmp.getIpAddress().equals(InetAddress.getByName("192.168.1.5"));
tmp = new IpAddress("10.1.2.3");
assert tmp.getPort() == 0;
assert tmp.getIpAddress().equals(InetAddress.getByName("10.1.2.3"));
tmp = new IpAddress("fe80::21b:21ff:fe07:a3b0:6000");
assert tmp.getPort() == 6000;
assert tmp.getIpAddress().equals(InetAddress.getByName("fe80::21b:21ff:fe07:a3b0"));
tmp = new IpAddressUUID(7500);
assert tmp.getPort() == 7500;
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class IpAddressTest method testCopy.
public void testCopy() {
IpAddress tmp = a.copy();
assert tmp.equals(a);
tmp = j.copy();
assert tmp.equals(j);
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class STATE_SOCK method createStreamToProvider.
protected Tuple<InputStream, Object> createStreamToProvider(Address provider, StateHeader hdr) throws Exception {
IpAddress address = hdr.bind_addr;
Socket socket = null;
try {
socket = getSocketFactory().createSocket("jgroups.state_sock.sock");
socket.bind(new InetSocketAddress(bind_addr, 0));
socket.setReceiveBufferSize(buffer_size);
Util.connect(socket, new InetSocketAddress(address.getIpAddress(), address.getPort()), 0);
log.debug("%s: connected to state provider %s:%d", local_addr, address.getIpAddress(), address.getPort());
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
Util.writeAddress(local_addr, out);
return new Tuple<>(new BufferedInputStream(socket.getInputStream(), buffer_size), socket);
} catch (Throwable t) {
Util.close(socket);
if (t instanceof Exception)
throw (Exception) t;
throw new Exception("failed creating socket", t);
}
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class Util method readAddress.
public static Address readAddress(DataInput in) throws Exception {
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 if (Util.isFlagSet(flags, Address.IP_ADDR_UUID)) {
addr = new IpAddressUUID();
addr.readFrom(in);
} else {
addr = readOtherAddress(in);
}
return addr;
}
use of org.jgroups.stack.IpAddress in project JGroups by belaban.
the class SizeTest method testIpAddress2.
public static void testIpAddress2() throws Exception {
IpAddress addr = new IpAddress(3456);
_testSize(addr);
}
Aggregations