Merge branch 'dev' into 'master'

2.0.6

See merge request ajg0702/ajqueue!26
This commit is contained in:
ajgeiss0702
2021-08-29 18:19:15 +00:00
6 changed files with 24 additions and 11 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ repositories {
}
allprojects {
version = "2.0.5"
version = "2.0.6"
group = "us.ajg0702"
plugins.apply("java")
@@ -19,6 +19,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class QueueManagerImpl implements QueueManager {
@@ -474,9 +476,14 @@ public class QueueManagerImpl implements QueueManager {
@Override
public void updateServers() {
ExecutorService pool = main.getTaskManager().getServersUpdateExecutor();
if (pool instanceof ThreadPoolExecutor && main.getConfig().getBoolean("pinger-debug")) {
main.getLogger().info("[pinger] Server update thread pool has "
+((ThreadPoolExecutor) pool).getActiveCount()+" threads");
}
try {
for(QueueServer server : servers) {
server.updatePing();
pool.submit(server::updatePing);
}
} catch(Exception e) {
e.printStackTrace();
@@ -2,10 +2,7 @@ package us.ajg0702.queue.common;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;
public class TaskManager {
@@ -13,6 +10,8 @@ public class TaskManager {
final ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
final ScheduledExecutorService updateExecutor = Executors.newScheduledThreadPool(1);
final ExecutorService serversUpdateExecutor = Executors.newCachedThreadPool();
final QueueMain main;
public TaskManager(QueueMain main) {
this.main = main;
@@ -21,6 +20,11 @@ public class TaskManager {
public void shutdown() {
executor.shutdown();
updateExecutor.shutdown();
serversUpdateExecutor.shutdown();
}
public ExecutorService getServersUpdateExecutor() {
return serversUpdateExecutor;
}
public String taskStatus() {
@@ -52,7 +56,7 @@ public class TaskManager {
updateTask = scheduleAtFixedRate(updateExecutor,
main.getQueueManager()::updateServers,
500L,
(long) (Math.max(main.getTimeBetweenPlayers(), 2)*1000L),
(long) (Math.max(main.getTimeBetweenPlayers()/2, 1)*1000L),
TimeUnit.MILLISECONDS
);
@@ -249,10 +249,10 @@ public class QueueServerImpl implements QueueServer {
if(p != null && isWhitelisted() && !whitelistedUUIDs.contains(p.getUniqueId())) {
return false;
}
return this.isOnline() &&
this.canAccess(p) &&
!this.isFull() &&
!this.isPaused();
return isOnline() &&
canAccess(p) &&
!isFull() &&
!isPaused();
}
@Override
@@ -18,6 +18,7 @@ public class BungeeSender implements ICommandSender {
@Override
public boolean hasPermission(String permission) {
if(permission == null) return true;
return handle.hasPermission(permission);
}
@@ -17,6 +17,7 @@ public class VelocitySender implements ICommandSender {
@Override
public boolean hasPermission(String permission) {
if(permission == null) return true;
return handle.hasPermission(permission);
}