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


Java Node.putConnection方法代码示例

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


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

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

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

示例3: register

import com.aerospike.client.cluster.Node; //导入方法依赖的package包/类
/**
 * Register package containing user defined functions with server.
 * This asynchronous server call will return before command is complete.
 * The user can optionally wait for command completion by using the returned
 * RegisterTask instance.
 * <p>
 * This method is only supported by Aerospike 3 servers.
 * 
 * @param policy				generic configuration parameters, pass in null for defaults
 * @param clientPath			path of client file containing user defined functions, relative to current directory
 * @param serverPath			path to store user defined functions on the server, relative to configured script directory.
 * @param language				language of user defined functions
 * @throws AerospikeException	if register fails
 */
public final RegisterTask register(Policy policy, String clientPath, String serverPath, Language language) 
	throws AerospikeException {
	
	String content = Util.readFileEncodeBase64(clientPath);
	
	StringBuilder sb = new StringBuilder(serverPath.length() + content.length() + 100);
	sb.append("udf-put:filename=");
	sb.append(serverPath);
	sb.append(";content=");
	sb.append(content);
	sb.append(";content-len=");
	sb.append(content.length());
	sb.append(";udf-type=");
	sb.append(language);
	sb.append(";");
	
	// Send UDF to one node. That node will distribute the UDF to other nodes.
	String command = sb.toString();
	Node node = cluster.getRandomNode();
	int timeout = (policy == null)? 0 : policy.timeout;
	Connection conn = node.getConnection(timeout);
	
	try {			
		Info info = new Info(conn, command);
		NameValueParser parser = info.getNameValueParser();
		String error = null;
		String file = null;
		String line = null;
		String message = null;
		
		while (parser.next()) {
			String name = parser.getName();

			if (name.equals("error")) {
				error = parser.getValue();
			}
			else if (name.equals("file")) {
				file = parser.getValue();				
			}
			else if (name.equals("line")) {
				line = parser.getValue();				
			}
			else if (name.equals("message")) {
				message = parser.getStringBase64();					
			}
		}
		
		if (error != null) {			
			throw new AerospikeException("Registration failed: " + error + Environment.Newline +
				"File: " + file + Environment.Newline + 
				"Line: " + line + Environment.Newline +
				"Message: " + message
				);
		}
		
		node.putConnection(conn);
		return new RegisterTask(cluster, serverPath);
	}
	catch (AerospikeException ae) {
		conn.close();
		throw ae;
	}
	catch (RuntimeException re) {
		conn.close();
		throw new AerospikeException(re);
	}
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:82,代码来源:AerospikeClient.java


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