Search in sources :

Example 71 with IpAddress

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);
}
Also used : MockSocketChannel(org.jgroups.nio.MockSocketChannel) IpAddress(org.jgroups.stack.IpAddress) Buffers(org.jgroups.nio.Buffers) ByteArrayDataOutputStream(org.jgroups.util.ByteArrayDataOutputStream)

Example 72 with IpAddress

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);
}
Also used : NAKACK2(org.jgroups.protocols.pbcast.NAKACK2) JChannel(org.jgroups.JChannel) DefaultSocketFactory(org.jgroups.util.DefaultSocketFactory) IpAddress(org.jgroups.stack.IpAddress) STABLE(org.jgroups.protocols.pbcast.STABLE) GMS(org.jgroups.protocols.pbcast.GMS)

Example 73 with IpAddress

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;
}
Also used : IpAddress(org.jgroups.stack.IpAddress) SiteMaster(org.jgroups.protocols.relay.SiteMaster) IpAddress(org.jgroups.stack.IpAddress) SiteUUID(org.jgroups.protocols.relay.SiteUUID) SiteUUID(org.jgroups.protocols.relay.SiteUUID)

Example 74 with IpAddress

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));
}
Also used : FixedMembershipToken(org.jgroups.auth.FixedMembershipToken) IpAddress(org.jgroups.stack.IpAddress)

Example 75 with IpAddress

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();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) IpAddress(org.jgroups.stack.IpAddress) ManagedOperation(org.jgroups.annotations.ManagedOperation)

Aggregations

IpAddress (org.jgroups.stack.IpAddress)87 InetSocketAddress (java.net.InetSocketAddress)15 Address (org.jgroups.Address)13 InetAddress (java.net.InetAddress)7 Test (org.testng.annotations.Test)7 Event (org.jgroups.Event)6 PhysicalAddress (org.jgroups.PhysicalAddress)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 DataInputStream (java.io.DataInputStream)4 DataOutputStream (java.io.DataOutputStream)4 IOException (java.io.IOException)4 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)3 JChannel (org.jgroups.JChannel)3 ManagedOperation (org.jgroups.annotations.ManagedOperation)3 DefaultSocketFactory (org.jgroups.util.DefaultSocketFactory)3 Container (io.fabric8.kubernetes.api.model.Container)2 ContainerPort (io.fabric8.kubernetes.api.model.ContainerPort)2 Pod (io.fabric8.kubernetes.api.model.Pod)2 ServerSocket (java.net.ServerSocket)2