Search in sources :

Example 71 with HoodieException

use of org.apache.hudi.exception.HoodieException in project hudi by apache.

the class StreamerUtil method medianInstantTime.

/**
 * Returns the median instant time between the given two instant time.
 */
public static Option<String> medianInstantTime(String highVal, String lowVal) {
    try {
        long high = HoodieActiveTimeline.parseDateFromInstantTime(highVal).getTime();
        long low = HoodieActiveTimeline.parseDateFromInstantTime(lowVal).getTime();
        ValidationUtils.checkArgument(high > low, "Instant [" + highVal + "] should have newer timestamp than instant [" + lowVal + "]");
        long median = low + (high - low) / 2;
        final String instantTime = HoodieActiveTimeline.formatDate(new Date(median));
        if (HoodieTimeline.compareTimestamps(lowVal, HoodieTimeline.GREATER_THAN_OR_EQUALS, instantTime) || HoodieTimeline.compareTimestamps(highVal, HoodieTimeline.LESSER_THAN_OR_EQUALS, instantTime)) {
            return Option.empty();
        }
        return Option.of(instantTime);
    } catch (ParseException e) {
        throw new HoodieException("Get median instant time with interval [" + lowVal + ", " + highVal + "] error", e);
    }
}
Also used : HoodieException(org.apache.hudi.exception.HoodieException) ParseException(java.text.ParseException) Date(java.util.Date)

Example 72 with HoodieException

use of org.apache.hudi.exception.HoodieException in project hudi by apache.

the class StreamerUtil method instantTimeDiffSeconds.

/**
 * Returns the time interval in seconds between the given instant time.
 */
public static long instantTimeDiffSeconds(String newInstantTime, String oldInstantTime) {
    try {
        long newTimestamp = HoodieActiveTimeline.parseDateFromInstantTime(newInstantTime).getTime();
        long oldTimestamp = HoodieActiveTimeline.parseDateFromInstantTime(oldInstantTime).getTime();
        return (newTimestamp - oldTimestamp) / 1000;
    } catch (ParseException e) {
        throw new HoodieException("Get instant time diff with interval [" + oldInstantTime + ", " + newInstantTime + "] error", e);
    }
}
Also used : HoodieException(org.apache.hudi.exception.HoodieException) ParseException(java.text.ParseException)

Example 73 with HoodieException

use of org.apache.hudi.exception.HoodieException in project hudi by apache.

the class StreamWriteFunctionWrapper method checkpointComplete.

public void checkpointComplete(long checkpointId) {
    stateInitializationContext.getOperatorStateStore().checkpointSuccess(checkpointId);
    coordinator.notifyCheckpointComplete(checkpointId);
    this.bucketAssignerFunction.notifyCheckpointComplete(checkpointId);
    if (asyncCompaction) {
        try {
            compactFunctionWrapper.compact(checkpointId);
        } catch (Exception e) {
            throw new HoodieException(e);
        }
    }
}
Also used : HoodieException(org.apache.hudi.exception.HoodieException) HoodieException(org.apache.hudi.exception.HoodieException)

Example 74 with HoodieException

use of org.apache.hudi.exception.HoodieException in project hudi by apache.

the class RecordReaderValueIterator method hasNext.

@Override
public boolean hasNext() {
    if (nextVal == null) {
        K key = reader.createKey();
        V val = reader.createValue();
        try {
            boolean notDone = reader.next(key, val);
            if (!notDone) {
                return false;
            }
            this.nextVal = val;
        } catch (IOException e) {
            LOG.error("Got error reading next record from record reader");
            throw new HoodieException(e);
        }
    }
    return true;
}
Also used : HoodieException(org.apache.hudi.exception.HoodieException) IOException(java.io.IOException)

Example 75 with HoodieException

use of org.apache.hudi.exception.HoodieException in project hudi by apache.

the class TestJdbcbasedSchemaProvider method testJdbcbasedSchemaProvider.

@Test
public void testJdbcbasedSchemaProvider() throws Exception {
    try {
        initH2Database();
        Schema sourceSchema = UtilHelpers.createSchemaProvider(JdbcbasedSchemaProvider.class.getName(), PROPS, jsc()).getSourceSchema();
        assertEquals(sourceSchema.toString().toUpperCase(), new Schema.Parser().parse(UtilitiesTestBase.Helpers.readFile("delta-streamer-config/source-jdbc.avsc")).toString().toUpperCase());
    } catch (HoodieException e) {
        LOG.error("Failed to get connection through jdbc. ", e);
    }
}
Also used : Schema(org.apache.avro.Schema) HoodieException(org.apache.hudi.exception.HoodieException) Test(org.junit.jupiter.api.Test)

Aggregations

HoodieException (org.apache.hudi.exception.HoodieException)171 IOException (java.io.IOException)87 Path (org.apache.hadoop.fs.Path)45 Schema (org.apache.avro.Schema)35 HoodieIOException (org.apache.hudi.exception.HoodieIOException)35 List (java.util.List)30 ArrayList (java.util.ArrayList)27 HoodieTableMetaClient (org.apache.hudi.common.table.HoodieTableMetaClient)23 Collectors (java.util.stream.Collectors)21 HoodieInstant (org.apache.hudi.common.table.timeline.HoodieInstant)19 Option (org.apache.hudi.common.util.Option)19 HoodieTimeline (org.apache.hudi.common.table.timeline.HoodieTimeline)18 Map (java.util.Map)16 HoodieRecord (org.apache.hudi.common.model.HoodieRecord)16 GenericRecord (org.apache.avro.generic.GenericRecord)15 Arrays (java.util.Arrays)14 HoodieLogFile (org.apache.hudi.common.model.HoodieLogFile)14 Logger (org.apache.log4j.Logger)14 FileStatus (org.apache.hadoop.fs.FileStatus)13 HoodieCommitMetadata (org.apache.hudi.common.model.HoodieCommitMetadata)13