Пример #1
0
    @Override
    public void run() {
      // log.info("START");
      try {
        while (execute) {
          int next = random.nextInt(nodesMaxIndex);
          NodeData rndNode = parentNodes[next];
          if (random.nextBoolean()) {
            // put single item
            if (random.nextBoolean()) {
              // node
              cache.put(
                  new TransientNodeData(
                      QPath.makeChildPath(
                          rndNode.getQPath(), InternalQName.parse("[]childNode-" + next)),
                      IdGenerator.generate(),
                      1,
                      Constants.NT_UNSTRUCTURED,
                      new InternalQName[0],
                      1,
                      IdGenerator.generate(),
                      rndNode.getACL()));
            } else {
              TransientPropertyData pd =
                  new TransientPropertyData(
                      QPath.makeChildPath(
                          rndNode.getQPath(), InternalQName.parse("[]property-" + next)),
                      IdGenerator.generate(),
                      1,
                      PropertyType.STRING,
                      rndNode.getIdentifier(),
                      false,
                      new TransientValueData("prop data"));
              cache.put(pd);
            }
            itemsProcessed++;
          } else {
            // put list of childs
            if (random.nextBoolean()) {
              // nodes
              List<NodeData> cn = createNodesData(rndNode, 100);
              cache.addChildNodes(rndNode, cn);
              itemsProcessed += cn.size();
            } else {
              // properties w/o value
              List<PropertyData> cp = createPropertiesData(rndNode, 100);
              cache.addChildProperties(rndNode, cp);
              itemsProcessed += cp.size();
            }
          }

          Thread.sleep(putTimeout);
        }
      } catch (Exception e) {
        log.error(getName() + " " + e, e);
      }
      // log.info("FINISH");
    }
Пример #2
0
  /**
   * properties w/o value.
   *
   * @param parent
   * @param count
   * @return
   * @throws Exception
   */
  private List<PropertyData> createPropertiesData(NodeData parent, int count) throws Exception {

    List<PropertyData> props = new ArrayList<PropertyData>();

    for (int i = 1; i <= count; i++) {
      TransientPropertyData pd =
          new TransientPropertyData(
              QPath.makeChildPath(parent.getQPath(), InternalQName.parse("[]property-" + i)),
              IdGenerator.generate(),
              1,
              PropertyType.STRING,
              parent.getIdentifier(),
              false,
              new TransientValueData("prop data"));
      props.add(pd);
    }

    return props;
  }
Пример #3
0
  private List<NodeData> createNodesData(NodeData parent, int count) throws Exception {

    List<NodeData> nodes = new ArrayList<NodeData>();

    for (int i = 1; i <= count; i++) {
      nodes.add(
          new TransientNodeData(
              QPath.makeChildPath(parent.getQPath(), InternalQName.parse("[]node" + i)),
              IdGenerator.generate(),
              1,
              Constants.NT_UNSTRUCTURED,
              new InternalQName[0],
              1,
              IdGenerator.generate(),
              parent.getACL()));
    }

    return nodes;
  }