private boolean recoveryIndexFromCoordinator() throws FileNotFoundException, RepositoryException, IOException,
SuspendException
{
try
{
IndexRecovery indexRecovery = handler.getContext().getIndexRecovery();
// check if index not ready
if (!indexRecovery.checkIndexReady())
{
return false;
}
indexRecovery.setIndexOffline();
File indexDirectory = new File(handler.getContext().getIndexDirectory());
for (String filePath : indexRecovery.getIndexList())
{
File indexFile = new File(indexDirectory, filePath);
if (!PrivilegedFileHelper.exists(indexFile.getParentFile()))
{
PrivilegedFileHelper.mkdirs(indexFile.getParentFile());
}
// transfer file
InputStream in = indexRecovery.getIndexFile(filePath);
OutputStream out = PrivilegedFileHelper.fileOutputStream(indexFile);
try
{
byte[] buf = new byte[2048];
int len;
while ((len = in.read(buf)) > 0)
{
out.write(buf, 0, len);
}
}
finally
{
if (in != null)
{
in.close();
}
if (out != null)
{
out.close();
}
}
indexRecovery.setIndexOnline();
}
}
finally
{
}