public String getStorageID() { return storage.getStorageID(); }
/** * Get DataNode info - used primarily for logging */ public String getDatanodeInfo() { return machineName + ":" + selfAddr.getPort() + "; storageID= " + storage.getStorageID(); }
protected void setFields(Properties props, StorageDirectory sd ) throws IOException { props.setProperty(STORAGE_TYPE, storageType.toString()); props.setProperty(LAYOUT_VERSION, String.valueOf(layoutVersion)); props.setProperty(STORAGE_ID, getStorageID()); // Set NamespaceID in version before federation if (layoutVersion > FSConstants.FEDERATION_VERSION) { props.setProperty(NAMESPACE_ID, String.valueOf(namespaceID)); props.setProperty(CHECK_TIME, String.valueOf(cTime)); } }
public void setStorageInfo(DataStorage storage) { this.storageInfo = new StorageInfo(storage); this.storageID = storage.getStorageID(); }
/** * Initializes the {@link #data}. The initialization is done only once, when * handshake with the the first namenode is completed. */ private synchronized void initFsDataSet(Configuration conf, AbstractList<File> dataDirs, int numNamespaces) throws IOException { if (data != null) { // Already initialized return; } // get version and id info from the name-node boolean simulatedFSDataset = conf.getBoolean("dfs.datanode.simulateddatastorage", false); if (simulatedFSDataset) { storage.createStorageID(selfAddr.getPort()); // it would have been better to pass storage as a parameter to // constructor below - need to augment ReflectionUtils used below. conf.set("dfs.datanode.StorageId", storage.getStorageID()); try { data = (FSDatasetInterface) ReflectionUtils.newInstance( Class.forName( "org.apache.hadoop.hdfs.server.datanode.SimulatedFSDataset"), conf); } catch (ClassNotFoundException e) { throw new IOException(StringUtils.stringifyException(e)); } } else { data = new FSDataset(this, conf, numNamespaces); } }
assert ("".equals(storage.getStorageID()) && !"".equals(dnRegistration.getStorageID())) || storage.getStorageID().equals(dnRegistration.getStorageID()) : "New storageID can be assigned only if data-node is not formatted"; if (storage.getStorageID().equals("")) { storage.setStorageID(dnRegistration.getStorageID()); storage.writeAll(); + " is assigned to data-node " + dnRegistration.getName()); if(! storage.getStorageID().equals(dnRegistration.getStorageID())) { throw new IOException("Inconsistent storage IDs. Name-node returned " + dnRegistration.getStorageID() + ". Expecting " + storage.getStorageID());
} catch (InterruptedException ie) {} assert ("".equals(storage.getStorageID()) && !"".equals(nsRegistration.getStorageID())) || storage.getStorageID().equals(nsRegistration.getStorageID()) : "New storageID can be assigned only if data-node is not formatted"; if (storage.getStorageID().equals("")) { storage.setStorageID(nsRegistration.getStorageID()); storage.writeAll(); + " is assigned to data-node " + nsRegistration.getName()); if(! storage.getStorageID().equals(nsRegistration.getStorageID())) { throw new IOException("Inconsistent storage IDs. Name-node returned " + nsRegistration.getStorageID() + ". Expecting " + storage.getStorageID());
/** * An FSDataset has a directory where it loads its data files. */ public FSDataset(DataStorage storage, Configuration conf) throws IOException { this.maxBlocksPerDir = conf.getInt("dfs.datanode.numblocks", 64); FSVolume[] volArray = new FSVolume[storage.getNumStorageDirs()]; for (int idx = 0; idx < storage.getNumStorageDirs(); idx++) { volArray[idx] = new FSVolume(storage.getStorageDir(idx).getCurrentDir(), conf); } volumes = new FSVolumeSet(volArray); volumeMap = new HashMap<Block, DatanodeBlockInfo>(); volumes.getVolumeMap(volumeMap); registerMBean(storage.getStorageID()); }
assert ("".equals(storage.getStorageID()) && !"".equals(dnRegistration.getStorageID())) || storage.getStorageID().equals(dnRegistration.getStorageID()) : "New storageID can be assigned only if data-node is not formatted"; if (storage.getStorageID().equals("")) { storage.setStorageID(dnRegistration.getStorageID()); storage.writeAll(); + " is assigned to data-node " + dnRegistration.getName()); if(! storage.getStorageID().equals(dnRegistration.getStorageID())) { throw new IOException("Inconsistent storage IDs. Name-node returned " + dnRegistration.getStorageID() + ". Expecting " + storage.getStorageID());
nsRegistration.setStorageID(storage.getStorageID()); //same as DN nsRegistration.storageInfo.layoutVersion = FSConstants.LAYOUT_VERSION; nsRegistration.storageInfo.namespaceID = nsInfo.namespaceID; storage.getNStorage(nsInfo.namespaceID), storage.getStorageID()); data.initialize(storage);
registerMBean(storage.getStorageID()); initialized = true; } finally {
/** * Initialize global settings for DN */ protected void initGlobalSetting(Configuration conf, AbstractList<File> dataDirs) throws IOException { this.dataDirs = dataDirs; this.conf = conf; storage = new DataStorage(this); // global DN settings initConfig(conf); registerMXBean(); initDataXceiver(conf); startInfoServer(conf); initIpcServer(conf); myMetrics = new DataNodeMetrics(conf, storage.getStorageID()); }