YARN-4365. FileSystemNodeLabelStore should check for root dir existence on startup. Contributed by Kuhu Shukla
(cherry picked from commit f5acf94eca
)
Conflicts:
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java
This commit is contained in:
parent
4ba5667aed
commit
b68f527b9f
|
@ -31,6 +31,9 @@ Release 2.7.3 - UNRELEASED
|
||||||
YARN-4344. NMs reconnecting with changed capabilities can lead to wrong
|
YARN-4344. NMs reconnecting with changed capabilities can lead to wrong
|
||||||
cluster resource calculations (Varun Vasudev via jlowe)
|
cluster resource calculations (Varun Vasudev via jlowe)
|
||||||
|
|
||||||
|
YARN-4365. FileSystemNodeLabelStore should check for root dir existence on
|
||||||
|
startup (Kuhu Shukla via jlowe)
|
||||||
|
|
||||||
Release 2.7.2 - UNRELEASED
|
Release 2.7.2 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -917,6 +920,9 @@ Release 2.6.3 - UNRELEASED
|
||||||
YARN-3925. ContainerLogsUtils#getContainerLogFile fails to read container
|
YARN-3925. ContainerLogsUtils#getContainerLogFile fails to read container
|
||||||
log files from full disks. (zhihai xu via jlowe)
|
log files from full disks. (zhihai xu via jlowe)
|
||||||
|
|
||||||
|
YARN-4365. FileSystemNodeLabelStore should check for root dir existence on
|
||||||
|
startup (Kuhu Shukla via jlowe)
|
||||||
|
|
||||||
Release 2.6.2 - 2015-10-28
|
Release 2.6.2 - 2015-10-28
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -84,7 +84,9 @@ public class FileSystemNodeLabelsStore extends NodeLabelsStore {
|
||||||
setFileSystem(conf);
|
setFileSystem(conf);
|
||||||
|
|
||||||
// mkdir of root dir path
|
// mkdir of root dir path
|
||||||
fs.mkdirs(fsWorkingPath);
|
if (!fs.exists(fsWorkingPath)) {
|
||||||
|
fs.mkdirs(fsWorkingPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -97,7 +99,7 @@ public class FileSystemNodeLabelsStore extends NodeLabelsStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFileSystem(Configuration conf) throws IOException {
|
void setFileSystem(Configuration conf) throws IOException {
|
||||||
Configuration confCopy = new Configuration(conf);
|
Configuration confCopy = new Configuration(conf);
|
||||||
confCopy.setBoolean("dfs.client.retry.policy.enabled", true);
|
confCopy.setBoolean("dfs.client.retry.policy.enabled", true);
|
||||||
String retryPolicy =
|
String retryPolicy =
|
||||||
|
|
|
@ -24,6 +24,8 @@ import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.yarn.event.InlineDispatcher;
|
import org.apache.hadoop.yarn.event.InlineDispatcher;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -32,6 +34,7 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
|
public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
|
||||||
MockNodeLabelManager mgr = null;
|
MockNodeLabelManager mgr = null;
|
||||||
|
@ -273,4 +276,30 @@ public class TestFileSystemNodeLabelsStore extends NodeLabelTestBase {
|
||||||
Arrays.asList("p2", "p4", "p6", "p7", "p8", "p9")));
|
Arrays.asList("p2", "p4", "p6", "p7", "p8", "p9")));
|
||||||
mgr.stop();
|
mgr.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRootMkdirOnInitStore() throws Exception {
|
||||||
|
final FileSystem mockFs = Mockito.mock(FileSystem.class);
|
||||||
|
FileSystemNodeLabelsStore mockStore = new FileSystemNodeLabelsStore(mgr) {
|
||||||
|
void setFileSystem(Configuration conf) throws IOException {
|
||||||
|
fs = mockFs;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mockStore.fs = mockFs;
|
||||||
|
verifyMkdirsCount(mockStore, true, 0);
|
||||||
|
verifyMkdirsCount(mockStore, false, 1);
|
||||||
|
verifyMkdirsCount(mockStore, true, 1);
|
||||||
|
verifyMkdirsCount(mockStore, false, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void verifyMkdirsCount(FileSystemNodeLabelsStore store,
|
||||||
|
boolean existsRetVal, int expectedNumOfCalls)
|
||||||
|
throws Exception {
|
||||||
|
Mockito.when(store.fs.exists(Mockito.any(
|
||||||
|
Path.class))).thenReturn(existsRetVal);
|
||||||
|
store.init(conf);
|
||||||
|
Mockito.verify(store.fs,Mockito.times(
|
||||||
|
expectedNumOfCalls)).mkdirs(Mockito.any(Path
|
||||||
|
.class));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue