@Test public void testForCorruptedAggregatedLogs() throws Exception { Configuration conf = new Configuration(); File workDir = new File(testWorkDir, "testReadAcontainerLogs1"); Path remoteAppLogFile = new Path(workDir.getAbsolutePath(), "aggregatedLogFile"); Path srcFileRoot = new Path(workDir.getAbsolutePath(), "srcFiles"); ContainerId testContainerId = TestContainerId.newContainerId(1, 1, 1, 1); Path t = new Path(srcFileRoot, testContainerId.getApplicationAttemptId() .getApplicationId().toString()); Path srcFilePath = new Path(t, testContainerId.toString()); long numChars = 950000; writeSrcFileAndALog(srcFilePath, "stdout", numChars, remoteAppLogFile, srcFileRoot, testContainerId); LogReader logReader = new LogReader(conf, remoteAppLogFile); LogKey rLogKey = new LogKey(); DataInputStream dis = logReader.next(rLogKey); Writer writer = new StringWriter(); try { LogReader.readAcontainerLogs(dis, writer); } catch (Exception e) { if(e.toString().contains("NumberFormatException")) { Assert.fail("Aggregated logs are corrupted."); } } }
@Test public void testForCorruptedAggregatedLogs() throws Exception { Configuration conf = new Configuration(); File workDir = new File(testWorkDir, "testReadAcontainerLogs1"); Path remoteAppLogFile = new Path(workDir.getAbsolutePath(), "aggregatedLogFile"); Path srcFileRoot = new Path(workDir.getAbsolutePath(), "srcFiles"); ContainerId testContainerId = TestContainerId.newContainerId(1, 1, 1, 1); Path t = new Path(srcFileRoot, testContainerId.getApplicationAttemptId() .getApplicationId().toString()); Path srcFilePath = new Path(t, testContainerId.toString()); long numChars = 950000; writeSrcFileAndALog(srcFilePath, "stdout", numChars, remoteAppLogFile, srcFileRoot, testContainerId); LogReader logReader = new LogReader(conf, remoteAppLogFile); LogKey rLogKey = new LogKey(); DataInputStream dis = logReader.next(rLogKey); Writer writer = new StringWriter(); try { LogReader.readAcontainerLogs(dis, writer); } catch (Exception e) { if(e.toString().contains("NumberFormatException")) { Assert.fail("Aggregated logs are corrupted."); } } }
@Test public void testForCorruptedAggregatedLogs() throws Exception { Configuration conf = new Configuration(); File workDir = new File(testWorkDir, "testReadAcontainerLogs1"); Path remoteAppLogFile = new Path(workDir.getAbsolutePath(), "aggregatedLogFile"); Path srcFileRoot = new Path(workDir.getAbsolutePath(), "srcFiles"); ContainerId testContainerId = TestContainerId.newContainerId(1, 1, 1, 1); Path t = new Path(srcFileRoot, testContainerId.getApplicationAttemptId() .getApplicationId().toString()); Path srcFilePath = new Path(t, testContainerId.toString()); long numChars = 950000; writeSrcFileAndALog(srcFilePath, "stdout", numChars, remoteAppLogFile, srcFileRoot, testContainerId); LogReader logReader = new LogReader(conf, remoteAppLogFile); LogKey rLogKey = new LogKey(); DataInputStream dis = logReader.next(rLogKey); Writer writer = new StringWriter(); try { LogReader.readAcontainerLogs(dis, writer); } catch (Exception e) { if(e.toString().contains("NumberFormatException")) { Assert.fail("Aggregated logs are corrupted."); } } }
LogReader.readAcontainerLogs(dis, writer, System.currentTimeMillis()); } else { LogReader.readAcontainerLogs(dis, writer);
LogReader.readAcontainerLogs(dis, writer, System.currentTimeMillis()); } else { LogReader.readAcontainerLogs(dis, writer);
LogReader.readAcontainerLogs(dis, writer, System.currentTimeMillis()); } else { LogReader.readAcontainerLogs(dis, writer);
/** * Writes all logs for a single container to the provided writer. * @param valueStream the value stream * @param writer the log writer * @throws IOException if we can not read the container logs. */ public static void readAcontainerLogs(DataInputStream valueStream, Writer writer) throws IOException { readAcontainerLogs(valueStream, writer, -1); }
/** * Writes all logs for a single container to the provided writer. * @param valueStream * @param writer * @throws IOException */ public static void readAcontainerLogs(DataInputStream valueStream, Writer writer) throws IOException { readAcontainerLogs(valueStream, writer, -1); }
/** * Writes all logs for a single container to the provided writer. * @param valueStream * @param writer * @throws IOException */ public static void readAcontainerLogs(DataInputStream valueStream, Writer writer) throws IOException { readAcontainerLogs(valueStream, writer, -1); }