HBASE-5290 [FindBugs] Synchronization on boxed primitive (Ben West)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1238693 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
093c7203e8
commit
650b321396
|
@ -36,9 +36,18 @@ public class CompactSelection {
|
|||
// the actual list - this is needed to handle methods like "sublist"
|
||||
// correctly
|
||||
List<StoreFile> filesToCompact = new ArrayList<StoreFile>();
|
||||
// number of off peak compactions either in the compaction queue or
|
||||
// happening now
|
||||
public static Integer numOutstandingOffPeakCompactions = 0;
|
||||
|
||||
/**
|
||||
* Number of off peak compactions either in the compaction queue or
|
||||
* happening now. Please lock compactionCountLock before modifying.
|
||||
*/
|
||||
static long numOutstandingOffPeakCompactions = 0;
|
||||
|
||||
/**
|
||||
* Lock object for numOutstandingOffPeakCompactions
|
||||
*/
|
||||
private final static Object compactionCountLock = new Object();
|
||||
|
||||
// HBase conf object
|
||||
Configuration conf;
|
||||
// was this compaction promoted to an off-peak
|
||||
|
@ -83,7 +92,7 @@ public class CompactSelection {
|
|||
*/
|
||||
public double getCompactSelectionRatio() {
|
||||
double r = this.compactRatio;
|
||||
synchronized(numOutstandingOffPeakCompactions) {
|
||||
synchronized(compactionCountLock) {
|
||||
if (isOffPeakHour() && numOutstandingOffPeakCompactions == 0) {
|
||||
r = this.compactRatioOffPeak;
|
||||
numOutstandingOffPeakCompactions++;
|
||||
|
@ -104,7 +113,7 @@ public class CompactSelection {
|
|||
*/
|
||||
public void finishRequest() {
|
||||
if (isOffPeakCompaction) {
|
||||
synchronized(numOutstandingOffPeakCompactions) {
|
||||
synchronized(compactionCountLock) {
|
||||
numOutstandingOffPeakCompactions--;
|
||||
isOffPeakCompaction = false;
|
||||
}
|
||||
|
@ -124,7 +133,7 @@ public class CompactSelection {
|
|||
public void emptyFileList() {
|
||||
filesToCompact.clear();
|
||||
if (isOffPeakCompaction) {
|
||||
synchronized(numOutstandingOffPeakCompactions) {
|
||||
synchronized(compactionCountLock) {
|
||||
// reset the off peak count
|
||||
numOutstandingOffPeakCompactions--;
|
||||
isOffPeakCompaction = false;
|
||||
|
|
Loading…
Reference in New Issue