Search in sources :

Example 16 with Semaphore

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");
}
Also used : Semaphore(com.swiftmq.tools.concurrent.Semaphore) EntityRemoveException(com.swiftmq.mgmt.EntityRemoveException)

Example 17 with Semaphore

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");
}
Also used : Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Example 18 with Semaphore

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");
}
Also used : Semaphore(com.swiftmq.tools.concurrent.Semaphore) File(java.io.File) Date(java.util.Date)

Example 19 with Semaphore

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");
}
Also used : Close(com.swiftmq.impl.store.standard.cache.po.Close) Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Example 20 with Semaphore

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");
}
Also used : Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Aggregations

Semaphore (com.swiftmq.tools.concurrent.Semaphore)149 MsgNoVerifier (jms.base.MsgNoVerifier)18 IOException (java.io.IOException)8 SwiftletException (com.swiftmq.swiftlet.SwiftletException)6 ArrayList (java.util.ArrayList)6 CommitLogRecord (com.swiftmq.impl.store.standard.log.CommitLogRecord)5 DataStreamOutputStream (com.swiftmq.tools.util.DataStreamOutputStream)5 List (java.util.List)5 StartBackup (com.swiftmq.impl.store.standard.backup.po.StartBackup)2 StartShrink (com.swiftmq.impl.store.standard.cache.po.StartShrink)2 UnknownHostException (java.net.UnknownHostException)2 POAttachDurableConsumer (com.swiftmq.amqp.v100.client.po.POAttachDurableConsumer)1 POAuthenticate (com.swiftmq.amqp.v100.client.po.POAuthenticate)1 POCloseLink (com.swiftmq.amqp.v100.client.po.POCloseLink)1 POOpen (com.swiftmq.amqp.v100.client.po.POOpen)1 POProtocolRequest (com.swiftmq.amqp.v100.client.po.POProtocolRequest)1 POSendClose (com.swiftmq.amqp.v100.client.po.POSendClose)1 POSendMessage (com.swiftmq.amqp.v100.client.po.POSendMessage)1 AddressString (com.swiftmq.amqp.v100.generated.messaging.message_format.AddressString)1 Header (com.swiftmq.amqp.v100.generated.messaging.message_format.Header)1