/// <summary> /// Gets the pooling options. If not specified, gets the default by protocol version /// </summary> internal PoolingOptions GetPoolingOptions(byte protocolVersion) { if (this._poolingOptions != null) { return(this._poolingOptions); } this._poolingOptions = PoolingOptions.GetDefault(protocolVersion); return(this._poolingOptions); }
public void GetRequest_With_Timestamp_Generator_Empty_Value_With_Statement_Timestamp() { var statement = new SimpleStatement("STATEMENT WITH TIMESTAMP"); var expectedTimestamp = new DateTimeOffset(2010, 04, 29, 1, 2, 3, 4, TimeSpan.Zero).AddTicks(20); statement.SetTimestamp(expectedTimestamp); var policies = new Dse.Policies( Dse.Policies.DefaultLoadBalancingPolicy, Dse.Policies.DefaultReconnectionPolicy, Dse.Policies.DefaultRetryPolicy, Dse.Policies.DefaultSpeculativeExecutionPolicy, new NoTimestampGenerator()); var config = new Configuration( policies, new ProtocolOptions(), PoolingOptions.GetDefault(ProtocolVersion.MaxSupported), new SocketOptions(), new ClientOptions(), NoneAuthProvider.Instance, null, new QueryOptions(), new DefaultAddressTranslator()); var request = RequestHandler <RowSet> .GetRequest(statement, Serializer, config); var stream = new MemoryStream(); request.WriteFrame(1, stream, Serializer); var headerSize = FrameHeader.GetSize(ProtocolVersion.MaxSupported); var bodyBuffer = new byte[stream.Length - headerSize]; stream.Position = headerSize; stream.Read(bodyBuffer, 0, bodyBuffer.Length); // The query request is composed by: // <query><consistency><flags><result_page_size><timestamp> var queryBuffer = BeConverter.GetBytes(statement.QueryString.Length) .Concat(Encoding.UTF8.GetBytes(statement.QueryString)) .ToArray(); CollectionAssert.AreEqual(queryBuffer, bodyBuffer.Take(queryBuffer.Length)); // Skip the query and consistency (2) var offset = queryBuffer.Length + 2; // The remaining length should be 13 = flags (1) + result_page_size (4) + timestamp (8) Assert.AreEqual(13, bodyBuffer.Length - offset); var flags = (QueryFlags)bodyBuffer[offset]; Assert.True(flags.HasFlag(QueryFlags.WithDefaultTimestamp)); Assert.True(flags.HasFlag(QueryFlags.PageSize)); // Skip flags (1) + result_page_size (4) offset += 5; var timestamp = BeConverter.ToInt64(bodyBuffer, offset); Assert.AreEqual(TypeSerializer.SinceUnixEpoch(expectedTimestamp).Ticks / 10, timestamp); }
public void GetRequest_With_Timestamp_Generator_Empty_Value() { var statement = new SimpleStatement("QUERY"); var policies = new Dse.Policies( Dse.Policies.DefaultLoadBalancingPolicy, Dse.Policies.DefaultReconnectionPolicy, Dse.Policies.DefaultRetryPolicy, Dse.Policies.DefaultSpeculativeExecutionPolicy, new NoTimestampGenerator()); var config = new Configuration( policies, new ProtocolOptions(), PoolingOptions.GetDefault(ProtocolVersion.MaxSupported), new SocketOptions(), new ClientOptions(), NoneAuthProvider.Instance, null, new QueryOptions(), new DefaultAddressTranslator()); var request = RequestHandler <RowSet> .GetRequest(statement, Serializer.Default, config); var stream = new MemoryStream(); request.WriteFrame(1, stream, Serializer); var headerSize = FrameHeader.GetSize(ProtocolVersion.MaxSupported); var bodyBuffer = new byte[stream.Length - headerSize]; stream.Position = headerSize; stream.Read(bodyBuffer, 0, bodyBuffer.Length); // The query request is composed by: // <query><consistency><flags><result_page_size> var queryBuffer = BeConverter.GetBytes(statement.QueryString.Length) .Concat(Encoding.UTF8.GetBytes(statement.QueryString)) .ToArray(); CollectionAssert.AreEqual(queryBuffer, bodyBuffer.Take(queryBuffer.Length)); // Skip the query and consistency (2) var offset = queryBuffer.Length + 2; // The remaining length should be 13 = flags (1) + result_page_size (4) Assert.AreEqual(5, bodyBuffer.Length - offset); var flags = (QueryFlags)bodyBuffer[offset]; Assert.False(flags.HasFlag(QueryFlags.WithDefaultTimestamp)); Assert.True(flags.HasFlag(QueryFlags.PageSize)); Assert.False(flags.HasFlag(QueryFlags.Values)); Assert.False(flags.HasFlag(QueryFlags.WithPagingState)); Assert.False(flags.HasFlag(QueryFlags.SkipMetadata)); Assert.False(flags.HasFlag(QueryFlags.WithSerialConsistency)); }