Permalink
Browse files

Split astyanax into multiple projects

  • Loading branch information...
elandau committed Feb 14, 2013
1 parent 6bf463e commit b52e984fdfabb83f31443f0fd450aeacb3371fa9
Showing 1,183 changed files with 1,832 additions and 226,396 deletions.
@@ -80,4 +80,10 @@
* @param cqlVersion
*/
String getCqlVersion();
+
+ /**
+ * @return Returns the major cassandra version (x.x) with which this client is communicating.
+ * This is a hack for backwards compatibility when APIs break between version
+ */
+ String getTargetCassandraVersion();
}
@@ -0,0 +1,88 @@
+package com.netflix.astyanax.cql;
+
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.UUID;
+
+import com.netflix.astyanax.Execution;
+import com.netflix.astyanax.Serializer;
+
+public interface CqlPreparedStatement extends Execution<CqlStatementResult> {
+ /**
+ * Specify a value of custom type for which a convenience method does not exist
+ * @param value
+ * @param serializer
+ * @return
+ */
+ <V> CqlPreparedStatement withByteBufferValue(V value, Serializer<V> serializer);
+
+ /**
+ * Set the next parameter value to this ByteBuffer
+ * @param value
+ * @return
+ */
+ CqlPreparedStatement withValue(ByteBuffer value);
+
+ /**
+ * Add a list of ByteBuffer values
+ * @param value
+ * @return
+ */
+ CqlPreparedStatement withValues(List<ByteBuffer> value);
+
+ /**
+ * Set the next parameter value to this String
+ * @param value
+ * @return
+ */
+ CqlPreparedStatement withStringValue(String value);
+
+ /**
+ * Set the next parameter value to this Integer
+ * @param value
+ * @return
+ */
+ CqlPreparedStatement withIntegerValue(Integer value);
+
+ /**
+ * Set the next parameter value to this Boolean
+ * @param value
+ * @return
+ */
+ CqlPreparedStatement withBooleanValue(Boolean value);
+
+ /**
+ * Set the next parameter value to this Double
+ * @param value
+ * @return
+ */
+ CqlPreparedStatement withDoubleValue(Double value);
+
+ /**
+ * Set the next parameter value to this Long
+ * @param value
+ * @return
+ */
+ CqlPreparedStatement withLongValue(Long value);
+
+ /**
+ * Set the next parameter value to this Float
+ * @param value
+ * @return
+ */
+ CqlPreparedStatement withFloatValue(Float value);
+
+ /**
+ * Set the next parameter value to this Short
+ * @param value
+ * @return
+ */
+ CqlPreparedStatement withShortValue(Short value);
+
+ /**
+ * Set the next parameter value to this Short
+ * @param value
+ * @return
+ */
+ CqlPreparedStatement withUUIDValue(UUID value);
+}
@@ -1,7 +1,10 @@
package com.netflix.astyanax.cql;
import com.netflix.astyanax.Execution;
+import com.netflix.astyanax.model.ConsistencyLevel;
public interface CqlStatement extends Execution<CqlStatementResult> {
+ public CqlStatement withConsistencyLevel(ConsistencyLevel cl);
public CqlStatement withCql(String cql);
+ public CqlPreparedStatement asPreparedStatement();
}
@@ -42,6 +42,7 @@
private int discoveryIntervalInSeconds = 30;
private ConnectionPoolType connectionPoolType = ConnectionPoolType.ROUND_ROBIN;
private String cqlVersion = null;
+ private String targetCassandraVersion = "1.1";
public AstyanaxConfigurationImpl() {
}
@@ -140,4 +141,14 @@ public AstyanaxConfigurationImpl setCqlVersion(String cqlVersion) {
this.cqlVersion = cqlVersion;
return this;
}
+
+ @Override
+ public String getTargetCassandraVersion() {
+ return this.targetCassandraVersion;
+ }
+
+ public AstyanaxConfigurationImpl setTargetCassandraVersion(String version) {
+ this.targetCassandraVersion = version;
+ return this;
+ }
}
@@ -25,7 +25,7 @@ public static Partitioner get() {
return instance;
}
- protected BigInteger127Partitioner() {
+ public BigInteger127Partitioner() {
}
@@ -33,6 +33,11 @@
import com.google.common.io.Resources;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
+/**
+ * Use EmbeddedCassandraFactory
+ * @author elandau
+ *
+ */
public class EmbeddedCassandra {
private static final Logger LOG = LoggerFactory.getLogger(EmbeddedCassandra.class);
File renamed without changes.
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
+<log4j:configuration>
+ <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
+ </layout>
+ </appender>
+ <root>
+ <priority value="info"></priority>
+ <appender-ref ref="stdout"/>
+ </root>
+</log4j:configuration>
@@ -31,7 +31,6 @@
import com.netflix.astyanax.connectionpool.OperationFilterFactory;
import com.netflix.astyanax.connectionpool.RetryBackoffStrategy;
import com.netflix.astyanax.connectionpool.SSLConnectionContext;
-import com.netflix.astyanax.partitioner.BigInteger127Partitioner;
import com.netflix.astyanax.partitioner.Partitioner;
import com.netflix.astyanax.shallows.EmptyBadHostDetectorImpl;
import com.netflix.astyanax.shallows.EmptyLatencyScoreStrategyImpl;
@@ -68,9 +67,11 @@
public static final float DEFAULT_MIN_HOST_IN_POOL_RATIO = 0.65f;
public static final int DEFAULT_BLOCKED_THREAD_THRESHOLD = 10;
public static final BadHostDetector DEFAULT_BAD_HOST_DETECTOR = EmptyBadHostDetectorImpl.getInstance();
- public static final Partitioner DEFAULT_PARTITIONER = BigInteger127Partitioner.get();
+// public static final Partitioner DEFAULT_PARTITIONER = BigInteger127Partitioner.get();
private static final int DEFAULT_RECONNECT_THREAD_COUNT = 5;
private static final int DEFAULT_MAINTAINANCE_THREAD_COUNT = 1;
+
+ private static final String DEFAULT_PARTITIONER_CLASS = "com.netflix.astyanax.partitioner.BigInteger127Partitioner";
private final String name;
@@ -106,7 +107,7 @@
private BadHostDetector badHostDetector = DEFAULT_BAD_HOST_DETECTOR;
private AuthenticationCredentials credentials = null;
private OperationFilterFactory filterFactory = EmptyOperationFilterFactory.getInstance();
- private Partitioner partitioner = DEFAULT_PARTITIONER;
+ private Partitioner partitioner = null;
private SSLConnectionContext sslCtx;
private ScheduledExecutorService maintainanceExecutor;
@@ -125,6 +126,14 @@ public ConnectionPoolConfigurationImpl(String name) {
@Override
public void initialize() {
+ if (partitioner == null) {
+ try {
+ partitioner = (Partitioner) Class.forName(DEFAULT_PARTITIONER_CLASS).newInstance();
+ } catch (Throwable t) {
+ throw new RuntimeException("Can't instantiate default partitioner " + DEFAULT_PARTITIONER_CLASS, t);
+ }
+ }
+
if (maintainanceExecutor == null) {
maintainanceExecutor = Executors.newScheduledThreadPool(DEFAULT_MAINTAINANCE_THREAD_COUNT, new ThreadFactoryBuilder().setDaemon(true).build());
bOwnMaintainanceExecutor = true;
@@ -34,7 +34,6 @@
import com.netflix.astyanax.connectionpool.exceptions.ThrottledException;
import com.netflix.astyanax.connectionpool.exceptions.UnknownException;
import com.netflix.astyanax.connectionpool.impl.OperationResultImpl;
-import com.netflix.astyanax.thrift.ThriftConverter;
public class TestConnectionFactory implements ConnectionFactory<TestClient> {
private final ConnectionPoolConfiguration config;
@@ -74,8 +73,13 @@ public TestConnectionFactory(ConnectionPoolConfiguration config,
} catch (Exception e) {
long now = System.nanoTime();
latency = now - startTime;
- ConnectionException connectionException = ThriftConverter
- .ToConnectionPoolException(e).setLatency(latency);
+ ConnectionException connectionException;
+ if (!(e instanceof ConnectionException))
+ connectionException = new UnknownException(e);
+ else
+ connectionException = (ConnectionException)e;
+ connectionException.setLatency(latency);
+
if (!(connectionException instanceof IsTimeoutException)) {
pool.addLatencySample(latency, now);
}
Oops, something went wrong.

0 comments on commit b52e984

Please sign in to comment.