• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Node类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: info

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
public static String info(Node node, String name) {
  try {
    String result = Info.request(node.getHost().name, node.getHost().port, name);
    return result;
    // The result looks like this (broken here into 5 lines). Node the ; in the middle.
    //   reads:20:07:45-GMT,ops/sec,>1ms,>8ms,>64ms;20:07:55,0.0,0.00,0.00,0.00;
    //   writes_master:20:07:45-GMT,ops/sec,>1ms,>8ms,>64ms;20:07:55,0.0,0.00,0.00,0.00;
    //   proxy:20:07:45-GMT,ops/sec,>1ms,>8ms,>64ms;20:07:55,0.0,0.00,0.00,0.00;
    //   udf:20:07:45-GMT,ops/sec,>1ms,>8ms,>64ms;20:07:55,0.0,0.00,0.00,0.00;
    //   query:20:07:45-GMT,ops/sec,>1ms,>8ms,>64ms;20:07:55,0.0,0.00,0.00,0.00;
  } catch (AerospikeException e) {
    int resultCode = e.getResultCode();
    System.err.format("info request %s %s %s\n", name, ResultCode.getResultString(resultCode), e);
  }
  return null;
}
 
开发者ID:aerospike,项目名称:geospatial-samples,代码行数:17,代码来源:InfoParser.java


示例2: queryByLua

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
private KeyRecordIterator queryByLua(Statement stmt, Boolean metaOnly, Node node, Qualifier[] qualifiers){
	Map<String, Object> originArgs = new HashMap<String, Object>();
	originArgs.put("includeAllFields", 1);
	ResultSet resultSet = null;

	String filterFuncStr = buildFilterFunction(qualifiers);
	originArgs.put("filterFuncStr", filterFuncStr);

	if (metaOnly)
		stmt.setAggregateFunction(this.getClass().getClassLoader(), AS_UTILITY_PATH, QUERY_MODULE, "query_meta", Value.get(originArgs));
	else
		stmt.setAggregateFunction(this.getClass().getClassLoader(), AS_UTILITY_PATH, QUERY_MODULE, "select_records", Value.get(originArgs));
	if (node != null) {
		resultSet = this.client.queryAggregateNode(queryPolicy, stmt, node);
	} else {
		resultSet = this.client.queryAggregate(queryPolicy, stmt);
	}
	return new KeyRecordIterator(stmt.getNamespace(), resultSet);

}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:21,代码来源:QueryEngine.java


示例3: refreshNamespaceData

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
public void refreshNamespaceData(Node node, Namespace namespace) {
	/*
	 * refresh namespace data
	 */
	try {
		String nameSpaceString = Info.request(infoPolicy, node, "namespace/" + namespace);
		namespace.mergeNamespaceInfo(nameSpaceString);
		String setsString = Info.request(infoPolicy, node, "sets/" + namespace);
		if (!setsString.isEmpty()) {
			String[] sets = setsString.split(";");
			for (String setData : sets) {
				namespace.mergeSet(setData);
			}
		}
	} catch (AerospikeException e) {
		log.error("Error geting Namespace details", e);
	}
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:19,代码来源:QueryEngine.java


示例4: sendInfoCommand

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
private String sendInfoCommand(Policy policy, String command) throws AerospikeException {		
	Node node = cluster.getRandomNode();
	int timeout = (policy == null)? 0 : policy.timeout;
	Connection conn = node.getConnection(timeout);
	Info info;
	
	try {
		info = new Info(conn, command);
		node.putConnection(conn);
	}
	catch (AerospikeException ae) {
		conn.close();
		throw ae;
	}
	catch (RuntimeException re) {
		conn.close();
		throw new AerospikeException(re);
	}
	return info.getValue();
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:21,代码来源:AerospikeClient.java


示例5: request

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
/**
 * Get one info value by name from the specified database server node.
 * 
 * @param node					server node
 * @param name					name of value to retrieve
 * @return						info value
 */
public static String request(Node node, String name) 
	throws AerospikeException {
	Connection conn = node.getConnection(DEFAULT_TIMEOUT);
	
	try {
		String response = Info.request(conn, name);
		node.putConnection(conn);
		return response;
	}
	catch (AerospikeException ae) {
		conn.close();
		throw ae;
	}
	catch (RuntimeException re) {
		conn.close();
		throw re;
	}
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:26,代码来源:Info.java


示例6: isDone

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
/**
 * Query all nodes for task completion status.
 */
public boolean isDone() throws AerospikeException {
	String command = "udf-list";
	Node[] nodes = cluster.getNodes();
	boolean done = false;

	for (Node node : nodes) {
		String response = Info.request(node, command);
		String find = "filename=" + packageName;
		int index = response.indexOf(find);

		if (index < 0) {
			return false;
		}
		done = true;
	}
	return done;
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:21,代码来源:RegisterTask.java


示例7: BatchCommandGet

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
public BatchCommandGet(
	Node node,
	BatchNode.BatchNamespace batchNamespace,
	Policy policy,		
	HashMap<Key,BatchItem> keyMap,
	HashSet<String> binNames,
	Record[] records,
	int readAttr
) {
	super(node);
	this.batchNamespace = batchNamespace;
	this.policy = policy;
	this.keyMap = keyMap;
	this.binNames = binNames;
	this.records = records;
	this.readAttr = readAttr;
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:18,代码来源:BatchCommandGet.java


示例8: AsyncScanExecutor

import com.aerospike.client.cluster.Node; //导入依赖的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


示例9: setServerSpecificParameters

import com.aerospike.client.cluster.Node; //导入依赖的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


示例10: printNodes

import com.aerospike.client.cluster.Node; //导入依赖的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


示例11: infoAll

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
public static String[] infoAll(AerospikeClient client, String name) {
  String[] result = new String[client.getNodes().length];
  int i = 0;
  for (Node node : client.getNodes()) {
    result[i++] = info(node, name);
  }
  return result;
}
 
开发者ID:aerospike,项目名称:geospatial-samples,代码行数:9,代码来源:InfoParser.java


示例12: refreshNamespaces

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
/**
 * refreshes the cached Namespace information
 */
public synchronized void refreshNamespaces() {
	/*
	 * cache namespaces
	 */
	if (this.namespaceCache == null) {
		this.namespaceCache = new TreeMap<String, Namespace>();
		Node[] nodes = client.getNodes();
		for (Node node : nodes) {
			try {
				String namespaceString = Info.request(getInfoPolicy(), node, "namespaces");
				if (!namespaceString.isEmpty()) {
					String[] namespaceList = namespaceString.split(";");
					for (String namespace : namespaceList) {
						Namespace ns = this.namespaceCache.get(namespace);
						if (ns == null) {
							ns = new Namespace(namespace);
							this.namespaceCache.put(namespace, ns);
						}
						refreshNamespaceData(node, ns);
					}
				}
			} catch (AerospikeException e) {
				log.error("Error geting Namespaces ", e);
			}

		}
	}
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:32,代码来源:QueryEngine.java


示例13: refreshIndexes

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
/**
 * refreshes the Index cache from the Cluster
 */
public synchronized void refreshIndexes() {
	/*
	 * cache index by Bin name
	 */
	if (this.indexCache == null)
		this.indexCache = new TreeMap<String, Index>();

	Node[] nodes = client.getNodes();
	for (Node node : nodes) {
		if (node.isActive()) {
			try {
				String indexString = Info.request(getInfoPolicy(), node, "sindex");
				if (!indexString.isEmpty()) {
					String[] indexList = indexString.split(";");
					for (String oneIndexString : indexList) {
						Index index = new Index(oneIndexString);
						this.indexCache.put(index.toKeyString(), index);
					}
				}
				break;
			} catch (AerospikeException e) {
				log.error("Error geting Index informaton", e);
			}
		}
	}
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:30,代码来源:QueryEngine.java


示例14: refreshModules

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
/**
 * refreshes the Module cache from the cluster. The Module cache contains a list of register UDF modules.
 */
public synchronized void refreshModules() {
	if (this.moduleCache == null)
		this.moduleCache = new TreeMap<String, Module>();
	boolean loadedModules = false;
	Node[] nodes = client.getNodes();
	for (Node node : nodes) {
		try {

			String packagesString = Info.request(infoPolicy, node, "udf-list");
			if (!packagesString.isEmpty()) {
				String[] packagesList = packagesString.split(";");
				for (String pkgString : packagesList) {
					Module module = new Module(pkgString);
					String udfString = Info.request(infoPolicy, node, "udf-get:filename=" + module.getName());
					module.setDetailInfo(udfString);//gen=qgmyp0d8hQNvJdnR42X3BXgUGPE=;type=LUA;recordContent=bG9jYWwgZnVuY3Rpb24gcHV0QmluKHIsbmFtZSx2YWx1ZSkKICAgIGlmIG5vdCBhZXJvc3Bpa2U6ZXhpc3RzKHIpIHRoZW4gYWVyb3NwaWtlOmNyZWF0ZShyKSBlbmQKICAgIHJbbmFtZV0gPSB2YWx1ZQogICAgYWVyb3NwaWtlOnVwZGF0ZShyKQplbmQKCi0tIFNldCBhIHBhcnRpY3VsYXIgYmluCmZ1bmN0aW9uIHdyaXRlQmluKHIsbmFtZSx2YWx1ZSkKICAgIHB1dEJpbihyLG5hbWUsdmFsdWUpCmVuZAoKLS0gR2V0IGEgcGFydGljdWxhciBiaW4KZnVuY3Rpb24gcmVhZEJpbihyLG5hbWUpCiAgICByZXR1cm4gcltuYW1lXQplbmQKCi0tIFJldHVybiBnZW5lcmF0aW9uIGNvdW50IG9mIHJlY29yZApmdW5jdGlvbiBnZXRHZW5lcmF0aW9uKHIpCiAgICByZXR1cm4gcmVjb3JkLmdlbihyKQplbmQKCi0tIFVwZGF0ZSByZWNvcmQgb25seSBpZiBnZW4gaGFzbid0IGNoYW5nZWQKZnVuY3Rpb24gd3JpdGVJZkdlbmVyYXRpb25Ob3RDaGFuZ2VkKHIsbmFtZSx2YWx1ZSxnZW4pCiAgICBpZiByZWNvcmQuZ2VuKHIpID09IGdlbiB0aGVuCiAgICAgICAgcltuYW1lXSA9IHZhbHVlCiAgICAgICAgYWVyb3NwaWtlOnVwZGF0ZShyKQogICAgZW5kCmVuZAoKLS0gU2V0IGEgcGFydGljdWxhciBiaW4gb25seSBpZiByZWNvcmQgZG9lcyBub3QgYWxyZWFkeSBleGlzdC4KZnVuY3Rpb24gd3JpdGVVbmlxdWUocixuYW1lLHZhbHVlKQogICAgaWYgbm90IGFlcm9zcGlrZTpleGlzdHMocikgdGhlbiAKICAgICAgICBhZXJvc3Bpa2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HYgKyBhZGRWYWx1ZQogICAgICAgIGFlcm9zcGlrZTp1cGRhdGUocikKICAgIGVuZAplbmQKCi0tIFNldCBleHBpcmF0aW9uIG9mIHJlY29yZAotLSBmdW5jdGlvbiBleHBpcmUocix0dGwpCi0tICAgIGlmIHJlY29yZC50dGwocikgPT0gZ2VuIHRoZW4KLS0gICAgICAgIHJbbmFtZV0gPSB2YWx1ZQotLSAgICAgICAgYWVyb3NwaWtlOnVwZGF0ZShyKQotLSAgICBlbmQKLS0gZW5kCg==;
					this.moduleCache.put(module.getName(), module);
				}
			}
			loadedModules = true;
			break;
		} catch (AerospikeException e) {

		}
	}
	if (!loadedModules) {
		throw new ClusterRefreshError("Cannot find UDF modules");
	}
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:32,代码来源:QueryEngine.java


示例15: infoAll

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
/**
 * Sends an "Info" command to all nodes in the cluster
 *
 * @param client AerospikeClient instance
 * @param cmd	Info command to be sent to the cluster
 * @return A string containing the results from all nodes in the cluster
 */
public static String infoAll(AerospikeClient client, String cmd) {
	Node[] nodes = client.getNodes();
	StringBuilder results = new StringBuilder();
	for (Node node : nodes) {
		results.append(Info.request(node.getHost().name, node.getHost().port, cmd)).append("\n");
	}
	return results.toString();
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:16,代码来源:Utils.java


示例16: getNodeNames

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
/**
 * Return list of active server node names in the cluster.
 * 
 * @return	list of active node names
 */
public final List<String> getNodeNames() {
	Node[] nodes = cluster.getNodes();		
	ArrayList<String> names = new ArrayList<String>(nodes.length);
	
	for (Node node : nodes) {
		names.add(node.getName());
	}
	return names;
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:15,代码来源:AerospikeClient.java


示例17: isDone

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
/**
 * Query all nodes for task completion status.
 */
@Override
public boolean isDone() throws AerospikeException {
   if(cluster == null) return true;
	String command = "sindex/" + namespace + '/' + indexName;
	Node[] nodes = cluster.getNodes();
	boolean complete = false;

	for (Node node : nodes) {
		try {
			String response = Info.request(node, command);
			String find = "load_pct=";
			int index = response.indexOf(find);

			if (index < 0) {
				complete = true;
				continue;
			}

			int begin = index + find.length();
			int end = response.indexOf(';', begin);
			String str = response.substring(begin, end);
			int pct = Integer.parseInt(str);
			
			if (pct >= 0 && pct < 100) {
				return false;
			}
			complete = true;
		}
		catch (Exception e) {
			complete = true;
		}
	}
	return complete;
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:38,代码来源:IndexTask.java


示例18: ScanCommand

import com.aerospike.client.cluster.Node; //导入依赖的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


示例19: ScanExecutor

import com.aerospike.client.cluster.Node; //导入依赖的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


示例20: generateList

import com.aerospike.client.cluster.Node; //导入依赖的package包/类
public static List<BatchNode> generateList(Cluster cluster, Key[] keys) throws AerospikeException {
	Node[] nodes = cluster.getNodes();
	
	if (nodes.length == 0) {
		throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Command failed because cluster is empty.");
	}
	
	int nodeCount = nodes.length;
	int keysPerNode = keys.length / nodeCount + 10;

	// Split keys by server node.
	List<BatchNode> batchNodes = new ArrayList<BatchNode>(nodeCount+1);
			
	for (int i = 0; i < keys.length; i++) {
		Key key = keys[i];
		Partition partition = new Partition(key);			
		BatchNode batchNode;
		
		Node node = cluster.getNode(partition);
		batchNode = findBatchNode(batchNodes, node);
		
		if (batchNode == null) {
			batchNodes.add(new BatchNode(node, keysPerNode, key));
		}
		else {
			batchNode.addKey(key);
		}
	}
	return batchNodes;
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:31,代码来源:BatchNode.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InternalKieModule类代码示例发布时间:2022-05-22
下一篇:
Java IWorkingCopyManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap