Java Code Examples for com.datastax.driver.core.ConsistencyLevel#SERIAL

The following examples show how to use com.datastax.driver.core.ConsistencyLevel#SERIAL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatementHandler.java    From scalardb with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a {@link ConsistencyLevel} based on the specified {@link Operation} and {@link
 * Consistency}
 *
 * @param operation an {@code Operation}
 * @param consistency a {@code Consistency}
 * @return a {@code ConsistencyLevel}
 */
public static ConsistencyLevel convert(Operation operation, Consistency consistency) {
  switch (consistency) {
    case SEQUENTIAL:
      return ConsistencyLevel.QUORUM;
    case EVENTUAL:
      return ConsistencyLevel.ONE;
    case LINEARIZABLE:
      if (operation instanceof Selection) {
        // setConsistencyLevel() with SERIAL is only valid when an operation is read.
        // when an operation is write, it comes with conditional update and consistency level is
        // automatically set in overwriteConsistency().
        return ConsistencyLevel.SERIAL;
      } else {
        return ConsistencyLevel.QUORUM;
      }
    default:
      LOGGER.warn("Unsupported consistency is specified. SEQUENTIAL is being used instead.");
      return ConsistencyLevel.QUORUM;
  }
}
 
Example 2
Source File: CassandraConsistenciesConfiguration.java    From james-project with Apache License 2.0 5 votes vote down vote up
public static ConsistencyLevel fromString(String value) {
    switch (value) {
        case "QUORUM":
            return ConsistencyLevel.QUORUM;
        case "LOCAL_QUORUM":
            return ConsistencyLevel.LOCAL_QUORUM;
        case "EACH_QUORUM":
            return ConsistencyLevel.EACH_QUORUM;
        case "SERIAL":
            return ConsistencyLevel.SERIAL;
        case "LOCAL_SERIAL":
            return ConsistencyLevel.LOCAL_SERIAL;
    }
    throw new IllegalArgumentException("'" + value + "' is not a value ConsistencyLevel");
}