From 3558ee0c3b4b24dd1100c2bd542044d5fb0e60d4 Mon Sep 17 00:00:00 2001 From: xincunSong <365724453@qq.com> Date: Tue, 16 Jun 2020 17:34:07 +0800 Subject: [PATCH] =?UTF-8?q?HBASE-24478=20The=20regionInfo=20parameter=20fo?= =?UTF-8?q?r=20MasterProcedureScheduler#wai=E2=80=A6=20(#1819)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guangxu Cheng Signed-off-by: clarax --- .../procedure/MasterProcedureScheduler.java | 40 +++++++++---------- .../TestMasterProcedureScheduler.java | 16 ++++---- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/MasterProcedureScheduler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/MasterProcedureScheduler.java index 8dc2273a8618..c470c428125a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/MasterProcedureScheduler.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/MasterProcedureScheduler.java @@ -700,12 +700,12 @@ public boolean waitRegion(final Procedure procedure, final RegionInfo regionI * Suspend the procedure if the specified set of regions are already locked. * @param procedure the procedure trying to acquire the lock on the regions * @param table the table name of the regions we are trying to lock - * @param regionInfo the list of regions we are trying to lock + * @param regionInfos the list of regions we are trying to lock * @return true if the procedure has to wait for the regions to be available */ public boolean waitRegions(final Procedure procedure, final TableName table, - final RegionInfo... regionInfo) { - Arrays.sort(regionInfo, RegionInfo.COMPARATOR); + final RegionInfo... regionInfos) { + Arrays.sort(regionInfos, RegionInfo.COMPARATOR); schedLock(); try { assert table != null; @@ -715,14 +715,14 @@ public boolean waitRegions(final Procedure procedure, final TableName table, // acquire region xlocks or wait boolean hasLock = true; - final LockAndQueue[] regionLocks = new LockAndQueue[regionInfo.length]; - for (int i = 0; i < regionInfo.length; ++i) { - assert regionInfo[i] != null; - assert regionInfo[i].getTable() != null; - assert regionInfo[i].getTable().equals(table): regionInfo[i] + " " + procedure; - assert i == 0 || regionInfo[i] != regionInfo[i - 1] : "duplicate region: " + regionInfo[i]; - - regionLocks[i] = locking.getRegionLock(regionInfo[i].getEncodedName()); + final LockAndQueue[] regionLocks = new LockAndQueue[regionInfos.length]; + for (int i = 0; i < regionInfos.length; ++i) { + assert regionInfos[i] != null; + assert regionInfos[i].getTable() != null; + assert regionInfos[i].getTable().equals(table): regionInfos[i] + " " + procedure; + assert i == 0 || regionInfos[i] != regionInfos[i - 1] : "duplicate region: " + regionInfos[i]; + + regionLocks[i] = locking.getRegionLock(regionInfos[i].getEncodedName()); if (!regionLocks[i].tryExclusiveLock(procedure)) { LOG.info("Waiting on xlock for {} held by pid={}", procedure, regionLocks[i].getExclusiveLockProcIdOwner()); @@ -758,26 +758,26 @@ public void wakeRegion(final Procedure procedure, final RegionInfo regionInfo /** * Wake the procedures waiting for the specified regions * @param procedure the procedure that was holding the regions - * @param regionInfo the list of regions the procedure was holding + * @param regionInfos the list of regions the procedure was holding */ public void wakeRegions(final Procedure procedure,final TableName table, - final RegionInfo... regionInfo) { - Arrays.sort(regionInfo, RegionInfo.COMPARATOR); + final RegionInfo... regionInfos) { + Arrays.sort(regionInfos, RegionInfo.COMPARATOR); schedLock(); try { int numProcs = 0; - final Procedure[] nextProcs = new Procedure[regionInfo.length]; - for (int i = 0; i < regionInfo.length; ++i) { - assert regionInfo[i].getTable().equals(table); - assert i == 0 || regionInfo[i] != regionInfo[i - 1] : "duplicate region: " + regionInfo[i]; + final Procedure[] nextProcs = new Procedure[regionInfos.length]; + for (int i = 0; i < regionInfos.length; ++i) { + assert regionInfos[i].getTable().equals(table); + assert i == 0 || regionInfos[i] != regionInfos[i - 1] : "duplicate region: " + regionInfos[i]; - LockAndQueue regionLock = locking.getRegionLock(regionInfo[i].getEncodedName()); + LockAndQueue regionLock = locking.getRegionLock(regionInfos[i].getEncodedName()); if (regionLock.releaseExclusiveLock(procedure)) { if (!regionLock.isWaitingQueueEmpty()) { // release one procedure at the time since regions has an xlock nextProcs[numProcs++] = regionLock.removeFirst(); } else { - locking.removeRegionLock(regionInfo[i].getEncodedName()); + locking.removeRegionLock(regionInfos[i].getEncodedName()); } } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterProcedureScheduler.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterProcedureScheduler.java index 484ebaae45be..03c6dfb5cd27 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterProcedureScheduler.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestMasterProcedureScheduler.java @@ -850,30 +850,30 @@ public ProcedureEvent getEvent() { } public static class TestRegionProcedure extends TestTableProcedure { - private final RegionInfo[] regionInfo; + private final RegionInfo[] regionInfos; public TestRegionProcedure() { throw new UnsupportedOperationException("recovery should not be triggered here"); } public TestRegionProcedure(long procId, TableName tableName, TableOperationType opType, - RegionInfo... regionInfo) { - this(-1, procId, tableName, opType, regionInfo); + RegionInfo... regionInfos) { + this(-1, procId, tableName, opType, regionInfos); } public TestRegionProcedure(long parentProcId, long procId, TableName tableName, - TableOperationType opType, RegionInfo... regionInfo) { - this(-1, parentProcId, procId, tableName, opType, regionInfo); + TableOperationType opType, RegionInfo... regionInfos) { + this(-1, parentProcId, procId, tableName, opType, regionInfos); } public TestRegionProcedure(long rootProcId, long parentProcId, long procId, TableName tableName, - TableOperationType opType, RegionInfo... regionInfo) { + TableOperationType opType, RegionInfo... regionInfos) { super(rootProcId, parentProcId, procId, tableName, opType); - this.regionInfo = regionInfo; + this.regionInfos = regionInfos; } public RegionInfo[] getRegionInfo() { - return regionInfo; + return regionInfos; } @Override