Skip to content

Commit

Permalink
Merge pull request #1349 from hbs/ratelimiter
Browse files Browse the repository at this point in the history
Replaced call to acquire by a call to tryAcquire which has not change…
  • Loading branch information
hbs committed Feb 28, 2024
2 parents 999b7d9 + 179c253 commit 3b31bba
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions warp10/src/main/java/io/warp10/hadoop/Warp10RecordWriter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2018-2023 SenX S.A.S.
// Copyright 2018-2024 SenX S.A.S.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,7 @@
import java.net.URL;
import java.util.HashMap;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPOutputStream;

import org.apache.hadoop.io.BytesWritable;
Expand Down Expand Up @@ -136,7 +137,9 @@ public void write(Writable key, Writable value) throws IOException, InterruptedE

while (decoder.next()) {
if (null != this.limiter) {
this.limiter.acquire(1);
if (!this.limiter.tryAcquire(1, Long.MAX_VALUE, TimeUnit.MICROSECONDS)) {
throw new IOException("The configured write rate will not allow the data to be written to Warp 10, consider increasing the provided value.");
}
}

if (!first) {
Expand Down

0 comments on commit 3b31bba

Please sign in to comment.