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


Java AerospikeClient类代码示例

本文整理汇总了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();
}
 
开发者ID:pawankumbhare4213,项目名称:TinyURL,代码行数:21,代码来源:AerospikeDB.java

示例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);
	}
}
 
开发者ID:aerospike,项目名称:geospatial-samples,代码行数:22,代码来源:Around.java

示例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);
	}
}
 
开发者ID:aerospike,项目名称:geospatial-samples,代码行数:22,代码来源:Around.java

示例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));
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:29,代码来源:AerospikeBeanConfig.java

示例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);
}
 
开发者ID:aerospike,项目名称:aerospike-hadoop,代码行数:18,代码来源:ExternalJoin.java

示例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");
  }
}
 
开发者ID:apache,项目名称:gora,代码行数:25,代码来源:AerospikeParameters.java

示例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;
}
 
开发者ID:aerospike,项目名称:url-tracker,代码行数:32,代码来源:CustomerRecord.java

示例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;
}
 
开发者ID:aerospike,项目名称:url-tracker,代码行数:31,代码来源:UserRecord.java

示例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();
}
 
开发者ID:aerospike,项目名称:url-tracker,代码行数:19,代码来源:EmulateUser.java

示例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;
}
 
开发者ID:aerospike,项目名称:url-tracker,代码行数:24,代码来源:ScanSet.java

示例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;
}
 
开发者ID:aerospike,项目名称:url-tracker,代码行数:25,代码来源:ScanKeySet.java

示例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);
}
 
开发者ID:pawankumbhare4213,项目名称:TinyURL,代码行数:8,代码来源:AerospikeDB.java

示例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);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:16,代码来源:AerospikeStore.java

示例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());
    }
}
 
开发者ID:maverickgautam,项目名称:Aerospike-unit,代码行数:10,代码来源:AerospikeUtils.java

示例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


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