org.jgroups.protocols.PingData Java Examples
The following examples show how to use
org.jgroups.protocols.PingData.
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 |
@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: UniTimeClusterDiscovery.java From unitime with Apache License 2.0 | 6 votes |
protected void update(PingData data) { if (!ClusterDiscoveryDAO.isConfigured()) return; org.hibernate.Session hibSession = ClusterDiscoveryDAO.getInstance().createNewSession(); String own_address = addressAsString(data.getAddress()); Transaction tx = null; try { tx = hibSession.beginTransaction(); ClusterDiscovery cluster = ClusterDiscoveryDAO.getInstance().get(new ClusterDiscovery(own_address, cluster_name), hibSession); if (cluster == null) cluster = new ClusterDiscovery(own_address, cluster_name); cluster.setPingData(serializeWithoutView(data)); cluster.setTimeStamp(new Date()); hibSession.saveOrUpdate(cluster); hibSession.flush(); if (tx != null) tx.commit(); } catch (Exception e) { if (tx!=null) tx.rollback(); log.info("Failed to update my data for cluster " + cluster_name + ": " + e.getMessage()); } finally { hibSession.close(); } }
Example #3
Source File: UniTimeClusterDiscovery.java From unitime with Apache License 2.0 | 4 votes |
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)); }