Package java.util.concurrent

Examples of java.util.concurrent.ConcurrentLinkedQueue$Node


        try {
            final PackageBuilder packageBuilder = new PackageBuilder();
            packageBuilder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_MultithreadFiringCheck.drl" ) ) );
            final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
            ruleBase.addPackage( packageBuilder.getPackage() );
            final Queue errorList = new ConcurrentLinkedQueue();
            final Thread t[] = new Thread[50];
            for ( int i = 0; i < t.length; i++ ) {
                final int count = i;
                t[i] = new Thread( new Runnable() {
                    public void run() {
                        try {
                            final int iterations = count * 15 + 3000;
                            final List results = new ArrayList();
                            final StatefulSession session2 = ruleBase.newStatefulSession();
                            session2.setGlobal( "results",
                                                results );
                            session2.insert( new Integer( -1 ) );
                            for ( int k = 0; k < iterations; k++ ) {
                                session2.insert( new Integer( k ) );
                                if ( k + 1 != session2.getAgenda().agendaSize() ) {
                                    errorList.add( "THREAD-" + count + " ERROR: expected agenda size=" + (k + 1) + " but was " + session2.getAgenda().agendaSize() );
                                }
                            }
                            session2.fireAllRules();
                            session2.dispose();
                            if ( results.size() != iterations ) {
                                errorList.add( "THREAD-" + count + " ERROR: expected fire count=" + iterations + " but was " + results.size() );
                            }
                        } catch ( Exception e ) {
                            errorList.add( "THREAD-" + count + " EXCEPTION: " + e.getMessage() );
                            e.printStackTrace();
                        }
                    }
                } );
                t[i].start();
            }
            for ( int i = 0; i < t.length; i++ ) {
                t[i].join();
            }
            assertTrue( "Errors during execution: " + errorList.toString(),
                        errorList.isEmpty() );
        } catch ( Exception e ) {
            e.printStackTrace();
            fail( "No exception should have been raised: " + e.getMessage() );
        }
    }
View Full Code Here


    // create list for SortContainers...
    final LinkedList<SortContainer> scl = new LinkedList<SortContainer>();

    // walk through children...
    for (int i = 0; i < node.jjtGetNumChildren(); ++i) {
      Node n = node.jjtGetChild(i); // get current child

      boolean desc = false; // set order ASC as default

      // current node is Order node...
      if (n instanceof ASTAscOrder || n instanceof ASTDescOrder) {
        if (n instanceof ASTDescOrder) // reset order value to DESC...
          desc = true;

        i++; // increase counter to get next child (which is sort
        // condition)
      }

      n = node.jjtGetChild(i); // get next child (which is sort condition)

      // parse node with the filter...
      final SPARQLParserVisitorImplementationDumper filterDumper = new SPARQLParserVisitorImplementationDumper();
      final String sortString = n.accept(filterDumper);

      try {
        final SortContainer sc = new SortContainer(this.prefix, desc,
            sortString); // create SortContainer
View Full Code Here

  @SuppressWarnings("unchecked")
  public Object visit(final ASTTripleSet node, final Object data) {
    final Item[] item = { null, null, null };

    for (int i = 0; i < 3; i++) {
      final Node n = node.jjtGetChild(i);
      item[i] = lupos.sparql1_1.operatorgraph.SPARQLCoreParserVisitorImplementation.getItem(n);
    }

    final HashMap<Item, QueryRDFTerm> rdfHash = (HashMap<Item, QueryRDFTerm>) data;
View Full Code Here

    // if AST exists...
    if (debugViewerCreator!=null && debugViewerCreator instanceof SPARQLDebugViewerCreator
        && ((SPARQLDebugViewerCreator) debugViewerCreator).getAST() != null) {

      final Node ast = ((SPARQLDebugViewerCreator) debugViewerCreator).getAST(); // get AST

      // walk through first level children of AST...
      for (int i = 0; i < ast.jjtGetNumChildren(); ++i) {
        final Node child = ast.jjtGetChild(i); // get current child

        if (child instanceof ASTSelectQuery) {
          final ASTSelectQuery selectChild = (ASTSelectQuery) child;

          // SELECT is not the wildcard *...
          if (!selectChild.isSelectAll()) {
            // walk through select children...
            for (int j = 0; j < selectChild.jjtGetNumChildren(); ++j) {
              final Node selectChildChild = selectChild
              .jjtGetChild(j);

              // child of select is variable...
              if (selectChildChild instanceof ASTVar) {
                final ASTVar var = (ASTVar) selectChildChild;

                // add name of variable to order...
                if (!resultOrder.contains(var.getName())) {
                  resultOrder.add(var.getName());
                }
              } else if (selectChildChild instanceof ASTAs) {
                for (int j1 = 0; j1 < selectChildChild
                .jjtGetNumChildren(); ++j1) {
                  final Node selectChildChildChild = selectChildChild
                  .jjtGetChild(j1);
                  if (selectChildChildChild instanceof ASTVar) {
                    final ASTVar var = (ASTVar) selectChildChildChild;

                    // add name of variable to order...
View Full Code Here

        ret += "\n";
        final String orderByClause = " ORDER BY "
          + toBeSorted.toString() + "\n";
        boolean ORDERBYADDED = false;
        while (i < node.jjtGetNumChildren()) {
          final Node child = node.jjtGetChild(i);
          if (!ORDERBYADDED
              && (child instanceof ASTOrderConditions
                  || child instanceof ASTLimit || child instanceof ASTOffset)) {
            ORDERBYADDED = true;
            ret += orderByClause;
View Full Code Here

  private static void determineVariables(final Node root,
      final Set<String> variables) {
    if (root instanceof ASTSelectQuery) {
      for (int i = 0; i < root.jjtGetNumChildren(); i++) {
        final Node node = root.jjtGetChild(i);
        if (node instanceof ASTGroupConstraint)
          determineVariables(node, variables);
      }
    } else {
      if (root instanceof ASTVar) {
View Full Code Here

  public DebugContainerQuery<BasicOperatorByteArray, Node> compileQueryDebugByteArray(
      final String query, final Prefix prefixInstance) throws ParseException {
    final SimpleNode root = StreamSPARQL1_1Parser.parse(query);
    if(root!=null){
      for (int i = 0; i < root.jjtGetNumChildren(); ++i) {
        final Node child = root.jjtGetChild(i); // get current child

        if (child instanceof ASTPrefixDecl) {
          // get prefix...
          final String prefix = ((ASTPrefixDecl) child).getPrefix();

          // get child of PrefixDecl to get the namespace...
          final Node prefixDeclChild = child.jjtGetChild(0);

          // if child of PrefixDecl is QuotedURIRef...
          if (prefixDeclChild instanceof ASTQuotedURIRef) {
            // get namespace...
            final String namespace = ((ASTQuotedURIRef) prefixDeclChild).toQueryString();
View Full Code Here

    return msg;
  }

  public FederatedQuery(final Node federatedQuery) {
    this.federatedQuery = federatedQuery;
    final Node child0 = this.federatedQuery.jjtGetChild(0);
    if (child0 instanceof ASTVar) {
      this.endpoint = new Variable(((ASTVar) child0).getName());
    } else {
      this.endpoint = LiteralFactory.createURILiteralWithoutLazyLiteralWithoutException("<" + child0.toString() + ">");
    }
    this.variablesInServiceCall = new HashSet<Variable>();
    FederatedQuery.checkVariables(this.federatedQuery.jjtGetChild(1), this.variablesInServiceCall);
    this.surelyBoundVariablesInServiceCall = this.getSurelyBoundVariables();
  }
View Full Code Here

      dcq = this.rdfsStreamQueryToIndexQueryDebugByteArray(query, root_param, prefixInstance);
    } else {
      final SimpleNode root = SPARQL1_1Parser.parse(query);

      for (int i = 0; i < root.jjtGetNumChildren(); ++i) {
        final Node child = root.jjtGetChild(i); // get current child

        if (child instanceof ASTPrefixDecl) {
          // get prefix...
          final String prefix = ((ASTPrefixDecl) child).getPrefix();

          // get child of PrefixDecl to get the namespace...
          final Node prefixDeclChild = child.jjtGetChild(0);

          // if child of PrefixDecl is QuotedURIRef...
          if (prefixDeclChild instanceof ASTQuotedURIRef) {
            // get namespace...
            final String namespace = ((ASTQuotedURIRef) prefixDeclChild)
View Full Code Here

        // or from the whole DataEditor) must be first inserted!

        final ASTGroupConstraint node = SPARQL1_1Parser.parseGroupGraphPatternsAndRDFTerms(content);

        for (int i = 0; i < node.jjtGetNumChildren(); i++) {
          final Node child = node.jjtGetChild(i);

          if (child instanceof ASTGroupConstraint) {
            final VisualQueryGenerator vqg = new VisualQueryGenerator(
                ((VisualGraphOperatorWithPrefix) this.visualGraphs
                    .get(0)).prefix);

            final Object data = child.jjtAccept(
                (SPARQL1_1ParserVisitor) vqg, rdfHash);

            result.add(data);

            final Operator newOp = (Operator) data;
View Full Code Here

TOP

Related Classes of java.util.concurrent.ConcurrentLinkedQueue$Node

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.