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


Java ScanPolicy类代码示例

本文整理汇总了Java中com.aerospike.client.policy.ScanPolicy的典型用法代码示例。如果您正苦于以下问题:Java ScanPolicy类的具体用法?Java ScanPolicy怎么用?Java ScanPolicy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ScanPolicy类属于com.aerospike.client.policy包,在下文中一共展示了ScanPolicy类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scanAllWorkaround

import com.aerospike.client.policy.ScanPolicy; //导入依赖的package包/类
final void scanAllWorkaround(ScanPolicy policy, String namespace, String setName, ScanCallback callback, String... bins)
      throws AerospikeException {
    while (true) {
      try {
        client.scanAll(policy, namespace, setName, callback, bins);
        break;
      } catch (AerospikeException e) {
        int resultCode = e.getResultCode();
//        System.err.format("Retrying scanAll of %-6s %s %s\n", setName, ResultCode.getResultString(resultCode), e);
        if (resultCode != ResultCode.PARAMETER_ERROR) {
          throw e;
        }
        // Keep trying until we're past the client library bug with transaction ID.
      }
    }
  }
 
开发者ID:aerospike,项目名称:geospatial-samples,代码行数:17,代码来源:AerospikeDatabase.java

示例2: AsyncScan

import com.aerospike.client.policy.ScanPolicy; //导入依赖的package包/类
public AsyncScan(
	AsyncMultiExecutor parent,
	AsyncCluster cluster,
	AsyncNode node,
	ScanPolicy policy,
	RecordSequenceListener listener,
	String namespace,
	String setName,
	String[] binNames
) {
	super(parent, cluster, node, true);
	this.policy = policy;
	this.listener = listener;
	this.namespace = namespace;
	this.setName = setName;
	this.binNames = binNames;
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:18,代码来源:AsyncScan.java

示例3: AsyncScanExecutor

import com.aerospike.client.policy.ScanPolicy; //导入依赖的package包/类
public AsyncScanExecutor(
	AsyncCluster cluster,
	ScanPolicy policy,
	RecordSequenceListener listener,
	String namespace,
	String setName,
	String[] binNames
) throws AerospikeException {
	this.listener = listener;

	Node[] nodes = cluster.getNodes();
	if (nodes.length == 0) {
		throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Scan failed because cluster is empty.");
	}

	completedSize = nodes.length;

	for (Node node : nodes) {			
		AsyncScan async = new AsyncScan(this, cluster, (AsyncNode)node, policy, listener, namespace, setName, binNames);
		async.execute();
	}
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:23,代码来源:AsyncScanExecutor.java

示例4: runScan

import com.aerospike.client.policy.ScanPolicy; //导入依赖的package包/类
/**
 * Scan all nodes in parallel and read all records in a List.
 * @param client
 * @param namespace
 * @param set
 */
public List<Record> runScan(AerospikeClient client, String namespace, String set) 
		throws Exception 
{
	console.debug("Scan parallel: namespace=" + namespace + " set=" + set);
	recordCount = 0;
	long begin = System.currentTimeMillis();
	ScanPolicy policy = new ScanPolicy();
	client.scanAll(policy, namespace, set, this);

	long end = System.currentTimeMillis();
	double seconds =  (double)(end - begin) / 1000.0;
	console.debug("Total records returned: " + recordCount);
	console.debug("Elapsed time: " + seconds + " seconds");
	double performance = Math.round((double)recordCount / seconds);
	console.debug("Records/second: " + performance);
	return recordList;
}
 
开发者ID:aerospike,项目名称:url-tracker,代码行数:24,代码来源:ScanSet.java

示例5: runScan

import com.aerospike.client.policy.ScanPolicy; //导入依赖的package包/类
/**
 * Scan all nodes in parallel and return the KEYS of all of the records
 * in a list.
 * @param client
 * @param namespace
 * @param set
 */
public List<Key> runScan(AerospikeClient client, String namespace, String set) 
		throws Exception 
{
	console.debug("Scan parallel: namespace=" + namespace + " set=" + set);
	recordCount = 0;
	long begin = System.currentTimeMillis();
	ScanPolicy policy = new ScanPolicy();
	client.scanAll(policy, namespace, set, this);

	long end = System.currentTimeMillis();
	double seconds =  (double)(end - begin) / 1000.0;
	console.debug("Total records returned: " + recordCount);
	console.debug("Elapsed time: " + seconds + " seconds");
	double performance = Math.round((double)recordCount / seconds);
	console.debug("Records/second: " + performance);
	return keyList;
}
 
开发者ID:aerospike,项目名称:url-tracker,代码行数:25,代码来源:ScanKeySet.java

示例6: clearSet

import com.aerospike.client.policy.ScanPolicy; //导入依赖的package包/类
void clearSet(String setName) {
  ScanPolicy scanPolicy = new ScanPolicy();
  scanPolicy.timeout = 100;
  try {
    // Scan the entire Set using scanAll(). This will scan each node
    // in the cluster and return the record Digest to the call back object
    ClearScanCallback callback = new ClearScanCallback();
    scanAllWorkaround(scanPolicy, namespace, setName, callback);
    System.out.println("Deleted " + callback.count + " records from set " + setName);
  } catch (AerospikeException e) {
    int resultCode = e.getResultCode();
    System.err.format("scanAll to clear set: %s %s %s\n", setName, ResultCode.getResultString(resultCode), e);
  }
}
 
开发者ID:aerospike,项目名称:geospatial-samples,代码行数:15,代码来源:AerospikeDatabase.java

示例7: ScanCommand

import com.aerospike.client.policy.ScanPolicy; //导入依赖的package包/类
public ScanCommand(
	Node node,
	ScanPolicy policy,
	String namespace,
	String setName,
	ScanCallback callback,
	String[] binNames
) {
	super(node);
	this.policy = policy;
	this.namespace = namespace;
	this.setName = setName;
	this.callback = callback;
	this.binNames = binNames;
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:16,代码来源:ScanCommand.java

示例8: ScanExecutor

import com.aerospike.client.policy.ScanPolicy; //导入依赖的package包/类
public ScanExecutor(Cluster cluster, Node[] nodes, ScanPolicy policy, String namespace, String setName, ScanCallback callback, String[] binNames) {
	this.completedCount = new AtomicInteger();
	this.threadPool = cluster.getThreadPool();
	
	// Initialize threads.		
	threads = new ScanThread[nodes.length];
	
	for (int i = 0; i < nodes.length; i++) {
		ScanCommand command = new ScanCommand(nodes[i], policy, namespace, setName, callback, binNames);
		threads[i] = new ScanThread(command);
	}
	
	// Initialize maximum number of nodes to query in parallel.
	maxConcurrentNodes = (policy.maxConcurrentNodes == 0 || policy.maxConcurrentNodes >= threads.length)? threads.length : policy.maxConcurrentNodes;
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:16,代码来源:ScanExecutor.java

示例9: run

import com.aerospike.client.policy.ScanPolicy; //导入依赖的package包/类
public void run() {
    try {
        AerospikeClient client =
            AerospikeClientSingleton.getInstance(new ClientPolicy(),
                                                 host, port);

        log.info(String.format("scanNode %s:%d:%s:%s",
                               host, port, namespace, setName));
        ScanPolicy scanPolicy = new ScanPolicy();
        CallBack cb = new CallBack();
        log.info("scan starting");
        isRunning = true;
        if (binNames != null) 
            client.scanNode(scanPolicy, node, namespace, setName,
                            cb, binNames);
        else
            client.scanNode(scanPolicy, node, namespace, setName,
                            cb);
        isFinished = true;
        log.info("scan finished");
    }
    catch (Exception ex) {
        log.error("exception in ASSCanReader.run: " + ex);
        isError = true;
        return;
    }
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:28,代码来源:AerospikeRecordReader.java

示例10: run

import com.aerospike.client.policy.ScanPolicy; //导入依赖的package包/类
public void run() {
    try {
        AerospikeClient client =
            AerospikeClientSingleton.getInstance(new ClientPolicy(),
                                                 host, port);

        log.info(String.format("scanNode %s:%d:%s:%s",
                               host, port, namespace, setName));
        ScanPolicy scanPolicy = new ScanPolicy();
        scanPolicy.scanPercent = scanPercent;
        CallBack cb = new CallBack();
        log.info("scan starting with scan percent: " + scanPolicy.scanPercent + "%");
        isRunning = true;
        if (binNames != null) 
            client.scanNode(scanPolicy, node, namespace, setName,
                            cb, binNames);
        else
            client.scanNode(scanPolicy, node, namespace, setName,
                            cb);
        isFinished = true;
        log.info("scan finished");
    }
    catch (Exception ex) {
        log.error("exception in ASSCanReader.run: " + ex);
        isError = true;
        return;
    }
}
 
开发者ID:aerospike,项目名称:aerospike-hadoop,代码行数:29,代码来源:AerospikeRecordReader.java

示例11: deleteSet

import com.aerospike.client.policy.ScanPolicy; //导入依赖的package包/类
private static void deleteSet(String keyspace2, String mytable1Constant) {
    /*
     * // Delete existing keys client.delete(null, key1); client.delete(null, key2); client.delete(null, key3);
     */
    ScanCallback deleteAll = new ScanCallback() {

        @Override
        public void scanCallback(Key key, Record record) throws AerospikeException {
            client.delete(null, key);

        }
    };
    client.scanAll(new ScanPolicy(), KEYSPACE, MYTABLE1_CONSTANT, deleteAll, new String[] {});

}
 
开发者ID:Stratio,项目名称:stratio-connector-deep,代码行数:16,代码来源:DeepConnectorAerospikeFT.java

示例12: scanNode

import com.aerospike.client.policy.ScanPolicy; //导入依赖的package包/类
/**
 * Read all records in specified namespace and set for one node only.
 * The node is specified by name.
 * <p>
 * This call will block until the scan is complete - callbacks are made
 * within the scope of this call.
 * 
 * @param policy				scan configuration parameters, pass in null for defaults
 * @param nodeName				server node name
 * @param namespace				namespace - equivalent to database name
 * @param setName				optional set name - equivalent to database table
 * @param callback				read callback method - called with record data
 * @param binNames				optional bin to retrieve. All bins will be returned if not specified.  
 * 								Aerospike 2 servers ignore this parameter.
 * @throws AerospikeException	if scan fails
 */
public final void scanNode(ScanPolicy policy, String nodeName, String namespace, String setName, ScanCallback callback, String... binNames) 
	throws AerospikeException {		
	Node node = cluster.getNode(nodeName);
	scanNode(policy, node, namespace, setName, callback, binNames);
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:22,代码来源:AerospikeClient.java


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