Skip to content

Commit

Permalink
Merge branch 'master' into better-assertion-message
Browse files Browse the repository at this point in the history
  • Loading branch information
sunchao authored Sep 24, 2024
2 parents 50b7efa + 36995d9 commit 80dd446
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public static boolean isCoordinatedCommitsToFSConversion(
Long commitVersion,
UpdatedActions updatedActions) {
boolean oldMetadataHasCoordinatedCommits =
!getCoordinator(updatedActions.getOldMetadata()).isEmpty();
getCoordinatorName(updatedActions.getOldMetadata()).isPresent();
boolean newMetadataHasCoordinatedCommits =
!getCoordinator(updatedActions.getNewMetadata()).isEmpty();
getCoordinatorName(updatedActions.getNewMetadata()).isPresent();
return oldMetadataHasCoordinatedCommits && !newMetadataHasCoordinatedCommits && commitVersion > 0;
}

Expand Down Expand Up @@ -120,10 +120,17 @@ public static Path commitDirPath(Path logPath) {
return new Path(logPath, COMMIT_SUBDIR);
}

public static String getCoordinator(AbstractMetadata metadata) {
/**
* Retrieves the coordinator name from the provided abstract metadata.
* If no coordinator is set, an empty optional is returned.
*
* @param metadata The abstract metadata from which to retrieve the coordinator name.
* @return The coordinator name if set, otherwise an empty optional.
*/
public static Optional<String> getCoordinatorName(AbstractMetadata metadata) {
String coordinator = metadata
.getConfiguration()
.get(COORDINATED_COMMITS_COORDINATOR_NAME_KEY);
return coordinator != null ? coordinator : "";
return Optional.ofNullable(coordinator);
}
}

0 comments on commit 80dd446

Please sign in to comment.