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;
}
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());
}
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();
}
Aggregations