Distributed Hashmap in java or distributed information storage

一笑奈何 提交于 2019-12-06 07:30:17

问题


Does someone knows a good java framework for distributed hashmaps (DHT)?

Some time ago I worked with Overlay Weaver, but a good documentation is missing here, so I only used it for an prototype with ugly hacks..., but now I need reliable code. Or does someone found a good docu for OverlayWeaver?

It would be perfect if the dht framework supports Chord or Kademlia and can be called inside my java application.

Or does someone knows a better approach to save reliable and failuresafe short string data in distibuted systems?


回答1:


I think that Hazelcast works fine for this type of situation. It practically requires no setup (more than that you need to add the dependencies to the Hazelcast jars). The following code sample shows how to setup a shared Map.

// Code in process 1
Config cfg = new Config();
HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg);
Map<Integer, String> sharedData = instance.getMap("shared");
sharedData.put(1, "This is shared data");

// Code in process 2
Config cfg = new Config();
HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg);
Map<Integer, String> sharedData = instance.getMap("shared");
String theSharedString = sharedData.get(1);

Hazelcast support various shared data structures including Map, Queue, List, AtomicLong, IdGenerator etc. The documentation is good and in my experience the implementation is solid.

If your are using a sane build environment (e.g. Maven) the following dependency is all that is needed to get started:

<dependency>
    <groupId>com.hazelcast</groupId>
    <artifactId>hazelcast</artifactId>
    <version>3.4</version>
</dependency>



回答2:


Try Hazelcast.It is open-source and has Enterprise support.




回答3:


Give a try to Redisson PRO. It supports sharded maps.




回答4:


You can also check Apache Ignite . It supports In-memory distributed key-value store, Distributed Tasks, Durable Memory, Distributed Locks etc. It also support ANSI-99 complaint distributed SQLs.

Getting started is as simple as adding maven dependencies -

<dependency>
    <groupId>org.apache.ignite</groupId>
    <artifactId>ignite-core</artifactId>
    <version>${ignite.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.ignite</groupId>
    <artifactId>ignite-spring</artifactId>
    <version>${ignite.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.ignite</groupId>
    <artifactId>ignite-indexing</artifactId>
    <version>${ignite.version}</version>
</dependency>


来源:https://stackoverflow.com/questions/27815056/distributed-hashmap-in-java-or-distributed-information-storage

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!