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() + "'"); } }
/** * Get the BlockPoolSliceStorage from {@link bpStorageMap}. * If the object is not found, create a new object and put it to the map. */ synchronized BlockPoolSliceStorage getBlockPoolSliceStorage( final NamespaceInfo nsInfo) { final String bpid = nsInfo.getBlockPoolID(); BlockPoolSliceStorage bpStorage = bpStorageMap.get(bpid); if (bpStorage == null) { bpStorage = new BlockPoolSliceStorage(nsInfo.getNamespaceID(), bpid, nsInfo.getCTime(), nsInfo.getClusterID()); bpStorageMap.put(bpid, bpStorage); } return bpStorage; }
private void doUpgrade(final StorageDirectory sd, final NamespaceInfo nsInfo, final File prevDir, final File tmpDir, final File bbwDir, final File toDir, final int oldLV, Configuration conf) throws IOException { // 3.2. Link block files from <SD>/previous.tmp to <SD>/current linkAllBlocks(tmpDir, bbwDir, toDir, oldLV, conf); // 4. Write version file under <SD>/current clusterID = nsInfo.getClusterID(); upgradeProperties(sd, conf); // 5. Rename <SD>/previous.tmp to <SD>/previous rename(tmpDir, prevDir); LOG.info("Upgrade of {} is complete", sd.getRoot()); }
void format(StorageDirectory sd, NamespaceInfo nsInfo, String newDatanodeUuid, Configuration conf) throws IOException { sd.clearDirectory(); // create directory this.layoutVersion = HdfsServerConstants.DATANODE_LAYOUT_VERSION; this.clusterID = nsInfo.getClusterID(); this.namespaceID = nsInfo.getNamespaceID(); this.cTime = 0; setDatanodeUuid(newDatanodeUuid); createStorageID(sd, false, conf); writeProperties(sd); }
@VisibleForTesting NamespaceInfo setNamespaceInfo(NamespaceInfo nsInfo) throws IOException { writeLock(); try { NamespaceInfo old = bpNSInfo; if (bpNSInfo != null && nsInfo != null) { checkNSEquality(bpNSInfo.getBlockPoolID(), nsInfo.getBlockPoolID(), "Blockpool ID"); checkNSEquality(bpNSInfo.getNamespaceID(), nsInfo.getNamespaceID(), "Namespace ID"); checkNSEquality(bpNSInfo.getClusterID(), nsInfo.getClusterID(), "Cluster ID"); } bpNSInfo = nsInfo; // cache the block pool id for lock-free access. bpId = (nsInfo != null) ? nsInfo.getBlockPoolID() : null; return old; } finally { writeUnlock(); } }
" Namespace ID: " + nsInfo.getNamespaceID() + "\n" + " Block pool ID: " + nsInfo.getBlockPoolID() + "\n" + " Cluster ID: " + nsInfo.getClusterID() + "\n" + " Layout version: " + nsInfo.getLayoutVersion() + "\n" + " isUpgradeFinalized: " + isUpgradeFinalized + "\n" +
&& !getClusterID().equals(nsInfo.getClusterID())) { throw new IOException("Incompatible clusterIDs in " + sd.getRoot().getCanonicalPath() + ": namenode clusterID = " + nsInfo.getClusterID() + "; datanode clusterID = " + getClusterID());
storage.setStorageInfo(nsInfo); storage.setBlockPoolID(nsInfo.getBlockPoolID()); storage.setClusterID(nsInfo.getClusterID()); } else { nsInfo.validateStorage(storage);
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() + "'"); } }
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() + "'"); } }
/** * Get the BlockPoolSliceStorage from {@link bpStorageMap}. * If the object is not found, create a new object and put it to the map. */ synchronized BlockPoolSliceStorage getBlockPoolSliceStorage( final NamespaceInfo nsInfo) { final String bpid = nsInfo.getBlockPoolID(); BlockPoolSliceStorage bpStorage = bpStorageMap.get(bpid); if (bpStorage == null) { bpStorage = new BlockPoolSliceStorage(nsInfo.getNamespaceID(), bpid, nsInfo.getCTime(), nsInfo.getClusterID()); bpStorageMap.put(bpid, bpStorage); } return bpStorage; }
/** * Get the BlockPoolSliceStorage from {@link bpStorageMap}. * If the object is not found, create a new object and put it to the map. */ synchronized BlockPoolSliceStorage getBlockPoolSliceStorage( final NamespaceInfo nsInfo) { final String bpid = nsInfo.getBlockPoolID(); BlockPoolSliceStorage bpStorage = bpStorageMap.get(bpid); if (bpStorage == null) { bpStorage = new BlockPoolSliceStorage(nsInfo.getNamespaceID(), bpid, nsInfo.getCTime(), nsInfo.getClusterID()); bpStorageMap.put(bpid, bpStorage); } return bpStorage; }
private void doUpgrade(final StorageDirectory sd, final NamespaceInfo nsInfo, final File prevDir, final File tmpDir, final File bbwDir, final File toDir, final int oldLV, Configuration conf) throws IOException { // 3.2. Link block files from <SD>/previous.tmp to <SD>/current linkAllBlocks(tmpDir, bbwDir, toDir, oldLV, conf); // 4. Write version file under <SD>/current clusterID = nsInfo.getClusterID(); upgradeProperties(sd); // 5. Rename <SD>/previous.tmp to <SD>/previous rename(tmpDir, prevDir); LOG.info("Upgrade of " + sd.getRoot()+ " is complete"); }
/** * Return the cluster ID inherent in the currently running * Namenode. */ public static String getCurrentClusterID(MiniDFSCluster cluster) throws IOException { if (cluster != null) { return cluster.getNameNodeRpc().versionRequest().getClusterID(); } return namenodeStorageClusterID; }
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); createStorageID(sd, false); writeProperties(sd); }
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); createStorageID(sd, false); writeProperties(sd); }
private void doUpgrade(final StorageDirectory sd, final NamespaceInfo nsInfo, final File prevDir, final File tmpDir, final File bbwDir, final File toDir, final int oldLV, Configuration conf) throws IOException { // 3.2. Link block files from <SD>/previous.tmp to <SD>/current linkAllBlocks(tmpDir, bbwDir, toDir, oldLV, conf); // 4. Write version file under <SD>/current clusterID = nsInfo.getClusterID(); upgradeProperties(sd); // 5. Rename <SD>/previous.tmp to <SD>/previous rename(tmpDir, prevDir); LOG.info("Upgrade of " + sd.getRoot()+ " is complete"); }
storage.setStorageInfo(nsInfo); storage.setBlockPoolID(nsInfo.getBlockPoolID()); storage.setClusterID(nsInfo.getClusterID()); } else { nsInfo.validateStorage(storage);
checkNSEquality(bpNSInfo.getNamespaceID(), nsInfo.getNamespaceID(), "Namespace ID"); checkNSEquality(bpNSInfo.getClusterID(), nsInfo.getClusterID(), "Cluster ID");
/** * Test that a dummy implementation of JournalManager can * be initialized on startup */ @Test public void testDummyJournalManager() throws Exception { MiniDFSCluster cluster = null; Configuration conf = new Configuration(); conf.set(DFSConfigKeys.DFS_NAMENODE_EDITS_PLUGIN_PREFIX + ".dummy", DummyJournalManager.class.getName()); conf.set(DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY, DUMMY_URI); conf.setInt(DFSConfigKeys.DFS_NAMENODE_CHECKED_VOLUMES_MINIMUM_KEY, 0); try { cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build(); cluster.waitActive(); assertTrue(DummyJournalManager.shouldPromptCalled); assertTrue(DummyJournalManager.formatCalled); assertNotNull(DummyJournalManager.conf); assertEquals(new URI(DUMMY_URI), DummyJournalManager.uri); assertNotNull(DummyJournalManager.nsInfo); assertEquals(DummyJournalManager.nsInfo.getClusterID(), cluster.getNameNode().getNamesystem().getClusterId()); } finally { if (cluster != null) { cluster.shutdown(); } } }