Skip to content

RATIS-2581. Route file operations through NIO.2#1499

Merged
szetszwo merged 1 commit into
apache:masterfrom
HTHou:ratis-2581-file-destroyer
Jul 3, 2026
Merged

RATIS-2581. Route file operations through NIO.2#1499
szetszwo merged 1 commit into
apache:masterfrom
HTHou:ratis-2581-file-destroyer

Conversation

@HTHou

@HTHou HTHou commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Route a few remaining Ratis file operations through Java NIO.2 so they can be intercepted by the default FileSystemProvider.

This patch removes direct use of File.delete() from AtomicFileOutputStream#abort, opens segmented log write channels through FileChannel.open(Path, ...) instead of RandomAccessFile#getChannel, and routes zero-size open log segment deletion through FileUtils.

With these changes, downstream projects that install a custom default FileSystemProvider can cover these cleanup and truncate paths without adding a Ratis-specific file destruction API.

https://issues.apache.org/jira/browse/RATIS-2581

How was this patch tested?

  • Ran git diff --check and git diff --cached --check.
  • Ran ./mvnw -pl ratis-common -Dtest=TestFileUtils test.
  • Ran ./mvnw -pl ratis-server -am -DskipTests compile.

@HTHou HTHou changed the title RATIS-2581. Add pluggable file destruction hook RATIS-2581. Add pluggable file destroyer Jun 30, 2026
@HTHou HTHou marked this pull request as ready for review June 30, 2026 07:58
@HTHou HTHou force-pushed the ratis-2581-file-destroyer branch 4 times, most recently from cb7edeb to 7bd1336 Compare June 30, 2026 10:55
@HTHou HTHou force-pushed the ratis-2581-file-destroyer branch from 7bd1336 to 435f83f Compare July 3, 2026 01:49
@HTHou HTHou changed the title RATIS-2581. Add pluggable file destroyer RATIS-2581. Route file operations through NIO.2 Jul 3, 2026

@szetszwo szetszwo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 the change looks good.

@szetszwo szetszwo merged commit c3debb7 into apache:master Jul 3, 2026
18 checks passed
@HTHou HTHou deleted the ratis-2581-file-destroyer branch July 3, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants