Examples of JTProtocol


Examples of org.apache.hadoop.mapreduce.test.system.JTProtocol

        cluster.getJTClient().isJobStarted(jobId));
    TaskInfo taskInfo = getTaskInfo(jobId, false);
    Assert.assertNotNull("TaskInfo is null",taskInfo);
    Assert.assertTrue("Task has not been started for 1 min.",
        cluster.getJTClient().isTaskStarted(taskInfo));   
    JTProtocol wovenClient = cluster.getJTClient().getProxy();
    int counter = 0;
    TaskInfo tempTaskInfo;
    while (counter++ < 60) {
      if (taskInfo.getTaskStatus().length == 0) {
        UtilsForTests.waitFor(1000);
        tempTaskInfo = taskInfo;
        taskInfo = wovenClient.getTaskInfo(taskInfo.getTaskID());
      }else if (taskInfo.getTaskStatus()[0].getRunState() ==
          TaskStatus.State.RUNNING) {
        UtilsForTests.waitFor(1000);
        tempTaskInfo = taskInfo;
        taskInfo = wovenClient.getTaskInfo(taskInfo.getTaskID());
      } else {
        break;
      }
      if (taskInfo == null) {
        taskInfo = tempTaskInfo;
        break;
      }
    }
    verifyProcessTreeOverLimit(taskInfo,jobId);
    JobInfo jInfo = wovenClient.getJobInfo(jobId);
    LOG.info("Waiting till the job is completed...");
    counter = 0;
    while (counter++ < 60) {
      if(jInfo == null) {
        break;
      } else if (jInfo.getStatus().isJobComplete()) {
        break;
      }
      UtilsForTests.waitFor(1000);
      jInfo = wovenClient.getJobInfo(jobId);
    }
  }
View Full Code Here

Examples of org.apache.hadoop.mapreduce.test.system.JTProtocol

    return jobId;
  }
 
  private TaskInfo getTaskInfo(JobID jobId, boolean isMap)
      throws IOException {
    JTProtocol wovenClient = cluster.getJTClient().getProxy();
    JobInfo jInfo = wovenClient.getJobInfo(jobId);
    TaskInfo[] taskInfos = wovenClient.getTaskInfo(jobId);
    for (TaskInfo taskinfo : taskInfos) {
      if (!taskinfo.isSetupOrCleanup()) {
        if (taskinfo.getTaskID().isMap() == isMap) {
          return taskinfo;
        }
View Full Code Here

Examples of org.apache.hadoop.mapreduce.test.system.JTProtocol

    // This calculates the previous number fo jobs submitted before a new
    // job gets submitted.
    int prevJobsNum = 0;

    // JTProtocol wovenClient
    JTProtocol wovenClient = cluster.getJTClient().getProxy();

    // JobStatus
    JobStatus[] jobStatus = null;

    // JobID
    JobID id = null;

    // RunningJob rJob;
    RunningJob rJob = null;

    // JobInfo jInfo;
    JobInfo jInfo = null;

    //Getting the previous job numbers that are submitted.
    jobStatus = client.getAllJobs();
    prevJobsNum = jobStatus.length;

    // Run RandomWriter
    Assert.assertEquals(ToolRunner.run(job, tool, args), 0);

    //Waiting for the job to appear in the jobstatus
    jobStatus = client.getAllJobs();

    while (jobStatus.length - prevJobsNum == 0) {
      LOG.info("Waiting for the job to appear in the jobStatus");
      Thread.sleep(1000);
      jobStatus = client.getAllJobs();
    }

    //Getting the jobId of the just submitted job
    //The just submitted job is always added in the first slot of jobstatus
    id = jobStatus[0].getJobID();

    rJob = client.getJob(id);

    jInfo = wovenClient.getJobInfo(id);

    //Making sure that the job is complete.
    while (jInfo != null && !jInfo.getStatus().isJobComplete()) {
      Thread.sleep(10000);
      jInfo = wovenClient.getJobInfo(id);
    }

    cluster.getJTClient().verifyCompletedJob(id);
  }
View Full Code Here

Examples of org.apache.hadoop.mapreduce.test.system.JTProtocol

  }

  @Test
  public void testControlledJob() throws Exception {
    Configuration conf = new Configuration(cluster.getConf());
    JTProtocol wovenClient = cluster.getJTClient().getProxy();
    FinishTaskControlAction.configureControlActionForJob(conf);
    SleepJob job = new SleepJob();
    job.setConf(conf);

    Job slpJob = job.createJob(1, 0, 100, 100, 100, 100);
    slpJob.submit();
    JobClient client = cluster.getJTClient().getClient();

    RunningJob rJob =
        client.getJob(org.apache.hadoop.mapred.JobID.downgrade(slpJob
            .getJobID()));
    JobID id = rJob.getID();

    JobInfo jInfo = wovenClient.getJobInfo(id);

    while (jInfo.getStatus().getRunState() != JobStatus.RUNNING) {
      Thread.sleep(1000);
      jInfo = wovenClient.getJobInfo(id);
    }

    LOG.info("Waiting till job starts running one map");
    jInfo = wovenClient.getJobInfo(id);
    Assert.assertEquals(jInfo.runningMaps(), 1);

    LOG.info("waiting for another cycle to "
        + "check if the maps dont finish off");
    Thread.sleep(1000);
    jInfo = wovenClient.getJobInfo(id);
    Assert.assertEquals(jInfo.runningMaps(), 1);

    TaskInfo[] taskInfos = wovenClient.getTaskInfo(id);

    for (TaskInfo info : taskInfos) {
      LOG.info("constructing control action to signal task to finish");
      FinishTaskControlAction action =
          new FinishTaskControlAction(TaskID.downgrade(info.getTaskID()));
      for (TTClient cli : cluster.getTTClients()) {
        cli.getProxy().sendAction(action);
      }
    }

    jInfo = wovenClient.getJobInfo(id);
    int i = 1;
    if (jInfo != null) {
      while (!jInfo.getStatus().isJobComplete()) {
        Thread.sleep(1000);
        jInfo = wovenClient.getJobInfo(id);
        if (jInfo == null) {
          break;
        }
        if (i > 40) {
          Assert.fail("Controlled Job with ID : "
View Full Code Here

Examples of org.apache.hadoop.mapreduce.test.system.JTProtocol

   * @param none
   * @return void
   */
  public void testDistributedCache() throws Exception {
    Configuration conf = new Configuration(cluster.getConf());
    JTProtocol wovenClient = cluster.getJTClient().getProxy();

    // This counter will check for count of a loop,
    // which might become infinite.
    int count = 0;
    // This boolean will decide whether to run job again
    boolean continueLoop = true;
    // counter for job Loop
    int countLoop = 0;
    // This counter incerases with all the tasktrackers in which tasks ran
    int taskTrackerCounter = 0;
    // This will store all the tasktrackers in which tasks ran
    ArrayList<String> taskTrackerCollection = new ArrayList<String>();

    do {
      SleepJob job = new SleepJob();
      job.setConf(conf);
      Job slpJob = job.createJob(5, 1, 1000, 1000, 100, 100);

      DistributedCache.createSymlink(conf);
      URI uri = URI.create(uriPath);
      DistributedCache.addCacheFile(uri, conf);
      JobConf jconf = new JobConf(conf);

      // Controls the job till all verification is done
      FinishTaskControlAction.configureControlActionForJob(conf);

      // Submitting the job
      slpJob.submit();
      RunningJob rJob =
          cluster.getJTClient().getClient().getJob(
              org.apache.hadoop.mapred.JobID.downgrade(slpJob.getJobID()));

      // counter for job Loop
      countLoop++;

      TTClient tClient = null;
      JobInfo jInfo = wovenClient.getJobInfo(rJob.getID());
      LOG.info("jInfo is :" + jInfo);

      // Assert if jobInfo is null
      Assert.assertNotNull("jobInfo is null", jInfo);

      // Wait for the job to start running.
      count = 0;
      while (jInfo.getStatus().getRunState() != JobStatus.RUNNING) {
        UtilsForTests.waitFor(10000);
        count++;
        jInfo = wovenClient.getJobInfo(rJob.getID());
        // If the count goes beyond a point, then break; This is to avoid
        // infinite loop under unforeseen circumstances. Testcase will anyway
        // fail later.
        if (count > 10) {
          Assert.fail("job has not reached running state for more than"
View Full Code Here

Examples of org.apache.hadoop.mapreduce.test.system.JTProtocol

   * @param none
   * @return void
   */
  public void testDistributedCache() throws Exception {
    Configuration conf = new Configuration(cluster.getConf());
    JTProtocol wovenClient = cluster.getJTClient().getProxy();

    // This counter will check for count of a loop,
    // which might become infinite.
    int count = 0;
    // This boolean will decide whether to run job again
    boolean continueLoop = true;
    // counter for job Loop
    int countLoop = 0;
    // This counter increases with all the tasktrackers in which tasks ran
    int taskTrackerCounter = 0;
    // This will store all the tasktrackers in which tasks ran
    ArrayList<String> taskTrackerCollection = new ArrayList<String>();
    // This boolean tells if two tasks ran onteh same tasktracker or not
    boolean taskTrackerFound = false;

    do {
      SleepJob job = new SleepJob();
      job.setConf(conf);
      Job slpJob = job.createJob(5, 1, 1000, 1000, 100, 100);

      // Before starting, Modify the file
      String input = "This will be the content of\n" + "distributed cache\n";
      // Creating the path with the file
      DataOutputStream file =
          UtilsForTests.createTmpFileDFS(dfs, URIPATH, permission, input);

      DistributedCache.createSymlink(conf);
      URI uri = URI.create(uriPath);
      DistributedCache.addCacheFile(uri, conf);
      JobConf jconf = new JobConf(conf);

      // Controls the job till all verification is done
      FinishTaskControlAction.configureControlActionForJob(conf);

      slpJob.submit();
      // Submitting the job
      RunningJob rJob =
          cluster.getJTClient().getClient().getJob(
              org.apache.hadoop.mapred.JobID.downgrade(slpJob.getJobID()));

      // counter for job Loop
      countLoop++;

      TTClient tClient = null;
      JobInfo jInfo = wovenClient.getJobInfo(rJob.getID());
      LOG.info("jInfo is :" + jInfo);

      // Assert if jobInfo is null
      Assert.assertNotNull("jobInfo is null", jInfo);

      // Wait for the job to start running.
      count = 0;
      while (jInfo.getStatus().getRunState() != JobStatus.RUNNING) {
        UtilsForTests.waitFor(10000);
        count++;
        jInfo = wovenClient.getJobInfo(rJob.getID());
        // If the count goes beyond a point, then break; This is to avoid
        // infinite loop under unforeseen circumstances. Testcase will anyway
        // fail later.
        if (count > 10) {
          Assert.fail("job has not reached running state for more than"
              + "100 seconds. Failing at this point");
        }
      }

      LOG.info("job id is :" + rJob.getID().toString());

      TaskInfo[] taskInfos =
          cluster.getJTClient().getProxy().getTaskInfo(rJob.getID());

      boolean distCacheFileIsFound;

      for (TaskInfo taskInfo : taskInfos) {
        distCacheFileIsFound = false;
        String[] taskTrackers = taskInfo.getTaskTrackers();
        for (String taskTracker : taskTrackers) {
          // Formatting tasktracker to get just its FQDN
          taskTracker = UtilsForTests.getFQDNofTT(taskTracker);
          LOG.info("taskTracker is :" + taskTracker);

          // The tasktrackerFound variable is initialized
          taskTrackerFound = false;

          // This will be entered from the second job onwards
          if (countLoop > 1) {
            if (taskTracker != null) {
              continueLoop = taskTrackerCollection.contains(taskTracker);
            }
            if (continueLoop) {
              taskTrackerFound = true;
            }
          }
          // Collecting the tasktrackers
          if (taskTracker != null)
            taskTrackerCollection.add(taskTracker);

          // we have loopped through two times to look for task
          // getting submitted on same tasktrackers.The same tasktracker
          // for subsequent jobs was not hit maybe because of many number
          // of tasktrackers. So, testcase has to stop here.
          if (countLoop > 1) {
            continueLoop = false;
          }

          tClient = cluster.getTTClient(taskTracker);

          // tClient maybe null because the task is already dead. Ex: setup
          if (tClient == null) {
            continue;
          }

          String[] localDirs = tClient.getMapredLocalDirs();
          int distributedFileCount = 0;
          // Go to every single path
          for (String localDir : localDirs) {
            // Public Distributed cache will always be stored under
            // mapre.local.dir/tasktracker/archive
            localDir =
                localDir
                    + Path.SEPARATOR
                    + TaskTracker.getPublicDistributedCacheDir();
            LOG.info("localDir is : " + localDir);

            // Get file status of all the directories
            // and files under that path.
            FileStatus[] fileStatuses =
                tClient.listStatus(localDir, true, true);
            for (FileStatus fileStatus : fileStatuses) {
              Path path = fileStatus.getPath();
              LOG.info("path is :" + path.toString());
              // Checking if the received path ends with
              // the distributed filename
              distCacheFileIsFound =
                  (path.toString()).endsWith(distributedFileName);
              // If file is found, check for its permission.
              // Since the file is found break out of loop
              if (distCacheFileIsFound) {
                LOG.info("PATH found is :" + path.toString());
                distributedFileCount++;
                String filename = path.getName();
                FsPermission fsPerm = fileStatus.getPermission();
                Assert.assertTrue("File Permission is not 777", fsPerm
                    .equals(new FsPermission("777")));
              }
            }
          }

          LOG.debug("The distributed FileCount is :" + distributedFileCount);
          LOG.debug("The taskTrackerFound is :" + taskTrackerFound);

          // If distributed cache is modified in dfs
          // between two job runs, it can be present more than once
          // in any of the task tracker, in which job ran.
          if (distributedFileCount != 2 && taskTrackerFound) {
            Assert.fail("The distributed cache file has to be two. "
                + "But found was " + distributedFileCount);
          } else if (distributedFileCount > 1 && !taskTrackerFound) {
            Assert.fail("The distributed cache file cannot more than one."
                + " But found was " + distributedFileCount);
          } else if (distributedFileCount < 1)
            Assert.fail("The distributed cache file is less than one. "
                + "But found was " + distributedFileCount);
          if (!distCacheFileIsFound) {
            Assert.assertEquals(
                "The distributed cache file does not exist",
                distCacheFileIsFound, false);
          }
        }
      }
      // Allow the job to continue through MR control job.
      for (TaskInfo taskInfoRemaining : taskInfos) {
        FinishTaskControlAction action =
            new FinishTaskControlAction(TaskID.downgrade(taskInfoRemaining
                .getTaskID()));
        Collection<TTClient> tts = cluster.getTTClients();
        for (TTClient cli : tts) {
          cli.getProxy().sendAction(action);
        }
      }

      // Killing the job because all the verification needed
      // for this testcase is completed.
      rJob.killJob();

      // Waiting for 3 seconds for cleanup to start
      Thread.sleep(3000);

      // Getting the last cleanup task's tasktracker also, as
      // distributed cache gets uploaded even during cleanup.
      TaskInfo[] myTaskInfos = wovenClient.getTaskInfo(rJob.getID());
      if (myTaskInfos != null) {
        for (TaskInfo info : myTaskInfos) {
          if (info.isSetupOrCleanup()) {
            String[] taskTrackers = info.getTaskTrackers();
            for (String taskTracker : taskTrackers) {
              // Formatting tasktracker to get just its FQDN
              taskTracker = UtilsForTests.getFQDNofTT(taskTracker);
              LOG.info("taskTracker is :" + taskTracker);
              // Collecting the tasktrackers
              if (taskTracker != null)
                taskTrackerCollection.add(taskTracker);
            }
          }
        }
      }

      // Making sure that the job is complete.
      while (jInfo != null && !jInfo.getStatus().isJobComplete()) {
        Thread.sleep(10000);
        jInfo = wovenClient.getJobInfo(rJob.getID());
      }

    } while (continueLoop);
  }
View Full Code Here

Examples of org.apache.hadoop.mapreduce.test.system.JTProtocol

   * @param none
   * @return void
   */
  public void testDistributedCache() throws Exception {
    Configuration conf = new Configuration(cluster.getConf());
    JTProtocol wovenClient = cluster.getJTClient().getProxy();

    //This counter will check for count of a loop,
    //which might become infinite.
    int count = 0;

    SleepJob job = new SleepJob();
    job.setConf(conf);
    Job slpJob = job.createJob(5, 1, 1000, 1000, 100, 100);

    DistributedCache.createSymlink(conf);
    URI uri = URI.create(uriPath);
    DistributedCache.addCacheFile(uri, conf);
    JobConf jconf = new JobConf(conf);

    //Controls the job till all verification is done
    FinishTaskControlAction.configureControlActionForJob(conf);

    //Submitting the job
    slpJob.submit();
    RunningJob rJob =
        cluster.getJTClient().getClient().getJob(org.apache.hadoop.mapred.JobID.downgrade(slpJob.getJobID()));

    JobStatus[] jobStatus = client.getAllJobs();
    String userName = jobStatus[0].getUsername();

    TTClient tClient = null;
    JobInfo jInfo = wovenClient.getJobInfo(rJob.getID());
    LOG.info("jInfo is :" + jInfo);

    //Assert if jobInfo is null
    Assert.assertNotNull("jobInfo is null", jInfo);

    //Wait for the job to start running.
    count = 0;
    while (jInfo.getStatus().getRunState() != JobStatus.RUNNING) {
      UtilsForTests.waitFor(10000);
      count++;
      jInfo = wovenClient.getJobInfo(rJob.getID());
      //If the count goes beyond a point, then Assert; This is to avoid
      //infinite loop under unforeseen circumstances.
      if (count > 10) {
        Assert.fail("job has not reached running state for more than" +
            "100 seconds. Failing at this point");
View Full Code Here

Examples of org.apache.hadoop.mapreduce.test.system.JTProtocol

   * @throws Exception
   */
  @Test
  public void testTaskDetails() throws Exception {
    Configuration conf = new Configuration(cluster.getConf());
    JTProtocol wovenClient = cluster.getJTClient().getProxy();
    FinishTaskControlAction.configureControlActionForJob(conf);
    SleepJob job = new SleepJob();
    job.setConf(conf);

    Job rJob = job.createJob(1, 1, 100, 100, 100, 100);
    JobClient client = cluster.getJTClient().getClient();
    rJob.submit();
    RunningJob rJob1 =
        client.getJob(org.apache.hadoop.mapred.JobID.downgrade(rJob.getJobID()));
    JobID id = rJob.getJobID();

    JobInfo jInfo = wovenClient.getJobInfo(id);

    while (jInfo.getStatus().getRunState() != JobStatus.RUNNING) {
      Thread.sleep(1000);
      jInfo = wovenClient.getJobInfo(id);
    }

    LOG.info("Waiting till job starts running one map");

    TaskInfo[] myTaskInfos = wovenClient.getTaskInfo(id);
    boolean isOneTaskStored = false;
    String sometaskpid = null;
    org.apache.hadoop.mapreduce.TaskAttemptID sometaskId = null;
    TTClient myCli = null;
    for (TaskInfo info : myTaskInfos) {
      if (!info.isSetupOrCleanup()) {
        String[] taskTrackers = info.getTaskTrackers();
        for (String taskTracker : taskTrackers) {
          TTInfo ttInfo = wovenClient.getTTInfo(taskTracker);
          TTClient ttCli = cluster.getTTClient(ttInfo.getStatus().getHost());
          TaskID taskId = info.getTaskID();
          TTTaskInfo ttTaskInfo = ttCli.getProxy().getTask(taskId);
          Assert.assertNotNull(ttTaskInfo);
          Assert.assertNotNull(ttTaskInfo.getConf());
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.