Ejemplo n.º 1
0
  @Override
  public Object clone() throws CloneNotSupportedException {
    ReplicaCatalogEntry r = new ReplicaCatalogEntry();

    r.setPFN(getPFN());
    r.setResourceHandle(getResourceHandle());
    r.addAttribute(this.m_attributeMap);

    return r;
  }
Ejemplo n.º 2
0
  /**
   * Merges the attribute maps of two entries in a controlled fashion. Entries are only merged with
   * another entry, if the physical filenames match.
   *
   * @param a is one replica catalog entry to merge.
   * @param b is the other replica catalog entry to merge.
   * @param overwrite resolves intersections. If true, uses rce's attribute to remain, if false, the
   *     original attribute remains.
   * @return the merged entry, if the PFNs matched, or <code>null</code> if the PFN mismatched.
   */
  public static ReplicaCatalogEntry merge(
      ReplicaCatalogEntry a, ReplicaCatalogEntry b, boolean overwrite) {
    ReplicaCatalogEntry result = null;

    String pfn1 = a.getPFN();
    String pfn2 = b.getPFN();
    if (pfn1 == null && pfn2 == null || pfn1 != null && pfn2 != null && pfn1.equals(pfn2)) {
      result = new ReplicaCatalogEntry(pfn1, a.m_attributeMap);
      result.merge(b, overwrite); // result cannot be false
    }

    // will return null on PFN mismatch
    return result;
  }
Ejemplo n.º 3
0
  /**
   * Matches two ReplicaCatalogEntry objects. The primary key in this case is the pfn and all the
   * attributes.
   *
   * @return true if the pfn and all the attributes match, false otherwise.
   */
  public boolean equals(Object obj) {
    // null check
    if (obj == null) return false;

    // see if type of objects match
    if (!(obj instanceof ReplicaCatalogEntry)) return false;

    ReplicaCatalogEntry rce = (ReplicaCatalogEntry) obj;
    String pfn1 = this.m_pfn;
    String pfn2 = rce.getPFN();

    // rce with null pfns are assumed to match
    boolean result =
        (pfn1 == null && pfn2 == null
            || pfn1 != null
                && pfn2 != null
                && pfn1.equals(pfn2)
                && this.getAttributeCount() == rce.getAttributeCount());

    if (result) {
      String key;
      Object val;

      // do the matching on attributes now
      for (Iterator it = rce.getAttributeIterator(); it.hasNext(); ) {
        key = (String) it.next();
        val = rce.getAttribute(key);
        if (hasAttribute(key)) {
          if (!(getAttribute(key).equals(val))) {
            result = false;
            break;
          }
        }
      }
    }

    return result;
  }
Ejemplo n.º 4
0
  /**
   * Merges the attribute maps in a controlled fashion. An entry is only merged with another entry,
   * if the physical filenames match.
   *
   * @param rce is another replica catalog entry to merge with.
   * @param overwrite resolves intersections. If true, uses rce's attribute to remain, if false, the
   *     original attribute remains.
   * @return true if a merge was attempted, false if the PFNs did not match.
   */
  public boolean merge(ReplicaCatalogEntry rce, boolean overwrite) {
    String pfn1 = this.m_pfn;
    String pfn2 = rce.getPFN();
    boolean result =
        (pfn1 == null && pfn2 == null || pfn1 != null && pfn2 != null && pfn1.equals(pfn2));

    // only merge if PFN match
    if (result) {
      String key;
      Object val;

      for (Iterator i = rce.getAttributeIterator(); i.hasNext(); ) {
        key = (String) i.next();
        val = rce.getAttribute(key);
        if (hasAttribute(key)) {
          if (overwrite) setAttribute(key, val);
        } else {
          setAttribute(key, val);
        }
      }
    }

    return result;
  }