コード例 #1
0
ファイル: Discovery.java プロジェクト: randythomas/JGroups
 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;
 }
コード例 #2
0
ファイル: Discovery.java プロジェクト: DevFactory/JGroups
 /**
  * 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;
   }
 }
コード例 #3
0
ファイル: Discovery.java プロジェクト: randythomas/JGroups
    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();
      }
    }
コード例 #4
0
ファイル: Discovery.java プロジェクト: DevFactory/JGroups
  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);
    }
  }