Search in sources :

Example 6 with HoodieInstantInfo

use of org.apache.hudi.avro.model.HoodieInstantInfo in project hudi by apache.

the class TestMetadataConversionUtils method createRollbackMetadata.

private void createRollbackMetadata(String instantTime) throws Exception {
    HoodieRollbackMetadata rollbackMetadata = new HoodieRollbackMetadata();
    rollbackMetadata.setCommitsRollback(Arrays.asList(instantTime));
    rollbackMetadata.setStartRollbackTime(instantTime);
    HoodieRollbackPartitionMetadata rollbackPartitionMetadata = new HoodieRollbackPartitionMetadata();
    rollbackPartitionMetadata.setPartitionPath("p1");
    rollbackPartitionMetadata.setSuccessDeleteFiles(Arrays.asList("f1"));
    rollbackPartitionMetadata.setFailedDeleteFiles(new ArrayList<>());
    rollbackPartitionMetadata.setRollbackLogFiles(new HashMap<>());
    Map<String, HoodieRollbackPartitionMetadata> partitionMetadataMap = new HashMap<>();
    partitionMetadataMap.put("p1", rollbackPartitionMetadata);
    rollbackMetadata.setPartitionMetadata(partitionMetadataMap);
    rollbackMetadata.setInstantsRollback(Arrays.asList(new HoodieInstantInfo("1", HoodieTimeline.COMMIT_ACTION)));
    HoodieTestTable.of(metaClient).addRollback(instantTime, rollbackMetadata);
}
Also used : HoodieRollbackMetadata(org.apache.hudi.avro.model.HoodieRollbackMetadata) HashMap(java.util.HashMap) HoodieInstantInfo(org.apache.hudi.avro.model.HoodieInstantInfo) HoodieRollbackPartitionMetadata(org.apache.hudi.avro.model.HoodieRollbackPartitionMetadata)

Example 7 with HoodieInstantInfo

use of org.apache.hudi.avro.model.HoodieInstantInfo in project hudi by apache.

the class TimelineMetadataUtils method convertRollbackMetadata.

public static HoodieRollbackMetadata convertRollbackMetadata(String startRollbackTime, Option<Long> durationInMs, List<HoodieInstant> instants, List<HoodieRollbackStat> rollbackStats) {
    Map<String, HoodieRollbackPartitionMetadata> partitionMetadataBuilder = new HashMap<>();
    int totalDeleted = 0;
    for (HoodieRollbackStat stat : rollbackStats) {
        Map<String, Long> rollbackLogFiles = stat.getCommandBlocksCount().keySet().stream().collect(Collectors.toMap(f -> f.getPath().toString(), FileStatus::getLen));
        HoodieRollbackPartitionMetadata metadata = new HoodieRollbackPartitionMetadata(stat.getPartitionPath(), stat.getSuccessDeleteFiles(), stat.getFailedDeleteFiles(), rollbackLogFiles);
        partitionMetadataBuilder.put(stat.getPartitionPath(), metadata);
        totalDeleted += stat.getSuccessDeleteFiles().size();
    }
    return new HoodieRollbackMetadata(startRollbackTime, durationInMs.orElseGet(() -> -1L), totalDeleted, instants.stream().map(HoodieInstant::getTimestamp).collect(Collectors.toList()), Collections.unmodifiableMap(partitionMetadataBuilder), DEFAULT_VERSION, instants.stream().map(instant -> new HoodieInstantInfo(instant.getTimestamp(), instant.getAction())).collect(Collectors.toList()));
}
Also used : HoodieAvroUtils(org.apache.hudi.avro.HoodieAvroUtils) ByteArrayOutputStream(java.io.ByteArrayOutputStream) HoodieRestorePlan(org.apache.hudi.avro.model.HoodieRestorePlan) FileReader(org.apache.avro.file.FileReader) Option(org.apache.hudi.common.util.Option) HashMap(java.util.HashMap) FileStatus(org.apache.hadoop.fs.FileStatus) HoodieSavepointMetadata(org.apache.hudi.avro.model.HoodieSavepointMetadata) SpecificDatumWriter(org.apache.avro.specific.SpecificDatumWriter) HoodieRequestedReplaceMetadata(org.apache.hudi.avro.model.HoodieRequestedReplaceMetadata) Map(java.util.Map) HoodieRollbackMetadata(org.apache.hudi.avro.model.HoodieRollbackMetadata) HoodieRollbackPartitionMetadata(org.apache.hudi.avro.model.HoodieRollbackPartitionMetadata) SpecificData(org.apache.avro.specific.SpecificData) ValidationUtils(org.apache.hudi.common.util.ValidationUtils) Schema(org.apache.avro.Schema) DatumWriter(org.apache.avro.io.DatumWriter) HoodieCleanerPlan(org.apache.hudi.avro.model.HoodieCleanerPlan) SpecificRecordBase(org.apache.avro.specific.SpecificRecordBase) DataFileWriter(org.apache.avro.file.DataFileWriter) IOException(java.io.IOException) HoodieRollbackPlan(org.apache.hudi.avro.model.HoodieRollbackPlan) Collectors(java.util.stream.Collectors) HoodieInstantInfo(org.apache.hudi.avro.model.HoodieInstantInfo) SpecificDatumReader(org.apache.avro.specific.SpecificDatumReader) DatumReader(org.apache.avro.io.DatumReader) List(java.util.List) HoodieCleanMetadata(org.apache.hudi.avro.model.HoodieCleanMetadata) SeekableByteArrayInput(org.apache.avro.file.SeekableByteArrayInput) HoodieCompactionPlan(org.apache.hudi.avro.model.HoodieCompactionPlan) HoodieReplaceCommitMetadata(org.apache.hudi.avro.model.HoodieReplaceCommitMetadata) HoodieRestoreMetadata(org.apache.hudi.avro.model.HoodieRestoreMetadata) HoodieSavepointPartitionMetadata(org.apache.hudi.avro.model.HoodieSavepointPartitionMetadata) HoodieRollbackStat(org.apache.hudi.common.HoodieRollbackStat) Collections(java.util.Collections) DataFileReader(org.apache.avro.file.DataFileReader) HoodieRollbackStat(org.apache.hudi.common.HoodieRollbackStat) HoodieRollbackMetadata(org.apache.hudi.avro.model.HoodieRollbackMetadata) HashMap(java.util.HashMap) HoodieInstantInfo(org.apache.hudi.avro.model.HoodieInstantInfo) HoodieRollbackPartitionMetadata(org.apache.hudi.avro.model.HoodieRollbackPartitionMetadata)

Aggregations

HoodieInstantInfo (org.apache.hudi.avro.model.HoodieInstantInfo)7 HashMap (java.util.HashMap)5 IOException (java.io.IOException)4 List (java.util.List)4 HoodieRollbackMetadata (org.apache.hudi.avro.model.HoodieRollbackMetadata)4 HoodieInstant (org.apache.hudi.common.table.timeline.HoodieInstant)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 HoodieRestorePlan (org.apache.hudi.avro.model.HoodieRestorePlan)3 HoodieRollbackPartitionMetadata (org.apache.hudi.avro.model.HoodieRollbackPartitionMetadata)3 HoodieRollbackPlan (org.apache.hudi.avro.model.HoodieRollbackPlan)3 Option (org.apache.hudi.common.util.Option)3 Collections (java.util.Collections)2 HoodieRestoreMetadata (org.apache.hudi.avro.model.HoodieRestoreMetadata)2 HoodieWriteConfig (org.apache.hudi.config.HoodieWriteConfig)2 HoodieIOException (org.apache.hudi.exception.HoodieIOException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Stream (java.util.stream.Stream)1 Schema (org.apache.avro.Schema)1