Skip to content

Commit

Permalink
PLT-191: Support for redis in janusgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
n5nk committed Nov 23, 2023
1 parent 5adf28d commit d19ef5d
Show file tree
Hide file tree
Showing 14 changed files with 529 additions and 11 deletions.
12 changes: 11 additions & 1 deletion docs/configs/janusgraph-cfg.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,20 @@ Configuration options that modify JanusGraph's caching behavior

| Name | Description | Datatype | Default Value | Mutability |
| ---- | ---- | ---- | ---- | ---- |
| cache.cache-type | Enable or disable Redis cache (redis/inmemory) | String | inmemory | MASKABLE |
| cache.db-cache | Whether to enable JanusGraph's database-level cache, which is shared across all transactions. Enabling this option speeds up traversals by holding hot graph elements in memory, but also increases the likelihood of reading stale data. Disabling it forces each transaction to independently fetch graph elements from storage before reading/writing them. | Boolean | false | MASKABLE |
| cache.db-cache-clean-wait | How long, in milliseconds, database-level cache will keep entries after flushing them. This option is only useful on distributed storage backends that are capable of acknowledging writes without necessarily making them immediately visible. | Integer | 50 | GLOBAL_OFFLINE |
| cache.db-cache-size | Size of JanusGraph's database level cache. Values between 0 and 1 are interpreted as a percentage of VM heap, while larger values are interpreted as an absolute size in bytes. | Double | 0.3 | MASKABLE |
| cache.db-cache-time | Default expiration time, in milliseconds, for entries in the database-level cache. Entries are evicted when they reach this age even if the cache has room to spare. Set to 0 to disable expiration (cache entries live forever or until memory pressure triggers eviction when set to 0). | Long | 10000 | GLOBAL_OFFLINE |
| cache.redis-cache-connectTimeout | Timeout during connecting to any Redis server. | Integer | 1000 | MASKABLE |
| cache.redis-cache-keepAlive | Enables TCP keepAlive for connection. | Boolean | true | MASKABLE |
| cache.redis-cache-lock-watchdog-ms | This prevents against infinity locked locks due to Redisson client crush or any other reason when lock can't be released in proper way. | Long | 600000 | MASKABLE |
| cache.redis-cache-mastername | Master server name used by Redis Sentinel servers and master change monitoring task. | String | mymaster | MASKABLE |
| cache.redis-cache-password | Password for Redis authentication. | String | password | MASKABLE |
| cache.redis-cache-sentinel-urls | csv values for multiple redis sentinel host:port urls. | String | localhost:26379 | MASKABLE |
| cache.redis-cache-server-mode | Redis connection mode, either single or sentinel connection | String | single | MASKABLE |
| cache.redis-cache-server-url | Redis server url. | String | localhost:6379 | MASKABLE |
| cache.redis-cache-username | Username for Redis authentication. | String | default | MASKABLE |
| cache.tx-cache-size | Maximum size of the transaction-level cache of recently-used vertices. | Integer | 20000 | MASKABLE |
| cache.tx-dirty-size | Initial size of the transaction-level cache of uncommitted dirty vertices. This is a performance hint for write-heavy, performance-sensitive transactional workloads. If set, it should roughly match the median vertices modified per transaction. | Integer | (no default value) | MASKABLE |

Expand Down Expand Up @@ -521,7 +531,7 @@ HBase storage options
| storage.hbase.short-cf-names | Whether to shorten the names of JanusGraph's column families to one-character mnemonics to conserve storage space | Boolean | true | FIXED |
| storage.hbase.skip-schema-check | Assume that JanusGraph's HBase table and column families already exist. When this is true, JanusGraph will not check for the existence of its table/CFs, nor will it attempt to create them under any circumstances. This is useful when running JanusGraph without HBase admin privileges. | Boolean | false | MASKABLE |
| storage.hbase.snapshot-name | The name of an existing HBase snapshot to be used by HBaseSnapshotInputFormat | String | janusgraph-snapshot | LOCAL |
| storage.hbase.snapshot-restore-dir | The temporary directory to be used by HBaseSnapshotInputFormat to restore a snapshot. This directory should be on the same File System as the HBase root dir. | String | /tmp | LOCAL |
| storage.hbase.snapshot-restore-dir | The temporary directory to be used by HBaseSnapshotInputFormat to restore a snapshot. This directory should be on the same File System as the HBase root dir. | String | /var/folders/yh/wtzt_tkn4xjbyg6kr5zz3dl80000gn/T/ | LOCAL |
| storage.hbase.table | The name of the table JanusGraph will use. When storage.hbase.skip-schema-check is false, JanusGraph will automatically create this table if it does not already exist. If this configuration option is not provided but graph.graphname is, the table will be set to that value. | String | janusgraph | LOCAL |

### storage.lock
Expand Down
52 changes: 52 additions & 0 deletions janusgraph-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,58 @@
<artifactId>janusgraph-driver</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>de.ruedigermoeller</groupId>
<artifactId>fst</artifactId>
<version>2.56</version>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.20.1</version>
<exclusions>
<exclusion>
<groupId>com.esotericsoftware</groupId>
<artifactId>minlog</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-resolver</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns</artifactId>
</exclusion>
<exclusion>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- TinkerPop -->
<dependency>
<groupId>org.apache.tinkerpop</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction;
import org.janusgraph.diskstorage.keycolumnvalue.cache.CacheTransaction;
import org.janusgraph.diskstorage.keycolumnvalue.cache.ExpirationKCVSCache;
import org.janusgraph.diskstorage.keycolumnvalue.cache.ExpirationKCVSRedisCache;
import org.janusgraph.diskstorage.keycolumnvalue.cache.KCVSCache;
import org.janusgraph.diskstorage.keycolumnvalue.cache.NoKCVSCache;
import org.janusgraph.diskstorage.keycolumnvalue.keyvalue.OrderedKeyValueStoreManager;
Expand Down Expand Up @@ -84,6 +85,7 @@

import static org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.BASIC_METRICS;
import static org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.BUFFER_SIZE;
import static org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.CACHE_TYPE;
import static org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.DB_CACHE;
import static org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.DB_CACHE_CLEAN_WAIT;
import static org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.DB_CACHE_SIZE;
Expand Down Expand Up @@ -154,6 +156,7 @@ public class Backend implements LockerProvider, AutoCloseable {

public static final String SYSTEM_TX_LOG_NAME = "txlog";
public static final String SYSTEM_MGMT_LOG_NAME = "systemlog";
public static final String REDIS_TAG = "redis";

public static final double EDGESTORE_CACHE_PERCENT = 0.8;
public static final double INDEXSTORE_CACHE_PERCENT = 0.2;
Expand Down Expand Up @@ -343,9 +346,21 @@ public void initialize(Configuration config) {
Preconditions.checkArgument(EDGESTORE_CACHE_PERCENT + INDEXSTORE_CACHE_PERCENT == 1.0,"Cache percentages don't add up!");
long edgeStoreCacheSize = Math.round(cacheSizeBytes * EDGESTORE_CACHE_PERCENT);
long indexStoreCacheSize = Math.round(cacheSizeBytes * INDEXSTORE_CACHE_PERCENT);

edgeStore = new ExpirationKCVSCache(edgeStoreRaw,getMetricsCacheName(EDGESTORE_NAME),expirationTime,cleanWaitTime,edgeStoreCacheSize);
indexStore = new ExpirationKCVSCache(indexStoreRaw,getMetricsCacheName(INDEXSTORE_NAME),expirationTime,cleanWaitTime,indexStoreCacheSize);
String cacheType = configuration.get(CACHE_TYPE);

if(REDIS_TAG.equals(cacheType)){
log.info("======== Configuring redis cache ========");
edgeStore = new ExpirationKCVSRedisCache(edgeStoreRaw,getMetricsCacheName(EDGESTORE_NAME)!=null?getMetricsCacheName(EDGESTORE_NAME)
:"edgeStore",expirationTime,cleanWaitTime,
edgeStoreCacheSize, configuration);
indexStore = new ExpirationKCVSRedisCache(indexStoreRaw,getMetricsCacheName(INDEXSTORE_NAME)!=null?
getMetricsCacheName(INDEXSTORE_NAME):"indexStore",expirationTime,cleanWaitTime,
indexStoreCacheSize, configuration);
}else{
log.info("======== Configuring inmemory cache ========");
edgeStore = new ExpirationKCVSCache(edgeStoreRaw,getMetricsCacheName(EDGESTORE_NAME),expirationTime,cleanWaitTime,edgeStoreCacheSize);
indexStore = new ExpirationKCVSCache(indexStoreRaw,getMetricsCacheName(INDEXSTORE_NAME),expirationTime,cleanWaitTime,indexStoreCacheSize);
}
} else {
edgeStore = new NoKCVSCache(edgeStoreRaw);
indexStore = new NoKCVSCache(indexStoreRaw);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package org.janusgraph.diskstorage;

import java.io.Serializable;
import java.util.AbstractList;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -45,7 +46,7 @@ public interface EntryList extends List<Entry> {

EmptyList EMPTY_LIST = new EmptyList();

class EmptyList extends AbstractList<Entry> implements EntryList {
class EmptyList extends AbstractList<Entry> implements EntryList, Serializable {

@Override
public Entry get(int index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
import com.google.common.base.Preconditions;
import org.janusgraph.diskstorage.StaticBuffer;

import java.io.Serializable;
import java.util.Objects;

/**
* Extends {@link SliceQuery} by a key that identifies the location of the slice in the key-ring.
* @author Matthias Broecheler ([email protected])
*/

public class KeySliceQuery extends SliceQuery {
public class KeySliceQuery extends SliceQuery implements Serializable {

private final StaticBuffer key;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.janusgraph.graphdb.query.BackendQuery;
import org.janusgraph.graphdb.query.BaseQuery;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand All @@ -37,7 +38,7 @@
* @author Matthias Broecheler ([email protected])
*/

public class SliceQuery extends BaseQuery implements BackendQuery<SliceQuery> {
public class SliceQuery extends BaseQuery implements BackendQuery<SliceQuery>, Serializable {

private final StaticBuffer sliceStart;
private final StaticBuffer sliceEnd;
Expand Down
Loading

0 comments on commit d19ef5d

Please sign in to comment.