Package org.apache.hadoop.mapreduce.server.tasktracker.userlogs

Examples of org.apache.hadoop.mapreduce.server.tasktracker.userlogs.UserLogManager


    tt.setMaxMapSlots(MAP_SLOTS);
    tt.setMaxReduceSlots(REDUCE_SLOTS);
    tt.setTaskController(new DefaultTaskController());
    jvmManager = new JvmManager(tt);
    tt.setJvmManagerInstance(jvmManager);
    tt.setUserLogManager(new UserLogManager(ttConf));
  }
View Full Code Here


   * @throws IOException
   */
  @Test
  public void testNoTruncationNeeded() throws IOException {
    Configuration conf = setRetainSizes(1000L, 1000L);
    UserLogManager logManager = new UtilsForTests.InLineUserLogManager(conf);

    TaskID baseId = new TaskID();
    int taskcount = 0;

    TaskAttemptID attemptID = new TaskAttemptID(baseId, taskcount++);
    Task task = new MapTask(null, attemptID, 0, new JobSplit.TaskSplitIndex(),
                            0);

    // Let the tasks write logs within retain-size
    for (LogName log : LogName.values()) {
      writeRandomBytes(attemptID, attemptID, log, 500);
    }
    File logIndex = TaskLog.getIndexFile(attemptID, false);
    long indexModificationTimeStamp = logIndex.lastModified();

    File attemptDir = TaskLog.getAttemptDir(attemptID, false);
    assertTrue(attemptDir + " doesn't exist!", attemptDir.exists());
    assertEquals("index file got modified", indexModificationTimeStamp,
        logIndex.lastModified());

    // Finish the task and the JVM too.
    JVMInfo jvmInfo = new JVMInfo(attemptDir, Arrays.asList(task));
    logManager.addLogEvent(new JvmFinishedEvent(jvmInfo));

    // There should be no truncation of the log-file.
    assertTrue(attemptDir.exists());
    assertEquals("index file got modified", indexModificationTimeStamp,
        logIndex.lastModified());

    Map<LogName, Long> logLengths = getAllLogsFileLengths(attemptID, false);
    for (LogName log : LogName.values()) {
      File logFile = TaskLog.getTaskLogFile(attemptID, false, log);
      assertEquals(500, logFile.length());
      // The index file should also be proper.
      assertEquals(500, logLengths.get(log).longValue());
    }

    // truncate it once again
    logManager.addLogEvent(new JvmFinishedEvent(jvmInfo));
    assertEquals("index file got modified", indexModificationTimeStamp,
        logIndex.lastModified());
   
    logLengths = getAllLogsFileLengths(attemptID, false);
    for (LogName log : LogName.values()) {
View Full Code Here

   */
  @Test
  public void testDisabledLogTruncation() throws IOException {
    // Anything less than 0 disables the truncation.
    Configuration conf = setRetainSizes(-1L, -1L);
    UserLogManager logManager = new UtilsForTests.InLineUserLogManager(conf);

    TaskID baseId = new TaskID();
    int taskcount = 0;

    TaskAttemptID attemptID = new TaskAttemptID(baseId, taskcount++);
    Task task = new MapTask(null, attemptID, 0, new JobSplit.TaskSplitIndex(),
                            0);

    // Let the tasks write some logs
    for (LogName log : LogName.values()) {
      writeRandomBytes(attemptID, attemptID, log, 1500);
    }

    File attemptDir = TaskLog.getAttemptDir(attemptID, false);
    assertTrue(attemptDir + " doesn't exist!", attemptDir.exists());

    // Finish the task and the JVM too.
    JVMInfo jvmInfo = new JVMInfo(attemptDir, Arrays.asList(task));
    logManager.addLogEvent(new JvmFinishedEvent(jvmInfo));

    // The log-file should not be truncated.
    assertTrue(attemptDir.exists());
    Map<LogName, Long> logLengths = getAllLogsFileLengths(attemptID, false);
    for (LogName log : LogName.values()) {
View Full Code Here

   * @throws IOException
   */
  @Test
  public void testLogTruncationOnFinishing() throws IOException {
    Configuration conf = setRetainSizes(1000L, 1000L);
    UserLogManager logManager = new UtilsForTests.InLineUserLogManager(conf);

    TaskID baseId = new TaskID();
    int taskcount = 0;

    TaskAttemptID attemptID = new TaskAttemptID(baseId, taskcount++);
    Task task = new MapTask(null, attemptID, 0, new JobSplit.TaskSplitIndex(),
                            0);

    // Let the tasks write logs more than retain-size
    for (LogName log : LogName.values()) {
      writeRandomBytes(attemptID, attemptID, log, 1500);
    }

    File attemptDir = TaskLog.getAttemptDir(attemptID, false);
    assertTrue(attemptDir + " doesn't exist!", attemptDir.exists());

    // Finish the task and the JVM too.
    JVMInfo jvmInfo = new JVMInfo(attemptDir, Arrays.asList(task));
    logManager.addLogEvent(new JvmFinishedEvent(jvmInfo));

    // The log-file should now be truncated.
    assertTrue(attemptDir.exists());

    Map<LogName, Long> logLengths = getAllLogsFileLengths(attemptID, false);
View Full Code Here

   * @throws IOException
   */
  @Test
  public void testLogTruncation() throws IOException {
    Configuration conf = setRetainSizes(1000L, 1000L);
    UserLogManager logManager = new UtilsForTests.InLineUserLogManager(conf);

    TaskID baseId = new TaskID();
    int taskcount = 0;

    TaskAttemptID attemptID = new TaskAttemptID(baseId, taskcount++);
    Task task = new MapTask(null, attemptID, 0, new JobSplit.TaskSplitIndex(),
                            0);

    // Let the tasks write logs more than retain-size
    writeRandomBytes(attemptID, attemptID, LogName.SYSLOG, 1500);
    writeRandomBytes(attemptID, attemptID, LogName.STDERR, 500);

    File attemptDir = TaskLog.getAttemptDir(attemptID, false);
    assertTrue(attemptDir + " doesn't exist!", attemptDir.exists());

    // Finish the task and the JVM too.
    JVMInfo jvmInfo = new JVMInfo(attemptDir, Arrays.asList(task));
    logManager.addLogEvent(new JvmFinishedEvent(jvmInfo));

    // The log-file should now be truncated.
    assertTrue(attemptDir.exists());

    Map<LogName, Long> logLengths = getAllLogsFileLengths(attemptID, false);
    File logFile = TaskLog.getTaskLogFile(attemptID, false, LogName.SYSLOG);
    assertEquals(1000 + truncatedMsgSize, logFile.length());
    // The index file should also be proper.
    assertEquals(1000 + truncatedMsgSize, logLengths.get(LogName.SYSLOG)
        .longValue());
    String syslog = TestMiniMRMapRedDebugScript.readTaskLog(LogName.SYSLOG,
        attemptID, false);
    assertTrue(syslog.startsWith(TaskLogsTruncater.TRUNCATED_MSG));
    logFile = TaskLog.getTaskLogFile(attemptID, false, LogName.STDERR);
    assertEquals(500, logFile.length());
    // The index file should also be proper.
    assertEquals(500, logLengths.get(LogName.STDERR).longValue());
    String stderr = TestMiniMRMapRedDebugScript.readTaskLog(LogName.STDERR,
        attemptID, false);
    assertFalse(stderr.startsWith(TaskLogsTruncater.TRUNCATED_MSG));

    // truncate once again
    logManager.addLogEvent(new JvmFinishedEvent(jvmInfo));
    logLengths = getAllLogsFileLengths(attemptID, false);
    logFile = TaskLog.getTaskLogFile(attemptID, false, LogName.SYSLOG);
    assertEquals(1000 + truncatedMsgSize, logFile.length());
    // The index file should also be proper.
    assertEquals(1000 + truncatedMsgSize, logLengths.get(LogName.SYSLOG)
View Full Code Here

   * @throws IOException
   */
  @Test
  public void testLogTruncationOnFinishingWithJVMReuse() throws IOException {
    Configuration conf = setRetainSizes(150L, 150L);
    UserLogManager logManager = new UtilsForTests.InLineUserLogManager(conf);

    TaskID baseTaskID = new TaskID();
    int attemptsCount = 0;

    // Assuming the job's retain size is 150
    TaskAttemptID attempt1 = new TaskAttemptID(baseTaskID, attemptsCount++);
    Task task1 = new MapTask(null, attempt1, 0, new JobSplit.TaskSplitIndex(),
                             0);

    // Let the tasks write logs more than retain-size
    writeRealChars(attempt1, attempt1, LogName.SYSLOG, 200, 'A');

    File attemptDir = TaskLog.getAttemptDir(attempt1, false);
    assertTrue(attemptDir + " doesn't exist!", attemptDir.exists());

    // Start another attempt in the same JVM
    TaskAttemptID attempt2 = new TaskAttemptID(baseTaskID, attemptsCount++);
    Task task2 = new MapTask(null, attempt2, 0, new JobSplit.TaskSplitIndex(),
                             0);
    // Let attempt2 also write some logs
    writeRealChars(attempt1, attempt2, LogName.SYSLOG, 100, 'B');
    // Start yet another attempt in the same JVM
    TaskAttemptID attempt3 = new TaskAttemptID(baseTaskID, attemptsCount++);
    Task task3 = new MapTask(null, attempt3, 0, new JobSplit.TaskSplitIndex(),
                             0);
    // Let attempt3 also write some logs
    writeRealChars(attempt1, attempt3, LogName.SYSLOG, 225, 'C');
    // Finish the JVM.
    JVMInfo jvmInfo = new JVMInfo(attemptDir,
        Arrays.asList((new Task[] { task1, task2, task3 })));
    logManager.addLogEvent(new JvmFinishedEvent(jvmInfo));

    // The log-file should now be truncated.
    assertTrue(attemptDir.exists());
    File logFile = TaskLog.getTaskLogFile(attempt1, false, LogName.SYSLOG);
    assertEquals(400  + (2 * truncatedMsgSize), logFile.length());
    // The index files should also be proper.
    assertEquals(150 + truncatedMsgSize, getAllLogsFileLengths(attempt1, false)
        .get(LogName.SYSLOG).longValue());
    assertEquals(100, getAllLogsFileLengths(attempt2, false)
        .get(LogName.SYSLOG).longValue());
    assertEquals(150 + truncatedMsgSize, getAllLogsFileLengths(attempt3, false)
        .get(LogName.SYSLOG).longValue());

    // assert data for attempt1
    String syslog = TestMiniMRMapRedDebugScript.readTaskLog(LogName.SYSLOG,
        attempt1, false);
    assertTrue(syslog.startsWith(TaskLogsTruncater.TRUNCATED_MSG));
    String truncatedLog = syslog.substring(truncatedMsgSize);
    for (int i = 0 ; i < 150; i++) {
      assertEquals("Truncation didn't happen properly. At "
         + (i + 1) + "th byte, expected 'A' but found "
         + truncatedLog.charAt(i), 'A', truncatedLog.charAt(i));
    }
   
    // assert data for attempt2
    syslog = TestMiniMRMapRedDebugScript.readTaskLog(LogName.SYSLOG,
          attempt2, false);
    for (int i = 0 ; i < 100; i++) {
        assertEquals("Truncation didn't happen properly. At "
           + (i + 1) + "th byte, expected 'B' but found "
           + truncatedLog.charAt(i), 'B', syslog.charAt(i));
      }
   
    // assert data for attempt3
    syslog = TestMiniMRMapRedDebugScript.readTaskLog(LogName.SYSLOG,
        attempt3, false);
    assertTrue(syslog.startsWith(TaskLogsTruncater.TRUNCATED_MSG));
    truncatedLog = syslog.substring(truncatedMsgSize);
    for (int i = 0 ; i < 150; i++) {
      assertEquals("Truncation didn't happen properly. At "
         + (i + 1) + "th byte, expected 'C' but found "
         + truncatedLog.charAt(i), 'C', truncatedLog.charAt(i));
    }

    logManager.addLogEvent(new JvmFinishedEvent(jvmInfo));
    // First and third attempts' logs are only truncated, so include 2*length of
    // TRUNCATED_MSG header
    assertEquals(400 + 2 * truncatedMsgSize, logFile.length());
  }
View Full Code Here

        new LocalDirAllocator(JobConf.MAPRED_LOCAL_DIR_PROPERTY);
    tt.getTaskController().setup(ldirAlloc, new LocalStorage(ttConf.getLocalDirs()));
    JobID jobId = new JobID("test", 0);
    jvmManager = new JvmManager(tt);
    tt.setJvmManagerInstance(jvmManager);
    tt.setUserLogManager(new UserLogManager(ttConf));
    tt.setCleanupThread(new InlineCleanupQueue());
  }
View Full Code Here

    LocalDirAllocator ldirAlloc = new LocalDirAllocator("mapred.local.dir");
    tt.getTaskController().setup(ldirAlloc);
    JobID jobId = new JobID("test", 0);
    jvmManager = new JvmManager(tt);
    tt.setJvmManagerInstance(jvmManager);
    tt.setUserLogManager(new UserLogManager(ttConf));
    tt.setCleanupThread(new InlineCleanupQueue());
  }
View Full Code Here

    tt.setMaxMapSlots(MAP_SLOTS);
    tt.setMaxReduceSlots(REDUCE_SLOTS);
    tt.setTaskController(new DefaultTaskController());
    jvmManager = new JvmManager(tt);
    tt.setJvmManagerInstance(jvmManager);
    tt.setUserLogManager(new UserLogManager(ttConf));
  }
View Full Code Here

        new LocalDirAllocator(JobConf.MAPRED_LOCAL_DIR_PROPERTY);
    tt.getTaskController().setup(ldirAlloc, new LocalStorage(ttConf.getLocalDirs()));
    JobID jobId = new JobID("test", 0);
    jvmManager = new JvmManager(tt);
    tt.setJvmManagerInstance(jvmManager);
    tt.setUserLogManager(new UserLogManager(ttConf));
    tt.setCleanupThread(new InlineCleanupQueue());
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.mapreduce.server.tasktracker.userlogs.UserLogManager

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.