Skip to content

Commit 6013edc

Browse files
committed
Updating README, config option naming, and removing dead code.
1 parent f7c218d commit 6013edc

File tree

4 files changed

+20
-36
lines changed

4 files changed

+20
-36
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ JanusGraph, coupled with the FoundationDB storage adapter provides the following
99
* High availability
1010
* ACID transactions
1111

12-
# Limitations
13-
1412
# Compatibility Matrix
1513

1614
|FDB Storage Adapter|JanusGraph|FoundationDB|
@@ -19,11 +17,13 @@ JanusGraph, coupled with the FoundationDB storage adapter provides the following
1917

2018
# Getting started
2119

22-
The FoundationDB storage adapter requires a single FoundatoinDB instance or cluster and the FoundationDB client libraries. Downloads for server and client can be found [here](https://apple.github.io/foundationdb/downloads.html).
20+
The FoundationDB storage adapter requires a single FoundationDB instance or cluster and the FoundationDB client libraries. Downloads for server and client can be found [here](https://apple.github.io/foundationdb/downloads.html).
2321

2422
## Setting up FoundationDB
2523

26-
## Installing from a binary release
24+
Mac install instructions can be found [here](https://apple.github.io/foundationdb/getting-started-mac.html) and Linux [here](https://apple.github.io/foundationdb/getting-started-linux.html).
25+
26+
## Installing the adapter from a binary release
2727
Binary releases can be found on [GitHub](http://github.com/experoinc/janusgraph-foundationdb/releases).
2828

2929
This installation procedure will copy the necessary libraries, properties, and Gremlin Server configuration files into your JanusGraph installation.
@@ -53,5 +53,8 @@ Follow these steps if you'd like to use the latest version built from source.
5353
|-|-|-|
5454
|`storage.fdb.directory`|Name of the JanusGraph storage directory in FoundationDB.|`janusgraph`|
5555
|`storage.fdb.version`|The FoundationDB client version.|`5.2.0`|
56-
|`storage.fdb.cluster_file_path`|The location of the `fdb.cluster` file.|`/etc/foundationdb/fdb.cluster`|
57-
|`storage.fdb.serializable`|JanusGraph transactions are serializable if `true`, read committed if `false`.|`true`|
56+
|`storage.fdb.cluster-file-path`|The location of the `fdb.cluster` file.|`/etc/foundationdb/fdb.cluster`|
57+
|`storage.fdb.isolation-level`|The three options are `serializable`, `read_committed_no_write`, and `read_committed_with_write`.|`serializable`|
58+
59+
## Isolation Levels
60+
FoundationDB provides serializable isolation under a specific set of [constraints](https://apple.github.io/foundationdb/known-limitations.html#current-limitations). Namely transactions will fail if they take longer than 5 seconds or read/write more than 10,000,000 bytes. This adapter allows the user to relax the how JanusGraph uses FoundationDB transactions and to spread a single JanusGraph transaction over more than one FoundationDB transaction. `read_committed_no_write` allows reads to be spread across more than one transasction, but will fail any writes that are attempted outside of the first transaction period. `read_committed_with_write` allows reads and writes to extend over more than one single transaction. If this option is selected, invariants may be broken and the system will behave similarily to an eventually consistent system.

src/main/java/com/experoinc/janusgraph/diskstorage/foundationdb/FoundationDBConfigOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public interface FoundationDBConfigOptions {
4949

5050
ConfigOption<String> CLUSTER_FILE_PATH = new ConfigOption<>(
5151
FDB_NS,
52-
"cluster_file_path",
52+
"cluster-file-path",
5353
"Path to the FoundationDB cluster file",
5454
ConfigOption.Type.LOCAL,
5555
"default");

src/main/java/com/experoinc/janusgraph/diskstorage/foundationdb/FoundationDBKeyValueStore.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ public synchronized void close() throws BackendException {
8787

8888
@Override
8989
public StaticBuffer get(StaticBuffer key, StoreTransaction txh) throws BackendException {
90-
// Transaction tx = getTransaction(txh);
9190
FoundationDBTx tx = getTransaction(txh);
9291
try {
9392
byte[] databaseKey = db.pack(key.as(ENTRY_FACTORY));
@@ -118,7 +117,6 @@ public void acquireLock(StaticBuffer key, StaticBuffer expectedValue, StoreTrans
118117
@Override
119118
public RecordIterator<KeyValueEntry> getSlice(KVQuery query, StoreTransaction txh) throws BackendException {
120119
log.trace("beginning db={}, op=getSlice, tx={}", name, txh);
121-
// final Transaction tx = getTransaction(txh);
122120
final FoundationDBTx tx = getTransaction(txh);
123121
final StaticBuffer keyStart = query.getStart();
124122
final StaticBuffer keyEnd = query.getEnd();
@@ -176,7 +174,6 @@ public void remove() {
176174
@Override
177175
public Map<KVQuery,RecordIterator<KeyValueEntry>> getSlices(List<KVQuery> queries, StoreTransaction txh) throws BackendException {
178176
log.trace("beginning db={}, op=getSlice, tx={}", name, txh);
179-
// final Transaction tx = getTransaction(txh);
180177
FoundationDBTx tx = getTransaction(txh);
181178
final Map<KVQuery, RecordIterator<KeyValueEntry>> resultMap = new ConcurrentHashMap<>();
182179
final List<CompletableFuture<Void>> futures = new ArrayList<>();
@@ -190,18 +187,6 @@ public Map<KVQuery,RecordIterator<KeyValueEntry>> getSlices(List<KVQuery> querie
190187
final byte[] foundKey = db.pack(keyStart.as(ENTRY_FACTORY));
191188
final byte[] endKey = db.pack(keyEnd.as(ENTRY_FACTORY));
192189
preppedQueries.add(new Object[]{query, foundKey, endKey});
193-
// final Transaction tx = getTransaction(txh);
194-
// final FoundationDBTx tx = getTransaction(txh);
195-
// r = futures.add(tx.getRange(foundKey, endKey, query.getLimit());
196-
// .thenAccept((r) -> {
197-
// final List<KeyValueEntry> result = new ArrayList<>();
198-
// for (final KeyValue keyValue : r) {
199-
// final StaticBuffer key = getBuffer(db.unpack(keyValue.getKey()).getBytes(0));
200-
// if (selector.include(key))
201-
// result.add(new KeyValueEntry(key, getBuffer(keyValue.getValue())));
202-
// }
203-
// resultMap.put(query, new FoundationDBRecordIterator(result));
204-
// }));
205190
}
206191
final Map<KVQuery, List<KeyValue>> result = tx.getMultiRange(preppedQueries);
207192

@@ -215,7 +200,6 @@ public Map<KVQuery,RecordIterator<KeyValueEntry>> getSlices(List<KVQuery> querie
215200
resultMap.put(entry.getKey(), new FoundationDBRecordIterator(results));
216201

217202
}
218-
// CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])).join();
219203
} catch (Exception e) {
220204
throw new PermanentBackendException(e);
221205
}
@@ -229,7 +213,6 @@ public void insert(StaticBuffer key, StaticBuffer value, StoreTransaction txh) t
229213
}
230214

231215
public void insert(StaticBuffer key, StaticBuffer value, StoreTransaction txh, boolean allowOverwrite) throws BackendException {
232-
// Transaction tx = getTransaction(txh);
233216
FoundationDBTx tx = getTransaction(txh);
234217
try {
235218

src/main/java/com/experoinc/janusgraph/diskstorage/foundationdb/FoundationDBTx.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
import java.util.concurrent.atomic.AtomicInteger;
2424

2525
/**
26-
* @author twilmes
26+
* @author Ted Wilmes (twilmes@gmail.com)
2727
*/
2828
public class FoundationDBTx extends AbstractStoreTransaction {
2929

30-
3130
private static final Logger log = LoggerFactory.getLogger(FoundationDBTx.class);
3231

3332
private volatile Transaction tx;
@@ -43,7 +42,7 @@ public enum IsolationLevel { SERIALIZABLE, READ_COMMITTED_NO_WRITE, READ_COMMITT
4342

4443
private final IsolationLevel isolationLevel;
4544

46-
private AtomicInteger txId = new AtomicInteger(0);
45+
private AtomicInteger txCtr = new AtomicInteger(0);
4746

4847
public FoundationDBTx(Database db, Transaction t, BaseTransactionConfig config, IsolationLevel isolationLevel) {
4948
super(config);
@@ -62,7 +61,7 @@ public FoundationDBTx(Database db, Transaction t, BaseTransactionConfig config,
6261
}
6362

6463
public synchronized void restart() {
65-
txId.incrementAndGet();
64+
txCtr.incrementAndGet();
6665
if (tx == null) return;
6766
try {
6867
tx.cancel();
@@ -75,7 +74,7 @@ public synchronized void restart() {
7574
// Reapply mutations but do not clear them out just in case this transaction also
7675
// times out and they need to be reapplied.
7776
//
78-
// @todo Note that at this point, the too large transaction case (tx exceeds 10,000,000 bytes) is not handled.
77+
// @todo Note that at this point, the large transaction case (tx exceeds 10,000,000 bytes) is not handled.
7978
inserts.forEach(insert -> tx.set(insert.getKey(), insert.getValue()));
8079
deletions.forEach(delete -> tx.clear(delete));
8180
}
@@ -171,14 +170,14 @@ public List<KeyValue> getRange(final byte[] startKey, final byte[] endKey,
171170
boolean failing = true;
172171
List<KeyValue> result = Collections.emptyList();
173172
for (int i = 0; i < maxRuns; i++) {
174-
final int startTxId = txId.get();
173+
final int startTxId = txCtr.get();
175174
try {
176175
result = tx.getRange(new Range(startKey, endKey), limit).asList().get();
177176
if (result == null) return Collections.emptyList();
178177
failing = false;
179178
break;
180179
} catch (ExecutionException e) {
181-
if (txId.get() == startTxId)
180+
if (txCtr.get() == startTxId)
182181
this.restart();
183182
} catch (Exception e) {
184183
throw new PermanentBackendException(e);
@@ -193,15 +192,15 @@ public List<KeyValue> getRange(final byte[] startKey, final byte[] endKey,
193192
public synchronized Map<KVQuery, List<KeyValue>> getMultiRange(final List<Object[]> queries)
194193
throws PermanentBackendException {
195194
Map<KVQuery, List<KeyValue>> resultMap = new ConcurrentHashMap<>();
196-
List<Object[]> retries = new CopyOnWriteArrayList<>(queries);
197-
List<CompletableFuture> futures = new LinkedList<>();
195+
final List<Object[]> retries = new CopyOnWriteArrayList<>(queries);
196+
final List<CompletableFuture> futures = new LinkedList<>();
198197
for (int i = 0; i < (maxRuns * 5); i++) {
199198
for(Object[] obj : retries) {
200199
final KVQuery query = (KVQuery) obj[0];
201200
final byte[] start = (byte[]) obj[1];
202201
final byte[] end = (byte[]) obj[2];
203202

204-
final int startTxId = txId.get();
203+
final int startTxId = txCtr.get();
205204
try {
206205
futures.add(tx.getRange(start, end, query.getLimit()).asList()
207206
.whenComplete((res, th) -> {
@@ -212,7 +211,7 @@ public synchronized Map<KVQuery, List<KeyValue>> getMultiRange(final List<Objec
212211
}
213212
resultMap.put(query, res);
214213
} else {
215-
if (startTxId == txId.get())
214+
if (startTxId == txCtr.get())
216215
this.restart();
217216
}
218217
}));
@@ -228,7 +227,6 @@ public synchronized Map<KVQuery, List<KeyValue>> getMultiRange(final List<Objec
228227
// some tasks will fail due to tx time limits being exceeded
229228
} catch (IllegalStateException is) {
230229
// illegal state can arise from tx being closed while tx is inflight
231-
// todo find way to clean this up and prevent this state from occurring
232230
} catch (Exception e) {
233231
throw new PermanentBackendException(e);
234232
}

0 commit comments

Comments
 (0)