Skip to content

Commit 991b8b0

Browse files
committed
Rename CoreConsistencyLevel to DefaultConsistencyLevel
1 parent e0c6b2f commit 991b8b0

8 files changed

Lines changed: 33 additions & 33 deletions

File tree

core/src/main/java/com/datastax/oss/driver/api/core/ConsistencyLevel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* <p>The only reason to model this as an interface (as opposed to an enum type) is to accommodate
2222
* for custom protocol extensions. If you're connecting to a standard Apache Cassandra cluster, all
23-
* {@code ConsistencyLevel}s are {@link CoreConsistencyLevel} instances.
23+
* {@code ConsistencyLevel}s are {@link DefaultConsistencyLevel} instances.
2424
*/
2525
public interface ConsistencyLevel {
2626

core/src/main/java/com/datastax/oss/driver/api/core/CoreConsistencyLevel.java renamed to core/src/main/java/com/datastax/oss/driver/api/core/DefaultConsistencyLevel.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.util.Map;
2121

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

3838
private final int protocolCode;
3939

40-
CoreConsistencyLevel(int protocolCode) {
40+
DefaultConsistencyLevel(int protocolCode) {
4141
this.protocolCode = protocolCode;
4242
}
4343

@@ -46,19 +46,19 @@ public int getProtocolCode() {
4646
return protocolCode;
4747
}
4848

49-
public static CoreConsistencyLevel fromCode(int code) {
50-
CoreConsistencyLevel level = BY_CODE.get(code);
49+
public static DefaultConsistencyLevel fromCode(int code) {
50+
DefaultConsistencyLevel level = BY_CODE.get(code);
5151
if (level == null) {
5252
throw new IllegalArgumentException("Unknown code: " + code);
5353
}
5454
return level;
5555
}
5656

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

59-
private static Map<Integer, CoreConsistencyLevel> mapByCode(CoreConsistencyLevel[] levels) {
60-
ImmutableMap.Builder<Integer, CoreConsistencyLevel> builder = ImmutableMap.builder();
61-
for (CoreConsistencyLevel level : levels) {
59+
private static Map<Integer, DefaultConsistencyLevel> mapByCode(DefaultConsistencyLevel[] levels) {
60+
ImmutableMap.Builder<Integer, DefaultConsistencyLevel> builder = ImmutableMap.builder();
61+
for (DefaultConsistencyLevel level : levels) {
6262
builder.put(level.protocolCode, level);
6363
}
6464
return builder.build();

core/src/main/java/com/datastax/oss/driver/internal/core/DefaultConsistencyLevelRegistry.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@
1616
package com.datastax.oss.driver.internal.core;
1717

1818
import com.datastax.oss.driver.api.core.ConsistencyLevel;
19-
import com.datastax.oss.driver.api.core.CoreConsistencyLevel;
19+
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
2020
import com.google.common.collect.ImmutableList;
2121

2222
public class DefaultConsistencyLevelRegistry implements ConsistencyLevelRegistry {
2323

2424
private static final ImmutableList<ConsistencyLevel> values =
25-
ImmutableList.<ConsistencyLevel>builder().add(CoreConsistencyLevel.values()).build();
25+
ImmutableList.<ConsistencyLevel>builder().add(DefaultConsistencyLevel.values()).build();
2626

2727
@Override
2828
public ConsistencyLevel fromCode(int code) {
29-
return CoreConsistencyLevel.fromCode(code);
29+
return DefaultConsistencyLevel.fromCode(code);
3030
}
3131

3232
@Override
3333
public ConsistencyLevel fromName(String name) {
34-
return CoreConsistencyLevel.valueOf(name);
34+
return DefaultConsistencyLevel.valueOf(name);
3535
}
3636

3737
@Override

core/src/test/java/com/datastax/oss/driver/api/core/retry/DefaultRetryPolicyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package com.datastax.oss.driver.api.core.retry;
1717

18-
import static com.datastax.oss.driver.api.core.CoreConsistencyLevel.QUORUM;
18+
import static com.datastax.oss.driver.api.core.DefaultConsistencyLevel.QUORUM;
1919
import static com.datastax.oss.driver.api.core.retry.RetryDecision.RETHROW;
2020
import static com.datastax.oss.driver.api.core.retry.RetryDecision.RETRY_NEXT;
2121
import static com.datastax.oss.driver.api.core.retry.RetryDecision.RETRY_SAME;

core/src/test/java/com/datastax/oss/driver/internal/core/cql/CqlRequestHandlerRetryTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import static org.mockito.Mockito.atMost;
2323

2424
import com.datastax.oss.driver.TestDataProviders;
25-
import com.datastax.oss.driver.api.core.CoreConsistencyLevel;
25+
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
2626
import com.datastax.oss.driver.api.core.connection.HeartbeatException;
2727
import com.datastax.oss.driver.api.core.cql.AsyncResultSet;
2828
import com.datastax.oss.driver.api.core.cql.ExecutionInfo;
@@ -370,7 +370,7 @@ public void mockRetryPolicyDecision(RetryPolicy policy, RetryDecision decision)
370370
Mockito.when(
371371
policy.onReadTimeout(
372372
any(SimpleStatement.class),
373-
eq(CoreConsistencyLevel.LOCAL_ONE),
373+
eq(DefaultConsistencyLevel.LOCAL_ONE),
374374
eq(2),
375375
eq(1),
376376
eq(true),
@@ -401,7 +401,7 @@ public void mockRetryPolicyDecision(RetryPolicy policy, RetryDecision decision)
401401
Mockito.when(
402402
policy.onWriteTimeout(
403403
any(SimpleStatement.class),
404-
eq(CoreConsistencyLevel.LOCAL_ONE),
404+
eq(DefaultConsistencyLevel.LOCAL_ONE),
405405
eq(CoreWriteType.SIMPLE),
406406
eq(2),
407407
eq(1),
@@ -428,7 +428,7 @@ public void mockRetryPolicyDecision(RetryPolicy policy, RetryDecision decision)
428428
Mockito.when(
429429
policy.onUnavailable(
430430
any(SimpleStatement.class),
431-
eq(CoreConsistencyLevel.LOCAL_ONE),
431+
eq(DefaultConsistencyLevel.LOCAL_ONE),
432432
eq(2),
433433
eq(1),
434434
eq(0)))

core/src/test/java/com/datastax/oss/driver/internal/core/cql/QueryTraceFetcherTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import static org.mockito.ArgumentMatchers.anyLong;
2121
import static org.mockito.Mockito.times;
2222

23-
import com.datastax.oss.driver.api.core.CoreConsistencyLevel;
2423
import com.datastax.oss.driver.api.core.CqlSession;
24+
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
2525
import com.datastax.oss.driver.api.core.config.CoreDriverOption;
2626
import com.datastax.oss.driver.api.core.config.DriverConfigProfile;
2727
import com.datastax.oss.driver.api.core.cql.AsyncResultSet;
@@ -96,13 +96,13 @@ public void setup() {
9696
Mockito.when(config.getDuration(CoreDriverOption.REQUEST_TRACE_INTERVAL))
9797
.thenReturn(Duration.ZERO);
9898
Mockito.when(config.getString(CoreDriverOption.REQUEST_CONSISTENCY))
99-
.thenReturn(CoreConsistencyLevel.LOCAL_ONE.name());
99+
.thenReturn(DefaultConsistencyLevel.LOCAL_ONE.name());
100100
Mockito.when(config.getString(CoreDriverOption.REQUEST_TRACE_CONSISTENCY))
101-
.thenReturn(CoreConsistencyLevel.ONE.name());
101+
.thenReturn(DefaultConsistencyLevel.ONE.name());
102102

103103
Mockito.when(
104104
config.withString(
105-
CoreDriverOption.REQUEST_CONSISTENCY, CoreConsistencyLevel.ONE.name()))
105+
CoreDriverOption.REQUEST_CONSISTENCY, DefaultConsistencyLevel.ONE.name()))
106106
.thenReturn(traceConfig);
107107

108108
Mockito.when(context.consistencyLevelRegistry())

core/src/test/java/com/datastax/oss/driver/internal/core/cql/RequestHandlerTestHarness.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import static org.mockito.ArgumentMatchers.anyInt;
2020
import static org.mockito.ArgumentMatchers.anyString;
2121

22-
import com.datastax.oss.driver.api.core.CoreConsistencyLevel;
2322
import com.datastax.oss.driver.api.core.CqlIdentifier;
23+
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
2424
import com.datastax.oss.driver.api.core.ProtocolVersion;
2525
import com.datastax.oss.driver.api.core.config.CoreDriverOption;
2626
import com.datastax.oss.driver.api.core.config.DriverConfig;
@@ -95,10 +95,10 @@ private RequestHandlerTestHarness(Builder builder) {
9595
Mockito.when(defaultConfigProfile.getDuration(CoreDriverOption.REQUEST_TIMEOUT))
9696
.thenReturn(Duration.ofMillis(500));
9797
Mockito.when(defaultConfigProfile.getString(CoreDriverOption.REQUEST_CONSISTENCY))
98-
.thenReturn(CoreConsistencyLevel.LOCAL_ONE.name());
98+
.thenReturn(DefaultConsistencyLevel.LOCAL_ONE.name());
9999
Mockito.when(defaultConfigProfile.getInt(CoreDriverOption.REQUEST_PAGE_SIZE)).thenReturn(5000);
100100
Mockito.when(defaultConfigProfile.getString(CoreDriverOption.REQUEST_SERIAL_CONSISTENCY))
101-
.thenReturn(CoreConsistencyLevel.SERIAL.name());
101+
.thenReturn(DefaultConsistencyLevel.SERIAL.name());
102102
Mockito.when(defaultConfigProfile.getBoolean(CoreDriverOption.REQUEST_DEFAULT_IDEMPOTENCE))
103103
.thenReturn(builder.defaultIdempotence);
104104
Mockito.when(defaultConfigProfile.getBoolean(CoreDriverOption.PREPARE_ON_ALL_NODES))

integration-tests/src/test/java/com/datastax/oss/driver/api/core/retry/DefaultRetryPolicyIT.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import static org.assertj.core.api.Assertions.fail;
2828

2929
import com.datastax.oss.driver.api.core.AllNodesFailedException;
30-
import com.datastax.oss.driver.api.core.CoreConsistencyLevel;
3130
import com.datastax.oss.driver.api.core.CqlSession;
31+
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
3232
import com.datastax.oss.driver.api.core.connection.ClosedConnectionException;
3333
import com.datastax.oss.driver.api.core.cql.ResultSet;
3434
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
@@ -114,7 +114,7 @@ public void should_not_retry_on_read_timeout_when_data_present() {
114114
fail("Expected a ReadTimeoutException");
115115
} catch (ReadTimeoutException rte) {
116116
// then a read timeout exception is thrown
117-
assertThat(rte.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
117+
assertThat(rte.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
118118
assertThat(rte.getReceived()).isEqualTo(1);
119119
assertThat(rte.getBlockFor()).isEqualTo(3);
120120
assertThat(rte.wasDataPresent()).isTrue();
@@ -137,7 +137,7 @@ public void should_not_retry_on_read_timeout_when_less_than_blockFor_received()
137137
fail("Expected a ReadTimeoutException");
138138
} catch (ReadTimeoutException rte) {
139139
// then a read timeout exception is thrown
140-
assertThat(rte.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
140+
assertThat(rte.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
141141
assertThat(rte.getReceived()).isEqualTo(2);
142142
assertThat(rte.getBlockFor()).isEqualTo(3);
143143
assertThat(rte.wasDataPresent()).isFalse();
@@ -160,7 +160,7 @@ public void should_retry_on_read_timeout_when_enough_responses_and_data_not_pres
160160
fail("Expected a ReadTimeoutException");
161161
} catch (ReadTimeoutException rte) {
162162
// then a read timeout exception is thrown.
163-
assertThat(rte.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
163+
assertThat(rte.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
164164
assertThat(rte.getReceived()).isEqualTo(3);
165165
assertThat(rte.getBlockFor()).isEqualTo(3);
166166
assertThat(rte.wasDataPresent()).isFalse();
@@ -275,7 +275,7 @@ public void should_retry_on_write_timeout_if_write_type_batch_log() {
275275
fail("WriteTimeoutException expected");
276276
} catch (WriteTimeoutException wte) {
277277
// then a write timeout exception is thrown
278-
assertThat(wte.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
278+
assertThat(wte.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
279279
assertThat(wte.getReceived()).isEqualTo(1);
280280
assertThat(wte.getBlockFor()).isEqualTo(3);
281281
assertThat(wte.getWriteType()).isEqualTo(CoreWriteType.BATCH_LOG);
@@ -314,7 +314,7 @@ public void should_not_retry_on_write_timeout_if_write_type_non_batch_log(
314314
fail("WriteTimeoutException expected");
315315
} catch (WriteTimeoutException wte) {
316316
// then a write timeout exception is thrown
317-
assertThat(wte.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
317+
assertThat(wte.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
318318
assertThat(wte.getReceived()).isEqualTo(1);
319319
assertThat(wte.getBlockFor()).isEqualTo(3);
320320
}
@@ -339,7 +339,7 @@ public void should_not_retry_on_write_timeout_if_write_type_batch_log_but_non_id
339339
fail("WriteTimeoutException expected");
340340
} catch (WriteTimeoutException wte) {
341341
// then a write timeout exception is thrown
342-
assertThat(wte.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
342+
assertThat(wte.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
343343
assertThat(wte.getReceived()).isEqualTo(1);
344344
assertThat(wte.getBlockFor()).isEqualTo(3);
345345
assertThat(wte.getWriteType()).isEqualTo(CoreWriteType.BATCH_LOG);
@@ -389,7 +389,7 @@ public void should_only_retry_once_on_unavailable() {
389389
// tried).
390390
assertThat(ue.getCoordinator().getConnectAddress())
391391
.isEqualTo(simulacron.cluster().node(1).inetSocketAddress());
392-
assertThat(ue.getConsistencyLevel()).isEqualTo(CoreConsistencyLevel.LOCAL_QUORUM);
392+
assertThat(ue.getConsistencyLevel()).isEqualTo(DefaultConsistencyLevel.LOCAL_QUORUM);
393393
assertThat(ue.getRequired()).isEqualTo(3);
394394
assertThat(ue.getAlive()).isEqualTo(0);
395395
}

0 commit comments

Comments
 (0)