コード例 #1
0
ファイル: EMDClient.java プロジェクト: elambert/honeycomb
  /**
   * This <code>setMetadata</code> method is the OA callback to populate a local cache.
   *
   * @param <code>SystemMetadata</code> are the SystemMetadata extracted from the local fragment
   * @param <code>Disk</code> is the disk containing the fragment
   *     <p>note: this method DEPRECIATED, crawl uses above methods instead. Kept here for reference
   *     until replacement methods are validated.
   */
  public void setMetadata(SystemMetadata systemMD, byte[] MDField, Disk disk) {
    if (LOG.isLoggable(Level.FINE)) {
      LOG.fine(
          "setMetadata has been called for oid " + systemMD.getOID() + " on disk [" + disk + "]");
    }

    // Precompute the connection
    ConnectionFactory.DiskConnection[] connections = new ConnectionFactory.DiskConnection[1];
    connections[0] = ConnectionFactory.getConnection(disk);

    // Check if the system metadata should be set
    ArrayList disks =
        MDDiskAbstraction.getInstance((byte) 0)
            .getUsedDisksFromMapId(systemMD.getLayoutMapId(), CacheClientInterface.SYSTEM_CACHE);
    if (disks.contains(disk)) {
      setMetadata(CacheClientInterface.SYSTEM_CACHE, connections, systemMD.getOID(), systemMD);
    }

    try {
      // Find the cacheId
      MDHeader header = new MDHeader(MDField);

      String cacheId = header.getCacheId();

      if (cacheId != null) {
        disks =
            MDDiskAbstraction.getInstance((byte) 0)
                .getUsedDisksFromMapId(systemMD.getLayoutMapId(), cacheId);

        if (disks.contains(disk)) {
          CacheRecord metadataObject =
              CacheManager.getInstance()
                  .getClientInterface(cacheId)
                  .generateMetadataObject(systemMD.getOID());

          // Set the metadata
          setMetadata(cacheId, connections, systemMD.getOID(), metadataObject);
        }
      }

    } catch (IOException e) {
      LOG.log(Level.SEVERE, "Failed to update the metadata [" + e.getMessage() + "]", e);
    } catch (EMDException e) {
      LOG.log(Level.SEVERE, "Failed to update the metadata [" + e.getMessage() + "]", e);
    }
  }
コード例 #2
0
ファイル: EMDClient.java プロジェクト: elambert/honeycomb
  /** Sets metadata for cacheId on given disk (not system MD) */
  private void setExtMetadata(
      NewObjectIdentifier oid,
      String cacheId,
      Disk disk,
      ConnectionFactory.DiskConnection[] connections) {

    // not all layout disks necessarily used, depends on reduncancy
    if (usesDisk(oid.getLayoutMapId(), cacheId, disk)) {
      try {
        CacheRecord metadataObject =
            CacheManager.getInstance().getClientInterface(cacheId).generateMetadataObject(oid);
        // Set the metadata
        setMetadata(cacheId, connections, oid, metadataObject);
      } catch (EMDException e) {
        LOG.log(Level.SEVERE, "Failed to update the metadata [" + e.getMessage() + "]", e);
      }
    }
  }