You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by pr...@apache.org on 2015/08/11 14:20:26 UTC

[03/50] [abbrv] incubator-lens git commit: LENS-619: Applying Query Launching Constraints before allowing a query to be launched (Also contains LENS-687 and LENS-688)

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/lens-server/src/test/java/org/apache/lens/server/query/collect/DefaultEstimatedQueryCollectionTest.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/collect/DefaultEstimatedQueryCollectionTest.java b/lens-server/src/test/java/org/apache/lens/server/query/collect/DefaultEstimatedQueryCollectionTest.java
new file mode 100644
index 0000000..4dde18a
--- /dev/null
+++ b/lens-server/src/test/java/org/apache/lens/server/query/collect/DefaultEstimatedQueryCollectionTest.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.server.query.collect;
+
+import static org.apache.lens.server.query.collect.QueryCollectUtil.createQueriesSetWithUserStubbing;
+
+import static org.mockito.Mockito.*;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Set;
+
+import org.apache.lens.server.api.driver.LensDriver;
+import org.apache.lens.server.api.error.LensException;
+import org.apache.lens.server.api.query.QueryContext;
+import org.apache.lens.server.api.query.cost.FactPartitionBasedQueryCost;
+import org.apache.lens.server.api.query.cost.QueryCost;
+
+import org.testng.annotations.Test;
+
+import com.beust.jcommander.internal.Sets;
+import com.google.common.collect.Iterables;
+
+public class DefaultEstimatedQueryCollectionTest {
+
+  private static final String MOCK_USER = "MockUserEmail";
+
+  @Test
+  public void testGetTotalQueryCostForUserWithZeroLaunchedQueries() throws LensException {
+
+    QueryCollection mockQueries = mock(QueryCollection.class);
+    when(mockQueries.getQueries(MOCK_USER)).thenReturn(Sets.<QueryContext>newLinkedHashSet());
+
+    EstimatedQueryCollection queries = new DefaultEstimatedQueryCollection(mockQueries);
+    QueryCost actualQueryCost = queries.getTotalQueryCost(MOCK_USER);
+    assertEquals(actualQueryCost, new FactPartitionBasedQueryCost(0));
+  }
+
+  @Test
+  public void testGetTotalQueryCostForUserWithMoreThanOneLaunchedQueries() throws LensException {
+
+    QueryCollection mockQueries = mock(QueryCollection.class);
+    Set<QueryContext> mockQueriesSet = createQueriesSetWithUserStubbing(2, MOCK_USER);
+    when(mockQueries.getQueries(MOCK_USER)).thenReturn(mockQueriesSet);
+
+    final QueryContext query0 = Iterables.get(mockQueriesSet, 0);
+    final QueryContext query1 = Iterables.get(mockQueriesSet, 1);
+
+    final QueryCost mockCost0 = mock(QueryCost.class);
+    final QueryCost mockCost1 = mock(QueryCost.class);
+    final QueryCost mockCost0Plus0 = mock(QueryCost.class);
+    final QueryCost mockCost0Plus0Plus1 = mock(QueryCost.class);
+
+    when(query0.getSelectedDriverQueryCost()).thenReturn(mockCost0);
+    when(query1.getSelectedDriverQueryCost()).thenReturn(mockCost1);
+
+    when(mockCost0.add(mockCost0)).thenReturn(mockCost0Plus0);
+    when(mockCost0Plus0.add(mockCost1)).thenReturn(mockCost0Plus0Plus1);
+
+    QueryCost actualQueryCost = new DefaultEstimatedQueryCollection(mockQueries).getTotalQueryCost(MOCK_USER);
+    assertEquals(actualQueryCost, mockCost0Plus0Plus1);
+  }
+
+  @Test
+  public void testAddAndRemoveAndGetQueriesMethod() throws LensException {
+
+    QueryContext mockQuery = mock(QueryContext.class);
+    LensDriver mockSelectedDriver = mock(LensDriver.class);
+    QueryCost mockQueryCost = mock(QueryCost.class);
+    when(mockQuery.getSelectedDriver()).thenReturn(mockSelectedDriver);
+    when(mockQuery.getSelectedDriverQueryCost()).thenReturn(mockQueryCost);
+
+    QueryCollection mockQueries = mock(QueryCollection.class);
+    EstimatedQueryCollection queries = new DefaultEstimatedQueryCollection(mockQueries);
+
+    queries.add(mockQuery);
+    assertEquals(queries.getQueriesCount(mockSelectedDriver), 1);
+    verify(mockQueries, times(1)).add(mockQuery);
+
+    queries.remove(mockQuery);
+    assertEquals(queries.getQueriesCount(mockSelectedDriver), 0);
+    verify(mockQueries, times(1)).remove(mockQuery);
+  }
+
+  @Test(expectedExceptions = IllegalStateException.class)
+  public void testCheckStateMustRecognizeIllegalStateWhenSelectedDriverIsNotSet() throws LensException {
+
+    QueryContext mockQuery = mock(QueryContext.class);
+    /* Setting selected driver cost, however since selected driver is not set. This should result in
+    IllegalStateException */
+    when(mockQuery.getSelectedDriverQueryCost()).thenReturn(mock(QueryCost.class));
+
+    QueryCollection mockQueries = mock(QueryCollection.class);
+    DefaultEstimatedQueryCollection queries = new DefaultEstimatedQueryCollection(mockQueries);
+    queries.checkState(mockQuery);
+  }
+
+  @Test(expectedExceptions = IllegalStateException.class)
+  public void testCheckStateMustRecognizeIllegalStateWhenQueryCostIsNotSet() {
+
+    QueryContext mockQuery = mock(QueryContext.class);
+    /* Selected Driver is set, however since selected driver query cost is not set. This should result in
+    IllegalStateException. */
+    when(mockQuery.getSelectedDriver()).thenReturn(mock(LensDriver.class));
+
+    QueryCollection mockQueries = mock(QueryCollection.class);
+    DefaultEstimatedQueryCollection queries = new DefaultEstimatedQueryCollection(mockQueries);
+    queries.checkState(mockQuery);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/lens-server/src/test/java/org/apache/lens/server/query/collect/DefaultQueryCollectionTest.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/collect/DefaultQueryCollectionTest.java b/lens-server/src/test/java/org/apache/lens/server/query/collect/DefaultQueryCollectionTest.java
new file mode 100644
index 0000000..7a81e83
--- /dev/null
+++ b/lens-server/src/test/java/org/apache/lens/server/query/collect/DefaultQueryCollectionTest.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.server.query.collect;
+
+import static org.apache.lens.server.query.collect.QueryCollectUtil.*;
+
+import static org.mockito.Mockito.mock;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Set;
+
+import org.apache.lens.server.api.query.QueryContext;
+
+import org.testng.annotations.Test;
+
+public class DefaultQueryCollectionTest {
+
+  private static final String MOCK_USER = "MockUserEmail";
+
+  /* Note: Since verification of addition/removal required calling get methods,
+  hence methods getQueriesCount and getQueries(user) are indirectly getting tested in these tests */
+
+  @Test
+  public void testAddMethodAddsQueriesToAllViews(){
+
+    /* Initialization */
+    final int noOfQueriesUsedInTest = 2;
+    QueryCollection queries = createQueriesInstanceWithUserStubbing(noOfQueriesUsedInTest, MOCK_USER);
+
+    /* Verification 1: Verifies that queries were added to queries list by calling getQueriesCount which gets results
+    from queries list */
+    assertEquals(queries.getQueriesCount(), noOfQueriesUsedInTest);
+
+    /* Verification 2: Verifies that queries were added to queries per user map by calling getQueries(user) method,
+    which gets information from queries per user map */
+
+    assertEquals(queries.getQueries(MOCK_USER).size(), noOfQueriesUsedInTest);
+  }
+
+  @Test
+  public void testRemoveMethodRemovesFromAllViews() {
+
+    /* Initialization */
+    QueryContext mockQuery = mock(QueryContext.class);
+    QueryCollection queries = stubMockQueryAndCreateQueriesInstance(mockQuery, MOCK_USER);
+
+    /* Execution */
+    queries.remove(mockQuery);
+
+    /* Verification 1: Verifies that queries were removed from queries list by calling getQueriesCount which gets
+    results from queries list */
+    assertEquals(queries.getQueriesCount(), 0);
+
+    /* Verification 2: Verifies that queries were removed from queries per user map by calling getQueries(user) method,
+    which gets information from queries per user map */
+
+    assertEquals(queries.getQueries(MOCK_USER).size(), 0);
+  }
+
+  @Test
+  public void testGetQueriesMustReturnCopyOfUnderlyingCollection() {
+
+    /* Initialization */
+    final int noOfQueriesUsedInTest = 2;
+    QueryCollection queries = createQueriesInstanceWithMockedQueries(noOfQueriesUsedInTest);
+
+    /* Execution: Get queries and empty returned collection */
+    Set<QueryContext> copiedSet = queries.getQueries();
+    copiedSet.clear();
+
+    /* System under set (queries) should still have the added queries, which can be verified by checking count */
+    assertEquals(queries.getQueriesCount(), noOfQueriesUsedInTest);
+  }
+
+  @Test
+  public void testGetQueriesPerUserMustReturnCopyOfUnderlyingCollection() {
+
+    /* Initialization */
+    final int noOfQueriesUsedInTest = 2;
+    QueryCollection queries = createQueriesInstanceWithUserStubbing(noOfQueriesUsedInTest, MOCK_USER);
+
+    /* Execution: Get queries for user and empty returned collection */
+    Set<QueryContext> copiedSet = queries.getQueries(MOCK_USER);
+    copiedSet.clear();
+
+    /* System under set (queries) should still have the added queries, which can be verified by checking count */
+    assertEquals(queries.getQueries(MOCK_USER).size(), noOfQueriesUsedInTest);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/lens-server/src/test/java/org/apache/lens/server/query/collect/IntersectingWaitingQueriesSelectorTest.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/collect/IntersectingWaitingQueriesSelectorTest.java b/lens-server/src/test/java/org/apache/lens/server/query/collect/IntersectingWaitingQueriesSelectorTest.java
new file mode 100644
index 0000000..62e371d
--- /dev/null
+++ b/lens-server/src/test/java/org/apache/lens/server/query/collect/IntersectingWaitingQueriesSelectorTest.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.server.query.collect;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.lens.server.api.query.FinishedLensQuery;
+import org.apache.lens.server.api.query.QueryContext;
+import org.apache.lens.server.api.query.collect.EstimatedImmutableQueryCollection;
+import org.apache.lens.server.api.query.collect.WaitingQueriesSelectionPolicy;
+
+import org.testng.annotations.Test;
+import org.testng.collections.Sets;
+
+import com.beust.jcommander.internal.Lists;
+import com.google.common.collect.ImmutableSet;
+
+public class IntersectingWaitingQueriesSelectorTest {
+
+  @Test
+  public void testFindCommonQueriesWhenInputIsEmptyListOfSets() {
+
+    List<Set<QueryContext>> candidateQueriesSets = Lists.newArrayList();
+    Set<QueryContext> expectedEligibleQueries = Sets.newHashSet();
+
+    testFindCommonQueries(candidateQueriesSets, expectedEligibleQueries);
+  }
+
+  @Test
+  public void testFindCommonQueriesWhenNoCommonQueryIsPresent() {
+
+    QueryContext eligibleQuery1 = mock(QueryContext.class);
+    QueryContext eligibleQuery2 = mock(QueryContext.class);
+
+    Set<QueryContext> eligibleQueriesSetA = Sets.newHashSet(Arrays.asList(eligibleQuery1));
+    Set<QueryContext> eligibleQueriesSetB = Sets.newHashSet(Arrays.asList(eligibleQuery2));
+
+    List<Set<QueryContext>> candidateQueriesSets = Arrays.asList(eligibleQueriesSetA, eligibleQueriesSetB);
+    Set<QueryContext> expectedEligibleQueries = Sets.newHashSet();
+
+    testFindCommonQueries(candidateQueriesSets, expectedEligibleQueries);
+  }
+
+  @Test
+  public void testFindCommonQueriesWhenACommonQueryIsPresent() {
+
+    QueryContext eligibleQuery1 = mock(QueryContext.class);
+    QueryContext eligibleQuery2 = mock(QueryContext.class);
+    QueryContext eligibleQuery3 = mock(QueryContext.class);
+
+    Set<QueryContext> eligibleQueriesSetA = Sets.newHashSet(Arrays.asList(eligibleQuery1, eligibleQuery2));
+    Set<QueryContext> eligibleQueriesSetB = Sets.newHashSet(Arrays.asList(eligibleQuery1, eligibleQuery3));
+
+    List<Set<QueryContext>> candidateQueriesSets = Arrays.asList(eligibleQueriesSetA, eligibleQueriesSetB);
+    Set<QueryContext> expectedEligibleQueries = Sets.newHashSet(Arrays.asList(eligibleQuery1));
+
+    testFindCommonQueries(candidateQueriesSets, expectedEligibleQueries);
+  }
+
+  private void testFindCommonQueries(final List<Set<QueryContext>> queriesSets,
+      final Set<QueryContext> expectedEligibleQueries) {
+
+    IntersectingWaitingQueriesSelector selector = new IntersectingWaitingQueriesSelector(mock(ImmutableSet.class));
+
+    Set<QueryContext> actualCommonQueries = selector.findCommonQueries(queriesSets);
+    assertEquals(actualCommonQueries, expectedEligibleQueries);
+  }
+
+  @Test
+  public void testPrepareAllSelectionPolicies() {
+
+    WaitingQueriesSelectionPolicy p1 = mock(WaitingQueriesSelectionPolicy.class);
+    WaitingQueriesSelectionPolicy p2 = mock(WaitingQueriesSelectionPolicy.class);
+    WaitingQueriesSelectionPolicy dp1 = mock(WaitingQueriesSelectionPolicy.class);
+    WaitingQueriesSelectionPolicy dp2 = mock(WaitingQueriesSelectionPolicy.class);
+
+    FinishedLensQuery mockFinishedQuery = mock(FinishedLensQuery.class);
+    when(mockFinishedQuery.getDriverSelectionPolicies()).thenReturn(ImmutableSet.of(dp1, dp2));
+
+    IntersectingWaitingQueriesSelector selector = new IntersectingWaitingQueriesSelector(ImmutableSet.of(p1, p2));
+    assertEquals(selector.prepareAllSelectionPolicies(mockFinishedQuery), ImmutableSet.of(p1, p2, dp1, dp2));
+  }
+
+  @Test
+  public void testPrepareAllSelectionPoliciesWithNoDriverSelectionPolicy() {
+
+    WaitingQueriesSelectionPolicy p1 = mock(WaitingQueriesSelectionPolicy.class);
+    WaitingQueriesSelectionPolicy p2 = mock(WaitingQueriesSelectionPolicy.class);
+
+    final ImmutableSet<WaitingQueriesSelectionPolicy> emptySet = ImmutableSet.copyOf(
+        Sets.<WaitingQueriesSelectionPolicy>newHashSet());
+
+    FinishedLensQuery mockFinishedQuery = mock(FinishedLensQuery.class);
+    when(mockFinishedQuery.getDriverSelectionPolicies()).thenReturn(emptySet);
+
+    IntersectingWaitingQueriesSelector selector = new IntersectingWaitingQueriesSelector(ImmutableSet.of(p1, p2));
+
+    assertEquals(selector.prepareAllSelectionPolicies(mockFinishedQuery), ImmutableSet.of(p1, p2));
+  }
+
+  @Test
+  public void testSelectQueriesCommonBetweenAllSelectionPolicies(){
+
+    QueryContext q1 = mock(QueryContext.class);
+    QueryContext q2 = mock(QueryContext.class);
+    QueryContext q3 = mock(QueryContext.class);
+
+    /* eligibleQueriesSet1, eligibleQueriesSet2, eligibleQueriesSet3 have q1 in common */
+    Set<QueryContext> eligibleQueriesSet1 = Sets.newHashSet(Arrays.asList(q1, q2));
+    Set<QueryContext> eligibleQueriesSet2 = Sets.newHashSet(Arrays.asList(q1, q3));
+    Set<QueryContext> eligibleQueriesSet3 = Sets.newHashSet(Arrays.asList(q1, q2));
+
+    FinishedLensQuery mockFinishedQuery = mock(FinishedLensQuery.class);
+    EstimatedImmutableQueryCollection mockWaitingQueries = mock(EstimatedImmutableQueryCollection.class);
+    WaitingQueriesSelectionPolicy policy1 = mock(WaitingQueriesSelectionPolicy.class);
+    WaitingQueriesSelectionPolicy policy2 = mock(WaitingQueriesSelectionPolicy.class);
+    WaitingQueriesSelectionPolicy driverSelectionPolicy = mock(WaitingQueriesSelectionPolicy.class);
+
+    when(mockFinishedQuery.getDriverSelectionPolicies()).thenReturn(ImmutableSet.of(driverSelectionPolicy));
+
+    /* selection policy1 will return eligibleQueriesSet1 */
+    when(policy1.selectQueries(mockFinishedQuery, mockWaitingQueries)).thenReturn(eligibleQueriesSet1);
+
+    /* selection policy2 will return eligibleQueriesSet2 */
+    when(policy2.selectQueries(mockFinishedQuery, mockWaitingQueries)).thenReturn(eligibleQueriesSet2);
+
+    /* driver selection policy will return eligibleQueriesSet3 */
+    when(driverSelectionPolicy.selectQueries(mockFinishedQuery, mockWaitingQueries)).thenReturn(eligibleQueriesSet3);
+
+    WaitingQueriesSelector selector = new IntersectingWaitingQueriesSelector(ImmutableSet.of(policy1, policy2));
+
+    /* selector should return only eligibleQuery1, as this is the only common eligible waiting query returned
+    * by both selection policies */
+    Set<QueryContext> actualEligibleQueries = selector.selectQueries(mockFinishedQuery, mockWaitingQueries);
+    Set<QueryContext> expectedEligibleQueries = Sets.newHashSet(Arrays.asList(q1));
+
+    assertEquals(actualEligibleQueries, expectedEligibleQueries);
+  }
+
+  @Test(expectedExceptions = NullPointerException.class)
+  public void testSelectorMustNotAcceptNullAsSelectionPolicies() {
+    new IntersectingWaitingQueriesSelector(null);
+  }
+
+  @Test
+  public void testSelectQueriesWithNoSelectionPolicies(){
+
+    FinishedLensQuery mockFinishedQuery = mock(FinishedLensQuery.class);
+    EstimatedImmutableQueryCollection mockWaitingQueries = mock(EstimatedImmutableQueryCollection.class);
+    Set<WaitingQueriesSelectionPolicy> emptySetOfPolicies = Sets.newHashSet();
+
+    when(mockFinishedQuery.getDriverSelectionPolicies()).thenReturn(ImmutableSet.copyOf(emptySetOfPolicies));
+
+    WaitingQueriesSelector selector = new IntersectingWaitingQueriesSelector(ImmutableSet.copyOf(emptySetOfPolicies));
+
+    /* selector should return an empty set as no selection policy is available */
+    Set<QueryContext> actualEligibleQueries = selector.selectQueries(mockFinishedQuery, mockWaitingQueries);
+
+    assertTrue(actualEligibleQueries.isEmpty());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/lens-server/src/test/java/org/apache/lens/server/query/collect/QueryCollectUtil.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/collect/QueryCollectUtil.java b/lens-server/src/test/java/org/apache/lens/server/query/collect/QueryCollectUtil.java
new file mode 100644
index 0000000..51fcf00
--- /dev/null
+++ b/lens-server/src/test/java/org/apache/lens/server/query/collect/QueryCollectUtil.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.server.query.collect;
+
+import static java.lang.reflect.Modifier.isPublic;
+import static java.lang.reflect.Modifier.isSynchronized;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertTrue;
+
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import org.apache.lens.server.api.query.QueryContext;
+
+import com.google.common.collect.Sets;
+
+public class QueryCollectUtil {
+
+  protected QueryCollectUtil() {
+    throw new UnsupportedOperationException();
+  }
+
+  public static Set<QueryContext> createQueriesSetWithUserStubbing(final int reqNoOfMockQueries,
+      final String mockUser) {
+
+    final Set<QueryContext> mockQueries = getMockQueriesSet(reqNoOfMockQueries);
+    stubSubmittedUserInMockQueries(mockQueries, mockUser);
+    return mockQueries;
+  }
+
+  public static void stubSubmittedUserInMockQueries(final Set<QueryContext> mockQueries, final String mockUser) {
+
+    for (QueryContext mockQuery : mockQueries) {
+      when(mockQuery.getSubmittedUser()).thenReturn(mockUser);
+    }
+  }
+
+  public static Set<QueryContext> getMockQueriesSet(final int reqNoOfMockQueries) {
+
+    Set<QueryContext> mockQueries = Sets.newLinkedHashSet();
+
+    for (int i = 1; i <= reqNoOfMockQueries; ++i) {
+      mockQueries.add(mock(QueryContext.class));
+    }
+    return mockQueries;
+  }
+
+  public static QueryCollection createQueriesInstanceWithMockedQueries(final int reqNoOfMockQueries) {
+
+    final Set<QueryContext> mockQueries = getMockQueriesSet(reqNoOfMockQueries);
+    return new DefaultQueryCollection(mockQueries);
+  }
+
+  public static QueryCollection createQueriesInstanceWithUserStubbing(final int reqNoOfMockQueries,
+    final String mockUser) {
+
+    final Set<QueryContext> mockQueries = createQueriesSetWithUserStubbing(reqNoOfMockQueries, mockUser);
+    return new DefaultQueryCollection(mockQueries);
+  }
+
+  public static QueryCollection stubMockQueryAndCreateQueriesInstance(final QueryContext mockQuery,
+    final String mockUser) {
+
+    Set<QueryContext> mockQueries = Sets.newHashSet(mockQuery);
+    stubSubmittedUserInMockQueries(mockQueries, mockUser);
+    return new DefaultQueryCollection(mockQueries);
+  }
+
+  public static <T> void testAllMethodsHaveSynchronizedKeyword(final Class<T> clazz) {
+
+    Method[] allMethods = clazz.getDeclaredMethods();
+
+    for (Method method : allMethods) {
+
+      int modifierSet = method.getModifiers();
+      if (isPublic(modifierSet)) {
+        /* If the method is public, then it should also have synchronized modifier on it */
+        assertTrue(isSynchronized(modifierSet), "method [" + method.getName() + "] in class ["
+            + clazz.getName() + "] does not have synchronized modifier on it");
+      }
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/lens-server/src/test/java/org/apache/lens/server/query/collect/ThreadSafetyTest.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/collect/ThreadSafetyTest.java b/lens-server/src/test/java/org/apache/lens/server/query/collect/ThreadSafetyTest.java
new file mode 100644
index 0000000..74a0389
--- /dev/null
+++ b/lens-server/src/test/java/org/apache/lens/server/query/collect/ThreadSafetyTest.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.server.query.collect;
+
+import org.testng.annotations.Test;
+
+public class ThreadSafetyTest {
+
+  @Test
+  public void testThreadSafetyForThreadSafeQueries() {
+
+    QueryCollectUtil.testAllMethodsHaveSynchronizedKeyword(ThreadSafeQueryCollection.class);
+  }
+
+  @Test
+  public void testThreadSafetyForThreadSafeEstimatedQueries() {
+
+    QueryCollectUtil.testAllMethodsHaveSynchronizedKeyword(ThreadSafeEstimatedQueryCollection.class);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/lens-server/src/test/java/org/apache/lens/server/query/collect/UserSpecificWaitingQueriesSelectionPolicyTest.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/collect/UserSpecificWaitingQueriesSelectionPolicyTest.java b/lens-server/src/test/java/org/apache/lens/server/query/collect/UserSpecificWaitingQueriesSelectionPolicyTest.java
new file mode 100644
index 0000000..b3e9d38
--- /dev/null
+++ b/lens-server/src/test/java/org/apache/lens/server/query/collect/UserSpecificWaitingQueriesSelectionPolicyTest.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.server.query.collect;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Set;
+
+import org.apache.lens.server.api.query.FinishedLensQuery;
+import org.apache.lens.server.api.query.collect.EstimatedImmutableQueryCollection;
+import org.apache.lens.server.api.query.collect.WaitingQueriesSelectionPolicy;
+
+import org.testng.annotations.Test;
+
+public class UserSpecificWaitingQueriesSelectionPolicyTest {
+
+  @Test
+  public void testSelectQueries() {
+
+    FinishedLensQuery mockFinishedQuery = mock(FinishedLensQuery.class);
+    EstimatedImmutableQueryCollection mockWaitingQueries = mock(EstimatedImmutableQueryCollection.class);
+    String mockUser = "MockUser";
+    Set expectedQueriesSet = mock(Set.class);
+
+    when(mockFinishedQuery.getSubmitter()).thenReturn(mockUser);
+    when(mockWaitingQueries.getQueries(mockUser)).thenReturn(expectedQueriesSet);
+
+    WaitingQueriesSelectionPolicy selectionPolicy = new UserSpecificWaitingQueriesSelectionPolicy();
+    Set actualEligibleQueries = selectionPolicy.selectQueries(mockFinishedQuery, mockWaitingQueries);
+
+    assertEquals(actualEligibleQueries, expectedQueriesSet);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/lens-server/src/test/java/org/apache/lens/server/query/constraint/DefaultQueryLaunchingConstraintsCheckerTest.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/constraint/DefaultQueryLaunchingConstraintsCheckerTest.java b/lens-server/src/test/java/org/apache/lens/server/query/constraint/DefaultQueryLaunchingConstraintsCheckerTest.java
new file mode 100644
index 0000000..ab030cc
--- /dev/null
+++ b/lens-server/src/test/java/org/apache/lens/server/query/constraint/DefaultQueryLaunchingConstraintsCheckerTest.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.server.query.constraint;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+
+import org.apache.lens.server.api.query.QueryContext;
+import org.apache.lens.server.api.query.collect.EstimatedImmutableQueryCollection;
+import org.apache.lens.server.api.query.constraint.QueryLaunchingConstraint;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+public class DefaultQueryLaunchingConstraintsCheckerTest {
+
+  @Test
+  public void testCanLaunchShouldReturnFalseWhenAtleastOneConstraintFails() {
+
+    QueryContext mockCandidateQuery = mock(QueryContext.class);
+    EstimatedImmutableQueryCollection mockRunningQueries = mock(EstimatedImmutableQueryCollection.class);
+
+    final QueryLaunchingConstraint constraint1 = mock(QueryLaunchingConstraint.class);
+    final QueryLaunchingConstraint constraint2 = mock(QueryLaunchingConstraint.class);
+    QueryLaunchingConstraintsChecker constraintsChecker
+      = new DefaultQueryLaunchingConstraintsChecker(ImmutableSet.of(constraint1, constraint2));
+
+    final QueryLaunchingConstraint driverConstraint = mock(QueryLaunchingConstraint.class);
+    when(mockCandidateQuery.getSelectedDriverQueryConstraints()).thenReturn(ImmutableSet.of(driverConstraint));
+
+    /* Constraint1 stubbed to pass */
+    when(constraint1.allowsLaunchOf(mockCandidateQuery, mockRunningQueries)).thenReturn(true);
+
+    /* Constraint2 stubbed to fail */
+    when(constraint2.allowsLaunchOf(mockCandidateQuery, mockRunningQueries)).thenReturn(false);
+
+    /* DriverConstraint stubbed to fail */
+    when(driverConstraint.allowsLaunchOf(mockCandidateQuery, mockRunningQueries)).thenReturn(false);
+
+    /* Execute test */
+    boolean canLaunchQuery = constraintsChecker.canLaunch(mockCandidateQuery, mockRunningQueries);
+
+    /* Verify */
+    Assert.assertFalse(canLaunchQuery);
+  }
+
+  @Test
+  public void testCanLaunchShouldReturnTrueWhenAllConstraintPass() {
+
+    QueryContext mockCandidateQuery = mock(QueryContext.class);
+    EstimatedImmutableQueryCollection mockRunningQueries = mock(EstimatedImmutableQueryCollection.class);
+
+    final QueryLaunchingConstraint constraint1 = mock(QueryLaunchingConstraint.class);
+    final QueryLaunchingConstraint constraint2 = mock(QueryLaunchingConstraint.class);
+
+    QueryLaunchingConstraintsChecker constraintsChecker
+      = new DefaultQueryLaunchingConstraintsChecker(ImmutableSet.of(constraint1, constraint2));
+
+    final QueryLaunchingConstraint driverConstraint = mock(QueryLaunchingConstraint.class);
+    when(mockCandidateQuery.getSelectedDriverQueryConstraints()).thenReturn(ImmutableSet.of(driverConstraint));
+
+    /* all constraints stubbed to pass */
+    when(constraint1.allowsLaunchOf(mockCandidateQuery, mockRunningQueries)).thenReturn(true);
+    when(constraint2.allowsLaunchOf(mockCandidateQuery, mockRunningQueries)).thenReturn(true);
+    when(driverConstraint.allowsLaunchOf(mockCandidateQuery, mockRunningQueries)).thenReturn(true);
+
+    /* Execute test */
+    boolean canLaunchQuery = constraintsChecker.canLaunch(mockCandidateQuery, mockRunningQueries);
+
+    /* Verify */
+    Assert.assertTrue(canLaunchQuery);
+  }
+
+  @Test
+  public void testCanLaunchShouldReturnTrueWhenConstraintsSetIsEmpty() {
+
+    QueryContext mockCandidateQuery = mock(QueryContext.class);
+    EstimatedImmutableQueryCollection mockRunningQueries = mock(EstimatedImmutableQueryCollection.class);
+
+    ImmutableSet<QueryLaunchingConstraint> emptySetOfConstraints
+      = ImmutableSet.copyOf(Sets.<QueryLaunchingConstraint>newHashSet());
+
+    when(mockCandidateQuery.getSelectedDriverQueryConstraints()).thenReturn(emptySetOfConstraints);
+
+    QueryLaunchingConstraintsChecker constraintsChecker
+      = new DefaultQueryLaunchingConstraintsChecker(ImmutableSet.copyOf(emptySetOfConstraints));
+
+    boolean canLaunchQuery = constraintsChecker.canLaunch(mockCandidateQuery, mockRunningQueries);
+    Assert.assertTrue(canLaunchQuery);
+  }
+
+  @Test(expectedExceptions = NullPointerException.class)
+  public void testConstraintsCheckerMustNotAcceptNullConstraintsSet() {
+    new DefaultQueryLaunchingConstraintsChecker(null);
+  }
+
+  @Test
+  public void testPrepareAllConstraints() {
+
+    QueryLaunchingConstraint c1 = mock(QueryLaunchingConstraint.class);
+    QueryLaunchingConstraint c2 = mock(QueryLaunchingConstraint.class);
+
+    QueryLaunchingConstraint dc1 = mock(QueryLaunchingConstraint.class);
+    QueryLaunchingConstraint dc2 = mock(QueryLaunchingConstraint.class);
+
+    QueryContext mockCandidateQuery = mock(QueryContext.class);
+    when(mockCandidateQuery.getSelectedDriverQueryConstraints()).thenReturn(ImmutableSet.of(dc1, dc2));
+
+    DefaultQueryLaunchingConstraintsChecker constraintsChecker
+      = new DefaultQueryLaunchingConstraintsChecker(ImmutableSet.of(c1, c2));
+    assertEquals(constraintsChecker.prepareAllConstraints(mockCandidateQuery), ImmutableSet.of(c1, c2, dc1, dc2));
+  }
+
+  @Test
+  public void testPrepareAllConstraintsWithNoDriverConstraints() {
+
+    QueryLaunchingConstraint c1 = mock(QueryLaunchingConstraint.class);
+    QueryLaunchingConstraint c2 = mock(QueryLaunchingConstraint.class);
+
+    ImmutableSet<QueryLaunchingConstraint> emptySet = ImmutableSet.copyOf(Sets.<QueryLaunchingConstraint>newHashSet());
+    QueryContext mockCandidateQuery = mock(QueryContext.class);
+    when(mockCandidateQuery.getSelectedDriverQueryConstraints()).thenReturn(emptySet);
+
+    DefaultQueryLaunchingConstraintsChecker constraintsChecker
+      = new DefaultQueryLaunchingConstraintsChecker(ImmutableSet.of(c1, c2));
+    assertEquals(constraintsChecker.prepareAllConstraints(mockCandidateQuery), ImmutableSet.of(c1, c2));
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/lens-server/src/test/java/org/apache/lens/server/query/constraint/TotalQueryCostCeilingConstraintFactoryTest.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/constraint/TotalQueryCostCeilingConstraintFactoryTest.java b/lens-server/src/test/java/org/apache/lens/server/query/constraint/TotalQueryCostCeilingConstraintFactoryTest.java
new file mode 100644
index 0000000..f42e79e
--- /dev/null
+++ b/lens-server/src/test/java/org/apache/lens/server/query/constraint/TotalQueryCostCeilingConstraintFactoryTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.server.query.constraint;
+
+import static org.testng.Assert.assertEquals;
+
+import org.apache.lens.server.api.LensConfConstants;
+import org.apache.lens.server.api.common.ConfigBasedObjectCreationFactory;
+import org.apache.lens.server.api.query.constraint.QueryLaunchingConstraint;
+import org.apache.lens.server.api.query.cost.FactPartitionBasedQueryCost;
+import org.apache.lens.server.api.query.cost.QueryCost;
+
+import org.apache.hadoop.conf.Configuration;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+
+public class TotalQueryCostCeilingConstraintFactoryTest {
+
+  @DataProvider
+  public Object[][] dpTestCreate() {
+    return new Object[][] {
+      {"-1.0", new TotalQueryCostCeilingConstraint(Optional.<QueryCost>absent())},
+      {"0.0", new TotalQueryCostCeilingConstraint(Optional.<QueryCost>of(new FactPartitionBasedQueryCost(0.0)))},
+      {"90.0", new TotalQueryCostCeilingConstraint(Optional.<QueryCost>of(new FactPartitionBasedQueryCost(90.0)))},
+    };
+  }
+  @Test(dataProvider = "dpTestCreate")
+  public void testCreate(final String totalQueryCostCeilingPerUser, final QueryLaunchingConstraint expectedConstraint) {
+
+    Configuration conf = new Configuration();
+    conf.set(LensConfConstants.TOTAL_QUERY_COST_CEILING_PER_USER_KEY, totalQueryCostCeilingPerUser);
+
+    ConfigBasedObjectCreationFactory<QueryLaunchingConstraint> fac = new TotalQueryCostCeilingConstraintFactory();
+    assertEquals(fac.create(conf), expectedConstraint);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/lens-server/src/test/java/org/apache/lens/server/query/constraint/TotalQueryCostCeilingConstraintTest.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/query/constraint/TotalQueryCostCeilingConstraintTest.java b/lens-server/src/test/java/org/apache/lens/server/query/constraint/TotalQueryCostCeilingConstraintTest.java
new file mode 100644
index 0000000..460190a
--- /dev/null
+++ b/lens-server/src/test/java/org/apache/lens/server/query/constraint/TotalQueryCostCeilingConstraintTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.lens.server.query.constraint;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+
+import org.apache.lens.server.api.query.QueryContext;
+import org.apache.lens.server.api.query.collect.EstimatedImmutableQueryCollection;
+import org.apache.lens.server.api.query.constraint.QueryLaunchingConstraint;
+import org.apache.lens.server.api.query.cost.FactPartitionBasedQueryCost;
+import org.apache.lens.server.api.query.cost.QueryCost;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+
+public class TotalQueryCostCeilingConstraintTest {
+
+  @DataProvider
+  public Object[][] dpTestAllowsLaunchOfQuery() {
+    return new Object[][] { {7.0, true} , {90.0, true}, {91.0, false}};
+  }
+
+  @Test(dataProvider = "dpTestAllowsLaunchOfQuery")
+  public void testAllowsLaunchOfQuery(final double totalQueryCostForCurrentUser, final boolean expectedCanLaunchQuery) {
+
+    final QueryCost totalQueryCostCeilingPerUser = new FactPartitionBasedQueryCost(90.0);
+    final QueryLaunchingConstraint queryConstraint
+      = new TotalQueryCostCeilingConstraint(Optional.of(totalQueryCostCeilingPerUser));
+
+    final QueryContext query = mock(QueryContext.class);
+    final EstimatedImmutableQueryCollection launchedQueries = mock(EstimatedImmutableQueryCollection.class);
+    final String mockUser = "MockUser";
+
+    when(query.getSubmittedUser()).thenReturn(mockUser);
+    when(launchedQueries.getTotalQueryCost(mockUser))
+      .thenReturn(new FactPartitionBasedQueryCost(totalQueryCostForCurrentUser));
+
+    boolean actualCanLaunchQuery = queryConstraint.allowsLaunchOf(query, launchedQueries);
+    assertEquals(actualCanLaunchQuery, expectedCanLaunchQuery);
+  }
+
+  @Test
+  public void testAllowsLaunchOfQueryWhenCeilingIsAbsent() {
+
+    final QueryLaunchingConstraint queryConstraint
+      = new TotalQueryCostCeilingConstraint(Optional.<QueryCost>absent());
+
+    final QueryContext query = mock(QueryContext.class);
+    final EstimatedImmutableQueryCollection launchedQueries = mock(EstimatedImmutableQueryCollection.class);
+
+    boolean actualCanLaunchQuery = queryConstraint.allowsLaunchOf(query, launchedQueries);
+    assertEquals(actualCanLaunchQuery, true);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/lens-server/src/test/resources/lens-site.xml
----------------------------------------------------------------------
diff --git a/lens-server/src/test/resources/lens-site.xml b/lens-server/src/test/resources/lens-site.xml
index 41c7eb6..bd93828 100644
--- a/lens-server/src/test/resources/lens-site.xml
+++ b/lens-server/src/test/resources/lens-site.xml
@@ -163,5 +163,4 @@
     <name>lens.server.estimate.timeout.millis</name>
     <value>120000</value>
   </property>
-
 </configuration>

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/lens-server/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/lens-server/src/test/resources/log4j.properties b/lens-server/src/test/resources/log4j.properties
index 69ff32c..9cc1e36 100644
--- a/lens-server/src/test/resources/log4j.properties
+++ b/lens-server/src/test/resources/log4j.properties
@@ -35,7 +35,7 @@ log4j.additivity.org.apache.lens.server.TestLogResource=true
 log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
 log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
 log4j.appender.STDOUT.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} [%X{logSegregationId}] [%t] %-5p %c %x - %m%n
-log4j.appender.STDOUT.Threshold=INFO
+log4j.appender.STDOUT.Threshold=ERROR
 
 log4j.appender.TEST_LOG_FILE=org.apache.log4j.RollingFileAppender
 log4j.appender.TEST_LOG_FILE.File=target/test.log

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/src/site/apt/admin/config.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/admin/config.apt b/src/site/apt/admin/config.apt
index f850190..2e1dbe7 100644
--- a/src/site/apt/admin/config.apt
+++ b/src/site/apt/admin/config.apt
@@ -127,98 +127,106 @@ Lens server configuration
 *--+--+---+--+
 |50|lens.server.query.acceptors| |Query Acceptors configured. Query acceptors are consulted first, before anything happens for the given query. They can either return null or return a messaging indicating why the given query shouldn't be accepted. These can be used to filter out queries at the earliest.|
 *--+--+---+--+
-|51|lens.server.query.phase1.rewriters| |Query phase 1 rewriters. This is to convert user query to cube query. The resulting cube query will be passed for validation and rewriting to hql query.\ |
+|51|lens.server.query.launching.constraint.factories|org.apache.lens.server.query.constraint.TotalQueryCostCeilingConstraintFactory|Factories used to instantiate constraints enforced on queries by lens. Every Factory should be an implementation of org.apache.lens.server.api.common.ConfigBasedObjectCreationFactory and create an implementation of org.apache.lens.server.api.query.constraint.QueryLaunchingConstraint. A query will be launched only if all constraints pass.|
+*--+--+---+--+
+|52|lens.server.query.phase1.rewriters| |Query phase 1 rewriters. This is to convert user query to cube query. The resulting cube query will be passed for validation and rewriting to hql query.\ |
 |  |                                  | |Use cases will be to use extra intelligence to convert user query to optimized cube query.                                                              \ |
 |  |                                  | |Or define shortcuts for certain frequently used queries :)                                                                                                |
 *--+--+---+--+
-|52|lens.server.query.service.impl|org.apache.lens.server.query.QueryExecutionServiceImpl|Implementation class for query execution service|
+|53|lens.server.query.service.impl|org.apache.lens.server.query.QueryExecutionServiceImpl|Implementation class for query execution service|
+*--+--+---+--+
+|54|lens.server.query.state.logger.enabled|true|Disable or enable the query state logger with this config. The location for the logger can be specified in log4j properties for the class org.apache.lens.server.query.QueryExecutionServiceImpl.QueryStatusLogger|
+*--+--+---+--+
+|55|lens.server.query.ws.resource.impl|org.apache.lens.server.query.QueryServiceResource|Implementation class for Query Resource|
+*--+--+---+--+
+|56|lens.server.quota.service.impl|org.apache.lens.server.quota.QuotaServiceImpl|Implementation class for quota service|
 *--+--+---+--+
-|53|lens.server.query.state.logger.enabled|true|Disable or enable the query state logger with this config. The location for the logger can be specified in log4j properties for the class org.apache.lens.server.query.QueryExecutionServiceImpl.QueryStatusLogger|
+|57|lens.server.quota.ws.resource.impl|org.apache.lens.server.quota.QuotaResource|Implementation class for Quota Resource|
 *--+--+---+--+
-|54|lens.server.query.ws.resource.impl|org.apache.lens.server.query.QueryServiceResource|Implementation class for Query Resource|
+|58|lens.server.recover.onrestart|true|If the flag is enabled, all the services will be started from last saved state, if disabled all the services will start afresh|
 *--+--+---+--+
-|55|lens.server.quota.service.impl|org.apache.lens.server.quota.QuotaServiceImpl|Implementation class for quota service|
+|59|lens.server.restart.enabled|true|If flag is enabled, all the services will be persisted to persistent location passed.|
 *--+--+---+--+
-|56|lens.server.quota.ws.resource.impl|org.apache.lens.server.quota.QuotaResource|Implementation class for Quota Resource|
+|60|lens.server.scheduler.service.impl|org.apache.lens.server.scheduler.QuerySchedulerServiceImpl|Implementation class for query scheduler service|
 *--+--+---+--+
-|57|lens.server.recover.onrestart|true|If the flag is enabled, all the services will be started from last saved state, if disabled all the services will start afresh|
+|61|lens.server.scheduler.ws.resource.impl|org.apache.lens.server.scheduler.ScheduleResource|Implementation class for query scheduler resource|
 *--+--+---+--+
-|58|lens.server.restart.enabled|true|If flag is enabled, all the services will be persisted to persistent location passed.|
+|62|lens.server.scheduling.queue.poll.interval.millisec|2000|The interval at which submission thread will poll scheduling queue to fetch the next query for submission. If value is less than equal to 0, then it would mean that thread will continuosly poll without sleeping. The interval has to be given in milliseconds.|
 *--+--+---+--+
-|59|lens.server.scheduler.service.impl|org.apache.lens.server.scheduler.QuerySchedulerServiceImpl|Implementation class for query scheduler service|
+|63|lens.server.serverMode.ws.filter.impl|org.apache.lens.server.ServerModeFilter|Implementation class for ServerMode Filter|
 *--+--+---+--+
-|60|lens.server.scheduler.ws.resource.impl|org.apache.lens.server.scheduler.ScheduleResource|Implementation class for query scheduler resource|
+|64|lens.server.service.provider.factory|org.apache.lens.server.ServiceProviderFactoryImpl|Service provider factory implementation class. This parameter is used to lookup the factory implementation class name that would provide an instance of ServiceProvider. Users should instantiate the class to obtain its instance. Example -- Class spfClass = conf.getClass("lens.server.service.provider.factory", null, ServiceProviderFactory.class); ServiceProviderFactory spf = spfClass.newInstance(); ServiceProvider serviceProvider = spf.getServiceProvider(); -- This is not supposed to be overridden by users.|
 *--+--+---+--+
-|61|lens.server.serverMode.ws.filter.impl|org.apache.lens.server.ServerModeFilter|Implementation class for ServerMode Filter|
+|65|lens.server.servicenames|session,query,metastore,scheduler,quota|These services would be started in the specified order when lens-server starts up|
 *--+--+---+--+
-|62|lens.server.service.provider.factory|org.apache.lens.server.ServiceProviderFactoryImpl|Service provider factory implementation class. This parameter is used to lookup the factory implementation class name that would provide an instance of ServiceProvider. Users should instantiate the class to obtain its instance. Example -- Class spfClass = conf.getClass("lens.server.service.provider.factory", null, ServiceProviderFactory.class); ServiceProviderFactory spf = spfClass.newInstance(); ServiceProvider serviceProvider = spf.getServiceProvider(); -- This is not supposed to be overridden by users.|
+|66|lens.server.session.expiry.service.interval.secs|3600|Interval at which lens session expiry service runs|
 *--+--+---+--+
-|63|lens.server.servicenames|session,query,metastore,scheduler,quota|These services would be started in the specified order when lens-server starts up|
+|67|lens.server.session.service.impl|org.apache.lens.server.session.HiveSessionService|Implementation class for session service|
 *--+--+---+--+
-|64|lens.server.session.expiry.service.interval.secs|3600|Interval at which lens session expiry service runs|
+|68|lens.server.session.timeout.seconds|86400|Lens session timeout in seconds.If there is no activity on the session for this period then the session will be closed.Default timeout is one day.|
 *--+--+---+--+
-|65|lens.server.session.service.impl|org.apache.lens.server.session.HiveSessionService|Implementation class for session service|
+|69|lens.server.session.ws.resource.impl|org.apache.lens.server.session.SessionResource|Implementation class for Session Resource|
 *--+--+---+--+
-|66|lens.server.session.timeout.seconds|86400|Lens session timeout in seconds.If there is no activity on the session for this period then the session will be closed.Default timeout is one day.|
+|70|lens.server.snapshot.interval|300000|Snapshot interval time in miliseconds for saving lens server state.|
 *--+--+---+--+
-|67|lens.server.session.ws.resource.impl|org.apache.lens.server.session.SessionResource|Implementation class for Session Resource|
+|71|lens.server.state.persist.out.stream.buffer.size|1048576|Output Stream Buffer Size used in writing lens server state to file system. Size is in bytes.|
 *--+--+---+--+
-|68|lens.server.snapshot.interval|300000|Snapshot interval time in miliseconds for saving lens server state.|
+|72|lens.server.statistics.db|lensstats|Database to which statistics tables are created and partitions are added.|
 *--+--+---+--+
-|69|lens.server.state.persist.out.stream.buffer.size|1048576|Output Stream Buffer Size used in writing lens server state to file system. Size is in bytes.|
+|73|lens.server.statistics.log.rollover.interval|3600000|Default rate which log statistics store scans for rollups in milliseconds.|
 *--+--+---+--+
-|70|lens.server.statistics.db|lensstats|Database to which statistics tables are created and partitions are added.|
+|74|lens.server.statistics.store.class|org.apache.lens.server.stats.store.log.LogStatisticsStore|Default implementation of class used to persist Lens Statistics.|
 *--+--+---+--+
-|71|lens.server.statistics.log.rollover.interval|3600000|Default rate which log statistics store scans for rollups in milliseconds.|
+|75|lens.server.statistics.warehouse.dir|file:///tmp/lens/statistics/warehouse|Default top level location where stats are moved by the log statistics store.|
 *--+--+---+--+
-|72|lens.server.statistics.store.class|org.apache.lens.server.stats.store.log.LogStatisticsStore|Default implementation of class used to persist Lens Statistics.|
+|76|lens.server.total.query.cost.ceiling.per.user|-1.0|A query submitted by user will be launched only if total query cost of all current launched queries of user is less than or equal to total query cost ceiling defined by this property. This configuration value is only useful when TotalQueryCostCeilingConstraint is enabled by using org.apache.lens.server.query.constraint.TotalQueryCostCeilingConstraintFactory as one of the factories in lens.server.query.constraint.factories property. Default is -1.0 which means that there is no limit on the total query cost of launched queries submitted by a user.|
 *--+--+---+--+
-|73|lens.server.statistics.warehouse.dir|file:///tmp/lens/statistics/warehouse|Default top level location where stats are moved by the log statistics store.|
+|77|lens.server.ui.base.uri|http://0.0.0.0:19999/|The base url for the Lens UI Server|
 *--+--+---+--+
-|74|lens.server.ui.base.uri|http://0.0.0.0:19999/|The base url for the Lens UI Server|
+|78|lens.server.ui.enable|true|Bringing up the ui server is optional. By default it brings up UI server.|
 *--+--+---+--+
-|75|lens.server.ui.enable|true|Bringing up the ui server is optional. By default it brings up UI server.|
+|79|lens.server.ui.enable.caching|true|Set this to false to disable static file caching in the UI server|
 *--+--+---+--+
-|76|lens.server.ui.enable.caching|true|Set this to false to disable static file caching in the UI server|
+|80|lens.server.ui.static.dir|webapp/lens-server/static|The base directory to server UI static files from|
 *--+--+---+--+
-|77|lens.server.ui.static.dir|webapp/lens-server/static|The base directory to server UI static files from|
+|81|lens.server.user.resolver.custom.class|full.package.name.Classname|Required for CUSTOM user resolver. In case the provided implementations are not sufficient for user config resolver, a custom classname can be provided. Class should extend org.apache.lens.server.user.UserConfigLoader|
 *--+--+---+--+
-|78|lens.server.user.resolver.custom.class|full.package.name.Classname|Required for CUSTOM user resolver. In case the provided implementations are not sufficient for user config resolver, a custom classname can be provided. Class should extend org.apache.lens.server.user.UserConfigLoader|
+|82|lens.server.user.resolver.db.keys|lens.session.cluster.user,mapred.job.queue.name|Required for DATABASE and LDAP_BACKED_DATABASE user resolvers. For database based user config loaders, the conf keys that will be loaded from database.|
 *--+--+---+--+
-|79|lens.server.user.resolver.db.keys|lens.session.cluster.user,mapred.job.queue.name|Required for DATABASE and LDAP_BACKED_DATABASE user resolvers. For database based user config loaders, the conf keys that will be loaded from database.|
+|83|lens.server.user.resolver.db.query|select clusteruser,queue from user_config_table where username=?|Required for DATABASE and LDAP_BACKED_DATABASE user resolvers. For database based user config loader, this query will be run with single argument = logged in user and the result columns will be assigned to lens.server.user.resolver.db.keys in order. For ldap backed database resolver, the argument to this query will be the intermediate values obtained from ldap.|
 *--+--+---+--+
-|80|lens.server.user.resolver.db.query|select clusteruser,queue from user_config_table where username=?|Required for DATABASE and LDAP_BACKED_DATABASE user resolvers. For database based user config loader, this query will be run with single argument = logged in user and the result columns will be assigned to lens.server.user.resolver.db.keys in order. For ldap backed database resolver, the argument to this query will be the intermediate values obtained from ldap.|
+|84|lens.server.user.resolver.fixed.value| |Required for FIXED user resolver. when lens.server.user.resolver.type=FIXED, This will be the value cluster user will resolve to.|
 *--+--+---+--+
-|81|lens.server.user.resolver.fixed.value| |Required for FIXED user resolver. when lens.server.user.resolver.type=FIXED, This will be the value cluster user will resolve to.|
+|85|lens.server.user.resolver.ldap.bind.dn| |Required for LDAP_BACKED_DATABASE user resolvers. ldap dn for admin binding example: CN=company-it-admin,ou=service-account,ou=company-service-account,dc=dc1,dc=com...|
 *--+--+---+--+
-|82|lens.server.user.resolver.ldap.bind.dn| |Required for LDAP_BACKED_DATABASE user resolvers. ldap dn for admin binding example: CN=company-it-admin,ou=service-account,ou=company-service-account,dc=dc1,dc=com...|
+|86|lens.server.user.resolver.ldap.bind.password| |Required for LDAP_BACKED_DATABASE user resolvers. ldap password for admin binding above|
 *--+--+---+--+
-|83|lens.server.user.resolver.ldap.bind.password| |Required for LDAP_BACKED_DATABASE user resolvers. ldap password for admin binding above|
+|87|lens.server.user.resolver.ldap.fields|department|Required for LDAP_BACKED_DATABASE user resolvers. list of fields to be obtained from ldap. These will be cached by the intermediate db.|
 *--+--+---+--+
-|84|lens.server.user.resolver.ldap.fields|department|Required for LDAP_BACKED_DATABASE user resolvers. list of fields to be obtained from ldap. These will be cached by the intermediate db.|
+|88|lens.server.user.resolver.ldap.intermediate.db.delete.sql|delete from user_department where username=?|Required for LDAP_BACKED_DATABASE user resolvers. query to delete intermediate values from database backing ldap as cache. one argument: logged in user.|
 *--+--+---+--+
-|85|lens.server.user.resolver.ldap.intermediate.db.delete.sql|delete from user_department where username=?|Required for LDAP_BACKED_DATABASE user resolvers. query to delete intermediate values from database backing ldap as cache. one argument: logged in user.|
+|89|lens.server.user.resolver.ldap.intermediate.db.insert.sql|insert into user_department (username, department, expiry) values (?, ?, ?)|Required for LDAP_BACKED_DATABASE user resolvers. query to insert intermediate values from database backing ldap as cache. arguments: first logged in user, then all intermediate values, then current time + expiration time|
 *--+--+---+--+
-|86|lens.server.user.resolver.ldap.intermediate.db.insert.sql|insert into user_department (username, department, expiry) values (?, ?, ?)|Required for LDAP_BACKED_DATABASE user resolvers. query to insert intermediate values from database backing ldap as cache. arguments: first logged in user, then all intermediate values, then current time + expiration time|
+|90|lens.server.user.resolver.ldap.intermediate.db.query|select department from user_department where username=? and expiry>?|Required for LDAP_BACKED_DATABASE user resolvers. query to obtain intermediate values from database backing ldap as cache. two arguments: logged in user and current time.|
 *--+--+---+--+
-|87|lens.server.user.resolver.ldap.intermediate.db.query|select department from user_department where username=? and expiry>?|Required for LDAP_BACKED_DATABASE user resolvers. query to obtain intermediate values from database backing ldap as cache. two arguments: logged in user and current time.|
+|91|lens.server.user.resolver.ldap.search.base| |Required for LDAP_BACKED_DATABASE user resolvers. for searching intermediate values for a user, the search keys. example: cn=users,dc=dc1,dc=dc2...|
 *--+--+---+--+
-|88|lens.server.user.resolver.ldap.search.base| |Required for LDAP_BACKED_DATABASE user resolvers. for searching intermediate values for a user, the search keys. example: cn=users,dc=dc1,dc=dc2...|
+|92|lens.server.user.resolver.ldap.search.filter|(&(objectClass=user)(sAMAccountName=%s))|Required for LDAP_BACKED_DATABASE user resolvers. filter pattern for ldap search|
 *--+--+---+--+
-|89|lens.server.user.resolver.ldap.search.filter|(&(objectClass=user)(sAMAccountName=%s))|Required for LDAP_BACKED_DATABASE user resolvers. filter pattern for ldap search|
+|93|lens.server.user.resolver.ldap.url| |Required for LDAP_BACKED_DATABASE user resolvers. ldap url to connect to.|
 *--+--+---+--+
-|90|lens.server.user.resolver.ldap.url| |Required for LDAP_BACKED_DATABASE user resolvers. ldap url to connect to.|
+|94|lens.server.user.resolver.propertybased.filename|/path/to/propertyfile|Required for PROPERTYBASED user resolver. when lens.server.user.resolver.type is PROPERTYBASED, then this file will be read and parsed to determine cluster user. Each line should contain username followed by DOT followed by property full name followed by equal-to sign and followed by value. example schema of the file is: user1.lens.server.cluster.user=clusteruser1 user1.mapred.job.queue.name=queue1 *.lens.server.cluster.user=defaultclusteruser *.mapred.job.queue.name=default|
 *--+--+---+--+
-|91|lens.server.user.resolver.propertybased.filename|/path/to/propertyfile|Required for PROPERTYBASED user resolver. when lens.server.user.resolver.type is PROPERTYBASED, then this file will be read and parsed to determine cluster user. Each line should contain username followed by DOT followed by property full name followed by equal-to sign and followed by value. example schema of the file is: user1.lens.server.cluster.user=clusteruser1 user1.mapred.job.queue.name=queue1 *.lens.server.cluster.user=defaultclusteruser *.mapred.job.queue.name=default|
+|95|lens.server.user.resolver.type|FIXED|Type of user config resolver. allowed values are FIXED, PROPERTYBASED, DATABASE, LDAP_BACKED_DATABASE, CUSTOM.|
 *--+--+---+--+
-|92|lens.server.user.resolver.type|FIXED|Type of user config resolver. allowed values are FIXED, PROPERTYBASED, DATABASE, LDAP_BACKED_DATABASE, CUSTOM.|
+|96|lens.server.waiting.queries.selection.policy.factories|org.apache.lens.server.query.collect.UserSpecificWaitingQueriesSelectionPolicyFactory|Factories used to instantiate waiting queries selection policies. Every factory should be an implementation of org.apache.lens.server.api.common.ConfigBasedObjectCreationFactory and create an implementation of org.apache.lens.server.api.query.collect.WaitingQueriesSelectionPolicy.|
 *--+--+---+--+
-|93|lens.server.ws.featurenames|multipart|These JAX-RS Feature(s) would be started in the specified order when lens-server starts up|
+|97|lens.server.ws.featurenames|multipart|These JAX-RS Feature(s) would be started in the specified order when lens-server starts up|
 *--+--+---+--+
-|94|lens.server.ws.filternames|authentication,consistentState,serverMode|These JAX-RS filters would be started in the specified order when lens-server starts up|
+|98|lens.server.ws.filternames|authentication,consistentState,serverMode|These JAX-RS filters would be started in the specified order when lens-server starts up|
 *--+--+---+--+
-|95|lens.server.ws.listenernames|appevent|These listeners would be called in the specified order when lens-server starts up|
+|99|lens.server.ws.listenernames|appevent|These listeners would be called in the specified order when lens-server starts up|
 *--+--+---+--+
-|96|lens.server.ws.resourcenames|session,metastore,query,quota,scheduler,index,log|These JAX-RS resources would be started in the specified order when lens-server starts up|
+|100|lens.server.ws.resourcenames|session,metastore,query,quota,scheduler,index,log|These JAX-RS resources would be started in the specified order when lens-server starts up|
 *--+--+---+--+
 The configuration parameters and their default values

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/src/site/apt/admin/hivedriver-config.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/admin/hivedriver-config.apt b/src/site/apt/admin/hivedriver-config.apt
index 80a3028..b1a25c3 100644
--- a/src/site/apt/admin/hivedriver-config.apt
+++ b/src/site/apt/admin/hivedriver-config.apt
@@ -68,4 +68,8 @@ Hive driver configuration
 *--+--+---+--+
 |15|lens.driver.hive.query.hook.class|org.apache.lens.server.api.driver.NoOpDriverQueryHook|The query hook class for hive driver. By default hook is No op. To add a hook, you should look at the default implementation and from there it'll be easy to derive what value can be added through a new hook|
 *--+--+---+--+
+|16|lens.driver.hive.query.launching.constraint.factories| |Factories used to instantiate constraints enforced on queries by driver. A query will be launched only if all constraints pass. Every Factory should be an implementation of org.apache.lens.server.api.common.ConfigBasedObjectCreationFactory and create an implementation of org.apache.lens.server.api.query.constraint.QueryLaunchingConstraint.|
+*--+--+---+--+
+|17|lens.driver.hive.waiting.queries.selection.policy.factories| |Factories used to instantiate driver specific waiting queries selection policies. Every factory should be an implementation of org.apache.lens.server.api.common.ConfigBasedObjectCreationFactory and create an implementation of org.apache.lens.server.api.query.collect.WaitingQueriesSelectionPolicy.|
+*--+--+---+--+
 The configuration parameters and their default values

http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/c879f991/src/site/apt/admin/jdbcdriver-config.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/admin/jdbcdriver-config.apt b/src/site/apt/admin/jdbcdriver-config.apt
index b3d25f6..7b42309 100644
--- a/src/site/apt/admin/jdbcdriver-config.apt
+++ b/src/site/apt/admin/jdbcdriver-config.apt
@@ -24,56 +24,62 @@ Jdbc driver configuration
 *--+--+---+--+
 |<<No.>>|<<Property Name>>|<<Default Value>>|<<Description>>|
 *--+--+---+--+
-|1|lens.cube.query.driver.supported.storages| |List of comma separated storage names that supported by a driver. If no value is specified, all storages are valid|
+|1|driver.max.concurrent.launched.queries|15|Maximum queries which can be launched simultaneously on this driver. This should be equal to lens.driver.jdbc.pool.max.size. This configuration value is only useful when MaxConcurrentDriverQueriesConstraint is enabled by using org.apache.lens.server.api.query.constraint.MaxConcurrentDriverQueriesConstraintFactory as one of the factories in lens.driver.jdbc.query.constraint.factories property.|
 *--+--+---+--+
-|2|lens.cube.query.partition.where.clause.format|yyyy-MM-dd HH:mm:ss|The simple date format of how the queried partition should be put in where clause. If nothing is specified, it will use the format from org.apache.lens.cube.metadata.UpdatePeriod for each type of partition|
+|2|lens.cube.query.driver.supported.storages| |List of comma separated storage names that supported by a driver. If no value is specified, all storages are valid|
 *--+--+---+--+
-|3|lens.cube.query.replace.timedim|false|Tells whether timedim attribute queried in the time range should be replaced with its corresponding partition column name.|
+|3|lens.cube.query.partition.where.clause.format|yyyy-MM-dd HH:mm:ss|The simple date format of how the queried partition should be put in where clause. If nothing is specified, it will use the format from org.apache.lens.cube.metadata.UpdatePeriod for each type of partition|
 *--+--+---+--+
-|4|lens.cube.query.time.range.writer.class|org.apache.lens.cube.parse.BetweenTimeRangeWriter|The timerange writer class which specifies how the resolved partitions in timeranges should be written in final query. Available writers are org.apache.lens.cube.parse.ORTimeRangeWriter and org.apache.lens.cube.parse.BetweenTimeRangeWriter|
+|4|lens.cube.query.replace.timedim|false|Tells whether timedim attribute queried in the time range should be replaced with its corresponding partition column name.|
 *--+--+---+--+
-|5|lens.driver.jdbc.connection.provider| |A contract for obtaining JDBC connections|
+|5|lens.cube.query.time.range.writer.class|org.apache.lens.cube.parse.BetweenTimeRangeWriter|The timerange writer class which specifies how the resolved partitions in timeranges should be written in final query. Available writers are org.apache.lens.cube.parse.ORTimeRangeWriter and org.apache.lens.cube.parse.BetweenTimeRangeWriter|
 *--+--+---+--+
-|6|lens.driver.jdbc.db.password| |The database user's password|
+|6|lens.driver.jdbc.connection.provider| |A contract for obtaining JDBC connections|
 *--+--+---+--+
-|7|lens.driver.jdbc.db.uri| |JDBC connection URL in the format jdbc:dbms://host:port/dbname|
+|7|lens.driver.jdbc.db.password| |The database user's password|
 *--+--+---+--+
-|8|lens.driver.jdbc.db.user| |The database user on whose behalf the connection is being made|
+|8|lens.driver.jdbc.db.uri| |JDBC connection URL in the format jdbc:dbms://host:port/dbname|
 *--+--+---+--+
-|9|lens.driver.jdbc.driver.class|com.mysql.jdbc.Driver|Type of JDBC driver used to connect backend database|
+|9|lens.driver.jdbc.db.user| |The database user on whose behalf the connection is being made|
 *--+--+---+--+
-|10|lens.driver.jdbc.enable.resultset.streaming.retrieval|false|Flag to enable row by row retrieval of result set from the database server. This is used to enable streaming result sets for MySQL. This is set to false by default.|
+|10|lens.driver.jdbc.driver.class|com.mysql.jdbc.Driver|Type of JDBC driver used to connect backend database|
 *--+--+---+--+
-|11|lens.driver.jdbc.estimate.db.password| |The database user's password, for estimate queries. If this property is unspecified, value for lens.driver.jdbc.db.password would be used. Override this property to tune estimate connection pool|
+|11|lens.driver.jdbc.enable.resultset.streaming.retrieval|false|Flag to enable row by row retrieval of result set from the database server. This is used to enable streaming result sets for MySQL. This is set to false by default.|
 *--+--+---+--+
-|12|lens.driver.jdbc.estimate.db.uri| |JDBC connection URL in the format jdbc:dbms://host:port/dbname for estimate queries. If this property is unspecified, value for lens.driver.jdbc.db.uri will be used.|
+|12|lens.driver.jdbc.estimate.db.password| |The database user's password, for estimate queries. If this property is unspecified, value for lens.driver.jdbc.db.password would be used. Override this property to tune estimate connection pool|
 *--+--+---+--+
-|13|lens.driver.jdbc.estimate.db.user| |The database user on whose behalf the connection is being made, for estimate queries. If this property is unspecified, value for lens.driver.jdbc.db.user would be used. Override this property to tune estimate connection pool|
+|13|lens.driver.jdbc.estimate.db.uri| |JDBC connection URL in the format jdbc:dbms://host:port/dbname for estimate queries. If this property is unspecified, value for lens.driver.jdbc.db.uri will be used.|
 *--+--+---+--+
-|14|lens.driver.jdbc.estimate.driver.class| |Type of JDBC driver used to connect backend database for estimate queries. If This property is not specified, value for lens.driver.jdbc.driver.class will be used. Override this property to tune estimate connection pool|
+|14|lens.driver.jdbc.estimate.db.user| |The database user on whose behalf the connection is being made, for estimate queries. If this property is unspecified, value for lens.driver.jdbc.db.user would be used. Override this property to tune estimate connection pool|
 *--+--+---+--+
-|15|lens.driver.jdbc.estimate.get.connection.timeout| |Response timeout in milliseconds of any JDBC call invoking data transmission over a connection socket , for estimate queries. If this property is not specified, value for lens.driver.jdbc.get.connection.timeout would be used. Override this property to tune estimate connection pool.|
+|15|lens.driver.jdbc.estimate.driver.class| |Type of JDBC driver used to connect backend database for estimate queries. If This property is not specified, value for lens.driver.jdbc.driver.class will be used. Override this property to tune estimate connection pool|
 *--+--+---+--+
-|16|lens.driver.jdbc.estimate.pool.idle.time| |Maximum idle time in sec before a connection is closed, for estimate queries. If this property is not specified, value for lens.driver.jdbc.pool.idle.time would be used. Override this property to tune estimate connection pool.|
+|16|lens.driver.jdbc.estimate.get.connection.timeout| |Response timeout in milliseconds of any JDBC call invoking data transmission over a connection socket , for estimate queries. If this property is not specified, value for lens.driver.jdbc.get.connection.timeout would be used. Override this property to tune estimate connection pool.|
 *--+--+---+--+
-|17|lens.driver.jdbc.estimate.pool.max.size| |Maximum number of concurrent connections allowed in pool, for estimate queries. If this property is unspecified, value for lens.driver.jdbc.pool.max.size would be used. Override this property to tune estimate connection pool|
+|17|lens.driver.jdbc.estimate.pool.idle.time| |Maximum idle time in sec before a connection is closed, for estimate queries. If this property is not specified, value for lens.driver.jdbc.pool.idle.time would be used. Override this property to tune estimate connection pool.|
 *--+--+---+--+
-|18|lens.driver.jdbc.estimate.pool.max.statements| |Maximum number of prepared statements to cache per connection, for estimate queries. If this property is not specified, value for lens.driver.jdbc.pool.max.statements would be used.|
+|18|lens.driver.jdbc.estimate.pool.max.size| |Maximum number of concurrent connections allowed in pool, for estimate queries. If this property is unspecified, value for lens.driver.jdbc.pool.max.size would be used. Override this property to tune estimate connection pool|
 *--+--+---+--+
-|19|lens.driver.jdbc.explain.keyword|Explain|Explain keyword used to get the query plan of underlying database|
+|19|lens.driver.jdbc.estimate.pool.max.statements| |Maximum number of prepared statements to cache per connection, for estimate queries. If this property is not specified, value for lens.driver.jdbc.pool.max.statements would be used.|
 *--+--+---+--+
-|20|lens.driver.jdbc.fetch.size|1000|Fetch size for JDBC result set|
+|20|lens.driver.jdbc.explain.keyword|Explain|Explain keyword used to get the query plan of underlying database|
 *--+--+---+--+
-|21|lens.driver.jdbc.get.connection.timeout|10000|Response timeout in milliseconds of any JDBC call invoking data transmission over a connection socket|
+|21|lens.driver.jdbc.fetch.size|1000|Fetch size for JDBC result set|
 *--+--+---+--+
-|22|lens.driver.jdbc.pool.idle.time|600|Maximum idle time in sec before a connection is closed|
+|22|lens.driver.jdbc.get.connection.timeout|10000|Response timeout in milliseconds of any JDBC call invoking data transmission over a connection socket|
 *--+--+---+--+
-|23|lens.driver.jdbc.pool.max.size|15|Maximum number of concurrent connections allowed in pool|
+|23|lens.driver.jdbc.pool.idle.time|600|Maximum idle time in sec before a connection is closed|
 *--+--+---+--+
-|24|lens.driver.jdbc.pool.max.statements|20|Maximum number of prepared statements to cache per connection|
+|24|lens.driver.jdbc.pool.max.size|15|Maximum number of concurrent connections allowed in pool|
 *--+--+---+--+
-|25|lens.driver.jdbc.query.rewriter|org.apache.lens.driver.jdbc.ColumnarSQLRewriter|Rewriting the HQL to optimized sql queries|
+|25|lens.driver.jdbc.pool.max.statements|20|Maximum number of prepared statements to cache per connection|
 *--+--+---+--+
-|26|lens.driver.jdbc.validate.through.prepare|true|Flag to enable query syntactic and semantic validation using prepared statement.|
+|26|lens.driver.jdbc.query.launching.constraint.factories|org.apache.lens.server.api.query.constraint.MaxConcurrentDriverQueriesConstraintFactory|Factories used to instantiate constraints enforced on queries by driver. A query will be launched only if all constraints pass. Every Factory should be an implementation of org.apache.lens.server.api.common.ConfigBasedObjectCreationFactory and create an implementation of org.apache.lens.server.api.query.constraint.QueryLaunchingConstraint.|
+*--+--+---+--+
+|27|lens.driver.jdbc.query.rewriter|org.apache.lens.driver.jdbc.ColumnarSQLRewriter|Rewriting the HQL to optimized sql queries|
+*--+--+---+--+
+|28|lens.driver.jdbc.validate.through.prepare|true|Flag to enable query syntactic and semantic validation using prepared statement.|
+*--+--+---+--+
+|29|lens.driver.jdbc.waiting.queries.selection.policy.factories|org.apache.lens.server.api.query.collect.DriverSpecificWaitingQueriesSelectionPolicyFactory|Factories used to instantiate driver specific waiting queries selection policies. Every factory should be an implementation of org.apache.lens.server.api.common.ConfigBasedObjectCreationFactory and create an implementation of org.apache.lens.server.api.query.collect.WaitingQueriesSelectionPolicy.|
 *--+--+---+--+
 The configuration parameters and their default values