diff --git a/arklet/arklet-core/pom.xml b/arklet/arklet-core/pom.xml
index 0c154c6ca..a21b972a8 100644
--- a/arklet/arklet-core/pom.xml
+++ b/arklet/arklet-core/pom.xml
@@ -21,7 +21,6 @@
com.github.oshi
oshi-core
- ${oshi.version}
@@ -69,6 +68,7 @@
junit
test
+
org.mockito
mockito-core
diff --git a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/CommandServiceImpl.java b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/CommandServiceImpl.java
index 1ac6cd9bf..f18b69043 100644
--- a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/CommandServiceImpl.java
+++ b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/CommandServiceImpl.java
@@ -23,7 +23,6 @@
import java.util.concurrent.ThreadPoolExecutor;
import com.alibaba.fastjson.JSONObject;
-
import com.alipay.sofa.ark.common.util.BizIdentityUtils;
import com.alipay.sofa.common.utils.StringUtil;
import com.alipay.sofa.serverless.arklet.core.api.model.ResponseCode;
@@ -35,7 +34,6 @@
import com.alipay.sofa.serverless.arklet.core.command.builtin.handler.UninstallBizHandler;
import com.alipay.sofa.serverless.arklet.core.command.builtin.handler.*;
import com.alipay.sofa.serverless.arklet.core.command.coordinate.BizOpsCommandCoordinator;
-import com.alipay.sofa.serverless.arklet.core.command.coordinate.CommandMutexException;
import com.alipay.sofa.serverless.arklet.core.command.executor.ExecutorServiceManager;
import com.alipay.sofa.serverless.arklet.core.command.meta.AbstractCommandHandler;
import com.alipay.sofa.serverless.arklet.core.command.meta.bizops.ArkBizMeta;
@@ -111,26 +109,7 @@ public Output> process(String cmd, Map content) throws CommandValidationExcept
if (isBizOpsHandler(handler)) {
ArkBizMeta arkBizMeta = (ArkBizMeta) input;
AssertUtils.assertNotNull(arkBizMeta,
- "when execute bizOpsHandler, arkBizMeta should not be null");
- boolean canProcess = BizOpsCommandCoordinator.checkAndLock(arkBizMeta.getBizName(),
- arkBizMeta.getBizVersion(), handler.command());
- if (!canProcess) {
- return Output
- .ofFailed(ResponseCode.FAILED.name()
- + ":"
- + String.format(
- "%s %s conflict, exist unfinished command(%s) for this biz",
- BizIdentityUtils.generateBizIdentity(arkBizMeta.getBizName(),
- arkBizMeta.getBizVersion()),
- handler.command().getId(),
- BizOpsCommandCoordinator.getCurrentProcessingCommand(
- arkBizMeta.getBizName(), arkBizMeta.getBizVersion()).getId()));
- }
- try {
- handler.handle(input);
- } finally {
- BizOpsCommandCoordinator
- .unlock(arkBizMeta.getBizName(), arkBizMeta.getBizVersion());
+ "when execute bizOpsHandler, arkBizMeta should not be null");
if (arkBizMeta.isAync()) {
String requestId = arkBizMeta.getRequestId();
if (ProcessRecordHolder.getProcessRecord(requestId) != null) {
@@ -141,31 +120,50 @@ public Output> process(String cmd, Map content) throws CommandValidationExcept
ThreadPoolExecutor executor = ExecutorServiceManager.getArkBizOpsExecutor();
executor.submit(() -> {
try {
- BizOpsCommandCoordinator.putBizExecution(arkBizMeta.getBizName(), arkBizMeta.getBizVersion(), handler.command());
- processRecord.start();
- Output output = handler.handle(input);
- if (output.success()) {
- processRecord.success();
+ boolean canProcess = BizOpsCommandCoordinator.checkAndLock(arkBizMeta.getBizName(),
+ arkBizMeta.getBizVersion(), handler.command());
+ if (!canProcess) {
+ processRecord.fail("command conflict, exist unfinished command for this biz");
} else {
- processRecord.fail(output.getMessage());
+ processRecord.start();
+ Output output = handler.handle(input);
+ if (output.success()) {
+ processRecord.success();
+ } else {
+ processRecord.fail(output.getMessage());
+ }
}
} catch (Throwable throwable) {
processRecord.fail(throwable.getMessage(), throwable);
LOGGER.error("Error happened when handling command, requestId=" + requestId, throwable);
} finally {
processRecord.markFinishTime();
- BizOpsCommandCoordinator.popBizExecution(arkBizMeta.getBizName(), arkBizMeta.getBizVersion());
+ BizOpsCommandCoordinator
+ .unlock(arkBizMeta.getBizName(), arkBizMeta.getBizVersion());
}
});
return Output.ofSuccess(processRecord);
} else {
+ boolean canProcess = BizOpsCommandCoordinator.checkAndLock(arkBizMeta.getBizName(),
+ arkBizMeta.getBizVersion(), handler.command());
+ if (!canProcess) {
+ return Output
+ .ofFailed(ResponseCode.FAILED.name()
+ + ":"
+ + String.format(
+ "%s %s conflict, exist unfinished command(%s) for this biz",
+ BizIdentityUtils.generateBizIdentity(arkBizMeta.getBizName(),
+ arkBizMeta.getBizVersion()),
+ handler.command().getId(),
+ BizOpsCommandCoordinator.getCurrentProcessingCommand(
+ arkBizMeta.getBizName(), arkBizMeta.getBizVersion()).getId()));
+ }
try {
- BizOpsCommandCoordinator.putBizExecution(arkBizMeta.getBizName(), arkBizMeta.getBizVersion(), handler.command());
- return handler.handle(input);
- } catch (Throwable e) {
- throw e;
+ handler.handle(input);
} finally {
- BizOpsCommandCoordinator.popBizExecution(arkBizMeta.getBizName(), arkBizMeta.getBizVersion());
+ BizOpsCommandCoordinator
+ .unlock(arkBizMeta.getBizName(), arkBizMeta.getBizVersion());
+
}
}
}
diff --git a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/InstallBizHandler.java b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/InstallBizHandler.java
index 578e03ec9..1c185e83b 100644
--- a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/InstallBizHandler.java
+++ b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/InstallBizHandler.java
@@ -19,7 +19,6 @@
import com.alipay.sofa.ark.api.ClientResponse;
import com.alipay.sofa.ark.api.ResponseCode;
import com.alipay.sofa.ark.common.util.StringUtils;
-import com.alipay.sofa.ark.spi.model.BizInfo;
import com.alipay.sofa.serverless.arklet.core.command.builtin.BuiltinCommand;
import com.alipay.sofa.serverless.arklet.core.command.builtin.handler.InstallBizHandler.Input;
import com.alipay.sofa.serverless.arklet.core.command.meta.AbstractCommandHandler;
@@ -62,8 +61,8 @@ public Command command() {
public void validate(Input input) throws CommandValidationException {
notBlank(input.getBizName(), "bizName should not be blank");
notBlank(input.getBizVersion(), "bizVersion should not be blank");
- notBlank(input.getArkBizFilePath(), "arkBizFilePath should not be blank");
- isTrue(!input.isAync() || !StringUtils.isEmpty(input.getRequestId()), "requestId should not be blank when aync is true");
+ isTrue(!input.isAync() || !StringUtils.isEmpty(input.getRequestId()),
+ "requestId should not be blank when aync is true");
notBlank(input.getBizUrl(), "bizUrl should not be blank");
}
diff --git a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/QueryBizOpsHandler.java b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/QueryBizOpsHandler.java
index 6fb1412b2..298273d76 100644
--- a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/QueryBizOpsHandler.java
+++ b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/QueryBizOpsHandler.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.alipay.sofa.serverless.arklet.core.command.builtin.handler;
import com.alipay.sofa.serverless.arklet.core.command.meta.AbstractCommandHandler;
@@ -16,7 +32,8 @@
* @author: yuanyuan
* @date: 2023/9/4 9:50 下午
*/
-public class QueryBizOpsHandler extends AbstractCommandHandler {
+public class QueryBizOpsHandler extends
+ AbstractCommandHandler {
@Override
public void validate(Input input) throws CommandValidationException {
diff --git a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/SwitchBizHandler.java b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/SwitchBizHandler.java
index bf5983326..e8298d08c 100644
--- a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/SwitchBizHandler.java
+++ b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/SwitchBizHandler.java
@@ -60,7 +60,8 @@ public Command command() {
public void validate(Input input) throws CommandValidationException {
notBlank(input.getBizName(), "bizName should not be blank");
notBlank(input.getBizVersion(), "bizVersion should not be blank");
- isTrue(!input.isAync() || !StringUtils.isEmpty(input.getRequestId()), "requestId should not be blank when aync is true");
+ isTrue(!input.isAync() || !StringUtils.isEmpty(input.getRequestId()),
+ "requestId should not be blank when aync is true");
}
public static class Input extends ArkBizMeta {
diff --git a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/UninstallBizHandler.java b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/UninstallBizHandler.java
index 72a2c1281..a191db629 100644
--- a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/UninstallBizHandler.java
+++ b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/builtin/handler/UninstallBizHandler.java
@@ -60,7 +60,8 @@ public Command command() {
public void validate(Input input) throws CommandValidationException {
notBlank(input.getBizName(), "bizName should not be blank");
notBlank(input.getBizVersion(), "bizVersion should not be blank");
- isTrue(!input.isAync() || !StringUtils.isEmpty(input.getRequestId()), "requestId should not be blank when aync is true");
+ isTrue(!input.isAync() || !StringUtils.isEmpty(input.getRequestId()),
+ "requestId should not be blank when aync is true");
}
public static class Input extends ArkBizMeta {
diff --git a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/executor/ExecutorServiceManager.java b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/executor/ExecutorServiceManager.java
index b7c5e4be1..cd88af0be 100644
--- a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/executor/ExecutorServiceManager.java
+++ b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/executor/ExecutorServiceManager.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.alipay.sofa.serverless.arklet.core.command.executor;
import java.util.concurrent.ArrayBlockingQueue;
@@ -10,16 +26,14 @@
*/
public class ExecutorServiceManager {
- private static ThreadPoolExecutor ARK_BIZ_OPS_EXECUTOR = new ThreadPoolExecutor(
- 20,
- 50,
- 30,
- TimeUnit.SECONDS,
- new ArrayBlockingQueue<>(
- 100),
- new NamedThreadFactory(
- "ark-biz-ops"),
- new ThreadPoolExecutor.CallerRunsPolicy());
+ private static ThreadPoolExecutor ARK_BIZ_OPS_EXECUTOR = new ThreadPoolExecutor(
+ 20,
+ 50,
+ 30,
+ TimeUnit.SECONDS,
+ new ArrayBlockingQueue<>(100),
+ new NamedThreadFactory("ark-biz-ops"),
+ new ThreadPoolExecutor.CallerRunsPolicy());
public static ThreadPoolExecutor getArkBizOpsExecutor() {
return ARK_BIZ_OPS_EXECUTOR;
diff --git a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/executor/NamedThreadFactory.java b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/executor/NamedThreadFactory.java
index 61976a7b3..fc662cb51 100644
--- a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/executor/NamedThreadFactory.java
+++ b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/executor/NamedThreadFactory.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.alipay.sofa.serverless.arklet.core.command.executor;
import java.util.concurrent.ThreadFactory;
diff --git a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/meta/bizops/ArkBizMeta.java b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/meta/bizops/ArkBizMeta.java
index 1cb1fd9f1..753f2e453 100644
--- a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/meta/bizops/ArkBizMeta.java
+++ b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/meta/bizops/ArkBizMeta.java
@@ -25,9 +25,9 @@
* @date 2023/8/21
*/
public class ArkBizMeta extends InputMeta {
- private String bizName;
- private String bizVersion;
- private String requestId;
+ private String bizName;
+ private String bizVersion;
+ private String requestId;
private boolean aync;
public String getBizName() {
diff --git a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/record/ProcessRecord.java b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/record/ProcessRecord.java
index 7025894b9..408ff1493 100644
--- a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/record/ProcessRecord.java
+++ b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/record/ProcessRecord.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.alipay.sofa.serverless.arklet.core.command.record;
import com.alipay.sofa.serverless.arklet.core.common.log.ArkletLogger;
@@ -20,24 +36,23 @@ public class ProcessRecord {
private static final ArkletLogger LOGGER = ArkletLoggerFactory.getDefaultLogger();
- private String requestId;
-
- private String threadName;
+ private String requestId;
- private Status status;
+ private String threadName;
- private Throwable throwable;
+ private Status status;
- private String errorCode;
+ private Throwable throwable;
- private String message;
+ private String errorCode;
- private long startTimestamp;
+ private String message;
- private long endTimestamp;
+ private long startTimestamp;
- private long elapsedTime;
+ private long endTimestamp;
+ private long elapsedTime;
public enum Status {
@@ -49,7 +64,7 @@ public enum Status {
FAILED("FAILED");
- private String name;
+ private String name;
Status(String name) {
this.name = name;
diff --git a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/record/ProcessRecordHolder.java b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/record/ProcessRecordHolder.java
index 3b0f17f6f..198fd12fb 100644
--- a/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/record/ProcessRecordHolder.java
+++ b/arklet/arklet-core/src/main/java/com/alipay/sofa/serverless/arklet/core/command/record/ProcessRecordHolder.java
@@ -1,6 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.alipay.sofa.serverless.arklet.core.command.record;
-
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
diff --git a/arklet/arklet-springboot-starter/pom.xml b/arklet/arklet-springboot-starter/pom.xml
index b78ad5657..ef1c02545 100644
--- a/arklet/arklet-springboot-starter/pom.xml
+++ b/arklet/arklet-springboot-starter/pom.xml
@@ -12,11 +12,6 @@
arklet-springboot-starter
-
- 2.5.12
-
-
-
com.alipay.sofa.serverless
@@ -26,29 +21,30 @@
org.springframework.boot
spring-boot-autoconfigure
- ${spring.boot.version}
provided
org.springframework.boot
spring-boot-loader
- ${spring.boot.version}
provided
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
org.springframework.boot
spring-boot-starter-test
- ${spring.boot.version}
test
org.springframework.boot
spring-boot-starter-logging
- ${spring.boot.version}
test
@@ -76,12 +72,6 @@
test
-
- org.springframework.boot
- spring-boot-starter-actuator
- ${spring.boot.version}
-
-
junit
junit
diff --git a/arklet/pom.xml b/arklet/pom.xml
index ac5d43597..af188ea05 100644
--- a/arklet/pom.xml
+++ b/arklet/pom.xml
@@ -7,7 +7,7 @@
${revision}
4.0.0
- 1.0.0-SNAPSHOT
+ 0.3-SNAPSHOT
UTF-8
UTF-8
1.8
@@ -29,7 +29,9 @@
4.8.1
1.5.0
2.2.3-SNAPSHOT
+ 2.5.12
6.4.5
+ 3.12.0
16.0.1
1.2.69
@@ -62,6 +64,36 @@
${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-starter-actuator
+ ${spring.boot.version}
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ ${spring.boot.version}
+
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+ ${spring.boot.version}
+
+
com.google.inject
guice
@@ -110,6 +142,18 @@
${lombok.version}
+
+ com.github.oshi
+ oshi-core
+ ${oshi.version}
+
+
+
+ org.apache.commons
+ commons-lang3
+ ${commons.lang3.version}
+
+
com.alipay.sofa.serverless
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index e69de29bb..000000000