protected internal override void ParseResult(Connection conn) { // Read header. conn.ReadFully(dataBuffer, MSG_TOTAL_HEADER_SIZE); int resultCode = dataBuffer[13]; if (resultCode == 0) { int generation = ByteUtil.BytesToInt(dataBuffer, 14); int expiration = ByteUtil.BytesToInt(dataBuffer, 18); record = new Record(null, generation, expiration); } else { if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR) { record = null; } else { throw new AerospikeException(resultCode); } } EmptySocket(conn); }
public PartitionParser(Connection conn, Node node, Dictionary<string, Node[][]> map, int partitionCount, bool requestProleReplicas) { // Send format 1: partition-generation\nreplicas-master\n // Send format 2: partition-generation\nreplicas-all\n this.partitionCount = partitionCount; this.map = map; string command = (requestProleReplicas) ? ReplicasAll : ReplicasMaster; Info info = new Info(conn, PartitionGeneration, command); this.length = info.GetLength(); if (length == 0) { throw new AerospikeException.Parse("Partition info is empty"); } this.buffer = info.GetBuffer(); generation = ParseGeneration(); if (requestProleReplicas) { ParseReplicasAll(node); } else { ParseReplicasMaster(node); } }
protected internal override void ParseResult(Connection conn) { // Read header. conn.ReadFully(dataBuffer, MSG_TOTAL_HEADER_SIZE); int resultCode = dataBuffer[13]; if (resultCode != 0 && resultCode != ResultCode.KEY_NOT_FOUND_ERROR) { throw new AerospikeException(resultCode); } exists = resultCode == 0; EmptySocket(conn); }
protected internal override void ParseResult(Connection conn) { // Read header. conn.ReadFully(dataBuffer, MSG_TOTAL_HEADER_SIZE); long sz = ByteUtil.BytesToLong(dataBuffer, 0); byte headerLength = dataBuffer[8]; int resultCode = dataBuffer[13]; int generation = ByteUtil.BytesToInt(dataBuffer, 14); int expiration = ByteUtil.BytesToInt(dataBuffer, 18); int fieldCount = ByteUtil.BytesToShort(dataBuffer, 26); // almost certainly 0 int opCount = ByteUtil.BytesToShort(dataBuffer, 28); int receiveSize = ((int)(sz & 0xFFFFFFFFFFFFL)) - headerLength; // Read remaining message bytes. if (receiveSize > 0) { SizeBuffer(receiveSize); conn.ReadFully(dataBuffer, receiveSize); } if (resultCode != 0) { if (resultCode == ResultCode.KEY_NOT_FOUND_ERROR || resultCode == ResultCode.LARGE_ITEM_NOT_FOUND) { return; } if (resultCode == ResultCode.UDF_BAD_RESPONSE) { record = ParseRecord(opCount, fieldCount, generation, expiration); HandleUdfError(resultCode); return; } throw new AerospikeException(resultCode); } if (opCount == 0) { // Bin data was not returned. record = new Record(null, generation, expiration); return; } record = ParseRecord(opCount, fieldCount, generation, expiration); }
public void Authenticate(Connection conn, byte[] user, byte[] password) { SetAuthenticate(user, password); conn.Write(dataBuffer, dataOffset); conn.ReadFully(dataBuffer, HEADER_SIZE); int result = dataBuffer[RESULT_CODE]; if (result != 0) { throw new AerospikeException(result, "Authentication failed"); } }
private int ReadBlocks(Connection conn) { int status = 0; while (status == 0) { conn.ReadFully(dataBuffer, 8); long size = ByteUtil.BytesToLong(dataBuffer, 0); int receiveSize = ((int)(size & 0xFFFFFFFFFFFFL)); if (receiveSize > 0) { if (receiveSize > dataBuffer.Length) { dataBuffer = ThreadLocalData.ResizeBuffer(receiveSize); } conn.ReadFully(dataBuffer, receiveSize); status = ParseBlock(receiveSize); } } return status; }
protected internal abstract void ParseResult(Connection conn);
protected internal void EmptySocket(Connection conn) { // There should not be any more bytes. // Empty the socket to be safe. long sz = ByteUtil.BytesToLong(dataBuffer, 0); int headerLength = dataBuffer[8]; int receiveSize = ((int)(sz & 0xFFFFFFFFFFFFL)) - headerLength; // Read remaining message bytes. if (receiveSize > 0) { SizeBuffer(receiveSize); conn.ReadFully(dataBuffer, receiveSize); } }
protected internal int UpdatePartitions(Connection conn, Node node) { PartitionParser parser = new PartitionParser(conn, node, partitionMap, Node.PARTITIONS, requestProleReplicas); if (parser.IsPartitionMapCopied) { partitionMap = parser.PartitionMap; } return parser.Generation; }
/// <summary> /// Get all the default info from the specified database server node. /// </summary> /// <param name="conn">socket connection to server node</param> public static Dictionary <string, string> Request(Connection conn) { Info info = new Info(conn); return(info.ParseMultiResponse()); }
//------------------------------------------------------- // Get Info via Connection //------------------------------------------------------- /// <summary> /// Get one info value by name from the specified database server node. /// </summary> /// <param name="conn">socket connection to server node</param> /// <param name="name">name of value to retrieve</param> public static string Request(Connection conn, string name) { Info info = new Info(conn, name); return(info.ParseSingleResponse(name)); }
/// <summary> /// Send default empty command to server and store results. /// This constructor is used internally. /// The static request methods should be used instead. /// </summary> /// <param name="conn">connection to server node</param> public Info(Connection conn) { buffer = ThreadLocalData.GetBuffer(); offset = 8; // Skip size field. SendCommand(conn); }