public static CheckpointSignature convert(CheckpointSignatureProto s) { StorageInfo si = PBHelper.convert(s.getStorageInfo(), NodeType.NAME_NODE); return new CheckpointSignature(si, s.getBlockPoolId(), s.getMostRecentCheckpointTxId(), s.getCurSegmentTxId()); }
boolean isSameCluster = (dstStorage.versionSupportsFederation(NameNodeLayoutVersion.FEATURES) && sig.isSameCluster(checkpointImage)) || (!dstStorage.versionSupportsFederation(NameNodeLayoutVersion.FEATURES) && sig.namespaceIdMatches(checkpointImage)); if (isFreshCheckpointer || (isSameCluster && !sig.storageVersionMatches(checkpointImage.getStorage()))) { dstStorage.setClusterID(sig.getClusterID()); dstStorage.setBlockPoolID(sig.getBlockpoolID()); loadImage = true; sig.validateStorageInfo(checkpointImage);
@Override public boolean equals(Object o) { if (!(o instanceof CheckpointSignature)) { return false; } return compareTo((CheckpointSignature)o) == 0; }
public static CheckpointSignatureProto convert(CheckpointSignature s) { return CheckpointSignatureProto.newBuilder() .setBlockPoolId(s.getBlockpoolID()) .setCurSegmentTxId(s.getCurSegmentTxId()) .setMostRecentCheckpointTxId(s.getMostRecentCheckpointTxId()) .setStorageInfo(PBHelper.convert((StorageInfo) s)).build(); }
@Test public void testConvertCheckpointSignature() { CheckpointSignature s = new CheckpointSignature( getStorageInfo(NodeType.NAME_NODE), "bpid", 100, 1); CheckpointSignatureProto sProto = PBHelper.convert(s); CheckpointSignature s1 = PBHelper.convert(sProto); assertEquals(s.getBlockpoolID(), s1.getBlockpoolID()); assertEquals(s.getClusterID(), s1.getClusterID()); assertEquals(s.getCTime(), s1.getCTime()); assertEquals(s.getCurSegmentTxId(), s1.getCurSegmentTxId()); assertEquals(s.getLayoutVersion(), s1.getLayoutVersion()); assertEquals(s.getMostRecentCheckpointTxId(), s1.getMostRecentCheckpointTxId()); assertEquals(s.getNamespaceID(), s1.getNamespaceID()); }
/** * End checkpoint. * <p> * Validate the current storage info with the given signature. * * @param sig to validate the current storage info against * @throws IOException if the checkpoint fields are inconsistent */ void endCheckpoint(CheckpointSignature sig) throws IOException { LOG.info("End checkpoint at txid " + getEditLog().getLastWrittenTxId()); sig.validateStorageInfo(this); }
public void write(DataOutput out) throws IOException { out.writeInt(getLayoutVersion()); out.writeInt(getNamespaceID()); out.writeLong(getCTime()); out.writeLong(editsTime); out.writeLong(checkpointTime); }
@Override // ClientProtocol public long rollEdits() throws AccessControlException, IOException { checkNNStartup(); CheckpointSignature sig = namesystem.rollEditLog(); return sig.getCurSegmentTxId(); }
@Test public void testCheckpointSignature() throws IOException { MiniDFSCluster cluster = null; Configuration conf = new HdfsConfiguration(); SecondaryNameNode secondary = null; try { cluster = new MiniDFSCluster.Builder(conf).numDataNodes(numDatanodes) .format(true).build(); NameNode nn = cluster.getNameNode(); NamenodeProtocols nnRpc = nn.getRpcServer(); secondary = startSecondaryNameNode(conf); // prepare checkpoint image secondary.doCheckpoint(); CheckpointSignature sig = nnRpc.rollEditLog(); // manipulate the CheckpointSignature fields sig.setBlockpoolID("somerandomebpid"); sig.clusterID = "somerandomcid"; try { sig.validateStorageInfo(nn.getFSImage()); // this should fail assertTrue("This test is expected to fail.", false); } catch (Exception ignored) { } } finally { cleanup(secondary); secondary = null; cleanup(cluster); cluster = null; } }
public static CheckpointSignatureProto convert(CheckpointSignature s) { return CheckpointSignatureProto.newBuilder() .setBlockPoolId(s.getBlockpoolID()) .setCurSegmentTxId(s.getCurSegmentTxId()) .setMostRecentCheckpointTxId(s.getMostRecentCheckpointTxId()) .setStorageInfo(PBHelper.convert((StorageInfo) s)).build(); }
sig.validateStorageInfo(bnImage);
public void write(DataOutput out) throws IOException { out.writeInt(getLayoutVersion()); out.writeInt(getNamespaceID()); out.writeLong(getCTime()); out.writeLong(editsTime); out.writeLong(checkpointTime); imageDigest.write(out); out.writeInt(checkpointState.serialize()); }
@Override // ClientProtocol public long rollEdits() throws AccessControlException, IOException { checkNNStartup(); CheckpointSignature sig = namesystem.rollEditLog(); return sig.getCurSegmentTxId(); }
boolean isSameCluster = (dstStorage.versionSupportsFederation(NameNodeLayoutVersion.FEATURES) && sig.isSameCluster(checkpointImage)) || (!dstStorage.versionSupportsFederation(NameNodeLayoutVersion.FEATURES) && sig.namespaceIdMatches(checkpointImage)); if (isFreshCheckpointer || (isSameCluster && !sig.storageVersionMatches(checkpointImage.getStorage()))) { dstStorage.setClusterID(sig.getClusterID()); dstStorage.setBlockPoolID(sig.getBlockpoolID()); loadImage = true; sig.validateStorageInfo(checkpointImage);
CheckpointSignature rollEditLog(int layoutVersion) throws IOException { getEditLog().rollEditLog(layoutVersion); // Record this log segment ID in all of the storage directories, so // we won't miss this log segment on a restart if the edits directories // go missing. storage.writeTransactionIdFileToStorage(getEditLog().getCurSegmentTxId()); //Update NameDirSize Metric getStorage().updateNameDirSize(); return new CheckpointSignature(this); }
public static CheckpointSignatureProto convert(CheckpointSignature s) { return CheckpointSignatureProto.newBuilder() .setBlockPoolId(s.getBlockpoolID()) .setCurSegmentTxId(s.getCurSegmentTxId()) .setMostRecentCheckpointTxId(s.getMostRecentCheckpointTxId()) .setStorageInfo(PBHelper.convert((StorageInfo) s)).build(); }
/** * End checkpoint. * <p> * Validate the current storage info with the given signature. * * @param sig to validate the current storage info against * @throws IOException if the checkpoint fields are inconsistent */ void endCheckpoint(CheckpointSignature sig) throws IOException { LOG.info("End checkpoint at txid " + getEditLog().getLastWrittenTxId()); sig.validateStorageInfo(this); }
public int compareTo(CheckpointSignature o) { return (layoutVersion < o.layoutVersion) ? -1 : (layoutVersion > o.layoutVersion) ? 1 : (namespaceID < o.namespaceID) ? -1 : (namespaceID > o.namespaceID) ? 1 : (cTime < o.cTime) ? -1 : (cTime > o.cTime) ? 1 : (editsTime < o.editsTime) ? -1 : (editsTime > o.editsTime) ? 1 : (checkpointTime < o.checkpointTime) ? -1 : (checkpointTime > o.checkpointTime) ? 1 : imageDigest.compareTo(o.imageDigest); }
@Override // ClientProtocol public long rollEdits() throws AccessControlException, IOException { checkNNStartup(); CheckpointSignature sig = namesystem.rollEditLog(); return sig.getCurSegmentTxId(); }
boolean isSameCluster = (dstStorage.versionSupportsFederation(NameNodeLayoutVersion.FEATURES) && sig.isSameCluster(checkpointImage)) || (!dstStorage.versionSupportsFederation(NameNodeLayoutVersion.FEATURES) && sig.namespaceIdMatches(checkpointImage)); if (isFreshCheckpointer || (isSameCluster && !sig.storageVersionMatches(checkpointImage.getStorage()))) { dstStorage.setClusterID(sig.getClusterID()); dstStorage.setBlockPoolID(sig.getBlockpoolID()); loadImage = true; sig.validateStorageInfo(checkpointImage);