@InterfaceAudience.Private public class RegionLocations extends Object
HRegionLocation
's that correspond to the
same range. The list is indexed by the replicaId. This is an immutable list,
however mutation operations are provided which returns a new List via copy-on-write
(assuming small number of locations)Modifier and Type | Field and Description |
---|---|
private HRegionLocation[] |
locations |
private int |
numNonNullElements |
Constructor and Description |
---|
RegionLocations(Collection<HRegionLocation> locations) |
RegionLocations(HRegionLocation... locations)
Constructs the region location list.
|
Modifier and Type | Method and Description |
---|---|
HRegionLocation |
getDefaultRegionLocation() |
HRegionLocation |
getRegionLocation()
Returns the first not-null region location in the list
|
HRegionLocation |
getRegionLocation(int replicaId) |
HRegionLocation |
getRegionLocationByRegionName(byte[] regionName)
Returns the region location from the list for matching regionName, which can
be regionName or encodedRegionName
|
HRegionLocation[] |
getRegionLocations() |
boolean |
isEmpty()
Returns whether there are non-null elements in the list
|
private boolean |
isGreaterThan(long a,
long b,
boolean checkForEquals) |
RegionLocations |
mergeLocations(RegionLocations other)
Merges this RegionLocations list with the given list assuming
same range, and keeping the most up to date version of the
HRegionLocation entries from either list according to seqNum.
|
int |
numNonNullElements()
Returns the size of not-null locations
|
RegionLocations |
remove(HRegionLocation location)
Removes the given location from the list
|
RegionLocations |
remove(int replicaId)
Removes location of the given replicaId from the list
|
RegionLocations |
removeByServer(ServerName serverName)
Returns a new RegionLocations with the locations removed (set to null)
which have the destination server as given.
|
private HRegionLocation |
selectRegionLocation(HRegionLocation oldLocation,
HRegionLocation location,
boolean checkForEquals,
boolean force) |
int |
size()
Returns the size of the list even if some of the elements
might be null.
|
String |
toString() |
RegionLocations |
updateLocation(HRegionLocation location,
boolean checkForEquals,
boolean force)
Updates the location with new only if the new location has a higher
seqNum than the old one or force is true.
|
private final int numNonNullElements
private final HRegionLocation[] locations
public RegionLocations(HRegionLocation... locations)
locations
- an array of HRegionLocations for the same region rangepublic RegionLocations(Collection<HRegionLocation> locations)
public int size()
public int numNonNullElements()
public boolean isEmpty()
public RegionLocations removeByServer(ServerName serverName)
serverName
- the serverName to remove locations ofpublic RegionLocations remove(HRegionLocation location)
location
- the location to removepublic RegionLocations remove(int replicaId)
replicaId
- the replicaId of the location to removepublic RegionLocations mergeLocations(RegionLocations other)
other
- the locations to merge withprivate HRegionLocation selectRegionLocation(HRegionLocation oldLocation, HRegionLocation location, boolean checkForEquals, boolean force)
public RegionLocations updateLocation(HRegionLocation location, boolean checkForEquals, boolean force)
location
- the location to add or updatecheckForEquals
- whether to update the location if seqNums for the
HRegionLocations for the old and new location are the sameforce
- whether to force updateprivate boolean isGreaterThan(long a, long b, boolean checkForEquals)
public HRegionLocation getRegionLocation(int replicaId)
public HRegionLocation getRegionLocationByRegionName(byte[] regionName)
regionName
- regionName or encodedRegionNamepublic HRegionLocation[] getRegionLocations()
public HRegionLocation getDefaultRegionLocation()
public HRegionLocation getRegionLocation()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.