Skip to content

Commit

Permalink
releaseb 6g limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammers21 committed Jan 13, 2025
1 parent 72ec34e commit 8a02b86
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ EXPOSE 9000 9400
CMD java \
-jar \
--add-opens java.base/java.lang=ALL-UNNAMED \
-Xmx7g \
-Xmx6g \
-Xms1g \
-XX:+UseG1GC \
wow-pla.jar
24 changes: 15 additions & 9 deletions src/io/github/sammers/pla/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.github.sammers.pla.logic.CharacterCache;
import io.github.sammers.pla.logic.Ladder;
import io.github.sammers.pla.logic.Refs;
import io.prometheus.metrics.core.metrics.Counter;
import io.prometheus.metrics.core.metrics.Gauge;
import io.prometheus.metrics.exporter.httpserver.HTTPServer;
import io.prometheus.metrics.instrumentation.jvm.JvmMetrics;
Expand Down Expand Up @@ -56,19 +57,19 @@ public static void main(String[] args) throws IOException {
.buildAndStart();
log.info("Starting Metrics server on port 9400");
final Vertx vertx = Vertx.vertx(new VertxOptions()
.setBlockedThreadCheckInterval(10)
.setBlockedThreadCheckIntervalUnit(TimeUnit.SECONDS)
.setWarningExceptionTime(10)
.setWarningExceptionTimeUnit(TimeUnit.SECONDS)
.setMaxEventLoopExecuteTime(10)
.setMaxEventLoopExecuteTimeUnit(TimeUnit.SECONDS)
.setEventLoopPoolSize(32)
.setBlockedThreadCheckInterval(10)
.setBlockedThreadCheckIntervalUnit(TimeUnit.SECONDS)
.setWarningExceptionTime(10)
.setWarningExceptionTimeUnit(TimeUnit.SECONDS)
.setMaxEventLoopExecuteTime(10)
.setMaxEventLoopExecuteTimeUnit(TimeUnit.SECONDS)
.setEventLoopPoolSize(32)
);
RxJavaPlugins.setComputationSchedulerHandler(s -> RxHelper.scheduler(vertx));
RxJavaPlugins.setIoSchedulerHandler(s -> RxHelper.blockingScheduler(vertx));
RxJavaPlugins.setNewThreadSchedulerHandler(s -> RxHelper.scheduler(vertx));
final WebClient webClient = WebClient.create(vertx,
new WebClientOptions().setMaxPoolSize(100)
new WebClientOptions().setMaxPoolSize(100)
);
final String dbUri = System.getenv("DB_URI");
final String clientId = System.getenv("CLIENT_ID");
Expand All @@ -87,7 +88,12 @@ public static void main(String[] args) throws IOException {
.help("How many permits are left in the rate limiter")
.labelNames("name")
.register();
final BlizzardAPI blizzardAPI = new BlizzardAPI(permitsMetric, clientId, clientSecret, webClient, refs, characterCache, cutoffsMap);
Counter rqCounter = Counter.builder()
.name("BlizzardAPIRequests")
.labelNames("type")
.help("Blizzard API requests counter")
.build();
final BlizzardAPI blizzardAPI = new BlizzardAPI(permitsMetric, rqCounter, clientId, clientSecret, webClient, refs, characterCache, cutoffsMap);
DB db = new DB(mongoClient);
Ladder ladder = new Ladder(webClient, db, blizzardAPI, characterCache, refs, cutoffsMap);
ladder.start();
Expand Down
13 changes: 6 additions & 7 deletions src/io/github/sammers/pla/blizzard/BlizzardAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,19 @@ public class BlizzardAPI {
private final String clientId;
private final AtomicReference<BlizzardAuthToken> token = new AtomicReference<>();
private final RateLimiter rateLimiter;
public static final Counter rqCounter = Counter.builder()
.name("BlizzardAPIRequests")
.labelNames("type")
.help("Blizzard API requests counter")
.build();
private final Counter rqCounter;

public BlizzardAPI(Gauge permits, String clientId, String clientSecret, WebClient webClient, Refs refs, CharacterCache characterCache, Map<String, Cutoffs> cutoffs) {
public BlizzardAPI(Gauge permits, Counter rqCounter,
String clientId, String clientSecret, WebClient webClient, Refs refs,
CharacterCache characterCache, Map<String, Cutoffs> cutoffs) {
this.rqCounter = rqCounter;
this.clientId = clientId;
this.clientSecret = clientSecret;
this.webClient = webClient;
this.refs = refs;
this.characterCache = characterCache;
this.cutoffs = cutoffs;
rateLimiter = new RateLimiter("100 per sec", permits, 100, TimeUnit.SECONDS, 1000,
this.rateLimiter = new RateLimiter("100 per sec", permits, 100, TimeUnit.SECONDS, 1000,
Optional.of(new RateLimiter("36000 per hr", permits, 36000, TimeUnit.HOURS, 1000, Optional.empty(), Main.VTHREAD_SCHEDULER)),
Main.VTHREAD_SCHEDULER);
}
Expand Down

0 comments on commit 8a02b86

Please sign in to comment.