当前位置: 首页>>代码示例>>Java>>正文


Java ConsistencyLevel.valueOf方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:22,代码来源:SettingsCommand.java

示例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());
    }
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:24,代码来源:SettingsCommand.java

示例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));
    }

}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:41,代码来源:CassandraBase.java

示例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;
}
 
开发者ID:dvasilen,项目名称:Hive-Cassandra,代码行数:20,代码来源:CassandraAbstractPut.java

示例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());
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:49,代码来源:SettingsCommand.java

示例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());
    }
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:47,代码来源:SettingsCommand.java

示例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();
}
 
开发者ID:dvasilen,项目名称:Hive-Cassandra,代码行数:50,代码来源:ColumnFamilyWideRowRecordReader.java


注:本文中的org.apache.cassandra.thrift.ConsistencyLevel.valueOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。