Search in sources :

Example 1 with EpochProto

use of org.apache.hadoop.yarn.proto.YarnServerResourceManagerRecoveryProtos.EpochProto in project hadoop by apache.

the class TestProtos method testProtoCanBePrinted.

@Test
public void testProtoCanBePrinted() throws Exception {
    EpochProto proto = EpochProto.newBuilder().setEpoch(100).build();
    String protoString = proto.toString();
    Assert.assertNotNull(protoString);
}
Also used : EpochProto(org.apache.hadoop.yarn.proto.YarnServerResourceManagerRecoveryProtos.EpochProto) Test(org.junit.Test)

Example 2 with EpochProto

use of org.apache.hadoop.yarn.proto.YarnServerResourceManagerRecoveryProtos.EpochProto in project hadoop by apache.

the class LeveldbRMStateStore method getAndIncrementEpoch.

@Override
public synchronized long getAndIncrementEpoch() throws Exception {
    long currentEpoch = 0;
    byte[] dbKeyBytes = bytes(EPOCH_NODE);
    try {
        byte[] data = db.get(dbKeyBytes);
        if (data != null) {
            currentEpoch = EpochProto.parseFrom(data).getEpoch();
        }
        EpochProto proto = Epoch.newInstance(currentEpoch + 1).getProto();
        db.put(dbKeyBytes, proto.toByteArray());
    } catch (DBException e) {
        throw new IOException(e);
    }
    return currentEpoch;
}
Also used : DBException(org.iq80.leveldb.DBException) EpochProto(org.apache.hadoop.yarn.proto.YarnServerResourceManagerRecoveryProtos.EpochProto) IOException(java.io.IOException)

Aggregations

EpochProto (org.apache.hadoop.yarn.proto.YarnServerResourceManagerRecoveryProtos.EpochProto)2 IOException (java.io.IOException)1 DBException (org.iq80.leveldb.DBException)1 Test (org.junit.Test)1