{"id":19519786,"url":"https://github.com/ep2p/dht-sample","last_synced_at":"2026-05-15T10:43:20.454Z","repository":{"id":126685167,"uuid":"306825274","full_name":"ep2p/dht-sample","owner":"ep2p","description":"Distributed Hash Table sample using Kademlia API, Spring Boot and ROW ","archived":false,"fork":false,"pushed_at":"2020-11-01T09:06:30.000Z","size":26,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-08T13:27:21.522Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ep2p.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-24T06:59:43.000Z","updated_at":"2023-04-27T07:48:41.000Z","dependencies_parsed_at":"2023-06-17T16:32:13.921Z","dependency_job_id":null,"html_url":"https://github.com/ep2p/dht-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ep2p%2Fdht-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ep2p%2Fdht-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ep2p%2Fdht-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ep2p%2Fdht-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ep2p","download_url":"https://codeload.github.com/ep2p/dht-sample/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240767837,"owners_count":19854329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T00:21:48.108Z","updated_at":"2026-05-15T10:43:20.399Z","avatar_url":"https://github.com/ep2p.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dht-sample\nDistributed Hash Table sample using Spring Boot and ROW \n\nThis repository contains a sample DHT using [Eleuth Kademlia Api](https://github.com/ep2p/kademlia-api), and [Rest Over Websocket](https://github.com/idioglossia/spring-rest-over-ws)\n\n## RUN\n\nFirst run 2 nodes:\n\n**Node 1**\n\n`mvn spring-boot:run -Dspring-boot.run.arguments=\"--nodeId=1 --server.port=8001 --server.address=127.0.0.1\"`\n\n**Node 2**\n\n`mvn spring-boot:run -Dspring-boot.run.arguments=\"--nodeId=2 --server.port=8002 --server.address=127.0.0.1\"`\n\n---\n\nStart node 1:\n\n```\ncurl --request GET \\\n  --url http://localhost:8001/manager/start\n```\n\nBootstrap node 2 using node 1 address:\n\n```\ncurl --request POST \\\n  --url http://localhost:8002/manager/bootstrap \\\n  --header 'content-type: application/json' \\\n  --data '{\n\t\"id\": 1,\n\t\"connectionInfo\": {\n\t\t\"address\": \"127.0.0.1\",\n\t\t\"port\": 8001\n\t}\n}'\n```\n\nStore data on nodes.\n\n```\ncurl --request POST \\\n  --url http://localhost:8002/manager/store \\\n  --header 'content-type: application/json' \\\n  --data '{\n\t\"key\": 1,\n\t\"value\": \"Value for key 1\"\n}'\n```\n\nresponse: `Node #1 STORED DATA`\n\nStore another data:\n\n```\ncurl --request POST \\\n  --url http://localhost:8002/manager/store \\\n  --header 'content-type: application/json' \\\n  --data '{\n\t\"key\": 2,\n\t\"value\": \"Value for key 2\"\n}'\n```\n\nresponse: `Node #2 STORED DATA`\n\nBoth store calls were sent to second node, but as you can see, node#1 stored data for key 1.\n\nGet data of key 1:\n\n```\ncurl --request GET \\\n  --url http://localhost:8002/manager/get/1\n```\n\nResponse: `Node #1 GOT DATA: Value for key 1`\n\nGet data of key 2:\n\n```\ncurl --request GET \\\n  --url http://localhost:8002/manager/get/2\n```\n\nResponse: `Node #2 GOT DATA: Value for key 2`\n\nSo data is distributed. Now shutdown node 1 by pressing `cntl+c`.\nAfter shutdown, try to get data of key 1, which previously was stored in node 1.\n\n```\ncurl --request GET \\\n  --url http://localhost:8002/manager/get/1\n```\n\nResponse: `Node #2 GOT DATA: Value for key 1`\n\nWhich means data was moved to closest node (from 1 to 2) before shutdown.\n\nYou can run this on more nodes, and results would have same logic :)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fep2p%2Fdht-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fep2p%2Fdht-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fep2p%2Fdht-sample/lists"}