Class RandomDocumentMessageProducer
- java.lang.Object
-
- org.nuxeo.lib.stream.pattern.producer.AbstractProducer<DocumentMessage>
-
- org.nuxeo.importer.stream.producer.RandomDocumentMessageProducer
-
- All Implemented Interfaces:
AutoCloseable,Iterator<DocumentMessage>,ProducerIterator<DocumentMessage>
public class RandomDocumentMessageProducer extends AbstractProducer<DocumentMessage>
- Since:
- 9.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classRandomDocumentMessageProducer.DocType
-
Field Summary
Fields Modifier and Type Field Description protected BlobInfoFetcherblobInfoFetcherprotected booleanblobOnlyTextprotected intblobSizeKBprotected Set<String>childrenprotected booleancountFolderAsDocumentprotected RandomDocumentMessageProducer.DocTypecurrentTypeprotected static String[]DC_COVERAGEprotected static String[]DC_LANGUAGEprotected static String[]DC_NATUREprotected static String[]DC_RIGHTSprotected static String[]DC_SOURCEprotected static String[]DC_SUBJECTSprotected intdocumentCountprotected intdocumentInCurrentFolderCountprotected intdocumentInCurrentFolderLimitprotected intfolderCountprotected List<String>folderishChildrenprotected intfoldersInCurrentFolderLimitprotected static RandomTextGeneratorgenprotected intmaxDocumentsPerFolderprotected intmaxFoldersPerFolderprotected longnbDocumentsprotected intparentIndexprotected List<String>parentsprotected Randomrand-
Fields inherited from class org.nuxeo.lib.stream.pattern.producer.AbstractProducer
producerId
-
-
Constructor Summary
Constructors Constructor Description RandomDocumentMessageProducer(int producerId, long nbDocuments, String lang, BlobInfoFetcher blobInfoFetcher)
-
Method Summary
-
Methods inherited from class org.nuxeo.lib.stream.pattern.producer.AbstractProducer
getProducerId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Methods inherited from interface org.nuxeo.lib.stream.pattern.producer.ProducerIterator
remove
-
-
-
-
Field Detail
-
nbDocuments
protected final long nbDocuments
-
blobInfoFetcher
protected final BlobInfoFetcher blobInfoFetcher
-
countFolderAsDocument
protected boolean countFolderAsDocument
-
maxFoldersPerFolder
protected int maxFoldersPerFolder
-
maxDocumentsPerFolder
protected int maxDocumentsPerFolder
-
blobSizeKB
protected int blobSizeKB
-
blobOnlyText
protected boolean blobOnlyText
-
documentCount
protected int documentCount
-
folderCount
protected int folderCount
-
rand
protected final Random rand
-
gen
protected static RandomTextGenerator gen
-
DC_NATURE
protected static final String[] DC_NATURE
-
DC_SUBJECTS
protected static final String[] DC_SUBJECTS
-
DC_RIGHTS
protected static final String[] DC_RIGHTS
-
DC_LANGUAGE
protected static final String[] DC_LANGUAGE
-
DC_SOURCE
protected static final String[] DC_SOURCE
-
DC_COVERAGE
protected static final String[] DC_COVERAGE
-
foldersInCurrentFolderLimit
protected int foldersInCurrentFolderLimit
-
documentInCurrentFolderLimit
protected int documentInCurrentFolderLimit
-
currentType
protected RandomDocumentMessageProducer.DocType currentType
-
parentIndex
protected int parentIndex
-
documentInCurrentFolderCount
protected int documentInCurrentFolderCount
-
-
Constructor Detail
-
RandomDocumentMessageProducer
public RandomDocumentMessageProducer(int producerId, long nbDocuments, String lang, BlobInfoFetcher blobInfoFetcher)
-
-
Method Detail
-
setMaxFoldersPerFolder
public RandomDocumentMessageProducer setMaxFoldersPerFolder(int max)
-
setMaxDocumentsPerFolder
public RandomDocumentMessageProducer setMaxDocumentsPerFolder(int max)
-
countFolderAsDocument
public RandomDocumentMessageProducer countFolderAsDocument(boolean value)
-
withBlob
public RandomDocumentMessageProducer withBlob(int sizeKB, boolean onlyText)
-
getPartition
public int getPartition(DocumentMessage message, int partitions)
Description copied from interface:ProducerIteratorReturns a partition associated with theMessage. The value returned must be between 0 and lower than partitions.- Parameters:
message- the message to shardpartitions- the number of partitions
-
hasNext
public boolean hasNext()
-
next
public DocumentMessage next()
-
createRoot
protected DocumentMessage createRoot()
-
createFolder
protected DocumentMessage createFolder(String parentPath, Set<String> exclude)
-
createDocument
protected DocumentMessage createDocument(String parentPath, Set<String> exclude)
-
getRandomNodeWithExclusion
protected DocumentMessage getRandomNodeWithExclusion(String type, String parentPath, boolean withBlob, Set<String> exclude)
-
getRandomNode
protected DocumentMessage getRandomNode(String type, String parentPath, boolean withBlob)
-
getRandomNodeWithPrefix
protected DocumentMessage getRandomNodeWithPrefix(String prefix, String type, String parentPath)
-
getRandomBlob
protected Blob getRandomBlob()
-
getBlobMimeType
protected String getBlobMimeType()
-
getTitle
protected String getTitle()
-
getRandomProperties
protected HashMap<String,Serializable> getRandomProperties(String title)
-
close
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classAbstractProducer<DocumentMessage>- Throws:
Exception
-
-