* @return +1 if tx was committed, 0 if tx was not committed
*/
public int increase(int retry, int wait_time)
{
int returnValue = 0;
AtomicAction a = new AtomicAction();
a.begin();
try
{
int locking_result = LockResult.REFUSED;
int locking_attempt_count = 0;
do
{
locking_result = setlock(new Lock(LockMode.WRITE), retry, wait_time);
if (locking_result == LockResult.GRANTED)
{
mValue++;
}
else
{
locking_attempt_count++;
}
if (timeOfLastWaiting < (System.currentTimeMillis() - 15000))
{
System.out.println("Thread: [" + Thread.currentThread() + "]");
timeOfLastWaiting = System.currentTimeMillis();
}
}
while ((locking_result != LockResult.GRANTED) && (locking_attempt_count < mLimit));
if (locking_result != LockResult.GRANTED)
{
qautil.qadebug("trying to get lock for " + mLimit + "th time");
a.abort();
}
else
{
a.commit();
returnValue = 1;
}
}
catch (Exception e)
{
a.abort();
qautil.debug("exception in increase method ", e);
}
return returnValue;
}