Browse Source

ебка с потоками и утечкой 3

master
gsd 2 years ago
parent
commit
d47a2dfe89
  1. 14
      src/main/java/app/entities/server/BaseServer.java

14
src/main/java/app/entities/server/BaseServer.java

@ -17,25 +17,35 @@ public abstract class BaseServer {
private ExecutorService executorServices_query; private ExecutorService executorServices_query;
@JsonIgnore @JsonIgnore
private ExecutorService executorServices_rcon; private ExecutorService executorServices_rcon;
@JsonIgnore
private SourceRconClient sourceRconClient;
@JsonIgnore
private SourceQueryClient sourceQueryClient;
@JsonIgnore @JsonIgnore
public SourceRconClient GetSourceRconClient() { public SourceRconClient GetSourceRconClient() {
if (executorServices_rcon == null) executorServices_rcon = Executors.newCachedThreadPool(); if (executorServices_rcon == null) executorServices_rcon = Executors.newCachedThreadPool();
if (sourceRconClient == null) {
SourceRconOptions options = SourceRconOptions.builder() SourceRconOptions options = SourceRconOptions.builder()
.option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH) .option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH)
.option(GeneralOptions.THREAD_EXECUTOR_SERVICE, executorServices_rcon) .option(GeneralOptions.THREAD_EXECUTOR_SERVICE, executorServices_rcon)
.build(); .build();
return new SourceRconClient(options); sourceRconClient = new SourceRconClient(options);
}
return sourceRconClient;
} }
@JsonIgnore @JsonIgnore
public SourceQueryClient GetSourceQueryClient() { public SourceQueryClient GetSourceQueryClient() {
if (executorServices_query == null) executorServices_query = Executors.newCachedThreadPool(); if (executorServices_query == null) executorServices_query = Executors.newCachedThreadPool();
if (sourceQueryClient == null) {
SourceQueryOptions options = SourceQueryOptions.builder() SourceQueryOptions options = SourceQueryOptions.builder()
.option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH) .option(FailsafeOptions.FAILSAFE_RATELIMIT_TYPE, RateLimitType.SMOOTH)
.option(GeneralOptions.THREAD_EXECUTOR_SERVICE, executorServices_query) .option(GeneralOptions.THREAD_EXECUTOR_SERVICE, executorServices_query)
.build(); .build();
return new SourceQueryClient(options); sourceQueryClient = new SourceQueryClient(options);
}
return sourceQueryClient;
} }
} }

Loading…
Cancel
Save