apache geode 试用
2024-10-18 20:23:18
使用docker 运行,文档参考的官方的5 分钟学习文档
拉取镜像
docker pull apachegeode/geode
启动
docker run -it -p 10334:10334 -p 7575:7575 -p 1099:1099 -p 40404:40404 apachegeode/geode
初始化数据
容器内
start locator
start server
create region --name=hello --type=REPLICATE
提示信息
create region --name=hello --type=REPLICATE
Member | Status
---------------- | ---------------------------------------------
fix-powerful-cup | Region "/hello" created on "fix-powerful-cup"
简单运行
因为使用了容器,同时我们需要配置一个简单hosts 别名
/etc/hosts
127.0.0.1 55bbae309e69
使用maven 管理
- 项目结构
├── pom.xml
└── src
├── main
│ ├── java
│ │ └── com
│ │ └── dalong
│ │ └── Application.java
│ └── resources
└── test
├── java
└── resources
- 代码说明
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dalong.app</groupId>
<artifactId>dw-jdbc-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.geode</groupId>
<artifactId>geode-core</artifactId>
<version>1.8.0</version>
</dependency>
</dependencies>
</project>
application.java
package com.dalong;
import java.util.Map;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.*;
public class Application {
public static void main(String[] args) {
ClientCache cache = new ClientCacheFactory()
.addPoolLocator("localhost", 10334)
.create();
Region<String, String> region = cache
.<String, String>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
.create("hello");
region.put("1", "Hello");
region.put("2", "World");
for (Map.Entry<String, String> entry : region.entrySet()) {
System.out.format("key = %s, value = %s\n", entry.getKey(), entry.getValue());
}
cache.close();
}
}
- 运行效果
[info 2019/01/10 16:02:11.749 CST <main> tid=0x1] initializing InternalDataSerializer with 0 services
[info 2019/01/10 16:02:11.784 CST <main> tid=0x1] [ThreadsMonitor] New Monitor object and process were created.
[info 2019/01/10 16:02:11.812 CST <StatSampler> tid=0x11] Disabling statistic archival.
[info 2019/01/10 16:02:11.839 CST <main> tid=0x1] Running in client mode
[info 2019/01/10 16:02:11.955 CST <main> tid=0x1] AutoConnectionSource UpdateLocatorListTask started with interval=10000 ms.
[info 2019/01/10 16:02:11.957 CST <main> tid=0x1] Pool DEFAULT started with multiuser-authentication=false
[info 2019/01/10 16:02:12.004 CST <poolTimer-DEFAULT-3> tid=0x1a] Updating membership port. Port changed from 0 to 52778. ID is now bogon(71460:loner):0:b16ec836
key = 1, value = Hello
key = 2, value = World
[info 2019/01/10 16:02:12.084 CST <main> tid=0x1] GemFireCache[id = 1097897234; isClosing = true; isShutDownAll = false; created = Thu Jan 10 16:02:11 CST 2019; server = false; copyOnRead = false; lockLease = 120; lockTimeout = 60]: Now closing.
[info 2019/01/10 16:02:12.132 CST <main> tid=0x1] Destroying connection pool DEFAULT
说明
apache geode 功能还是很强大的,同时也很灵活
参考资料
https://cwiki.apache.org/confluence/display/GEODE/Index#Index-Geodein5minutesGeodein5minutes
https://hub.docker.com/r/apachegeode/geode
https://github.com/rongfengliang/geode-java-demo
最新文章
- JavaWeb_day04搜索_乱码_路径_转发重定向_cookie
- 【Windows编程】系列第四篇:使用Unicode编程
- string、Empty和null三者的区别
- java中string内存的相关知识点
- ios8版本地图定位注意点
- Xcode 缓存 帮助文档 隐藏文件夹显示方法
- DWZ框架一些技巧
- 2014 多校联合训练赛6 Fighting the Landlords
- hdu 4741 Save Labman No.004(2013杭州网络赛)
- 【转】 bio 与块设备驱动
- 痞子衡嵌入式:飞思卡尔Kinetis系列MCU开发那些事 - 索引
- Linux 内存释放命令非常不错具有参考借鉴价值
- IObservable 接口
- html image 圖像路徑
- ES系列十七、logback+ELK日志搭建
- UX设计秘诀之注册表单设计,细节决定成败
- 服务器返回的http状态码
- bzoj 1178 [Apio2009]CONVENTION会议中心
- 成为linux的合格公民
- Redis学习(8)-redis其他特性
热门文章
- 【JAVA多线程】interrupted() 和 isInterrupted() 的区别
- Linux系统下yum源配置(Centos 6)
- CKEditor编辑器的使用
- ssh免密登陆
- 装饰器-wrapper
- POJ - 2635 E - The Embarrassed Cryptographer
- Codeforces Round #495 (Div. 2) B
- 如何实时查看Linux下日志
- TkbmMWFileClient产生的Timeout/error waiting for connection.
- kali linux 入侵window实例