Exemple #1
0
  @Test
  public void testBackpressure() throws Exception {
    createAndRegisterStats();
    MockStatsSource.delay = 20;

    /*
     * Generate a bunch of requests, should get backpressure on some of them
     */
    for (int ii = 0; ii < 30; ii++) {
      m_mvoltdb
          .getStatsAgent()
          .performOpsAction(m_mockConnection, 32, OpsSelector.STATISTICS, subselect("DR", 0));
    }

    boolean hadBackpressure = false;
    for (int ii = 0; ii < 30; ii++) {
      ClientResponseImpl response = responses.take();

      if (response.getStatus() == ClientResponse.GRACEFUL_FAILURE) {
        assertTrue("Too many pending stat requests".equals(response.getStatusString()));
        hadBackpressure = true;
      }
    }
    assertTrue(hadBackpressure);

    /*
     * Now having recieved all responses, it should be possible to collect the stats
     */
    m_mvoltdb
        .getStatsAgent()
        .performOpsAction(m_mockConnection, 32, OpsSelector.STATISTICS, subselect("DR", 0));
    ClientResponseImpl response = responses.take();
    verifyResults(response);
  }
Exemple #2
0
  @Test
  public void testCollectionTimeout() throws Exception {
    createAndRegisterStats();
    StatsAgent.OPS_COLLECTION_TIMEOUT = 300;
    MockStatsSource.delay = 200;
    m_mvoltdb
        .getStatsAgent()
        .performOpsAction(m_mockConnection, 32, OpsSelector.STATISTICS, subselect("DR", 0));
    ClientResponseImpl response = responses.take();

    assertEquals(ClientResponse.GRACEFUL_FAILURE, response.getStatus());
    VoltTable results[] = response.getResults();
    assertEquals(0, results.length);
    System.out.println(response.getStatusString());
    assertEquals(
        "OPS request hit sixty second timeout before all responses were received",
        response.getStatusString());
  }
Exemple #3
0
 @Test
 public void testInvalidStatisticsSubselector() throws Exception {
   createAndRegisterStats();
   m_mvoltdb
       .getStatsAgent()
       .performOpsAction(m_mockConnection, 32, OpsSelector.STATISTICS, subselect("CRAZY", 0));
   ClientResponseImpl response = responses.take();
   assertEquals(ClientResponse.GRACEFUL_FAILURE, response.getStatus());
   assertEquals(
       "First argument to @Statistics must be a valid STRING selector, instead was CRAZY",
       response.getStatusString());
   System.out.println(response.toJSONString());
 }
Exemple #4
0
 @Test
 public void testCollectUnavailableStats() throws Exception {
   for (StatsSelector selector : StatsSelector.values()) {
     m_mvoltdb
         .getStatsAgent()
         .performOpsAction(
             m_mockConnection, 32, OpsSelector.STATISTICS, subselect(selector.name(), 0));
     ClientResponseImpl response = responses.take();
     assertEquals(ClientResponse.GRACEFUL_FAILURE, response.getStatus());
     VoltTable results[] = response.getResults();
     assertEquals(0, results.length);
     assertEquals(
         "Requested info \""
             + selector.name()
             + "\" is not yet available or not "
             + "supported in the current configuration.",
         response.getStatusString());
   }
 }