Skip to content

Commit c771e56

Browse files
authored
Add Cassandra configuration (#69)
close #58
1 parent 6de40bf commit c771e56

11 files changed

Lines changed: 491 additions & 10 deletions

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,18 @@ be able to start all dependencies for testing. In the same folder, you can find
238238
So from the `conf` folder:
239239
- To start
240240
```ssh
241-
docker-compose up -d
241+
docker-compose -f docker-compose-postgres.yml up -d
242242
```
243243
244244
- To create the database or clean up:
245245
```ssh
246-
docker cp ./schema.sql conf_db_1:/root/schema.sql
247-
docker exec conf_db_1 psql akka-persistence akka -f /root/schema.sql
246+
docker cp ./schema-postgres.sql conf_db_1:/root/schema-postgres.sql
247+
docker exec conf_db_1 psql akka-persistence akka -f /root/schema-postgres.sql
248248
```
249249
250250
- To stop:
251251
```ssh
252-
docker-compose up -d
252+
docker-compose -f docker-compose-postgres.yml up -d
253253
```
254254
255255
More information about [Docker Compose in the documentation](https://docs.docker.com/compose/).
@@ -267,6 +267,7 @@ bin/simplexspatial-core \
267267
-jvm-debug 9010 \
268268
-J-Xms1G \
269269
-J-Xmx4G \
270+
-Dconfig.file=conf/application-postgres.conf\
270271
-Dakka.remote.artery.canonical.port=2550 \
271272
-Dsimplexportal.spatial.entrypoint.grpc-web.port=6080 \
272273
-Dsimplexportal.spatial.entrypoint.grpc.port=7080 \
@@ -280,6 +281,7 @@ bin/simplexspatial-core \
280281
-jvm-debug 9011 \
281282
-J-Xms1G \
282283
-J-Xmx4G \
284+
-Dconfig.file=conf/application-postgres.conf\
283285
-Dakka.remote.artery.canonical.port=2551 \
284286
-Dsimplexportal.spatial.entrypoint.grpc-web.port=6081 \
285287
-Dsimplexportal.spatial.entrypoint.grpc.port=7081 \
@@ -292,6 +294,7 @@ bin/simplexspatial-core \
292294
-java-home /usr/lib/jvm/java-8-openjdk-amd64 \
293295
-J-Xms1G \
294296
-J-Xmx4G \
297+
-Dconfig.file=conf/application-postgres.conf\
295298
-Dakka.remote.artery.canonical.port=0 \
296299
-Dsimplexportal.spatial.entrypoint.grpc-web.port=0 \
297300
-Dsimplexportal.spatial.entrypoint.grpc.port=0 \

build.sbt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ lazy val commonSettings = Seq(
2727
version := "0.0.1-SNAPSHOT",
2828
fork := true,
2929
resolvers += "osm4scala repo" at "https://dl.bintray.com/angelcervera/maven",
30-
scalaVersion := "2.12.10",
30+
scalaVersion := "2.12.11",
3131
// Compile / scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-Xlog-reflective-calls", "-Xlint"),
3232
Compile / javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation")
3333
// run / javaOptions ++= Seq("-Xms128m", "-Xmx1024m", "-Djava.library.path=./target/native"),
@@ -114,17 +114,19 @@ lazy val core = (project in file("core"))
114114
"com.simplexportal.spatial.Main"
115115
),
116116
libraryDependencies ++= Seq(
117-
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
118-
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion,
119117
"com.typesafe.akka" %% "akka-actor-typed" % akkaVersion,
120118
"com.typesafe.akka" %% "akka-persistence-typed" % akkaVersion,
121119
"com.typesafe.akka" %% "akka-persistence-query" % akkaVersion,
122120
"com.typesafe.akka" %% "akka-stream-typed" % akkaVersion,
123121
"com.typesafe.akka" %% "akka-cluster-typed" % akkaVersion,
124122
"com.typesafe.akka" %% "akka-cluster-sharding-typed" % akkaVersion,
123+
"com.typesafe.akka" %% "akka-cluster-tools" % akkaVersion,
124+
"com.typesafe.akka" %% "akka-persistence-cassandra" % "1.0.0-RC1",
125+
"com.typesafe.akka" %% "akka-discovery" % akkaVersion, // FIXME: Remove after update sbt-akka-grpc
126+
"com.typesafe.akka" %% "akka-http" % akkaHttpVersion,
127+
"com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion,
125128
"io.altoo" %% "akka-kryo-serialization" % akkaKryoSerializationVersion,
126129
"ch.megard" %% "akka-http-cors" % akkaHttpCorsVersion,
127-
"com.typesafe.akka" %% "akka-discovery" % akkaVersion, // FIXME: Remove after update sbt-akka-grpc
128130
"org.fusesource.leveldbjni" % "leveldbjni-all" % leveldbVersion,
129131
"ch.qos.logback" % "logback-classic" % "1.2.3",
130132
"io.jvm.uuid" %% "scala-uuid" % scalaUUIDVersion,
@@ -133,10 +135,10 @@ lazy val core = (project in file("core"))
133135
"org.postgresql" % "postgresql" % postgresJDBCDriver
134136
) ++ Seq(
135137
"com.typesafe.akka" %% "akka-actor-testkit-typed" % akkaVersion,
138+
"com.typesafe.akka" %% "akka-multi-node-testkit" % akkaVersion,
136139
"org.scalatest" %% "scalatest" % scalatestVersion,
137140
"org.scalactic" %% "scalactic" % scalatestVersion,
138-
"com.github.pathikrit" %% "better-files" % betterFilesVersion,
139-
"com.typesafe.akka" %% "akka-multi-node-testkit" % akkaVersion
141+
"com.github.pathikrit" %% "better-files" % betterFilesVersion
140142
).map(_ % Test)
141143
)
142144
.enablePlugins(UniversalPlugin)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
akka {
2+
3+
log-dead-letters = 100
4+
log-dead-letters-during-shutdown = on
5+
loglevel = "ERROR"
6+
7+
extensions = [akka.persistence.Persistence]
8+
9+
persistence {
10+
journal {
11+
plugin = "akka.persistence.cassandra.journal"
12+
}
13+
snapshot-store {
14+
plugin = "akka.persistence.cassandra.snapshot"
15+
}
16+
}
17+
18+
cluster {
19+
seed-nodes = [
20+
"akka://[email protected]:2550",
21+
"akka://[email protected]:2551"
22+
]
23+
sharding {
24+
number-of-shards = 100
25+
}
26+
}
27+
28+
}
29+
30+
datastax-java-driver {
31+
advanced {
32+
reconnect-on-init = true
33+
}
34+
profiles {
35+
akka-persistence-cassandra-profile {
36+
basic.request.consistency = LOCAL_QUORUM
37+
}
38+
}
39+
}
40+
41+
simplexportal.spatial {
42+
entrypoint {
43+
restful {
44+
interface = "0.0.0.0"
45+
// port = 8080
46+
}
47+
grpc {
48+
interface = "0.0.0.0"
49+
// port = 7080
50+
}
51+
grpc-web {
52+
interface = "0.0.0.0"
53+
// port = 6080
54+
}
55+
}
56+
indexes {
57+
grid-index {
58+
partitions {
59+
nodes-lookup = 5
60+
ways-lookup = 5
61+
latitude = 10000
62+
longitude = 10000
63+
}
64+
}
65+
}
66+
}
67+
68+
File renamed without changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: '3.7'
2+
3+
services:
4+
cassandra_seed:
5+
image: cassandra:3
6+
restart: always
7+
ports:
8+
- 9160:9160
9+
- 9042:9042
10+
networks:
11+
default:
12+
ipv4_address: 172.28.0.100
13+
environment:
14+
CASSANDRA_SEEDS: 172.28.0.100
15+
cassandra:
16+
image: cassandra:3
17+
restart: always
18+
ports:
19+
- 9160
20+
- 9042
21+
environment:
22+
CASSANDRA_SEEDS: 172.28.0.100
23+
depends_on:
24+
- "cassandra_seed"
25+
networks:
26+
default:
27+
ipam:
28+
driver: default
29+
config:
30+
- subnet: 172.28.0.0/16
31+
File renamed without changes.
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
CREATE
2+
KEYSPACE IF NOT EXISTS akka
3+
WITH REPLICATION = { 'class' : 'SimpleStrategy','replication_factor':1 }; -- In production, replica should be at least 3
4+
5+
CREATE TABLE IF NOT EXISTS akka.messages
6+
(
7+
persistence_id text,
8+
partition_nr bigint,
9+
sequence_nr bigint,
10+
timestamp timeuuid,
11+
timebucket text,
12+
writer_uuid text,
13+
ser_id int,
14+
ser_manifest text,
15+
event_manifest text,
16+
event blob,
17+
meta_ser_id int,
18+
meta_ser_manifest text,
19+
meta blob,
20+
tags set< text >,
21+
PRIMARY KEY ((persistence_id, partition_nr),
22+
sequence_nr,
23+
timestamp,
24+
timebucket
25+
)
26+
)
27+
WITH gc_grace_seconds =864000
28+
AND compaction = {
29+
'class' : 'SizeTieredCompactionStrategy',
30+
'enabled' : true,
31+
'tombstone_compaction_interval' : 86400,
32+
'tombstone_threshold' : 0.2,
33+
'unchecked_tombstone_compaction' : false,
34+
'bucket_high' : 1.5,
35+
'bucket_low' : 0.5,
36+
'max_threshold' : 32,
37+
'min_threshold' : 4,
38+
'min_sstable_size' : 50
39+
};
40+
41+
CREATE TABLE IF NOT EXISTS akka.tag_views
42+
(
43+
tag_name text,
44+
persistence_id text,
45+
sequence_nr bigint,
46+
timebucket bigint,
47+
timestamp timeuuid,
48+
tag_pid_sequence_nr bigint,
49+
writer_uuid text,
50+
ser_id int,
51+
ser_manifest text,
52+
event_manifest text,
53+
event blob,
54+
meta_ser_id int,
55+
meta_ser_manifest text,
56+
meta blob,
57+
PRIMARY KEY ((tag_name, timebucket),
58+
timestamp,
59+
persistence_id,
60+
tag_pid_sequence_nr
61+
)
62+
)
63+
WITH gc_grace_seconds =864000
64+
AND compaction = {
65+
'class' : 'SizeTieredCompactionStrategy',
66+
'enabled' : true,
67+
'tombstone_compaction_interval' : 86400,
68+
'tombstone_threshold' : 0.2,
69+
'unchecked_tombstone_compaction' : false,
70+
'bucket_high' : 1.5,
71+
'bucket_low' : 0.5,
72+
'max_threshold' : 32,
73+
'min_threshold' : 4,
74+
'min_sstable_size' : 50
75+
};
76+
77+
CREATE TABLE IF NOT EXISTS akka.tag_write_progress
78+
(
79+
persistence_id text,
80+
tag text,
81+
sequence_nr bigint,
82+
tag_pid_sequence_nr bigint,
83+
offset timeuuid,
84+
PRIMARY KEY (persistence_id, tag)
85+
);
86+
87+
CREATE TABLE IF NOT EXISTS akka.tag_scanning
88+
(
89+
persistence_id text,
90+
sequence_nr bigint,
91+
PRIMARY KEY (persistence_id)
92+
);
93+
94+
CREATE TABLE IF NOT EXISTS akka.metadata
95+
(
96+
persistence_id text PRIMARY KEY,
97+
deleted_to bigint,
98+
properties map< text,
99+
text>
100+
);
101+
102+
CREATE TABLE IF NOT EXISTS akka.all_persistence_ids
103+
(
104+
persistence_id text PRIMARY KEY
105+
);
106+
107+
CREATE KEYSPACE IF NOT EXISTS akka_snapshot
108+
WITH REPLICATION = { 'class' : 'SimpleStrategy','replication_factor':1 }; -- In production, replica should be at least 3
109+
110+
CREATE TABLE IF NOT EXISTS akka_snapshot.snapshots (
111+
persistence_id text,
112+
sequence_nr bigint,
113+
timestamp bigint,
114+
ser_id int,
115+
ser_manifest text,
116+
snapshot_data blob,
117+
snapshot blob,
118+
meta_ser_id int,
119+
meta_ser_manifest text,
120+
meta blob,
121+
PRIMARY KEY (persistence_id, sequence_nr)
122+
)
123+
WITH CLUSTERING ORDER BY (sequence_nr DESC)
124+
AND gc_grace_seconds =864000
125+
AND compaction = {
126+
'class' : 'SizeTieredCompactionStrategy',
127+
'enabled' : true,
128+
'tombstone_compaction_interval' : 86400,
129+
'tombstone_threshold' : 0.2,
130+
'unchecked_tombstone_compaction' : false,
131+
'bucket_high' : 1.5,
132+
'bucket_low' : 0.5,
133+
'max_threshold' : 32,
134+
'min_threshold' : 4,
135+
'min_sstable_size' : 50
136+
};
File renamed without changes.

0 commit comments

Comments
 (0)