Java中的分布式Hashmap或分布式信息存储 [英] Distributed Hashmap in java or distributed information storage

查看:240
本文介绍了Java中的分布式Hashmap或分布式信息存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道分布式哈希映射(DHT)的好框架吗?

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

前段时间我曾与 Overlay Weaver 合作,但是这里缺少一个好的文档,所以我只用它来制作一个丑陋的黑客原型......但是现在我需要可靠的代码。或者有人为OverlayWeaver找到了一个好的文档?

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?

如果dht框架支持Chord或Kademlia并且可以在我的java应用程序中调用它将是完美的。

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?

推荐答案

我认为 Hazelcast 适用于这种情况。它实际上不需要设置(超过你需要将依赖项添加到Hazelcast罐子)。以下代码示例显示如何设置共享地图

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支持各种共享数据结构,包括 Map 队列列表 AtomicLong IdGenerator 文档很好根据我的经验,实现是可靠的。

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.

如果您使用的是理智的构建环境(例如Maven),则以下依赖项都是开始时需要:

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>

这篇关于Java中的分布式Hashmap或分布式信息存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆