| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.tools.makeldif; |
| | | |
| | |
| | | import java.util.concurrent.LinkedBlockingQueue; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.util.LDIFException; |
| | | import org.opends.server.util.LDIFWriter; |
| | |
| | | private LDIFWriter ldifWriter; |
| | | |
| | | // The queue used to hold generated entries until they can be read. |
| | | private LinkedBlockingQueue<Entry> entryQueue; |
| | | private LinkedBlockingQueue<TemplateEntry> entryQueue; |
| | | |
| | | // The background thread being used to actually generate the entries. |
| | | private MakeLDIFInputStreamThread generatorThread; |
| | |
| | | |
| | | allGenerated = false; |
| | | closed = false; |
| | | entryQueue = new LinkedBlockingQueue<Entry>(10); |
| | | entryQueue = new LinkedBlockingQueue<TemplateEntry>(10); |
| | | ioException = null; |
| | | entryBytes = null; |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public boolean writeEntry(Entry entry) |
| | | public boolean writeEntry(TemplateEntry entry) |
| | | throws IOException, MakeLDIFException |
| | | { |
| | | while (! closed) |
| | |
| | | */ |
| | | private boolean getNextEntry() |
| | | { |
| | | Entry entry = entryQueue.poll(); |
| | | TemplateEntry entry = entryQueue.poll(); |
| | | while (entry == null) |
| | | { |
| | | if (closed) |
| | |
| | | try |
| | | { |
| | | entryOutputStream.reset(); |
| | | ldifWriter.writeEntry(entry); |
| | | ldifWriter.writeTemplateEntry(entry); |
| | | ldifWriter.flush(); |
| | | entryBytes = ByteBuffer.wrap(entryOutputStream.toByteArray()); |
| | | } |