Skip to content

Commit

Permalink
spotless and UT adjustments
Browse files Browse the repository at this point in the history
Change-Id: I84e8627b9844e57ce1948660c19c3d4563e329be
  • Loading branch information
Wellington Chevreuil committed Jan 5, 2023
1 parent dd11028 commit 405e3c1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,9 @@ private void checkIsDead(final ServerName serverName, final String what)
* Assumes onlineServers is locked.
* @return ServerName with matching hostname and port.
*/
public ServerName findServerWithSameHostnamePortWithLock(
final ServerName serverName) {
ServerName end = ServerName.valueOf(serverName.getHostname(), serverName.getPort(),
Long.MAX_VALUE);
public ServerName findServerWithSameHostnamePortWithLock(final ServerName serverName) {
ServerName end =
ServerName.valueOf(serverName.getHostname(), serverName.getPort(), Long.MAX_VALUE);

ServerName r = onlineServers.lowerKey(end);
if (r != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ public class TransitRegionStateProcedure

public static final boolean DEFAULT_FORCE_REGION_RETAINMENT = false;

public static final String FORCE_REGION_RETAINMENT_WAIT = "hbase.master.scp.retain.assignment.force.wait";
public static final String FORCE_REGION_RETAINMENT_WAIT =
"hbase.master.scp.retain.assignment.force.wait";

public static final long DEFAULT_FORCE_REGION_RETAINMENT_WAIT = 500;

public static final String FORCE_REGION_RETAINMENT_RETRIES = "hbase.master.scp.retain.assignment.force.retries";
public static final String FORCE_REGION_RETAINMENT_RETRIES =
"hbase.master.scp.retain.assignment.force.retries";

public static final long DEFAULT_FORCE_REGION_RETAINMENT_RETRIES = 600;

Expand Down Expand Up @@ -185,14 +187,14 @@ protected TransitRegionStateProcedure(MasterProcedureEnv env, RegionInfo hri,
evictCache =
env.getMasterConfiguration().getBoolean(EVICT_BLOCKS_ON_CLOSE_KEY, DEFAULT_EVICT_ON_CLOSE);

forceRegionRetainment = env.getMasterConfiguration().
getBoolean(FORCE_REGION_RETAINMENT, DEFAULT_FORCE_REGION_RETAINMENT);
forceRegionRetainment = env.getMasterConfiguration().getBoolean(FORCE_REGION_RETAINMENT,
DEFAULT_FORCE_REGION_RETAINMENT);

forceRegionRetainmentWait = env.getMasterConfiguration().
getLong(FORCE_REGION_RETAINMENT_WAIT, DEFAULT_FORCE_REGION_RETAINMENT_WAIT);
forceRegionRetainmentWait = env.getMasterConfiguration().getLong(FORCE_REGION_RETAINMENT_WAIT,
DEFAULT_FORCE_REGION_RETAINMENT_WAIT);

forceRegionRetainmentRetries = env.getMasterConfiguration().
getLong(FORCE_REGION_RETAINMENT_RETRIES, DEFAULT_FORCE_REGION_RETAINMENT_RETRIES);
forceRegionRetainmentRetries = env.getMasterConfiguration()
.getLong(FORCE_REGION_RETAINMENT_RETRIES, DEFAULT_FORCE_REGION_RETAINMENT_RETRIES);

serverManager = env.getMasterServices().getServerManager();
}
Expand Down Expand Up @@ -221,10 +223,10 @@ protected boolean waitInitialized(MasterProcedureEnv env) {
}

private void checkAndWaitForOriginalServer(ServerName lastHost)
throws ProcedureSuspendedException {
throws ProcedureSuspendedException {
boolean isOnline = serverManager.findServerWithSameHostnamePortWithLock(lastHost) != null;
long retries = 0;
while(!isOnline && retries < forceRegionRetainmentRetries) {
while (!isOnline && retries < forceRegionRetainmentRetries) {
try {
synchronized (this) {
wait(forceRegionRetainmentWait);
Expand All @@ -235,9 +237,10 @@ private void checkAndWaitForOriginalServer(ServerName lastHost)
retries++;
isOnline = serverManager.findServerWithSameHostnamePortWithLock(lastHost) != null;
}
LOG.info("{} is true. We waited {} ms for host {} to come back online. "
+ "Did host come back online? {}", FORCE_REGION_RETAINMENT,
(retries * forceRegionRetainmentRetries), lastHost, isOnline);
LOG.info(
"{} is true. We waited {} ms for host {} to come back online. "
+ "Did host come back online? {}",
FORCE_REGION_RETAINMENT, (retries * forceRegionRetainmentRetries), lastHost, isOnline);
}

private void queueAssign(MasterProcedureEnv env, RegionStateNode regionNode)
Expand All @@ -252,8 +255,8 @@ private void queueAssign(MasterProcedureEnv env, RegionStateNode regionNode)
regionNode.setRegionLocation(assignCandidate);
} else if (regionNode.getLastHost() != null) {
retain = true;
LOG.info("Setting lastHost {} as the location for region {}",
regionNode.getLastHost(), regionNode.getRegionInfo().getEncodedName());
LOG.info("Setting lastHost {} as the location for region {}", regionNode.getLastHost(),
regionNode.getRegionInfo().getEncodedName());
regionNode.setRegionLocation(regionNode.getLastHost());
}
if (regionNode.getRegionLocation() != null && forceRegionRetainment) {
Expand Down Expand Up @@ -431,7 +434,7 @@ protected Flow executeFromState(MasterProcedureEnv env, RegionStateTransitionSta
return Flow.NO_MORE_STATE;
}
}
queueAssign(env, regionNode);
queueAssign(env, regionNode);
return Flow.HAS_MORE_STATE;
case REGION_STATE_TRANSITION_OPEN:
openRegion(env, regionNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@
*/
package org.apache.hadoop.hbase.master;

import static org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure.DEFAULT_FORCE_REGION_RETAINMENT_WAIT;
import static org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure.FORCE_REGION_RETAINMENT;
import static org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure.FORCE_REGION_RETAINMENT_WAIT;
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.io.IOException;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
Expand Down Expand Up @@ -272,11 +269,6 @@ public void testForceRetainAssignment() throws Exception {

LOG.info("\n\nSleeping a bit");
Thread.sleep(1000);
//make sure none of the regions previously on this dead server got reassigned
List<RegionInfo> rits = new ArrayList<>();
cluster.getMaster().getAssignmentManager().getRegionsInTransition().stream().
forEach( r -> rits.add(r.getRegionInfo()));
deadRSRegions.forEach( r -> assertTrue(rits.contains(r)));

LOG.info("\n\nStarting region server {} second time with the same port", deadRS);
cluster.getConf().setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, 3);
Expand Down

0 comments on commit 405e3c1

Please sign in to comment.