本文整理汇总了Java中com.aerospike.client.AerospikeClient类的典型用法代码示例。如果您正苦于以下问题:Java AerospikeClient类的具体用法?Java AerospikeClient怎么用?Java AerospikeClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AerospikeClient类属于com.aerospike.client包,在下文中一共展示了AerospikeClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: incrementBin
import com.aerospike.client.AerospikeClient; //导入依赖的package包/类
public void incrementBin(String name, String key, String bin) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
synchronized (obj) {
try {
aClient = new AerospikeClient(Constants.IP, Constants.PORT);
Key keyObj = new Key(NAMESPACE, name, key);
Bin binObj = new Bin(bin, 1);
aClient.add(writePolicy, keyObj, binObj);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (aClient != null) aClient.close();
}
}
}
});
thread.start();
}
示例2: run
import com.aerospike.client.AerospikeClient; //导入依赖的package包/类
private static void run(String[] args) throws Exception {
Parameters params = parseParameters(args);
AerospikeClient client = setupAerospike(params);
try {
if (params.category != null) {
registerUDF(params, client);
}
long t0 = System.nanoTime();
queryCircle(params, client);
long t1 = System.nanoTime();
System.out.printf("found %d records in %.3f milliseconds\n",
count, (t1 - t0) / 1e6);
}
finally {
cleanupAerospike(params, client);
}
}
示例3: run
import com.aerospike.client.AerospikeClient; //导入依赖的package包/类
private static void run(String[] args) throws Exception {
Parameters params = parseParameters(args);
AerospikeClient client = setupAerospike(params);
try {
if (params.amenity != null) {
registerUDF(params, client);
}
long t0 = System.nanoTime();
queryCircle(params, client);
long t1 = System.nanoTime();
System.out.printf("found %d records in %.3f milliseconds\n",
count, (t1 - t0) / 1e6);
}
finally {
cleanupAerospike(params, client);
}
}
示例4: init
import com.aerospike.client.AerospikeClient; //导入依赖的package包/类
/**
* initialize and validate configuration options
*
* @param context
* @param issues
*/
public void init(Target.Context context, List<Target.ConfigIssue> issues) {
List<Host> hosts = getAerospikeHosts(issues, connectionString, Groups.AEROSPIKE.getLabel(), "aerospikeBeanConfig.connectionString", context);
ClientPolicy cp = new ClientPolicy();
try {
client = new AerospikeClient(cp, hosts.toArray(new Host[hosts.size()]));
int retries = 0;
while (!client.isConnected() && retries <= maxRetries) {
if (retries > maxRetries) {
issues.add(context.createConfigIssue(Groups.AEROSPIKE.getLabel(), "aerospikeBeanConfig.connectionString", AerospikeErrors.AEROSPIKE_03, connectionString));
return;
}
retries++;
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {
}
}
} catch (AerospikeException ex) {
issues.add(context.createConfigIssue(Groups.AEROSPIKE.getLabel(), "aerospikeBeanConfig.connectionString", AerospikeErrors.AEROSPIKE_03, connectionString));
}
}
示例5: writeAerospike
import com.aerospike.client.AerospikeClient; //导入依赖的package包/类
@Override
public void writeAerospike(Text sessid,
Session session,
AerospikeClient client,
WritePolicy writePolicy,
String namespace,
String setName) throws IOException {
writePolicy.timeout = 10000;
Key kk = new Key(namespace, setName, sessid.toString());
Bin bin0 = new Bin("userid", session.userid);
Bin bin1 = new Bin("start", session.start);
Bin bin2 = new Bin("end", session.end);
Bin bin3 = new Bin("nhits", session.nhits);
Bin bin4 = new Bin("age", session.age);
Bin bin5 = new Bin("isMale", session.isMale);
client.put(writePolicy, kk, bin0, bin1, bin2, bin3, bin4, bin5);
}
示例6: setServerSpecificParameters
import com.aerospike.client.AerospikeClient; //导入依赖的package包/类
/**
* Retrieves and sets the server specific parameters
* Validates the existence of user provided namespace and validates for single binned
* namespaces
*
* @param client aerospike client used to connect with the server
*/
public void setServerSpecificParameters(AerospikeClient client) {
String namespaceTokens = null;
for (Node node : client.getNodes()) {
String namespaceFilter = "namespace/" + aerospikeMapping.getNamespace();
namespaceTokens = Info.request(null, node, namespaceFilter);
if (namespaceTokens != null) {
isSingleBinEnabled = parseBoolean(namespaceTokens, "single-bin");
break;
}
}
if (namespaceTokens == null) {
LOG.error("Failed to get namespace info from Aerospike");
throw new RuntimeException("Failed to get namespace info from Aerospike");
}
}
示例7: remove
import com.aerospike.client.AerospikeClient; //导入依赖的package包/类
/**
* Given a customer object, remove it from the set (using the key custID).
*
* @param client
* @param nameSpace
* @return
* @throws Exception
*/
public Record remove(AerospikeClient client, String namespace, String setName)
throws Exception
{
Record record = null;
String recordKey = this.customerID;
try {
// Note that custID is BOTH the name of the Aerospike SET and it
// is the KEY of the Singleton Record for Customer info.
Key key = new Key(namespace, setName, recordKey);
// Remove the record
console.debug("Remove Record: namespace(%s) set(%s) key(%s)",
key.namespace, key.setName, key.userKey);
client.delete(this.writePolicy, key);
} catch (Exception e){
e.printStackTrace();
console.warn("Exception: " + e);
}
return record;
}
示例8: remove
import com.aerospike.client.AerospikeClient; //导入依赖的package包/类
/**
* Given a User object, remove it from the set (using the key custID).
*
* @param client
* @param nameSpace
* @param setName
* @return
* @throws Exception
*/
public Record remove(AerospikeClient client, String namespace, String setName)
throws Exception
{
Record record = null;
String recordKey = this.userID;
try {
Key key = new Key(namespace, setName, recordKey);
// Remove the record
console.debug("Remove Record: namespace(%s) set(%s) key(%s)",
key.namespace, key.setName, key.userKey);
client.delete(this.writePolicy, key);
} catch (Exception e){
e.printStackTrace();
console.warn("Exception: " + e);
}
return record;
}
示例9: EmulateUser
import com.aerospike.client.AerospikeClient; //导入依赖的package包/类
public EmulateUser(Console console, AerospikeClient client, DbOps dbOps,
DbParameters dbParms, int threadTPS, long emulationDays, long customers, long users,
int threadNumber, long timeToLive )
{
this.console = console;
this.client = client;
this.dbOps = dbOps;
this.customerMax = (int) customers;
this.userMax = (int) users;
this.baseNamespace = dbParms.baseNamespace;
this.cacheNamespace = dbParms.cacheNamespace;
this.emulationDays = emulationDays;
this.threadNumber = threadNumber;
this.client = client;
this.timeToLive = timeToLive;
this.threadTPS = threadTPS;
this.random = new Random();
}
示例10: runScan
import com.aerospike.client.AerospikeClient; //导入依赖的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;
}
示例11: runScan
import com.aerospike.client.AerospikeClient; //导入依赖的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;
}
示例12: AerospikeDB
import com.aerospike.client.AerospikeClient; //导入依赖的package包/类
public AerospikeDB(String namespace) {
AerospikeDB.NAMESPACE = namespace;
writePolicy = new WritePolicy();
readPolicy = new Policy();
batchPolicy = new BatchPolicy();
client = new AerospikeClient(Constants.IP, Constants.PORT);
}
示例13: connect
import com.aerospike.client.AerospikeClient; //导入依赖的package包/类
/**
* Create connection with database.
*/
@Override
public void connect()
{
try {
client = new AerospikeClient(node, port);
logger.debug("Aerospike connection Success");
} catch (AerospikeException ex) {
throw new RuntimeException("closing database resource", ex);
} catch (Throwable t) {
DTThrowable.rethrow(t);
}
}
示例14: printNodes
import com.aerospike.client.AerospikeClient; //导入依赖的package包/类
public static void printNodes(AerospikeClient client) {
if (client == null) {
LOG.warn("null client has been sent returning");
return;
}
for (Node node : client.getNodes()) {
LOG.info("node name is " + node.getAddress().getHostString());
}
}
示例15: setup
import com.aerospike.client.AerospikeClient; //导入依赖的package包/类
@BeforeClass
public void setup() throws Exception {
// Instatiate the cluster with Multiple NameSpaceNames
nameSpaceList = new ArrayList<>();
nameSpaceList.add("userStore");
nameSpaceList.add("ucm");
nameSpaceList.add("dimData");
cluster = new AerospikeSingleNodeCluster(nameSpaceList);
cluster.start();
// Get the runTime configuration of the cluster
runtimConfig = cluster.getRunTimeConfiguration();
client = new AerospikeClient("127.0.0.1", runtimConfig.getServicePort());
AerospikeUtils.printNodes(client);
}
开发者ID:maverickgautam,项目名称:Aerospike-unit,代码行数:15,代码来源:AerospikeSingleNodeMultiNamespaceClusterTest.java