Search in sources :

Example 26 with LogWriter

use of org.apache.geode.LogWriter in project geode by apache.

the class CompiledJunctionInternalsJUnitTest method testOrganizedOperandsSingleCondnEvalMultipleLessThanInEqualities_AND.

/**
   * Tests the functionality of organizedOperands function of a RangeJunction for various
   * combinations of LESS THAN and Not equal conditions etc which results in a SingleCondnEvaluator
   * or CompiledComparison for a AND junction. It checks the correctness of the operator & the
   * evaluated key
   * 
   */
@Test
public void testOrganizedOperandsSingleCondnEvalMultipleLessThanInEqualities_AND() {
    LogWriter logger = CacheUtils.getCache().getLogger();
    try {
        CompiledComparison[] cv = null;
        ExecutionContext context = new QueryExecutionContext(null, CacheUtils.getCache());
        this.bindIteratorsAndCreateIndex(context);
        /**
       * ******************For all LESS THAN OR LESS THAN EQUAL To ********************
       */
        // Case 1 : a < 7 and a <=4 and a < 5 and a <=4
        cv = new CompiledComparison[4];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LT);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(4)), OQLLexerTokenTypes.TOK_LE);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(5)), OQLLexerTokenTypes.TOK_LT);
        cv[3] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(4)), OQLLexerTokenTypes.TOK_LE);
        OrganizedOperands oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        assertTrue("Filter Openad of OrganizedOperand is not of type RangeJunction", oo.filterOperand instanceof RangeJunction);
        RangeJunction rj = (RangeJunction) oo.filterOperand;
        OrganizedOperands oo1 = rj.organizeOperands(context);
        assertTrue(oo1.filterOperand == cv[1] || oo1.filterOperand == cv[3]);
        // Case2: a<=8 and a < 12 and a <=10 and a<=8
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(8)), OQLLexerTokenTypes.TOK_LE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(12)), OQLLexerTokenTypes.TOK_LT);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(10)), OQLLexerTokenTypes.TOK_LT);
        cv[3] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(8)), OQLLexerTokenTypes.TOK_LT);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        assertTrue("Filter Openad of OrganizedOperand is not of type RangeJunction", oo.filterOperand instanceof RangeJunction);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(oo1.filterOperand == cv[0] || oo1.filterOperand == cv[3]);
        cv = new CompiledComparison[5];
        // Case 3 : 3 >= a and a <=4 and a < 5 and a <= 3 and a != 1
        cv[0] = new CompiledComparison(new CompiledLiteral(new Integer(3)), new CompiledPath(new CompiledID("p"), "ID"), OQLLexerTokenTypes.TOK_GE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(4)), OQLLexerTokenTypes.TOK_LE);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(5)), OQLLexerTokenTypes.TOK_LT);
        cv[3] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(3)), OQLLexerTokenTypes.TOK_LE);
        cv[4] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(1)), OQLLexerTokenTypes.TOK_NE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(RangeJunction.isInstanceOfSingleCondnEvaluator(oo1.filterOperand));
        assertTrue(RangeJunction.getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LE);
        assertTrue(RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(new Integer(3)));
        assertTrue(RangeJunction.getIndex(oo1.filterOperand).getName().equals("idIndex"));
        assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).size() == 1 && RangeJunction.getKeysToBeRemoved(oo1.filterOperand).iterator().next().equals(new Integer(1)));
        // Case 4 : 3 > a and a <=2
        cv = new CompiledComparison[2];
        cv[0] = new CompiledComparison(new CompiledLiteral(new Integer(3)), new CompiledPath(new CompiledID("p"), "ID"), OQLLexerTokenTypes.TOK_GT);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(2)), OQLLexerTokenTypes.TOK_LE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(oo1.filterOperand == cv[1]);
        // Case 5 : a < 7 and a <=7
        cv = new CompiledComparison[2];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LT);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(oo1.filterOperand == cv[0]);
        // Case 6 : a <= 7 and a <7
        cv = new CompiledComparison[2];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LT);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(oo1.filterOperand == cv[1]);
        // Case 7 : a <= 8 and a <9
        cv = new CompiledComparison[2];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(8)), OQLLexerTokenTypes.TOK_LE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(9)), OQLLexerTokenTypes.TOK_LT);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(oo1.filterOperand == cv[0]);
        // Case 8 : a <=8 and a <=10
        cv = new CompiledComparison[2];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(8)), OQLLexerTokenTypes.TOK_LE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(10)), OQLLexerTokenTypes.TOK_LE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(oo1.filterOperand == cv[0]);
        // Case 9 : a <=6 and a <= 5
        cv = new CompiledComparison[2];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(6)), OQLLexerTokenTypes.TOK_LE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(5)), OQLLexerTokenTypes.TOK_LE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(oo1.filterOperand == cv[1]);
        // Case 10 : 7 > a and a <=7 and a != 2
        cv = new CompiledComparison[3];
        cv[0] = new CompiledComparison(new CompiledLiteral(new Integer(7)), new CompiledPath(new CompiledID("p"), "ID"), OQLLexerTokenTypes.TOK_GT);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LE);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(2)), OQLLexerTokenTypes.TOK_NE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(new Integer(7)));
        assertTrue(RangeJunction.getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LT);
        assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).iterator().next().equals(new Integer(2)));
        // Case 11 : a < 7 and a <=7 and a != 1
        cv = new CompiledComparison[3];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LT);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LE);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(1)), OQLLexerTokenTypes.TOK_NE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(new Integer(7)));
        assertTrue(RangeJunction.getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LT);
        assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).iterator().next().equals(new Integer(1)));
        // Case 12 : a <= 7 and a <7 and a != 1
        cv = new CompiledComparison[3];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LT);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(1)), OQLLexerTokenTypes.TOK_NE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(new Integer(7)));
        assertTrue(RangeJunction.getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LT);
        assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).iterator().next().equals(new Integer(1)));
        // Case 13 : a <= 8 and a <9 and a !=1
        cv = new CompiledComparison[3];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(8)), OQLLexerTokenTypes.TOK_LE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(9)), OQLLexerTokenTypes.TOK_LT);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(1)), OQLLexerTokenTypes.TOK_NE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(new Integer(8)));
        assertTrue(RangeJunction.getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LE);
        assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).iterator().next().equals(new Integer(1)));
        // Case 14 : a <=8 and a <=9 and a !=1
        cv = new CompiledComparison[3];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(8)), OQLLexerTokenTypes.TOK_LE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(9)), OQLLexerTokenTypes.TOK_LE);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(1)), OQLLexerTokenTypes.TOK_NE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(new Integer(8)));
        assertTrue(RangeJunction.getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LE);
        assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).iterator().next().equals(new Integer(1)));
        // Case 15 : a <=7 and a <=6 and a != 1
        cv = new CompiledComparison[3];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(6)), OQLLexerTokenTypes.TOK_LE);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(1)), OQLLexerTokenTypes.TOK_NE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(new Integer(6)));
        assertTrue(RangeJunction.getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LE);
        assertTrue(RangeJunction.getKeysToBeRemoved(oo1.filterOperand).iterator().next().equals(new Integer(1)));
        // Case 15 : a <=7 and a <= 6and a != 6
        cv = new CompiledComparison[3];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(6)), OQLLexerTokenTypes.TOK_LE);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(6)), OQLLexerTokenTypes.TOK_NE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(new Integer(6)));
        assertTrue(RangeJunction.getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LE);
        assertTrue(RangeJunction.getKeysToBeRemoved((oo1.filterOperand)).iterator().next().equals(new Integer(6)));
        // Case 16 : a <=7 and a <=6 and a != 7
        cv = new CompiledComparison[3];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(6)), OQLLexerTokenTypes.TOK_LE);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_NE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(oo1.filterOperand == cv[1]);
        // Case 17 : a <=7 and a <=6 and a != 7 and a!=10 and a != 8
        cv = new CompiledComparison[5];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(6)), OQLLexerTokenTypes.TOK_LE);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_NE);
        cv[3] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(10)), OQLLexerTokenTypes.TOK_NE);
        cv[4] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(8)), OQLLexerTokenTypes.TOK_NE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(oo1.filterOperand == cv[1]);
        // Case 18 : a <=7 and a <=6 and a != 7 and a!=8 and a !=9 and a != 2 and
        // a != 6
        cv = new CompiledComparison[7];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LE);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(6)), OQLLexerTokenTypes.TOK_LE);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_NE);
        cv[3] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(8)), OQLLexerTokenTypes.TOK_NE);
        cv[4] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(9)), OQLLexerTokenTypes.TOK_NE);
        cv[5] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(2)), OQLLexerTokenTypes.TOK_NE);
        cv[6] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(6)), OQLLexerTokenTypes.TOK_NE);
        oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        rj = (RangeJunction) oo.filterOperand;
        oo1 = rj.organizeOperands(context);
        assertTrue(RangeJunction.getSingleCondnEvaluatorKey(oo1.filterOperand).equals(new Integer(6)));
        assertTrue(RangeJunction.getSingleCondnEvaluatorOperator(oo1.filterOperand) == OQLLexerTokenTypes.TOK_LE);
        Iterator itr = RangeJunction.getKeysToBeRemoved((oo1.filterOperand)).iterator();
        Object temp;
        assertTrue((temp = itr.next()).equals(new Integer(2)) || temp.equals(new Integer(6)));
        assertTrue((temp = itr.next()).equals(new Integer(2)) || temp.equals(new Integer(6)));
        assertFalse(itr.hasNext());
    // //////////////////////////////////////////////////////////////
    } catch (Exception e) {
        logger.error(e);
        fail(e.toString());
    }
}
Also used : LogWriter(org.apache.geode.LogWriter) Iterator(java.util.Iterator) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 27 with LogWriter

use of org.apache.geode.LogWriter in project geode by apache.

the class CompiledJunctionInternalsJUnitTest method testOrganizedOperandsSingleRangeJunctionCreationWithIterOperandForAND.

/**
   * Tests the creation of a single RangeJunction if the CompiledJunction only contains same index
   * condition and an iter operand for AND
   */
@Test
public void testOrganizedOperandsSingleRangeJunctionCreationWithIterOperandForAND() {
    LogWriter logger = CacheUtils.getCache().getLogger();
    try {
        CompiledComparison[] cv = null;
        ExecutionContext context = new QueryExecutionContext(null, CacheUtils.getCache());
        this.bindIteratorsAndCreateIndex(context);
        cv = new CompiledComparison[13];
        cv[0] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(2)), OQLLexerTokenTypes.TOK_EQ);
        cv[1] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(5)), OQLLexerTokenTypes.TOK_LE);
        cv[2] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LT);
        cv[3] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_GT);
        cv[4] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_GE);
        cv[5] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_NE);
        cv[6] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(2)), OQLLexerTokenTypes.TOK_EQ);
        cv[7] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(5)), OQLLexerTokenTypes.TOK_LE);
        cv[8] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_LT);
        cv[9] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_GT);
        cv[10] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_GE);
        cv[11] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "ID"), new CompiledLiteral(new Integer(7)), OQLLexerTokenTypes.TOK_NE);
        cv[12] = new CompiledComparison(new CompiledPath(new CompiledID("p"), "createTime"), new CompiledLiteral(new Long(7)), OQLLexerTokenTypes.TOK_NE);
        OrganizedOperands oo = this.oganizedOperandsSingleRangeJunctionCreation(OQLLexerTokenTypes.LITERAL_and, cv, context);
        assertNotNull("OrganizedOperand object is null", oo);
        assertTrue("Filter Openad of OrganizedOperand is not of type RangeJunction", oo.filterOperand instanceof RangeJunction);
        RangeJunction rj = (RangeJunction) oo.filterOperand;
        assertEquals(cv.length, rj.getOperands().size());
    } catch (Exception e) {
        logger.error(e);
        fail(e.toString());
    }
}
Also used : LogWriter(org.apache.geode.LogWriter) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 28 with LogWriter

use of org.apache.geode.LogWriter in project geode by apache.

the class JCAManagedConnection method getConnection.

@Override
public Object getConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException {
    if (!this.initialized || this.cache.isClosed()) {
        init();
    }
    LogWriter logger = this.cache.getLogger();
    if (logger.fineEnabled()) {
        logger.fine("JCAManagedConnection:getConnection. Returning new Connection");
    }
    GFConnectionImpl connection = new GFConnectionImpl(this);
    this.connections.add(connection);
    return connection;
}
Also used : LogWriter(org.apache.geode.LogWriter) GFConnectionImpl(org.apache.geode.internal.ra.GFConnectionImpl)

Example 29 with LogWriter

use of org.apache.geode.LogWriter in project geode by apache.

the class JCAManagedConnection method init.

private void init() {
    this.cache = (InternalCache) CacheFactory.getAnyInstance();
    LogWriter logger = this.cache.getLogger();
    if (logger.fineEnabled()) {
        logger.fine("JCAManagedConnection:init. Inside init");
    }
    this.transactionManager = this.cache.getTxManager();
    this.initialized = true;
}
Also used : LogWriter(org.apache.geode.LogWriter)

Example 30 with LogWriter

use of org.apache.geode.LogWriter in project geode by apache.

the class JCALocalTransaction method commit.

@Override
public void commit() throws ResourceException {
    LogWriter logger = this.cache.getLogger();
    if (logger.fineEnabled()) {
        logger.fine("JCALocalTransaction:invoked commit");
    }
    TXStateProxy tsp = this.gfTxMgr.getTXState();
    if (tsp != null && this.tid != tsp.getTransactionId()) {
        throw new IllegalStateException("Local Transaction associated with Tid = " + this.tid + " attempting to commit a different transaction");
    }
    try {
        this.gfTxMgr.commit();
        this.tid = null;
    } catch (Exception e) {
        // TODO: consider wrapping the cause
        throw new LocalTransactionException(e.toString());
    }
}
Also used : LocalTransactionException(javax.resource.spi.LocalTransactionException) LogWriter(org.apache.geode.LogWriter) TXStateProxy(org.apache.geode.internal.cache.TXStateProxy) ResourceException(javax.resource.ResourceException) SystemException(javax.transaction.SystemException) LocalTransactionException(javax.resource.spi.LocalTransactionException)

Aggregations

LogWriter (org.apache.geode.LogWriter)87 Test (org.junit.Test)34 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)18 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)17 Host (org.apache.geode.test.dunit.Host)17 Region (org.apache.geode.cache.Region)15 DistributedSystem (org.apache.geode.distributed.DistributedSystem)15 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)15 VM (org.apache.geode.test.dunit.VM)13 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)12 Iterator (java.util.Iterator)11 Set (java.util.Set)11 Cache (org.apache.geode.cache.Cache)11 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)11 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)10 LocalRegion (org.apache.geode.internal.cache.LocalRegion)9 Properties (java.util.Properties)8 InternalLogWriter (org.apache.geode.internal.logging.InternalLogWriter)8 IOException (java.io.IOException)7 HashSet (java.util.HashSet)7