@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -17,7 +17,7 @@ package org.springframework.cassandra.core;
|
||||
|
||||
/**
|
||||
* Generic Consistency Levels associated with Cassandra.
|
||||
*
|
||||
*
|
||||
* @author David Webb
|
||||
* @author Antoine Toulme
|
||||
* @deprecated Use the driver's {@link com.datastax.driver.core.ConsistencyLevel}.
|
||||
@@ -40,7 +40,7 @@ public enum ConsistencyLevel {
|
||||
/**
|
||||
* @deprecated Use {@link #EACH_QUORUM}
|
||||
*/
|
||||
@Deprecated EACH_QUOROM, //
|
||||
@Deprecated EACH_QUOROM,
|
||||
|
||||
ALL, LOCAL_ONE, SERIAL, LOCAL_SERIAL,
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -19,7 +19,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Determine driver consistency level based on ConsistencyLevel
|
||||
*
|
||||
*
|
||||
* @author David Webb
|
||||
* @author Antoine Toulme
|
||||
* @deprecated Use the driver's {@link com.datastax.driver.core.ConsistencyLevel}.
|
||||
@@ -34,17 +34,16 @@ public final class ConsistencyLevelResolver {
|
||||
|
||||
/**
|
||||
* Decode the generic spring data cassandra enum to the type required by the DataStax Driver.
|
||||
*
|
||||
*
|
||||
* @param level the consistency level to resolve, must not be {@literal null}.
|
||||
* @return The DataStax Driver Consistency Level.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static com.datastax.driver.core.ConsistencyLevel resolve(ConsistencyLevel level) {
|
||||
|
||||
Assert.notNull(level, "ConsistencyLevel must not be null");
|
||||
|
||||
/*
|
||||
* Determine the driver level based on our enum
|
||||
*/
|
||||
// Determine the driver ConsistencyLevel based on SD Cassandra's enum
|
||||
switch (level) {
|
||||
case ONE:
|
||||
return com.datastax.driver.core.ConsistencyLevel.ONE;
|
||||
|
||||
@@ -137,10 +137,9 @@ public class CqlTemplate extends CassandraAccessor implements CqlOperations {
|
||||
* @param queryOptions query options (e.g. consistency level) to add to the Cassandra {@link PreparedStatement}.
|
||||
*/
|
||||
public static PreparedStatement addPreparedStatementOptions(PreparedStatement preparedStatement,
|
||||
QueryOptions queryOptions) {
|
||||
QueryOptions queryOptions) {
|
||||
|
||||
if (queryOptions != null) {
|
||||
|
||||
if (queryOptions.getDriverConsistencyLevel() != null) {
|
||||
preparedStatement.setConsistencyLevel(queryOptions.getDriverConsistencyLevel());
|
||||
} else if (queryOptions.getConsistencyLevel() != null) {
|
||||
@@ -167,7 +166,6 @@ public class CqlTemplate extends CassandraAccessor implements CqlOperations {
|
||||
public static <T extends Statement> T addQueryOptions(T statement, QueryOptions queryOptions) {
|
||||
|
||||
if (queryOptions != null) {
|
||||
|
||||
if (queryOptions.getDriverConsistencyLevel() != null) {
|
||||
statement.setConsistencyLevel(queryOptions.getDriverConsistencyLevel());
|
||||
} else if (queryOptions.getConsistencyLevel() != null) {
|
||||
@@ -180,14 +178,14 @@ public class CqlTemplate extends CassandraAccessor implements CqlOperations {
|
||||
statement.setRetryPolicy(RetryPolicyResolver.resolve(queryOptions.getRetryPolicy()));
|
||||
}
|
||||
|
||||
if (queryOptions.getReadTimeout() != null) {
|
||||
statement.setReadTimeoutMillis(queryOptions.getReadTimeout().intValue());
|
||||
}
|
||||
|
||||
if (queryOptions.getFetchSize() != null) {
|
||||
statement.setFetchSize(queryOptions.getFetchSize());
|
||||
}
|
||||
|
||||
if (queryOptions.getReadTimeout() != null) {
|
||||
statement.setReadTimeoutMillis(queryOptions.getReadTimeout().intValue());
|
||||
}
|
||||
|
||||
if (queryOptions.getTracing() != null) {
|
||||
if (queryOptions.getTracing()) {
|
||||
statement.enableTracing();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -24,7 +24,7 @@ import com.datastax.driver.core.SocketOptions;
|
||||
/**
|
||||
* Cassandra Query Options for queries. {@link QueryOptions} allow tuning of various query options on a per-request
|
||||
* level. Only options that are set are applied to queries.
|
||||
*
|
||||
*
|
||||
* @author David Webb
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@@ -36,10 +36,12 @@ public class QueryOptions {
|
||||
private RetryPolicy retryPolicy;
|
||||
private com.datastax.driver.core.policies.RetryPolicy driverRetryPolicy;
|
||||
|
||||
private Long readTimeout;
|
||||
private Integer fetchSize;
|
||||
private Boolean tracing;
|
||||
|
||||
private Integer fetchSize;
|
||||
|
||||
private Long readTimeout;
|
||||
|
||||
/**
|
||||
* Creates new {@link QueryOptions}.
|
||||
*/
|
||||
@@ -47,7 +49,7 @@ public class QueryOptions {
|
||||
|
||||
/**
|
||||
* Creates new {@link QueryOptions} for the given {@link ConsistencyLevel} and {@link RetryPolicy}.
|
||||
*
|
||||
*
|
||||
* @param consistencyLevel the consistency level, may be {@literal null}.
|
||||
* @param retryPolicy the retry policy, may be {@literal null}.
|
||||
*/
|
||||
@@ -58,7 +60,7 @@ public class QueryOptions {
|
||||
|
||||
/**
|
||||
* Creates a new {@link QueryOptionsBuilder}.
|
||||
*
|
||||
*
|
||||
* @return a new {@link QueryOptionsBuilder}.
|
||||
* @since 1.5
|
||||
*/
|
||||
@@ -68,7 +70,7 @@ public class QueryOptions {
|
||||
|
||||
/**
|
||||
* Returns the {@link ConsistencyLevel}.
|
||||
*
|
||||
*
|
||||
* @return the consistencyLevel.
|
||||
* @deprecated Use {@link #setConsistencyLevel(com.datastax.driver.core.ConsistencyLevel)}
|
||||
*/
|
||||
@@ -80,7 +82,7 @@ public class QueryOptions {
|
||||
/**
|
||||
* Sets the driver {@link ConsistencyLevel}. Setting both ({@link ConsistencyLevel} and
|
||||
* {@link com.datastax.driver.core.ConsistencyLevel driver ConsistencyLevel}) consistency levels is not supported.
|
||||
*
|
||||
*
|
||||
* @param consistencyLevel the consistencyLevel to set.
|
||||
* @throws IllegalStateException if the {@link com.datastax.driver.core.ConsistencyLevel driver ConsistencyLevel} is
|
||||
* set
|
||||
@@ -172,30 +174,6 @@ public class QueryOptions {
|
||||
return driverRetryPolicy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the read timeout in milliseconds. Overrides the default per-host read timeout (
|
||||
* {@link SocketOptions#getReadTimeoutMillis()}).
|
||||
*
|
||||
* @param readTimeout the read timeout in milliseconds. Negative values are not allowed. If it is {@code 0}, the read timeout
|
||||
* will be disabled for this statement.
|
||||
* @since 1.5
|
||||
* @see SocketOptions#getReadTimeoutMillis()
|
||||
* @see com.datastax.driver.core.Cluster.Builder#withSocketOptions(SocketOptions)
|
||||
*/
|
||||
public void setReadTimeout(long readTimeout) {
|
||||
|
||||
Assert.isTrue(readTimeout >= 0, "ReadTimeout must be greater or equal to zero");
|
||||
this.readTimeout = readTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the read timeout in milliseconds. May be {@literal null} if not set.
|
||||
* @since 1.5
|
||||
*/
|
||||
protected Long getReadTimeout() {
|
||||
return readTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the query fetch size for {@link com.datastax.driver.core.ResultSet} chunks.
|
||||
* <p>
|
||||
@@ -211,7 +189,7 @@ public class QueryOptions {
|
||||
*/
|
||||
public void setFetchSize(int fetchSize) {
|
||||
|
||||
Assert.isTrue(fetchSize >= 0, "FetchSize must be greater or equal to zero");
|
||||
Assert.isTrue(fetchSize >= 0, "FetchSize must be greater than equal to zero");
|
||||
this.fetchSize = fetchSize;
|
||||
}
|
||||
|
||||
@@ -223,6 +201,30 @@ public class QueryOptions {
|
||||
return fetchSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the read timeout in milliseconds. Overrides the default per-host read timeout (
|
||||
* {@link SocketOptions#getReadTimeoutMillis()}).
|
||||
*
|
||||
* @param readTimeout the read timeout in milliseconds. Negative values are not allowed. If it is {@code 0}, the read timeout
|
||||
* will be disabled for this statement.
|
||||
* @since 1.5
|
||||
* @see SocketOptions#getReadTimeoutMillis()
|
||||
* @see com.datastax.driver.core.Cluster.Builder#withSocketOptions(SocketOptions)
|
||||
*/
|
||||
public void setReadTimeout(long readTimeout) {
|
||||
|
||||
Assert.isTrue(readTimeout >= 0, "ReadTimeout must be greater than equal to zero");
|
||||
this.readTimeout = readTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the read timeout in milliseconds. May be {@literal null} if not set.
|
||||
* @since 1.5
|
||||
*/
|
||||
protected Long getReadTimeout() {
|
||||
return readTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables statement tracing.
|
||||
*
|
||||
@@ -253,12 +255,28 @@ public class QueryOptions {
|
||||
private RetryPolicy retryPolicy;
|
||||
private com.datastax.driver.core.policies.RetryPolicy driverRetryPolicy;
|
||||
|
||||
private Long readTimeout;
|
||||
private Integer fetchSize;
|
||||
private Boolean tracing;
|
||||
|
||||
private Integer fetchSize;
|
||||
|
||||
private Long readTimeout;
|
||||
|
||||
QueryOptionsBuilder() {}
|
||||
|
||||
/**
|
||||
* Sets the {@link com.datastax.driver.core.ConsistencyLevel} to use.
|
||||
*
|
||||
* @param driverConsistencyLevel must not be {@literal null}.
|
||||
* @return {@code this} {@link QueryOptionsBuilder}
|
||||
*/
|
||||
public QueryOptionsBuilder consistencyLevel(com.datastax.driver.core.ConsistencyLevel driverConsistencyLevel) {
|
||||
|
||||
Assert.notNull(driverConsistencyLevel, "Driver ConsistencyLevel must not be null");
|
||||
|
||||
this.driverConsistencyLevel = driverConsistencyLevel;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link RetryPolicy} to use. Setting both ({@link RetryPolicy} and
|
||||
* {@link com.datastax.driver.core.policies.RetryPolicy driver RetryPolicy}) retry policies is not supported.
|
||||
@@ -297,16 +315,23 @@ public class QueryOptions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link com.datastax.driver.core.ConsistencyLevel} to use.
|
||||
* Sets the query fetch size for {@link com.datastax.driver.core.ResultSet} chunks.
|
||||
* <p>
|
||||
* The fetch size controls how much resulting rows will be retrieved simultaneously (the goal being to avoid loading
|
||||
* too much results in memory for queries yielding large results). Please note that while value as low as 1 can be
|
||||
* used, it is *highly* discouraged to use such a low value in practice as it will yield very poor performance.
|
||||
*
|
||||
* @param driverConsistencyLevel must not be {@literal null}.
|
||||
* @param fetchSize the number of rows to fetch per chunking request. To disable chunking of the result set, use
|
||||
* {@code fetchSize == Integer.MAX_VALUE}. Negative values are not allowed.
|
||||
* @return {@code this} {@link QueryOptionsBuilder}
|
||||
* @see com.datastax.driver.core.QueryOptions#getFetchSize()
|
||||
* @see com.datastax.driver.core.Cluster.Builder#withQueryOptions(com.datastax.driver.core.QueryOptions)
|
||||
*/
|
||||
public QueryOptionsBuilder consistencyLevel(com.datastax.driver.core.ConsistencyLevel driverConsistencyLevel) {
|
||||
public QueryOptionsBuilder fetchSize(int fetchSize) {
|
||||
|
||||
Assert.notNull(driverConsistencyLevel, "Driver ConsistencyLevel must not be null");
|
||||
Assert.isTrue(fetchSize >= 0, "FetchSize must be greater or equal to zero");
|
||||
|
||||
this.driverConsistencyLevel = driverConsistencyLevel;
|
||||
this.fetchSize = fetchSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -348,27 +373,6 @@ public class QueryOptions {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the query fetch size for {@link com.datastax.driver.core.ResultSet} chunks.
|
||||
* <p>
|
||||
* The fetch size controls how much resulting rows will be retrieved simultaneously (the goal being to avoid loading
|
||||
* too much results in memory for queries yielding large results). Please note that while value as low as 1 can be
|
||||
* used, it is *highly* discouraged to use such a low value in practice as it will yield very poor performance.
|
||||
*
|
||||
* @param fetchSize the number of rows to fetch per chunking request. To disable chunking of the result set, use
|
||||
* {@code fetchSize == Integer.MAX_VALUE}. Negative values are not allowed.
|
||||
* @return {@code this} {@link QueryOptionsBuilder}
|
||||
* @see com.datastax.driver.core.QueryOptions#getFetchSize()
|
||||
* @see com.datastax.driver.core.Cluster.Builder#withQueryOptions(com.datastax.driver.core.QueryOptions)
|
||||
*/
|
||||
public QueryOptionsBuilder fetchSize(int fetchSize) {
|
||||
|
||||
Assert.isTrue(fetchSize >= 0, "FetchSize must be greater or equal to zero");
|
||||
|
||||
this.fetchSize = fetchSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables statement tracing.
|
||||
*
|
||||
@@ -383,7 +387,7 @@ public class QueryOptions {
|
||||
|
||||
/**
|
||||
* Enables statement tracing.
|
||||
*
|
||||
*
|
||||
* @return {@code this} {@link QueryOptionsBuilder}
|
||||
*/
|
||||
public QueryOptionsBuilder withTracing() {
|
||||
@@ -405,14 +409,14 @@ public class QueryOptions {
|
||||
queryOptions.setRetryPolicy(retryPolicy);
|
||||
queryOptions.setRetryPolicy(driverRetryPolicy);
|
||||
|
||||
if (readTimeout != null) {
|
||||
queryOptions.setReadTimeout(readTimeout);
|
||||
}
|
||||
|
||||
if (fetchSize != null) {
|
||||
queryOptions.setFetchSize(fetchSize);
|
||||
}
|
||||
|
||||
if (readTimeout != null) {
|
||||
queryOptions.setReadTimeout(readTimeout);
|
||||
}
|
||||
|
||||
if (tracing != null) {
|
||||
queryOptions.setTracing(tracing);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -21,7 +21,9 @@ package org.springframework.cassandra.core;
|
||||
*
|
||||
* @author David Webb
|
||||
* @author Mark Paluch
|
||||
* @deprecated Use the driver's {@link com.datastax.driver.core.policies.RetryPolicy}.
|
||||
*/
|
||||
@Deprecated
|
||||
public enum RetryPolicy {
|
||||
|
||||
DEFAULT, DOWNGRADING_CONSISTENCY, FALLTHROUGH,
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.datastax.driver.core.policies.FallthroughRetryPolicy;
|
||||
*
|
||||
* @author David Webb
|
||||
*/
|
||||
@Deprecated
|
||||
public final class RetryPolicyResolver {
|
||||
|
||||
/**
|
||||
@@ -33,17 +34,16 @@ public final class RetryPolicyResolver {
|
||||
|
||||
/**
|
||||
* Decode the generic spring data cassandra enum to the type required by the DataStax Driver.
|
||||
*
|
||||
*
|
||||
* @param level
|
||||
* @return The DataStax Driver Consistency Level.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static com.datastax.driver.core.policies.RetryPolicy resolve(RetryPolicy policy) {
|
||||
|
||||
com.datastax.driver.core.policies.RetryPolicy resolvedPolicy = DefaultRetryPolicy.INSTANCE;
|
||||
com.datastax.driver.core.policies.RetryPolicy resolvedPolicy;
|
||||
|
||||
/*
|
||||
* Determine the driver level based on our enum
|
||||
*/
|
||||
// Determine the driver RetryPolicy based on SD Cassandra's enum
|
||||
switch (policy) {
|
||||
case DEFAULT:
|
||||
resolvedPolicy = DefaultRetryPolicy.INSTANCE;
|
||||
@@ -60,6 +60,5 @@ public final class RetryPolicyResolver {
|
||||
}
|
||||
|
||||
return resolvedPolicy;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* Cassandra Write Options are an extension to {@link QueryOptions} for write operations. {@link WriteOptions}allow
|
||||
* tuning of various query options on a per-request level. Only options that are set are applied to queries.
|
||||
*
|
||||
*
|
||||
* @author David Webb
|
||||
* @author Mark Paluch
|
||||
* @see QueryOptions
|
||||
@@ -36,7 +36,7 @@ public class WriteOptions extends QueryOptions {
|
||||
|
||||
/**
|
||||
* Creates new {@link WriteOptions} for the given {@link ConsistencyLevel} and {@link RetryPolicy}.
|
||||
*
|
||||
*
|
||||
* @param consistencyLevel the consistency level, may be {@literal null}.
|
||||
* @param retryPolicy the retry policy, may be {@literal null}.
|
||||
*/
|
||||
@@ -46,7 +46,7 @@ public class WriteOptions extends QueryOptions {
|
||||
|
||||
/**
|
||||
* Creates new {@link WriteOptions} for the given {@link ConsistencyLevel}, {@link RetryPolicy} and {@code ttl}.
|
||||
*
|
||||
*
|
||||
* @param consistencyLevel the consistency level, may be {@literal null}.
|
||||
* @param retryPolicy the retry policy, may be {@literal null}.
|
||||
* @param ttl the ttl, may be {@literal null}.
|
||||
@@ -75,7 +75,7 @@ public class WriteOptions extends QueryOptions {
|
||||
|
||||
/**
|
||||
* Sets the time to live for write operations.
|
||||
*
|
||||
*
|
||||
* @param ttl the ttl to set.
|
||||
*/
|
||||
public void setTtl(Integer ttl) {
|
||||
@@ -94,6 +94,15 @@ public class WriteOptions extends QueryOptions {
|
||||
|
||||
private WriteOptionsBuilder() {}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.QueryOptions.QueryOptionsBuilder#consistencyLevel(com.datastax.driver.core.ConsistencyLevel)
|
||||
*/
|
||||
@Override
|
||||
public WriteOptionsBuilder consistencyLevel(com.datastax.driver.core.ConsistencyLevel driverConsistencyLevel) {
|
||||
return (WriteOptionsBuilder) super.consistencyLevel(driverConsistencyLevel);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.QueryOptions.QueryOptionsBuilder#retryPolicy(org.springframework.cassandra.core.RetryPolicy)
|
||||
@@ -112,34 +121,7 @@ public class WriteOptions extends QueryOptions {
|
||||
return (WriteOptionsBuilder) super.retryPolicy(retryPolicy);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.QueryOptions.QueryOptionsBuilder#consistencyLevel(com.datastax.driver.core.ConsistencyLevel)
|
||||
*/
|
||||
@Override
|
||||
public WriteOptionsBuilder consistencyLevel(com.datastax.driver.core.ConsistencyLevel driverConsistencyLevel) {
|
||||
return (WriteOptionsBuilder) super.consistencyLevel(driverConsistencyLevel);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.QueryOptions.QueryOptionsBuilder#readTimeout(long)
|
||||
*/
|
||||
@Override
|
||||
public WriteOptionsBuilder readTimeout(long readTimeout) {
|
||||
return (WriteOptionsBuilder) super.readTimeout(readTimeout);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.QueryOptions.QueryOptionsBuilder#readTimeout(long, java.util.concurrent.TimeUnit)
|
||||
*/
|
||||
@Override
|
||||
public WriteOptionsBuilder readTimeout(long readTimeout, TimeUnit timeUnit) {
|
||||
return (WriteOptionsBuilder) super.readTimeout(readTimeout, timeUnit);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.QueryOptions.QueryOptionsBuilder#fetchSize(int)
|
||||
*/
|
||||
@@ -148,7 +130,25 @@ public class WriteOptions extends QueryOptions {
|
||||
return (WriteOptionsBuilder) super.fetchSize(fetchSize);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.QueryOptions.QueryOptionsBuilder#readTimeout(long)
|
||||
*/
|
||||
@Override
|
||||
public WriteOptionsBuilder readTimeout(long readTimeout) {
|
||||
return (WriteOptionsBuilder) super.readTimeout(readTimeout);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.QueryOptions.QueryOptionsBuilder#readTimeout(long, java.util.concurrent.TimeUnit)
|
||||
*/
|
||||
@Override
|
||||
public WriteOptionsBuilder readTimeout(long readTimeout, TimeUnit timeUnit) {
|
||||
return (WriteOptionsBuilder) super.readTimeout(readTimeout, timeUnit);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.QueryOptions.QueryOptionsBuilder#tracing(boolean)
|
||||
*/
|
||||
@@ -157,7 +157,7 @@ public class WriteOptions extends QueryOptions {
|
||||
return (WriteOptionsBuilder) super.tracing(tracing);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.cassandra.core.QueryOptions.QueryOptionsBuilder#withTracing()
|
||||
*/
|
||||
|
||||
@@ -67,13 +67,13 @@ public class CqlTemplateUnitTests {
|
||||
|
||||
private CqlTemplate template;
|
||||
|
||||
@Mock private Session mockSession;
|
||||
@Mock private Insert mockInsert;
|
||||
|
||||
@Mock private PreparedStatement mockPreparedStatement;
|
||||
|
||||
@Mock private Statement mockStatement;
|
||||
@Mock private Session mockSession;
|
||||
|
||||
@Mock private Insert mockInsert;
|
||||
@Mock private Statement mockStatement;
|
||||
|
||||
@Mock private Update mockUpdate;
|
||||
|
||||
@@ -449,8 +449,8 @@ public class CqlTemplateUnitTests {
|
||||
@Test
|
||||
public void addPreparedStatementOptionsShouldAddOurQueryOptions() {
|
||||
|
||||
QueryOptions queryOptions = QueryOptions.builder() //
|
||||
.retryPolicy(RetryPolicy.FALLTHROUGH).build();
|
||||
QueryOptions queryOptions = QueryOptions.builder().retryPolicy(RetryPolicy.FALLTHROUGH).build();
|
||||
|
||||
queryOptions.setConsistencyLevel(org.springframework.cassandra.core.ConsistencyLevel.LOCAL_QUOROM);
|
||||
|
||||
template.addPreparedStatementOptions(mockPreparedStatement, queryOptions);
|
||||
@@ -465,7 +465,8 @@ public class CqlTemplateUnitTests {
|
||||
@Test
|
||||
public void addStatementQueryOptionsShouldAddDriverQueryOptions() {
|
||||
|
||||
QueryOptions queryOptions = QueryOptions.builder().consistencyLevel(ConsistencyLevel.EACH_QUORUM) //
|
||||
QueryOptions queryOptions = QueryOptions.builder()
|
||||
.consistencyLevel(ConsistencyLevel.EACH_QUORUM) //
|
||||
.retryPolicy(FallthroughRetryPolicy.INSTANCE) //
|
||||
.build();
|
||||
|
||||
@@ -481,9 +482,8 @@ public class CqlTemplateUnitTests {
|
||||
@Test
|
||||
public void addStatementQueryOptionsShouldAddOurQueryOptions() {
|
||||
|
||||
QueryOptions queryOptions = QueryOptions.builder() //
|
||||
.retryPolicy(RetryPolicy.FALLTHROUGH) //
|
||||
.build();
|
||||
QueryOptions queryOptions = QueryOptions.builder().retryPolicy(RetryPolicy.FALLTHROUGH).build();
|
||||
|
||||
queryOptions.setConsistencyLevel(org.springframework.cassandra.core.ConsistencyLevel.LOCAL_QUOROM);
|
||||
|
||||
template.addQueryOptions(mockStatement, queryOptions);
|
||||
@@ -512,8 +512,8 @@ public class CqlTemplateUnitTests {
|
||||
public void addStatementQueryOptionsShouldAddGenericQueryOptions() {
|
||||
|
||||
QueryOptions queryOptions = QueryOptions.builder() //
|
||||
.readTimeout(1, TimeUnit.MINUTES) //
|
||||
.fetchSize(10) //
|
||||
.readTimeout(1, TimeUnit.MINUTES) //
|
||||
.withTracing() //
|
||||
.build();
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.datastax.driver.core.policies.LoggingRetryPolicy;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link QueryOptions}.
|
||||
*
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class QueryOptionsUnitTests {
|
||||
@@ -90,9 +90,7 @@ public class QueryOptionsUnitTests {
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void builderShouldRejectSettingOurAndDriverRetryPolicy() {
|
||||
|
||||
QueryOptions.builder() //
|
||||
.retryPolicy(RetryPolicy.DEFAULT).retryPolicy(FallthroughRetryPolicy.INSTANCE);
|
||||
QueryOptions.builder().retryPolicy(RetryPolicy.DEFAULT).retryPolicy(FallthroughRetryPolicy.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,11 +98,7 @@ public class QueryOptionsUnitTests {
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void builderShouldRejectSettingDriverAndOurRetryPolicy() {
|
||||
|
||||
QueryOptions.builder() //
|
||||
.retryPolicy(FallthroughRetryPolicy.INSTANCE)//
|
||||
.retryPolicy(RetryPolicy.DEFAULT);
|
||||
|
||||
QueryOptions.builder().retryPolicy(FallthroughRetryPolicy.INSTANCE).retryPolicy(RetryPolicy.DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.datastax.driver.core.policies.FallthroughRetryPolicy;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link WriteOptions}.
|
||||
*
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class WriteOptionsUnitTests {
|
||||
@@ -61,9 +61,7 @@ public class WriteOptionsUnitTests {
|
||||
@Test
|
||||
public void buildReadTimeoutOptionsWriteOptions() {
|
||||
|
||||
WriteOptions writeOptions = WriteOptions.builder() //
|
||||
.readTimeout(1, TimeUnit.MINUTES)//
|
||||
.build(); //
|
||||
WriteOptions writeOptions = WriteOptions.builder().readTimeout(1, TimeUnit.MINUTES).build();
|
||||
|
||||
assertThat(writeOptions.getReadTimeout(), is(60L * 1000L));
|
||||
assertThat(writeOptions.getFetchSize(), is(nullValue()));
|
||||
@@ -76,9 +74,7 @@ public class WriteOptionsUnitTests {
|
||||
@Test
|
||||
public void buildQueryOptionsWithDriverRetryPolicy() {
|
||||
|
||||
QueryOptions writeOptions = QueryOptions.builder() //
|
||||
.retryPolicy(FallthroughRetryPolicy.INSTANCE) //
|
||||
.build(); //
|
||||
QueryOptions writeOptions = QueryOptions.builder().retryPolicy(FallthroughRetryPolicy.INSTANCE).build();
|
||||
|
||||
assertThat(writeOptions.getRetryPolicy(), is(nullValue()));
|
||||
assertThat(writeOptions.getDriverRetryPolicy(),
|
||||
@@ -91,9 +87,7 @@ public class WriteOptionsUnitTests {
|
||||
@Test
|
||||
public void buildQueryOptionsWithRetryPolicy() {
|
||||
|
||||
QueryOptions writeOptions = QueryOptions.builder() //
|
||||
.retryPolicy(RetryPolicy.DOWNGRADING_CONSISTENCY) //
|
||||
.build(); //
|
||||
QueryOptions writeOptions = QueryOptions.builder().retryPolicy(RetryPolicy.DOWNGRADING_CONSISTENCY).build();
|
||||
|
||||
assertThat(writeOptions.getRetryPolicy(), is(RetryPolicy.DOWNGRADING_CONSISTENCY));
|
||||
assertThat(writeOptions.getDriverRetryPolicy(), is(nullValue()));
|
||||
@@ -104,9 +98,7 @@ public class WriteOptionsUnitTests {
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void builderShouldRejectSettingOurAndDriverRetryPolicy() {
|
||||
|
||||
WriteOptions.builder() //
|
||||
.retryPolicy(RetryPolicy.DEFAULT).retryPolicy(FallthroughRetryPolicy.INSTANCE);
|
||||
WriteOptions.builder().retryPolicy(RetryPolicy.DEFAULT).retryPolicy(FallthroughRetryPolicy.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,10 +106,6 @@ public class WriteOptionsUnitTests {
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void builderShouldRejectSettingDriverAndOurRetryPolicy() {
|
||||
|
||||
WriteOptions.builder() //
|
||||
.retryPolicy(FallthroughRetryPolicy.INSTANCE)//
|
||||
.retryPolicy(RetryPolicy.DEFAULT);
|
||||
|
||||
WriteOptions.builder().retryPolicy(FallthroughRetryPolicy.INSTANCE).retryPolicy(RetryPolicy.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user