Package org.apache.hadoop.raid.protocol

Examples of org.apache.hadoop.raid.protocol.PolicyInfo


  }

  void purgeCode(Codec codec) throws IOException {
    Path parityPath = new Path(codec.parityDirectory);
    FileSystem parityFs = parityPath.getFileSystem(conf);
    PolicyInfo policy = raidNode == null ? null: raidNode.determinePolicy(codec);
    FileSystem srcFs = parityFs;  // Assume src == parity
    FileStatus stat = null;
    try {
      stat = parityFs.getFileStatus(parityPath);
    } catch (FileNotFoundException e) {}
View Full Code Here


      Utils.loadTestCodecs(conf, new Builder[] {Utils.getDirXORBuilder(),
          Utils.getDirRSBuilder(), Utils.getRSBuilder(),
          Utils.getXORBuilder()});
      List<PolicyInfo> allPolicies = new ArrayList<PolicyInfo>();
      for (Codec codec: Codec.getCodecs()) {
        PolicyInfo info = new PolicyInfo(codec.id, conf);
        info.setSrcPath("/a");
        info.setProperty("modTimePeriod", "0");
        info.setProperty("targetReplication", "1");
        info.setCodecId(codec.id);
        allPolicies.add(info);
      }
      createFile(fs, new Path("/a/dir-xor/RAIDED1"), 1, 3, 512L);
      createFile(fs, new Path("/a/dir-xor/RAIDED2"), 1, 3, 512L);
      doRaid(fs, new Path("/a/dir-xor"), Codec.getCodec("dir-xor"), 1, 1);
View Full Code Here

    }
  }
 
  public void verifyLowPrioritySourceCollect(String lpId, String hpId,
      FileSystem fs) throws IOException {
    PolicyInfo lpInfo = new PolicyInfo("Test-Low-Pri-" + lpId, conf);
    lpInfo.setSrcPath("/a");
    lpInfo.setProperty("modTimePeriod", "0");
    lpInfo.setProperty("targetReplication", "1");
    lpInfo.setCodecId(lpId);

    PolicyInfo hpInfo = new PolicyInfo("Test-High-Pri-" + hpId, conf);
    hpInfo.setSrcPath("/a");
    hpInfo.setProperty("modTimePeriod", "0");
    hpInfo.setProperty("targetReplication", "2");
    hpInfo.setCodecId(hpId);
   
    Codec lpCodec = Codec.getCodec(lpId);
    createFile(fs, new Path("/a/b/f/g/RAIDED"), 1, 3, 1024L);
    doRaid(fs, new Path("/a/b/f/g/RAIDED"), lpCodec, 1, 1);
    createFile(fs, new Path("/a/b/f/h/RAIDED"), 1, 4, 1024L);
View Full Code Here

  }

  public void verifyDirRaidSourceCollect(String codecId, FileSystem fs,
                                         boolean writeAndRestoreSnapshot)
                                             throws IOException {
    PolicyInfo info = new PolicyInfo("Test-Dir-Raid-" + codecId, conf);
    info.setSrcPath("/a");
    info.setProperty("modTimePeriod", "0");
    info.setProperty("targetReplication", "1");
    info.setCodecId(codecId);
   
    PolicyInfo infoTooNew = new PolicyInfo("Test-Too-New-" + codecId, conf);
    infoTooNew.setSrcPath("/new");
    infoTooNew.setProperty("modTimePeriod", "" + Long.MAX_VALUE);
    infoTooNew.setProperty("targetReplication", "1");
    infoTooNew.setCodecId(codecId);
   
    Codec curCodec = Codec.getCodec(codecId);
   
    createFile(fs, new Path("/a/b/NOT_RAIDED1"), 1, 1, 1024L);
    createFile(fs, new Path("/a/b/NOT_RAIDED2"), 2, 2, 1024L);
View Full Code Here

  }
 
  public void verifySourceCollect(String codecId, FileSystem fs,
                                  boolean writeAndRestoreSnapshot)
      throws Exception {
    PolicyInfo info = new PolicyInfo("Test-Raided-" + codecId, conf);
    info.setSrcPath("/a/b");
    info.setProperty("modTimePeriod", "0");
    info.setProperty("targetReplication", "1");
    info.setCodecId(codecId);

    PolicyInfo infoTooNew = new PolicyInfo("Test-Too-New-" + codecId, conf);
    infoTooNew.setSrcPath("/a/new");
    infoTooNew.setProperty("modTimePeriod", "" + Long.MAX_VALUE);
    infoTooNew.setProperty("targetReplication", "1");
    infoTooNew.setCodecId(codecId);
   
    Codec curCodec = Codec.getCodec(codecId);
    createFile(fs, new Path("/a/b/TOO_SMALL"), 1, 1, 1024L);
    createFile(fs, new Path("/a/b/d/TOO_SMALL"), 2, 2, 1024L);
    createFile(fs, new Path("/a/b/f/g/RAIDED"), 1, 3, 1024L);
View Full Code Here

    LOG.info("Statistics html:\n " + st.htmlTable());
    fs.delete(parityPath, true);
  }

  public void verifyLongPrefixOverride(FileSystem fs) throws Exception {
    PolicyInfo info = new PolicyInfo("Test", conf);
    info.setSrcPath("/a/b");
    info.setProperty("modTimePeriod", "0");
    info.setProperty("targetReplication", "1");
    info.setCodecId("rs");

    PolicyInfo infoLongPrefix = new PolicyInfo("Long-Prefix", conf);
    infoLongPrefix.setSrcPath("/a/b/c");
    infoLongPrefix.setProperty("modTimePeriod", "0");
    infoLongPrefix.setProperty("targetReplication", "2");
    infoLongPrefix.setCodecId("xor");

    createFile(fs, new Path("/a/b/k"), 3, 4, 1024L);
    createFile(fs, new Path("/a/b/c/d"), 3, 5, 1024L);
    StatisticsCollector collector =
        new StatisticsCollector(fakeRaidNode, fakeConfigManager, conf);
View Full Code Here

    assertCounters(rsOther, 1, 5, 15 * 1024L, 5 * 1024L);
    fs.delete(new Path("/a"), true);
  }

  public void verifyRsCodeOverride(FileSystem fs) throws Exception {
    PolicyInfo info = new PolicyInfo("Test", conf);
    info.setSrcPath("/a/b/*");
    info.setProperty("modTimePeriod", "0");
    info.setProperty("targetReplication", "1");
    info.setCodecId("xor");

    PolicyInfo infoLongPrefix = new PolicyInfo("Long-Prefix", conf);
    infoLongPrefix.setSrcPath("/a/b/c");
    infoLongPrefix.setProperty("modTimePeriod", "0");
    infoLongPrefix.setProperty("targetReplication", "2");
    infoLongPrefix.setCodecId("rs");

    createFile(fs, new Path("/a/b/k"), 3, 4, 1024L);
    createFile(fs, new Path("/a/b/c/d"), 3, 5, 1024L);
    StatisticsCollector collector =
        new StatisticsCollector(fakeRaidNode, fakeConfigManager, conf);
View Full Code Here

        checksum.update(b);
      }
      stm.close();
      LOG.info("[SMOKETEST] Created a test file: " + testFile +
          " with CRC32 checksum " + checksum.getValue());
      PolicyInfo info = new PolicyInfo(testFile, distRaidNode.getConf());
      info.setCodecId(TEST_CODEC);
      info.setSrcPath(testFileDirectory);
      info.setShouldRaid(true);
      info.setProperty("modTimePeriod", "0");
      info.setProperty("targetReplication", "1");
      info.setProperty("metaReplication", "1");
      FileStatus stat = fileSys.getFileStatus(testPath);
      ArrayList<FileStatus> fstats = new ArrayList<FileStatus>();
      fstats.add(stat);
      // Raid it using rs
      DistRaid dr = DistRaidNode.raidFiles(distRaidNode.getConf(), distRaidNode.jobMonitor,
View Full Code Here

    SAXException, RaidConfigurationException,
    ClassNotFoundException, ParserConfigurationException, JSONException {
    // find the matched raid policy
    String policyName = args[startIndex++];
    ConfigManager configManager = new ConfigManager(conf);
    PolicyInfo policy = configManager.getPolicy(policyName);
    if (policy == null) {
      System.err.println ("Invalid policy: " + policyName);
      return -1;
    }
    Codec codec = Codec.getCodec(policy.getCodecId());
    if (codec == null) {
      System.err.println("Policy " + policyName
          + " with invalid codec " + policy.getCodecId());
    }

    // find the matched paths to raid
    FileSystem fs = FileSystem.get(conf);
    List<FileStatus> pathsToRaid = new ArrayList<FileStatus>();
    List<Path> policySrcPaths = policy.getSrcPathExpanded();
    for (int i = startIndex; i< args.length; i++) {
      boolean invalidPathToRaid = true;
      Path pathToRaid = new Path(args[i]).makeQualified(fs);
      String pathToRaidStr = pathToRaid.toString();
      if (!pathToRaidStr.endsWith(Path.SEPARATOR)) {
        pathToRaidStr = pathToRaidStr.concat(Path.SEPARATOR);
      }
      for (Path srcPath : policySrcPaths) {
        String srcStr = srcPath.toString();
        if (!srcStr.endsWith(Path.SEPARATOR)) {
          srcStr = srcStr.concat(Path.SEPARATOR);
        }
        if (pathToRaidStr.startsWith(srcStr)) {
          if (codec.isDirRaid) {
            FileUtil.listStatusForLeafDir(
                fs, fs.getFileStatus(pathToRaid), pathsToRaid);
          } else {
            FileUtil.listStatusHelper(fs, pathToRaid,
                Integer.MAX_VALUE, pathsToRaid);
          }
          invalidPathToRaid = false;
          break;
        }
      }
      if (invalidPathToRaid) {
        System.err.println("Path " + pathToRaidStr +
          " does not support by the given policy " + policyName);
      }
    }
   
    // Check if files are valid
    List<FileStatus> validPaths = new ArrayList<FileStatus>();
    List<PolicyInfo> policyInfos = new ArrayList<PolicyInfo>(1);
    policyInfos.add(policy);
    RaidState.Checker checker = new RaidState.Checker(
        policyInfos, conf);
    long now = System.currentTimeMillis();
    for (FileStatus fileStatus : pathsToRaid) {
      FileStatus[] dirStats = null;
      if (codec.isDirRaid) {
        dirStats = fs.listStatus(fileStatus.getPath());
      }
      RaidState stat = checker.check(
          policy, fileStatus, now, false,
          dirStats == null ? null : Arrays.asList(dirStats));
      if (stat == RaidState.NOT_RAIDED_BUT_SHOULD) {
        validPaths.add(fileStatus);
      } else {
        System.err.println("Path " + fileStatus.getPath() +
            " is not qualified for raiding: " + stat);
      }
    }
    if (validPaths.isEmpty()) {
      System.err.println("No file can be raided");
      return 0;
    }
    DistRaid dr = new DistRaid(conf);
    //add paths for distributed raiding
    List<EncodingCandidate> validEC =
        RaidNode.splitPaths(conf, Codec.getCodec(policy.getCodecId()), validPaths);
    dr.addRaidPaths(policy, validEC);
   
    if (dr.startDistRaid()) {
      System.out.println("Job started: " + dr.getJobTrackingURL());
      System.out.print("Job in progress ");
View Full Code Here

TOP

Related Classes of org.apache.hadoop.raid.protocol.PolicyInfo

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.