Package org.apache.hadoop.filecache

Examples of org.apache.hadoop.filecache.TrackerDistributedCacheManager


    LOG.info("state = " + buf.toString());
  }
 
  private void checkLocalizedPath(boolean visibility)
  throws IOException, LoginException, InterruptedException {
    TrackerDistributedCacheManager manager =
      new TrackerDistributedCacheManager(conf, taskController);
    String userName = getJobOwnerName();
    File workDir = new File(TEST_ROOT_DIR, "workdir");
    Path cacheFile = new Path(TEST_ROOT_DIR, "fourthcachefile");
    if (visibility) {
      createPublicTempFile(cacheFile);
    } else {
      createPrivateTempFile(cacheFile);
    }

    Configuration conf1 = new Configuration(conf);
    conf1.set("user.name", userName);
    DistributedCache.addCacheFile(cacheFile.toUri(), conf1);
    TrackerDistributedCacheManager.determineTimestamps(conf1);
    TrackerDistributedCacheManager.determineCacheVisibilities(conf1);
    dumpState(conf1);

    // Task localizing for job
    TaskDistributedCacheManager handle = manager
        .newTaskDistributedCacheManager(new JobID("jt", 1), conf1);
    handle.setupCache(conf1, TaskTracker.getPublicDistributedCacheDir(),
        TaskTracker.getPrivateDistributedCacheDir(userName));
    JobLocalizer.downloadPrivateCache(conf1);
    TaskDistributedCacheManager.CacheFile c = handle.getCacheFiles().get(0);
    String distCacheDir;
    if (visibility) {
      distCacheDir = TaskTracker.getPublicDistributedCacheDir();
    } else {
      distCacheDir = TaskTracker.getPrivateDistributedCacheDir(userName);
    }
    Path localizedPath =
      manager.getLocalCache(cacheFile.toUri(), conf1, distCacheDir,
                            fs.getFileStatus(cacheFile), false,
                        c.timestamp, visibility, c);
    assertTrue("Cache file didn't get localized in the expected directory. " +
        "Expected localization to happen within " +
        ROOT_MAPRED_LOCAL_DIR + "/" + distCacheDir +
View Full Code Here


    conf2.setLong("mapreduce.tasktracker.local.cache.numberdirectories", 3);
    //The goal is to get down to 15.75K and 2 dirs
    conf2.setFloat("mapreduce.tasktracker.cache.local.keep.pct", 0.75f);
    conf2.setLong("mapreduce.tasktracker.distributedcache.checkperiod", CACHE_DELETE_PERIOD_MS);
    refreshConf(conf2);
    TrackerDistributedCacheManager manager =
      new TrackerDistributedCacheManager(conf2, taskController);
    try {
      manager.startCleanupThread();
      FileSystem localfs = FileSystem.getLocal(conf2);
      String userName = getJobOwnerName();
      conf2.set("user.name", userName);

      //Here we are testing the LRU.  In this case we will add in 4 cache entries
      // 2 of them are 8k each and 2 of them are very small.  We want to verify
      // That they are deleted in LRU order.
      // So what we will do is add in the two large files first, 1 then 2, and
      // then one of the small ones 3.  We will then release them in opposite
      // order 3, 2, 1.
      //
      // Finally we will add in the last small file.  This last file should push
      // us over the 3 entry limit to trigger a cleanup.  So LRU order is 3, 2, 1
      // And we will only delete 2 entries so that should leave 1 un touched
      // but 3 and 2 deleted

      Path thirdCacheFile = new Path(TEST_ROOT_DIR, "thirdcachefile");
      Path fourthCacheFile = new Path(TEST_ROOT_DIR, "fourthcachefile");
      // Adding two more small files, so it triggers the number of sub directory
      // limit but does not trigger the file size limit.
      createTempFile(thirdCacheFile, 1);
      createTempFile(fourthCacheFile, 1);

      FileStatus stat = fs.getFileStatus(firstCacheFilePublic);
      CacheFile cfile1 = new CacheFile(firstCacheFilePublic.toUri(),
          CacheFile.FileType.REGULAR, true,
          stat.getModificationTime(),
          true);

      Path firstLocalCache = manager.getLocalCache(firstCacheFilePublic.toUri(), conf2,
          TaskTracker.getPrivateDistributedCacheDir(userName),
          fs.getFileStatus(firstCacheFilePublic), false,
          fs.getFileStatus(firstCacheFilePublic).getModificationTime(), true,
          cfile1);

      stat = fs.getFileStatus(secondCacheFilePublic);
      CacheFile cfile2 = new CacheFile(secondCacheFilePublic.toUri(),
          CacheFile.FileType.REGULAR, true,
          stat.getModificationTime(),
          true);

      Path secondLocalCache = manager.getLocalCache(secondCacheFilePublic.toUri(), conf2,
          TaskTracker.getPrivateDistributedCacheDir(userName),
          fs.getFileStatus(secondCacheFilePublic), false,
          fs.getFileStatus(secondCacheFilePublic).getModificationTime(), true,
          cfile2);

      stat = fs.getFileStatus(thirdCacheFile);
      CacheFile cfile3 = new CacheFile(thirdCacheFile.toUri(),
          CacheFile.FileType.REGULAR, true,
          stat.getModificationTime(),
          true);

      Path thirdLocalCache = manager.getLocalCache(thirdCacheFile.toUri(), conf2,
          TaskTracker.getPrivateDistributedCacheDir(userName),
          fs.getFileStatus(thirdCacheFile), false,
          fs.getFileStatus(thirdCacheFile).getModificationTime(), true,
          cfile3);

      manager.releaseCache(cfile3.getStatus());
      manager.releaseCache(cfile2.getStatus());
      manager.releaseCache(cfile1.getStatus());

      // Getting the fourth cache will make the number of sub directories becomes
      // 4 which is greater than 3. So the released cache will be deleted.
      stat = fs.getFileStatus(fourthCacheFile);
      CacheFile cfile4 = new CacheFile(fourthCacheFile.toUri(),
          CacheFile.FileType.REGULAR, true,
          stat.getModificationTime(),
          true);

      Path fourthLocalCache = manager.getLocalCache(fourthCacheFile.toUri(), conf2,
          TaskTracker.getPrivateDistributedCacheDir(userName),
          fs.getFileStatus(fourthCacheFile), false,
          fs.getFileStatus(fourthCacheFile).getModificationTime(), true,
          cfile4);

      checkCacheDeletion(localfs, secondLocalCache, "DistributedCache failed " +
          "deleting second cache LRU order");

      checkCacheDeletion(localfs, thirdLocalCache,
          "DistributedCache failed deleting third" +
      " cache LRU order.");

      checkCacheNOTDeletion(localfs, firstLocalCache, "DistributedCache failed " +
      "Deleted first cache LRU order.");

      checkCacheNOTDeletion(localfs, fourthCacheFile, "DistributedCache failed " +
      "Deleted fourth cache LRU order.");
      // Clean up the files created in this test
      new File(thirdCacheFile.toString()).delete();
      new File(fourthCacheFile.toString()).delete();
    } finally {
      manager.stopCleanupThread();
    }
  }
View Full Code Here

    this.taskTrackerName = "tracker_" + localHostname + ":" + taskReportAddress;
    LOG.info("Starting tracker " + taskTrackerName);

    // Initialize DistributedCache
    this.distributedCacheManager = new TrackerDistributedCacheManager(
        this.fConf, taskController);
    this.distributedCacheManager.startCleanupThread();
   
    this.jobClient = (InterTrackerProtocol)
    UserGroupInformation.getLoginUser().doAs(
View Full Code Here

      this.localJobFile = new Path(this.localJobDir, id + ".xml");

      // Manage the distributed cache.  If there are files to be copied,
      // this will trigger localFile to be re-written again.
      this.trackerDistributedCacheManager =
        new TrackerDistributedCacheManager(conf, taskController);
      this.taskDistributedCacheManager =
        trackerDistributedCacheManager.newTaskDistributedCacheManager(
            jobid, conf);
      taskDistributedCacheManager.setupCache(conf, "archive", "archive");
      // Localize private distributed cache
View Full Code Here

    this.taskTrackerName = "tracker_" + localHostname + ":" + taskReportAddress;
    LOG.info("Starting tracker " + taskTrackerName);

    // Initialize DistributedCache
    this.distributedCacheManager = new TrackerDistributedCacheManager(
        this.fConf, taskController);
    this.distributedCacheManager.startCleanupThread();
   
    this.jobClient = (InterTrackerProtocol)
    UserGroupInformation.getLoginUser().doAs(
View Full Code Here

    this.taskTrackerName = "tracker_" + localHostname + ":" + taskReportAddress;
    LOG.info("Starting tracker " + taskTrackerName);

    // Initialize DistributedCache
    this.distributedCacheManager = new TrackerDistributedCacheManager(
        this.fConf, taskController);

    this.jobClient = (InterTrackerProtocol)
    UserGroupInformation.getLoginUser().doAs(
        new PrivilegedExceptionAction<Object>() {
View Full Code Here

TOP

Related Classes of org.apache.hadoop.filecache.TrackerDistributedCacheManager

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.