Search in sources :

Example 91 with Semaphore

use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.

the class BackupProcessor method visit.

public void visit(ChangePath po) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.storeSwiftlet.getName(), toString() + "/" + po + " ...");
    if (backupActive) {
        // reject it
        po.setException("Can't change Path: another Backup is active right now!");
        po.setSuccess(false);
    } else {
        po.setSuccess(true);
        path = SwiftUtilities.addWorkingDir(po.getNewPath());
    }
    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 92 with Semaphore

use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.

the class Scheduler method close.

public void close() {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.schedulerSwiftlet.getName(), toString() + "/close ...");
    Semaphore sem = new Semaphore();
    pipelineQueue.enqueue(new Close(sem));
    sem.waitHere();
    pipelineQueue.close();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.schedulerSwiftlet.getName(), toString() + "/close done");
}
Also used : Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Example 93 with Semaphore

use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.

the class SchedulerSwiftletImpl method removeTemporarySchedule.

public boolean removeTemporarySchedule(String name) {
    boolean rc = false;
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(getName(), "removeTemporarySchedule, name=" + name + " ...");
    Semaphore sem = new Semaphore();
    ScheduleRemoved po = new ScheduleRemoved(name, sem);
    ctx.scheduler.enqueue(po);
    sem.waitHere(1000);
    rc = po.isSuccess();
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(getName(), "removeTemporarySchedule, name=" + name + " done (rc=" + rc + ")");
    return rc;
}
Also used : Semaphore(com.swiftmq.tools.concurrent.Semaphore) ScheduleRemoved(com.swiftmq.impl.scheduler.standard.po.ScheduleRemoved)

Example 94 with Semaphore

use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.

the class RootIndex method getQueueIndex.

public synchronized QueueIndex getQueueIndex(String queueName) throws Exception {
    IndexEntry entry = find(queueName);
    if (entry == null) {
        Semaphore sem = new Semaphore();
        List journal = new ArrayList();
        setJournal(journal);
        QueueIndexPage indexPage = new QueueIndexPage(ctx, -1);
        journal.add(new InsertLogAction(indexPage.getPage().pageNo));
        indexPage.setJournal(journal);
        indexPage.setPrevPage(-1);
        indexPage.setNextPage(-1);
        entry = new RootIndexEntry();
        entry.setKey(queueName);
        entry.setRootPageNo(indexPage.getPage().pageNo);
        add(entry);
        long txId = ctx.transactionManager.createTxId();
        CommitLogRecord logRecord = new CommitLogRecord(txId, sem, journal, new IndexPageRelease(this, indexPage), null);
        ctx.recoveryManager.commit(logRecord);
        sem.waitHere();
        ctx.transactionManager.removeTxId(txId);
    } else
        unloadPages();
    return new QueueIndex(ctx, entry.getRootPageNo());
}
Also used : CommitLogRecord(com.swiftmq.impl.store.standard.log.CommitLogRecord) ArrayList(java.util.ArrayList) InsertLogAction(com.swiftmq.impl.store.standard.log.InsertLogAction) List(java.util.List) ArrayList(java.util.ArrayList) Semaphore(com.swiftmq.tools.concurrent.Semaphore)

Example 95 with Semaphore

use of com.swiftmq.tools.concurrent.Semaphore in project swiftmq-ce by iitsoftware.

the class BackupJob method start.

public synchronized void start(Properties properties, JobTerminationListener jobTerminationListener) throws JobException {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.storeSwiftlet.getName(), toString() + "/start, properties=" + properties + " ...");
    this.jobTerminationListener = jobTerminationListener;
    this.properties = properties;
    Semaphore sem = new Semaphore();
    StartBackup po = new StartBackup(sem, this);
    ctx.backupProcessor.enqueue(po);
    sem.waitHere();
    if (!po.isSuccess())
        jobTerminationListener.jobTerminated(new JobException(po.getException(), new Exception(po.getException()), false));
}
Also used : JobException(com.swiftmq.swiftlet.scheduler.JobException) Semaphore(com.swiftmq.tools.concurrent.Semaphore) StartBackup(com.swiftmq.impl.store.standard.backup.po.StartBackup) JobException(com.swiftmq.swiftlet.scheduler.JobException)

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