yanghua commented on a change in pull request #2434: URL: https://github.com/apache/hudi/pull/2434#discussion_r557472212
########## File path: hudi-flink/src/main/java/org/apache/hudi/operator/InstantGenerateOperator.java ########## @@ -222,4 +237,60 @@ public void close() throws Exception { fs.close(); } } + + private boolean checkReceivedData(long checkpointId) throws InterruptedException, IOException { + int numberOfParallelSubtasks = getRuntimeContext().getNumberOfParallelSubtasks(); + FileStatus[] fileStatuses; + Path instantMarkerPath = new Path(HoodieTableMetaClient.AUXILIARYFOLDER_NAME, INSTANT_MARKER_FOLDER_NAME); + int tryTimes = 1; + // waiting all subtask create marker file ready + while (true) { + Thread.sleep(500L); + fileStatuses = fs.listStatus(instantMarkerPath, new PathFilter() { + @Override + public boolean accept(Path pathname) { + return pathname.getName().contains(String.format("_%d_", checkpointId)); + } + }); + + // is ready + if (fileStatuses != null && fileStatuses.length == numberOfParallelSubtasks) { + break; + } + + if (tryTimes >= 5) { + LOG.warn("waiting generate file, checkpointId [{}]", checkpointId); + tryTimes = 0; + } + tryTimes++; + } + + boolean receivedData = false; + // judge whether has data in this checkpoint and delete maker file. + for (FileStatus fileStatus : fileStatuses) { + Path path = fileStatus.getPath(); + String name = path.getName(); + // has data + if (Long.parseLong(name.split(UNDERLINE)[2]) > 0) { + receivedData = true; + break; + } + } + + // delete all marker file + fileStatuses = fs.listStatus(instantMarkerPath); + for (FileStatus fileStatus : fileStatuses) { + fs.delete(fileStatus.getPath(), true); + } + + return receivedData; + } + + private void createInstantMarkerDir() throws IOException { + // Always create instantMarkerFolder which is needed for InstantGenerateOperator + final Path instantMarkerFolder = new Path(new Path(cfg.targetBasePath, HoodieTableMetaClient.AUXILIARYFOLDER_NAME), INSTANT_MARKER_FOLDER_NAME); Review comment: `Paths.get()` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org