本文整理汇总了Java中org.apache.cassandra.thrift.ConsistencyLevel.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java ConsistencyLevel.valueOf方法的具体用法?Java ConsistencyLevel.valueOf怎么用?Java ConsistencyLevel.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.thrift.ConsistencyLevel
的用法示例。
在下文中一共展示了ConsistencyLevel.valueOf方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SettingsCommand
import org.apache.cassandra.thrift.ConsistencyLevel; //导入方法依赖的package包/类
public SettingsCommand(Command type, Options options, Count count, Uncertainty uncertainty)
{
this.type = type;
this.tries = Math.max(1, Integer.parseInt(options.retries.value()) + 1);
this.ignoreErrors = options.ignoreErrors.setByUser();
this.consistencyLevel = ConsistencyLevel.valueOf(options.consistencyLevel.value().toUpperCase());
if (count != null)
{
this.count = Long.parseLong(count.count.value());
this.targetUncertainty = -1;
this.minimumUncertaintyMeasurements = -1;
this.maximumUncertaintyMeasurements = -1;
}
else
{
this.count = -1;
this.targetUncertainty = Double.parseDouble(uncertainty.uncertainty.value());
this.minimumUncertaintyMeasurements = Integer.parseInt(uncertainty.minMeasurements.value());
this.maximumUncertaintyMeasurements = Integer.parseInt(uncertainty.maxMeasurements.value());
}
}
示例2: SettingsCommand
import org.apache.cassandra.thrift.ConsistencyLevel; //导入方法依赖的package包/类
public SettingsCommand(Command type, Options options, Count count, Uncertainty uncertainty)
{
this.type = type;
this.tries = Math.max(1, Integer.parseInt(options.retries.value()) + 1);
this.ignoreErrors = options.ignoreErrors.setByUser();
this.consistencyLevel = ConsistencyLevel.valueOf(options.consistencyLevel.value().toUpperCase());
this.keysAtOnce = Integer.parseInt(options.atOnce.value());
this.add = options.add.get();
if (count != null)
{
this.count = Long.parseLong(count.count.value());
this.targetUncertainty = -1;
this.minimumUncertaintyMeasurements = -1;
this.maximumUncertaintyMeasurements = -1;
}
else
{
this.count = -1;
this.targetUncertainty = Double.parseDouble(uncertainty.uncertainty.value());
this.minimumUncertaintyMeasurements = Integer.parseInt(uncertainty.minMeasurements.value());
this.maximumUncertaintyMeasurements = Integer.parseInt(uncertainty.maxMeasurements.value());
}
}
示例3: CassandraBase
import org.apache.cassandra.thrift.ConsistencyLevel; //导入方法依赖的package包/类
public CassandraBase(String instance, Map<String, String> config) {
// The configuration has the following:
// keyspace
// columnParent
// readConsitency (optional)
// writeConsistency (optional)
messageCatalog = new Messages("Cassandra");
// The connection to Cassandra comes from RaptureCASSANDRA.cfg
// and has host and port
cassHost = MultiValueConfigLoader.getConfig("CASSANDRA-" + instance + ".host");
if (cassHost == null) {
cassHost = "localhost";
}
String cassPortString = MultiValueConfigLoader.getConfig("CASSANDRA-" + instance + ".port");
if (cassPortString == null) {
cassPortString = "9160";
}
cassPort = Integer.valueOf(cassPortString);
keySpace = config.get(CassandraConstants.KEYSPACECFG);
columnFamily = config.get(CassandraConstants.CFCFG);
try {
getConnection();
} catch (TTransportException e) {
throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, messageCatalog.getMessage("DbCommsError"), e);
}
ensureAllPresent();
if (config.containsKey(CassandraConstants.READ_CONSISTENCY)) {
readCL = ConsistencyLevel.valueOf(config.get(CassandraConstants.READ_CONSISTENCY));
}
if (config.containsKey(CassandraConstants.WRITE_CONSISTENCY)) {
writeCL = ConsistencyLevel.valueOf(config.get(CassandraConstants.WRITE_CONSISTENCY));
}
}
示例4: getConsistencyLevel
import org.apache.cassandra.thrift.ConsistencyLevel; //导入方法依赖的package包/类
/**
* Parse consistency level from job configuration. If none is defined, or if the specified value is not a valid
* <code>ConsistencyLevel</code>, return default consistency level ONE.
*
* @param jc job configuration
* @return cassandra consistency level
*/
protected static ConsistencyLevel getConsistencyLevel(JobConf jc) {
String consistencyLevel = jc.get(AbstractColumnSerDe.CASSANDRA_CONSISTENCY_LEVEL,
AbstractColumnSerDe.DEFAULT_CONSISTENCY_LEVEL);
ConsistencyLevel level = null;
try {
level = ConsistencyLevel.valueOf(consistencyLevel);
} catch (IllegalArgumentException e) {
level = ConsistencyLevel.ONE;
}
return level;
}
示例5: SettingsCommand
import org.apache.cassandra.thrift.ConsistencyLevel; //导入方法依赖的package包/类
public SettingsCommand(Command type, Options options, Count count, Duration duration, Uncertainty uncertainty)
{
this.type = type;
this.consistencyLevel = ConsistencyLevel.valueOf(options.consistencyLevel.value().toUpperCase());
this.noWarmup = options.noWarmup.setByUser();
this.truncate = TruncateWhen.valueOf(options.truncate.value().toUpperCase());
if (count != null)
{
this.count = OptionDistribution.parseLong(count.count.value());
this.duration = 0;
this.durationUnits = null;
this.targetUncertainty = -1;
this.minimumUncertaintyMeasurements = -1;
this.maximumUncertaintyMeasurements = -1;
}
else if (duration != null)
{
this.count = -1;
this.duration = Long.parseLong(duration.duration.value().substring(0, duration.duration.value().length() - 1));
switch (duration.duration.value().toLowerCase().charAt(duration.duration.value().length() - 1))
{
case 's':
this.durationUnits = TimeUnit.SECONDS;
break;
case 'm':
this.durationUnits = TimeUnit.MINUTES;
break;
case 'h':
this.durationUnits = TimeUnit.HOURS;
break;
default:
throw new IllegalStateException();
}
this.targetUncertainty = -1;
this.minimumUncertaintyMeasurements = -1;
this.maximumUncertaintyMeasurements = -1;
}
else
{
this.count = -1;
this.duration = 0;
this.durationUnits = null;
this.targetUncertainty = Double.parseDouble(uncertainty.uncertainty.value());
this.minimumUncertaintyMeasurements = Integer.parseInt(uncertainty.minMeasurements.value());
this.maximumUncertaintyMeasurements = Integer.parseInt(uncertainty.maxMeasurements.value());
}
}
示例6: SettingsCommand
import org.apache.cassandra.thrift.ConsistencyLevel; //导入方法依赖的package包/类
public SettingsCommand(Command type, Options options, Count count, Duration duration, Uncertainty uncertainty)
{
this.type = type;
this.consistencyLevel = ConsistencyLevel.valueOf(options.consistencyLevel.value().toUpperCase());
this.noWarmup = options.noWarmup.setByUser();
if (count != null)
{
this.count = Long.parseLong(count.count.value());
this.duration = 0;
this.durationUnits = null;
this.targetUncertainty = -1;
this.minimumUncertaintyMeasurements = -1;
this.maximumUncertaintyMeasurements = -1;
}
else if (duration != null)
{
this.count = -1;
this.duration = Long.parseLong(duration.duration.value().substring(0, duration.duration.value().length() - 1));
switch (duration.duration.value().toLowerCase().charAt(duration.duration.value().length() - 1))
{
case 's':
this.durationUnits = TimeUnit.SECONDS;
break;
case 'm':
this.durationUnits = TimeUnit.MINUTES;
break;
case 'h':
this.durationUnits = TimeUnit.HOURS;
break;
default:
throw new IllegalStateException();
}
this.targetUncertainty = -1;
this.minimumUncertaintyMeasurements = -1;
this.maximumUncertaintyMeasurements = -1;
}
else
{
this.count = -1;
this.duration = 0;
this.durationUnits = null;
this.targetUncertainty = Double.parseDouble(uncertainty.uncertainty.value());
this.minimumUncertaintyMeasurements = Integer.parseInt(uncertainty.minMeasurements.value());
this.maximumUncertaintyMeasurements = Integer.parseInt(uncertainty.maxMeasurements.value());
}
}
示例7: initialize
import org.apache.cassandra.thrift.ConsistencyLevel; //导入方法依赖的package包/类
@Override
public void initialize(InputSplit split, TaskAttemptContext context) throws IOException {
this.split = (ColumnFamilySplit) split;
Configuration conf = context.getConfiguration();
predicate = ConfigHelper.getInputSlicePredicate(conf);
if (!isSliceRangePredicate(predicate)) {
throw new AssertionError("WideRowsRequire a slice range");
}
totalRowCount = ConfigHelper.getInputSplitSize(conf);
Log.info("total rows = "+totalRowCount);
batchRowCount = 1;
rowPageSize = predicate.getSlice_range().getCount();
startSlicePredicate = predicate.getSlice_range().start;
cfName = ConfigHelper.getInputColumnFamily(conf);
consistencyLevel = ConsistencyLevel.valueOf(ConfigHelper.getReadConsistencyLevel(conf));
keyspace = ConfigHelper.getInputKeyspace(conf);
try {
// only need to connect once
if (socket != null && socket.isOpen()) {
return;
}
// create connection using thrift
String location = getLocation();
socket = new TSocket(location, ConfigHelper.getInputRpcPort(conf));
TBinaryProtocol binaryProtocol = new TBinaryProtocol(new TFramedTransport(socket));
client = new Cassandra.Client(binaryProtocol);
socket.open();
// log in
client.set_keyspace(keyspace);
if (ConfigHelper.getInputKeyspaceUserName(conf) != null) {
Map<String, String> creds = new HashMap<String, String>();
creds.put(IAuthenticator.USERNAME_KEY, ConfigHelper.getInputKeyspaceUserName(conf));
creds.put(IAuthenticator.PASSWORD_KEY, ConfigHelper.getInputKeyspacePassword(conf));
AuthenticationRequest authRequest = new AuthenticationRequest(creds);
client.login(authRequest);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
iter = new WideRowIterator();
}