fix: nonr

This commit is contained in:
chuntaojun 2020-05-11 18:02:09 +08:00
parent fa5769381c
commit 4871eff336
4 changed files with 13 additions and 30 deletions

View File

@ -117,16 +117,19 @@
<artifactId>tomcat-embed-core</artifactId>
</dependency>
<!-- JRaft -->
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>jraft-core</artifactId>
<scope>compile</scope>
<scope>system</scope>
<systemPath>${project.basedir}/../libs/jraft-core-1.3.2.beta1.jar</systemPath>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>rpc-grpc-impl</artifactId>
<scope>compile</scope>
<scope>system</scope>
<systemPath>${project.basedir}/../libs/rpc-grpc-impl-1.3.2.beta1.jar</systemPath>
</dependency>
<dependency>

View File

@ -19,6 +19,7 @@ import com.alibaba.nacos.common.executor.ExecutorFactory;
import com.alibaba.nacos.common.executor.NameThreadFactory;
import com.alibaba.nacos.common.executor.ThreadPoolManager;
import com.alibaba.nacos.common.file.WatchFileCenter;
import com.alibaba.nacos.common.http.HttpClientManager;
import com.alibaba.nacos.common.utils.DiskUtils;
import com.alibaba.nacos.core.notify.NotifyCenter;
import com.alibaba.nacos.core.utils.ApplicationUtils;
@ -152,14 +153,17 @@ public class StartingSpringApplicationRunListener
LOGGER.error("Startup errors : {}", exception);
LOGGER.error("Nacos failed to start, please see {} for more details.",
Paths.get(ApplicationUtils.getNacosHome(), "logs/nacos.log"));
HttpClientManager.shutdown();
ThreadPoolManager.shutdown();
WatchFileCenter.shutdown();
NotifyCenter.shutdown();
closeExecutor();
LOGGER.error("Nacos failed to start, please see {} for more details.",
Paths.get(ApplicationUtils.getNacosHome(), "logs/nacos.log"));
context.close();
}
/**

View File

@ -49,6 +49,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
*
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
@SuppressWarnings("all")
public class EnlargeShrinksCapacity {
/**

View File

@ -67,9 +67,6 @@ import com.alipay.sofa.jraft.rpc.RpcServer;
import com.alipay.sofa.jraft.rpc.impl.cli.CliClientServiceImpl;
import com.alipay.sofa.jraft.util.BytesUtil;
import com.alipay.sofa.jraft.util.Endpoint;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.ScheduledReporter;
import com.codahale.metrics.Slf4jReporter;
import org.springframework.util.CollectionUtils;
import java.nio.ByteBuffer;
@ -465,9 +462,6 @@ public class JRaftServer {
tuple.node.shutdown();
tuple.raftGroupService.shutdown();
if (tuple.regionMetricsReporter != null) {
tuple.regionMetricsReporter.close();
}
}
cliService.shutdown();
@ -608,7 +602,6 @@ public class JRaftServer {
private final Node node;
private final RaftGroupService raftGroupService;
private final NacosStateMachine machine;
private ScheduledReporter regionMetricsReporter;
public RaftGroupTuple(Node node, LogProcessor processor,
RaftGroupService raftGroupService, NacosStateMachine machine) {
@ -616,24 +609,6 @@ public class JRaftServer {
this.processor = processor;
this.raftGroupService = raftGroupService;
this.machine = machine;
final MetricRegistry metricRegistry = this.node.getNodeMetrics()
.getMetricRegistry();
if (metricRegistry != null) {
// auto start raft node metrics reporter
regionMetricsReporter = Slf4jReporter.forRegistry(metricRegistry)
.prefixedWith("nacos_raft_[" + node.getGroupId() + "]")
.withLoggingLevel(Slf4jReporter.LoggingLevel.INFO)
.outputTo(Loggers.RAFT)
.scheduleOn(RaftExecutor.getRaftCommonExecutor())
.shutdownExecutorOnStop(
RaftExecutor.getRaftCommonExecutor().isShutdown())
.build();
regionMetricsReporter.start(30, TimeUnit.SECONDS);
}
}
public Node getNode() {