Package com.fathomdb.hash

Examples of com.fathomdb.hash.Md5Hash


    }
  }

  @Override
  protected Md5Hash getSourceMd5(OpsTarget target) throws OpsException {
    Md5Hash resolved = getResolved(target);

    if (resolved == null) {
      throw new IllegalStateException("Hash could not be determined (file could not be resolved?)");
    }
View Full Code Here


    InputStream is = null;

    try {
      is = Files.newInputStream(md5Path);
      String md5 = IoUtils.readAll(is);
      return new Md5Hash(md5);
    } finally {
      IoUtils.safeClose(is);
    }
  }
View Full Code Here

    // OpsServer server = smartGetServer(true);
    // Agent agent = server.getAgent();

    File filePath = getFilePath();

    Md5Hash sourceMd5 = null;
    if (!OpsContext.isDelete()) {
      sourceMd5 = getSourceMd5(target);
    }

    Md5Hash remoteMd5;
    if (target.isMachineTerminated()) {
      remoteMd5 = null;
    } else {
      remoteMd5 = target.getFileHash(filePath);
    }

    boolean isUpToDate = Objects.equal(sourceMd5, remoteMd5);

    if (OpsContext.isDelete()) {
      if (remoteMd5 != null) {
        target.rm(filePath);
        doDeleteAction(target);
      }
    }

    if (OpsContext.isConfigure()) {
      boolean changed = false;

      if (mkdirs != null) {
        if (remoteMd5 == null) {
          File dir = filePath.getParentFile();
          if (target.getFilesystemInfoFile(dir) == null) {
            // TODO: Can mkdir return true/false to indicate presence?
            target.mkdir(dir, mkdirs.mode);

            if (mkdirs.owner != null) {
              target.chown(dir, mkdirs.owner, mkdirs.group, false, false);
            }
          }
        }
      }

      boolean doUpload = false;
      if (!isUpToDate) {
        doUpload = true;
        if (isOnlyIfNotExists()) {
          if (remoteMd5 != null) {
            log.info("File already exists, and file set to create only if not exists: exiting");
            doUpload = false;
          }
        }
      }

      if (OpsContext.isForce()) {
        doUpload = true;
      }

      if (doUpload) {
        File newSymlinkDestination = null;
        if (isSymlinkVersions()) {
          throw new UnsupportedOperationException();

          // newSymlinkDestination = new FilePath(getRemoteFilePath() + "-" +
          // OpsSystem.buildSimpleTimeString());
          // uploadFile(newSymlinkDestination.asString());
          //
          // remoteMd5 = agent.getRemoteMd5(newSymlinkDestination);
        } else {
          uploadFile(target, filePath);
          if (remoteMd5 == null) {
            newFileWasCreated = true;
          }

          remoteMd5 = target.getFileHash(filePath);
        }

        if (!Objects.equal(remoteMd5, sourceMd5)) {
          String remote = target.readTextFile(filePath);
          Md5Hash debugSourceMd5 = getSourceMd5(target);
          debugSourceMd5 = getSourceMd5(target);
          log.debug("debugSourceMd5: " + debugSourceMd5 + " vs " + remoteMd5);
          throw new IllegalStateException("Uploaded file, but contents did not then match: " + filePath);
        }
View Full Code Here

    if (hash == null) {
      throw new IllegalStateException();
    }

    // We return the hash in the hope that we've already copied the artifact!
    return new Md5Hash(hash);
  }
View Full Code Here

  private File checkDirectory(File base, Md5Hash hash, int splits) throws OpsException {
    String relativePath = toRelativePath(hash, splits);
    File seedFile = new File(base, relativePath);
    FilesystemInfo seedFileInfo = host.getFilesystemInfoFile(seedFile);
    if (seedFileInfo != null) {
      Md5Hash seedFileHash = host.getFileHash(seedFile);
      if (!seedFileHash.equals(hash)) {
        log.warn("Hash mismatch on file: " + seedFile);
        return null;
      }

      // For LRU
View Full Code Here

    }
    return null;
  }

  public FilesystemCasObject copyToStaging(CasStoreObject src) throws OpsException {
    Md5Hash hash = src.getHash();
    File cachePath = new File(PATH_CACHE, toRelativePath(hash, 2));
    host.mkdir(cachePath.getParentFile());

    // This could be copyTo0, but it serves as a nice test that copyTo is falling through correctly
    // src.copyTo(host, cachePath);
View Full Code Here

TOP

Related Classes of com.fathomdb.hash.Md5Hash

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.