You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by twdsilva <gi...@git.apache.org> on 2015/03/25 05:50:50 UTC

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

GitHub user twdsilva opened a pull request:

    https://github.com/apache/phoenix/pull/55

    PHOENIX-1457 Use high priority queue for metadata endpoint calls

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/twdsilva/phoenix metadata_qos

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/phoenix/pull/55.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #55
    
----
commit a7690e93f34b18a740083ecd226f6e9aada93d0d
Author: Thomas D'Silva <tw...@gmail.com>
Date:   2015-03-25T00:17:44Z

    PHOENIX-1457 Use high priority queue for metadata endpoint calls

commit 093c3d8cf2b310b9887ee00abed6fa2617ccdfce
Author: Thomas D'Silva <tw...@gmail.com>
Date:   2015-03-25T00:28:08Z

    fix tests

commit e83ec3262ce29fa375cf8c966f56b7dfd3d092fa
Author: Thomas D'Silva <tw...@gmail.com>
Date:   2015-03-25T01:06:17Z

    added metadata rpc test

commit b58d84eeb951f3c7ae873c235432d5025a19ba09
Author: Thomas D'Silva <tw...@gmail.com>
Date:   2015-03-25T01:15:15Z

    modify test

commit 7407ee1ed9dd33f95db99210dcbe917d0247861b
Author: Thomas D'Silva <tw...@gmail.com>
Date:   2015-03-25T03:07:17Z

    fix tests

commit 89af97db157b5f5037ccc06d493c86d6d4f08fe2
Author: Thomas D'Silva <tw...@gmail.com>
Date:   2015-03-25T03:10:17Z

    remove unused variable

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by twdsilva <gi...@git.apache.org>.
Github user twdsilva commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27151905
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/hbase/index/PhoenixRpcControllerFactory.java ---
    @@ -26,52 +26,57 @@
     import org.apache.hadoop.hbase.ipc.DelegatingPayloadCarryingRpcController;
     import org.apache.hadoop.hbase.ipc.PayloadCarryingRpcController;
     import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
    -import org.apache.phoenix.hbase.index.ipc.PhoenixIndexRpcSchedulerFactory;
    +import org.apache.phoenix.hbase.index.ipc.PhoenixRpcSchedulerFactory;
     import org.apache.phoenix.util.SchemaUtil;
     
     /**
      * {@link RpcControllerFactory} that overrides the standard {@link PayloadCarryingRpcController} to
      * allow the configured index tables (via {@link #INDEX_TABLE_NAMES_KEY}) to use the Index priority.
      */
    -public class IndexQosRpcControllerFactory extends RpcControllerFactory {
    +public class PhoenixRpcControllerFactory extends RpcControllerFactory {
     
         public static final String INDEX_TABLE_NAMES_KEY = "phoenix.index.rpc.controller.index-tables";
     
    -    public IndexQosRpcControllerFactory(Configuration conf) {
    +    public PhoenixRpcControllerFactory(Configuration conf) {
             super(conf);
         }
     
         @Override
         public PayloadCarryingRpcController newController() {
             PayloadCarryingRpcController delegate = super.newController();
    -        return new IndexQosRpcController(delegate, conf);
    +        return new PhoenixRpcController(delegate, conf);
         }
     
         @Override
         public PayloadCarryingRpcController newController(CellScanner cellScanner) {
             PayloadCarryingRpcController delegate = super.newController(cellScanner);
    -        return new IndexQosRpcController(delegate, conf);
    +        return new PhoenixRpcController(delegate, conf);
         }
     
         @Override
         public PayloadCarryingRpcController newController(List<CellScannable> cellIterables) {
             PayloadCarryingRpcController delegate = super.newController(cellIterables);
    -        return new IndexQosRpcController(delegate, conf);
    +        return new PhoenixRpcController(delegate, conf);
         }
     
    -    private class IndexQosRpcController extends DelegatingPayloadCarryingRpcController {
    +    private class PhoenixRpcController extends DelegatingPayloadCarryingRpcController {
     
    -        private int priority;
    +        private int indexPriority;
    +        private int metadataPriority;
     
    -        public IndexQosRpcController(PayloadCarryingRpcController delegate, Configuration conf) {
    +        public PhoenixRpcController(PayloadCarryingRpcController delegate, Configuration conf) {
                 super(delegate);
    -            this.priority = PhoenixIndexRpcSchedulerFactory.getMinPriority(conf);
    +            this.indexPriority = PhoenixRpcSchedulerFactory.getIndexMinPriority(conf);
    +            this.metadataPriority = PhoenixRpcSchedulerFactory.getMetadataMinPriority(conf);
             }
             @Override
             public void setPriority(final TableName tn) {
    -            // if its an index table, then we override to the index priority
    -            if (!tn.isSystemTable() &&  !SchemaUtil.isSystemDataTable(tn.getNameAsString())) {
    -                setPriority(this.priority);
    +            // this is function is called for hbase system tables, phoenix system tables and index tables 
    +            if (SchemaUtil.isSystemDataTable(tn.getNameAsString())) {
    --- End diff --
    
    Sure I will move and rename.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by jyates <gi...@git.apache.org>.
Github user jyates commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27154898
  
    --- Diff: phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java ---
    @@ -40,28 +40,34 @@
         private static final int DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER = 10;
     
         private RpcScheduler delegate;
    -    private int minPriority;
    -    private int maxPriority;
    -    private RpcExecutor callExecutor;
    +    private int indexPriority;
    +    private int metadataPriority;
    +    private RpcExecutor indexCallExecutor;
    +    private RpcExecutor metadataCallExecutor;
         private int port;
     
    -    public PhoenixIndexRpcScheduler(int indexHandlerCount, Configuration conf,
    -            RpcScheduler delegate, int minPriority, int maxPriority) {
    +    public PhoenixRpcScheduler(int indexHandlerCount, int metadataHandlerCount, Configuration conf,
    --- End diff --
    
    No, we can have standard ones and then the ability to overwrite them in configuration. Each scheduler would likely need its own limits config though.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by jyates <gi...@git.apache.org>.
Github user jyates commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27154098
  
    --- Diff: phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java ---
    @@ -40,28 +40,34 @@
         private static final int DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER = 10;
     
         private RpcScheduler delegate;
    -    private int minPriority;
    -    private int maxPriority;
    -    private RpcExecutor callExecutor;
    +    private int indexPriority;
    +    private int metadataPriority;
    +    private RpcExecutor indexCallExecutor;
    +    private RpcExecutor metadataCallExecutor;
         private int port;
     
    -    public PhoenixIndexRpcScheduler(int indexHandlerCount, Configuration conf,
    -            RpcScheduler delegate, int minPriority, int maxPriority) {
    +    public PhoenixRpcScheduler(int indexHandlerCount, int metadataHandlerCount, Configuration conf,
    --- End diff --
    
    Can we do layered handlers instead of clumping them all into one? HBase did this with its meta, regular, and replication queues and it is terribly ugly.
    
    Instead, maybe have this class instantiate the necessary handler and then chain through them until one of the handlers range (min/max priority) applies to the incoming message and it then passes it onto the queue. You could also do some checking to ensure the ranges don't overlap, etc.
    
    At the very least, this will get rid of the layers of if/else below.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27154463
  
    --- Diff: phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java ---
    @@ -40,28 +40,34 @@
         private static final int DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER = 10;
     
         private RpcScheduler delegate;
    -    private int minPriority;
    -    private int maxPriority;
    -    private RpcExecutor callExecutor;
    +    private int indexPriority;
    +    private int metadataPriority;
    +    private RpcExecutor indexCallExecutor;
    +    private RpcExecutor metadataCallExecutor;
         private int port;
     
    -    public PhoenixIndexRpcScheduler(int indexHandlerCount, Configuration conf,
    -            RpcScheduler delegate, int minPriority, int maxPriority) {
    +    public PhoenixRpcScheduler(int indexHandlerCount, int metadataHandlerCount, Configuration conf,
    --- End diff --
    
    Would we need separate entries for each RpcScheduler in hbase-sites.xml then?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by jyates <gi...@git.apache.org>.
Github user jyates commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27153852
  
    --- Diff: phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixRpcIT.java ---
    @@ -0,0 +1,264 @@
    +/*
    + * 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.phoenix.end2end.index;
    +
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL;
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
    +import static org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM;
    +import static org.apache.phoenix.util.TestUtil.LOCALHOST;
    +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertFalse;
    +import static org.junit.Assert.assertNotEquals;
    +import static org.junit.Assert.assertTrue;
    +
    +import java.sql.Connection;
    +import java.sql.PreparedStatement;
    +import java.sql.ResultSet;
    +import java.util.List;
    +import java.util.Properties;
    +
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.hbase.HBaseConfiguration;
    +import org.apache.hadoop.hbase.HBaseTestingUtility;
    +import org.apache.hadoop.hbase.HRegionInfo;
    +import org.apache.hadoop.hbase.MiniHBaseCluster;
    +import org.apache.hadoop.hbase.ServerName;
    +import org.apache.hadoop.hbase.client.HBaseAdmin;
    +import org.apache.hadoop.hbase.ipc.BalancedQueueRpcExecutor;
    +import org.apache.hadoop.hbase.ipc.CallRunner;
    +import org.apache.hadoop.hbase.ipc.PhoenixRpcScheduler;
    +import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
    +import org.apache.hadoop.hbase.ipc.RpcExecutor;
    +import org.apache.hadoop.hbase.ipc.RpcScheduler;
    +import org.apache.hadoop.hbase.master.AssignmentManager;
    +import org.apache.hadoop.hbase.master.HMaster;
    +import org.apache.hadoop.hbase.regionserver.HRegionServer;
    +import org.apache.hadoop.hbase.regionserver.RegionServerServices;
    +import org.apache.hadoop.hbase.util.Bytes;
    +import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
    +import org.apache.phoenix.hbase.index.PhoenixRpcControllerFactory;
    +import org.apache.phoenix.hbase.index.ipc.PhoenixRpcSchedulerFactory;
    +import org.apache.phoenix.jdbc.PhoenixTestDriver;
    +import org.apache.phoenix.query.BaseTest;
    +import org.apache.phoenix.query.QueryServices;
    +import org.apache.phoenix.util.PropertiesUtil;
    +import org.apache.phoenix.util.QueryUtil;
    +import org.apache.phoenix.util.ReadOnlyProps;
    +import org.apache.phoenix.util.SchemaUtil;
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.mockito.Mockito;
    +
    +
    +@Category(NeedsOwnMiniClusterTest.class)
    --- End diff --
    
    This ensures it runs the methods single-threaded, right?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by jyates <gi...@git.apache.org>.
Github user jyates commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27153514
  
    --- Diff: phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixRpcIT.java ---
    @@ -0,0 +1,264 @@
    +/*
    + * 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.phoenix.end2end.index;
    +
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL;
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
    +import static org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM;
    +import static org.apache.phoenix.util.TestUtil.LOCALHOST;
    +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertFalse;
    +import static org.junit.Assert.assertNotEquals;
    +import static org.junit.Assert.assertTrue;
    +
    +import java.sql.Connection;
    +import java.sql.PreparedStatement;
    +import java.sql.ResultSet;
    +import java.util.List;
    +import java.util.Properties;
    +
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.hbase.HBaseConfiguration;
    +import org.apache.hadoop.hbase.HBaseTestingUtility;
    +import org.apache.hadoop.hbase.HRegionInfo;
    +import org.apache.hadoop.hbase.MiniHBaseCluster;
    +import org.apache.hadoop.hbase.ServerName;
    +import org.apache.hadoop.hbase.client.HBaseAdmin;
    +import org.apache.hadoop.hbase.ipc.BalancedQueueRpcExecutor;
    +import org.apache.hadoop.hbase.ipc.CallRunner;
    +import org.apache.hadoop.hbase.ipc.PhoenixRpcScheduler;
    +import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
    +import org.apache.hadoop.hbase.ipc.RpcExecutor;
    +import org.apache.hadoop.hbase.ipc.RpcScheduler;
    +import org.apache.hadoop.hbase.master.AssignmentManager;
    +import org.apache.hadoop.hbase.master.HMaster;
    +import org.apache.hadoop.hbase.regionserver.HRegionServer;
    +import org.apache.hadoop.hbase.regionserver.RegionServerServices;
    +import org.apache.hadoop.hbase.util.Bytes;
    +import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
    +import org.apache.phoenix.hbase.index.PhoenixRpcControllerFactory;
    +import org.apache.phoenix.hbase.index.ipc.PhoenixRpcSchedulerFactory;
    +import org.apache.phoenix.jdbc.PhoenixTestDriver;
    +import org.apache.phoenix.query.BaseTest;
    +import org.apache.phoenix.query.QueryServices;
    +import org.apache.phoenix.util.PropertiesUtil;
    +import org.apache.phoenix.util.QueryUtil;
    +import org.apache.phoenix.util.ReadOnlyProps;
    +import org.apache.phoenix.util.SchemaUtil;
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.mockito.Mockito;
    +
    +
    +@Category(NeedsOwnMiniClusterTest.class)
    +public class PhoenixRpcIT extends BaseTest {
    +
    +    private static final String SCHEMA_NAME = "S";
    +    private static final String INDEX_TABLE_NAME = "I";
    +    private static final String DATA_TABLE_FULL_NAME = SchemaUtil.getTableName(SCHEMA_NAME, "T");
    +    private static final String INDEX_TABLE_FULL_NAME = SchemaUtil.getTableName(SCHEMA_NAME, "I");
    +    private static final int NUM_SLAVES = 2;
    +
    +    private static String url;
    +    private static PhoenixTestDriver driver;
    +    private HBaseTestingUtility util;
    +    private HBaseAdmin admin;
    +    private Configuration conf;
    +    private static RpcExecutor indexRpcExecutor = Mockito.spy(new BalancedQueueRpcExecutor("test-index-queue", 30, 1, 300));
    +    private static RpcExecutor metadataRpcExecutor = Mockito.spy(new BalancedQueueRpcExecutor("test-metataqueue", 30, 1, 300));
    +    
    +    /**
    +     * Factory that uses a spyed RpcExecutor
    +     */
    +    public static class TestPhoenixIndexRpcSchedulerFactory extends PhoenixRpcSchedulerFactory {
    +        @Override
    +        public RpcScheduler create(Configuration conf, RegionServerServices services) {
    +            PhoenixRpcScheduler phoenixIndexRpcScheduler = (PhoenixRpcScheduler)super.create(conf, services);
    +            phoenixIndexRpcScheduler.setIndexExecutorForTesting(indexRpcExecutor);
    +            phoenixIndexRpcScheduler.setMetadataExecutorForTesting(metadataRpcExecutor);
    +            return phoenixIndexRpcScheduler;
    +        }
    +    }
    +
    +    @Before
    +    public void doSetup() throws Exception {
    +        conf = HBaseConfiguration.create();
    +        setUpConfigForMiniCluster(conf);
    +        conf.set(HRegionServer.REGION_SERVER_RPC_SCHEDULER_FACTORY_CLASS,
    +                TestPhoenixIndexRpcSchedulerFactory.class.getName());
    +        conf.set(RpcControllerFactory.CUSTOM_CONTROLLER_CONF_KEY, PhoenixRpcControllerFactory.class.getName());
    +        util = new HBaseTestingUtility(conf);
    +        // start cluster with 2 region servers
    +        util.startMiniCluster(NUM_SLAVES);
    +        admin = util.getHBaseAdmin();
    +        String clientPort = util.getConfiguration().get(QueryServices.ZOOKEEPER_PORT_ATTRIB);
    +        url = JDBC_PROTOCOL + JDBC_PROTOCOL_SEPARATOR + LOCALHOST + JDBC_PROTOCOL_SEPARATOR + clientPort
    --- End diff --
    
    isn't there a helper method for this somewhere?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27151502
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/hbase/index/PhoenixRpcControllerFactory.java ---
    @@ -26,52 +26,57 @@
     import org.apache.hadoop.hbase.ipc.DelegatingPayloadCarryingRpcController;
     import org.apache.hadoop.hbase.ipc.PayloadCarryingRpcController;
     import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
    -import org.apache.phoenix.hbase.index.ipc.PhoenixIndexRpcSchedulerFactory;
    +import org.apache.phoenix.hbase.index.ipc.PhoenixRpcSchedulerFactory;
     import org.apache.phoenix.util.SchemaUtil;
     
     /**
      * {@link RpcControllerFactory} that overrides the standard {@link PayloadCarryingRpcController} to
      * allow the configured index tables (via {@link #INDEX_TABLE_NAMES_KEY}) to use the Index priority.
      */
    -public class IndexQosRpcControllerFactory extends RpcControllerFactory {
    +public class PhoenixRpcControllerFactory extends RpcControllerFactory {
     
         public static final String INDEX_TABLE_NAMES_KEY = "phoenix.index.rpc.controller.index-tables";
     
    -    public IndexQosRpcControllerFactory(Configuration conf) {
    +    public PhoenixRpcControllerFactory(Configuration conf) {
             super(conf);
         }
     
         @Override
         public PayloadCarryingRpcController newController() {
             PayloadCarryingRpcController delegate = super.newController();
    -        return new IndexQosRpcController(delegate, conf);
    +        return new PhoenixRpcController(delegate, conf);
         }
     
         @Override
         public PayloadCarryingRpcController newController(CellScanner cellScanner) {
             PayloadCarryingRpcController delegate = super.newController(cellScanner);
    -        return new IndexQosRpcController(delegate, conf);
    +        return new PhoenixRpcController(delegate, conf);
         }
     
         @Override
         public PayloadCarryingRpcController newController(List<CellScannable> cellIterables) {
             PayloadCarryingRpcController delegate = super.newController(cellIterables);
    -        return new IndexQosRpcController(delegate, conf);
    +        return new PhoenixRpcController(delegate, conf);
         }
     
    -    private class IndexQosRpcController extends DelegatingPayloadCarryingRpcController {
    +    private class PhoenixRpcController extends DelegatingPayloadCarryingRpcController {
     
    -        private int priority;
    +        private int indexPriority;
    +        private int metadataPriority;
     
    -        public IndexQosRpcController(PayloadCarryingRpcController delegate, Configuration conf) {
    +        public PhoenixRpcController(PayloadCarryingRpcController delegate, Configuration conf) {
                 super(delegate);
    -            this.priority = PhoenixIndexRpcSchedulerFactory.getMinPriority(conf);
    +            this.indexPriority = PhoenixRpcSchedulerFactory.getIndexMinPriority(conf);
    +            this.metadataPriority = PhoenixRpcSchedulerFactory.getMetadataMinPriority(conf);
             }
             @Override
             public void setPriority(final TableName tn) {
    -            // if its an index table, then we override to the index priority
    -            if (!tn.isSystemTable() &&  !SchemaUtil.isSystemDataTable(tn.getNameAsString())) {
    -                setPriority(this.priority);
    +            // this is function is called for hbase system tables, phoenix system tables and index tables 
    +            if (SchemaUtil.isSystemDataTable(tn.getNameAsString())) {
    --- End diff --
    
    Minor nit: how about moving SchemaUtil.isSystemDataTable() here and calling it useHighPriorityQueue() instead as I don't think it'd be called elsewhere (since it's somewhat random subset of our system tables).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27270296
  
    --- Diff: phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java ---
    @@ -40,28 +40,34 @@
         private static final int DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER = 10;
     
         private RpcScheduler delegate;
    -    private int minPriority;
    -    private int maxPriority;
    -    private RpcExecutor callExecutor;
    +    private int indexPriority;
    +    private int metadataPriority;
    +    private RpcExecutor indexCallExecutor;
    +    private RpcExecutor metadataCallExecutor;
         private int port;
     
    -    public PhoenixIndexRpcScheduler(int indexHandlerCount, Configuration conf,
    -            RpcScheduler delegate, int minPriority, int maxPriority) {
    +    public PhoenixRpcScheduler(int indexHandlerCount, int metadataHandlerCount, Configuration conf,
    --- End diff --
    
    I don't think you need int indexHandlerCount, int metadataHandlerCount anymore, nor do we need the config params. I believe this was based on the range of priorities we were reserving. Both are just 1 now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27270740
  
    --- Diff: phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java ---
    @@ -40,28 +40,34 @@
         private static final int DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER = 10;
     
         private RpcScheduler delegate;
    -    private int minPriority;
    -    private int maxPriority;
    -    private RpcExecutor callExecutor;
    +    private int indexPriority;
    +    private int metadataPriority;
    +    private RpcExecutor indexCallExecutor;
    +    private RpcExecutor metadataCallExecutor;
         private int port;
     
    -    public PhoenixIndexRpcScheduler(int indexHandlerCount, Configuration conf,
    -            RpcScheduler delegate, int minPriority, int maxPriority) {
    +    public PhoenixRpcScheduler(int indexHandlerCount, int metadataHandlerCount, Configuration conf,
    --- End diff --
    
    I don't think declaring a range of priorities future proofs this as no one will know we've reserved that range - folks don't even read docs in general. If if they did happen upon it, there's nothing that'll enforce that they respect it. Better IMO to declare that we're using two explicit priorities. If folks need to change them, it pretty straightforward as it's two documented config parameters.
    
    The current implementation is simpler, removes a number of configs (we already have too many), and meets the needs.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by jyates <gi...@git.apache.org>.
Github user jyates commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27271213
  
    --- Diff: phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java ---
    @@ -40,28 +40,34 @@
         private static final int DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER = 10;
     
         private RpcScheduler delegate;
    -    private int minPriority;
    -    private int maxPriority;
    -    private RpcExecutor callExecutor;
    +    private int indexPriority;
    +    private int metadataPriority;
    +    private RpcExecutor indexCallExecutor;
    +    private RpcExecutor metadataCallExecutor;
         private int port;
     
    -    public PhoenixIndexRpcScheduler(int indexHandlerCount, Configuration conf,
    -            RpcScheduler delegate, int minPriority, int maxPriority) {
    +    public PhoenixRpcScheduler(int indexHandlerCount, int metadataHandlerCount, Configuration conf,
    --- End diff --
    
    I've stated my case - if you still think I'm being overkill @JamesRTaylor then I'm happy to go with your proposal. Just wanted to call out the full implications.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27152695
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/hbase/index/ipc/PhoenixRpcSchedulerFactory.java ---
    @@ -62,30 +62,59 @@ public RpcScheduler create(Configuration conf, RegionServerServices services) {
                 return delegate;
             }
     
    +        // get the index priority configs
             int indexHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_HANDLER_COUNT);
    -        int minPriority = getMinPriority(conf);
    -        int maxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_MAX_PRIORITY);
    -        // make sure the ranges are outside the warning ranges
    -        Preconditions.checkArgument(maxPriority > minPriority, "Max index priority (" + maxPriority
    -                + ") must be larger than min priority (" + minPriority + ")");
    -        boolean allSmaller =
    -                minPriority < HConstants.REPLICATION_QOS
    -                        && maxPriority < HConstants.REPLICATION_QOS;
    -        boolean allLarger = minPriority > HConstants.HIGH_QOS;
    -        Preconditions.checkArgument(allSmaller || allLarger, "Index priority range (" + minPriority
    -                + ",  " + maxPriority + ") must be outside HBase priority range ("
    -                + HConstants.REPLICATION_QOS + ", " + HConstants.HIGH_QOS + ")");
    +        int indexMinPriority = getIndexMinPriority(conf);
    +        int indexMaxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_MAX_PRIORITY);
    +        validatePriority(indexMinPriority, indexMaxPriority);
    +        
    +        // get the metadata priority configs
    +        int metadataHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_METADATA_HANDLER_COUNT);
    +        int metadataMinPriority = getMetadataMinPriority(conf);
    +        int metadataMaxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_METADATA_MAX_PRIORITY);
    --- End diff --
    
    That'd be my vote. It'd cut down on what you'd need to configure too, right? If we have a default value for the priority, you wouldn't even need to specify this in hbase-sites.xml. If we need more down the road, we can always add it (but I don't think we will).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by jyates <gi...@git.apache.org>.
Github user jyates commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27153585
  
    --- Diff: phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixRpcIT.java ---
    @@ -0,0 +1,264 @@
    +/*
    + * 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.phoenix.end2end.index;
    +
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL;
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
    +import static org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM;
    +import static org.apache.phoenix.util.TestUtil.LOCALHOST;
    +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertFalse;
    +import static org.junit.Assert.assertNotEquals;
    +import static org.junit.Assert.assertTrue;
    +
    +import java.sql.Connection;
    +import java.sql.PreparedStatement;
    +import java.sql.ResultSet;
    +import java.util.List;
    +import java.util.Properties;
    +
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.hbase.HBaseConfiguration;
    +import org.apache.hadoop.hbase.HBaseTestingUtility;
    +import org.apache.hadoop.hbase.HRegionInfo;
    +import org.apache.hadoop.hbase.MiniHBaseCluster;
    +import org.apache.hadoop.hbase.ServerName;
    +import org.apache.hadoop.hbase.client.HBaseAdmin;
    +import org.apache.hadoop.hbase.ipc.BalancedQueueRpcExecutor;
    +import org.apache.hadoop.hbase.ipc.CallRunner;
    +import org.apache.hadoop.hbase.ipc.PhoenixRpcScheduler;
    +import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
    +import org.apache.hadoop.hbase.ipc.RpcExecutor;
    +import org.apache.hadoop.hbase.ipc.RpcScheduler;
    +import org.apache.hadoop.hbase.master.AssignmentManager;
    +import org.apache.hadoop.hbase.master.HMaster;
    +import org.apache.hadoop.hbase.regionserver.HRegionServer;
    +import org.apache.hadoop.hbase.regionserver.RegionServerServices;
    +import org.apache.hadoop.hbase.util.Bytes;
    +import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
    +import org.apache.phoenix.hbase.index.PhoenixRpcControllerFactory;
    +import org.apache.phoenix.hbase.index.ipc.PhoenixRpcSchedulerFactory;
    +import org.apache.phoenix.jdbc.PhoenixTestDriver;
    +import org.apache.phoenix.query.BaseTest;
    +import org.apache.phoenix.query.QueryServices;
    +import org.apache.phoenix.util.PropertiesUtil;
    +import org.apache.phoenix.util.QueryUtil;
    +import org.apache.phoenix.util.ReadOnlyProps;
    +import org.apache.phoenix.util.SchemaUtil;
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.mockito.Mockito;
    +
    +
    +@Category(NeedsOwnMiniClusterTest.class)
    +public class PhoenixRpcIT extends BaseTest {
    +
    +    private static final String SCHEMA_NAME = "S";
    +    private static final String INDEX_TABLE_NAME = "I";
    +    private static final String DATA_TABLE_FULL_NAME = SchemaUtil.getTableName(SCHEMA_NAME, "T");
    +    private static final String INDEX_TABLE_FULL_NAME = SchemaUtil.getTableName(SCHEMA_NAME, "I");
    +    private static final int NUM_SLAVES = 2;
    +
    +    private static String url;
    +    private static PhoenixTestDriver driver;
    +    private HBaseTestingUtility util;
    +    private HBaseAdmin admin;
    +    private Configuration conf;
    +    private static RpcExecutor indexRpcExecutor = Mockito.spy(new BalancedQueueRpcExecutor("test-index-queue", 30, 1, 300));
    +    private static RpcExecutor metadataRpcExecutor = Mockito.spy(new BalancedQueueRpcExecutor("test-metataqueue", 30, 1, 300));
    +    
    +    /**
    +     * Factory that uses a spyed RpcExecutor
    +     */
    +    public static class TestPhoenixIndexRpcSchedulerFactory extends PhoenixRpcSchedulerFactory {
    +        @Override
    +        public RpcScheduler create(Configuration conf, RegionServerServices services) {
    +            PhoenixRpcScheduler phoenixIndexRpcScheduler = (PhoenixRpcScheduler)super.create(conf, services);
    +            phoenixIndexRpcScheduler.setIndexExecutorForTesting(indexRpcExecutor);
    +            phoenixIndexRpcScheduler.setMetadataExecutorForTesting(metadataRpcExecutor);
    +            return phoenixIndexRpcScheduler;
    +        }
    +    }
    +
    +    @Before
    +    public void doSetup() throws Exception {
    +        conf = HBaseConfiguration.create();
    +        setUpConfigForMiniCluster(conf);
    +        conf.set(HRegionServer.REGION_SERVER_RPC_SCHEDULER_FACTORY_CLASS,
    +                TestPhoenixIndexRpcSchedulerFactory.class.getName());
    +        conf.set(RpcControllerFactory.CUSTOM_CONTROLLER_CONF_KEY, PhoenixRpcControllerFactory.class.getName());
    +        util = new HBaseTestingUtility(conf);
    +        // start cluster with 2 region servers
    +        util.startMiniCluster(NUM_SLAVES);
    +        admin = util.getHBaseAdmin();
    +        String clientPort = util.getConfiguration().get(QueryServices.ZOOKEEPER_PORT_ATTRIB);
    +        url = JDBC_PROTOCOL + JDBC_PROTOCOL_SEPARATOR + LOCALHOST + JDBC_PROTOCOL_SEPARATOR + clientPort
    +                + JDBC_PROTOCOL_TERMINATOR + PHOENIX_TEST_DRIVER_URL_PARAM;
    +        driver = initAndRegisterDriver(url, ReadOnlyProps.EMPTY_PROPS);
    +    }
    +
    +    @After
    +    public void tearDown() throws Exception {
    +        try {
    +            destroyDriver(driver);
    +            if (admin!=null) {
    +            	admin.close();
    +            }
    +        } finally {
    +            util.shutdownMiniCluster();
    --- End diff --
    
    Do we need a whole new cluster for every method?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27151696
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/hbase/index/ipc/PhoenixRpcSchedulerFactory.java ---
    @@ -62,30 +62,59 @@ public RpcScheduler create(Configuration conf, RegionServerServices services) {
                 return delegate;
             }
     
    +        // get the index priority configs
             int indexHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_HANDLER_COUNT);
    -        int minPriority = getMinPriority(conf);
    -        int maxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_MAX_PRIORITY);
    -        // make sure the ranges are outside the warning ranges
    -        Preconditions.checkArgument(maxPriority > minPriority, "Max index priority (" + maxPriority
    -                + ") must be larger than min priority (" + minPriority + ")");
    -        boolean allSmaller =
    -                minPriority < HConstants.REPLICATION_QOS
    -                        && maxPriority < HConstants.REPLICATION_QOS;
    -        boolean allLarger = minPriority > HConstants.HIGH_QOS;
    -        Preconditions.checkArgument(allSmaller || allLarger, "Index priority range (" + minPriority
    -                + ",  " + maxPriority + ") must be outside HBase priority range ("
    -                + HConstants.REPLICATION_QOS + ", " + HConstants.HIGH_QOS + ")");
    +        int indexMinPriority = getIndexMinPriority(conf);
    +        int indexMaxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_MAX_PRIORITY);
    +        validatePriority(indexMinPriority, indexMaxPriority);
    +        
    +        // get the metadata priority configs
    +        int metadataHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_METADATA_HANDLER_COUNT);
    +        int metadataMinPriority = getMetadataMinPriority(conf);
    +        int metadataMaxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_METADATA_MAX_PRIORITY);
    --- End diff --
    
    Do we really need a range? Might be simpler if we just had a single config attribute for "SYSTEM_RPC_PRIORITY".


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27158033
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/hbase/index/ipc/PhoenixRpcSchedulerFactory.java ---
    @@ -62,30 +62,59 @@ public RpcScheduler create(Configuration conf, RegionServerServices services) {
                 return delegate;
             }
     
    +        // get the index priority configs
             int indexHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_HANDLER_COUNT);
    -        int minPriority = getMinPriority(conf);
    -        int maxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_MAX_PRIORITY);
    -        // make sure the ranges are outside the warning ranges
    -        Preconditions.checkArgument(maxPriority > minPriority, "Max index priority (" + maxPriority
    -                + ") must be larger than min priority (" + minPriority + ")");
    -        boolean allSmaller =
    -                minPriority < HConstants.REPLICATION_QOS
    -                        && maxPriority < HConstants.REPLICATION_QOS;
    -        boolean allLarger = minPriority > HConstants.HIGH_QOS;
    -        Preconditions.checkArgument(allSmaller || allLarger, "Index priority range (" + minPriority
    -                + ",  " + maxPriority + ") must be outside HBase priority range ("
    -                + HConstants.REPLICATION_QOS + ", " + HConstants.HIGH_QOS + ")");
    +        int indexMinPriority = getIndexMinPriority(conf);
    +        int indexMaxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_MAX_PRIORITY);
    +        validatePriority(indexMinPriority, indexMaxPriority);
    +        
    +        // get the metadata priority configs
    +        int metadataHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_METADATA_HANDLER_COUNT);
    +        int metadataMinPriority = getMetadataMinPriority(conf);
    +        int metadataMaxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_METADATA_MAX_PRIORITY);
    --- End diff --
    
    The range is implied and documented by having a config for PHOENIX_META priority and config for PHOENIX_INDEX priority.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27269910
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/query/QueryServices.java ---
    @@ -123,9 +123,10 @@
         // Index will be partially re-built from index disable time stamp - following overlap time
         public static final String INDEX_FAILURE_HANDLING_REBUILD_OVERLAP_TIME_ATTRIB =
             "phoenix.index.failure.handling.rebuild.overlap.time";
    -    public static final String MIN_INDEX_PRIOIRTY_ATTRIB = "phoenix.regionserver.index.priority.min";
    -    public static final String MAX_INDEX_PRIOIRTY_ATTRIB = "phoenix.regionserver.index.priority.max";
    +    public static final String INDEX_PRIOIRTY_ATTRIB = "phoenix.regionserver.index.priority";
         public static final String INDEX_HANDLER_COUNT_ATTRIB = "phoenix.regionserver.index.handler.count";
    +    public static final String METADATA_PRIOIRTY_ATTRIB = "phoenix.regionserver.metadata.priority";
    --- End diff --
    
    This is a client side and region server param, isn't it? How about phoenix.index.rpc.priority and phoenix.metadata.rpc.priority?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by twdsilva <gi...@git.apache.org>.
Github user twdsilva commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27155154
  
    --- Diff: phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixRpcIT.java ---
    @@ -0,0 +1,264 @@
    +/*
    + * 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.phoenix.end2end.index;
    +
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL;
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
    +import static org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM;
    +import static org.apache.phoenix.util.TestUtil.LOCALHOST;
    +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertFalse;
    +import static org.junit.Assert.assertNotEquals;
    +import static org.junit.Assert.assertTrue;
    +
    +import java.sql.Connection;
    +import java.sql.PreparedStatement;
    +import java.sql.ResultSet;
    +import java.util.List;
    +import java.util.Properties;
    +
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.hbase.HBaseConfiguration;
    +import org.apache.hadoop.hbase.HBaseTestingUtility;
    +import org.apache.hadoop.hbase.HRegionInfo;
    +import org.apache.hadoop.hbase.MiniHBaseCluster;
    +import org.apache.hadoop.hbase.ServerName;
    +import org.apache.hadoop.hbase.client.HBaseAdmin;
    +import org.apache.hadoop.hbase.ipc.BalancedQueueRpcExecutor;
    +import org.apache.hadoop.hbase.ipc.CallRunner;
    +import org.apache.hadoop.hbase.ipc.PhoenixRpcScheduler;
    +import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
    +import org.apache.hadoop.hbase.ipc.RpcExecutor;
    +import org.apache.hadoop.hbase.ipc.RpcScheduler;
    +import org.apache.hadoop.hbase.master.AssignmentManager;
    +import org.apache.hadoop.hbase.master.HMaster;
    +import org.apache.hadoop.hbase.regionserver.HRegionServer;
    +import org.apache.hadoop.hbase.regionserver.RegionServerServices;
    +import org.apache.hadoop.hbase.util.Bytes;
    +import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
    +import org.apache.phoenix.hbase.index.PhoenixRpcControllerFactory;
    +import org.apache.phoenix.hbase.index.ipc.PhoenixRpcSchedulerFactory;
    +import org.apache.phoenix.jdbc.PhoenixTestDriver;
    +import org.apache.phoenix.query.BaseTest;
    +import org.apache.phoenix.query.QueryServices;
    +import org.apache.phoenix.util.PropertiesUtil;
    +import org.apache.phoenix.util.QueryUtil;
    +import org.apache.phoenix.util.ReadOnlyProps;
    +import org.apache.phoenix.util.SchemaUtil;
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.mockito.Mockito;
    +
    +
    +@Category(NeedsOwnMiniClusterTest.class)
    +public class PhoenixRpcIT extends BaseTest {
    +
    +    private static final String SCHEMA_NAME = "S";
    +    private static final String INDEX_TABLE_NAME = "I";
    +    private static final String DATA_TABLE_FULL_NAME = SchemaUtil.getTableName(SCHEMA_NAME, "T");
    +    private static final String INDEX_TABLE_FULL_NAME = SchemaUtil.getTableName(SCHEMA_NAME, "I");
    +    private static final int NUM_SLAVES = 2;
    +
    +    private static String url;
    +    private static PhoenixTestDriver driver;
    +    private HBaseTestingUtility util;
    +    private HBaseAdmin admin;
    +    private Configuration conf;
    +    private static RpcExecutor indexRpcExecutor = Mockito.spy(new BalancedQueueRpcExecutor("test-index-queue", 30, 1, 300));
    +    private static RpcExecutor metadataRpcExecutor = Mockito.spy(new BalancedQueueRpcExecutor("test-metataqueue", 30, 1, 300));
    +    
    +    /**
    +     * Factory that uses a spyed RpcExecutor
    +     */
    +    public static class TestPhoenixIndexRpcSchedulerFactory extends PhoenixRpcSchedulerFactory {
    +        @Override
    +        public RpcScheduler create(Configuration conf, RegionServerServices services) {
    +            PhoenixRpcScheduler phoenixIndexRpcScheduler = (PhoenixRpcScheduler)super.create(conf, services);
    +            phoenixIndexRpcScheduler.setIndexExecutorForTesting(indexRpcExecutor);
    +            phoenixIndexRpcScheduler.setMetadataExecutorForTesting(metadataRpcExecutor);
    +            return phoenixIndexRpcScheduler;
    +        }
    +    }
    +
    +    @Before
    +    public void doSetup() throws Exception {
    +        conf = HBaseConfiguration.create();
    +        setUpConfigForMiniCluster(conf);
    +        conf.set(HRegionServer.REGION_SERVER_RPC_SCHEDULER_FACTORY_CLASS,
    +                TestPhoenixIndexRpcSchedulerFactory.class.getName());
    +        conf.set(RpcControllerFactory.CUSTOM_CONTROLLER_CONF_KEY, PhoenixRpcControllerFactory.class.getName());
    +        util = new HBaseTestingUtility(conf);
    +        // start cluster with 2 region servers
    +        util.startMiniCluster(NUM_SLAVES);
    +        admin = util.getHBaseAdmin();
    +        String clientPort = util.getConfiguration().get(QueryServices.ZOOKEEPER_PORT_ATTRIB);
    +        url = JDBC_PROTOCOL + JDBC_PROTOCOL_SEPARATOR + LOCALHOST + JDBC_PROTOCOL_SEPARATOR + clientPort
    --- End diff --
    
    Yes there is getLocalClusterUrl, I will use that.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by jyates <gi...@git.apache.org>.
Github user jyates commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27153366
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/hbase/index/ipc/PhoenixRpcSchedulerFactory.java ---
    @@ -62,30 +62,59 @@ public RpcScheduler create(Configuration conf, RegionServerServices services) {
                 return delegate;
             }
     
    +        // get the index priority configs
             int indexHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_HANDLER_COUNT);
    -        int minPriority = getMinPriority(conf);
    -        int maxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_MAX_PRIORITY);
    -        // make sure the ranges are outside the warning ranges
    -        Preconditions.checkArgument(maxPriority > minPriority, "Max index priority (" + maxPriority
    -                + ") must be larger than min priority (" + minPriority + ")");
    -        boolean allSmaller =
    -                minPriority < HConstants.REPLICATION_QOS
    -                        && maxPriority < HConstants.REPLICATION_QOS;
    -        boolean allLarger = minPriority > HConstants.HIGH_QOS;
    -        Preconditions.checkArgument(allSmaller || allLarger, "Index priority range (" + minPriority
    -                + ",  " + maxPriority + ") must be outside HBase priority range ("
    -                + HConstants.REPLICATION_QOS + ", " + HConstants.HIGH_QOS + ")");
    +        int indexMinPriority = getIndexMinPriority(conf);
    +        int indexMaxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_MAX_PRIORITY);
    +        validatePriority(indexMinPriority, indexMaxPriority);
    +        
    +        // get the metadata priority configs
    +        int metadataHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_METADATA_HANDLER_COUNT);
    +        int metadataMinPriority = getMetadataMinPriority(conf);
    +        int metadataMaxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_METADATA_MAX_PRIORITY);
    --- End diff --
    
    I can see us wanting a reserved range for metadata updates - say 10 different numbers - so we don't have to worry about conflicting with anything else that needs its own priority in the future. Its easy to get into situations, especially if everyone is carefully watching these numbers and fully know whats going on, to get into situations where you have META = 1, SOME_FEATURE=2, OTHER_META=3, etc.
    
    A reserved range is just safer for the future and is likely to never be changed in the configuration, unless people already to priority changing, which is unlikely given how hard it was for us :). However, having the configuration is necessary, regardless of range or a single value, to ensure people can make it work with their existing installations (and as proof against HBase invading our range space by accident).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by jyates <gi...@git.apache.org>.
Github user jyates commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27270493
  
    --- Diff: phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java ---
    @@ -40,28 +40,34 @@
         private static final int DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER = 10;
     
         private RpcScheduler delegate;
    -    private int minPriority;
    -    private int maxPriority;
    -    private RpcExecutor callExecutor;
    +    private int indexPriority;
    +    private int metadataPriority;
    +    private RpcExecutor indexCallExecutor;
    +    private RpcExecutor metadataCallExecutor;
         private int port;
     
    -    public PhoenixIndexRpcScheduler(int indexHandlerCount, Configuration conf,
    -            RpcScheduler delegate, int minPriority, int maxPriority) {
    +    public PhoenixRpcScheduler(int indexHandlerCount, int metadataHandlerCount, Configuration conf,
    --- End diff --
    
    @JamesRTaylor 
    >  I believe this was based on the range of priorities we were reserving. Both are just 1 now.
    
    Why don't you agree with the future proofing of a range of priorities? I think I put forward a good case for them elsewhere.. maybe I didn't see your comments otherwise?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by jyates <gi...@git.apache.org>.
Github user jyates commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27153823
  
    --- Diff: phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixRpcIT.java ---
    @@ -0,0 +1,264 @@
    +/*
    + * 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.phoenix.end2end.index;
    +
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL;
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
    +import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
    +import static org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM;
    +import static org.apache.phoenix.util.TestUtil.LOCALHOST;
    +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertFalse;
    +import static org.junit.Assert.assertNotEquals;
    +import static org.junit.Assert.assertTrue;
    +
    +import java.sql.Connection;
    +import java.sql.PreparedStatement;
    +import java.sql.ResultSet;
    +import java.util.List;
    +import java.util.Properties;
    +
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.hbase.HBaseConfiguration;
    +import org.apache.hadoop.hbase.HBaseTestingUtility;
    +import org.apache.hadoop.hbase.HRegionInfo;
    +import org.apache.hadoop.hbase.MiniHBaseCluster;
    +import org.apache.hadoop.hbase.ServerName;
    +import org.apache.hadoop.hbase.client.HBaseAdmin;
    +import org.apache.hadoop.hbase.ipc.BalancedQueueRpcExecutor;
    +import org.apache.hadoop.hbase.ipc.CallRunner;
    +import org.apache.hadoop.hbase.ipc.PhoenixRpcScheduler;
    +import org.apache.hadoop.hbase.ipc.RpcControllerFactory;
    +import org.apache.hadoop.hbase.ipc.RpcExecutor;
    +import org.apache.hadoop.hbase.ipc.RpcScheduler;
    +import org.apache.hadoop.hbase.master.AssignmentManager;
    +import org.apache.hadoop.hbase.master.HMaster;
    +import org.apache.hadoop.hbase.regionserver.HRegionServer;
    +import org.apache.hadoop.hbase.regionserver.RegionServerServices;
    +import org.apache.hadoop.hbase.util.Bytes;
    +import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
    +import org.apache.phoenix.hbase.index.PhoenixRpcControllerFactory;
    +import org.apache.phoenix.hbase.index.ipc.PhoenixRpcSchedulerFactory;
    +import org.apache.phoenix.jdbc.PhoenixTestDriver;
    +import org.apache.phoenix.query.BaseTest;
    +import org.apache.phoenix.query.QueryServices;
    +import org.apache.phoenix.util.PropertiesUtil;
    +import org.apache.phoenix.util.QueryUtil;
    +import org.apache.phoenix.util.ReadOnlyProps;
    +import org.apache.phoenix.util.SchemaUtil;
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.mockito.Mockito;
    +
    +
    +@Category(NeedsOwnMiniClusterTest.class)
    +public class PhoenixRpcIT extends BaseTest {
    +
    +    private static final String SCHEMA_NAME = "S";
    +    private static final String INDEX_TABLE_NAME = "I";
    +    private static final String DATA_TABLE_FULL_NAME = SchemaUtil.getTableName(SCHEMA_NAME, "T");
    +    private static final String INDEX_TABLE_FULL_NAME = SchemaUtil.getTableName(SCHEMA_NAME, "I");
    +    private static final int NUM_SLAVES = 2;
    +
    +    private static String url;
    +    private static PhoenixTestDriver driver;
    +    private HBaseTestingUtility util;
    +    private HBaseAdmin admin;
    +    private Configuration conf;
    +    private static RpcExecutor indexRpcExecutor = Mockito.spy(new BalancedQueueRpcExecutor("test-index-queue", 30, 1, 300));
    --- End diff --
    
    Does the spys need to be reset for mockito?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by jyates <gi...@git.apache.org>.
Github user jyates commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27271159
  
    --- Diff: phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java ---
    @@ -40,28 +40,34 @@
         private static final int DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER = 10;
     
         private RpcScheduler delegate;
    -    private int minPriority;
    -    private int maxPriority;
    -    private RpcExecutor callExecutor;
    +    private int indexPriority;
    +    private int metadataPriority;
    +    private RpcExecutor indexCallExecutor;
    +    private RpcExecutor metadataCallExecutor;
         private int port;
     
    -    public PhoenixIndexRpcScheduler(int indexHandlerCount, Configuration conf,
    -            RpcScheduler delegate, int minPriority, int maxPriority) {
    +    public PhoenixRpcScheduler(int indexHandlerCount, int metadataHandlerCount, Configuration conf,
    --- End diff --
    
    And if we ever want to add different priorities for different indexes? Or for different metadata tables? Or some other special tables (e.g. higher priority tables as a logical construct). But ok, we can just assign each a number as it comes up... that's never been weird for any other use case ::sarcasm::
    
    > removes a number of configs 
    The number needs to be configurable to support installations where people are using priorities for other things that aren't necessarily phoenix (as I mentioned elsewhere), so having an upper and a lower for each isn't really that big of a deal, IMHO.
    
    > If if they did happen upon it, there's nothing that'll enforce that they respect it
    Except their cluster becoming unusable.
    
    >  Better IMO to declare that we're using two explicit priorities
    Which is again, buried somewhere in the docs. Its fine to say that they claim a range in the same place and then add a link to a 'you can configure it here', but maybe I'm mistaken in what users want?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by twdsilva <gi...@git.apache.org>.
Github user twdsilva commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27269432
  
    --- Diff: phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java ---
    @@ -40,28 +40,34 @@
         private static final int DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER = 10;
     
         private RpcScheduler delegate;
    -    private int minPriority;
    -    private int maxPriority;
    -    private RpcExecutor callExecutor;
    +    private int indexPriority;
    +    private int metadataPriority;
    +    private RpcExecutor indexCallExecutor;
    +    private RpcExecutor metadataCallExecutor;
         private int port;
     
    -    public PhoenixIndexRpcScheduler(int indexHandlerCount, Configuration conf,
    -            RpcScheduler delegate, int minPriority, int maxPriority) {
    +    public PhoenixRpcScheduler(int indexHandlerCount, int metadataHandlerCount, Configuration conf,
    --- End diff --
    
    I modified the controller factory to use  create a chain of controllers, which was easy I could just have them extend DelegatingPayloadCarryingRpcController. 
    However for the PhoenixRpcScheduler needs to implement getGeneralQueueLength and getActiveRpcHandlerCount which need queue lengths and counts of the indexCallExecutor and metadataCallExecutor . 
    Do you think it would be easier to have a map from prioirity to queue and then in dispatch() we just lookup the queue based on the priority (and if its not found in the map call  delegate.dispatch(callTask) )?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by twdsilva <gi...@git.apache.org>.
Github user twdsilva closed the pull request at:

    https://github.com/apache/phoenix/pull/55


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27271368
  
    --- Diff: phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java ---
    @@ -40,28 +40,34 @@
         private static final int DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER = 10;
     
         private RpcScheduler delegate;
    -    private int minPriority;
    -    private int maxPriority;
    -    private RpcExecutor callExecutor;
    +    private int indexPriority;
    +    private int metadataPriority;
    +    private RpcExecutor indexCallExecutor;
    +    private RpcExecutor metadataCallExecutor;
         private int port;
     
    -    public PhoenixIndexRpcScheduler(int indexHandlerCount, Configuration conf,
    -            RpcScheduler delegate, int minPriority, int maxPriority) {
    +    public PhoenixRpcScheduler(int indexHandlerCount, int metadataHandlerCount, Configuration conf,
    --- End diff --
    
    bq. And if we ever want to add different priorities for different indexes? Or for different metadata tables?
    I don't anticipate that based on what I've seen our users do and what's talked about on the mailing list. I'd rather keep things simpler for now as it's easier to understand. As new committers come onboard, it's easier to get them up to speed if that's the case.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by jyates <gi...@git.apache.org>.
Github user jyates commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27154220
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/hbase/index/ipc/PhoenixRpcSchedulerFactory.java ---
    @@ -62,30 +62,59 @@ public RpcScheduler create(Configuration conf, RegionServerServices services) {
                 return delegate;
             }
     
    +        // get the index priority configs
             int indexHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_HANDLER_COUNT);
    -        int minPriority = getMinPriority(conf);
    -        int maxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_MAX_PRIORITY);
    -        // make sure the ranges are outside the warning ranges
    -        Preconditions.checkArgument(maxPriority > minPriority, "Max index priority (" + maxPriority
    -                + ") must be larger than min priority (" + minPriority + ")");
    -        boolean allSmaller =
    -                minPriority < HConstants.REPLICATION_QOS
    -                        && maxPriority < HConstants.REPLICATION_QOS;
    -        boolean allLarger = minPriority > HConstants.HIGH_QOS;
    -        Preconditions.checkArgument(allSmaller || allLarger, "Index priority range (" + minPriority
    -                + ",  " + maxPriority + ") must be outside HBase priority range ("
    -                + HConstants.REPLICATION_QOS + ", " + HConstants.HIGH_QOS + ")");
    +        int indexMinPriority = getIndexMinPriority(conf);
    +        int indexMaxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_MAX_PRIORITY);
    +        validatePriority(indexMinPriority, indexMaxPriority);
    +        
    +        // get the metadata priority configs
    +        int metadataHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_METADATA_HANDLER_COUNT);
    +        int metadataMinPriority = getMetadataMinPriority(conf);
    +        int metadataMaxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_METADATA_MAX_PRIORITY);
    +        validatePriority(indexMinPriority, indexMaxPriority);
    +        
    +        //validate index and metadata priorities do not overlap
    +        Preconditions.checkArgument(doesNotOverlap(indexMinPriority, indexMaxPriority, metadataMinPriority, metadataMaxPriority), "Priority ranges ("
    +                + indexMinPriority + ",  " + indexMaxPriority + ") and  (" + metadataMinPriority + ", " + metadataMaxPriority
    --- End diff --
    
    super nit: Might be cleaner if you just use a format string here


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by jyates <gi...@git.apache.org>.
Github user jyates commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27153449
  
    --- Diff: phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PhoenixRpcIT.java ---
    @@ -0,0 +1,264 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
    --- End diff --
    
    Nit: looks like you formatted the header :-/


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by twdsilva <gi...@git.apache.org>.
Github user twdsilva commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27152399
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/hbase/index/ipc/PhoenixRpcSchedulerFactory.java ---
    @@ -62,30 +62,59 @@ public RpcScheduler create(Configuration conf, RegionServerServices services) {
                 return delegate;
             }
     
    +        // get the index priority configs
             int indexHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_HANDLER_COUNT);
    -        int minPriority = getMinPriority(conf);
    -        int maxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_MAX_PRIORITY);
    -        // make sure the ranges are outside the warning ranges
    -        Preconditions.checkArgument(maxPriority > minPriority, "Max index priority (" + maxPriority
    -                + ") must be larger than min priority (" + minPriority + ")");
    -        boolean allSmaller =
    -                minPriority < HConstants.REPLICATION_QOS
    -                        && maxPriority < HConstants.REPLICATION_QOS;
    -        boolean allLarger = minPriority > HConstants.HIGH_QOS;
    -        Preconditions.checkArgument(allSmaller || allLarger, "Index priority range (" + minPriority
    -                + ",  " + maxPriority + ") must be outside HBase priority range ("
    -                + HConstants.REPLICATION_QOS + ", " + HConstants.HIGH_QOS + ")");
    +        int indexMinPriority = getIndexMinPriority(conf);
    +        int indexMaxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_INDEX_MAX_PRIORITY);
    +        validatePriority(indexMinPriority, indexMaxPriority);
    +        
    +        // get the metadata priority configs
    +        int metadataHandlerCount = conf.getInt(QueryServices.INDEX_HANDLER_COUNT_ATTRIB, QueryServicesOptions.DEFAULT_METADATA_HANDLER_COUNT);
    +        int metadataMinPriority = getMetadataMinPriority(conf);
    +        int metadataMaxPriority = conf.getInt(QueryServices.MAX_INDEX_PRIOIRTY_ATTRIB, QueryServicesOptions.DEFAULT_METADATA_MAX_PRIORITY);
    --- End diff --
    
    I spoke with @jyates, I added the min/max range in case we want to support setting priorities of specific tables in the future, but if this is not required I can remove it and just have a single priority. Should I make the same change for the index priorities?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by JamesRTaylor <gi...@git.apache.org>.
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27269819
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java ---
    @@ -290,7 +290,7 @@ private void openConnection() throws SQLException {
         @Override
         public HTableInterface getTable(byte[] tableName) throws SQLException {
             try {
    -            return HBaseFactoryProvider.getHTableFactory().getTable(tableName, connection, null);
    +            return HBaseFactoryProvider.getHTableFactory().getTable(tableName, connection, getExecutor());
    --- End diff --
    
    Revert this change please - it was part of our experiment to get the RpcScheduler set on the client-side.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] phoenix pull request: PHOENIX-1457 Use high priority queue for met...

Posted by jyates <gi...@git.apache.org>.
Github user jyates commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/55#discussion_r27270440
  
    --- Diff: phoenix-core/src/main/java/org/apache/hadoop/hbase/ipc/PhoenixRpcScheduler.java ---
    @@ -40,28 +40,34 @@
         private static final int DEFAULT_MAX_CALLQUEUE_LENGTH_PER_HANDLER = 10;
     
         private RpcScheduler delegate;
    -    private int minPriority;
    -    private int maxPriority;
    -    private RpcExecutor callExecutor;
    +    private int indexPriority;
    +    private int metadataPriority;
    +    private RpcExecutor indexCallExecutor;
    +    private RpcExecutor metadataCallExecutor;
         private int port;
     
    -    public PhoenixIndexRpcScheduler(int indexHandlerCount, Configuration conf,
    -            RpcScheduler delegate, int minPriority, int maxPriority) {
    +    public PhoenixRpcScheduler(int indexHandlerCount, int metadataHandlerCount, Configuration conf,
    --- End diff --
    
    > DelegatingPayloadCarryingRpcController. 
    
    Huh? That's an odd one to pick.
    
    It seemed to me that you wanted to do something that looked like an RpcScheduler (maybe drop all the priority queue, replication queue methods) and change dispatch to look like ```boolean dispatch(CallRunner callTask)``` where boolean indicates handled or not.
    
    > needs to implement getGeneralQueueLength and getActiveRpcHandlerCount
    
    If you do the 'kinda like an RpcScheduler' route then you just loop through all of them and sum the counts. They don't need to be instantaneously accurate as its just being used for metrics, not for anything critical and need to 100% taken at the same point (really impossible if you have more than 1 queue).
    
    > would be easier to have a map from prioirity to queue and then in dispatch() we just lookup the queue based on the priority
    
    Not necessarily, as priority isn't the only thing that determines which queue an RPC should be sent to. For instance, QosPriority annotations can be used to determine which queue an RPC should be sent to as well:
    ```
      @QosPriority(priority=HConstants.HIGH_QOS)
      public GetRegionInfoResponse getRegionInfo(final RpcController controller,
          final GetRegionInfoRequest request) throws ServiceException {
    ```
    
    Now that you have implemented something like what I recommended, do you think its cleaner? easier to reason about? I was recommending based on what seemed like an anti-pattern in favor of a pretty reasonable abstraction from unix kernel hooks (and adopted by HBase for coprocessors)...however, I'm known to be a little heavy on generalizations, so this could be overkill to. What do you think? 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---