use of org.apache.hadoop.hdfs.server.protocol.NamespaceInfo in project hadoop by apache.
the class TestFSNamesystem method testHAStateInNamespaceInfo.
@Test
public void testHAStateInNamespaceInfo() throws IOException {
Configuration conf = new Configuration();
FSEditLog fsEditLog = Mockito.mock(FSEditLog.class);
FSImage fsImage = Mockito.mock(FSImage.class);
Mockito.when(fsImage.getEditLog()).thenReturn(fsEditLog);
NNStorage nnStorage = Mockito.mock(NNStorage.class);
Mockito.when(fsImage.getStorage()).thenReturn(nnStorage);
FSNamesystem fsNamesystem = new FSNamesystem(conf, fsImage);
FSNamesystem fsn = Mockito.spy(fsNamesystem);
Mockito.when(fsn.getState()).thenReturn(HAServiceProtocol.HAServiceState.ACTIVE);
NamespaceInfo nsInfo = fsn.unprotectedGetNamespaceInfo();
assertNotNull(nsInfo.getState());
}
use of org.apache.hadoop.hdfs.server.protocol.NamespaceInfo in project hadoop by apache.
the class BPServiceActor method reRegister.
void reRegister() throws IOException {
if (shouldRun()) {
// re-retrieve namespace info to make sure that, if the NN
// was restarted, we still match its version (HDFS-2120)
NamespaceInfo nsInfo = retrieveNamespaceInfo();
// and re-register
register(nsInfo);
scheduler.scheduleHeartbeat();
// for sometime.
if (state == HAServiceState.STANDBY) {
ibrManager.clearIBRs();
}
}
}
use of org.apache.hadoop.hdfs.server.protocol.NamespaceInfo in project hadoop by apache.
the class TestDataStorage method createNamespaceInfos.
private static List<NamespaceInfo> createNamespaceInfos(int num) {
List<NamespaceInfo> nsInfos = new ArrayList<NamespaceInfo>();
for (int i = 0; i < num; i++) {
String bpid = "bp-" + i;
nsInfos.add(new NamespaceInfo(0, CLUSTER_ID, bpid, CTIME, BUILD_VERSION, SOFTWARE_VERSION));
}
return nsInfos;
}
use of org.apache.hadoop.hdfs.server.protocol.NamespaceInfo in project hadoop by apache.
the class TestDataStorage method setUp.
@Before
public void setUp() throws IOException {
Configuration conf = new HdfsConfiguration();
storage = new DataStorage();
nsInfo = new NamespaceInfo(0, CLUSTER_ID, DEFAULT_BPID, CTIME, BUILD_VERSION, SOFTWARE_VERSION);
FileUtil.fullyDelete(TEST_DIR);
assertTrue("Failed to make test dir.", TEST_DIR.mkdirs());
Mockito.when(mockDN.getConf()).thenReturn(conf);
}
use of org.apache.hadoop.hdfs.server.protocol.NamespaceInfo in project hadoop by apache.
the class TestDataStorage method testMissingVersion.
@Test
public void testMissingVersion() throws IOException, URISyntaxException {
final int numLocations = 1;
final int numNamespace = 1;
List<StorageLocation> locations = createStorageLocations(numLocations);
StorageLocation firstStorage = locations.get(0);
Storage.StorageDirectory sd = new Storage.StorageDirectory(firstStorage);
// the directory is not initialized so VERSION does not exist
// create a fake directory under current/
File currentDir = new File(sd.getCurrentDir(), "BP-787466439-172.26.24.43-1462305406642");
assertTrue("unable to mkdir " + currentDir.getName(), currentDir.mkdirs());
// Add volumes for multiple namespaces.
List<NamespaceInfo> namespaceInfos = createNamespaceInfos(numNamespace);
for (NamespaceInfo ni : namespaceInfos) {
storage.addStorageLocations(mockDN, ni, locations, START_OPT);
}
// It should not format the directory because VERSION is missing.
assertTrue("Storage directory was formatted", currentDir.exists());
}
Aggregations