Examples of MD5Hash


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

Examples of com.fathomdb.hash.Md5Hash

    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

Examples of com.fathomdb.hash.Md5Hash

    // 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

Examples of com.fathomdb.hash.Md5Hash

    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

Examples of com.fathomdb.hash.Md5Hash

  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

Examples of com.fathomdb.hash.Md5Hash

    }
    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

Examples of com.linkedin.d2.balancer.util.hashing.MD5Hash

        Assert.assertEquals(hintedUri2, uri1.toString() + "/foo");
        // end test KeyMapper target host hint

        if (partitionMethod == 2)
        {
          hashFunction = new MD5Hash();
        }
        for (URI uri : expectedUris)
        {
          if (clientUri.contains(uri.toString()))
          {
View Full Code Here

Examples of org.apache.hadoop.io.MD5Hash

public class TestHashUtility {

  @Test
  public void testMD5HashForTextValueValue() throws IOException {
    Text key = new Text("abc2hf123");
    MD5Hash md5HashKey1 = HashUtility.getMD5Hash(key);
    MD5Hash md5HashKey2 = HashUtility.getMD5Hash(key);
    assertEquals(md5HashKey1, md5HashKey2);
  }
View Full Code Here

Examples of org.apache.hadoop.io.MD5Hash

  }

  @Test
  public void testMD5HashForStringValue() throws IOException {
    String key = new String("abc2hf123");
    MD5Hash md5HashKey1 = HashUtility.getMD5Hash(key);
    MD5Hash md5HashKey2 = HashUtility.getMD5Hash(key);
    assertEquals(md5HashKey1, md5HashKey2);
  }
View Full Code Here

Examples of org.apache.hadoop.io.MD5Hash

  }

  @Test
  public void testMD5HashForLongWritableKey() throws IOException {
    LongWritable key = new LongWritable(Long.parseLong("123"));
    MD5Hash md5HashKey1 = HashUtility.getMD5Hash(key);
    MD5Hash md5HashKey2 = HashUtility.getMD5Hash(key);
    assertEquals(md5HashKey1, md5HashKey2);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.