Java Code Examples for org.apache.hadoop.hdfs.server.protocol.NamespaceInfo#getNamespaceID()

The following examples show how to use org.apache.hadoop.hdfs.server.protocol.NamespaceInfo#getNamespaceID() . 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: DataStorage.java    From hadoop with Apache License 2.0 6 votes vote down vote up
void format(StorageDirectory sd, NamespaceInfo nsInfo,
            String datanodeUuid) throws IOException {
  sd.clearDirectory(); // create directory
  this.layoutVersion = HdfsConstants.DATANODE_LAYOUT_VERSION;
  this.clusterID = nsInfo.getClusterID();
  this.namespaceID = nsInfo.getNamespaceID();
  this.cTime = 0;
  setDatanodeUuid(datanodeUuid);

  if (sd.getStorageUuid() == null) {
    // Assign a new Storage UUID.
    sd.setStorageUuid(DatanodeStorage.generateUuid());
  }

  writeProperties(sd);
}
 
Example 2
Source File: DataStorage.java    From big-c with Apache License 2.0 6 votes vote down vote up
void format(StorageDirectory sd, NamespaceInfo nsInfo,
            String datanodeUuid) throws IOException {
  sd.clearDirectory(); // create directory
  this.layoutVersion = HdfsConstants.DATANODE_LAYOUT_VERSION;
  this.clusterID = nsInfo.getClusterID();
  this.namespaceID = nsInfo.getNamespaceID();
  this.cTime = 0;
  setDatanodeUuid(datanodeUuid);

  if (sd.getStorageUuid() == null) {
    // Assign a new Storage UUID.
    sd.setStorageUuid(DatanodeStorage.generateUuid());
  }

  writeProperties(sd);
}
 
Example 3
Source File: NameSpaceSliceStorage.java    From RDFS with Apache License 2.0 6 votes vote down vote up
/**
 * Format a namespace slice storage. 
 * @param sd the namespace storage
 * @param nsInfo the name space info
 * @throws IOException Signals that an I/O exception has occurred.
 */
private void format(StorageDirectory nsSdir, NamespaceInfo nsInfo) throws IOException {
  LOG.info("Formatting namespace " + namespaceID + " directory "
      + nsSdir.getCurrentDir());
  nsSdir.clearDirectory(); // create directory
  File rbwDir = new File(nsSdir.getCurrentDir(), STORAGE_DIR_RBW);
  File finalizedDir = new File(nsSdir.getCurrentDir(), STORAGE_DIR_FINALIZED);
  LOG.info("Creating Directories : " + rbwDir + ", " + finalizedDir);
  if (!rbwDir.mkdirs() || !finalizedDir.mkdirs()) {
    throw new IOException("Cannot create directories : " + rbwDir + ", "
        + finalizedDir);
  }
  this.layoutVersion = FSConstants.LAYOUT_VERSION;
  this.cTime = nsInfo.getCTime();
  this.namespaceID = nsInfo.getNamespaceID();
  this.storageType = NodeType.DATA_NODE;
  nsSdir.write();
}
 
Example 4
Source File: BlockPoolSliceStorage.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Format a block pool slice storage. 
 * @param bpSdir the block pool storage
 * @param nsInfo the name space info
 * @throws IOException Signals that an I/O exception has occurred.
 */
private void format(StorageDirectory bpSdir, NamespaceInfo nsInfo) throws IOException {
  LOG.info("Formatting block pool " + blockpoolID + " directory "
      + bpSdir.getCurrentDir());
  bpSdir.clearDirectory(); // create directory
  this.layoutVersion = HdfsConstants.DATANODE_LAYOUT_VERSION;
  this.cTime = nsInfo.getCTime();
  this.namespaceID = nsInfo.getNamespaceID();
  this.blockpoolID = nsInfo.getBlockPoolID();
  writeProperties(bpSdir);
}
 
Example 5
Source File: DataStorage.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Prepare a storage directory. It creates a builder which can be used to add
 * to the volume. If the volume cannot be added, it is OK to discard the
 * builder later.
 *
 * @param datanode DataNode object.
 * @param volume the root path of a storage directory.
 * @param nsInfos an array of namespace infos.
 * @return a VolumeBuilder that holds the metadata of this storage directory
 * and can be added to DataStorage later.
 * @throws IOException if encounters I/O errors.
 *
 * Note that if there is IOException, the state of DataStorage is not modified.
 */
public VolumeBuilder prepareVolume(DataNode datanode, File volume,
    List<NamespaceInfo> nsInfos) throws IOException {
  if (containsStorageDir(volume)) {
    final String errorMessage = "Storage directory is in use";
    LOG.warn(errorMessage + ".");
    throw new IOException(errorMessage);
  }

  StorageDirectory sd = loadStorageDirectory(
      datanode, nsInfos.get(0), volume, StartupOption.HOTSWAP);
  VolumeBuilder builder =
      new VolumeBuilder(this, sd);
  for (NamespaceInfo nsInfo : nsInfos) {
    List<File> bpDataDirs = Lists.newArrayList();
    bpDataDirs.add(BlockPoolSliceStorage.getBpRoot(
        nsInfo.getBlockPoolID(), new File(volume, STORAGE_DIR_CURRENT)));
    makeBlockPoolDataDir(bpDataDirs, null);

    BlockPoolSliceStorage bpStorage;
    final String bpid = nsInfo.getBlockPoolID();
    synchronized (this) {
      bpStorage = this.bpStorageMap.get(bpid);
      if (bpStorage == null) {
        bpStorage = new BlockPoolSliceStorage(
            nsInfo.getNamespaceID(), bpid, nsInfo.getCTime(),
            nsInfo.getClusterID());
        addBlockPoolStorage(bpid, bpStorage);
      }
    }
    builder.addBpStorageDirectories(
        bpid, bpStorage.loadBpStorageDirectories(
            datanode, nsInfo, bpDataDirs, StartupOption.HOTSWAP));
  }
  return builder;
}
 
Example 6
Source File: JNStorage.java    From hadoop with Apache License 2.0 5 votes vote down vote up
void checkConsistentNamespace(NamespaceInfo nsInfo)
    throws IOException {
  if (nsInfo.getNamespaceID() != getNamespaceID()) {
    throw new IOException("Incompatible namespaceID for journal " +
        this.sd + ": NameNode has nsId " + nsInfo.getNamespaceID() +
        " but storage has nsId " + getNamespaceID());
  }
  
  if (!nsInfo.getClusterID().equals(getClusterID())) {
    throw new IOException("Incompatible clusterID for journal " +
        this.sd + ": NameNode has clusterId '" + nsInfo.getClusterID() +
        "' but storage has clusterId '" + getClusterID() + "'");
    
  }
}
 
Example 7
Source File: BlockPoolSliceStorage.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Format a block pool slice storage. 
 * @param bpSdir the block pool storage
 * @param nsInfo the name space info
 * @throws IOException Signals that an I/O exception has occurred.
 */
private void format(StorageDirectory bpSdir, NamespaceInfo nsInfo) throws IOException {
  LOG.info("Formatting block pool " + blockpoolID + " directory "
      + bpSdir.getCurrentDir());
  bpSdir.clearDirectory(); // create directory
  this.layoutVersion = HdfsConstants.DATANODE_LAYOUT_VERSION;
  this.cTime = nsInfo.getCTime();
  this.namespaceID = nsInfo.getNamespaceID();
  this.blockpoolID = nsInfo.getBlockPoolID();
  writeProperties(bpSdir);
}
 
Example 8
Source File: DataStorage.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Prepare a storage directory. It creates a builder which can be used to add
 * to the volume. If the volume cannot be added, it is OK to discard the
 * builder later.
 *
 * @param datanode DataNode object.
 * @param volume the root path of a storage directory.
 * @param nsInfos an array of namespace infos.
 * @return a VolumeBuilder that holds the metadata of this storage directory
 * and can be added to DataStorage later.
 * @throws IOException if encounters I/O errors.
 *
 * Note that if there is IOException, the state of DataStorage is not modified.
 */
public VolumeBuilder prepareVolume(DataNode datanode, File volume,
    List<NamespaceInfo> nsInfos) throws IOException {
  if (containsStorageDir(volume)) {
    final String errorMessage = "Storage directory is in use";
    LOG.warn(errorMessage + ".");
    throw new IOException(errorMessage);
  }

  StorageDirectory sd = loadStorageDirectory(
      datanode, nsInfos.get(0), volume, StartupOption.HOTSWAP);
  VolumeBuilder builder =
      new VolumeBuilder(this, sd);
  for (NamespaceInfo nsInfo : nsInfos) {
    List<File> bpDataDirs = Lists.newArrayList();
    bpDataDirs.add(BlockPoolSliceStorage.getBpRoot(
        nsInfo.getBlockPoolID(), new File(volume, STORAGE_DIR_CURRENT)));
    makeBlockPoolDataDir(bpDataDirs, null);

    BlockPoolSliceStorage bpStorage;
    final String bpid = nsInfo.getBlockPoolID();
    synchronized (this) {
      bpStorage = this.bpStorageMap.get(bpid);
      if (bpStorage == null) {
        bpStorage = new BlockPoolSliceStorage(
            nsInfo.getNamespaceID(), bpid, nsInfo.getCTime(),
            nsInfo.getClusterID());
        addBlockPoolStorage(bpid, bpStorage);
      }
    }
    builder.addBpStorageDirectories(
        bpid, bpStorage.loadBpStorageDirectories(
            datanode, nsInfo, bpDataDirs, StartupOption.HOTSWAP));
  }
  return builder;
}
 
Example 9
Source File: JNStorage.java    From big-c with Apache License 2.0 5 votes vote down vote up
void checkConsistentNamespace(NamespaceInfo nsInfo)
    throws IOException {
  if (nsInfo.getNamespaceID() != getNamespaceID()) {
    throw new IOException("Incompatible namespaceID for journal " +
        this.sd + ": NameNode has nsId " + nsInfo.getNamespaceID() +
        " but storage has nsId " + getNamespaceID());
  }
  
  if (!nsInfo.getClusterID().equals(getClusterID())) {
    throw new IOException("Incompatible clusterID for journal " +
        this.sd + ": NameNode has clusterId '" + nsInfo.getClusterID() +
        "' but storage has clusterId '" + getClusterID() + "'");
    
  }
}
 
Example 10
Source File: DataStorage.java    From RDFS with Apache License 2.0 5 votes vote down vote up
void format(StorageDirectory sd, NamespaceInfo nsInfo) throws IOException {
  sd.clearDirectory(); // create directory
  this.layoutVersion = FSConstants.LAYOUT_VERSION;
  this.namespaceID = nsInfo.getNamespaceID();  // mother namespaceid
  this.cTime = 0;
  // store storageID as it currently is
  sd.write();
}
 
Example 11
Source File: DataStorage.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
void format(StorageDirectory sd, NamespaceInfo nsInfo) throws IOException {
  sd.clearDirectory(); // create directory
  this.layoutVersion = FSConstants.LAYOUT_VERSION;
  this.namespaceID = nsInfo.getNamespaceID();
  this.cTime = 0;
  // store storageID as it currently is
  sd.write();
}
 
Example 12
Source File: AvatarDataNode.java    From RDFS with Apache License 2.0 4 votes vote down vote up
private void setNamespaceInfo(NamespaceInfo nsinfo) {
  this.nsInfo = nsinfo;
  this.namespaceId = nsinfo.getNamespaceID();
  namespaceManager.addNamespace(this);
}
 
Example 13
Source File: DataNode.java    From RDFS with Apache License 2.0 4 votes vote down vote up
void setNamespaceInfo(NamespaceInfo nsinfo) {
  this.nsInfo = nsinfo;
  this.namespaceId = nsinfo.getNamespaceID();
  namespaceManager.addNamespace(this);
}