Search in sources :

Example 1 with PdsFoldersResolver

use of org.apache.ignite.internal.processors.cache.persistence.filename.PdsFoldersResolver in project ignite by apache.

the class MockWalIteratorFactory method iterator.

/**
 * Creates iterator
 * @param wal WAL directory without node consistent id
 * @param walArchive WAL archive without node consistent id
 * @return iterator
 * @throws IgniteCheckedException if IO failed
 */
@SuppressWarnings("unchecked")
public WALIterator iterator(File wal, File walArchive) throws IgniteCheckedException {
    final DataStorageConfiguration persistentCfg1 = Mockito.mock(DataStorageConfiguration.class);
    when(persistentCfg1.getWalPath()).thenReturn(wal.getAbsolutePath());
    when(persistentCfg1.getWalArchivePath()).thenReturn(walArchive.getAbsolutePath());
    when(persistentCfg1.getWalSegments()).thenReturn(segments);
    when(persistentCfg1.getWalBufferSize()).thenReturn(DataStorageConfiguration.DFLT_WAL_BUFF_SIZE);
    when(persistentCfg1.getWalRecordIteratorBufferSize()).thenReturn(DataStorageConfiguration.DFLT_WAL_RECORD_ITERATOR_BUFFER_SIZE);
    final FileIOFactory fileIOFactory = new DataStorageConfiguration().getFileIOFactory();
    when(persistentCfg1.getFileIOFactory()).thenReturn(fileIOFactory);
    final IgniteConfiguration cfg = Mockito.mock(IgniteConfiguration.class);
    when(cfg.getDataStorageConfiguration()).thenReturn(persistentCfg1);
    final GridKernalContext ctx = Mockito.mock(GridKernalContext.class);
    when(ctx.config()).thenReturn(cfg);
    when(ctx.clientNode()).thenReturn(false);
    when(ctx.pdsFolderResolver()).thenReturn(new PdsFoldersResolver() {

        @Override
        public PdsFolderSettings resolveFolders() {
            return new PdsFolderSettings(new File("."), subfolderName, consistentId, null, false);
        }
    });
    final GridDiscoveryManager disco = Mockito.mock(GridDiscoveryManager.class);
    when(ctx.discovery()).thenReturn(disco);
    final IgniteWriteAheadLogManager mgr = new FileWriteAheadLogManager(ctx);
    final GridCacheSharedContext sctx = Mockito.mock(GridCacheSharedContext.class);
    when(sctx.kernalContext()).thenReturn(ctx);
    when(sctx.discovery()).thenReturn(disco);
    when(sctx.gridConfig()).thenReturn(cfg);
    final GridCacheDatabaseSharedManager db = Mockito.mock(GridCacheDatabaseSharedManager.class);
    when(db.pageSize()).thenReturn(pageSize);
    when(sctx.database()).thenReturn(db);
    when(sctx.logger(any(Class.class))).thenReturn(log);
    mgr.start(sctx);
    return mgr.replay(null);
}
Also used : FileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory) IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) GridKernalContext(org.apache.ignite.internal.GridKernalContext) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) PdsFoldersResolver(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFoldersResolver) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) PdsFolderSettings(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings) File(java.io.File)

Aggregations

File (java.io.File)1 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 GridKernalContext (org.apache.ignite.internal.GridKernalContext)1 GridDiscoveryManager (org.apache.ignite.internal.managers.discovery.GridDiscoveryManager)1 IgniteWriteAheadLogManager (org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager)1 GridCacheSharedContext (org.apache.ignite.internal.processors.cache.GridCacheSharedContext)1 GridCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager)1 FileIOFactory (org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory)1 PdsFolderSettings (org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings)1 PdsFoldersResolver (org.apache.ignite.internal.processors.cache.persistence.filename.PdsFoldersResolver)1 FileWriteAheadLogManager (org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager)1