本文整理汇总了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.
}
}
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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[] {});
}
示例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);
}