Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: log code optimization update #290

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,15 @@ public void init() {
fileMonitorListener = new DefaultFileMonitorListener();

log.info("query channelDefineList:{}", gson.toJson(channelDefineList));
channelServiceList = channelDefineList.stream().map(channelDefine -> {
ChannelService channelService = this.channelServiceTrans(channelDefine);
if (null == channelService) {
failedChannelId.add(channelDefine.getChannelId());
}
return channelService;
}).filter(Objects::nonNull).collect(Collectors.toList());
channelServiceList = channelDefineList.stream()
.filter(channelDefine -> filterCollStart(channelDefine.getAppName()))
.map(channelDefine -> {
ChannelService channelService = this.channelServiceTrans(channelDefine);
if (null == channelService) {
failedChannelId.add(channelDefine.getChannelId());
}
return channelService;
}).filter(Objects::nonNull).collect(Collectors.toList());
// Delete failed channel
deleteFailedChannel(failedChannelId, this.channelDefineList, this.channelServiceList);
channelServiceList = new CopyOnWriteArrayList<>(channelServiceList);
Expand Down Expand Up @@ -533,13 +535,16 @@ private List<ChannelDefine> intersection(List<ChannelDefine> origin, List<Channe
*/
public void initIncrement(List<ChannelDefine> definesIncrement) {
List<Long> failedChannelId = Lists.newArrayList();
List<ChannelService> channelServices = definesIncrement.stream().filter(Objects::nonNull).map(channelDefine -> {
ChannelService channelService = channelServiceTrans(channelDefine);
if (null == channelService) {
failedChannelId.add(channelDefine.getChannelId());
}
return channelService;
}).filter(Objects::nonNull).collect(Collectors.toList());
List<ChannelService> channelServices = definesIncrement.stream()
.filter(Objects::nonNull)
.filter(channelDefine -> filterCollStart(channelDefine.getAppName()))
.map(channelDefine -> {
ChannelService channelService = channelServiceTrans(channelDefine);
if (null == channelService) {
failedChannelId.add(channelDefine.getChannelId());
}
return channelService;
}).filter(Objects::nonNull).collect(Collectors.toList());
deleteFailedChannel(failedChannelId, definesIncrement, channelServices);
List<Long> successChannelIds = channelStart(channelServices);
if (CollectionUtils.isNotEmpty(successChannelIds)) {
Expand All @@ -549,6 +554,14 @@ public void initIncrement(List<ChannelDefine> definesIncrement) {
log.info("[add config] after current channelDefineList:{},channelServiceList:{}", gson.toJson(this.channelDefineList), gson.toJson(gson.toJson(channelServiceList.stream().map(ChannelService::instanceId).collect(Collectors.toList()))));
}

private boolean filterCollStart(String appName) {
String serviceName = System.getenv("K8S_SERVICE");
if (StringUtils.isNotEmpty(serviceName) && StringUtils.isNotEmpty(appName)) {
return serviceName.contains(appName);
}
return true;
}


/**
* Send collection progress.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class ManagerUtil {

private static final String TAIL_KEY = "tail";

private static final String DEFAULT_SERVER_TYPE = "open";

private ManagerUtil() {

}
Expand Down Expand Up @@ -91,6 +93,10 @@ public static void getConfigFromNanos() {
* @return
*/
public static String getPhysicsDirectory(String logPath) {
String serverType = Config.ins().get("server.type", DEFAULT_SERVER_TYPE);
if (StringUtils.equals(DEFAULT_SERVER_TYPE, serverType)) {
return StringUtils.EMPTY;
}
String[] splitPath = StringUtils.split(logPath, "/");
if (splitPath.length > 2) {
return splitPath[splitPath.length - 2].trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public class Tpc {
@Resource
private MilogSpaceDao milogSpaceDao;

@Reference(interfaceClass = NodeFacade.class, group = "$tpc_dubbo_group", check = false, version = "1.0", timeout = 10000)
@Reference(interfaceClass = NodeFacade.class, group = "$tpc_dubbo_group", check = false, version = "1.0", timeout = 15000)
private NodeFacade tpcService;

@Reference(interfaceClass = NodeUserFacade.class, group = "$tpc_dubbo_group", check = false, version = "1.0", timeout = 10000)
@Reference(interfaceClass = NodeUserFacade.class, group = "$tpc_dubbo_group", check = false, version = "1.0", timeout = 15000)
private NodeUserFacade tpcUserService;

@Reference(interfaceClass = UserOrgFacade.class, group = "$tpc_dubbo_group", check = false, version = "1.0", timeout = 10000)
@Reference(interfaceClass = UserOrgFacade.class, group = "$tpc_dubbo_group", check = false, version = "1.0", timeout = 15000)
private UserOrgFacade userOrgFacade;

@Value("${tpc_node_code}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public Result<List<MapDTO<String, Long>>> getMilogSpaces(Long tenantId) {
List<NodeVo> nodeVos = new ArrayList<>();

while (true) {
com.xiaomi.youpin.infra.rpc.Result<PageDataVo<NodeVo>> tpcRes = spaceAuthService.getUserPermSpace("", pageNum, Integer.MAX_VALUE);
com.xiaomi.youpin.infra.rpc.Result<PageDataVo<NodeVo>> tpcRes = spaceAuthService.getUserPermSpace("", pageNum, 100);

if (tpcRes.getCode() != 0) {
return Result.fail(CommonError.UNAUTHORIZED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -199,12 +200,12 @@ public Result<Integer> defavourite(Integer sort, Long id) {
}

public Result<List<SpaceTreeFavouriteDTO>> storeTree() {
List<SpaceTreeFavouriteDTO> dtoList = new ArrayList<>();
List<SpaceTreeFavouriteDTO> dtoList = new CopyOnWriteArrayList<>();
int pageNum = 1;
List<MilogSpaceDTO> spaceDTOList = new ArrayList<>();

while (true) {
com.xiaomi.youpin.infra.rpc.Result<PageDataVo<NodeVo>> userPermSpace = spaceAuthService.getUserPermSpace("", pageNum, Integer.MAX_VALUE);
com.xiaomi.youpin.infra.rpc.Result<PageDataVo<NodeVo>> userPermSpace = spaceAuthService.getUserPermSpace("", pageNum, 100);

if (userPermSpace.getCode() != 0) {
return Result.fail(CommonError.UNAUTHORIZED);
Expand Down
Loading
Loading