ExportJob.java revision f0a048d41a13eca4cba405da9403c2469ca3d1ea
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
* Portions Copyright 2012-2015 ForgeRock AS.
*/
/**
* Export a JE backend to LDIF.
*/
class ExportJob
{
/**
* The requested LDIF export configuration.
*/
private final LDIFExportConfig exportConfig;
/**
* The number of milliseconds between job progress reports.
*/
private final long progressInterval = 10000;
/**
* The current number of entries exported.
*/
private long exportedCount;
/**
* The current number of entries skipped.
*/
private long skippedCount;
/**
* Create a new export job.
*
* @param exportConfig The requested LDIF export configuration.
*/
{
this.exportConfig = exportConfig;
}
/**
* Export entries from the backend to an LDIF file.
* @param rootContainer The root container to export.
* @throws StorageRuntimeException If an error occurs in the database.
* @throws IOException If an I/O error occurs while writing an entry.
* @throws LDIFException If an error occurs while trying to determine whether
* to write an entry.
*/
{
{
// Skip containers that are not covered by the include branches.
{
}
else
{
{
{
break;
}
}
}
}
// Make a note of the time we started.
// Start a timer for the progress report.
// Iterate through the containers.
try
{
{
{
{
if (exportConfig.isCancelled())
{
break;
}
try
{
}
finally
{
}
}
return null;
}
});
}
catch (Exception e)
{
throw new StorageRuntimeException(e);
}
finally
{
}
float rate = 0;
if (totalTime > 0)
{
}
}
/**
* Export the entries in a single entry entryContainer, in other words from
* one of the base DNs.
* @param entryContainer The entry container that holds the entries to be
* exported.
* @throws StorageRuntimeException If an error occurs in the database.
* @throws IOException If an error occurs while writing an entry.
* @throws LDIFException If an error occurs while trying to determine
* whether to write an entry.
*/
{
try
{
{
if (exportConfig.isCancelled())
{
break;
}
try
{
}
catch (Exception e)
{
if (logger.isTraceEnabled())
{
logger.traceException(e);
}
skippedCount++;
continue;
}
{
// This is the stored entry count.
continue;
}
try
{
}
catch (Exception e)
{
if (logger.isTraceEnabled())
{
logger.traceException(e);
}
skippedCount++;
continue;
}
{
}
else
{
skippedCount++;
}
}
}
finally
{
}
}
/**
* This class reports progress of the export job at fixed intervals.
*/
private class ProgressTask extends TimerTask
{
/**
* The number of entries that had been exported at the time of the
* previous progress report.
*/
private long previousCount;
/**
* The time in milliseconds of the previous progress report.
*/
private long previousTime;
/**
* Create a new export progress task.
*/
public ProgressTask()
{
}
/**
* The action to be performed by this timer task.
*/
public void run()
{
long latestCount = exportedCount;
if (deltaTime == 0)
{
return;
}
}
}
}