Optional<HoodieInstant> instant = activeTimeline.filterInflightsExcludingCompaction().lastInstant(); activeTimeline.saveToInflight(instant.get(), Optional.of(metadata.toJsonString().getBytes(StandardCharsets.UTF_8)));
Optional<HoodieInstant> instant = activeTimeline.filterInflightsExcludingCompaction().lastInstant(); activeTimeline.saveToInflight(instant.get(), Optional.of(metadata.toJsonString().getBytes(StandardCharsets.UTF_8)));
config.getBasePath(), true); metaClient.getActiveTimeline().filterInflightsExcludingCompaction().firstInstant().ifPresent(earliestInflight -> { Preconditions.checkArgument( HoodieTimeline.compareTimestamps(earliestInflight.getTimestamp(), instantTime, HoodieTimeline.GREATER),
config.getBasePath(), true); metaClient.getActiveTimeline().filterInflightsExcludingCompaction().firstInstant().ifPresent(earliestInflight -> { Preconditions.checkArgument( HoodieTimeline.compareTimestamps(earliestInflight.getTimestamp(), instantTime, HoodieTimeline.GREATER),
pendingCompactionInstant.getTimestamp().equals(compactionInstantTime)); HoodieInstant inflightInstant = metaClient.getActiveTimeline().filterInflightsExcludingCompaction().firstInstant().get(); assertTrue("inflight instant has expected instant time", inflightInstant.getTimestamp().equals(inflightInstantTime)); metaClient.getActiveTimeline().filterInflightsExcludingCompaction().firstInstant().get(); assertTrue("inflight instant has expected instant time", inflightInstant.getTimestamp().equals(nextInflightInstantTime)); assertTrue("Expect only one inflight instant", metaClient.getActiveTimeline().filterInflightsExcludingCompaction().getInstants().count() == 1);
@Test public void testScheduleCompactionAfterPendingIngestion() throws Exception { // Case: Failure case. Earliest ingestion inflight instant time must be later than compaction time HoodieWriteConfig cfg = getConfig(false); HoodieWriteClient client = new HoodieWriteClient(jsc, cfg, true); String firstInstantTime = "001"; String secondInstantTime = "004"; String inflightInstantTime = "005"; String compactionInstantTime = "006"; int numRecs = 2000; List<HoodieRecord> records = dataGen.generateInserts(firstInstantTime, numRecs); records = runNextDeltaCommits(client, Arrays.asList(firstInstantTime, secondInstantTime), records, cfg, true, new ArrayList<>()); HoodieTableMetaClient metaClient = new HoodieTableMetaClient(jsc.hadoopConfiguration(), cfg.getBasePath()); createNextDeltaCommit(inflightInstantTime, records, client, metaClient, cfg, true); metaClient = new HoodieTableMetaClient(jsc.hadoopConfiguration(), cfg.getBasePath()); HoodieInstant inflightInstant = metaClient.getActiveTimeline().filterInflightsExcludingCompaction().firstInstant().get(); assertTrue("inflight instant has expected instant time", inflightInstant.getTimestamp().equals(inflightInstantTime)); boolean gotException = false; try { // Schedule compaction but do not run them scheduleCompaction(compactionInstantTime, client, cfg); } catch (IllegalArgumentException iex) { // Earliest ingestion inflight instant time must be later than compaction time. Should fail here gotException = true; } assertTrue("Earliest ingestion inflight instant time must be later than compaction time", gotException); }