Examples of DNode


Examples of com.avaje.ebeaninternal.server.lib.util.Dnode

  private void readXmlRawSql(DeployBeanDescriptor<?> deployDesc, List<Dnode> entityXml) {

    List<Dnode> rawSqlQueries = xmlConfig.find(entityXml, "raw-sql");
    for (int i = 0; i < rawSqlQueries.size(); i++) {
      Dnode rawSqlDnode = rawSqlQueries.get(i);
      String name = rawSqlDnode.getAttribute("name");
      if (isEmpty(name)) {
        throw new IllegalStateException("raw-sql for " + deployDesc.getFullName() + " missing name attribute");
      }
      Dnode queryNode = rawSqlDnode.find("query");
      if (queryNode == null) {
        throw new IllegalStateException("raw-sql for " + deployDesc.getFullName() + " missing query element");
      }
      String sql = queryNode.getNodeContent();
      if (isEmpty(sql)) {
        throw new IllegalStateException("raw-sql for " + deployDesc.getFullName() + " has empty sql in the query element?");
      }

      List<Dnode> columnMappings = rawSqlDnode.findAll("columnMapping", 1);

      RawSqlBuilder rawSqlBuilder = RawSqlBuilder.parse(sql);
      for (int j = 0; j < columnMappings.size(); j++) {
        Dnode cm = columnMappings.get(j);
        String column = cm.getAttribute("column");
        String property = cm.getAttribute("property");
        rawSqlBuilder.columnMapping(column, property);
      }
      RawSql rawSql = rawSqlBuilder.create();

      DeployNamedQuery namedQuery = new DeployNamedQuery(name, rawSql);
View Full Code Here

Examples of com.avaje.ebeaninternal.server.lib.util.Dnode

    List<Dnode> namedQueries = entityXml.findAll("named-query", 1);

    for (Dnode namedQueryXml : namedQueries) {

      String name = (String) namedQueryXml.getAttribute("name");
      Dnode query = namedQueryXml.find("query");
      if (query == null) {
        logger.warn("orm.xml " + deployDesc.getFullName() + " named-query missing query element?");

      } else {
        String oql = query.getNodeContent();
        // TODO: QueryHints not read from xml yet
        if (name == null || oql == null) {
          logger.warn("orm.xml " + deployDesc.getFullName() + " named-query has no query content?");
        } else {
          // add the named query
View Full Code Here

Examples of com.splout.db.dnode.DNode

      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

Examples of com.splout.db.dnode.DNode

*/
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

Examples of com.splout.db.dnode.DNode

      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);
      handler.getContext().getTablespaceVersionsMap().put(new TablespaceVersion("tablespace1", 1l), tablespace1);
      handler.getContext().getCurrentVersionsMap().put("tablespace1", 1l);

      // The following has to be read as: multi-query range [23-25)
      // The impacted shard will be 1 [20-30)
      List<String> keyMins = Arrays.asList(new String[] { "23" });
      List<String> keyMaxs = Arrays.asList(new String[] { "25" });

      ArrayList<QueryStatus> resultObj = handler.multiQuery("tablespace1", keyMins, keyMaxs, "SELECT 1;");
      assertEquals(1, resultObj.size());

      assertTrue(1 == resultObj.get(0).getShard());
      assertEquals("DNode1", resultObj.get(0).getResult().get(0));

      // The following has to be read as: multi-query [13-25) Union [45-55).
      // The impacted shards will be 0 [10-20), 1 [20, 30), 3 [40, 50), 5 [50, 60)
      keyMins = Arrays.asList(new String[] { "13", "45" });
      keyMaxs = Arrays.asList(new String[] { "25", "55" });

      resultObj = handler.multiQuery("tablespace1", keyMins, keyMaxs, "SELECT 1;");

      assertEquals(4, resultObj.size());

      // The impacted shards will be 0 [0-10), 1 [10, 20), 3 [30, 40), 4 [40, 50)
      assertTrue(0 == resultObj.get(0).getShard());
      assertTrue(1 == resultObj.get(1).getShard());
      assertTrue(3 == resultObj.get(2).getShard());
      assertTrue(4 == resultObj.get(3).getShard());

      assertEquals("DNode0", resultObj.get(0).getResult().get(0));
      assertEquals("DNode1", resultObj.get(1).getResult().get(0));
      assertEquals("DNode3", resultObj.get(2).getResult().get(0));
      assertEquals("DNode4", resultObj.get(3).getResult().get(0));

      // The following has to be read as: multi-query the opened range (-Infinity, Infinity) regardless of the key type.
      // The impacted shards will be all: 0, 1, 2, 3, 4
      keyMins = Arrays.asList(new String[] {});
      keyMaxs = Arrays.asList(new String[] {});

      resultObj = handler.multiQuery("tablespace1", keyMins, keyMaxs, "SELECT 1;");

      assertEquals(5, resultObj.size());

      for(int i = 0; i < 5; i++) {
        assertTrue(i == resultObj.get(i).getShard());
        assertEquals("DNode" + i, resultObj.get(i).getResult().get(0));
      }
    } finally {
      handler.close();
      for(DNode dnode : dNodes) {
        dnode.stop();
      }
      Hazelcast.shutdownAll();
    }
  }
View Full Code Here

Examples of com.splout.db.dnode.DNode

    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
   
    DNodeHandler dHandler = new DNodeHandler();
    DNode dnode1 = TestUtils
        .getTestDNode(config1, dHandler, "dnode-" + this.getClass().getName() + "-1");

    SucceedingDNodeHandler succeed = new SucceedingDNodeHandler();
    DNode dnode2 = TestUtils.getTestDNode(config2, succeed, "dnode-" + this.getClass().getName() + "-2");

    try {
      handler.init(config);

      ReplicationEntry repEntry1 = new ReplicationEntry(0, dnode1.getAddress(), dnode2.getAddress());

      DeployRequest deployRequest1 = new DeployRequest();
      deployRequest1.setTablespace("t1");
      deployRequest1.setPartitionMap(PartitionMap.oneShardOpenedMap().getPartitionEntries());
      deployRequest1.setReplicationMap(Arrays.asList(repEntry1));

      File fakeDeployFolder = new File(DEPLOY_FOLDER_THAT_DOESNT_EXIST);
      // Remember we don't create the folder on purpose for making the DNode fail
      deployRequest1.setData_uri(fakeDeployFolder.toURI().toString());

      List<DeployRequest> l = new ArrayList<DeployRequest>();
      l.add(deployRequest1);

      handler.deploy(l);

      // wait until deploy finished
      new TestUtils.NotWaitingForeverCondition() {
       
        @Override
        public boolean endCondition() {
          return handler.getContext().getTablespaceVersionsMap().size() == 1;
        }
      }.waitAtMost(5000);

      // wait until replica balancer re-balanced the under-replicated partition
      new TestUtils.NotWaitingForeverCondition() {
       
        @Override
        public boolean endCondition() {
          ReplicationMap map = handler.getContext().getTablespaceVersionsMap().values().iterator().next().getReplicationMap();
          return map.getReplicationEntries().get(0).getNodes().size() == 2;
        }
      }.waitAtMost(5000);

      // everything OK
    } finally {
      handler.close();
      dnode1.stop();
      dnode2.stop();
      Hazelcast.shutdownAll();
    }
  }
View Full Code Here

Examples of com.splout.db.dnode.DNode

    fetcherTmp.mkdir();
    CatchAndRetry dNodeInit = new CatchAndRetry(TTransportException.class, 50) {

      @Override
      public void businessLogic() throws Throwable {
        DNode dNode = new DNode(testConfig, handler);
        dNode.init();
        reference.set(dNode);
      }
     
      @Override
      public void retryLogic() {
View Full Code Here

Examples of com.splout.db.dnode.DNode

      public String testCommand(String command) throws DNodeException {
        // TODO Auto-generated method stub
        return null;
      }
    };
    DNode dnode1 = TestUtils.getTestDNode(testConfig, okQueryHandler, "dnode-" + this.getClass().getName() + "-1");
    DNode dnode2 = TestUtils.getTestDNode(testConfig, okQueryHandler, "dnode-" + this.getClass().getName() + "-2");
   
    List<ReplicationEntry> rEntries = new ArrayList<ReplicationEntry>();
    rEntries.add(new ReplicationEntry(0, dnode1.getAddress(), dnode2.getAddress()));

    QNodeHandlerContext context = new QNodeHandlerContext(testConfig, null);
   
    Tablespace tablespace = new Tablespace(PartitionMap.oneShardOpenedMap(), new ReplicationMap(rEntries), 0, 0);
    context.getTablespaceVersionsMap().put(new TablespaceVersion("t1", 0l), tablespace);
View Full Code Here

Examples of com.splout.db.dnode.DNode

      public String testCommand(String command) throws DNodeException {
        // TODO Auto-generated method stub
        return null;
      }
    };
    DNode dnode1 = TestUtils.getTestDNode(testConfig, okQueryHandler, "dnode-" + this.getClass().getName() + "-1");
    DNode dnode2 = TestUtils.getTestDNode(testConfig, okQueryHandler, "dnode-" + this.getClass().getName() + "-2");
   
    List<ReplicationEntry> rEntries = new ArrayList<ReplicationEntry>();
    rEntries.add(new ReplicationEntry(0, dnode1.getAddress(), "fakeaddress:1111", dnode2.getAddress(), "fakeaddress:2222"));

    QNodeHandlerContext context = new QNodeHandlerContext(testConfig, null);
   
    Tablespace tablespace = new Tablespace(PartitionMap.oneShardOpenedMap(), new ReplicationMap(rEntries), 0, 0);
    context.getTablespaceVersionsMap().put(new TablespaceVersion("t1", 0l), tablespace);
View Full Code Here

Examples of com.splout.db.dnode.DNode

      public String testCommand(String command) throws DNodeException {
        // TODO Auto-generated method stub
        return null;
      }
    };
    DNode dnode1 = TestUtils.getTestDNode(testConfig, okQueryHandler, "dnode-" + this.getClass().getName() + "-1");
    DNode dnode2 = TestUtils.getTestDNode(testConfig, okQueryHandler, "dnode-" + this.getClass().getName() + "-2");
   
    List<ReplicationEntry> rEntries = new ArrayList<ReplicationEntry>();
    rEntries.add(new ReplicationEntry(0, dnode1.getAddress(), "failingaddress:1111", dnode2.getAddress(), "failingaddress:2222"));

    QNodeHandlerContext context = new QNodeHandlerContext(testConfig, null);
   
    Tablespace tablespace = new Tablespace(PartitionMap.oneShardOpenedMap(), new ReplicationMap(rEntries), 0, 0);
    context.getTablespaceVersionsMap().put(new TablespaceVersion("t1", 0l), tablespace);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.