Package com.splout.db.thrift

Examples of com.splout.db.thrift.PartitionMetadata


          deployAction.setTablespace(req.getTablespace());
          deployAction.setVersion(version);
          deployAction.setPartition(rEntry.getShard());

          // Add partition metadata to the deploy action for DNodes to save it
          PartitionMetadata metadata = new PartitionMetadata();
          metadata.setMinKey(pEntry.getMin());
          metadata.setMaxKey(pEntry.getMax());
          metadata.setNReplicas(rEntry.getNodes().size());
          metadata.setDeploymentDate(deployDate);
          metadata.setInitStatements(req.getInitStatements());
          metadata.setEngineId(req.getEngine());

          deployAction.setMetadata(metadata);
          actionsSoFar.add(deployAction);
        }
      }
View Full Code Here


              continue;
            }
            Integer partitionName = new Integer(partition.getName());
            File metadataFile = DNodeHandler.getLocalMetadataFile(config, tablespaceName, partitionName, versionName);
            ThriftReader reader = new ThriftReader(metadataFile);
            PartitionMetadata metadata = (PartitionMetadata) reader.read(new PartitionMetadata());
            reader.close();
            if(servingInfo.get(tablespaceName) == null) {
              servingInfo.put(tablespaceName, new HashMap<Long, Map<Integer,PartitionMetadata>>());
            }
            if(servingInfo.get(tablespaceName).get(versionName) == null) {
View Full Code Here

            // I always succeed.
            try {
              // Create the necessary disk structures so this node's partition is promoted to Hazelcast
              getLocalStorageFolder("t1", 0, version).mkdirs();
              ThriftWriter writer = new ThriftWriter(getLocalMetadataFile("t1", 0, version));
              PartitionMetadata metadata = new PartitionMetadata();
              // we need to set expected replication factor, otherwise replica balancing will not trigger for this test
              metadata.setNReplicas(2);
              writer.write(metadata);
              writer.close();
              new File(getLocalStorageFolder("t1", 0, version), "0.db").createNewFile();
              // promote info to Hazelcast
              getDnodesRegistry().changeInfo(new DNodeInfo(config));
View Full Code Here

              throw new DNodeException(EXCEPTION_ORDINARY, "Requested tablespace (" + tablespace
                  + ") + version (" + version + ") is not available.");
            }
            File metadata = getLocalMetadataFile(tablespace, partition, version);
            ThriftReader reader = new ThriftReader(metadata);
            PartitionMetadata partitionMetadata = (PartitionMetadata) reader
                .read(new PartitionMetadata());
            reader.close();
            dbPoolInCache = loadManagerInEHCache(tablespace, version, partition, dbFolder, partitionMetadata);
          }
        }
        // Query the {@link SQLite4JavaManager} and return
View Full Code Here

            if(deployDate != -1 && (deployDate != partition.getValue().getDeploymentDate())) {
              throw new TablespaceVersionInfoException(
                  "Inconsistent partition metadata within same node, deploy date was " + deployDate
                      + " versus " + partition.getValue().getDeploymentDate());
            }
            PartitionMetadata metadata = partition.getValue();
            Integer shard = partition.getKey();
            // Create a PartitionEntry according to this PartitionMetadata
            PartitionEntry myEntry = new PartitionEntry();
            myEntry.setMax(metadata.getMaxKey());
            myEntry.setMin(metadata.getMinKey());
            myEntry.setShard(shard);
            PartitionEntry existingPartitionEntry = null;
            // Look for an existing PartitionEntry for the same shard in the PartitionMap
            if(!partitionMap.contains(myEntry)) {
              if(!event.equals(DNodeEvent.LEAVE)) {
                // In this case all conditions are met for adding a new entry to the PartitionMap
                partitionMap.add(myEntry);
                // Note that now the PartitionMap is not necessarily sorted! let's sort it now
                Collections.sort(partitionMap);
              }
            } else {
              // Check consistency of this Partition Metadata
              existingPartitionEntry = partitionMap.get(partitionMap.indexOf(myEntry));
              if(existingPartitionEntry.getMax() == null || myEntry.getMax() == null) {
                if(!(existingPartitionEntry.getMax() == null && myEntry.getMax() == null)) {
                  throw new TablespaceVersionInfoException(
                      "Inconsistent partition metadata between nodes: " + existingPartitionEntry
                          + " versus " + myEntry);
                }
              } else {
                if(!existingPartitionEntry.getMax().equals(myEntry.getMax())) {
                  throw new TablespaceVersionInfoException(
                      "Inconsistent partition metadata between nodes: " + existingPartitionEntry
                          + " versus " + myEntry);
                }
              }
              if(existingPartitionEntry.getMin() == null || myEntry.getMin() == null) {
                if(!(existingPartitionEntry.getMin() == null && myEntry.getMin() == null)) {
                  throw new TablespaceVersionInfoException(
                      "Inconsistent partition metadata between nodes: " + existingPartitionEntry
                          + " versus " + myEntry);
                }
              } else {
                if(!existingPartitionEntry.getMin().equals(myEntry.getMin())) {
                  throw new TablespaceVersionInfoException(
                      "Inconsistent partition metadata between nodes: " + existingPartitionEntry
                          + " versus " + myEntry);
                }
              }
            }
            // Create a ReplicationEntry according to this PartitionMetadata
            // Will only contain this DNode as we don't know about the others yet
            ReplicationEntry reEntry = new ReplicationEntry();
            reEntry.setShard(shard);
            reEntry.setExpectedReplicationFactor(metadata.getNReplicas());
            reEntry.setNodes(new ArrayList<String>());
            // Look for an existing ReplicationEntry for the same shard in the ReplicationMap
            if(replicationMap.contains(reEntry)) {
              ReplicationEntry existingEntry = replicationMap.get(replicationMap.indexOf(reEntry));
              if(event.equals(DNodeEvent.LEAVE)) {
View Full Code Here

  @Test
  public void test() throws TablespaceVersionInfoException {

    SploutConfiguration config = SploutConfiguration.getTestConfig();

    PartitionMetadata metadata3Replicas = new PartitionMetadata();
    metadata3Replicas.setNReplicas(3);
    PartitionMetadata metadata1Replicas = new PartitionMetadata();
    metadata1Replicas.setNReplicas(1);

    // t1, version 1, partition 0 -> 3 replicas, only 2 dnodes: dnode1, dnode2
    DNodeInfoFacade facade1 = new DNodeInfoFacade("dnode1");
    facade1.addTablespaceVersionPartition("t1", 1l, 0, metadata3Replicas);
    DNodeInfoFacade facade2 = new DNodeInfoFacade("dnode2");
View Full Code Here

      DeployAction deploy = new DeployAction();
      deploy.setTablespace("tablespace3");
      deploy.setDataURI("file:///foo");
      deploy.setPartition(0);
      deploy.setVersion(1l);
      deploy.setMetadata(new PartitionMetadata());
      client.deploy(Arrays.asList(new DeployAction[] { deploy }), 1l);
      waitForDeployToFinish(client);

      Assert.assertEquals(true, dHandler.lastDeployTimedout.get());
      Assert.assertEquals(false, dHandler.deployInProgress.get() > 0);
View Full Code Here

      DeployAction deploy = new DeployAction();
      deploy.setTablespace("tablespace1");
      deploy.setDataURI(new File(DB_1 + ".1", "foo.db").toURI().toString());
      deploy.setPartition(0);
      deploy.setVersion(1l);
      deploy.setMetadata(new PartitionMetadata());
      client.deploy(Arrays.asList(new DeployAction[] { deploy }), 1l);
     
      Thread.sleep(1000);
      waitForDeployToFinish(client);

      Thread.sleep(200);
     
      Assert.assertEquals(false, dHandler.lastDeployTimedout.get());
      Assert.assertEquals(false, dHandler.deployInProgress.get() > 0);

      client.sqlQuery("tablespace1", 1l, 0, "SELECT 1;");
      Assert.assertEquals(dHandler.dbCache.getKeysWithExpiryCheck().size(), 1);

      deploy = new DeployAction();
      deploy.setTablespace("tablespace1");
      deploy.setDataURI(new File(DB_2 + ".1", "foo.db").toURI().toString());
      deploy.setPartition(0);
      deploy.setVersion(2l);
      deploy.setMetadata(new PartitionMetadata());
      client.deploy(Arrays.asList(new DeployAction[] { deploy }), 2l);
     
      Thread.sleep(1000);
      waitForDeployToFinish(client);
View Full Code Here

      DeployAction deploy = new DeployAction();
      deploy.setTablespace("tablespace1");
      deploy.setDataURI(new File(DB_1 + ".2", "foo.db").toURI().toString());
      deploy.setVersion(1l);
      deploy.setPartition(0);
      deploy.setMetadata(new PartitionMetadata());
      client.deploy(Arrays.asList(new DeployAction[] { deploy }), 1l);
      waitForDeployToFinish(client);

      Thread.sleep(200);
     
      Assert.assertEquals(false, dHandler.lastDeployTimedout.get());
      Assert.assertEquals(false, dHandler.deployInProgress.get() > 0);

      deploy = new DeployAction();
      deploy.setTablespace("tablespace1");
      deploy.setDataURI(new File(DB_2 + ".2", "foo.db").toURI().toString());
      deploy.setVersion(2l);
      deploy.setPartition(0);
      deploy.setMetadata(new PartitionMetadata());
      client.deploy(Arrays.asList(new DeployAction[] { deploy }), 2l);
      waitForDeployToFinish(client);

      ArrayList resultsV1 = JSONSerDe.deSer(client.sqlQuery("tablespace1", 1l, 0, "SELECT * FROM t;"),
          ArrayList.class);
View Full Code Here

      deploy.setTablespace("tablespace2");
      TestUtils.createFooDatabase(FOO_DEPLOY_FOLDER, 1, "foo");
      deploy.setDataURI(new File(FOO_DEPLOY_FOLDER, "foo.db").toURI().toString());
      deploy.setPartition(0);
      deploy.setVersion(1l);
      deploy.setMetadata(new PartitionMetadata());
      client.deploy(Arrays.asList(new DeployAction[] { deploy }), 1l);
      waitForDeployToFinish(client);
      Thread.sleep(200);
      File expectedDataFolder = dHandler.getLocalStorageFolder("tablespace2", 0, 1);
      Assert.assertTrue(expectedDataFolder.exists());
View Full Code Here

TOP

Related Classes of com.splout.db.thrift.PartitionMetadata

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.