Package com.splout.db.qnode

Examples of com.splout.db.qnode.QNodeHandler


  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


    TestUtils.cleanUpTmpFolders(this.getClass().getName(), 2);
  }
 
  @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);
      /*
       * Create 5 successful versions. current-version will be set to last one.
       */
     
      // TODO
     
//      coord.getTablespaces().put(new TablespaceVersion("t1", 0l), new Tablespace(null, null, 0l, 0l));
//      coord.getTablespaces().put(new TablespaceVersion("t1", 1l), new Tablespace(null, null, 1l, 0l));
//      coord.getTablespaces().put(new TablespaceVersion("t1", 2l), new Tablespace(null, null, 2l, 0l));
//      coord.getTablespaces().put(new TablespaceVersion("t1", 3l), new Tablespace(null, null, 3l, 0l));
//      coord.getTablespaces().put(new TablespaceVersion("t1", 4l), new Tablespace(null, null, 4l, 0l));

      Map<String, Long> versionsBeingServed = new HashMap<String, Long>();
      versionsBeingServed.put("t1", 4l);
      coord.getVersionsBeingServed().put(CoordinationStructures.VERSIONS_BEING_SERVED, versionsBeingServed);

      handler.init(config);
     
      List<SwitchVersionRequest> rRequest = new ArrayList<SwitchVersionRequest>();
      SwitchVersionRequest theRequest = new SwitchVersionRequest("t1", 3);
      rRequest.add(theRequest);
      handler.rollback(rRequest);
     
      new TestUtils.NotWaitingForeverCondition() {
        @Override
        public boolean endCondition() {
          return handler.getContext().getCurrentVersionsMap().get("t1") != null &&
              handler.getContext().getCurrentVersionsMap().get("t1") == 3l;
        }
      }.waitAtMost(5000);
     
      assertEquals(3l, (long)coord.getCopyVersionsBeingServed().get("t1"));
     
      /*
       * Changing our mind : now back to previous version 4
       */
      theRequest = new SwitchVersionRequest("t1", 4);
      rRequest = new ArrayList<SwitchVersionRequest>();
      rRequest.add(theRequest);
      handler.rollback(rRequest);
           
      new TestUtils.NotWaitingForeverCondition() {
        @Override
        public boolean endCondition() {
          return handler.getContext().getCurrentVersionsMap().get("t1") != null &&
              handler.getContext().getCurrentVersionsMap().get("t1") == 4l;
        }
      }.waitAtMost(5000);
     
      assertEquals(4l, (long)coord.getCopyVersionsBeingServed().get("t1"));
    } finally {
      handler.close();
      Hazelcast.shutdownAll();
    }
  }
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);
     
      /*
       * Create 5 successful versions. current-version will be set to last one.
       */
     
      // TODO
     
//      for(int i = 0; i < 5; i++) {
//        coord.getTablespaces().put(new TablespaceVersion("t1", i), new Tablespace(null, null, i, 0l));
//        coord.getTablespaces().put(new TablespaceVersion("t2", i), new Tablespace(null, null, i, 0l));
//        coord.getTablespaces().put(new TablespaceVersion("t3", i), new Tablespace(null, null, i, 0l));
//      }
     
      // T1 -> current version 4
      // T2 -> current version 3
      // T3 -> current version 2
      Map<String, Long> versionsBeingServed = new HashMap<String, Long>();
      versionsBeingServed.put("t1", 4l);
      versionsBeingServed.put("t2", 3l);
      versionsBeingServed.put("t3", 2l);
      coord.getVersionsBeingServed().put(CoordinationStructures.VERSIONS_BEING_SERVED, versionsBeingServed);
     
      handler.init(config);
     
      List<SwitchVersionRequest> rRequest = new ArrayList<SwitchVersionRequest>();

      // T1 -> rollback to version 2
      // T2 -> rollback to version 1
      // T3 -> rollback to version 0
      SwitchVersionRequest theRequest = new SwitchVersionRequest("t1", 2l);
      rRequest.add(theRequest);
      theRequest = new SwitchVersionRequest("t2", 1l);
      rRequest.add(theRequest);
      theRequest = new SwitchVersionRequest("t3", 0l);
      rRequest.add(theRequest);
     
      handler.rollback(rRequest);
     
      new TestUtils.NotWaitingForeverCondition() {
        @Override
        public boolean endCondition() {
          return
              handler.getContext().getCurrentVersionsMap().get("t1") != null &&
              handler.getContext().getCurrentVersionsMap().get("t1") == 2l;
        }
      }.waitAtMost(5000);

      assertEquals(2l, (long)coord.getCopyVersionsBeingServed().get("t1"));
      assertEquals(1l, (long)coord.getCopyVersionsBeingServed().get("t2"));
      assertEquals(0l, (long)coord.getCopyVersionsBeingServed().get("t3"));
     
      assertEquals(2l, (long)handler.getContext().getCurrentVersionsMap().get("t1"));
      assertEquals(1l, (long)handler.getContext().getCurrentVersionsMap().get("t2"));
      assertEquals(0l, (long)handler.getContext().getCurrentVersionsMap().get("t3"));
     
    } finally {
      handler.close();
      Hazelcast.shutdownAll();
    }
  }
View Full Code Here

          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;
View Full Code Here

      config.setProperty(FetcherProperties.TEMP_DIR, config.getString(FetcherProperties.TEMP_DIR) + "-" + i);
      DNode dnode = new DNode(config, new DNodeHandler());
      dnode.init();
    }
    QNode qnode = new QNode();
    qnode.start(config, new QNodeHandler());
  }
View Full Code Here

      // Assert that there is only MAX_VERSIONS versions of the tablespace (due to old version cleanup)
      new TestUtils.NotWaitingForeverCondition() {

        @Override
        public boolean endCondition() {
          QNodeHandler handler = (QNodeHandler) qNodes.get(0).getHandler();
          int seenVersions = 0;
          for(Map.Entry<TablespaceVersion, Tablespace> tablespaceVersion : handler.getContext()
              .getTablespaceVersionsMap().entrySet()) {
            if(tablespaceVersion.getKey().getTablespace().equals(TABLESPACE)) {
              seenVersions++;
            }
          }
View Full Code Here

    testConfig.setProperty(DNodeProperties.HANDLE_TEST_COMMANDS, true);
    final DNode dnode = new DNode(testConfig, new DNodeHandler());
    dnode.init();
   
    final QNode qnode = new QNode();
    qnode.start(testConfig, new QNodeHandler());

    // Wait until the QNode has 1 Dnode in the list
    waitUntilThereAreThatManyDNodes(qnode, 1);
   
    dnode.testCommand(TestCommands.SHUTDOWN.toString());
View Full Code Here

    /*
     * Create an ensemble of QNodes
     */
    for(int i = 0; i < nQnodes; i++) {
      SploutConfiguration qNodeConfig = SploutConfiguration.getTestConfig();
      QNode qnode = TestUtils.getTestQNode(qNodeConfig, new QNodeHandler());
      qNodes.add(qnode);
    }

    /*
     * Create an ensemble of DNodes
View Full Code Here

TOP

Related Classes of com.splout.db.qnode.QNodeHandler

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.