From c4c781d867ae133bbf4dd1e43b10bd4603b2f334 Mon Sep 17 00:00:00 2001 From: "tanu.ajmera" Date: Tue, 23 Jun 2020 16:12:42 +0530 Subject: [PATCH] YARN-10320. Replace FSDataInputStream#read with readFully in Log Aggregation Change-Id: If0ddae5e2eeff66921a7a204adec6d4e901b8d05 --- hadoop-project/pom.xml | 2 +- .../ifile/LogAggregationIndexedFileController.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hadoop-project/pom.xml b/hadoop-project/pom.xml index 8c11de695ae..94a3f65bdcc 100644 --- a/hadoop-project/pom.xml +++ b/hadoop-project/pom.xml @@ -58,7 +58,7 @@ file:///dev/urandom - 1.8.2.7.2.1.0-SNAPSHOT + 1.7.7 1.19 diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/LogAggregationIndexedFileController.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/LogAggregationIndexedFileController.java index 4eea2a90734..b5c3dad6c0a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/LogAggregationIndexedFileController.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/LogAggregationIndexedFileController.java @@ -263,7 +263,8 @@ public Object run() throws Exception { checksumFileInputStream = fc.open(remoteLogCheckSumFile); int nameLength = checksumFileInputStream.readInt(); byte[] b = new byte[nameLength]; - int actualLength = checksumFileInputStream.read(b); + checksumFileInputStream.readFully(b); + int actualLength = b.length; if (actualLength == nameLength) { String recoveredLogFile = new String( b, Charset.forName("UTF-8")); @@ -712,7 +713,8 @@ public boolean apply(FileStatus next) { checksumFileInputStream = fc.open(file.getPath()); int nameLength = checksumFileInputStream.readInt(); byte[] b = new byte[nameLength]; - int actualLength = checksumFileInputStream.read(b); + checksumFileInputStream.readFully(b); + int actualLength = b.length; if (actualLength == nameLength) { nodeName = new String(b, Charset.forName("UTF-8")); index = checksumFileInputStream.readLong(); @@ -844,7 +846,8 @@ public IndexedLogsMeta loadIndexedLogsMeta(Path remoteLogPath, long end, // Load UUID and make sure the UUID is correct. byte[] uuidRead = new byte[UUID_LENGTH]; - int uuidReadLen = fsDataIStream.read(uuidRead); + fsDataIStream.readFully(uuidRead); + int uuidReadLen = uuidRead.length; if (this.uuid == null) { this.uuid = createUUID(appId); } @@ -1227,7 +1230,8 @@ private Path getCurrentRemoteLogFile(final FileContext fc, .endsWith(CHECK_SUM_FILE_SUFFIX)) { fsDataInputStream = fc.open(checkPath); byte[] b = new byte[uuid.length]; - int actual = fsDataInputStream.read(b); + fsDataInputStream.readFully(b); + int actual = b.length; if (actual != uuid.length || Arrays.equals(b, uuid)) { deleteFileWithRetries(fc, checkPath); } else if (id == null){ -- 2.25.0