Search in sources :

Example 1 with DescriptiveThreadFactory

use of org.uberfire.commons.async.DescriptiveThreadFactory in project kie-wb-common by kiegroup.

the class IndexingTest method ioService.

protected IOService ioService() {
    if (ioService == null) {
        final Map<String, Analyzer> analyzers = getAnalyzers();
        MetadataConfigBuilder configBuilder = new MetadataConfigBuilder().withInMemoryMetaModelStore().usingAnalyzers(analyzers).usingAnalyzerWrapperFactory(getAnalyzerWrapperFactory()).useInMemoryDirectory().useDirectoryBasedIndex();
        if (config == null) {
            config = configBuilder.build();
        }
        ExecutorService executorService = Executors.newCachedThreadPool(new DescriptiveThreadFactory());
        ioService = new IOServiceIndexedImpl(config.getIndexEngine(), executorService);
        final TestIndexer indexer = getIndexer();
        IndexersFactory.clear();
        IndexersFactory.addIndexer(indexer);
        // Mock CDI injection and setup
        indexer.setIOService(ioService);
        indexer.setModuleService(getModuleService());
        indexer.setResourceTypeDefinition(getResourceTypeDefinition());
    }
    return ioService;
}
Also used : MetadataConfigBuilder(org.uberfire.ext.metadata.io.MetadataConfigBuilder) ExecutorService(java.util.concurrent.ExecutorService) DescriptiveThreadFactory(org.uberfire.commons.async.DescriptiveThreadFactory) Analyzer(org.apache.lucene.analysis.Analyzer) IOServiceIndexedImpl(org.uberfire.ext.metadata.io.IOServiceIndexedImpl)

Example 2 with DescriptiveThreadFactory

use of org.uberfire.commons.async.DescriptiveThreadFactory in project kie-wb-common by kiegroup.

the class BaseLibraryIndexingTest method ioService.

@SuppressWarnings("unchecked")
protected IOService ioService() {
    if (ioService == null) {
        final Map<String, Analyzer> analyzers = getAnalyzers();
        MetadataConfigBuilder configBuilder = new MetadataConfigBuilder().withInMemoryMetaModelStore().usingAnalyzers(analyzers).usingAnalyzerWrapperFactory(ImpactAnalysisAnalyzerWrapperFactory.getInstance()).useInMemoryDirectory().useDirectoryBasedIndex();
        if (config == null) {
            config = configBuilder.build();
        }
        ExecutorService executorService = Executors.newCachedThreadPool(new DescriptiveThreadFactory());
        ioService = new IOServiceIndexedImpl(config.getIndexEngine(), executorService);
        final LibraryIndexer indexer = new LibraryIndexer(new LibraryAssetTypeDefinition());
        IndexersFactory.clear();
        IndexersFactory.addIndexer(indexer);
        // Mock CDI injection and setup
        indexer.setIOService(ioService);
        indexer.setModuleService(getModuleService());
    }
    return ioService;
}
Also used : MetadataConfigBuilder(org.uberfire.ext.metadata.io.MetadataConfigBuilder) ExecutorService(java.util.concurrent.ExecutorService) DescriptiveThreadFactory(org.uberfire.commons.async.DescriptiveThreadFactory) FilenameAnalyzer(org.uberfire.ext.metadata.backend.lucene.analyzer.FilenameAnalyzer) LowerCaseOnlyAnalyzer(org.kie.workbench.common.services.refactoring.backend.server.indexing.LowerCaseOnlyAnalyzer) Analyzer(org.apache.lucene.analysis.Analyzer) IOServiceIndexedImpl(org.uberfire.ext.metadata.io.IOServiceIndexedImpl)

Example 3 with DescriptiveThreadFactory

use of org.uberfire.commons.async.DescriptiveThreadFactory in project kie-wb-common by kiegroup.

the class ExplorerServiceHelperTest method setUp.

@Before
public void setUp() throws Exception {
    fileSystemProvider = new SimpleFileSystemProvider();
    // Ensure URLs use the default:// scheme
    fileSystemProvider.forceAsDefault();
    path = fileSystemProvider.getPath(this.getClass().getResource("myfile.file").toURI());
    when(srcPath.toURI()).thenReturn(path.toUri().toString());
    when(srcTestPath.toURI()).thenReturn(path.toUri().toString());
    when(srcResourcesPath.toURI()).thenReturn(path.toUri().toString());
    when(testResourcesPath.toURI()).thenReturn(path.toUri().toString());
    when(pkg.getPackageMainSrcPath()).thenReturn(srcPath);
    when(pkg.getPackageTestSrcPath()).thenReturn(srcTestPath);
    when(pkg.getPackageMainResourcesPath()).thenReturn(srcResourcesPath);
    when(pkg.getPackageTestResourcesPath()).thenReturn(testResourcesPath);
    when(metadataService.getTags(any(Path.class))).thenReturn(tags);
    when(ioService.newDirectoryStream(any(org.uberfire.java.nio.file.Path.class), any(LinkedFilter.class))).thenReturn(new DirectoryStreamMock() {

        private List<org.uberfire.java.nio.file.Path> items = new ArrayList<org.uberfire.java.nio.file.Path>() {

            {
                add(path);
            }
        };

        @Override
        public Iterator<org.uberfire.java.nio.file.Path> iterator() {
            return items.iterator();
        }
    });
    ExecutorService executorService = Executors.newCachedThreadPool(new DescriptiveThreadFactory());
    helper = spy(new ExplorerServiceHelper(moduleService, folderListingResolver, ioService, ioServiceConfig, lockService, metadataService, userServices, deleteService, renameService, copyService, executorService));
}
Also used : Path(org.uberfire.backend.vfs.Path) ArrayList(java.util.ArrayList) SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) LinkedFilter(org.guvnor.common.services.backend.file.LinkedFilter) Iterator(java.util.Iterator) ExecutorService(java.util.concurrent.ExecutorService) DescriptiveThreadFactory(org.uberfire.commons.async.DescriptiveThreadFactory) Before(org.junit.Before)

Aggregations

ExecutorService (java.util.concurrent.ExecutorService)3 DescriptiveThreadFactory (org.uberfire.commons.async.DescriptiveThreadFactory)3 Analyzer (org.apache.lucene.analysis.Analyzer)2 IOServiceIndexedImpl (org.uberfire.ext.metadata.io.IOServiceIndexedImpl)2 MetadataConfigBuilder (org.uberfire.ext.metadata.io.MetadataConfigBuilder)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 LinkedFilter (org.guvnor.common.services.backend.file.LinkedFilter)1 Before (org.junit.Before)1 LowerCaseOnlyAnalyzer (org.kie.workbench.common.services.refactoring.backend.server.indexing.LowerCaseOnlyAnalyzer)1 Path (org.uberfire.backend.vfs.Path)1 FilenameAnalyzer (org.uberfire.ext.metadata.backend.lucene.analyzer.FilenameAnalyzer)1 SimpleFileSystemProvider (org.uberfire.java.nio.fs.file.SimpleFileSystemProvider)1