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"
|
// the actual list - this is needed to handle methods like "sublist"
|
||||||
// correctly
|
// correctly
|
||||||
List<StoreFile> filesToCompact = new ArrayList<StoreFile>();
|
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
|
// HBase conf object
|
||||||
Configuration conf;
|
Configuration conf;
|
||||||
// was this compaction promoted to an off-peak
|
// was this compaction promoted to an off-peak
|
||||||
|
@ -83,7 +92,7 @@ public class CompactSelection {
|
||||||
*/
|
*/
|
||||||
public double getCompactSelectionRatio() {
|
public double getCompactSelectionRatio() {
|
||||||
double r = this.compactRatio;
|
double r = this.compactRatio;
|
||||||
synchronized(numOutstandingOffPeakCompactions) {
|
synchronized(compactionCountLock) {
|
||||||
if (isOffPeakHour() && numOutstandingOffPeakCompactions == 0) {
|
if (isOffPeakHour() && numOutstandingOffPeakCompactions == 0) {
|
||||||
r = this.compactRatioOffPeak;
|
r = this.compactRatioOffPeak;
|
||||||
numOutstandingOffPeakCompactions++;
|
numOutstandingOffPeakCompactions++;
|
||||||
|
@ -104,7 +113,7 @@ public class CompactSelection {
|
||||||
*/
|
*/
|
||||||
public void finishRequest() {
|
public void finishRequest() {
|
||||||
if (isOffPeakCompaction) {
|
if (isOffPeakCompaction) {
|
||||||
synchronized(numOutstandingOffPeakCompactions) {
|
synchronized(compactionCountLock) {
|
||||||
numOutstandingOffPeakCompactions--;
|
numOutstandingOffPeakCompactions--;
|
||||||
isOffPeakCompaction = false;
|
isOffPeakCompaction = false;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +133,7 @@ public class CompactSelection {
|
||||||
public void emptyFileList() {
|
public void emptyFileList() {
|
||||||
filesToCompact.clear();
|
filesToCompact.clear();
|
||||||
if (isOffPeakCompaction) {
|
if (isOffPeakCompaction) {
|
||||||
synchronized(numOutstandingOffPeakCompactions) {
|
synchronized(compactionCountLock) {
|
||||||
// reset the off peak count
|
// reset the off peak count
|
||||||
numOutstandingOffPeakCompactions--;
|
numOutstandingOffPeakCompactions--;
|
||||||
isOffPeakCompaction = false;
|
isOffPeakCompaction = false;
|
||||||
|
|
Loading…
Reference in New Issue