Example usage for org.apache.hadoop.hdfs.server.namenode NameNodeLayoutVersion supports

List of usage examples for org.apache.hadoop.hdfs.server.namenode NameNodeLayoutVersion supports

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.server.namenode NameNodeLayoutVersion supports.

Prototype

public static boolean supports(final LayoutFeature f, final int lv) 

Source Link

Usage

From source file:com.github.brandtg.switchboard.HdfsLogParser.java

License:Apache License

@Override
protected FSEditLogOp nextOp() throws IOException {
    switch (state) {
    case UNINIT:/*from  w  ww .j av  a 2s.com*/
        try {
            tracker = new FSEditLogLoader.PositionTrackingInputStream(inputStream);
            dataInputStream = new DataInputStream(tracker);
            logVersion = dataInputStream.readInt();
            if (NameNodeLayoutVersion.supports(LayoutVersion.Feature.ADD_LAYOUT_FLAGS, logVersion)
                    || logVersion < NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION) {
                LayoutFlags.read(dataInputStream);
            }
            reader = new FSEditLogOp.Reader(dataInputStream, tracker, logVersion);
            reader.setMaxOpSize(maxOpSize);
            state = State.OPEN;
        } finally {
            if (reader == null) {
                dataInputStream.close();
                tracker.close();
                state = State.CLOSED;
            }
        }
        return nextOp();
    case OPEN:
        FSEditLogOp op = reader.readOp(false);
        if (op.opCode == FSEditLogOpCodes.OP_END_LOG_SEGMENT) {
            state = State.UNINIT;
        }
        return op;
    case CLOSED:
    default:
        return null;
    }
}