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 class
RandomDocumentMessageProducer.DocType
-
Field Summary
Fields Modifier and Type Field Description protected BlobInfoFetcher
blobInfoFetcher
protected boolean
blobOnlyText
protected int
blobSizeKB
protected Set<String>
children
protected boolean
countFolderAsDocument
protected RandomDocumentMessageProducer.DocType
currentType
protected static String[]
DC_COVERAGE
protected static String[]
DC_LANGUAGE
protected static String[]
DC_NATURE
protected static String[]
DC_RIGHTS
protected static String[]
DC_SOURCE
protected static String[]
DC_SUBJECTS
protected int
documentCount
protected int
documentInCurrentFolderCount
protected int
documentInCurrentFolderLimit
protected int
folderCount
protected List<String>
folderishChildren
protected int
foldersInCurrentFolderLimit
protected static RandomTextGenerator
gen
protected int
maxDocumentsPerFolder
protected int
maxFoldersPerFolder
protected long
nbDocuments
protected int
parentIndex
protected List<String>
parents
protected Random
rand
-
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:ProducerIterator
Returns 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:
close
in interfaceAutoCloseable
- Overrides:
close
in classAbstractProducer<DocumentMessage>
- Throws:
Exception
-
-