You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nemo.apache.org by sa...@apache.org on 2018/06/15 08:11:55 UTC
[incubator-nemo] branch master updated: [NEMO-107] SonarCloud Bugs
for Nemo Executor (#46)
This is an automated email from the ASF dual-hosted git repository.
sanha pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nemo.git
The following commit(s) were added to refs/heads/master by this push:
new 31ed262 [NEMO-107] SonarCloud Bugs for Nemo Executor (#46)
31ed262 is described below
commit 31ed262f92e2443e13ee8ee9d569ff5a2af62d5c
Author: Eunji Jeong <eg...@gmail.com>
AuthorDate: Fri Jun 15 17:11:49 2018 +0900
[NEMO-107] SonarCloud Bugs for Nemo Executor (#46)
JIRA: [NEMO-107: SonarCloud Bugs and Vulnerabilities for Nemo Runtime Executor](https://issues.apache.org/jira/projects/NEMO/issues/NEMO-107)
**Major changes:**
- Resolve reported bugs and vulnerabilities of Nemo Runtime Executor from SonarCloud.
resolves [NEMO-107](https://issues.apache.org/jira/projects/NEMO/issues/NEMO-107)
---
.../runtime/executor/data/BlockManagerWorker.java | 35 ++++++++++++++--------
.../executor/task/ParentTaskDataFetcher.java | 1 +
.../nemo/runtime/executor/task/TaskExecutor.java | 3 +-
3 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/data/BlockManagerWorker.java b/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/data/BlockManagerWorker.java
index 84d4d48..41446c1 100644
--- a/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/data/BlockManagerWorker.java
+++ b/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/data/BlockManagerWorker.java
@@ -428,22 +428,31 @@ public final class BlockManagerWorker {
@Override
public void run() {
try {
- if (DataStoreProperty.Value.LocalFileStore.equals(blockStore)
- || DataStoreProperty.Value.GlusterFileStore.equals(blockStore)) {
- final List<FileArea> fileAreas = ((FileBlock) getBlockStore(blockStore)
- .readBlock(blockId).get()).asFileAreas(keyRange);
- for (final FileArea fileArea : fileAreas) {
- outputContext.newOutputStream().writeFileArea(fileArea).close();
+ final Optional<Block> optionalBlock = getBlockStore(blockStore).readBlock(blockId);
+ if (optionalBlock.isPresent()) {
+ if (DataStoreProperty.Value.LocalFileStore.equals(blockStore)
+ || DataStoreProperty.Value.GlusterFileStore.equals(blockStore)) {
+ final List<FileArea> fileAreas = ((FileBlock) optionalBlock.get()).asFileAreas(keyRange);
+ for (final FileArea fileArea : fileAreas) {
+ try (ByteOutputContext.ByteOutputStream os = outputContext.newOutputStream()) {
+ os.writeFileArea(fileArea);
+ }
+ }
+ } else {
+ final Iterable<SerializedPartition> partitions = optionalBlock.get().readSerializedPartitions(keyRange);
+ for (final SerializedPartition partition : partitions) {
+ try (ByteOutputContext.ByteOutputStream os = outputContext.newOutputStream()) {
+ os.writeSerializedPartition(partition);
+ }
+ }
}
+ handleUsedData(blockStore, blockId);
+ outputContext.close();
+
} else {
- final Iterable<SerializedPartition> partitions = getBlockStore(blockStore)
- .readBlock(blockId).get().readSerializedPartitions(keyRange);
- for (final SerializedPartition partition : partitions) {
- outputContext.newOutputStream().writeSerializedPartition(partition).close();
- }
+ // We don't have the block here...
+ throw new RuntimeException(String.format("Block %s not found in local BlockManagerWorker", blockId));
}
- handleUsedData(blockStore, blockId);
- outputContext.close();
} catch (final IOException | BlockFetchException e) {
LOG.error("Closing a block request exceptionally", e);
outputContext.onChannelError(e);
diff --git a/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/ParentTaskDataFetcher.java b/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/ParentTaskDataFetcher.java
index 61a371f..53c03f1 100644
--- a/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/ParentTaskDataFetcher.java
+++ b/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/ParentTaskDataFetcher.java
@@ -135,6 +135,7 @@ class ParentTaskDataFetcher extends DataFetcher {
}
}
} catch (InterruptedException exception) {
+ Thread.currentThread().interrupt();
throw new IOException(exception);
}
}
diff --git a/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/TaskExecutor.java b/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/TaskExecutor.java
index f8ef425..87f09c0 100644
--- a/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/TaskExecutor.java
+++ b/runtime/executor/src/main/java/edu/snu/nemo/runtime/executor/task/TaskExecutor.java
@@ -35,6 +35,7 @@ import edu.snu.nemo.runtime.executor.datatransfer.*;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -209,7 +210,7 @@ public final class TaskExecutor {
} catch (Throwable throwable) {
// ANY uncaught throwable is reported to the master
taskStateManager.onTaskStateChanged(TaskState.State.FAILED_UNRECOVERABLE, Optional.empty(), Optional.empty());
- throwable.printStackTrace();
+ LOG.error(ExceptionUtils.getStackTrace(throwable));
}
}
--
To stop receiving notification emails like this one, please contact
sanha@apache.org.