Package com.splout.db.common

Examples of com.splout.db.common.SploutConfiguration


* Use this class to quickly run "n" DNodes in localhost.
*/
public class DNodeEnsemble {

  public void runForever(int nDNodes) throws Exception {
    SploutConfiguration config = SploutConfiguration.getTestConfig();
    for(int i = 0; i < nDNodes; i++) {
      config = SploutConfiguration.getTestConfig();
      // we need to change some props for avoiding conflicts, ports, etc
      config.setProperty(DNodeProperties.PORT, config.getInt(DNodeProperties.PORT) + i);
      config.setProperty(DNodeProperties.DATA_FOLDER, config.getString(DNodeProperties.DATA_FOLDER) + "-" + i);
      config.setProperty(FetcherProperties.TEMP_DIR, config.getString(FetcherProperties.TEMP_DIR) + "-" + i);
      DNode dnode = new DNode(config, new DNodeHandler());
      dnode.init();
    }
  }
View Full Code Here


* A program for running one QNode and one DNode with all default configurations.
*/
public class OneShardEnsemble {

  public void runForever() throws Exception {
    SploutConfiguration config = SploutConfiguration.getTestConfig();
    DNode dnode = new DNode(config, new DNodeHandler());
    dnode.init();
    QNode qnode = new QNode();
    qnode.start(config, new QNodeHandler());
  }
View Full Code Here

    try {
      // Create an ensemble of 5 DNodes
      List<PartitionEntry> partitions = new ArrayList<PartitionEntry>();
      List<ReplicationEntry> replicationEntries = new ArrayList<ReplicationEntry>();
      for(int i = 0; i < 5; i++) {
        SploutConfiguration dNodeConfig = SploutConfiguration.getTestConfig();
        // We instantiate a DNode with a handler that returns "DNode" + i for any query
        DNode dnode = TestUtils.getTestDNode(dNodeConfig, new TellIDHandler("DNode" + i), "dnode-"
            + this.getClass().getName() + "-" + i);
        dNodes.add(dnode);
        // Define the partition for this DNode
        // DNode 0 will have [10, 20), DNode 1 [20, 30], ...
        PartitionEntry partitionEntry = new PartitionEntry();
        partitionEntry.setMin((i * 10 + 10) + "");
        partitionEntry.setMax((i * 10 + 20) + "");
        partitionEntry.setShard(i);
        partitions.add(partitionEntry);
        // And the replication
        ReplicationEntry repEntry = new ReplicationEntry();
        repEntry.setShard(i);
        repEntry.setNodes(Arrays.asList(new String[] { "localhost:" + dNodeConfig.getInt(DNodeProperties.PORT) }));
        replicationEntries.add(repEntry);
      }

      Tablespace tablespace1 = new Tablespace(new PartitionMap(partitions), new ReplicationMap(replicationEntries), 1l,
          0l);
View Full Code Here

public class TestQNode {

  @Test
  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();
      }
View Full Code Here

    }
  }
  @Test
  public void testDeployFailover() throws Throwable {
    final QNodeHandler handler = new QNodeHandler();
    SploutConfiguration config = SploutConfiguration.getTestConfig();
    SploutConfiguration config1 = SploutConfiguration.getTestConfig();
    SploutConfiguration config2 = SploutConfiguration.getTestConfig();
   
    // Replica balancing should already be enabled for tests but we just make it explicit here -->
    config.setProperty(QNodeProperties.REPLICA_BALANCE_ENABLE, true);
    config.setProperty(QNodeProperties.WARMING_TIME, 0);
    config.setProperty(QNodeProperties.DEPLOY_SECONDS_TO_CHECK_ERROR, 1); // this has to be quick for testing
View Full Code Here

  }
 
  @Test
  public void testSimpleChange() throws Throwable {
    final QNodeHandler handler = new QNodeHandler();
    SploutConfiguration config = SploutConfiguration.getTestConfig();
    try {

      HazelcastInstance hz = Hazelcast.newHazelcastInstance(HazelcastConfigBuilder.build(config));
      CoordinationStructures coord = new CoordinationStructures(hz);
      /*
 
View Full Code Here

 
  @Test
  public void testMultiRollback() throws Throwable {
    // Here we will have more than one tablespace and we will rollback them all
    final QNodeHandler handler = new QNodeHandler();
    SploutConfiguration config = SploutConfiguration.getTestConfig();
    try {
      HazelcastInstance hz = Hazelcast.newHazelcastInstance(HazelcastConfigBuilder.build(config));
      CoordinationStructures coord = new CoordinationStructures(hz);
     
      /*
 
View Full Code Here

  }
 
  @Test
  @Ignore
  public void testAllFailingDNodes() throws JSONSerDeException {
    SploutConfiguration testConfig = SploutConfiguration.getTestConfig();
    QNodeHandlerContext context = new QNodeHandlerContext(testConfig, null);

    List<ReplicationEntry> rEntries = new ArrayList<ReplicationEntry>();
    rEntries.add(new ReplicationEntry(0, "localhost:4444", "localhost:5555", "localhost:6666"));
View Full Code Here

    }
  }
 
  @Test
  public void testRoundRobin() throws Throwable {
    SploutConfiguration testConfig = SploutConfiguration.getTestConfig();
    // A handler that returns OK to any query
    IDNodeHandler okQueryHandler = new IDNodeHandler() {
      @Override
      public void init(SploutConfiguration config) throws Exception {
      }
View Full Code Here

    }
  }
 
  @Test
  public void testRoundRobinWithSomeDeadNodes() throws Throwable {
    SploutConfiguration testConfig = SploutConfiguration.getTestConfig();
    // A handler that returns OK to any query
    IDNodeHandler okQueryHandler = new IDNodeHandler() {
      @Override
      public void init(SploutConfiguration config) throws Exception {
      }
View Full Code Here

TOP

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

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.