Search in sources :

Example 1 with SnapshotDiffReportEntryProto

use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.SnapshotDiffReportEntryProto in project hadoop by apache.

the class PBHelperClient method convert.

public static SnapshotDiffReportEntryProto convert(DiffReportEntry entry) {
    if (entry == null) {
        return null;
    }
    ByteString sourcePath = getByteString(entry.getSourcePath() == null ? DFSUtilClient.EMPTY_BYTES : entry.getSourcePath());
    String modification = entry.getType().getLabel();
    SnapshotDiffReportEntryProto.Builder builder = SnapshotDiffReportEntryProto.newBuilder().setFullpath(sourcePath).setModificationLabel(modification);
    if (entry.getType() == DiffType.RENAME) {
        ByteString targetPath = getByteString(entry.getTargetPath() == null ? DFSUtilClient.EMPTY_BYTES : entry.getTargetPath());
        builder.setTargetPath(targetPath);
    }
    return builder.build();
}
Also used : ByteString(com.google.protobuf.ByteString) ByteString(com.google.protobuf.ByteString) SnapshotDiffReportEntryProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.SnapshotDiffReportEntryProto)

Example 2 with SnapshotDiffReportEntryProto

use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.SnapshotDiffReportEntryProto in project hadoop by apache.

the class PBHelperClient method convert.

public static SnapshotDiffReportProto convert(SnapshotDiffReport report) {
    if (report == null) {
        return null;
    }
    List<DiffReportEntry> entries = report.getDiffList();
    List<SnapshotDiffReportEntryProto> entryProtos = new ArrayList<>();
    for (DiffReportEntry entry : entries) {
        SnapshotDiffReportEntryProto entryProto = convert(entry);
        if (entryProto != null)
            entryProtos.add(entryProto);
    }
    return SnapshotDiffReportProto.newBuilder().setSnapshotRoot(report.getSnapshotRoot()).setFromSnapshot(report.getFromSnapshot()).setToSnapshot(report.getLaterSnapshotName()).addAllDiffReportEntries(entryProtos).build();
}
Also used : ArrayList(java.util.ArrayList) DiffReportEntry(org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry) SnapshotDiffReportEntryProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.SnapshotDiffReportEntryProto)

Example 3 with SnapshotDiffReportEntryProto

use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.SnapshotDiffReportEntryProto in project hadoop by apache.

the class PBHelperClient method convert.

public static SnapshotDiffReport convert(SnapshotDiffReportProto reportProto) {
    if (reportProto == null) {
        return null;
    }
    String snapshotDir = reportProto.getSnapshotRoot();
    String fromSnapshot = reportProto.getFromSnapshot();
    String toSnapshot = reportProto.getToSnapshot();
    List<SnapshotDiffReportEntryProto> list = reportProto.getDiffReportEntriesList();
    List<DiffReportEntry> entries = new ArrayList<>();
    for (SnapshotDiffReportEntryProto entryProto : list) {
        DiffReportEntry entry = convert(entryProto);
        if (entry != null)
            entries.add(entry);
    }
    return new SnapshotDiffReport(snapshotDir, fromSnapshot, toSnapshot, entries);
}
Also used : SnapshotDiffReport(org.apache.hadoop.hdfs.protocol.SnapshotDiffReport) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) DiffReportEntry(org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry) SnapshotDiffReportEntryProto(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.SnapshotDiffReportEntryProto)

Aggregations

SnapshotDiffReportEntryProto (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.SnapshotDiffReportEntryProto)3 ByteString (com.google.protobuf.ByteString)2 ArrayList (java.util.ArrayList)2 DiffReportEntry (org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry)2 SnapshotDiffReport (org.apache.hadoop.hdfs.protocol.SnapshotDiffReport)1