Hi guys,

I have a couple of questions regarding our team’s use of Ignite’s semaphore. 

Our team has used semaphores to throttle the number of compute jobs being
sent to the grid:
e.g. :
In ComputeTaskAdapter.map {
final IgniteSemaphore semaphore = ignite.semaphore(semaphoreName,
throttleSize, true, true);
taskSession.setAttribute(SEMAPHORE_KEY, semaphoreName);
for (ComputeJob job : jobs) {
    semaphore.acquire();
    mapper.send(job);
}
}

The semaphores are then released in ComputeJob.execute {

final String semaphoreName =
taskSession.getAttribute(AbstractComputeTaskAdapter.SEMAPHORE_KEY);
final IgniteSemaphore semaphore = semaphoreName != null ?
ignite.semaphore(semaphoreName, 0, true, false) : null;
try {
    return executeManaged();
}
finally {

    if (semaphore != null) {
        semaphore.release();
    }
    if (latch != null) {
        latch.countDown();
    }
    LOG.info(".. completed sequence #" + sequence + ": " + taskSessionId);
}
}


My question is, is this the proper use of Ignite semaphores? Is it safe to
use semaphores inside compute tasks? During my resiliency testing with this
code, it seems like the locks from semaphores don’t get released whenever I
start killing (kill -9) all but one of our server nodes.





--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Proper-use-of-ignite-semaphore-tp13509.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to