org.jgroups.PhysicalAddress Java Examples

The following examples show how to use org.jgroups.PhysicalAddress. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServerTestBase.java    From openshift-ping with Apache License 2.0 6 votes vote down vote up
@Test @Ignore
public void testResponse() throws Exception {
    Address local_addr = pinger.getLocalAddress();
    PhysicalAddress physical_addr = (PhysicalAddress) pinger
            .down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr));
    PingData data = createPingData(local_addr, physical_addr);
    final PingHeader hdr = getPingHeader(data);
    Message msg = new Message(null).setFlag(Message.Flag.DONT_BUNDLE)
            .putHeader(pinger.getId(), hdr).setBuffer(streamableToBuffer(data));
    URL url = new URL("http://localhost:8888");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY);
    conn.addRequestProperty(Server.CLUSTER_NAME, TestBase.CLUSTER_NAME);
    conn.setDoOutput(true);
    conn.setRequestMethod("POST");

    DataOutputStream out = new DataOutputStream(conn.getOutputStream());
    msg.writeTo(out);
    out.flush();

    Assert.assertEquals(200, conn.getResponseCode());
}
 
Example #2
Source File: OpenshiftPing.java    From openshift-ping with Apache License 2.0 6 votes vote down vote up
@Override
protected void sendMcastDiscoveryRequest(Message msg) {
    final List<InetSocketAddress> hosts = readAll();
    final PhysicalAddress physical_addr = (PhysicalAddress) down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr));
    if (!(physical_addr instanceof IpAddress)) {
        log.error("Unable to send PING requests: physical_addr is not an IpAddress.");
        return;
    }
    // XXX: is it better to force this to be defined?
    // assume symmetry
    final int port = ((IpAddress) physical_addr).getPort();
    for (InetSocketAddress host: hosts) {
        // JGroups messages cannot be reused - https://github.com/belaban/workshop/blob/master/slides/admin.adoc#problem-9-reusing-a-message-the-sebastian-problem
        Message msgToHost = msg.copy();
        msgToHost.dest(new IpAddress(host.getAddress(), port));
        sendDown(down_prot, msgToHost);
    }
}
 
Example #3
Source File: UniTimeClusterDiscovery.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void discoveryRequestReceived(Address sender, String logical_name, PhysicalAddress physical_addr) {
    super.discoveryRequestReceived(sender, logical_name, physical_addr);
    if(physical_addr != null) {
        if(!initial_hosts.contains(physical_addr))
            dynamic_hosts.addIfAbsent(physical_addr);
    }
}
 
Example #4
Source File: KUBE_PING.java    From jgroups-kubernetes with Apache License 2.0 4 votes vote down vote up
private PhysicalAddress getCurrentPhysicalAddress(Address addr) {
    return (PhysicalAddress)down(new Event(Event.GET_PHYSICAL_ADDRESS, addr));
}
 
Example #5
Source File: UniTimeClusterDiscovery.java    From unitime with Apache License 2.0 4 votes vote down vote up
public List<PhysicalAddress> getInitialHosts() {
    return initial_hosts;
}
 
Example #6
Source File: UniTimeClusterDiscovery.java    From unitime with Apache License 2.0 4 votes vote down vote up
public void setInitialHosts(List<PhysicalAddress> initial_hosts) {
    this.initial_hosts=initial_hosts;
}
 
Example #7
Source File: UniTimeClusterDiscovery.java    From unitime with Apache License 2.0 4 votes vote down vote up
public void init() throws Exception {
    super.init();
    dynamic_hosts=new BoundedList<PhysicalAddress>(max_dynamic_hosts);
}
 
Example #8
Source File: UniTimeClusterDiscovery.java    From unitime with Apache License 2.0 4 votes vote down vote up
protected void writeOwnInformation() {
    PhysicalAddress physical_addr=(PhysicalAddress)down(new Event(Event.GET_PHYSICAL_ADDRESS, local_addr));
    update(new PingData(local_addr, is_server, UUID.get(local_addr), physical_addr).coord(is_coord));
}