use of org.apache.jackrabbit.core.cluster.ClusterException in project jackrabbit by apache.
the class ConsistencyCheckerImpl method repair.
/**
* Repair any errors found during a {@link #check}. Should be run after a {#check} and
* (if needed) {@link #doubleCheckErrors}.
*
* @throws RepositoryException
*/
public void repair() throws RepositoryException {
checkLostNFound();
bundles = new HashMap<NodeId, NodePropBundle>();
if (hasRepairableErrors()) {
boolean successful = false;
final CheckerUpdate update = new CheckerUpdate();
try {
eventChannel.updateCreated(update);
for (ConsistencyCheckerError error : errors) {
if (error.isRepairable()) {
try {
error.repair(update.getChanges());
info(null, "Repairing " + error);
} catch (ItemStateException e) {
error(null, "Failed to repair error: " + error, e);
}
}
}
final ChangeLog changes = update.getChanges();
if (changes.hasUpdates()) {
eventChannel.updatePrepared(update);
for (NodePropBundle bundle : bundles.values()) {
storeBundle(bundle);
}
update.setAttribute(ATTRIBUTE_UPDATE_SIZE, changes.getUpdateSize());
successful = true;
}
} catch (ClusterException e) {
throw new RepositoryException("Cannot create update", e);
} finally {
if (successful) {
eventChannel.updateCommitted(update, "checker@");
} else {
eventChannel.updateCancelled(update);
}
}
}
}
use of org.apache.jackrabbit.core.cluster.ClusterException in project jackrabbit by apache.
the class ConsistencyCheck method doubleCheckErrors.
public void doubleCheckErrors() {
if (!errors.isEmpty()) {
log.info("Double checking errors");
final ClusterNode clusterNode = handler.getContext().getClusterNode();
if (clusterNode != null) {
try {
clusterNode.sync();
} catch (ClusterException e) {
log.error("Could not sync cluster node for double checking errors");
}
}
final Iterator<ConsistencyCheckError> iterator = errors.iterator();
while (iterator.hasNext()) {
try {
final ConsistencyCheckError error = iterator.next();
if (!error.doubleCheck(handler, stateMgr)) {
log.info("False positive: " + error.toString());
iterator.remove();
}
} catch (RepositoryException e) {
log.error("Failed to double check consistency error", e);
} catch (IOException e) {
log.error("Failed to double check consistency error", e);
}
}
}
}
Aggregations