diff --git a/samples/springboot-samples/pom.xml b/samples/springboot-samples/pom.xml index 332ee9ea4..d6a121b8e 100644 --- a/samples/springboot-samples/pom.xml +++ b/samples/springboot-samples/pom.xml @@ -38,9 +38,7 @@ web/tomcat web/webflux/base web/webflux/biz - service/base - service/biz1 - service/biz2 + service slimming/log4j2 msg/kafka/base msg/kafka/biz1 diff --git a/samples/springboot-samples/service/base/base-bootstrap/src/main/java/com/alipay/sofa/base/rest/SampleController.java b/samples/springboot-samples/service/base/base-bootstrap/src/main/java/com/alipay/sofa/base/rest/SampleController.java index 6a5b3c936..6b24246ca 100644 --- a/samples/springboot-samples/service/base/base-bootstrap/src/main/java/com/alipay/sofa/base/rest/SampleController.java +++ b/samples/springboot-samples/service/base/base-bootstrap/src/main/java/com/alipay/sofa/base/rest/SampleController.java @@ -22,7 +22,7 @@ public class SampleController { @RequestMapping(value = "/", method = RequestMethod.GET) public String hello() { - Provider studentProvider = SpringServiceFinder.getModuleService("biz", "0.0.1-SNAPSHOT", + Provider studentProvider = SpringServiceFinder.getModuleService("biz1", "0.0.1-SNAPSHOT", "studentProvider", Provider.class); Result result = studentProvider.provide(new Param()); System.out.println(result.getClass()); @@ -30,7 +30,7 @@ public String hello() { System.out.println(result.getPeople().getClass()); System.out.println(result); - Provider teacherProvider = SpringServiceFinder.getModuleService("biz", "0.0.1-SNAPSHOT", + Provider teacherProvider = SpringServiceFinder.getModuleService("biz1", "0.0.1-SNAPSHOT", "teacherProvider", Provider.class); Result result1 = teacherProvider.provide(new Param()); System.out.println(result1.getClass()); @@ -38,7 +38,7 @@ public String hello() { System.out.println(result1.getPeople().getClass()); System.out.println(result1); - Map providerMap = SpringServiceFinder.listModuleServices("biz", "0.0.1-SNAPSHOT", + Map providerMap = SpringServiceFinder.listModuleServices("biz1", "0.0.1-SNAPSHOT", Provider.class); for (String beanName : providerMap.keySet()) { Result result2 = providerMap.get(beanName).provide(new Param()); diff --git a/samples/springboot-samples/service/base/pom.xml b/samples/springboot-samples/service/base/pom.xml index 9c75d7775..a2b2ff498 100644 --- a/samples/springboot-samples/service/base/pom.xml +++ b/samples/springboot-samples/service/base/pom.xml @@ -8,16 +8,13 @@ base-bootstrap - com.alipay.sofa - springboot-samples + com.alipay.sofa.service + cross-biz-calling 0.0.1-SNAPSHOT - ../../pom.xml + ../pom.xml - com.alipay.sofa.service base 0.0.1-SNAPSHOT - sample-service-base - sample-service-base pom diff --git a/samples/springboot-samples/service/biz1/pom.xml b/samples/springboot-samples/service/biz1/pom.xml index 47f05f1cd..91453fa4f 100644 --- a/samples/springboot-samples/service/biz1/pom.xml +++ b/samples/springboot-samples/service/biz1/pom.xml @@ -8,16 +8,13 @@ biz1-facade - com.alipay.sofa - springboot-samples + com.alipay.sofa.service + cross-biz-calling 0.0.1-SNAPSHOT - ../../pom.xml + ../pom.xml - com.alipay.sofa.service biz1 0.0.1-SNAPSHOT - sample-service-biz - sample-service-biz diff --git a/samples/springboot-samples/service/biz2/pom.xml b/samples/springboot-samples/service/biz2/pom.xml index f25ba67f5..e84a45029 100644 --- a/samples/springboot-samples/service/biz2/pom.xml +++ b/samples/springboot-samples/service/biz2/pom.xml @@ -8,16 +8,13 @@ biz2-facade - com.alipay.sofa - springboot-samples + com.alipay.sofa.service + cross-biz-calling 0.0.1-SNAPSHOT - ../../pom.xml + ../pom.xml - com.alipay.sofa.service biz2 0.0.1-SNAPSHOT - sample-service-biz2 - sample-service-biz2 diff --git a/samples/springboot-samples/service/pom.xml b/samples/springboot-samples/service/pom.xml new file mode 100644 index 000000000..5c5bc9228 --- /dev/null +++ b/samples/springboot-samples/service/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + com.alipay.sofa + springboot-samples + 0.0.1-SNAPSHOT + ../pom.xml + + com.alipay.sofa.service + cross-biz-calling + 0.0.1-SNAPSHOT + pom + + + base + biz1 + biz2 + + diff --git a/samples/springboot3-samples/pom.xml b/samples/springboot3-samples/pom.xml index 42132a1b6..bc78956a1 100644 --- a/samples/springboot3-samples/pom.xml +++ b/samples/springboot3-samples/pom.xml @@ -6,7 +6,7 @@ org.springframework.boot spring-boot-starter-parent - 3.0.9 + 3.2.1 @@ -18,10 +18,10 @@ pom - 3.0.9 + 3.2.1 17 3.0.1 - 0.5.5-jdk17 + 0.5.6-jdk17-SNAPSHOT 3.4.2 1.7.1 0.6.1 @@ -103,6 +103,25 @@ sofa-serverless-app-starter ${sofa.serverless.runtime.version} + + + com.alipay.sofa + log-sofa-boot-starter + 3.9.1 + + + + + com.alipay.sofa.common + sofa-common-tools + 2.0.3 + + + com.google.guava + * + + + @@ -133,4 +152,4 @@ - \ No newline at end of file + diff --git a/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/ArkletComponentRegistry.java b/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/ArkletComponentRegistry.java index 4c9f574df..b97ea4479 100644 --- a/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/ArkletComponentRegistry.java +++ b/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/ArkletComponentRegistry.java @@ -42,8 +42,6 @@ */ public class ArkletComponentRegistry { - private static final ArkletLogger LOGGER = ArkletLoggerFactory.getDefaultLogger(); - private static final Injector componentInjector = Guice .createInjector(new ComponentGuiceModule()); @@ -60,20 +58,20 @@ public class ArkletComponentRegistry { private static void initComponents() { String components = componentList.stream().map(s -> s.getClass().getSimpleName()).collect(Collectors.joining(", ")); - LOGGER.info("found components: {}", components); - LOGGER.info("start to initialize components"); + ArkletLoggerFactory.getDefaultLogger().info("found components: {}", components); + ArkletLoggerFactory.getDefaultLogger().info("start to initialize components"); for (ArkletComponent component : componentList) { component.init(); } - LOGGER.info("finish initialize components"); + ArkletLoggerFactory.getDefaultLogger().info("finish initialize components"); } private static void destroyComponents() { - LOGGER.info("start to destroy components"); + ArkletLoggerFactory.getDefaultLogger().info("start to destroy components"); for (ArkletComponent component : componentList) { component.destroy(); } - LOGGER.info("finish destroy components"); + ArkletLoggerFactory.getDefaultLogger().info("finish destroy components"); } public static UnifiedOperationService getOperationServiceInstance() { diff --git a/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/record/ProcessRecord.java b/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/record/ProcessRecord.java index d3e1f62ff..717d28707 100644 --- a/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/record/ProcessRecord.java +++ b/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/record/ProcessRecord.java @@ -37,31 +37,29 @@ @Setter public class ProcessRecord { - private static final ArkletLogger LOGGER = ArkletLoggerFactory.getDefaultLogger(); + private String requestId; - private String requestId; + private ArkBizMeta arkBizMeta; - private ArkBizMeta arkBizMeta; + private String threadName; - private String threadName; + private Status status; - private Status status; + private Throwable throwable; - private Throwable throwable; + private String errorCode; - private String errorCode; + private String message; - private String message; + private Date startTime; - private Date startTime; + private long startTimestamp; - private long startTimestamp; + private Date endTime; - private Date endTime; + private long endTimestamp; - private long endTimestamp; - - private long elapsedTime; + private long elapsedTime; public enum Status { @@ -102,21 +100,24 @@ public boolean finished() { public void start() { if (INITIALIZED.equals(getStatus())) { setStatus(EXECUTING); - LOGGER.info("Command execution status change: INIT -> EXECUTING"); + ArkletLoggerFactory.getDefaultLogger().info( + "Command execution status change: INIT -> EXECUTING"); } } public void success() { if (EXECUTING.equals(getStatus())) { setStatus(SUCCEEDED); - LOGGER.info("Command execution status change: EXECUTING -> SUCCESS"); + ArkletLoggerFactory.getDefaultLogger().info( + "Command execution status change: EXECUTING -> SUCCESS"); } } public void fail() { if (EXECUTING.equals(getStatus())) { setStatus(FAILED); - LOGGER.info("Command execution status change: EXECUTING -> FAIL"); + ArkletLoggerFactory.getDefaultLogger().info( + "Command execution status change: EXECUTING -> FAIL"); } } diff --git a/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/health/HealthServiceImpl.java b/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/health/HealthServiceImpl.java index 07ef96a24..2f6e54185 100644 --- a/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/health/HealthServiceImpl.java +++ b/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/health/HealthServiceImpl.java @@ -16,8 +16,6 @@ */ package com.alipay.sofa.serverless.arklet.core.health; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.alipay.sofa.ark.api.ArkClient; import com.alipay.sofa.ark.common.util.AssertUtils; import com.alipay.sofa.ark.common.util.StringUtils; @@ -47,7 +45,6 @@ @Singleton public class HealthServiceImpl implements HealthService { - private static final ArkletLogger LOGGER = ArkletLoggerFactory.getDefaultLogger(); private final HealthBuilder healthBuilder = new HealthBuilder(); private final Map indicators = new ConcurrentHashMap<>(3); @@ -190,7 +187,8 @@ public Indicator getIndicator(String indicatorId) { @Override public void registerIndicator(Indicator indicator) { this.indicators.put(indicator.getIndicatorId(), indicator); - LOGGER.info("register indicator " + indicator.getIndicatorId()); + ArkletLoggerFactory.getDefaultLogger().info( + "register indicator " + indicator.getIndicatorId()); } private void initIndicators() { diff --git a/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/ops/BatchInstallHelper.java b/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/ops/BatchInstallHelper.java index 279a965db..2874ff0b8 100644 --- a/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/ops/BatchInstallHelper.java +++ b/sofa-serverless-runtime/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/ops/BatchInstallHelper.java @@ -37,8 +37,6 @@ */ public class BatchInstallHelper { - private static final ArkletLogger LOGGER = ArkletLoggerFactory.getDefaultLogger(); - /** * 判断是否是 biz jar 文件 * 目前简单的以后缀 '-biz.jar' 为约束。 @@ -62,7 +60,8 @@ public List getBizUrlsFromLocalFileSystem(String absoluteBizDirPath) { public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { Path absolutePath = file.toAbsolutePath(); if (isBizJarFile(absolutePath)) { - LOGGER.info("Found biz jar file: {}", absolutePath); + ArkletLoggerFactory.getDefaultLogger().info("Found biz jar file: {}", + absolutePath); bizUrls.add(absolutePath.toString()); } return FileVisitResult.CONTINUE; diff --git a/sofa-serverless-runtime/arklet-springboot-starter/pom.xml b/sofa-serverless-runtime/arklet-springboot-starter/pom.xml index ebe56b883..3b1f26714 100644 --- a/sofa-serverless-runtime/arklet-springboot-starter/pom.xml +++ b/sofa-serverless-runtime/arklet-springboot-starter/pom.xml @@ -33,7 +33,6 @@ ch.qos.logback logback-core - ${logback.core} org.springframework.boot @@ -43,7 +42,6 @@ ch.qos.logback logback-classic - ${logback.core} test @@ -114,4 +112,4 @@ - \ No newline at end of file + diff --git a/sofa-serverless-runtime/pom.xml b/sofa-serverless-runtime/pom.xml index 3e74d416d..14a91dadf 100644 --- a/sofa-serverless-runtime/pom.xml +++ b/sofa-serverless-runtime/pom.xml @@ -9,10 +9,9 @@ pom - 0.5.6 + 0.5.7-SNAPSHOT 2.2.6 2.7.15 - 1.2.9 UTF-8 UTF-8 1.8 @@ -30,11 +29,6 @@ 1.5.0 6.4.5 6.0.0 - 4.1.94.Final - 1.2.9 - 1.18.22 - 4.13.1 - 4.8.1 1.5.0 6.4.5 32.1.3-jre @@ -86,6 +80,14 @@ + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + com.alipay.sofa.serverless arklet-core @@ -138,57 +140,13 @@ sofa-ark-api ${sofa.ark.version} - - - - org.springframework.boot - spring-boot-starter-actuator - ${spring.boot.version} - com.alipay.sofa sofa-ark-springboot-starter ${sofa.ark.version} - - - org.springframework.boot - spring-boot-autoconfigure - ${spring.boot.version} - - - - org.springframework.boot - spring-boot-loader - ${spring.boot.version} - - - - org.springframework.boot - spring-boot - ${spring.boot.version} - - - - org.springframework.boot - spring-boot-starter-test - ${spring.boot.version} - test - - - - org.springframework.boot - spring-boot-actuator - ${spring.boot.version} - - - - org.springframework.boot - spring-boot-starter-logging - ${spring.boot.version} - - + com.google.inject @@ -214,58 +172,11 @@ ${hessian.version} - - io.netty - netty-all - ${netty.version} - - - - ch.qos.logback - logback-classic - ${logback.version} - - - - ch.qos.logback - logback-core - ${logback.version} - - - - org.projectlombok - lombok - ${lombok.version} - - - - - junit - junit - ${junit.version} - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - com.github.oshi oshi-core ${oshi.version} - - - org.mockito - mockito-inline - ${mockito.version} - test - - diff --git a/sofa-serverless-runtime/sofa-serverless-base-plugin/src/main/java/com/alipay/sofa/serverless/plugin/manager/listener/StaticBatchInstallEventListener.java b/sofa-serverless-runtime/sofa-serverless-base-plugin/src/main/java/com/alipay/sofa/serverless/plugin/manager/listener/StaticBatchInstallEventListener.java index 3f151acd1..26aa8d57b 100644 --- a/sofa-serverless-runtime/sofa-serverless-base-plugin/src/main/java/com/alipay/sofa/serverless/plugin/manager/listener/StaticBatchInstallEventListener.java +++ b/sofa-serverless-runtime/sofa-serverless-base-plugin/src/main/java/com/alipay/sofa/serverless/plugin/manager/listener/StaticBatchInstallEventListener.java @@ -43,10 +43,8 @@ public class StaticBatchInstallEventListener implements ApplicationListener { - private static ArkletLogger LOGGER = ArkletLoggerFactory.getDefaultLogger(); - // 合并部署是否已经完成,防止重复执行。 - private AtomicBoolean isBatchdDeployed = new AtomicBoolean(false); + private AtomicBoolean isBatchdDeployed = new AtomicBoolean(false); @SneakyThrows public void batchDeployFromLocalDir() { @@ -54,7 +52,8 @@ public void batchDeployFromLocalDir() { if (StringUtils.isEmpty(absolutePath) || isBatchdDeployed.get()) { return; } - LOGGER.info("start to batch deploy from local dir:{}", absolutePath); + ArkletLoggerFactory.getDefaultLogger().info("start to batch deploy from local dir:{}", + absolutePath); UnifiedOperationService operationServiceInstance = ArkletComponentRegistry .getOperationServiceInstance(); @@ -62,8 +61,9 @@ public void batchDeployFromLocalDir() { .batchInstall(BatchInstallRequest.builder().bizDirAbsolutePath(absolutePath).build()); for (Map.Entry entry : batchInstallResponse.getBizUrlToResponse() .entrySet()) { - LOGGER.info("{}, {}, {}, BatchDeployResult", entry.getKey(), entry.getValue().getCode() - .toString(), entry.getValue().getMessage()); + ArkletLoggerFactory.getDefaultLogger().info("{}, {}, {}, BatchDeployResult", + entry.getKey(), entry.getValue().getCode().toString(), + entry.getValue().getMessage()); } isBatchdDeployed.set(true); Preconditions.checkState(batchInstallResponse.getCode() == ResponseCode.SUCCESS, diff --git a/sofa-serverless-runtime/sofa-serverless-common/src/main/java/com/alipay/sofa/serverless/common/util/SerializeUtils.java b/sofa-serverless-runtime/sofa-serverless-common/src/main/java/com/alipay/sofa/serverless/common/util/SerializeUtils.java index 482a38138..d2a12c719 100644 --- a/sofa-serverless-runtime/sofa-serverless-common/src/main/java/com/alipay/sofa/serverless/common/util/SerializeUtils.java +++ b/sofa-serverless-runtime/sofa-serverless-common/src/main/java/com/alipay/sofa/serverless/common/util/SerializeUtils.java @@ -37,6 +37,8 @@ public static Object serializeTransform(Object source, ClassLoader targetClassLo if (targetClassLoader != null) { Thread.currentThread().setContextClassLoader(targetClassLoader); } + + // 支持多态的序列化与反序列化,需要使用 hessian SerializerFactory serializerFactory = new SerializerFactory(); serializerFactory.setAllowNonSerializable(true); ByteArrayOutputStream bos = new ByteArrayOutputStream();