Skip to content

Commit b7ee103

Browse files
authored
Merge pull request JanusGraph#863 from jerryjch/timestamp-provider
Issue 862 Fix preferred default timestamp provider logic in janusgraph configuration
2 parents ddf95fd + 928681e commit b7ee103

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

docs/upgrade.adoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,14 @@ configuration properties.
103103
The legacy configuration track was not recommended in JanusGraph 0.1.z and is
104104
no longer supported in JanusGraph 0.2.0. Users should refer to the previous
105105
sections and migrate to the `REST_CLIENT`.
106+
107+
=== Upgrading from JanusGraph 0.2.0
108+
109+
==== HBase TTL
110+
111+
In JanusGraph 0.2.0, time-to-live (TTL) support was added for HBase storage backend.
112+
In order to utilize the TTL capability on HBase, the graph timestamps need to be
113+
MILLI. If the `graph.timestamps` property is not explicitly set to MILLI, the default
114+
is MICRO in JanusGraph 0.2.0, which does not work for HBase TTL. Since the `graph.timestamps`
115+
property is FIXED, a new graph needs to be created to make any change of the `graph.timestamps`
116+
property effective.

janusgraph-core/src/main/java/org/janusgraph/graphdb/configuration/GraphDatabaseConfiguration.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,6 @@ public GraphDatabaseConfiguration(ReadConfiguration localConfig) {
13811381
BasicConfiguration localbc = new BasicConfiguration(ROOT_NS,localConfig, BasicConfiguration.Restriction.NONE);
13821382
ModifiableConfiguration overwrite = new ModifiableConfiguration(ROOT_NS,new CommonsConfiguration(), BasicConfiguration.Restriction.NONE);
13831383

1384-
// KeyColumnValueStoreManager storeManager=null;
13851384
final KeyColumnValueStoreManager storeManager = Backend.getStorageManager(localbc);
13861385
final StoreFeatures storeFeatures = storeManager.getFeatures();
13871386
KCVSConfiguration kcvsConfig=Backend.getStandaloneGlobalConfiguration(storeManager,localbc);
@@ -1419,10 +1418,11 @@ public GraphDatabaseConfiguration(ReadConfiguration localConfig) {
14191418
globalWrite.set(TIMESTAMP_PROVIDER, backendPreference);
14201419
log.info("Set timestamps to {} according to storage backend preference",
14211420
LoggerUtil.sanitizeAndLaunder(globalWrite.get(TIMESTAMP_PROVIDER)));
1421+
} else {
1422+
globalWrite.set(TIMESTAMP_PROVIDER, TIMESTAMP_PROVIDER.getDefaultValue());
1423+
log.info("Set default timestamp provider {}",
1424+
LoggerUtil.sanitizeAndLaunder(globalWrite.get(TIMESTAMP_PROVIDER)));
14221425
}
1423-
globalWrite.set(TIMESTAMP_PROVIDER, TIMESTAMP_PROVIDER.getDefaultValue());
1424-
log.info("Set default timestamp provider {}",
1425-
LoggerUtil.sanitizeAndLaunder(globalWrite.get(TIMESTAMP_PROVIDER)));
14261426
} else {
14271427
log.info("Using configured timestamp provider {}", localbc.get(TIMESTAMP_PROVIDER));
14281428
}

janusgraph-hbase-parent/janusgraph-hbase-core/src/test/java/org/janusgraph/HBaseStorageSetup.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ public static ModifiableConfiguration getHBaseConfiguration(String tableName, St
103103
if (!StringUtils.isEmpty(tableName)) config.set(HBaseStoreManager.HBASE_TABLE, tableName);
104104
if (!StringUtils.isEmpty(graphName)) config.set(GraphDatabaseConfiguration.GRAPH_NAME, graphName);
105105
config.set(GraphDatabaseConfiguration.TIMESTAMP_PROVIDER, HBaseStoreManager.PREFERRED_TIMESTAMPS);
106-
config.set(GraphDatabaseConfiguration.TIMESTAMP_PROVIDER, HBaseStoreManager.PREFERRED_TIMESTAMPS);
107106
config.set(SimpleBulkPlacementStrategy.CONCURRENT_PARTITIONS, 1);
108107
config.set(GraphDatabaseConfiguration.DROP_ON_CLEAR, false);
109108

janusgraph-hbase-parent/janusgraph-hbase-core/src/test/java/org/janusgraph/diskstorage/hbase/HBaseStoreManagerConfigTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package org.janusgraph.diskstorage.hbase;
1616

17+
import static org.junit.Assert.assertEquals;
1718
import static org.junit.Assert.assertTrue;
1819

1920
import java.io.IOException;
@@ -28,8 +29,10 @@
2829
import org.janusgraph.diskstorage.BackendException;
2930
import org.janusgraph.diskstorage.configuration.BasicConfiguration;
3031
import org.janusgraph.diskstorage.configuration.ConfigElement;
32+
import org.janusgraph.diskstorage.configuration.ModifiableConfiguration;
3133
import org.janusgraph.diskstorage.configuration.WriteConfiguration;
3234
import org.janusgraph.diskstorage.keycolumnvalue.KeyColumnValueStore;
35+
import org.janusgraph.diskstorage.util.time.TimestampProviders;
3336
import org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration;
3437
import org.junit.AfterClass;
3538
import org.junit.BeforeClass;
@@ -81,5 +84,20 @@ public void testShortCfNames() throws Exception {
8184
store.close();
8285
manager.close();
8386
}
87+
88+
@Test
89+
// Test HBase preferred timestamp provider MILLI is set by default
90+
public void testHBaseTimestampProvider() throws BackendException {
91+
// Get an empty configuration
92+
// GraphDatabaseConfiguration.buildGraphConfiguration() only build an empty one.
93+
ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
94+
// Set backend to hbase
95+
config.set(GraphDatabaseConfiguration.STORAGE_BACKEND, "hbase");
96+
// Instantiate a GraphDatabaseConfiguration based on the above
97+
GraphDatabaseConfiguration graphConfig = new GraphDatabaseConfiguration(config.getConfiguration());
98+
// Check the TIMESTAMP_PROVIDER has been set to the hbase preferred MILLI
99+
TimestampProviders provider = graphConfig.getConfiguration().get(GraphDatabaseConfiguration.TIMESTAMP_PROVIDER);
100+
assertEquals(HBaseStoreManager.PREFERRED_TIMESTAMPS, provider);
101+
}
84102

85103
}

0 commit comments

Comments
 (0)