-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scalardb/cleanup cassandra deps #114
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2a4be8f
use SchemaLoader
yito88 9faa79b
add db_extend.clj
yito88 10c8506
remove cassandra-test
yito88 4714593
fix default db
yito88 950d132
fix extend-db
yito88 6113ba0
fix opts
yito88 5d2964d
fix generator
yito88 2492632
use scalardb-schema-loader 4.0.0-SNAPSHOT
yito88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
(ns scalardb.db-extend | ||
(:require [cassandra.core :as cassandra] | ||
[clojure.string :as string] | ||
[jepsen.db :as db]) | ||
(:import (com.scalar.db.storage.cassandra CassandraAdmin | ||
CassandraAdmin$ReplicationStrategy | ||
CassandraAdmin$CompactionStrategy) | ||
(java.util Properties))) | ||
|
||
(def ^:private ISOLATION_LEVELS {:snapshot "SNAPSHOT" | ||
:serializable "SERIALIZABLE"}) | ||
|
||
(def ^:private SERIALIZABLE_STRATEGIES {:extra-read "EXTRA_READ" | ||
:extra-write "EXTRA_WRITE"}) | ||
|
||
(defprotocol DbExtension | ||
(live-nodes [this test]) | ||
(wait-for-recovery [this test]) | ||
(create-table-opts [this test]) | ||
(create-properties [this test])) | ||
|
||
(defrecord ExtCassandra [] | ||
DbExtension | ||
(live-nodes [_ test] (cassandra/live-nodes test)) | ||
(wait-for-recovery [_ test] (cassandra/wait-rf-nodes test)) | ||
(create-table-opts | ||
[_ test] | ||
{(keyword CassandraAdmin/REPLICATION_STRATEGY) | ||
(str CassandraAdmin$ReplicationStrategy/SIMPLE_STRATEGY) | ||
(keyword CassandraAdmin/COMPACTION_STRATEGY) | ||
(str CassandraAdmin$CompactionStrategy/LCS) | ||
(keyword CassandraAdmin/REPLICATION_FACTOR) (:rf test)}) | ||
(create-properties | ||
[_ test] | ||
(let [nodes (cassandra/live-nodes test)] | ||
(when (nil? nodes) | ||
(throw (ex-info "No living node" {:test test}))) | ||
(doto (Properties.) | ||
(.setProperty "scalar.db.contact_points" (string/join "," nodes)) | ||
(.setProperty "scalar.db.username" "cassandra") | ||
(.setProperty "scalar.db.password" "cassandra") | ||
(.setProperty "scalar.db.consensus_commit.isolation_level" | ||
((:isolation-level test) ISOLATION_LEVELS)) | ||
(.setProperty "scalar.db.consensus_commit.serializable_strategy" | ||
((:serializable-strategy test) SERIALIZABLE_STRATEGIES)))))) | ||
|
||
(def ^:private ext-dbs | ||
{:cassandra (->ExtCassandra)}) | ||
|
||
(defn extend-db | ||
[db db-type] | ||
(let [ext-db (db-type ext-dbs)] | ||
(reify | ||
db/DB | ||
(setup! [_ test node] (db/setup! db test node)) | ||
(teardown! [_ test node] (db/teardown! db test node)) | ||
db/Primary | ||
(primaries [_ test] (db/primaries db test)) | ||
(setup-primary! [_ test node] (db/setup-primary! db test node)) | ||
db/LogFiles | ||
(log-files [_ test node] (db/log-files db test node)) | ||
DbExtension | ||
(live-nodes [_ test] (live-nodes ext-db test)) | ||
(wait-for-recovery [_ test] (wait-for-recovery ext-db test)) | ||
(create-table-opts [_ test] (create-table-opts ext-db test)) | ||
(create-properties [_ test] (create-properties ext-db test))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use 4.0.0-SNAPSHOT instead of the latest released version?
@brfrn169 What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes. I think so, too.