mirror of
https://github.com/actiontech/dble.git
synced 2026-01-05 04:10:32 -06:00
Merge branch 'master' into inner-2222
This commit is contained in:
@@ -538,6 +538,8 @@ public class ConnectionPool extends PoolBase implements PooledConnectionListener
|
||||
|
||||
// Try to maintain minimum connections
|
||||
fillPool();
|
||||
} catch (Throwable t) {
|
||||
LOGGER.warn("Evictor.run happen Throwable: ", t);
|
||||
} finally {
|
||||
// Restore the previous CCL
|
||||
Thread.currentThread().setContextClassLoader(savedClassLoader);
|
||||
@@ -551,6 +553,7 @@ public class ConnectionPool extends PoolBase implements PooledConnectionListener
|
||||
*/
|
||||
void setScheduledFuture(final ScheduledFuture<?> scheduledFuture) {
|
||||
this.scheduledFuture = scheduledFuture;
|
||||
EvictionTimer.getAliveEvictor().add(scheduledFuture);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -558,6 +561,7 @@ public class ConnectionPool extends PoolBase implements PooledConnectionListener
|
||||
*/
|
||||
void cancel() {
|
||||
scheduledFuture.cancel(false);
|
||||
EvictionTimer.getAliveEvictor().remove(scheduledFuture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,20 +5,21 @@
|
||||
|
||||
package com.actiontech.dble.backend.pool;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
final class EvictionTimer {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(EvictionTimer.class);
|
||||
|
||||
/**
|
||||
* Executor instance
|
||||
*/
|
||||
private static ScheduledThreadPoolExecutor executor; //@GuardedBy("EvictionTimer.class")
|
||||
|
||||
private static ConcurrentLinkedQueue aliveEvictor = new ConcurrentLinkedQueue();
|
||||
/**
|
||||
* Prevents instantiation
|
||||
*/
|
||||
@@ -26,6 +27,9 @@ final class EvictionTimer {
|
||||
// Hide the default constructor
|
||||
}
|
||||
|
||||
public static ConcurrentLinkedQueue getAliveEvictor() {
|
||||
return aliveEvictor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.4.3
|
||||
@@ -73,8 +77,9 @@ final class EvictionTimer {
|
||||
if (evictor != null) {
|
||||
evictor.cancel();
|
||||
}
|
||||
if (executor != null && executor.getQueue().isEmpty()) {
|
||||
if (executor != null && aliveEvictor.isEmpty()) {
|
||||
executor.shutdown();
|
||||
LOGGER.info("EvictionTimer executor shutdown");
|
||||
try {
|
||||
executor.awaitTermination(timeout, unit);
|
||||
} catch (final InterruptedException e) {
|
||||
|
||||
@@ -36,13 +36,13 @@ public final class ShowConnectionPoolProperty {
|
||||
FIELDS[i] = PacketUtil.getField("DB_GROUP", Fields.FIELD_TYPE_VAR_STRING);
|
||||
FIELDS[i++].setPacketId(++packetId);
|
||||
|
||||
FIELDS[i] = PacketUtil.getField("DB_INSTANCE", Fields.FIELD_TYPE_LONG);
|
||||
FIELDS[i] = PacketUtil.getField("DB_INSTANCE", Fields.FIELD_TYPE_VAR_STRING);
|
||||
FIELDS[i++].setPacketId(++packetId);
|
||||
|
||||
FIELDS[i] = PacketUtil.getField("PROPERTY", Fields.FIELD_TYPE_VAR_STRING);
|
||||
FIELDS[i++].setPacketId(++packetId);
|
||||
|
||||
FIELDS[i] = PacketUtil.getField("VALUE", Fields.FIELD_TYPE_LONG);
|
||||
FIELDS[i] = PacketUtil.getField("VALUE", Fields.FIELD_TYPE_VAR_STRING);
|
||||
FIELDS[i].setPacketId(++packetId);
|
||||
|
||||
EOF.setPacketId(++packetId);
|
||||
|
||||
Reference in New Issue
Block a user