use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.
the class Scheduler method visit.
public void visit(ScheduleRemoved po) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.schedulerSwiftlet.getName(), toString() + "/" + po + " ...");
Entry scheduleEntry = (Entry) schedules.remove(po.getName());
if (scheduleEntry != null) {
po.setSuccess(true);
stopSchedule(scheduleEntry);
try {
if (po.isMessageSchedule()) {
scheduleEntry.entity.setState(DONOTHING);
ctx.activeMessageScheduleList.removeEntity(scheduleEntry.entity);
} else
ctx.activeScheduleList.removeEntity(scheduleEntry.entity);
} catch (EntityRemoveException e) {
}
} else
po.setSuccess(false);
Semaphore sem = po.getSemaphore();
if (sem != null)
sem.notifySingleWaiter();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.schedulerSwiftlet.getName(), toString() + "/" + po + " done");
}
use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.
the class BackupProcessor method visit.
public void visit(ChangeGenerations po) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.storeSwiftlet.getName(), toString() + "/" + po + " ...");
if (backupActive) {
// reject it
po.setException("Can't change Generations: another Backup is active right now!");
po.setSuccess(false);
} else {
po.setSuccess(true);
generations = po.getNewGenerations();
}
Semaphore sem = po.getSemaphore();
if (sem != null)
sem.notifySingleWaiter();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.storeSwiftlet.getName(), toString() + "/" + po + " done");
}
use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.
the class BackupProcessor method visit.
public void visit(StartBackup po) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.storeSwiftlet.getName(), toString() + "/" + po + " ...");
if (backupActive) {
// reject it
String msg = "Can't start Backup: another Backup is active right now!";
po.setException(msg);
po.setSuccess(false);
BackupFinishedListener l = po.getFinishedListener();
if (l != null)
l.backupFinished(false, msg);
ctx.logSwiftlet.logError(ctx.storeSwiftlet.getName(), toString() + "/" + msg);
} else {
// start backup
backupActive = true;
currentSaveSet = path + File.separatorChar + fmt.format(new Date());
ctx.logSwiftlet.logInformation(ctx.storeSwiftlet.getName(), toString() + "/Backup started, save set: " + currentSaveSet);
new File(currentSaveSet).mkdir();
finishedListener = po.getFinishedListener();
po.setSuccess(true);
ctx.transactionManager.initiateCheckPoint(this);
}
Semaphore sem = po.getSemaphore();
if (sem != null)
sem.notifySingleWaiter();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.storeSwiftlet.getName(), toString() + "/" + po + " done");
}
use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.
the class ShrinkProcessor method close.
public void close() {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.storeSwiftlet.getName(), toString() + "/close ...");
Semaphore sem = new Semaphore();
pipelineQueue.enqueue(new Close(sem));
sem.waitHere();
pipelineQueue.close();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.storeSwiftlet.getName(), toString() + "/close done");
}
use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.
the class ShrinkProcessor method visit.
public void visit(StartShrink po) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.storeSwiftlet.getName(), toString() + "/" + po + " ...");
if (shrinkActive) {
// reject it
String msg = "Can't start Shrink: another Shrink is active right now!";
po.setException(msg);
po.setSuccess(false);
} else {
shrinkActive = true;
ctx.transactionManager.initiateCheckPoint(this);
po.setSuccess(true);
}
Semaphore sem = po.getSemaphore();
if (sem != null)
sem.notifySingleWaiter();
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.storeSwiftlet.getName(), toString() + "/" + po + " done");
}
Aggregations