com.rapid7.armor.xact.XactError Maven / Gradle / Ivy
The newest version!
package com.rapid7.armor.xact;
public class XactError extends RuntimeException {
private static final long serialVersionUID = 887665872580865041L;
private ArmorXact armorTransaction;
private DistXactRecord baseline;
private String errorMsg;
public XactError(String message) {
super(message);
errorMsg = message;
}
public XactError(ArmorXact armorTransaction, DistXactRecord baseline) {
this.armorTransaction = armorTransaction;
this.baseline = baseline;
if (baseline.getCurrent().equalsIgnoreCase(armorTransaction.getTarget()))
errorMsg = "The baseline transaction " + baseline.getCurrent() + " equals the targeted transaction " + armorTransaction.getTarget();
if (baseline.getPrevious() != null && baseline.getPrevious().equalsIgnoreCase(armorTransaction.getTarget()))
errorMsg = "The baseline transaction + " + baseline.getCurrent() + " equals the previous transaction " + baseline.getPrevious();
// Check the baseline MUST match current
if (!baseline.getCurrent().equalsIgnoreCase(armorTransaction.getBaseline()))
// Is this auto, in which case tone it down the message.
if (baseline.getAutoCurrent()) {
errorMsg = "The transaction " + armorTransaction.getTarget() + "at epoch " + armorTransaction.getTime() +
" has a baseline transaction of " + armorTransaction.getBaseline() +
". The stored basline " + baseline.getCurrent() + " was autogenerated most likely because it is a new table." +
"However another process already wrote to it. This error should go away, if it persists on the same target (table, shard) then investigate.";
} else {
// Else legit issue
errorMsg = "The transaction " + armorTransaction.getTarget() + "at epoch " + armorTransaction.getTime() +
" has a baseline transaction of " + armorTransaction.getBaseline() +
" that doesn't match the stored baseline of " + baseline.getCurrent() +
", another process already has written to it, verify locking is correct";
}
}
public ArmorXact getArmorXact() {
return armorTransaction;
}
public DistXactRecord getBaseline() {
return baseline;
}
@Override
public String getMessage() {
return errorMsg;
}
}