* Return null in failure.
*/
public List<String> getDumpPathListForRestore(int diskId)
{
assert currGen_ != null;
ProfileGeneration currGen = currGen_;
logger_.info
(String.format
("------------------------------------------------------\n" +
"getDumpPathListForRestore start for diskID %d.\n" +
"------------------------------------------------------\n",
diskId));
/* Initialize */
LinkedList<String> ret = new LinkedList<String>();
String uuid = currGen.getUuid(diskId);
/* Check the generation backup succeeded. */
if (currGen.isVmdkdumpSucceeded(diskId) == false) {
logger_.warning
(String.format
("Skipping: " +
"generation %d disk %d (%s) is marked FAILED.\n",
currGen.getGenerationId(), diskId, currGen.getUuid(diskId)));
return null;
}
/* Does this generation have the full dump */
String dumpPath;
dumpPath = currGen.getDumpOutPath(diskId);
logger_.info(String.format("dumpPath: %s\n", dumpPath));
if (currGen.isDumpOutExist(diskId)) {
ret.add(dumpPath);
return ret;
}
/* There is no dump of the current generation,
so search corresponding dump in newer generations. */
assert ret.isEmpty();
String rdiffPath;
boolean isFirstElementDump = false;
ProfileGeneration next = this.getNextGeneration();
while (next != null) {
/* Get nextDiskId */
int nextDiskId = next.getDiskIdWithUuid(uuid);
if (nextDiskId < 0) {
logger_.warning("diskId is invalid."); /* debug */
return null;
}
/* Check the vmdk backup succeeded. */
if (next.isVmdkdumpSucceeded(nextDiskId) == false) {
logger_.warning
(String.format
("backup of vmdk with diskId %d is failed.",
nextDiskId));
return null;
}
dumpPath = next.getDumpOutPath(nextDiskId);
rdiffPath = next.getRdiffOutPath(nextDiskId);
logger_.info
(String.format
("dumpPath: %s\n" + "rdiffPath: %s\n",
dumpPath, rdiffPath));
boolean notFoundFile = true;
if (next.isRdiffOutExist(nextDiskId)) {
/* Rdiff file is found. */
ret.addFirst(FormatString.toQuatedString(rdiffPath));
notFoundFile = false;
}
if (next.isDumpOutExist(nextDiskId)) {
/* Dump file is found. */
ret.addFirst(FormatString.toQuatedString(dumpPath));
isFirstElementDump = true;
break;
}
if (next.isChanged(nextDiskId) == false) {
/* The vmdk is not changed at all in This generation.
This generation may have none of dump, digest, and rdiff.
Just skip. */
notFoundFile = false;
}
if (notFoundFile) {
/* Error. */
logger_.warning
(String.format
("Error: neither dump nor rdiff is available in " +
" generation %d\n", next.getGenerationId()));
return null;
}
next = this.getNextGeneration(next.getGenerationId());
}
if (isFirstElementDump == false) {
logger_.warning
(String.format("isFirstElementDump is false."));