Java Code Examples for org.apache.hadoop.hdfs.DistributedFileSystem#finalizeUpgrade()

The following examples show how to use org.apache.hadoop.hdfs.DistributedFileSystem#finalizeUpgrade() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DFSAdmin.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Command to ask the namenode to finalize previously performed upgrade.
 * Usage: hdfs dfsadmin -finalizeUpgrade
 * @exception IOException 
 */
public int finalizeUpgrade() throws IOException {
  DistributedFileSystem dfs = getDFS();
  
  Configuration dfsConf = dfs.getConf();
  URI dfsUri = dfs.getUri();
  boolean isHaAndLogicalUri = HAUtil.isLogicalUri(dfsConf, dfsUri);
  if (isHaAndLogicalUri) {
    // In the case of HA and logical URI, run finalizeUpgrade for all
    // NNs in this nameservice.
    String nsId = dfsUri.getHost();
    List<ClientProtocol> namenodes =
        HAUtil.getProxiesForAllNameNodesInNameservice(dfsConf, nsId);
    if (!HAUtil.isAtLeastOneActive(namenodes)) {
      throw new IOException("Cannot finalize with no NameNode active");
    }

    List<ProxyAndInfo<ClientProtocol>> proxies =
        HAUtil.getProxiesForAllNameNodesInNameservice(dfsConf,
        nsId, ClientProtocol.class);
    for (ProxyAndInfo<ClientProtocol> proxy : proxies) {
      proxy.getProxy().finalizeUpgrade();
      System.out.println("Finalize upgrade successful for " +
          proxy.getAddress());
    }
  } else {
    dfs.finalizeUpgrade();
    System.out.println("Finalize upgrade successful");
  }
  
  return 0;
}
 
Example 2
Source File: DFSAdmin.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Command to ask the namenode to finalize previously performed upgrade.
 * Usage: hdfs dfsadmin -finalizeUpgrade
 * @exception IOException 
 */
public int finalizeUpgrade() throws IOException {
  DistributedFileSystem dfs = getDFS();
  
  Configuration dfsConf = dfs.getConf();
  URI dfsUri = dfs.getUri();
  boolean isHaAndLogicalUri = HAUtil.isLogicalUri(dfsConf, dfsUri);
  if (isHaAndLogicalUri) {
    // In the case of HA and logical URI, run finalizeUpgrade for all
    // NNs in this nameservice.
    String nsId = dfsUri.getHost();
    List<ClientProtocol> namenodes =
        HAUtil.getProxiesForAllNameNodesInNameservice(dfsConf, nsId);
    if (!HAUtil.isAtLeastOneActive(namenodes)) {
      throw new IOException("Cannot finalize with no NameNode active");
    }

    List<ProxyAndInfo<ClientProtocol>> proxies =
        HAUtil.getProxiesForAllNameNodesInNameservice(dfsConf,
        nsId, ClientProtocol.class);
    for (ProxyAndInfo<ClientProtocol> proxy : proxies) {
      proxy.getProxy().finalizeUpgrade();
      System.out.println("Finalize upgrade successful for " +
          proxy.getAddress());
    }
  } else {
    dfs.finalizeUpgrade();
    System.out.println("Finalize upgrade successful");
  }
  
  return 0;
}
 
Example 3
Source File: DFSAdmin.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Command to ask the namenode to finalize previously performed upgrade.
 * Usage: java DFSAdmin -finalizeUpgrade
 * @exception IOException 
 */
public int finalizeUpgrade() throws IOException {
  int exitCode = -1;

  DistributedFileSystem dfs = getDFS();
  if (dfs == null) {
    System.out.println("FileSystem is " + getFS().getUri());
    return exitCode;
  }

  dfs.finalizeUpgrade();
  exitCode = 0;
 
  return exitCode;
}
 
Example 4
Source File: DFSAdmin.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
/**
 * Command to ask the namenode to finalize previously performed upgrade.
 * Usage: java DFSAdmin -finalizeUpgrade
 * @exception IOException 
 */
public int finalizeUpgrade() throws IOException {
  int exitCode = -1;

  if (!(fs instanceof DistributedFileSystem)) {
    System.out.println("FileSystem is " + fs.getUri());
    return exitCode;
  }

  DistributedFileSystem dfs = (DistributedFileSystem) fs;
  dfs.finalizeUpgrade();
  exitCode = 0;
 
  return exitCode;
}