HDFS-10877. Make RemoteEditLogManifest.committedTxnId optional in Protocol Buffers. Contributed by Sean Mackrory.
This commit is contained in:
parent
8d619b4896
commit
40acacee08
|
@ -22,6 +22,7 @@ import java.util.List;
|
|||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
||||
|
||||
/**
|
||||
* An enumeration of logs available on a remote NameNode.
|
||||
|
@ -30,11 +31,15 @@ public class RemoteEditLogManifest {
|
|||
|
||||
private List<RemoteEditLog> logs;
|
||||
|
||||
private long committedTxnId = -1;
|
||||
private long committedTxnId = HdfsServerConstants.INVALID_TXID;
|
||||
|
||||
public RemoteEditLogManifest() {
|
||||
}
|
||||
|
||||
public RemoteEditLogManifest(List<RemoteEditLog> logs) {
|
||||
this(logs, HdfsServerConstants.INVALID_TXID);
|
||||
}
|
||||
|
||||
public RemoteEditLogManifest(List<RemoteEditLog> logs, long committedTxnId) {
|
||||
this.logs = logs;
|
||||
this.committedTxnId = committedTxnId;
|
||||
|
|
|
@ -88,7 +88,7 @@ message RemoteEditLogProto {
|
|||
*/
|
||||
message RemoteEditLogManifestProto {
|
||||
repeated RemoteEditLogProto logs = 1;
|
||||
required uint64 committedTxnId = 2;
|
||||
optional uint64 committedTxnId = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,6 +69,7 @@ import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier;
|
|||
import org.apache.hadoop.hdfs.security.token.block.ExportedBlockKeys;
|
||||
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManagerTestUtil;
|
||||
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeStorageInfo;
|
||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.NamenodeRole;
|
||||
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.NodeType;
|
||||
import org.apache.hadoop.hdfs.server.common.StorageInfo;
|
||||
|
@ -323,26 +324,37 @@ public class TestPBHelper {
|
|||
RemoteEditLog l1 = PBHelper.convert(lProto);
|
||||
compare(l, l1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertRemoteEditLogManifest() {
|
||||
List<RemoteEditLog> logs = new ArrayList<RemoteEditLog>();
|
||||
logs.add(new RemoteEditLog(1, 10));
|
||||
logs.add(new RemoteEditLog(11, 20));
|
||||
RemoteEditLogManifest m = new RemoteEditLogManifest(logs, 20);
|
||||
|
||||
private void convertAndCheckRemoteEditLogManifest(RemoteEditLogManifest m,
|
||||
List<RemoteEditLog> logs,
|
||||
long committedTxnId) {
|
||||
RemoteEditLogManifestProto mProto = PBHelper.convert(m);
|
||||
RemoteEditLogManifest m1 = PBHelper.convert(mProto);
|
||||
|
||||
|
||||
List<RemoteEditLog> logs1 = m1.getLogs();
|
||||
assertEquals(logs.size(), logs1.size());
|
||||
for (int i = 0; i < logs.size(); i++) {
|
||||
compare(logs.get(i), logs1.get(i));
|
||||
}
|
||||
assertEquals(committedTxnId, m.getCommittedTxnId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertRemoteEditLogManifest() {
|
||||
List<RemoteEditLog> logs = new ArrayList<RemoteEditLog>();
|
||||
logs.add(new RemoteEditLog(1, 10));
|
||||
logs.add(new RemoteEditLog(11, 20));
|
||||
|
||||
convertAndCheckRemoteEditLogManifest(new RemoteEditLogManifest(logs, 20),
|
||||
logs, 20);
|
||||
convertAndCheckRemoteEditLogManifest(new RemoteEditLogManifest(logs),
|
||||
logs, HdfsServerConstants.INVALID_TXID);
|
||||
}
|
||||
|
||||
public ExtendedBlock getExtendedBlock() {
|
||||
return getExtendedBlock(1);
|
||||
}
|
||||
|
||||
|
||||
public ExtendedBlock getExtendedBlock(long blkid) {
|
||||
return new ExtendedBlock("bpid", blkid, 100, 2);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue