Search in sources :

Example 11 with NamespaceInfo

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());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) NamespaceInfo(org.apache.hadoop.hdfs.server.protocol.NamespaceInfo) Test(org.junit.Test)

Example 12 with NamespaceInfo

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();
        }
    }
}
Also used : NamespaceInfo(org.apache.hadoop.hdfs.server.protocol.NamespaceInfo)

Example 13 with NamespaceInfo

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;
}
Also used : ArrayList(java.util.ArrayList) NamespaceInfo(org.apache.hadoop.hdfs.server.protocol.NamespaceInfo)

Example 14 with NamespaceInfo

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);
}
Also used : HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) Configuration(org.apache.hadoop.conf.Configuration) HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) NamespaceInfo(org.apache.hadoop.hdfs.server.protocol.NamespaceInfo) Before(org.junit.Before)

Example 15 with NamespaceInfo

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());
}
Also used : Storage(org.apache.hadoop.hdfs.server.common.Storage) StorageDirectory(org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory) StorageDirectory(org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory) NamespaceInfo(org.apache.hadoop.hdfs.server.protocol.NamespaceInfo) File(java.io.File) Test(org.junit.Test)

Aggregations

NamespaceInfo (org.apache.hadoop.hdfs.server.protocol.NamespaceInfo)35 IOException (java.io.IOException)13 Test (org.junit.Test)13 File (java.io.File)8 InetSocketAddress (java.net.InetSocketAddress)7 Storage (org.apache.hadoop.hdfs.server.common.Storage)6 StorageDirectory (org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory)6 ArrayList (java.util.ArrayList)5 DatanodeProtocolClientSideTranslatorPB (org.apache.hadoop.hdfs.protocolPB.DatanodeProtocolClientSideTranslatorPB)5 DataStorage (org.apache.hadoop.hdfs.server.datanode.DataStorage)5 Configuration (org.apache.hadoop.conf.Configuration)4 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)4 StorageLocation (org.apache.hadoop.hdfs.server.datanode.StorageLocation)4 DatanodeRegistration (org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration)4 NNHAStatusHeartbeat (org.apache.hadoop.hdfs.server.protocol.NNHAStatusHeartbeat)4 SlowPeerReports (org.apache.hadoop.hdfs.server.protocol.SlowPeerReports)4 VolumeFailureSummary (org.apache.hadoop.hdfs.server.protocol.VolumeFailureSummary)4 HeartbeatResponse (org.apache.hadoop.hdfs.server.protocol.HeartbeatResponse)3 MultipleIOException (org.apache.hadoop.io.MultipleIOException)3 Matchers.anyString (org.mockito.Matchers.anyString)3