Search in sources :

Example 1 with NamenodeRegistration

use of org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration in project hadoop by apache.

the class NameNodeRpcServer method registerSubordinateNamenode.

// NamenodeProtocol
@Override
public NamenodeRegistration registerSubordinateNamenode(NamenodeRegistration registration) throws IOException {
    checkNNStartup();
    namesystem.checkSuperuserPrivilege();
    verifyLayoutVersion(registration.getVersion());
    NamenodeRegistration myRegistration = nn.setRegistration();
    namesystem.registerBackupNode(registration, myRegistration);
    return myRegistration;
}
Also used : NamenodeRegistration(org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration)

Example 2 with NamenodeRegistration

use of org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration in project hadoop by apache.

the class TestPBHelper method testConvertNamenodeRegistration.

@Test
public void testConvertNamenodeRegistration() {
    StorageInfo info = getStorageInfo(NodeType.NAME_NODE);
    NamenodeRegistration reg = new NamenodeRegistration("address:999", "http:1000", info, NamenodeRole.NAMENODE);
    NamenodeRegistrationProto regProto = PBHelper.convert(reg);
    NamenodeRegistration reg2 = PBHelper.convert(regProto);
    assertEquals(reg.getAddress(), reg2.getAddress());
    assertEquals(reg.getClusterID(), reg2.getClusterID());
    assertEquals(reg.getCTime(), reg2.getCTime());
    assertEquals(reg.getHttpAddress(), reg2.getHttpAddress());
    assertEquals(reg.getLayoutVersion(), reg2.getLayoutVersion());
    assertEquals(reg.getNamespaceID(), reg2.getNamespaceID());
    assertEquals(reg.getRegistrationID(), reg2.getRegistrationID());
    assertEquals(reg.getRole(), reg2.getRole());
    assertEquals(reg.getVersion(), reg2.getVersion());
}
Also used : NamenodeRegistration(org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration) NamenodeRegistrationProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.NamenodeRegistrationProto) StorageInfo(org.apache.hadoop.hdfs.server.common.StorageInfo) DatanodeStorageInfo(org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo) Test(org.junit.Test)

Example 3 with NamenodeRegistration

use of org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration in project hadoop by apache.

the class BackupNode method registerWith.

/**
   * Register this backup node with the active name-node.
   * @param nsInfo namespace information
   * @throws IOException
   */
private void registerWith(NamespaceInfo nsInfo) throws IOException {
    BackupImage bnImage = (BackupImage) getFSImage();
    NNStorage storage = bnImage.getStorage();
    // verify namespaceID
    if (storage.getNamespaceID() == 0) {
        // new backup storage
        storage.setStorageInfo(nsInfo);
        storage.setBlockPoolID(nsInfo.getBlockPoolID());
        storage.setClusterID(nsInfo.getClusterID());
    } else {
        nsInfo.validateStorage(storage);
    }
    bnImage.initEditLog(StartupOption.REGULAR);
    setRegistration();
    NamenodeRegistration nnReg = null;
    while (!isStopRequested()) {
        try {
            nnReg = namenode.registerSubordinateNamenode(getRegistration());
            break;
        } catch (SocketTimeoutException e) {
            // name-node is busy
            LOG.info("Problem connecting to name-node: " + nnRpcAddress);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ie) {
                LOG.warn("Encountered exception ", e);
            }
        }
    }
    String msg = null;
    if (// consider as a rejection
    nnReg == null)
        msg = "Registration rejected by " + nnRpcAddress;
    else if (!nnReg.isRole(NamenodeRole.NAMENODE)) {
        msg = "Name-node " + nnRpcAddress + " is not active";
    }
    if (msg != null) {
        msg += ". Shutting down.";
        LOG.error(msg);
        // stop the node
        throw new IOException(msg);
    }
    nnRpcAddress = nnReg.getAddress();
}
Also used : NamenodeRegistration(org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration) SocketTimeoutException(java.net.SocketTimeoutException) IOException(java.io.IOException)

Aggregations

NamenodeRegistration (org.apache.hadoop.hdfs.server.protocol.NamenodeRegistration)3 IOException (java.io.IOException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 NamenodeRegistrationProto (org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.NamenodeRegistrationProto)1 DatanodeStorageInfo (org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo)1 StorageInfo (org.apache.hadoop.hdfs.server.common.StorageInfo)1 Test (org.junit.Test)1