Skip to content

Commit

Permalink
feat(maintenance): no longer delete session on pause (#2694)
Browse files Browse the repository at this point in the history
* also no longer pause permission when pausing tenant
* add missing AvailableWhenTenantIsPaused on PermissionAPI
* remove useless pause resume methods overriding

Covers [DEV-478](https://bonitasoft.atlassian.net/browse/DEV-478)

Co-authored-by: passga <pascal.garcia@bonitosft.com>
  • Loading branch information
abirembaut and passga authored Sep 5, 2023
1 parent c57258f commit e0d6af7
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @author Baptiste Mesta
*/
@Slf4j
@AvailableWhenTenantIsPaused
public class PermissionAPIImpl implements PermissionAPI {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,6 @@ public void stop() {
}
}

@Override
public void pause() {
stop();
}

@Override
public void resume() throws SBonitaException {
start();
}

@Override
public boolean isAuthorized(APICallContext apiCallContext) throws SExecutionException {
if (log.isTraceEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ public void pause() {
areTenantsElementsAlreadyRestarted = false;
}

@Override
public void resume() {
}

@Override
public boolean shouldRestartElements() {
return !areTenantsElementsAlreadyRestarted;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public synchronized void pause() throws Exception {
if (!tenant.isActivated()) {
throw new UpdateException("Can't pause a tenant in state " + tenant.getStatus());
}
sessionService.deleteSessionsOfTenantExceptTechnicalUser(tenantId);
pauseTenantInTransaction();
pauseSchedulerJobsInTransaction(tenantId);
tenantServicesManager.pause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,6 @@ public void should_start_then_stop_forbid_to_check_api() throws SBonitaException
permissionService.checkAPICallWithScript("plop", new APICallContext(), false);
}

@Test
public void should_resume_call_start() throws SBonitaException {
//when
permissionService.resume();
//then
verify(permissionService).start();
}

@Test
public void should_pause_call_stop() throws SBonitaException {
//given
permissionService.start();

//when
permissionService.pause();

//then
verify(permissionService).stop();
}

@Test
public void should_pause_call_stop_tow_times() {
//when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,7 @@ public void resume_should_throw_UpdateException_on_a_deactivated_tenant() throws
}

@Test
public void pause_should_delete_sessions() throws Exception {
whenTenantIsInState(STenant.ACTIVATED);
doReturn(okFuture()).when(broadcastService).executeOnOthersAndWait(any(), eq(TENANT_ID));

tenantStateManager.pause();

verify(sessionService).deleteSessionsOfTenantExceptTechnicalUser(TENANT_ID);
}

@Test
public void resume_should_delete_sessions() throws Exception {
public void resume_should_not_delete_sessions() throws Exception {
whenTenantIsInState(STenant.PAUSED);
doReturn(okFuture()).when(broadcastService).executeOnOthersAndWait(any(), eq(TENANT_ID));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,6 @@ private void destroyAllLocalClassLoaders() {
classLoaders.clear();
}

@Override
public void pause() {
}

@Override
public void resume() {
}

@Override
public boolean addListener(ClassLoaderIdentifier identifier, SingleClassLoaderListener singleClassLoaderListener) {
log.debug("Added listener {} on {}", singleClassLoaderListener, identifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,4 @@ private Map<String, CommandDeployment> toCommandDeploymentMap(List<CommandDeploy
return map;
}

@Override
public void stop() throws SBonitaException {
// nothing to do
}

@Override
public void pause() throws SBonitaException {
// nothing to do
}

@Override
public void resume() throws SBonitaException {
// nothing to do
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,4 @@ public void stop() {
}
}

@Override
public void pause() {

}

@Override
public void resume() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ public synchronized void start() {
}
}

@Override
public synchronized void pause() throws SWorkException {
}

@Override
public synchronized void resume() {
start();
Expand Down

0 comments on commit e0d6af7

Please sign in to comment.