perf[scheduler]: 优化代码结构,并删除无用代码

This commit is contained in:
jaysunxiao committed 2021-06-26 13:02:00 +08:00
1 parent 6883944e81
commit 57fe3ab0ae
13 files changed
+114 -133

No files matched your search

@@ -27,7 +27,7 @@ import com.zfoo.protocol.util.AssertionUtils;
import com.zfoo.protocol.util.IOUtils;
import com.zfoo.protocol.util.JsonUtils;
import com.zfoo.protocol.util.StringUtils;
import com.zfoo.scheduler.SchedulerContext;
import com.zfoo.scheduler.manager.SchedulerBus;
import com.zfoo.util.ThreadUtils;
import com.zfoo.util.net.HostAndPort;
import io.netty.util.concurrent.FastThreadLocalThread;
@@ -317,7 +317,7 @@ public class ZookeeperRegistry implements IRegistry {
initConsumerCache();
} catch (Exception e) {
logger.error("zookeeper初始化失败,等待[{}]秒,重新初始化", RETRY_SECONDS, e);
SchedulerContext.getSchedulerManager().schedule(new Runnable() {
SchedulerBus.schedule(new Runnable() {
@Override
public void run() {
initZookeeper();
@@ -441,7 +441,7 @@ public class ZookeeperRegistry implements IRegistry {
}
if (recheckFlag) {
SchedulerContext.getSchedulerManager().schedule(new Runnable() {
SchedulerBus.schedule(new Runnable() {
@Override
public void run() {
checkConsumer();
@@ -1,3 +1,16 @@
/*
* Copyright (C) 2020 The zfoo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
package com.zfoo.net.dispatcher.manager;
import com.zfoo.event.model.event.IEvent;
@@ -111,8 +124,8 @@ public abstract class PacketBus {
var receiverDefinition = new PacketReceiverDefinition(bean, method, packetClazz, attachmentClazz);
var enhanceReceiverDefinition = EnhanceUtils.createPacketReceiver(receiverDefinition);
packetReceiverList[protocolId] = enhanceReceiverDefinition;
} catch (Exception e) {
throw new RuntimeException(e);
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
}
@@ -19,7 +19,7 @@ import com.github.benmanes.caffeine.cache.LoadingCache;
import com.zfoo.event.manager.EventBus;
import com.zfoo.protocol.collection.CollectionUtils;
import com.zfoo.protocol.model.Pair;
import com.zfoo.scheduler.manager.SchedulerManager;
import com.zfoo.scheduler.manager.SchedulerBus;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -92,7 +92,7 @@ public class SimpleCache<K, V> {
});
SchedulerManager.getInstance().scheduleAtFixedRate(new Runnable() {
SchedulerBus.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
// 不在任务调度线程中执行耗时任务,因为任务调度线程只有一个线程池