Remote Hash Map
This project implements a distributed node cluster management system using gRPC. The system includes two main components:
- Node: Represents individual nodes in the cluster, capable of storing key-value pairs and responding to ping requests.
- NodeGroup: Manages a group of nodes, handles adding and retrieving nodes, and regularly pings nodes to ensure they are responsive.
Features
- Key-Value Storage: Store and retrieve key-value pairs in individual nodes.
- Node Management: Add and retrieve nodes from the node group (cluster).
- Health Checking: Regularly ping nodes to check their health and remove unresponsive nodes.
- Replication: Replicate hash map between nodes.
Sample usage
- Get and run the nodes and node group:
- Create a client and use remote_hash_map:
Create new project
src/main.rs
use RHMClient;
async
Getting Started
Prerequisites
- Rust (with
cargopackage manager) protoc(Protocol Buffers compiler) for gRPC
Building the Project
To compile the project, run:
This will build the project and produce the executables in the target/release directory.
Running the Project
Run a Single Node on Default Port
To run a single node using the default port, execute:
Run a Node on a Specified Port
To run a node on a specified port, use the --listen option:
Use Group (Cluster) Functionality
If you want to use the group (cluster) functionality, follow these steps:
-
Run NodeGroup: Start the NodeGroup on a specified port:
-
Run Nodes and Attach to the Group: Start as many nodes as you wish and attach them to the NodeGroup:
-
Pinging is configurable:
#ping every 4 seconds
Detailed Steps
-
Compile the Project: Ensure you have Rust and
cargoinstalled, then compile the project: -
Run NodeGroup: Start the NodeGroup service to manage the cluster:
-
Run Nodes: Start individual nodes and attach them to the NodeGroup:
Logging
The project uses env_logger for logging. By default, the log level is set to info. To see the log output, simply run the commands as specified. If you need more detailed logs (e.g., debug level), set the RUST_LOG environment variable:
RUST_LOG=debug
Troubleshooting
- Ensure that all necessary dependencies are installed and properly configured.
- Verify that the ports you are using are not blocked by any firewall or used by other services.
- Check the log output for any errors or warnings that might indicate what is going wrong.
Contributing
Contributions are welcome! Please submit a pull request or open an issue to discuss any changes or improvements.
License
This project is licensed under the MIT License. See the LICENSE file for more details.