Beispiel #1
0
 private static boolean containsCoordinatorResponse(Collection<PingData> rsps) {
   if (rsps == null || rsps.isEmpty()) return false;
   for (PingData rsp : rsps) {
     if (rsp.isCoord()) return true;
   }
   return false;
 }
Beispiel #2
0
 /**
  * Creates a byte[] representation of the PingData, but DISCARDING the view it contains.
  *
  * @param data the PingData instance to serialize.
  * @return
  */
 protected byte[] serializeWithoutView(PingData data) {
   final PingData clone =
       new PingData(
               data.getAddress(), data.isServer(), data.getLogicalName(), data.getPhysicalAddr())
           .coord(data.isCoord());
   try {
     return Util.streamableToByteBuffer(clone);
   } catch (Exception e) {
     log.error(Util.getMessage("ErrorSerializingPingData"), e);
     return null;
   }
 }
Beispiel #3
0
    public void addResponse(PingData rsp, boolean overwrite) {
      if (rsp == null) return;
      promise.getLock().lock();
      try {
        if (overwrite) ping_rsps.remove(rsp);

        // https://jira.jboss.org/jira/browse/JGRP-1179
        int index = ping_rsps.indexOf(rsp);
        if (index == -1) {
          ping_rsps.add(rsp);
          promise.getCond().signalAll();
        } else if (rsp.isCoord()) {
          PingData pr = ping_rsps.get(index);

          // Check if the already existing element is not server
          if (!pr.isCoord()) {
            ping_rsps.set(index, rsp);
            promise.getCond().signalAll();
          }
        }
      } finally {
        promise.getLock().unlock();
      }
    }
Beispiel #4
0
  protected void write(List<PingData> list, OutputStream out) throws Exception {
    try {
      for (PingData data : list) {
        String logical_name = data.getLogicalName();
        Address addr = data.getAddress();
        PhysicalAddress phys_addr = data.getPhysicalAddr();
        if (logical_name == null || addr == null || phys_addr == null) continue;
        out.write(logical_name.getBytes());
        out.write(WHITESPACE);

        out.write(addressAsString(addr).getBytes());
        out.write(WHITESPACE);

        out.write(phys_addr.toString().getBytes());
        out.write(WHITESPACE);

        out.write(
            data.isCoord() ? String.format("T%n").getBytes() : String.format("F%n").getBytes());
      }
    } finally {
      Util.close(out);
    }
  }