YARN-3930. FileSystemNodeLabelsStore should make sure edit log file closed when exception is thrown. (Dian Fu via wangda)

This commit is contained in:
Wangda Tan 2015-07-16 16:06:20 -07:00
parent d96bbe152c
commit fa2b63ed16
2 changed files with 27 additions and 15 deletions

View File

@ -637,6 +637,9 @@ Release 2.8.0 - UNRELEASED
YARN-3805. Update the documentation of Disk Checker based on YARN-90. YARN-3805. Update the documentation of Disk Checker based on YARN-90.
(Masatake Iwasaki via ozawa) (Masatake Iwasaki via ozawa)
YARN-3930. FileSystemNodeLabelsStore should make sure edit log file closed when
exception is thrown. (Dian Fu via wangda)
Release 2.7.2 - UNRELEASED Release 2.7.2 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -127,32 +127,41 @@ public class FileSystemNodeLabelsStore extends NodeLabelsStore {
@Override @Override
public void updateNodeToLabelsMappings( public void updateNodeToLabelsMappings(
Map<NodeId, Set<String>> nodeToLabels) throws IOException { Map<NodeId, Set<String>> nodeToLabels) throws IOException {
try {
ensureAppendEditlogFile(); ensureAppendEditlogFile();
editlogOs.writeInt(SerializedLogType.NODE_TO_LABELS.ordinal()); editlogOs.writeInt(SerializedLogType.NODE_TO_LABELS.ordinal());
((ReplaceLabelsOnNodeRequestPBImpl) ReplaceLabelsOnNodeRequest ((ReplaceLabelsOnNodeRequestPBImpl) ReplaceLabelsOnNodeRequest
.newInstance(nodeToLabels)).getProto().writeDelimitedTo(editlogOs); .newInstance(nodeToLabels)).getProto().writeDelimitedTo(editlogOs);
} finally {
ensureCloseEditlogFile(); ensureCloseEditlogFile();
} }
}
@Override @Override
public void storeNewClusterNodeLabels(List<NodeLabel> labels) public void storeNewClusterNodeLabels(List<NodeLabel> labels)
throws IOException { throws IOException {
try {
ensureAppendEditlogFile(); ensureAppendEditlogFile();
editlogOs.writeInt(SerializedLogType.ADD_LABELS.ordinal()); editlogOs.writeInt(SerializedLogType.ADD_LABELS.ordinal());
((AddToClusterNodeLabelsRequestPBImpl) AddToClusterNodeLabelsRequest ((AddToClusterNodeLabelsRequestPBImpl) AddToClusterNodeLabelsRequest
.newInstance(labels)).getProto().writeDelimitedTo(editlogOs); .newInstance(labels)).getProto().writeDelimitedTo(editlogOs);
} finally {
ensureCloseEditlogFile(); ensureCloseEditlogFile();
} }
}
@Override @Override
public void removeClusterNodeLabels(Collection<String> labels) public void removeClusterNodeLabels(Collection<String> labels)
throws IOException { throws IOException {
try {
ensureAppendEditlogFile(); ensureAppendEditlogFile();
editlogOs.writeInt(SerializedLogType.REMOVE_LABELS.ordinal()); editlogOs.writeInt(SerializedLogType.REMOVE_LABELS.ordinal());
((RemoveFromClusterNodeLabelsRequestPBImpl) RemoveFromClusterNodeLabelsRequest.newInstance(Sets ((RemoveFromClusterNodeLabelsRequestPBImpl) RemoveFromClusterNodeLabelsRequest.newInstance(Sets
.newHashSet(labels.iterator()))).getProto().writeDelimitedTo(editlogOs); .newHashSet(labels.iterator()))).getProto().writeDelimitedTo(editlogOs);
} finally {
ensureCloseEditlogFile(); ensureCloseEditlogFile();
} }
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.hadoop.yarn.nodelabels.NodeLabelsStore#recover(boolean) * @see org.apache.hadoop.yarn.nodelabels.NodeLabelsStore#recover(boolean)