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


Java ResultCode类代码示例

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


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

示例1: info

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

import com.aerospike.client.ResultCode; //导入依赖的package包/类
public QueryExecutor(Cluster cluster, QueryPolicy policy, Statement statement) throws AerospikeException {
	this.policy = policy;
	this.policy.maxRetries = 0; // Retry policy must be one-shot for queries.
	this.statement = statement;
	this.completedCount = new AtomicInteger();
	this.nodes = cluster.getNodes();

	if (this.nodes.length == 0) {
		throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Query failed because cluster is empty.");
	}

	this.threadPool = cluster.getThreadPool();
	this.threads = new QueryThread[nodes.length];

	// Initialize maximum number of nodes to query in parallel.
	this.maxConcurrentNodes = (policy.maxConcurrentNodes == 0 || policy.maxConcurrentNodes >= threads.length) ? threads.length : policy.maxConcurrentNodes;
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:18,代码来源:QueryExecutor.java

示例3: parseResult

import com.aerospike.client.ResultCode; //导入依赖的package包/类
protected void parseResult(Connection conn) throws AerospikeException, IOException {
	// Read header.		
	conn.readFully(dataBuffer, MSG_TOTAL_HEADER_SIZE);

	int resultCode = dataBuffer[13] & 0xFF;

       if (resultCode == 0) {
   		int generation = Buffer.bytesToInt(dataBuffer, 14);
   		int expiration = Buffer.bytesToInt(dataBuffer, 18);
       	record = new Record(null, null, generation, expiration);       	
       }
       else {
		if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR) {
			record = null;
		}
		else {
			throw new AerospikeException(resultCode);
		}
	}
	emptySocket(conn);
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:22,代码来源:ReadHeaderCommand.java

示例4: AsyncScanExecutor

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

示例5: parseResult

import com.aerospike.client.ResultCode; //导入依赖的package包/类
protected final void parseResult(ByteBuffer byteBuffer) throws AerospikeException {
	int resultCode = byteBuffer.get(5) & 0xFF;

       if (resultCode == 0) {
       	int generation = byteBuffer.getInt(6);
   		int expiration = byteBuffer.getInt(10);
   		record = new Record(null, null, generation, expiration);
       }
       else {
       	if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR) {
       		record = null;
       	}
       	else {
       		throw new AerospikeException(resultCode);
       	}
       }		        
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:18,代码来源:AsyncReadHeader.java

示例6: parseResult

import com.aerospike.client.ResultCode; //导入依赖的package包/类
protected void parseResult(Connection conn) throws AerospikeException, IOException {
	// Read header.		
	conn.readFully(dataBuffer, MSG_TOTAL_HEADER_SIZE);
	int resultCode = dataBuffer[13] & 0xFF;

    if (resultCode != 0 && resultCode != ResultCode.KEY_NOT_FOUND_ERROR) {
    	throw new AerospikeException(resultCode);        	
    }        	
	exists = resultCode == 0;
	emptySocket(conn);
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:12,代码来源:ExistsCommand.java

示例7: generateList

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

示例8: parseResult

import com.aerospike.client.ResultCode; //导入依赖的package包/类
protected void parseResult(Connection conn) throws AerospikeException, IOException {
	// Read header.		
	conn.readFully(dataBuffer, MSG_TOTAL_HEADER_SIZE);
	int resultCode = dataBuffer[13] & 0xFF;

    if (resultCode != 0 && resultCode != ResultCode.KEY_NOT_FOUND_ERROR) {
    	throw new AerospikeException(resultCode);        	
    }        	
	existed = resultCode == 0;
	emptySocket(conn);
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:12,代码来源:DeleteCommand.java

示例9: parseResult

import com.aerospike.client.ResultCode; //导入依赖的package包/类
protected void parseResult(ByteBuffer byteBuffer) throws AerospikeException {
	int resultCode = byteBuffer.get(5) & 0xFF;
	        
       if (resultCode == 0) {
       	existed = true;
       }
       else {
       	if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR) {
       		existed = false;
       	}
       	else {
       		throw new AerospikeException(resultCode);
       	}
       }
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:16,代码来源:AsyncDelete.java

示例10: parseResult

import com.aerospike.client.ResultCode; //导入依赖的package包/类
protected void parseResult(ByteBuffer byteBuffer) throws AerospikeException {
	int resultCode = byteBuffer.get(5) & 0xFF;
	        
       if (resultCode == 0) {
       	exists = true;
       }
       else {
       	if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR) {
           	exists = false;
       	}
       	else {
       		throw new AerospikeException(resultCode);
       	}
       }
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:16,代码来源:AsyncExists.java

示例11: parseResult

import com.aerospike.client.ResultCode; //导入依赖的package包/类
protected final void parseResult(ByteBuffer byteBuffer) throws AerospikeException {
	dataBuffer = ThreadLocalData.getBuffer();
	
	if (receiveSize > dataBuffer.length) {
		dataBuffer = ThreadLocalData.resizeBuffer(receiveSize);
	}
	// Copy entire message to dataBuffer.
	byteBuffer.position(0);
	byteBuffer.get(dataBuffer, 0, receiveSize);
		
	int resultCode = dataBuffer[5] & 0xFF;
	int generation = Buffer.bytesToInt(dataBuffer, 6);
	int expiration = Buffer.bytesToInt(dataBuffer, 10);
	int fieldCount = Buffer.bytesToShort(dataBuffer, 18);
	int opCount = Buffer.bytesToShort(dataBuffer, 20);
	dataOffset = Command.MSG_REMAINING_HEADER_SIZE;
	        
       if (resultCode == 0) {
           if (opCount == 0) {
           	// Bin data was not returned.
           	record = new Record(null, null, generation, expiration);
           }
           else {
           	record = parseRecord(opCount, fieldCount, generation, expiration);
           }
       }
       else {
       	if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR) {
       		record = null;
       	}
       	else {
       		throw new AerospikeException(resultCode);
       	}
       }
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:36,代码来源:AsyncRead.java

示例12: parseGroup

import com.aerospike.client.ResultCode; //导入依赖的package包/类
private final boolean parseGroup() throws AerospikeException {
	// Parse each message response and add it to the result array
	receiveOffset = 0;
	
	while (receiveOffset < receiveSize) {
		resultCode = receiveBuffer[receiveOffset + 5] & 0xFF;

		if (resultCode != 0) {
			if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR) {
				if (stopOnNotFound) {
					return true;
				}
			}
			else {
				throw new AerospikeException(resultCode);
			}
		}

		// If this is the end marker of the response, do not proceed further
		if ((receiveBuffer[receiveOffset + 3] & Command.INFO3_LAST) != 0) {
			return true;
		}			
		generation = Buffer.bytesToInt(receiveBuffer, receiveOffset + 6);
		expiration = Buffer.bytesToInt(receiveBuffer, receiveOffset + 10);
		fieldCount = Buffer.bytesToShort(receiveBuffer, receiveOffset + 18);
		opCount = Buffer.bytesToShort(receiveBuffer, receiveOffset + 20);

		receiveOffset += Command.MSG_REMAINING_HEADER_SIZE;
		
		Key key = parseKey();
		parseRow(key);
	}
	return false;
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:35,代码来源:AsyncMultiCommand.java

示例13: parseRecordResults

import com.aerospike.client.ResultCode; //导入依赖的package包/类
@Override
protected boolean parseRecordResults(int receiveSize) 
	throws AerospikeException, IOException {
	// Server commands (Query/Execute UDF) should only send back a return code.
	// Keep parsing logic to empty socket buffer just in case server does
	// send records back.
	dataOffset = 0;
	
	while (dataOffset < receiveSize) {
   		readBytes(MSG_REMAINING_HEADER_SIZE);    		
		int resultCode = dataBuffer[5] & 0xFF;
		
		if (resultCode != 0) {
			if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR) {
				return false;
			}
			throw new AerospikeException(resultCode);
		}

		byte info3 = dataBuffer[3];
		
		// If this is the end marker of the response, do not proceed further
		if ((info3 & Command.INFO3_LAST) == Command.INFO3_LAST) {
			return false;
		}		
		
		int fieldCount = Buffer.bytesToShort(dataBuffer, 18);
		int opCount = Buffer.bytesToShort(dataBuffer, 20);
		
		parseKey(fieldCount);

		for (int i = 0 ; i < opCount; i++) {
    		readBytes(8);	
			int opSize = Buffer.bytesToInt(dataBuffer, 0);
			byte nameSize = dataBuffer[7];
    		
			readBytes(nameSize);
	
			int particleBytesSize = (int) (opSize - (4 + nameSize));
			readBytes(particleBytesSize);
	    }
		
		if (! valid) {
			throw new AerospikeException.QueryTerminated();
		}
	}
	return true;
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:49,代码来源:ServerCommand.java

示例14: ServerExecutor

import com.aerospike.client.ResultCode; //导入依赖的package包/类
public ServerExecutor(
	Cluster cluster,
	Policy policy,
	Statement statement,
	String packageName, 
	String functionName, 
	Value[] functionArgs
) throws AerospikeException {
	statement.setAggregateFunction(packageName, functionName, functionArgs, false);
	
	if (statement.taskId == 0) {
		Random r = new Random();
		statement.taskId = r.nextInt(Integer.MAX_VALUE);
	}
	
	completedCount = new AtomicInteger();

	Node[] nodes = cluster.getNodes();
	if (nodes.length == 0) {
		throw new AerospikeException(ResultCode.SERVER_NOT_AVAILABLE, "Command failed because cluster is empty.");
	}

	threads = new ServerThread[nodes.length];
	
	for (int i = 0; i < nodes.length; i++) {
		ServerCommand command = new ServerCommand(nodes[i], policy, statement);
		threads[i] = new ServerThread(command);
	}
	
	ExecutorService threadPool = cluster.getThreadPool();

	for (int i = 0; i < nodes.length; i++) {
		threadPool.execute(threads[i]);
	}
	waitTillComplete();
	
	// Throw an exception if an error occurred.
	if (exception != null) {
		if (exception instanceof AerospikeException) {
			throw (AerospikeException)exception;		
		}
		else {
			throw new AerospikeException(exception);
		}		
	}		
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:47,代码来源:ServerExecutor.java

示例15: parseRecordResults

import com.aerospike.client.ResultCode; //导入依赖的package包/类
@Override
protected boolean parseRecordResults(int receiveSize) 
	throws AerospikeException, IOException {
	// Read/parse remaining message bytes one record at a time.
	dataOffset = 0;
	
	while (dataOffset < receiveSize) {
   		readBytes(MSG_REMAINING_HEADER_SIZE);    		
		int resultCode = dataBuffer[5] & 0xFF;
		
		if (resultCode != 0) {
			if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR) {
				return false;
			}
			throw new AerospikeException(resultCode);
		}

		byte info3 = dataBuffer[3];
		
		// If this is the end marker of the response, do not proceed further
		if ((info3 & Command.INFO3_LAST) == Command.INFO3_LAST) {
			return false;
		}
		
		int fieldCount = Buffer.bytesToShort(dataBuffer, 18);
		int opCount = Buffer.bytesToShort(dataBuffer, 20);
		
		parseKey(fieldCount);
		
		if (opCount != 1) {
			throw new AerospikeException("Query aggregate expected exactly one bin.  Received " + opCount);
		}

		// Parse aggregateValue.
   		readBytes(8);	
		int opSize = Buffer.bytesToInt(dataBuffer, 0);
		byte particleType = dataBuffer[5];
		byte nameSize = dataBuffer[7];
   		
		readBytes(nameSize);
		String name = Buffer.utf8ToString(dataBuffer, 0, nameSize);

		int particleBytesSize = (int) (opSize - (4 + nameSize));
		readBytes(particleBytesSize);
		
		if (! name.equals("SUCCESS")) {
			if (name.equals("FAILURE")) {
				Object value = Buffer.bytesToParticle(particleType, dataBuffer, 0, particleBytesSize);
				throw new AerospikeException(ResultCode.QUERY_GENERIC, value.toString());
			}
			else {
				throw new AerospikeException(ResultCode.QUERY_GENERIC, "Query aggregate expected bin name SUCCESS.  Received " + name);
			}
		}
		
		LuaValue aggregateValue = instance.getLuaValue(particleType, dataBuffer, 0, particleBytesSize);
								
		if (! valid) {
			throw new AerospikeException.QueryTerminated();
		}

		if (aggregateValue != null) {
			try {
				inputQueue.put(aggregateValue);			
			}
			catch (InterruptedException ie) {
			}
		}
	}
	return true;
}
 
开发者ID:otrimegistro,项目名称:aerospikez,代码行数:72,代码来源:QueryAggregateCommand.java


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