Codota Logo
PrimingRequest.queryBuilder
Code IndexAdd Codota to your IDE (free)

How to use
queryBuilder
method
in
org.scassandra.http.client.PrimingRequest

Best Java code snippets using org.scassandra.http.client.PrimingRequest.queryBuilder (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ScheduledThreadPoolExecutor s =
  • Codota Iconnew ScheduledThreadPoolExecutor(corePoolSize)
  • Codota IconThreadFactory threadFactory;new ScheduledThreadPoolExecutor(corePoolSize, threadFactory)
  • Codota IconString str;new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat(str).build())
  • Smart code suggestions by Codota
}
origin: com.datastax.cassandra/cassandra-driver-core

String query = "SELECT foo FROM bar";
primingClient.prime(
  queryBuilder().withQuery(query).withThen(then().withResult(result)).build());
origin: com.datastax.cassandra/cassandra-driver-core

@Test(groups = "short")
public void should_log_queries_beyond_constant_threshold() throws Exception {
 // given
 slow.setLevel(DEBUG);
 queryLogger = builder().withConstantThreshold(10).build();
 cluster.register(queryLogger);
 String query = "SELECT foo FROM bar";
 primingClient.prime(
   queryBuilder().withQuery(query).withThen(then().withFixedDelay(100L)).build());
 // when
 session.execute(query);
 // then
 String line = slowAppender.waitAndGet(5000);
 assertThat(line).contains("Query too slow").contains(ip).contains(query);
}
origin: com.datastax.cassandra/cassandra-driver-core

@Test(groups = "short")
public void should_log_timed_out_queries() throws Exception {
 // given
 error.setLevel(DEBUG);
 queryLogger = builder().build();
 cluster.register(queryLogger);
 cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1);
 String query = "SELECT foo FROM bar";
 primingClient.prime(
   queryBuilder().withQuery(query).withThen(then().withFixedDelay(100L)).build());
 // when
 try {
  session.execute(query);
  fail("Should have thrown OperationTimedOutException");
 } catch (OperationTimedOutException e) {
  // ok
 }
 // then
 String line = errorAppender.waitAndGet(5000);
 assertThat(line)
   .contains("Query error")
   .contains(ip)
   .contains(Integer.toString(scassandra.getBinaryPort()))
   .contains(query)
   .contains("Timed out waiting for server response");
}
origin: com.datastax.cassandra/cassandra-driver-core

PrimingRequest.queryBuilder()
  .withQuery("SELECT * FROM system.peers")
  .withThen(then().withRows(rows).withColumnTypes(ScassandraCluster.SELECT_PEERS))
PrimingRequest.queryBuilder()
  .withQuery("SELECT * FROM system.peers_v2")
  .withThen(then().withResult(Result.invalid))
origin: com.datastax.cassandra/cassandra-driver-core

@BeforeMethod(groups = "short")
public void setup() {
 primingClient.prime(
   queryBuilder().withQuery(query).withThen(then().withFixedDelay(100L)).build());
 // Set default timeout too low
 cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(10);
}
origin: com.datastax.cassandra/cassandra-driver-core

@Test(groups = "short")
public void should_fail_if_host_fails_query() {
 String query = "mock";
 sCluster
   .node(1)
   .primingClient()
   .prime(
     PrimingRequest.queryBuilder()
       .withQuery(query)
       .withThen(then().withResult(Result.unavailable))
       .build());
 // given a statement with a host configured to fail the given query.
 Host host1 = TestUtils.findHost(cluster, 1);
 Statement statement = new SimpleStatement(query).setHost(host1);
 try {
  // when statement is executed an error should be raised.
  session.execute(statement);
  fail("Query should have failed");
 } catch (NoHostAvailableException e) {
  // then the request should fail with a NHAE and no host was tried.
  assertThat(e.getErrors()).hasSize(1);
  assertThat(e.getErrors().values().iterator().next()).isInstanceOf(UnavailableException.class);
 } finally {
  verifyNoLbpInteractions();
 }
}
origin: com.datastax.cassandra/cassandra-driver-core

@Test(groups = "short")
public void should_count_inflight_requests_metrics() {
 sCluster
   .node(1)
   .primingClient()
   .prime(
     PrimingRequest.queryBuilder()
       .withQuery("mock query")
       .withThen(then().withFixedDelay(100000L))
       .build());
 Cluster cluster = null;
 try {
  cluster = builder().build();
  Session session = cluster.connect();
  assertThat(cluster.getMetrics().getInFlightRequests().getValue()).isEqualTo(0);
  session.executeAsync("mock query");
  session.executeAsync("mock query");
  assertThat(cluster.getMetrics().getInFlightRequests().getValue()).isEqualTo(2);
 } finally {
  if (cluster != null) {
   cluster.close();
  }
 }
}
origin: com.datastax.cassandra/cassandra-driver-core

@Test(groups = "short")
public void should_retry_on_client_timeout_if_statement_idempotent() {
 cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(1);
 try {
  scassandras
    .node(1)
    .primingClient()
    .prime(
      PrimingRequest.queryBuilder()
        .withQuery("mock query")
        .withThen(then().withFixedDelay(1000L).withRows(row("result", "result1")))
        .build());
  session.execute(new SimpleStatement("mock query").setIdempotent(true));
  assertOnRequestErrorWasCalled(1, OperationTimedOutException.class);
  assertThat(errors.getClientTimeouts().getCount()).isEqualTo(1);
  assertThat(errors.getRetries().getCount()).isEqualTo(1);
  assertThat(errors.getRetriesOnClientTimeout().getCount()).isEqualTo(1);
  assertQueried(1, 1);
  assertQueried(2, 1);
  assertQueried(3, 0);
 } finally {
  cluster
    .getConfiguration()
    .getSocketOptions()
    .setReadTimeoutMillis(SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS);
 }
}
origin: com.datastax.cassandra/cassandra-driver-core

 @Test(groups = "short")
 public void should_countdown_inflight_requests_metrics() {
  sCluster
    .node(1)
    .primingClient()
    .prime(PrimingRequest.queryBuilder().withQuery("mock query").withThen(then()).build());

  Cluster cluster = null;
  try {
   cluster = builder().build();
   Session session = cluster.connect();

   assertThat(cluster.getMetrics().getInFlightRequests().getValue()).isEqualTo(0);
   session.executeAsync("mock query").getUninterruptibly();
   session.executeAsync("mock query").getUninterruptibly();
   assertThat(cluster.getMetrics().getInFlightRequests().getValue()).isEqualTo(0);

  } finally {
   if (cluster != null) {
    cluster.close();
   }
  }
 }
}
origin: com.datastax.cassandra/cassandra-driver-core

.primingClient()
.prime(
  PrimingRequest.queryBuilder()
    .withQuery("mock query")
    .withThen(then().withFixedDelay(1000L).withRows(row("result", "result1")))
origin: com.datastax.cassandra/cassandra-driver-core

.primingClient()
.prime(
  PrimingRequest.queryBuilder()
    .withQuery("mock query")
    .withThen(then().withFixedDelay(1000L).withRows(row("result", "result1")))
origin: com.datastax.cassandra/cassandra-driver-core

protected void simulateError(int hostNumber, Result result) {
 scassandras
   .node(hostNumber)
   .primingClient()
   .prime(
     PrimingRequest.queryBuilder()
       .withQuery("mock query")
       .withThen(then().withResult(result))
       .build());
}
origin: com.datastax.cassandra/cassandra-driver-core

private void prime(int node, Result result) {
 sCluster
   .node(node)
   .primingClient()
   .prime(
     queryBuilder()
       .withQuery(QueryTracker.QUERY)
       .withThen(then().withResult(result))
       .build());
}
origin: com.datastax.cassandra/cassandra-driver-core

@Test(groups = "short")
public void should_not_start_speculative_execution_if_first_execution_completes_successfully() {
 scassandras
   .node(1)
   .primingClient()
   .prime(
     PrimingRequest.queryBuilder()
       .withQuery("mock query")
       .withThen(then().withRows(row("result", "result1")))
       .build());
 long execStartCount = errors.getSpeculativeExecutions().getCount();
 ResultSet rs = session.execute("mock query");
 Row row = rs.one();
 assertThat(row.getString("result")).isEqualTo("result1");
 assertThat(errors.getSpeculativeExecutions().getCount()).isEqualTo(execStartCount);
 ExecutionInfo executionInfo = rs.getExecutionInfo();
 assertThat(executionInfo.getTriedHosts()).containsOnly(host1);
 assertThat(executionInfo.getQueriedHost()).isEqualTo(host1);
 assertThat(executionInfo.getSpeculativeExecutions()).isEqualTo(0);
 assertThat(executionInfo.getSuccessfulExecutionIndex()).isEqualTo(0);
}
origin: com.datastax.cassandra/cassandra-driver-core

protected void simulateError(int hostNumber, Result result, Config config) {
 PrimingRequest.Then.ThenBuilder then = then().withResult(result);
 PrimingRequestBuilder builder = PrimingRequest.queryBuilder().withQuery("mock query");
 if (config != null) then = then.withConfig(config);
 builder = builder.withThen(then);
 scassandras.node(hostNumber).primingClient().prime(builder.build());
}
origin: com.datastax.cassandra/cassandra-driver-core

protected void simulateNormalResponse(int hostNumber) {
 scassandras
   .node(hostNumber)
   .primingClient()
   .prime(
     PrimingRequest.queryBuilder()
       .withQuery("mock query")
       .withThen(then().withRows(row("result", "result1")))
       .build());
}
origin: com.datastax.cassandra/cassandra-driver-core

@Test(groups = "short")
public void should_start_speculative_execution_if_first_execution_takes_too_long() {
 scassandras
   .node(1)
   .primingClient()
   .prime(
     PrimingRequest.queryBuilder()
       .withQuery("mock query")
       .withThen(then().withRows(row("result", "result1")).withFixedDelay(400L))
       .build());
 scassandras
   .node(2)
   .primingClient()
   .prime(
     PrimingRequest.queryBuilder()
       .withQuery("mock query")
       .withThen(then().withRows(row("result", "result2")))
       .build());
 long execStartCount = errors.getSpeculativeExecutions().getCount();
 ResultSet rs = session.execute("mock query");
 Row row = rs.one();
 assertThat(row.getString("result")).isEqualTo("result2");
 assertThat(errors.getSpeculativeExecutions().getCount()).isEqualTo(execStartCount + 1);
 ExecutionInfo executionInfo = rs.getExecutionInfo();
 // triedHosts does not contain host1 because the request to it had not completed yet
 assertThat(executionInfo.getTriedHosts()).containsOnly(host2);
 assertThat(executionInfo.getQueriedHost()).isEqualTo(host2);
 assertThat(executionInfo.getSpeculativeExecutions()).isEqualTo(1);
 assertThat(executionInfo.getSuccessfulExecutionIndex()).isEqualTo(1);
}
origin: com.datastax.cassandra/cassandra-driver-core

primingClient.prime(queryBuilder().withQuery(query).build());
LatencyAwarePolicy latencyAwarePolicy =
  LatencyAwarePolicy.builder(new RoundRobinPolicy()).withMininumMeasurements(1).build();
origin: com.datastax.cassandra/cassandra-driver-core

.primingClient()
.prime(
  PrimingRequest.queryBuilder()
    .withQuery("mock query")
    .withConsistency(Consistency.TWO)
.primingClient()
.prime(
  PrimingRequest.queryBuilder()
    .withQuery("mock query")
    .withConsistency(Consistency.ONE)
origin: com.datastax.cassandra/cassandra-driver-core

.primingClient()
.prime(
  PrimingRequest.queryBuilder()
    .withQuery("mock query")
    .withThen(then().withFixedDelay(1000L).withRows(row("result", "result1")))
org.scassandra.http.clientPrimingRequestqueryBuilder

Popular methods of PrimingRequest

  • then
  • preparedStatementBuilder
  • <init>

Popular in Java

  • Start an intent from android
  • setContentView (Activity)
  • requestLocationUpdates (LocationManager)
  • findViewById (Activity)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • LogFactory (org.apache.commons.logging)
    A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log look
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.This exception may include information for locating the er
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now