use of org.apache.accumulo.server.manager.recovery.LogCloser in project accumulo by apache.
the class RecoveryManager method recoverLogs.
public boolean recoverLogs(KeyExtent extent, Collection<Collection<String>> walogs) throws IOException {
boolean recoveryNeeded = false;
for (Collection<String> logs : walogs) {
for (String walog : logs) {
Path switchedWalog = VolumeUtil.switchVolume(walog, FileType.WAL, manager.getContext().getVolumeReplacements());
if (switchedWalog != null) {
// replaces the volume used for sorting, but do not change entry in metadata table. When
// the tablet loads it will change the metadata table entry. If
// the tablet has the same replacement config, then it will find the sorted log.
log.info("Volume replaced {} -> {}", walog, switchedWalog);
walog = switchedWalog.toString();
}
String[] parts = walog.split("/");
String sortId = parts[parts.length - 1];
String filename = new Path(walog).toString();
String dest = RecoveryPath.getRecoveryPath(new Path(filename)).toString();
boolean sortQueued;
synchronized (this) {
sortQueued = sortsQueued.contains(sortId);
}
if (sortQueued && zooCache.get(manager.getZooKeeperRoot() + Constants.ZRECOVERY + "/" + sortId) == null) {
synchronized (this) {
sortsQueued.remove(sortId);
}
}
if (exists(SortedLogState.getFinishedMarkerPath(dest))) {
synchronized (this) {
closeTasksQueued.remove(sortId);
recoveryDelay.remove(sortId);
sortsQueued.remove(sortId);
}
continue;
}
recoveryNeeded = true;
synchronized (this) {
if (!closeTasksQueued.contains(sortId) && !sortsQueued.contains(sortId)) {
AccumuloConfiguration aconf = manager.getConfiguration();
@SuppressWarnings("deprecation") LogCloser closer = Property.createInstanceFromPropertyName(aconf, aconf.resolve(Property.MANAGER_WAL_CLOSER_IMPLEMENTATION, Property.MANAGER_WALOG_CLOSER_IMPLEMETATION), LogCloser.class, new HadoopLogCloser());
Long delay = recoveryDelay.get(sortId);
if (delay == null) {
delay = aconf.getTimeInMillis(Property.MANAGER_RECOVERY_DELAY);
} else {
delay = Math.min(2 * delay, 1000 * 60 * 5L);
}
log.info("Starting recovery of {} (in : {}s), tablet {} holds a reference", filename, (delay / 1000), extent);
executor.schedule(new LogSortTask(closer, filename, dest, sortId), delay, TimeUnit.MILLISECONDS);
closeTasksQueued.add(sortId);
recoveryDelay.put(sortId, delay);
}
}
}
}
return recoveryNeeded;
}
Aggregations