mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-17 19:14:40 +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
|
@Override
|
||||||
|
@DB
|
||||||
public long pushCheckPoint(CleanupMaid context) {
|
public long pushCheckPoint(CleanupMaid context) {
|
||||||
long seq = _maidDao.pushCleanupDelegate(_msId, 0, context.getClass().getName(), context);
|
long seq = _maidDao.pushCleanupDelegate(_msId, 0, context.getClass().getName(), context);
|
||||||
return seq;
|
return seq;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@DB
|
||||||
public void updateCheckPointState(long taskId, CleanupMaid updatedContext) {
|
public void updateCheckPointState(long taskId, CleanupMaid updatedContext) {
|
||||||
CheckPointVO task = _maidDao.createForUpdate();
|
CheckPointVO task = _maidDao.createForUpdate();
|
||||||
task.setDelegate(updatedContext.getClass().getName());
|
task.setDelegate(updatedContext.getClass().getName());
|
||||||
@ -178,6 +180,7 @@ public class CheckPointManagerImpl implements CheckPointManager, Manager, Cluste
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@DB
|
||||||
public void popCheckPoint(long taskId) {
|
public void popCheckPoint(long taskId) {
|
||||||
_maidDao.remove(taskId);
|
_maidDao.remove(taskId);
|
||||||
}
|
}
|
||||||
@ -187,7 +190,7 @@ public class CheckPointManagerImpl implements CheckPointManager, Manager, Cluste
|
|||||||
CleanupMaid delegate = (CleanupMaid)SerializerHelper.fromSerializedString(task.getContext());
|
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();
|
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) {
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
s_logger.info("Successfully cleaned up " + task.getId());
|
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 but don't retry. Positive number
|
||||||
* indicates the cleanup was unsuccessful and retry in this many seconds.
|
* 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
|
@Override
|
||||||
public int cleanup() {
|
public int cleanup(CheckPointManager checkPointMgr) {
|
||||||
s_logger.debug("Cleanup called for " + seq);
|
s_logger.debug("Cleanup called for " + seq);
|
||||||
map.remove(seq);
|
map.remove(seq);
|
||||||
return canBeCleanup ? 0 : -1;
|
return canBeCleanup ? 0 : -1;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user