HBASE-5088 addendum
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1228761 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d821f6fcfc
commit
dd604d3136
|
@ -522,9 +522,9 @@ public class HConnectionManager {
|
||||||
* Map of table to table {@link HRegionLocation}s. The table key is made
|
* Map of table to table {@link HRegionLocation}s. The table key is made
|
||||||
* by doing a {@link Bytes#mapKey(byte[])} of the table's name.
|
* by doing a {@link Bytes#mapKey(byte[])} of the table's name.
|
||||||
*/
|
*/
|
||||||
private final Map<Integer, SoftValueSortedMap<byte [], HRegionLocation>>
|
private final Map<Integer, SortedMap<byte [], HRegionLocation>>
|
||||||
cachedRegionLocations =
|
cachedRegionLocations =
|
||||||
new HashMap<Integer, SoftValueSortedMap<byte [], HRegionLocation>>();
|
new HashMap<Integer, SortedMap<byte [], HRegionLocation>>();
|
||||||
|
|
||||||
// The presence of a server in the map implies it's likely that there is an
|
// The presence of a server in the map implies it's likely that there is an
|
||||||
// entry in cachedRegionLocations that map to this server; but the absence
|
// entry in cachedRegionLocations that map to this server; but the absence
|
||||||
|
@ -1069,7 +1069,7 @@ public class HConnectionManager {
|
||||||
*/
|
*/
|
||||||
HRegionLocation getCachedLocation(final byte [] tableName,
|
HRegionLocation getCachedLocation(final byte [] tableName,
|
||||||
final byte [] row) {
|
final byte [] row) {
|
||||||
SoftValueSortedMap<byte [], HRegionLocation> tableLocations =
|
SortedMap<byte [], HRegionLocation> tableLocations =
|
||||||
getTableLocations(tableName);
|
getTableLocations(tableName);
|
||||||
|
|
||||||
// start to examine the cache. we can only do cache actions
|
// start to examine the cache. we can only do cache actions
|
||||||
|
@ -1180,11 +1180,11 @@ public class HConnectionManager {
|
||||||
* @param tableName
|
* @param tableName
|
||||||
* @return Map of cached locations for passed <code>tableName</code>
|
* @return Map of cached locations for passed <code>tableName</code>
|
||||||
*/
|
*/
|
||||||
private SoftValueSortedMap<byte [], HRegionLocation> getTableLocations(
|
private SortedMap<byte [], HRegionLocation> getTableLocations(
|
||||||
final byte [] tableName) {
|
final byte [] tableName) {
|
||||||
// find the map of cached locations for this table
|
// find the map of cached locations for this table
|
||||||
Integer key = Bytes.mapKey(tableName);
|
Integer key = Bytes.mapKey(tableName);
|
||||||
SoftValueSortedMap<byte [], HRegionLocation> result;
|
SortedMap<byte [], HRegionLocation> result;
|
||||||
synchronized (this.cachedRegionLocations) {
|
synchronized (this.cachedRegionLocations) {
|
||||||
result = this.cachedRegionLocations.get(key);
|
result = this.cachedRegionLocations.get(key);
|
||||||
// if tableLocations for this table isn't built yet, make one
|
// if tableLocations for this table isn't built yet, make one
|
||||||
|
|
|
@ -106,9 +106,9 @@ public class SoftValueSortedMap<K,V> implements SortedMap<K,V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public V get(Object key) {
|
public V get(Object key) {
|
||||||
synchronized (sync) {
|
synchronized(sync) {
|
||||||
checkReferences();
|
checkReferences();
|
||||||
SoftValue<K, V> value = this.internalMap.get(key);
|
SoftValue<K,V> value = this.internalMap.get(key);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -121,9 +121,9 @@ public class SoftValueSortedMap<K,V> implements SortedMap<K,V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public V remove(Object key) {
|
public V remove(Object key) {
|
||||||
synchronized (sync) {
|
synchronized(sync) {
|
||||||
checkReferences();
|
checkReferences();
|
||||||
SoftValue<K, V> value = this.internalMap.remove(key);
|
SoftValue<K,V> value = this.internalMap.remove(key);
|
||||||
return value == null ? null : value.get();
|
return value == null ? null : value.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,10 +225,10 @@ public class SoftValueSortedMap<K,V> implements SortedMap<K,V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<V> values() {
|
public Collection<V> values() {
|
||||||
synchronized (sync) {
|
synchronized(sync) {
|
||||||
checkReferences();
|
checkReferences();
|
||||||
ArrayList<V> hardValues = new ArrayList<V>();
|
ArrayList<V> hardValues = new ArrayList<V>();
|
||||||
for (SoftValue<K, V> softValue : this.internalMap.values()) {
|
for (SoftValue<K,V> softValue : this.internalMap.values()) {
|
||||||
hardValues.add(softValue.get());
|
hardValues.add(softValue.get());
|
||||||
}
|
}
|
||||||
return hardValues;
|
return hardValues;
|
||||||
|
|
Loading…
Reference in New Issue