Example usage for org.apache.hadoop.hdfs.protocol LayoutFlags read

List of usage examples for org.apache.hadoop.hdfs.protocol LayoutFlags read

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.protocol LayoutFlags read.

Prototype

public static LayoutFlags read(DataInputStream in) throws IOException 

Source Link

Document

Load a LayoutFlags object from a stream.

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 w  w.j av  a 2s  .  c o  m
        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;
    }
}