Skip to content

Commit

Permalink
Rename CoreConsistencyLevel to DefaultConsistencyLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
olim7t committed Feb 12, 2018
1 parent e0c6b2f commit 991b8b0
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
Expand Up @@ -20,7 +20,7 @@
*
* <p>The only reason to model this as an interface (as opposed to an enum type) is to accommodate
* for custom protocol extensions. If you're connecting to a standard Apache Cassandra cluster, all
* {@code ConsistencyLevel}s are {@link CoreConsistencyLevel} instances.
* {@code ConsistencyLevel}s are {@link DefaultConsistencyLevel} instances.
*/
public interface ConsistencyLevel {

Expand Down
Expand Up @@ -20,7 +20,7 @@
import java.util.Map;

/** A default consistency level supported by the driver out of the box. */
public enum CoreConsistencyLevel implements ConsistencyLevel {
public enum DefaultConsistencyLevel implements ConsistencyLevel {
ANY(ProtocolConstants.ConsistencyLevel.ANY),
ONE(ProtocolConstants.ConsistencyLevel.ONE),
TWO(ProtocolConstants.ConsistencyLevel.TWO),
Expand All @@ -37,7 +37,7 @@ public enum CoreConsistencyLevel implements ConsistencyLevel {

private final int protocolCode;

CoreConsistencyLevel(int protocolCode) {
DefaultConsistencyLevel(int protocolCode) {
this.protocolCode = protocolCode;
}

Expand All @@ -46,19 +46,19 @@ public int getProtocolCode() {
return protocolCode;
}

public static CoreConsistencyLevel fromCode(int code) {
CoreConsistencyLevel level = BY_CODE.get(code);
public static DefaultConsistencyLevel fromCode(int code) {
DefaultConsistencyLevel level = BY_CODE.get(code);
if (level == null) {
throw new IllegalArgumentException("Unknown code: " + code);
}
return level;
}

private static Map<Integer, CoreConsistencyLevel> BY_CODE = mapByCode(values());
private static Map<Integer, DefaultConsistencyLevel> BY_CODE = mapByCode(values());

private static Map<Integer, CoreConsistencyLevel> mapByCode(CoreConsistencyLevel[] levels) {
ImmutableMap.Builder<Integer, CoreConsistencyLevel> builder = ImmutableMap.builder();
for (CoreConsistencyLevel level : levels) {
private static Map<Integer, DefaultConsistencyLevel> mapByCode(DefaultConsistencyLevel[] levels) {
ImmutableMap.Builder<Integer, DefaultConsistencyLevel> builder = ImmutableMap.builder();
for (DefaultConsistencyLevel level : levels) {
builder.put(level.protocolCode, level);
}
return builder.build();
Expand Down
Expand Up @@ -16,22 +16,22 @@
package com.datastax.oss.driver.internal.core;

import com.datastax.oss.driver.api.core.ConsistencyLevel;
import com.datastax.oss.driver.api.core.CoreConsistencyLevel;
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
import com.google.common.collect.ImmutableList;

public class DefaultConsistencyLevelRegistry implements ConsistencyLevelRegistry {

private static final ImmutableList<ConsistencyLevel> values =
ImmutableList.<ConsistencyLevel>builder().add(CoreConsistencyLevel.values()).build();
ImmutableList.<ConsistencyLevel>builder().add(DefaultConsistencyLevel.values()).build();

@Override
public ConsistencyLevel fromCode(int code) {
return CoreConsistencyLevel.fromCode(code);
return DefaultConsistencyLevel.fromCode(code);
}

@Override
public ConsistencyLevel fromName(String name) {
return CoreConsistencyLevel.valueOf(name);
return DefaultConsistencyLevel.valueOf(name);
}

@Override
Expand Down
Expand Up @@ -15,7 +15,7 @@
*/
package com.datastax.oss.driver.api.core.retry;

import static com.datastax.oss.driver.api.core.CoreConsistencyLevel.QUORUM;
import static com.datastax.oss.driver.api.core.DefaultConsistencyLevel.QUORUM;
import static com.datastax.oss.driver.api.core.retry.RetryDecision.RETHROW;
import static com.datastax.oss.driver.api.core.retry.RetryDecision.RETRY_NEXT;
import static com.datastax.oss.driver.api.core.retry.RetryDecision.RETRY_SAME;
Expand Down
Expand Up @@ -22,7 +22,7 @@
import static org.mockito.Mockito.atMost;

import com.datastax.oss.driver.TestDataProviders;
import com.datastax.oss.driver.api.core.CoreConsistencyLevel;
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
import com.datastax.oss.driver.api.core.connection.HeartbeatException;
import com.datastax.oss.driver.api.core.cql.AsyncResultSet;
import com.datastax.oss.driver.api.core.cql.ExecutionInfo;
Expand Down Expand Up @@ -370,7 +370,7 @@ public void mockRetryPolicyDecision(RetryPolicy policy, RetryDecision decision)
Mockito.when(
policy.onReadTimeout(
any(SimpleStatement.class),
eq(CoreConsistencyLevel.LOCAL_ONE),
eq(DefaultConsistencyLevel.LOCAL_ONE),
eq(2),
eq(1),
eq(true),
Expand Down Expand Up @@ -401,7 +401,7 @@ public void mockRetryPolicyDecision(RetryPolicy policy, RetryDecision decision)
Mockito.when(
policy.onWriteTimeout(
any(SimpleStatement.class),
eq(CoreConsistencyLevel.LOCAL_ONE),
eq(DefaultConsistencyLevel.LOCAL_ONE),
eq(CoreWriteType.SIMPLE),
eq(2),
eq(1),
Expand All @@ -428,7 +428,7 @@ public void mockRetryPolicyDecision(RetryPolicy policy, RetryDecision decision)
Mockito.when(
policy.onUnavailable(
any(SimpleStatement.class),
eq(CoreConsistencyLevel.LOCAL_ONE),
eq(DefaultConsistencyLevel.LOCAL_ONE),
eq(2),
eq(1),
eq(0)))
Expand Down
Expand Up @@ -20,8 +20,8 @@
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.times;

import com.datastax.oss.driver.api.core.CoreConsistencyLevel;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
import com.datastax.oss.driver.api.core.config.CoreDriverOption;
import com.datastax.oss.driver.api.core.config.DriverConfigProfile;
import com.datastax.oss.driver.api.core.cql.AsyncResultSet;
Expand Down Expand Up @@ -96,13 +96,13 @@ public void setup() {
Mockito.when(config.getDuration(CoreDriverOption.REQUEST_TRACE_INTERVAL))
.thenReturn(Duration.ZERO);
Mockito.when(config.getString(CoreDriverOption.REQUEST_CONSISTENCY))
.thenReturn(CoreConsistencyLevel.LOCAL_ONE.name());
.thenReturn(DefaultConsistencyLevel.LOCAL_ONE.name());
Mockito.when(config.getString(CoreDriverOption.REQUEST_TRACE_CONSISTENCY))
.thenReturn(CoreConsistencyLevel.ONE.name());
.thenReturn(DefaultConsistencyLevel.ONE.name());

Mockito.when(
config.withString(
CoreDriverOption.REQUEST_CONSISTENCY, CoreConsistencyLevel.ONE.name()))
CoreDriverOption.REQUEST_CONSISTENCY, DefaultConsistencyLevel.ONE.name()))
.thenReturn(traceConfig);

Mockito.when(context.consistencyLevelRegistry())
Expand Down
Expand Up @@ -19,8 +19,8 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;

import com.datastax.oss.driver.api.core.CoreConsistencyLevel;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
import com.datastax.oss.driver.api.core.ProtocolVersion;
import com.datastax.oss.driver.api.core.config.CoreDriverOption;
import com.datastax.oss.driver.api.core.config.DriverConfig;
Expand Down Expand Up @@ -95,10 +95,10 @@ private RequestHandlerTestHarness(Builder builder) {
Mockito.when(defaultConfigProfile.getDuration(CoreDriverOption.REQUEST_TIMEOUT))
.thenReturn(Duration.ofMillis(500));
Mockito.when(defaultConfigProfile.getString(CoreDriverOption.REQUEST_CONSISTENCY))
.thenReturn(CoreConsistencyLevel.LOCAL_ONE.name());
.thenReturn(DefaultConsistencyLevel.LOCAL_ONE.name());
Mockito.when(defaultConfigProfile.getInt(CoreDriverOption.REQUEST_PAGE_SIZE)).thenReturn(5000);
Mockito.when(defaultConfigProfile.getString(CoreDriverOption.REQUEST_SERIAL_CONSISTENCY))
.thenReturn(CoreConsistencyLevel.SERIAL.name());
.thenReturn(DefaultConsistencyLevel.SERIAL.name());
Mockito.when(defaultConfigProfile.getBoolean(CoreDriverOption.REQUEST_DEFAULT_IDEMPOTENCE))
.thenReturn(builder.defaultIdempotence);
Mockito.when(defaultConfigProfile.getBoolean(CoreDriverOption.PREPARE_ON_ALL_NODES))
Expand Down
Expand Up @@ -27,8 +27,8 @@
import static org.assertj.core.api.Assertions.fail;

import com.datastax.oss.driver.api.core.AllNodesFailedException;
import com.datastax.oss.driver.api.core.CoreConsistencyLevel;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
import com.datastax.oss.driver.api.core.connection.ClosedConnectionException;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
Expand Down Expand Up @@ -114,7 +114,7 @@ public void should_not_retry_on_read_timeout_when_data_present() {
fail("Expected a ReadTimeoutException");
} catch (ReadTimeoutException rte) {
// then a read timeout exception is thrown
assertThat(rte.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
assertThat(rte.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
assertThat(rte.getReceived()).isEqualTo(1);
assertThat(rte.getBlockFor()).isEqualTo(3);
assertThat(rte.wasDataPresent()).isTrue();
Expand All @@ -137,7 +137,7 @@ public void should_not_retry_on_read_timeout_when_less_than_blockFor_received()
fail("Expected a ReadTimeoutException");
} catch (ReadTimeoutException rte) {
// then a read timeout exception is thrown
assertThat(rte.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
assertThat(rte.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
assertThat(rte.getReceived()).isEqualTo(2);
assertThat(rte.getBlockFor()).isEqualTo(3);
assertThat(rte.wasDataPresent()).isFalse();
Expand All @@ -160,7 +160,7 @@ public void should_retry_on_read_timeout_when_enough_responses_and_data_not_pres
fail("Expected a ReadTimeoutException");
} catch (ReadTimeoutException rte) {
// then a read timeout exception is thrown.
assertThat(rte.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
assertThat(rte.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
assertThat(rte.getReceived()).isEqualTo(3);
assertThat(rte.getBlockFor()).isEqualTo(3);
assertThat(rte.wasDataPresent()).isFalse();
Expand Down Expand Up @@ -275,7 +275,7 @@ public void should_retry_on_write_timeout_if_write_type_batch_log() {
fail("WriteTimeoutException expected");
} catch (WriteTimeoutException wte) {
// then a write timeout exception is thrown
assertThat(wte.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
assertThat(wte.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
assertThat(wte.getReceived()).isEqualTo(1);
assertThat(wte.getBlockFor()).isEqualTo(3);
assertThat(wte.getWriteType()).isEqualTo(CoreWriteType.BATCH_LOG);
Expand Down Expand Up @@ -314,7 +314,7 @@ public void should_not_retry_on_write_timeout_if_write_type_non_batch_log(
fail("WriteTimeoutException expected");
} catch (WriteTimeoutException wte) {
// then a write timeout exception is thrown
assertThat(wte.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
assertThat(wte.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
assertThat(wte.getReceived()).isEqualTo(1);
assertThat(wte.getBlockFor()).isEqualTo(3);
}
Expand All @@ -339,7 +339,7 @@ public void should_not_retry_on_write_timeout_if_write_type_batch_log_but_non_id
fail("WriteTimeoutException expected");
} catch (WriteTimeoutException wte) {
// then a write timeout exception is thrown
assertThat(wte.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
assertThat(wte.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
assertThat(wte.getReceived()).isEqualTo(1);
assertThat(wte.getBlockFor()).isEqualTo(3);
assertThat(wte.getWriteType()).isEqualTo(CoreWriteType.BATCH_LOG);
Expand Down Expand Up @@ -389,7 +389,7 @@ public void should_only_retry_once_on_unavailable() {
// tried).
assertThat(ue.getCoordinator().getConnectAddress())
.isEqualTo(simulacron.cluster().node(1).inetSocketAddress());
assertThat(ue.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
assertThat(ue.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
assertThat(ue.getRequired()).isEqualTo(3);
assertThat(ue.getAlive()).isEqualTo(0);
}
Expand Down

0 comments on commit 991b8b0

Please sign in to comment.