Permalink
Browse files

Since this is a feature it has been moved to the titan0.1 branch.

This reverts commit 6172336.
  • Loading branch information...
1 parent 8b4caae commit 4512f0b61880dc6e0c9a41e6c84c63ddde4b4b8f @mbroecheler mbroecheler committed Jun 25, 2012
@@ -114,10 +114,7 @@ public void acquireLock(ByteBuffer key, ByteBuffer column,
@Override
public boolean containsKey(ByteBuffer key, TransactionHandle txh) {
try {
- // See getSlice() below for a warning suppression justification
- @SuppressWarnings("rawtypes")
RowQuery rq = (RowQuery)keyspace.prepareQuery(cf).getKey(key);
- @SuppressWarnings("unchecked")
OperationResult<ColumnList<ByteBuffer>> r = rq.withColumnRange(EMPTY, EMPTY, false, 1).execute();
return 0 < r.getResult().size();
} catch (ConnectionException e) {
@@ -165,9 +162,7 @@ public boolean containsKey(ByteBuffer key, TransactionHandle txh) {
OperationResult<ColumnList<ByteBuffer>> r;
try {
- @SuppressWarnings("unchecked")
- OperationResult<ColumnList<ByteBuffer>> tmp = (OperationResult<ColumnList<ByteBuffer>>)rq.execute();
- r = tmp;
+ r = (OperationResult<ColumnList<ByteBuffer>>)rq.execute();
} catch (ConnectionException e) {
throw new GraphStorageException(e);
}
@@ -21,30 +21,19 @@
import com.thinkaurelius.titan.diskstorage.OrderedKeyColumnValueStore;
import com.thinkaurelius.titan.diskstorage.StorageManager;
import com.thinkaurelius.titan.diskstorage.TransactionHandle;
+import com.thinkaurelius.titan.diskstorage.cassandra.CassandraThriftStorageManager;
import com.thinkaurelius.titan.diskstorage.locking.LocalLockMediator;
import com.thinkaurelius.titan.diskstorage.locking.LocalLockMediators;
import com.thinkaurelius.titan.diskstorage.util.ConfigHelper;
-import com.thinkaurelius.titan.diskstorage.util.OrderedKeyColumnValueIDManager;
import com.thinkaurelius.titan.diskstorage.util.SimpleLockConfig;
import com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration;
public class AstyanaxStorageManager implements StorageManager {
-
- /**
- * Default name for the Cassandra keyspace
- * <p>
- * Value = {@value}
- */
- public static final String KEYSPACE_DEFAULT = "titan";
- public static final String KEYSPACE_KEY = "keyspace";
-
- /**
- * Default name for the Cassandra cluster
- * <p>
- * Value = {@value}
- */
- public static final String CLUSTER_DEFAULT = "Test Cluster";
- public static final String CLUSTER_KEY = "cluster";
+
+ public static final String KS_NAME = "titantest"; // TODO destroy
+ public static final String CLUSTER_NAME = "Test Cluster"; // TODO destroy
+ public static final String LOCAL_LOCK_MEDIATOR_PREFIX_KEY = "local-lock-mediator-prefix"; // TODO destroy (and in CassandraThriftStorageManager too)
+ public static final String LOCAL_LOCK_MEDIATOR_PREFIX_DEFAULT = "astyanax"; // keep this but perhaps make it private
private static final ConcurrentHashMap<String, AstyanaxContext<Keyspace>> keyspaces =
new ConcurrentHashMap<String, AstyanaxContext<Keyspace>>();
@@ -54,30 +43,25 @@
private final AstyanaxContext<Keyspace> ks;
private final String ksName;
- private final String clusterName;
private final int lockRetryCount;
private final long lockWaitMS, lockExpireMS;
private final byte[] rid;
-
- private final OrderedKeyColumnValueIDManager idmanager;
private final String llmPrefix;
public AstyanaxStorageManager(Configuration config) {
-
- this.clusterName = config.getString(CLUSTER_KEY, CLUSTER_DEFAULT);
-
- this.ksName = config.getString(KEYSPACE_KEY, KEYSPACE_DEFAULT);
-
+ // TODO
+// this.ksName = conf.getString("keyspace");
+ this.ksName = KS_NAME;
this.ks = getOrCreateKeyspace();
this.rid = ConfigHelper.getRid(config);
this.llmPrefix =
config.getString(
LOCAL_LOCK_MEDIATOR_PREFIX_KEY,
- getClass().getName());
+ LOCAL_LOCK_MEDIATOR_PREFIX_DEFAULT); // TODO
this.lockRetryCount =
config.getInt(
@@ -93,14 +77,12 @@ public AstyanaxStorageManager(Configuration config) {
config.getLong(
GraphDatabaseConfiguration.LOCK_EXPIRE_MS,
GraphDatabaseConfiguration.LOCK_EXPIRE_MS_DEFAULT);
-
- idmanager = new OrderedKeyColumnValueIDManager(
- openDatabase("titan_ids", null), rid, config);
}
@Override
public long[] getIDBlock(int partition) {
- return idmanager.getIDBlock(partition);
+ // TODO Auto-generated method stub
+ return null;
}
@Override
@@ -149,7 +131,7 @@ private AstyanaxOrderedKeyColumnValueStore openDatabase(String name, SimpleLockC
private void ensureColumnFamilyExists(String name) {
- Cluster cl = clusters.get(clusterName).getEntity();
+ Cluster cl = clusters.get(CLUSTER_NAME).getEntity();
try {
KeyspaceDefinition ksDef = cl.describeKeyspace(ksName);
@@ -182,7 +164,7 @@ private void ensureColumnFamilyExists(String name) {
// TODO actual configuration
AstyanaxContext.Builder builder =
new AstyanaxContext.Builder()
- .forCluster(clusterName)
+ .forCluster(CLUSTER_NAME)
.forKeyspace(ksName)
.withAstyanaxConfiguration(
new AstyanaxConfigurationImpl()
@@ -204,9 +186,9 @@ private void ensureColumnFamilyExists(String name) {
clusterCtx.start();
- clusters.putIfAbsent(clusterName, clusterCtx);
+ clusters.putIfAbsent(CLUSTER_NAME, clusterCtx);
- clusterCtx = clusters.get(clusterName);
+ clusterCtx = clusters.get(CLUSTER_NAME);
Cluster cl = clusterCtx.getEntity();
@@ -117,6 +117,9 @@
*/
public static final String WRITE_CONSISTENCY_LEVEL_DEFAULT = "QUORUM";
+
+ public static final String LOCAL_LOCK_MEDIATOR_PREFIX_DEFAULT = "cassandra";
+
public static final String REPLICATION_FACTOR_KEY = "replication-factor";
public static final int REPLICATION_FACTOR_DEFAULT = 1;
@@ -160,7 +163,7 @@ public CassandraThriftStorageManager(Configuration config) {
this.llmPrefix =
config.getString(
LOCAL_LOCK_MEDIATOR_PREFIX_KEY,
- getClass().getName());
+ LOCAL_LOCK_MEDIATOR_PREFIX_DEFAULT);
this.replicationFactor =
config.getInt(
@@ -5,7 +5,6 @@
import com.thinkaurelius.titan.core.DefaultTypeMaker;
import com.thinkaurelius.titan.diskstorage.OrderedKeyColumnValueStore;
import com.thinkaurelius.titan.diskstorage.StorageManager;
-import com.thinkaurelius.titan.diskstorage.astyanax.AstyanaxStorageManager;
import com.thinkaurelius.titan.diskstorage.berkeleydb.je.BerkeleyJEStorageAdapter;
import com.thinkaurelius.titan.diskstorage.cassandra.CassandraThriftStorageManager;
import com.thinkaurelius.titan.diskstorage.hbase.HBaseStorageManager;
@@ -54,7 +53,6 @@
put("berkeleyje", BerkeleyJEStorageAdapter.class);
put("cassandra", CassandraThriftStorageManager.class);
put("hbase", HBaseStorageManager.class);
- put("astyanax", AstyanaxStorageManager.class);
}};
private static final Map<String,DefaultTypeMaker> preregisteredAutoType = new HashMap<String,DefaultTypeMaker>() {{
@@ -73,11 +73,5 @@ public static Configuration getHBaseGraphConfiguration() {
config.subset(GraphDatabaseConfiguration.STORAGE_NAMESPACE).addProperty(GraphDatabaseConfiguration.STORAGE_BACKEND_KEY,"hbase");
return config;
}
-
- public static Configuration getAstyanaxGraphConfiguration() {
- Configuration config = StorageSetup.getLocalGraphConfiguration();
- config.subset(GraphDatabaseConfiguration.STORAGE_NAMESPACE).addProperty(GraphDatabaseConfiguration.STORAGE_BACKEND_KEY,"astyanax");
- return config;
- }
}
@@ -21,7 +21,7 @@
@BeforeClass
public static void connectToClusterForCleanup() {
AstyanaxContext<Cluster> ctx = new AstyanaxContext.Builder()
- .forCluster(AstyanaxStorageManager.CLUSTER_DEFAULT)
+ .forCluster(AstyanaxStorageManager.CLUSTER_NAME)
.withAstyanaxConfiguration(
new AstyanaxConfigurationImpl()
.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE))
@@ -44,7 +44,7 @@ public StorageManager openStorageManager() {
@Override
public void cleanUp() {
try {
- cluster.dropKeyspace(AstyanaxStorageManager.KEYSPACE_DEFAULT);
+ cluster.dropKeyspace(AstyanaxStorageManager.KS_NAME);
AstyanaxStorageManager.clearKeyspaces();
} catch (ConnectionException e) {
// throw new RuntimeException(e);
@@ -11,6 +11,7 @@
import com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor;
import com.netflix.astyanax.impl.AstyanaxConfigurationImpl;
import com.netflix.astyanax.thrift.ThriftFamilyFactory;
+import com.thinkaurelius.titan.StorageSetup;
import com.thinkaurelius.titan.diskstorage.LockKeyColumnValueStoreTest;
import com.thinkaurelius.titan.diskstorage.StorageManager;
import com.thinkaurelius.titan.diskstorage.cassandra.CassandraLocalhostHelper;
@@ -24,7 +25,7 @@
@BeforeClass
public static void connectToClusterForCleanup() {
AstyanaxContext<Cluster> ctx = new AstyanaxContext.Builder()
- .forCluster(AstyanaxStorageManager.CLUSTER_DEFAULT)
+ .forCluster(AstyanaxStorageManager.CLUSTER_NAME)
.withAstyanaxConfiguration(
new AstyanaxConfigurationImpl()
.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE))
@@ -51,7 +52,7 @@ public StorageManager openStorageManager(short idx) {
@Override
public void cleanUp() {
try {
- cluster.dropKeyspace(AstyanaxStorageManager.KEYSPACE_DEFAULT);
+ cluster.dropKeyspace(AstyanaxStorageManager.KS_NAME);
AstyanaxStorageManager.clearKeyspaces();
} catch (ConnectionException e) {
// throw new RuntimeException(e);
@@ -1,53 +0,0 @@
-package com.thinkaurelius.titan.diskstorage.astyanax;
-
-import org.junit.BeforeClass;
-
-import com.netflix.astyanax.AstyanaxContext;
-import com.netflix.astyanax.Cluster;
-import com.netflix.astyanax.connectionpool.NodeDiscoveryType;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-import com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl;
-import com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor;
-import com.netflix.astyanax.impl.AstyanaxConfigurationImpl;
-import com.netflix.astyanax.thrift.ThriftFamilyFactory;
-import com.thinkaurelius.titan.StorageSetup;
-import com.thinkaurelius.titan.diskstorage.MultiWriteKeyColumnValueStoreTest;
-import com.thinkaurelius.titan.diskstorage.StorageManager;
-
-public class ExternalAstyanaxMultiWriteKeyColumnValueTest extends MultiWriteKeyColumnValueStoreTest {
-
- private static Cluster cluster;
-
- @BeforeClass
- public static void connectToClusterForCleanup() {
- AstyanaxContext<Cluster> ctx = new AstyanaxContext.Builder()
- .forCluster(AstyanaxStorageManager.CLUSTER_DEFAULT)
- .withAstyanaxConfiguration(
- new AstyanaxConfigurationImpl()
- .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE))
- .withConnectionPoolConfiguration(
- new ConnectionPoolConfigurationImpl("MyConnectionPool")
- .setPort(9160).setMaxConnsPerHost(16)
- .setSeeds("localhost"))
- .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
- .buildCluster(ThriftFamilyFactory.getInstance());
-
- cluster = ctx.getEntity();
- ctx.start();
- }
-
- @Override
- public StorageManager openStorageManager() {
- return new AstyanaxStorageManager(StorageSetup.getLocalStorageConfiguration());
- }
-
- @Override
- public void cleanUp() {
- try {
- cluster.dropKeyspace(AstyanaxStorageManager.KEYSPACE_DEFAULT);
- AstyanaxStorageManager.clearKeyspaces();
- } catch (ConnectionException e) {
-// throw new RuntimeException(e);
- }
- }
-}
@@ -1,52 +0,0 @@
-package com.thinkaurelius.titan.graphdb.astyanax;
-
-import org.junit.BeforeClass;
-
-import com.netflix.astyanax.AstyanaxContext;
-import com.netflix.astyanax.Cluster;
-import com.netflix.astyanax.connectionpool.NodeDiscoveryType;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-import com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl;
-import com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor;
-import com.netflix.astyanax.impl.AstyanaxConfigurationImpl;
-import com.netflix.astyanax.thrift.ThriftFamilyFactory;
-import com.thinkaurelius.titan.StorageSetup;
-import com.thinkaurelius.titan.diskstorage.astyanax.AstyanaxStorageManager;
-import com.thinkaurelius.titan.graphdb.TitanGraphTest;
-
-public class ExternalAstyanaxGraphTest extends TitanGraphTest {
-
- private static Cluster cluster;
-
- public ExternalAstyanaxGraphTest() {
- super(StorageSetup.getAstyanaxGraphConfiguration());
- }
-
- @BeforeClass
- public static void connectToClusterForCleanup() {
- AstyanaxContext<Cluster> ctx = new AstyanaxContext.Builder()
- .forCluster(AstyanaxStorageManager.CLUSTER_DEFAULT)
- .withAstyanaxConfiguration(
- new AstyanaxConfigurationImpl()
- .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE))
- .withConnectionPoolConfiguration(
- new ConnectionPoolConfigurationImpl("MyConnectionPool")
- .setPort(9160).setMaxConnsPerHost(16)
- .setSeeds("localhost"))
- .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
- .buildCluster(ThriftFamilyFactory.getInstance());
-
- cluster = ctx.getEntity();
- ctx.start();
- }
-
- @Override
- public void cleanUp() {
- try {
- cluster.dropKeyspace(AstyanaxStorageManager.KEYSPACE_DEFAULT);
- AstyanaxStorageManager.clearKeyspaces();
- } catch (ConnectionException e) {
-// throw new RuntimeException(e);
- }
- }
-}

0 comments on commit 4512f0b

Please sign in to comment.