// increment generation
generation++;
String newName = getFileName();
boolean success = false;
try {
OutputStream out = new IndexOutputStream(
directory.createOutput(newName));
try {
log.debug("Writing IndexInfos {}", newName);
DataOutputStream dataOut = new DataOutputStream(out);
dataOut.writeInt(WITH_GENERATION);
dataOut.writeInt(counter);
dataOut.writeInt(indexes.size());
for (Iterator it = iterator(); it.hasNext(); ) {
IndexInfo info = (IndexInfo) it.next();
dataOut.writeUTF(info.getName());
dataOut.writeLong(info.getGeneration());
log.debug(" + {}:{}", info.getName(), info.getGeneration());
}
} finally {
out.close();
}
lastModified = System.currentTimeMillis();
success = true;
} finally {
if (!success) {