Package com.splout.db.common

Examples of com.splout.db.common.Tablespace


    if (version == null) {
      return new ArrayList<QueryStatus>(Arrays.asList(new QueryStatus[]{new ErrorQueryStatus(
          "No available version for tablespace " + tablespaceName)}));
    }
    // TODO Object creation (new TablespaceVersion), not very efficient for performance
    Tablespace tablespace = context.getTablespaceVersionsMap().get(
        new TablespaceVersion(tablespaceName, version));
    if (tablespace == null) { // This can happen if, at startup, we only received the version and not the DNodeInfo
      return new ArrayList<QueryStatus>(Arrays.asList(new QueryStatus[]{new ErrorQueryStatus(
          "No available information for tablespace version " + tablespaceName + "," + version)}));
    }
    if (keyMins.size() == 0) {
      impactedKeys.addAll(tablespace.getPartitionMap().findPartitions(null, null)); // all partitions are hit
    }
    for (int i = 0; i < keyMins.size(); i++) {
      impactedKeys.addAll(tablespace.getPartitionMap().findPartitions(keyMins.get(i), keyMaxs.get(i)));
    }
    ArrayList<QueryStatus> toReturn = new ArrayList<QueryStatus>();
    for (Integer shardKey : impactedKeys) {
      toReturn.add(querier.query(tablespaceName, sql, shardKey));
    }
View Full Code Here


      }
    }
    status.setdNodes(aliveDNodes);
    Map<String, Tablespace> tablespaceMap = new HashMap<String, Tablespace>();
    for (Map.Entry<String, Long> currentVersion : context.getCurrentVersionsMap().entrySet()) {
      Tablespace tablespace = context.getTablespaceVersionsMap().get(
          new TablespaceVersion(currentVersion.getKey(), currentVersion.getValue()));
      if (tablespace != null) { // this might happen and it is not a bug
        tablespaceMap.put(currentVersion.getKey(), tablespace);
      }
    }
View Full Code Here

  public Tablespace tablespace(String tablespace) throws Exception {
    Long version = context.getCurrentVersionsMap().get(tablespace);
    if (version == null) {
      return null;
    }
    Tablespace t = context.getTablespaceVersionsMap().get(new TablespaceVersion(tablespace, version));
    return t;
  }
View Full Code Here

    new File(TMP_FOLDER).mkdirs();

    createSploutEnsemble(N_QNODES, N_DNODES);
    Random random = new Random(SEED);

    Tablespace testTablespace = createTestTablespace(N_DNODES);

    File deployData = new File(TMP_FOLDER + "/" + "deploy-folder-" + random.nextInt());
    deployData.mkdir();

    for(int i = 0; i < N_DNODES; i++) {
      File dbData = new File(deployData, i + ".db");
      Files.write(new String("foo").getBytes(), dbData);
    }

    final SploutClient[] clients = new SploutClient[N_QNODES];

    for(int i = 0; i < N_QNODES; i++) {
      clients[i] = new SploutClient(getqNodes().get(i).getAddress());
    }
    final SploutClient client1 = clients[0];

    // Check that all QNodes have the full list of DNodes
    new TestUtils.NotWaitingForeverCondition() {
      @Override
      public boolean endCondition() {
        try {
          for(int i = 0; i < N_QNODES; i++) {
            List<String> dNodeList = clients[i].dNodeList();
            if(dNodeList.size() != 3) {
              return false;
            }
            QNodeHandler handler = (QNodeHandler)getqNodes().get(i).getHandler();
            for(String dnode: dNodeList) {
              if(handler.getContext().getThriftClientCache().get(dnode) == null) {
                return false;
              }
            }
          }
          return true;
        } catch(IOException e) {
          // test failed
          e.printStackTrace();
          return true;
        }
      }
    }.waitAtMost(5000);
   
    // Deploy
    client1.deploy("p1", testTablespace.getPartitionMap(), testTablespace.getReplicationMap(),
        deployData.getAbsoluteFile().toURI());

    // Check that all QNodes have the deployment data
    new TestUtils.NotWaitingForeverCondition() {
View Full Code Here

    }
  }

  @SuppressWarnings("unchecked")
  private void deployAndQueryRandomTablespace(Random random) throws Exception {
    Tablespace testTablespace = createTestTablespace(N_DNODES);

    File deployData = new File(TMP_FOLDER + "/" + "deploy-folder-" + random.nextInt());
    deployData.mkdir();

    // Each random deployment will have a fixed random string associated with it
    String randomStr = "ID" + Math.abs(random.nextInt());

    for(int i = 0; i < N_DNODES; i++) {
      File dbData = new File(deployData, i + ".db");
      SQLite4JavaClient manager = new SQLite4JavaClient(dbData + "", null);
      // We create a foo database with one integer and one text
      manager.query("CREATE TABLE foo (intCol INT, strCol TEXT);", 100);
      // We insert as many values as the ones we defined in the partition map
      for(int j = i * 10; j < (i * 10 + 10); j++) {
        manager.query("INSERT INTO foo VALUES (" + j + ", " + "'" + randomStr + "');", 100);
      }
      manager.close();
    }

    SploutConfiguration config = SploutConfiguration.getTestConfig();
    SploutClient client = getRandomQNodeClient(random, config);
    client.deploy("p1", testTablespace.getPartitionMap(), testTablespace.getReplicationMap(),
        deployData.getAbsoluteFile().toURI());

    Thread.sleep(2000); // TODO How to improve this.

    // Perform N queries, one to each DNode and validate the resultant data
View Full Code Here

    SploutConfiguration config = SploutConfiguration.getTestConfig();
    DNode dnode = TestUtils.getTestDNode(config, dHandler, "dnode-" + this.getClass().getName() + "-2");
    try {
      ReplicationEntry repEntry = new ReplicationEntry(0, dnode.getAddress());
      Tablespace tablespace1 = new Tablespace(PartitionMap.oneShardOpenedMap(), new ReplicationMap(
          Arrays.asList(repEntry)), 0l, 0l);
      handler.getContext().getTablespaceVersionsMap()
          .put(new TablespaceVersion("tablespace1", 0l), tablespace1);
      handler.getContext().getCurrentVersionsMap().put("tablespace1", 0l);
View Full Code Here

    SploutConfiguration config = SploutConfiguration.getTestConfig();
    DNode dnode = TestUtils.getTestDNode(config, dHandler, "dnode-" + this.getClass().getName() + "-6");
    try {
      ReplicationEntry repEntry = new ReplicationEntry(0, dnode.getAddress());
      Tablespace tablespace1 = new Tablespace(PartitionMap.oneShardOpenedMap(), new ReplicationMap(
          Arrays.asList(repEntry)), 0l, 0l);
      handler.getContext().getTablespaceVersionsMap()
          .put(new TablespaceVersion("tablespace1", 0l), tablespace1);
      handler.getContext().getCurrentVersionsMap().put("tablespace1", 0l);
View Full Code Here

    Map<Integer, Long> rowIdsPerPartition = new HashMap<Integer, Long>();
    context.put("rowIdsPerPartition", rowIdsPerPartition);

    // First get Tablespace metadata - nPartitions
    SploutClient client = new SploutClient(((String) context.get("qnodes")).split(","));
    Tablespace tablespace = client.tablespace(TABLESPACE);
    int nPartitions = tablespace.getPartitionMap().getPartitionEntries().size();

    // Then gather number of registers for each partition
    for(int partition = 0; partition < nPartitions; partition++) {
      String query = "SELECT MAX(rowid) FROM pagecounts;";
      Map<String, Object> obj = (Map<String, Object>) client
View Full Code Here

    for(int i = 0; i < N_QNODES; i++) {
      qNodeAddresses[i] = getqNodes().get(i).getAddress();
    }

    final SploutClient client = new SploutClient(qNodeAddresses);
    final Tablespace testTablespace = createTestTablespace(N_DNODES);
    final Random random = new Random(SEED);
    final AtomicBoolean failed = new AtomicBoolean(false);
    final AtomicInteger iteration = new AtomicInteger(0);
    final Set<Integer> iterationsSeen = new HashSet<Integer>();
View Full Code Here

    for(int i = 0; i < N_QNODES; i++) {
      qNodeAddresses[i] = getqNodes().get(i).getAddress();
    }

    final SploutClient client = new SploutClient(qNodeAddresses);
    final Tablespace testTablespace = createTestTablespace(N_DNODES);
    final Random random = new Random(SEED);
    final AtomicBoolean failed = new AtomicBoolean(false);

    deployIteration(0, random, client, testTablespace);
   
View Full Code Here

TOP

Related Classes of com.splout.db.common.Tablespace

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.