Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into feat_plugin_manage
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
  • Loading branch information
yuanyuan2021 committed Sep 24, 2024
2 parents 5a35f75 + 6eef785 commit 4b08ce4
Show file tree
Hide file tree
Showing 18 changed files with 372 additions and 124 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</modules>

<properties>
<sofa.ark.version>2.3.0-SNAPSHOT</sofa.ark.version>
<sofa.ark.version.old>2.2.12</sofa.ark.version.old>
<sofa.ark.version>2.2.15-SNAPSHOT</sofa.ark.version>
<sofa.ark.version.old>2.2.14</sofa.ark.version.old>
<project.encoding>UTF-8</project.encoding>
<java.version>1.8</java.version>
<license.maven.plugin>3.0</license.maven.plugin>
Expand Down
2 changes: 1 addition & 1 deletion sofa-ark-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<properties>
<log4j.version>1.7.32</log4j.version>
<log.sofa.starter.version>3.16.3</log.sofa.starter.version>
<log.sofa.starter.version>3.2.0</log.sofa.starter.version>
<logback.version>1.2.13</logback.version>

<guice.version>6.0.0</guice.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class DirectoryContainerArchive implements ContainerArchive {

private final static String[] AKR_CONTAINER_JAR = { "aopalliance-1.0", "commons-io-2.7",
"guava-33.0.0-jre", "guice-6.0.0", "failureaccess-1.0.1", "javax.inject-1",
"logback-core-1.2.13", "logback-classic-1.2.13", "slf4j-api-1.7.32",
"logback-core-1.2.9", "logback-classic-1.2.9", "slf4j-api-1.7.32",
"log-sofa-boot-starter", "log-sofa-boot", "sofa-common-tools",
"netty-all-4.1.109.Final", "netty-transport-4.1.109.Final",
"netty-common-4.1.109.Final", "netty-handler-4.1.109.Final",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
import com.alipay.sofa.ark.spi.service.biz.AddBizToStaticDeployHook;
import com.alipay.sofa.ark.spi.service.extension.ArkServiceLoader;
import com.alipay.sofa.common.log.MultiAppLoggerSpaceManager;
import com.alipay.sofa.common.log.SpaceId;
import com.alipay.sofa.common.log.SpaceInfo;
import com.alipay.sofa.common.log.env.LogEnvUtils;
import com.alipay.sofa.common.log.factory.LogbackLoggerSpaceFactory;
import com.alipay.sofa.common.utils.ReportUtil;

import java.io.File;
Expand All @@ -56,13 +60,8 @@
import static com.alipay.sofa.ark.spi.constant.Constants.ARK_CONF_FILE;
import static com.alipay.sofa.ark.spi.constant.Constants.ARK_CONF_FILE_FORMAT;
import static com.alipay.sofa.common.log.Constants.LOGGING_PATH_DEFAULT;
import static com.alipay.sofa.common.log.Constants.LOG_CONFIG_PREFIX;
import static com.alipay.sofa.common.log.Constants.LOG_ENCODING_PROP_KEY;
import static com.alipay.sofa.common.log.Constants.LOG_LEVEL_PREFIX;
import static com.alipay.sofa.common.log.Constants.LOG_PATH;
import static com.alipay.sofa.common.log.Constants.LOG_PATH_PREFIX;
import static com.alipay.sofa.common.log.Constants.OLD_LOG_PATH;
import static com.alipay.sofa.common.log.Constants.SOFA_MIDDLEWARE_CONFIG_PREFIX;
import static com.alipay.sofa.common.log.Constants.UTF8_STR;

/**
Expand Down Expand Up @@ -249,34 +248,29 @@ public List<URL> getProfileConfFiles(String... profiles) {
* @throws ArkRuntimeException
*/
public void reInitializeArkLogger() throws ArkRuntimeException {
// log config from ark container or user app config files, the order of which to be used is:
// 1. using user app config files
// 2. using ark container config
// 3. using the default value
Map<String, String> arkLogConfig = new HashMap<>();

// 1. set config from app config and ark container config first
for (String key : ArkConfigs.keySet()) {
if (filterAllLogConfig(key)) {
arkLogConfig.put(key, ArkConfigs.getStringValue(key));
for (Map.Entry<SpaceId, SpaceInfo> entry : MultiAppLoggerSpaceManager.getSpacesMap()
.entrySet()) {
SpaceId spaceId = entry.getKey();
SpaceInfo spaceInfo = entry.getValue();
if (!ArkLoggerFactory.SOFA_ARK_LOGGER_SPACE.equals(spaceId.getSpaceName())) {
continue;
}
LogbackLoggerSpaceFactory arkLoggerSpaceFactory = (LogbackLoggerSpaceFactory) spaceInfo
.getAbstractLoggerSpaceFactory();
Map<String, String> arkLogConfig = new HashMap<>();
// set base logging.path
arkLogConfig.put(LOG_PATH, ArkConfigs.getStringValue(LOG_PATH, LOGGING_PATH_DEFAULT));
// set log file encoding
arkLogConfig.put(LOG_ENCODING_PROP_KEY,
ArkConfigs.getStringValue(LOG_ENCODING_PROP_KEY, UTF8_STR));
// set other log config
for (String key : ArkConfigs.keySet()) {
if (LogEnvUtils.filterAllLogConfig(key)) {
arkLogConfig.put(key, ArkConfigs.getStringValue(key));
}
}
arkLoggerSpaceFactory.reInitialize(arkLogConfig);
}

// 2. using the default value if not set
arkLogConfig.put(LOG_PATH, ArkConfigs.getStringValue(LOG_PATH, LOGGING_PATH_DEFAULT));
arkLogConfig.put("logging.file.path",
ArkConfigs.getStringValue("logging.file.path", LOGGING_PATH_DEFAULT));
arkLogConfig.put(LOG_ENCODING_PROP_KEY,
ArkConfigs.getStringValue(LOG_ENCODING_PROP_KEY, UTF8_STR));

MultiAppLoggerSpaceManager.init(ArkLoggerFactory.SOFA_ARK_LOGGER_SPACE, arkLogConfig);
}

private boolean filterAllLogConfig(String key) {
return key.startsWith(SOFA_MIDDLEWARE_CONFIG_PREFIX) || key.startsWith(LOG_LEVEL_PREFIX)
|| key.startsWith(LOG_PATH_PREFIX) || key.startsWith(LOG_CONFIG_PREFIX)
|| key.equals(LOG_PATH) || key.equals(OLD_LOG_PATH)
|| key.equals("logging.file.path") || key.equals(LOG_ENCODING_PROP_KEY);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,13 @@ public void stop() {
"Ark biz {} close biz classloader fail", getIdentity());
}
}

eventAdminService.sendEvent(new AfterBizStopEvent(this));
eventAdminService.unRegister(classLoader);
classLoader = null;
recycleBizTempWorkDir(bizTempWorkDir);
bizTempWorkDir = null;
ClassLoaderUtils.popContextClassLoader(oldClassLoader);
eventAdminService.sendEvent(new AfterBizStopEvent(this));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ public void stop() throws ArkRuntimeException {
throw new ArkRuntimeException(ex.getMessage(), ex);
} finally {
eventAdminService.sendEvent(new AfterPluginStopEvent(this));
if (this.getPluginClassLoader() != null) {
eventAdminService.unRegister(this.getPluginClassLoader());
}
}
}

Expand All @@ -375,4 +378,4 @@ public String toString() {
return "Ark Plugin: " + pluginName;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import com.alipay.sofa.ark.common.log.ArkLoggerFactory;
import com.alipay.sofa.ark.common.util.OrderComparator;
import com.alipay.sofa.ark.spi.event.ArkEvent;
import com.alipay.sofa.ark.spi.event.biz.BeforeBizRecycleEvent;
import com.alipay.sofa.ark.spi.event.plugin.AfterPluginStopEvent;
import com.alipay.sofa.ark.spi.registry.ServiceReference;
import com.alipay.sofa.ark.spi.service.PriorityOrdered;
import com.alipay.sofa.ark.spi.service.event.EventAdminService;
Expand Down Expand Up @@ -110,17 +108,6 @@ public void unRegister(ClassLoader classLoader) {

@Override
public void handleEvent(ArkEvent event) {
ClassLoader classLoader = null;

if (event instanceof BeforeBizRecycleEvent) {
classLoader = ((BeforeBizRecycleEvent) event).getSource().getBizClassLoader();
} else if (event instanceof AfterPluginStopEvent) {
classLoader = ((AfterPluginStopEvent) event).getSource().getPluginClassLoader();
}

if (classLoader != null) {
unRegister(classLoader);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public class Constants {
public final static String BIZ_EVENT_TOPIC_AFTER_INVOKE_BIZ_START = "AFTER-INVOKE-BIZ-START";
public final static String BIZ_EVENT_TOPIC_AFTER_INVOKE_BIZ_STOP = "AFTER-INVOKE-BIZ-STOP";
public final static String BIZ_EVENT_TOPIC_AFTER_BIZ_FAILED = "BIZ_EVENT_TOPIC_AFTER_BIZ_FAILED";

public final static String BIZ_EVENT_TOPIC_BEFORE_RECYCLE_BIZ = "BEFORE-RECYCLE-BIZ";
public final static String BIZ_EVENT_TOPIC_BEFORE_INVOKE_BIZ_START = "BEFORE-INVOKE-BIZ-START";
public final static String BIZ_EVENT_TOPIC_BEFORE_INVOKE_BIZ_STOP = "BEFORE-INVOKE-BIZ-STOP";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,45 @@ public class ModuleSlimConfig {
* group-a:tracer-core:3.0.10
* group-b:tracer-core:3.0.10:jdk17
*/
private LinkedHashSet<String> excludes = new LinkedHashSet<>();
private LinkedHashSet<String> excludes = new LinkedHashSet<>();

/**
* list of groupId names to exclude (exact match).
*/
private LinkedHashSet<String> excludeGroupIds = new LinkedHashSet<>();
private LinkedHashSet<String> excludeGroupIds = new LinkedHashSet<>();

/**
* list of artifact names to exclude (exact match).
*/
private LinkedHashSet<String> excludeArtifactIds = new LinkedHashSet<>();
private LinkedHashSet<String> excludeArtifactIds = new LinkedHashSet<>();

/**
* Colon separated groupId, artifactId [and classifier] to exclude (exact match). e.g:
* group-a:tracer-core:3.0.10
* group-b:tracer-core:3.0.10:jdk17
*/
private LinkedHashSet<String> includes = new LinkedHashSet<>();
private LinkedHashSet<String> includes = new LinkedHashSet<>();

/**
* list of groupId names to exclude (exact match).
*/
private LinkedHashSet<String> includeGroupIds = new LinkedHashSet<>();
private LinkedHashSet<String> includeGroupIds = new LinkedHashSet<>();

/**
* list of artifact names to exclude (exact match).
*/
private LinkedHashSet<String> includeArtifactIds = new LinkedHashSet<>();
private LinkedHashSet<String> includeArtifactIds = new LinkedHashSet<>();

/**
* 基座依赖标识,以 ${groupId}:${artifactId}:${version} 标识
*/
private String baseDependencyParentIdentity;

/**
* 是否排除依赖时,同时排除依赖及间接依赖。如:A依赖B,B依赖C,当 excludes 只配置了 A 时,B 和 C 都会被排除
*/
private boolean excludeWithIndirectDependencies = true;

public LinkedHashSet<String> getExcludeArtifactIds() {
return excludeArtifactIds;
}
Expand Down Expand Up @@ -144,4 +149,12 @@ public LinkedHashSet<String> getIncludeArtifactIds() {
public void setIncludeArtifactIds(LinkedHashSet<String> includeArtifactIds) {
this.includeArtifactIds = includeArtifactIds;
}

public boolean isExcludeWithIndirectDependencies() {
return excludeWithIndirectDependencies;
}

public void setExcludeWithIndirectDependencies(boolean excludeWithIndirectDependencies) {
this.excludeWithIndirectDependencies = excludeWithIndirectDependencies;
}
}
Loading

0 comments on commit 4b08ce4

Please sign in to comment.