if (this.first.compareAndSet(true, false)) {
// Fire off a FindOpenSeats so that we can prime ourselves
Pair<Object[], ProcedureCallback> ret = this.getFindOpenSeatsParams();
assert(ret != null);
Object params[] = ret.getFirst();
ProcedureCallback callback = ret.getSecond();
this.getClientHandle().callProcedure(callback, Transaction.FIND_OPEN_SEATS.getExecName(), params);
}
int tries = 10;
Pair<Object[], ProcedureCallback> ret = null;
Transaction txn = null;
while (tries-- > 0 && ret == null) {
txn = this.xacts.nextValue();
if (debug.val) LOG.debug("Attempting to execute " + txn);
this.startComputeTime(txn.displayName);
try {
switch (txn) {
case DELETE_RESERVATION: {
ret = this.getDeleteReservationParams();
break;
}
case FIND_FLIGHTS: {
ret = this.getFindFlightsParams();
break;
}
case FIND_OPEN_SEATS: {
ret = this.getFindOpenSeatsParams();
break;
}
case NEW_RESERVATION: {
ret = this.getNewReservationParams();
break;
}
case UPDATE_CUSTOMER: {
ret = this.getUpdateCustomerParams();
break;
}
case UPDATE_RESERVATION: {
ret = this.getUpdateReservationParams();
break;
}
default:
assert(false) : "Unexpected transaction: " + txn;
} // SWITCH
} finally {
this.stopComputeTime(txn.displayName);
}
if (ret != null && debug.val) LOG.debug("Executed a new invocation of " + txn);
}
if (ret != null) {
Object params[] = ret.getFirst();
ProcedureCallback callback = ret.getSecond();
this.getClientHandle().callProcedure(callback, txn.getExecName(), params);
}
if (tries == 0 && debug.val) LOG.warn("I have nothing to do!");
return (tries > 0);