Package com.splout.db.qnode.beans

Examples of com.splout.db.qnode.beans.QueryStatus


  public static class LambdaMerge extends BaseFunction {

    @Override
    public void execute(TridentTuple tuple, TridentCollector collector) {
      Map<String, Long> resultRealTime = (Map<String, Long>) tuple.get(1);
      QueryStatus resultBatch = (QueryStatus) tuple.get(2);

      TreeMap<String, Long> consolidatedResult;

      if(resultRealTime != null) {
        consolidatedResult = new TreeMap<String, Long>(resultRealTime);
      } else {
        consolidatedResult = new TreeMap<String, Long>();
      }

      if(resultBatch != null) {
        if(resultBatch.getResult() != null) {
          for(Object rowBatch : resultBatch.getResult()) {
            Map<String, Object> mapRow = (Map<String, Object>) rowBatch;
            String day = (String) mapRow.get("day");
            // we do this since Splout may return Integer or Long depending on the value
            Long count = Long.parseLong(mapRow.get("SUM(count)").toString());
            // In the real-time map we set the values from the batch view
View Full Code Here


      int index = lastNode % repEntry.getNodes().size();
      electedNode = repEntry.getNodes().get(index);
      partitionRoundRobin.get().put(partitionId, index);

      // Perform query
      QueryStatus qStatus = new QueryStatus();
      long start = System.currentTimeMillis();

      DNodeService.Client client = null;
      boolean renew = false;
     
      try {
        client = context.getDNodeClientFromPool(electedNode);

        String r;
        try {
          r = client.sqlQuery(tablespaceName, version, partitionId, sql);
        } catch(TTransportException e) {
          renew = true;
          throw e;
        }

        qStatus.setResult(JSONSerDe.deSer(r, ArrayList.class));
        long end = System.currentTimeMillis();
        // Report the time of the query
        qStatus.setMillis((end - start));
        // ... and the shard hit.
        qStatus.setShard(partitionId);
        return qStatus;
      } catch(DNodeException e) {
        log.error("Exception in Querier", e);
        if(tried == repEntry.getNodes().size()) {
          return new ErrorQueryStatus("DNode exception (" + e.getMsg() + ") from " + electedNode);
View Full Code Here

      handler.getContext().getTablespaceVersionsMap()
          .put(new TablespaceVersion("tablespace1", 0l), tablespace1);
      handler.getContext().getCurrentVersionsMap().put("tablespace1", 0l);

      // Query key 2 (> 1 < 10)
      QueryStatus qStatus = handler.query("tablespace1", "2", "SELECT 1;", null);
      Assert.assertEquals(new Integer(0), qStatus.getShard());
      Assert.assertEquals("[1]", qStatus.getResult().toString());
    } finally {
      handler.close();
      dnode.stop();
      Hazelcast.shutdownAll();
    }
View Full Code Here

      handler.getContext().getTablespaceVersionsMap()
          .put(new TablespaceVersion("tablespace1", 0l), tablespace1);
      handler.getContext().getCurrentVersionsMap().put("tablespace1", 0l);

      // Query shard 0
      QueryStatus qStatus = handler.query("tablespace1", null, "SELECT 1;", "0");
      Assert.assertEquals(new Integer(0), qStatus.getShard());
      Assert.assertEquals("[1]", qStatus.getResult().toString());

      // Query random partition
      qStatus = handler.query("tablespace1", null, "SELECT 1;", Querier.PARTITION_RANDOM);
      Assert.assertEquals(new Integer(0), qStatus.getShard());
      Assert.assertEquals("[1]", qStatus.getResult().toString());

    } finally {
      handler.close();
      dnode.stop();
      Hazelcast.shutdownAll();
View Full Code Here

        key += strKey;
      }
    }

    try {
      QueryStatus st = qNodeHandler.query(tablespace, key, sql, partition);
      log.info(Thread.currentThread().getName() + ": Query request received, tablespace[" + tablespace
          + "], key[" + key + "], sql[" + sql + "] time [" + st.getMillis() + "]");
      String response;
      response = JSONSerDe.ser(st);
      if(callback != null) {
        response = callback + "(" + response + ")";
      }
View Full Code Here

  public void test() throws Throwable {
    final SploutConfiguration config = SploutConfiguration.getTestConfig();
    QNode qnode = TestUtils.getTestQNode(config, new QNodeMockHandler() {
      @Override
      public QueryStatus query(String tablespace, String key, String sql, String partition) throws Exception {
        return new QueryStatus();
      }
      @Override
      public ArrayList<QueryStatus> multiQuery(String tablespace, List<String> keyMins, List<String> keyMaxs, String sql)
          throws Exception {
        return new ArrayList<QueryStatus>();
View Full Code Here

      }
    }

    previousVersion = status.getTablespaceMap().get("pagecountsintegration").getVersion();

    QueryStatus qStatus = client.query("pagecountsintegration", "*", "SELECT * FROM pagecounts;", null);
    System.out.println(qStatus.getResult());

    if(qStatus.getResult() == null) {
      throw new RuntimeException("Something failed as query() is returning null!");
    }

    System.out.println("Everything fine.");
    return 1;
View Full Code Here

    /*
     * Here we are testing basic round robin: we have 2 nodes serving one shard and we do 5 queries
     * so we want to assert that the node whom we are querying at step "i" is exactly "i % 2".
     */
    for(int i = 0; i < 5; i++) {
      QueryStatus status = querier.query("t1", "", 0);
      assertEquals((Integer)(i % 2), querier.getPartitionRoundRobin().get(0));
      assertEquals((Integer)0, status.getShard());
      assertEquals(null, status.getError());
    }
  }
View Full Code Here

     * Here we are testing round robin when there are some dead nodes in a shard. We have 2 alive nodes and 2 dead nodes.
     * Therefore we want to assert that at step "i" the chosen node will be "0 if i % 2 == 0 or 2 if i % 2 == 1".
     * This can be simplified to (i % 2) * 2
     */
    for(int i = 0; i < 7; i++) {
      QueryStatus status = querier.query("t1", "", 0);
      assertEquals((Integer)((i % 2) * 2), querier.getPartitionRoundRobin().get(0));
      assertEquals((Integer)0, status.getShard());
      assertEquals(null, status.getError());
    }
  }
View Full Code Here

     * Here we are testing round robin when there are failing nodes in a shard. We have 4 alive nodes with 2 failing nodes.
     * The assertion is the same than in the case of some dead nodes but we do another unit test because the business logic
     * inside the querier is different and we might have a bug anyway.
     */
    for(int i = 0; i < 7; i++) {
      QueryStatus status = querier.query("t1", "", 0);
      assertEquals((Integer)((i % 2) * 2), querier.getPartitionRoundRobin().get(0));
      assertEquals((Integer)0, status.getShard());
      assertEquals(null, status.getError());
    }
  }
View Full Code Here

TOP

Related Classes of com.splout.db.qnode.beans.QueryStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.