Skip to content

Conversation

@hadv
Copy link
Owner

@hadv hadv commented Oct 3, 2025

Overview

This PR migrates the Eclipse Store AFS NIO (New I/O) module from Java to .NET Core, providing local file system storage capabilities for NebulaStore.

Changes

Core Implementation

  • ✅ Ported all 7 Java source files from Eclipse Store NIO module to C#
  • ✅ Implemented NioFileSystem for local file system operations
  • ✅ Implemented NioConnector for AFS integration
  • ✅ Added comprehensive test suite with 23 passing tests
  • ✅ Added detailed README with usage examples and documentation

Key Components

  1. NioPathResolver - Path resolution with home directory expansion
  2. NioFileWrapper - Thread-safe file stream management with automatic positioning
  3. NioIoHandler - Core I/O operations (read, write, copy, move, truncate, etc.)
  4. NioConnector - Full IBlobStoreConnector implementation for AFS integration
  5. NioReadableFile - Read-only file access wrapper
  6. NioWritableFile - Read-write file access wrapper

Files Added

afs/nio/
├── NebulaStore.Afs.Nio.csproj
├── README.md
├── src/
│   ├── INioFileWrapper.cs
│   ├── INioItemWrapper.cs
│   ├── NioConnector.cs
│   ├── NioFileSystem.cs
│   ├── NioFileWrapperBase.cs
│   ├── NioIoHandler.cs
│   ├── NioPathResolver.cs
│   ├── NioReadableFile.cs
│   └── NioWritableFile.cs
└── test/
    ├── NebulaStore.Afs.Nio.Tests.csproj
    ├── NioConnectorTests.cs
    └── NioFileSystemTests.cs

Java to .NET Mappings

Java .NET
FileChannel FileStream
Path (Java NIO) string (file system path)
OpenOption FileMode, FileAccess, FileShare
ByteBuffer byte[]
synchronized blocks lock statements

Testing

  • ✅ All 23 unit tests passing
  • ✅ NIO project builds successfully
  • ✅ Test project builds successfully
  • ✅ Entire solution builds successfully

Test Coverage

NioFileSystemTests (10 tests):

  • File system creation with default/custom protocols
  • Path resolution (home directory, regular paths)
  • File wrapping (readable, writable)
  • File conversion (readable ↔ writable)
  • Read/write operations

NioConnectorTests (13 tests):

  • Directory and file creation
  • File existence checks
  • Read/write operations (full and partial)
  • File deletion
  • File listing (files and directories)
  • File move and copy operations
  • Multi-chunk writes

Features

  • Local File System Access: Direct access using .NET's System.IO
  • Thread-Safe Operations: All operations use proper synchronization
  • File Stream Management: Automatic positioning and lifecycle management
  • Path Resolution: Home directory expansion and platform-specific paths
  • AFS Integration: Full IBlobStoreConnector implementation
  • Comprehensive Error Handling: Proper exceptions for all error cases

Documentation

The afs/nio/README.md includes:

  • Architecture overview and class hierarchy
  • Usage examples and code snippets
  • Integration with EmbeddedStorage
  • Advanced file operations
  • Performance considerations
  • Best practices
  • Comparison with other AFS backends

Build Status

✅ Build succeeded with 0 errors
✅ All 23 tests passed
✅ Solution builds successfully

Related

Checklist

  • Code compiles without errors
  • All tests pass
  • Documentation added (README.md)
  • Follows existing code style and patterns
  • Added to solution file
  • No breaking changes to existing code

Pull Request opened by Augment Code with guidance from the PR author

- Port all 7 Java source files from Eclipse Store NIO module to C#
- Implement NioFileSystem for local file system operations
- Implement NioConnector for AFS integration
- Add comprehensive test suite with 23 passing tests
- Add detailed README with usage examples and documentation

Key components:
- NioPathResolver: Path resolution with home directory expansion
- NioFileWrapper: Thread-safe file stream management
- NioIoHandler: Core I/O operations (read, write, copy, move, etc.)
- NioConnector: Full IBlobStoreConnector implementation

All tests passing, builds successfully with the entire solution.
@hadv hadv merged commit 3ea6ea7 into main Oct 4, 2025
5 checks passed
@hadv hadv deleted the feature/afs-nio-migration branch October 4, 2025 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants