https://github.com/ykayacan/hashing-utils
A basic Java implementation of Consistent Hashing, Rendezvous Hashing and Weighted Rendezvous Hashing.
https://github.com/ykayacan/hashing-utils
consistent-hashing hashing java rendezvous
Last synced: about 2 months ago
JSON representation
A basic Java implementation of Consistent Hashing, Rendezvous Hashing and Weighted Rendezvous Hashing.
- Host: GitHub
- URL: https://github.com/ykayacan/hashing-utils
- Owner: ykayacan
- License: apache-2.0
- Created: 2019-10-10T14:15:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-19T15:47:55.000Z (almost 5 years ago)
- Last Synced: 2025-04-19T22:34:17.605Z (2 months ago)
- Topics: consistent-hashing, hashing, java, rendezvous
- Language: Java
- Homepage:
- Size: 113 KB
- Stars: 10
- Watchers: 0
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Hashing Utils



## Table of Contents
+ [About](#about)
+ [Getting Started](#getting_started)
+ [Usage](#usage)
+ [Contributing](CONTRIBUTING.md)A basic Java implementation of [Consistent Hashing](https://en.wikipedia.org/wiki/Consistent_hashing),
[Rendezvous Hashing](https://en.wikipedia.org/wiki/Rendezvous_hashing) and Weighted Rendezvous Hashing.### Latest Stable Releases

#### Gradle
```groovy
dependencies {
implementation 'io.github.ykayacan.hashing:hashing-api:LATEST_VERSION'
implementation 'io.github.ykayacan.hashing:hashing-consistent:LATEST_VERSION'
implementation 'io.github.ykayacan.hashing:hashing-rendezvous:LATEST_VERSION'
}
```#### Maven
```xml
io.github.ykayacan.hashing
hashing-api
LATEST_VERSION
io.github.ykayacan.hashing
hashing-consistent
LATEST_VERSION
io.github.ykayacan.hashing
hashing-rendezvous
LATEST_VERSION
```
### Snapshots
You can access the latest snapshot by adding the repository `https://oss.sonatype.org/content/repositories/snapshots`
to your build.Snapshots of the development version are available in [Sonatype's snapshots repository](https://oss.sonatype.org/content/repositories/snapshots/io/github/ykayacan/hashing/).
#### Consistent Hashing
```java
NodeRouter router =
ConsistentNodeRouter.create(15, MurMurHashFunction.create());List initialNodes =
Arrays.asList(PhysicalNode.of("node1"), PhysicalNode.of("node2"));router.addNodes(initialNodes);
// get
Optional nodeOpt = router.getNode("node1");// add
router.addNode(PhysicalNode.of("node3"));// remove
router.removeNode("node1");
```#### Rendezvous Hashing
```java
NodeRouter router = RendezvousNodeRouter.create(
MurMurHashFunction.create(), DefaultRendezvousStrategy.create());List initialNodes =
Arrays.asList(WeightedNode.of("node1"), WeightedNode.of("node2"));router.addNodes(initialNodes);
// get
Optional nodeOpt = router.getNode("node1");// add
router.addNode(WeightedNode.of("node3"));// remove
router.removeNode("node1");
```## License
```text
Copyright 2019 Yasin Sinan KayacanLicensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```