mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 18:43:26 +01:00
Add manager context to CleanupMaid to allow management service access in cleanup() method
This commit is contained in:
parent
f57fc2beb7
commit
824f0586f7
@ -164,12 +164,14 @@ public class CheckPointManagerImpl implements CheckPointManager, Manager, Cluste
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public long pushCheckPoint(CleanupMaid context) {
|
||||
long seq = _maidDao.pushCleanupDelegate(_msId, 0, context.getClass().getName(), context);
|
||||
return seq;
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public void updateCheckPointState(long taskId, CleanupMaid updatedContext) {
|
||||
CheckPointVO task = _maidDao.createForUpdate();
|
||||
task.setDelegate(updatedContext.getClass().getName());
|
||||
@ -178,6 +180,7 @@ public class CheckPointManagerImpl implements CheckPointManager, Manager, Cluste
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public void popCheckPoint(long taskId) {
|
||||
_maidDao.remove(taskId);
|
||||
}
|
||||
@ -187,7 +190,7 @@ public class CheckPointManagerImpl implements CheckPointManager, Manager, Cluste
|
||||
CleanupMaid delegate = (CleanupMaid)SerializerHelper.fromSerializedString(task.getContext());
|
||||
assert delegate.getClass().getName().equals(task.getDelegate()) : "Deserializer says " + delegate.getClass().getName() + " but it's suppose to be " + task.getDelegate();
|
||||
|
||||
int result = delegate.cleanup();
|
||||
int result = delegate.cleanup(this);
|
||||
if (result <= 0) {
|
||||
if (result == 0) {
|
||||
s_logger.info("Successfully cleaned up " + task.getId());
|
||||
|
||||
@ -33,7 +33,7 @@ public interface CleanupMaid {
|
||||
* indicates the cleanup was unsuccessful but don't retry. Positive number
|
||||
* indicates the cleanup was unsuccessful and retry in this many seconds.
|
||||
*/
|
||||
int cleanup();
|
||||
int cleanup(CheckPointManager checkPointMgr);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -216,7 +216,7 @@ public class CheckPointManagerTest extends TestCase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int cleanup() {
|
||||
public int cleanup(CheckPointManager checkPointMgr) {
|
||||
s_logger.debug("Cleanup called for " + seq);
|
||||
map.remove(seq);
|
||||
return canBeCleanup ? 0 : -1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user