/**
* {@inheritDoc}
*/
public void report(ProfileReport profileReport) {
// get the access detail, or return if there is none available
AccessedObjectsDetail detail = profileReport.getAccessedObjectsDetail();
if (detail == null) {
return;
}
// if a backlog is in use, then store the new detail
TransactionId txnId = null;
if (backlogMap != null) {
txnId = new TransactionId(profileReport.getTransactionId());
backlogMap.put(txnId, detail);
}
// if there was conflict, then figure out what to display
if (detail.getConflictType() != ConflictType.NONE) {
if (txnId == null) {
txnId = new TransactionId(profileReport.getTransactionId());
}
// print out the detail for the failed transaction
System.out.printf("Task type %s failed due to conflict. Details:"
+ "%n accessor id: %s, try count %d; objects "
+ "accessed ordered by first access:%n%s"
+ "conflict type: %s%n",
profileReport.getTask().getBaseTaskType(),
txnId, profileReport.getRetryCount(),
formatAccesses(detail.getAccessedObjects()),
detail.getConflictType());
// see if the conflicting transaction is known, otherwise we've
// shown all the detail we know
byte [] conflictingBytes = detail.getConflictingId();
if (conflictingBytes == null) {
System.out.printf("%n");
return;
}
TransactionId conflictingId = new TransactionId(conflictingBytes);
// if we're keeping a backlog, look through it to see if we
// have the detail on the conflicting id
if (backlogMap != null) {
// look to see if we know about the conflicting transaction,
// and add the new detail to the backlog
AccessedObjectsDetail conflictingDetail =
backlogMap.get(conflictingId);
// if we found the conflicting detail, display it and return
if (conflictingDetail != null) {
System.out.printf("Conflicting transaction id: %s, objects"
+ " accessed, ordered by first access:"
+ "%n%s%n", conflictingId,
formatAccesses(conflictingDetail.
getAccessedObjects()));
return;
}
}