Skip to content

Commit

Permalink
Removed some unnecessary functions in DynamicEventThrottler
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinmay Soman committed Jan 27, 2012
1 parent 4e41b6a commit fde488a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
Expand Up @@ -111,9 +111,10 @@ public HdfsFetcher(DynamicThrottleLimit dynThrottleLimit,
Long reportingIntervalBytes,
int bufferSize,
long minBytesPerSecond) {
if(dynThrottleLimit != null) {
if(dynThrottleLimit != null && dynThrottleLimit.getRate() != 0) {
this.maxBytesPerSecond = dynThrottleLimit.getRate();
this.throttler = new DynamicEventThrottler(dynThrottleLimit);
this.globalThrottleLimit = dynThrottleLimit;
logger.info("Initializing Dynamic Event throttler with rate : "
+ this.maxBytesPerSecond + " bytes / sec");
} else
Expand All @@ -122,7 +123,6 @@ public HdfsFetcher(DynamicThrottleLimit dynThrottleLimit,
this.bufferSize = bufferSize;
this.status = null;
this.minBytesPerSecond = minBytesPerSecond;
this.globalThrottleLimit = dynThrottleLimit;
}

public File fetch(String sourceFileUrl, String destinationFile) throws IOException {
Expand Down
10 changes: 1 addition & 9 deletions src/java/voldemort/utils/DynamicEventThrottler.java
Expand Up @@ -20,18 +20,10 @@ public DynamicEventThrottler(Time time, long ratePerSecond, long intervalMs) {
super(time, ratePerSecond, intervalMs);
}

public void updateRate(long l) {
public synchronized void updateRate(long l) {
this.dynamicRatePerSecond = l;
}

public void incrementNumJobs() {
this.dynThrottleLimit.incrementNumJobs();
}

public void decrementNumJobs() {
this.dynThrottleLimit.decrementNumJobs();
}

@Override
public long getRate() {
if(this.dynThrottleLimit != null)
Expand Down
6 changes: 1 addition & 5 deletions src/java/voldemort/utils/DynamicThrottleLimit.java
Expand Up @@ -14,11 +14,7 @@ public DynamicThrottleLimit(long val) {
}

public long getRate() {
long retVal;
synchronized(this) {
retVal = this.dynamicRatePerSecond;
}
return retVal;
return this.dynamicRatePerSecond;
}

public void incrementNumJobs() {
Expand Down

0 comments on commit fde488a

Please sign in to comment.