• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RegisterTask类的典型用法和代码示例

java 7次浏览

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

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

示例1: databaseSetup

点赞 3

import com.aerospike.client.task.RegisterTask; //导入依赖的package包/类
/**
 * Set up the Database.  In this case, this is primarily used for 
 * registering the User Defined Function (UDF) that we will use for
 * expiring data items in a Large Data Type (LDT).
 * 
 * Although the URL-Tracker app will use only one LDT flavor for a test
 * run instance, we will register both LLIST and LMAP UDFs here.
 * 
 * We have the choice of registering files as "UserModules", which is the
 * Lua Module that is used when we create an LDT, or we can register the
 * Lua Module as the container for a filter function.  For this example,
 * since we're going to do some configuration changes on the LDT, we will
 * use a UserModule for both LLIST and LMAP.
 * 
 * @param moduleName
 * @param functionName
 */
public void databaseSetup() {
	
	RegisterTask task;
	console.info("Register the Create Modules");
	try {

		task = client.register(dbParms.policy, 
				CM_LLIST_PATH, CM_LLIST_FILE, Language.LUA);
		task.waitTillComplete();

		task = client.register(dbParms.policy, 
				CM_LMAP_PATH, CM_LMAP_FILE, Language.LUA);
		task.waitTillComplete();

	} catch (Exception e) {
		e.printStackTrace();
		console.error("Problems with registering Create Modules");
	}
	console.info("Done with the Create Modules");
}
 

开发者ID:aerospike,
项目名称:url-tracker,
代码行数:38,
代码来源:ProcessCommands.java

示例2: registerUDF

点赞 2

import com.aerospike.client.task.RegisterTask; //导入依赖的package包/类
private static void registerUDF(Parameters params,
								AerospikeClient client) throws Exception {
	RegisterTask task =
		client.register(policy, "udf/filter_by_category.lua",
						"filter_by_category.lua", Language.LUA);
	task.waitTillComplete();
}
 

开发者ID:aerospike,
项目名称:geospatial-samples,
代码行数:8,
代码来源:Around.java

示例3: registerUDF

点赞 2

import com.aerospike.client.task.RegisterTask; //导入依赖的package包/类
private static void registerUDF(Parameters params,
								AerospikeClient client) throws Exception {
	RegisterTask task =
		client.register(policy, "udf/filter_by_amenity.lua",
						"filter_by_amenity.lua", Language.LUA);
	task.waitTillComplete();
}
 

开发者ID:aerospike,
项目名称:geospatial-samples,
代码行数:8,
代码来源:Around.java

示例4: registerUDF

点赞 2

import com.aerospike.client.task.RegisterTask; //导入依赖的package包/类
private void registerUDF() {
	if (!this.moduleCache.containsKey(QUERY_MODULE + ".lua")) { // register the as_utility udf module

		RegisterTask task = this.client.register(null, this.getClass().getClassLoader(),
				AS_UTILITY_PATH,
				QUERY_MODULE + ".lua", Language.LUA);
		task.isDone();
	}
}
 

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

示例5: registerUdf

点赞 2

import com.aerospike.client.task.RegisterTask; //导入依赖的package包/类
public static void registerUdf(AerospikeClient client, Policy policy, String clientPath, String serverPath,
        Language language) {
    RegisterTask task = client.register(policy, clientPath, serverPath, language);
    task.waitTillComplete();
}
 

开发者ID:maverickgautam,
项目名称:Aerospike-unit,
代码行数:6,
代码来源:AerospikeUtils.java

示例6: register

点赞 2

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


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)