Example usage for org.apache.hadoop.hdfs.server.protocol NamespaceInfo NamespaceInfo

List of usage examples for org.apache.hadoop.hdfs.server.protocol NamespaceInfo NamespaceInfo

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.server.protocol NamespaceInfo NamespaceInfo.

Prototype

public NamespaceInfo() 

Source Link

Usage

From source file:common.DataNode.java

License:Apache License

private NamespaceInfo handshake() throws IOException {
    NamespaceInfo nsInfo = new NamespaceInfo();
    while (shouldRun) {
        try {//from ww  w . ja  v a2  s . c  o m
            nsInfo = namenode.versionRequest();
            break;
        } catch (SocketTimeoutException e) { // namenode is busy
            LOG.info("Problem connecting to server: " + getNameNodeAddr());
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ie) {
            }
        }
    }
    String errorMsg = null;
    // verify build version
    if (!nsInfo.getBuildVersion().equals(Storage.getBuildVersion())) {
        errorMsg = "Incompatible build versions: namenode BV = " + nsInfo.getBuildVersion() + "; datanode BV = "
                + Storage.getBuildVersion();
        LOG.fatal(errorMsg);
        try {
            namenode.errorReport(dnRegistration, DatanodeProtocol.NOTIFY, errorMsg);
        } catch (SocketTimeoutException e) { // namenode is busy
            LOG.info("Problem connecting to server: " + getNameNodeAddr());
        }
        throw new IOException(errorMsg);
    }
    assert FSConstants.LAYOUT_VERSION == nsInfo
            .getLayoutVersion() : "Data-node and name-node layout versions must be the same." + "Expected: "
                    + FSConstants.LAYOUT_VERSION + " actual " + nsInfo.getLayoutVersion();
    return nsInfo;
}