Skip to content

Commit

Permalink
add stop biz state (#1026)
Browse files Browse the repository at this point in the history
* add stop biz state

* update ark version

* fix test
  • Loading branch information
lvjing2 authored Nov 13, 2024
1 parent 9c3de26 commit 7ab39b4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 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.2.15</sofa.ark.version>
<sofa.ark.version.old>2.2.14</sofa.ark.version.old>
<sofa.ark.version>2.2.16-SNAPSHOT</sofa.ark.version>
<sofa.ark.version.old>2.2.15</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
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ public void stop() {
BizManagerService bizManagerService = ArkServiceContainerHolder.getContainer()
.getService(BizManagerService.class);
bizManagerService.unRegisterBiz(bizName, bizVersion);
setBizState(BizState.UNRESOLVED, StateChangeReason.STOPPED);
setBizState(BizState.STOPPED, StateChangeReason.STOPPED);
eventAdminService.sendEvent(new BeforeBizRecycleEvent(this));
urls = null;
denyImportPackages = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void testStopFailedWithClean() {
bizModel.stop();
} catch (RuntimeException e) {
}
assertEquals(BizState.UNRESOLVED, bizModel.getBizState());
assertEquals(BizState.STOPPED, bizModel.getBizState());
}

bizModel.setBizState(BizState.ACTIVATED);
Expand Down Expand Up @@ -186,7 +186,7 @@ public void testStopSucceedWithClean() {
mockedStatic.when(ArkServiceContainerHolder::getContainer).thenReturn(arkServiceContainer);
bizModel.stop();

assertEquals(BizState.UNRESOLVED, bizModel.getBizState());
assertEquals(BizState.STOPPED, bizModel.getBizState());
}

bizModel.setBizState(BizState.ACTIVATED);
Expand All @@ -201,7 +201,7 @@ public void testStopSucceedWithClean() {
mockedStatic.when(ArkServiceContainerHolder::getContainer).thenReturn(arkServiceContainer);
bizModel.stop();

assertEquals(BizState.UNRESOLVED, bizModel.getBizState());
assertEquals(BizState.STOPPED, bizModel.getBizState());
} finally {
ArkConfigs.putStringValue(AUTO_UNINSTALL_WHEN_FAILED_ENABLE, "true");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
*/
public enum BizState {
/**
* init but not start install yet
* or
* uninstalled
* not init or not start install yet
*/
UNRESOLVED("unresolved"),
/**
Expand All @@ -45,9 +43,14 @@ public enum BizState {
DEACTIVATED("deactivated"),

/**
* install failed.
* install or uninstall failed.
*/
BROKEN("broken");
BROKEN("broken"),

/**
* uninstall succeed
*/
STOPPED("stopped");

private String state;

Expand All @@ -73,6 +76,8 @@ public static BizState of(String state) {
return ACTIVATED;
} else if (DEACTIVATED.name().equalsIgnoreCase(state)) {
return DEACTIVATED;
} else if (STOPPED.name().equalsIgnoreCase(state)) {
return STOPPED;
} else {
return BROKEN;
}
Expand Down

0 comments on commit 7ab39b4

Please sign in to comment.