-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HBASE-27766 Support steal job queue mode for read RPC queues of RWQue…
…ueRpcExecutor
- Loading branch information
Showing
11 changed files
with
293 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/StealReadJobRWQueueRpcExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* 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.hadoop.hbase.ipc; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.BlockingQueue; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.hbase.Abortable; | ||
import org.apache.hadoop.hbase.HBaseInterfaceAudience; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
import org.apache.yetus.audience.InterfaceStability; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@InterfaceAudience.LimitedPrivate({ HBaseInterfaceAudience.COPROC, HBaseInterfaceAudience.PHOENIX }) | ||
@InterfaceStability.Evolving | ||
public class StealReadJobRWQueueRpcExecutor extends RWQueueRpcExecutor { | ||
private static final Logger LOG = LoggerFactory.getLogger(StealReadJobRWQueueRpcExecutor.class); | ||
|
||
public StealReadJobRWQueueRpcExecutor(String name, int handlerCount, int maxQueueLength, | ||
PriorityFunction priority, Configuration conf, Abortable abortable) { | ||
super(name, handlerCount, maxQueueLength, priority, conf, abortable); | ||
} | ||
|
||
@Override | ||
public void initQueues() { | ||
queues = new ArrayList<>(this.numWriteQueues + this.numReadQueues + numScanQueues); | ||
initializeQueues(numWriteQueues); | ||
if (numReadQueues > 0 && numScanQueues > 0) { | ||
int stealQueueCount = Math.min(numReadQueues, numScanQueues); | ||
List<BlockingQueue<CallRunner>> stealScanQueues = new ArrayList<>(stealQueueCount); | ||
for (int i = 0; i < stealQueueCount; i++) { | ||
StealRpcJobQueue scanQueue = new StealRpcJobQueue(maxQueueLength, maxQueueLength); | ||
BlockingQueue<CallRunner> readQueue = scanQueue.getStealFromQueue(); | ||
queues.add(readQueue); | ||
stealScanQueues.add(scanQueue); | ||
} | ||
if (numReadQueues > numScanQueues) { | ||
initializeQueues(numReadQueues - numScanQueues); | ||
} | ||
queues.addAll(stealScanQueues); | ||
if (numScanQueues > numReadQueues) { | ||
initializeQueues(numScanQueues - numReadQueues); | ||
} | ||
} else { | ||
initializeQueues(Math.max(numReadQueues, numScanQueues)); | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/StealRpcJobQueue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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.hadoop.hbase.ipc; | ||
|
||
import java.util.Comparator; | ||
import org.apache.hadoop.hbase.util.StealJobQueue; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
|
||
@InterfaceAudience.Private | ||
public class StealRpcJobQueue extends StealJobQueue<CallRunner> { | ||
|
||
public final static RpcComparator RPCCOMPARATOR = new RpcComparator(); | ||
|
||
public StealRpcJobQueue(int initCapacity, int stealFromQueueInitCapacity) { | ||
super(initCapacity, stealFromQueueInitCapacity, RPCCOMPARATOR); | ||
} | ||
|
||
public static class RpcComparator implements Comparator<CallRunner> { | ||
public RpcComparator() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public int compare(CallRunner o1, CallRunner o2) { | ||
long diff = o1.getRpcCall().getReceiveTime() - o2.getRpcCall().getReceiveTime(); | ||
if (diff > 0) { | ||
return 1; | ||
} else if (diff < 0) { | ||
return -1; | ||
} else { | ||
return 0; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultiParallel2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* 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.hadoop.hbase.client; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.apache.hadoop.hbase.HConstants; | ||
import org.apache.hadoop.hbase.codec.KeyValueCodec; | ||
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; | ||
import org.apache.hadoop.hbase.ipc.RWQueueRpcExecutor; | ||
import org.apache.hadoop.hbase.ipc.RpcExecutor; | ||
import org.apache.hadoop.hbase.util.Bytes; | ||
import org.junit.Test; | ||
|
||
public class TestMultiParallel2 extends TestMultiParallel { | ||
|
||
public static void beforeClass() throws Exception { | ||
// Uncomment the following lines if more verbosity is needed for | ||
// debugging (see HBASE-12285 for details). | ||
// ((Log4JLogger)RpcServer.LOG).getLogger().setLevel(Level.ALL); | ||
// ((Log4JLogger)RpcClient.LOG).getLogger().setLevel(Level.ALL); | ||
// ((Log4JLogger)ScannerCallable.LOG).getLogger().setLevel(Level.ALL); | ||
UTIL.getConfiguration().set(HConstants.RPC_CODEC_CONF_KEY, | ||
KeyValueCodec.class.getCanonicalName()); | ||
// Disable table on master for now as the feature is broken | ||
// UTIL.getConfiguration().setBoolean(LoadBalancer.TABLES_ON_MASTER, true); | ||
// We used to ask for system tables on Master exclusively but not needed by test and doesn't | ||
// work anyways -- so commented out. | ||
// UTIL.getConfiguration().setBoolean(LoadBalancer.SYSTEM_TABLES_ON_MASTER, true); | ||
UTIL.getConfiguration().set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, | ||
MyMasterObserver.class.getName()); | ||
String queueType = RpcExecutor.CALL_QUEUE_TYPE_READ_STEAL_CONF_VALUE; | ||
UTIL.getConfiguration().set(RpcExecutor.CALL_QUEUE_TYPE_CONF_KEY, queueType); | ||
UTIL.getConfiguration().setFloat(RWQueueRpcExecutor.CALL_QUEUE_READ_SHARE_CONF_KEY, 0.5f); | ||
UTIL.getConfiguration().setFloat(RWQueueRpcExecutor.CALL_QUEUE_SCAN_SHARE_CONF_KEY, 1); | ||
UTIL.startMiniCluster(slaves); | ||
Table t = UTIL.createMultiRegionTable(TEST_TABLE, Bytes.toBytes(FAMILY)); | ||
UTIL.waitTableEnabled(TEST_TABLE); | ||
t.close(); | ||
CONNECTION = ConnectionFactory.createConnection(UTIL.getConfiguration()); | ||
assertTrue(MyMasterObserver.start.get()); | ||
} | ||
|
||
@Test | ||
public void test() throws Exception { | ||
testBatchWithGet(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.