Java Code Examples for org.apache.ignite.configuration.DataStorageConfiguration#setFileIOFactory()

The following examples show how to use org.apache.ignite.configuration.DataStorageConfiguration#setFileIOFactory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CorruptedTreeFailureHandlingTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    cfg.setConsistentId(gridName);

    DataStorageConfiguration dataStorageConfiguration = new DataStorageConfiguration();

    dataStorageConfiguration.getDefaultDataRegionConfiguration().setPersistenceEnabled(true);
    dataStorageConfiguration.setFileIOFactory(new CollectLinkFileIOFactory());

    cfg.setDataStorageConfiguration(dataStorageConfiguration);

    cfg.setCacheConfiguration(new CacheConfiguration<>()
        .setName(DEFAULT_CACHE_NAME)
        .setAffinity(new RendezvousAffinityFunction().setPartitions(1))
        .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
    );

    return cfg;
}
 
Example 2
Source File: IgnitePdsRestartAfterFailedToWriteMetaPageTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    cfg.setConsistentId(gridName);

    DataStorageConfiguration memCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setMaxSize(32L * 1024 * 1024)
                .setPersistenceEnabled(true))
        .setWalMode(WALMode.FSYNC)
        .setCheckpointFrequency(500L);

    memCfg.setFileIOFactory(new MyIOFactory());

    cfg.setDataStorageConfiguration(memCfg);

    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setName(DEFAULT_CACHE_NAME);
    ccfg.setCacheMode(CacheMode.REPLICATED);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 3
Source File: IgnitePdsCorruptedIndexTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setConsistentId(igniteInstanceName);

    DataStorageConfiguration dsCfg = new DataStorageConfiguration()
        .setWalMode(WALMode.LOG_ONLY)
        .setCheckpointFrequency(10 * 60 * 1000)
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setMaxSize(256 * 1024 * 1024)
                .setPersistenceEnabled(true)
        );

    if (haltFileIO)
        dsCfg.setFileIOFactory(new HaltOnTruncateFileIOFactory(new RandomAccessFileIOFactory()));

    cfg.setDataStorageConfiguration(dsCfg);

    CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(CACHE)
        .setBackups(1)
        .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC)
        .setIndexedTypes(Integer.class, IndexedObject.class, Long.class, IndexedObject.class)
        .setAffinity(new RendezvousAffinityFunction(false, 32));

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 4
Source File: IgniteSequentialNodeCrashRecoveryTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    DataStorageConfiguration dsCfg = new DataStorageConfiguration()
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setMaxSize(256 * 1024 * 1024).setPersistenceEnabled(true))
        // Set large checkpoint frequency to make sure no checkpoint happens right after the node start.
        .setCheckpointFrequency(getTestTimeout())
        .setPageSize(PAGE_SIZE);

    if (fileIoFactory != null)
        dsCfg.setFileIOFactory(fileIoFactory);

    if (discoverySpi != null)
        cfg.setDiscoverySpi(discoverySpi);

    cfg
        .setDataStorageConfiguration(dsCfg)
        .setConsistentId(igniteInstanceName);

    if (failureHnd != null)
        cfg.setFailureHandler(failureHnd);

    return cfg;
}
 
Example 5
Source File: IgniteShutdownOnSupplyMessageFailureTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String name) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(name);

    cfg.setConsistentId(name);

    DataStorageConfiguration conf = new DataStorageConfiguration()
        .setWalHistorySize(WAL_HISTORY_SIZE)
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setMaxSize(DataStorageConfiguration.DFLT_DATA_REGION_INITIAL_SIZE)
                .setPersistenceEnabled(true)
        )
        .setWalMode(WALMode.FSYNC)
        .setCheckpointFrequency(500);

    if (name.equals(getTestIgniteInstanceName(NODE_NAME_WITH_TEST_FILE_FACTORY))) {
        conf.setFileIOFactory(new FailingFileIOFactory(canFailFirstNode));

        cfg.setFailureHandler(new TestFailureHandler());
    }
    else
        cfg.setFailureHandler(new StopNodeFailureHandler());

    cfg.setDataStorageConfiguration(conf);

    return cfg;
}
 
Example 6
Source File: IgnitePdsDiskErrorsRecoveringTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setConsistentId(igniteInstanceName);

    DataStorageConfiguration dsCfg = new DataStorageConfiguration()
            .setDefaultDataRegionConfiguration(
                    new DataRegionConfiguration().setMaxSize(100L * 1024 * 1024).setPersistenceEnabled(true))
            .setWalMode(WALMode.LOG_ONLY)
            .setWalCompactionEnabled(false)
            .setWalSegmentSize(WAL_SEGMENT_SIZE)
            .setCheckpointFrequency(240 * 60 * 1000)
            .setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4);

    if (ioFactory != null)
        dsCfg.setFileIOFactory(ioFactory);

    cfg.setDataStorageConfiguration(dsCfg);

    CacheConfiguration cacheCfg = new CacheConfiguration(CACHE_NAME)
        .setRebalanceMode(CacheRebalanceMode.NONE)
        .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
        .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC)
        .setAffinity(new RendezvousAffinityFunction(false, 1));

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
Example 7
Source File: IgnitePdsTaskCancelingTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Default data storage configuration.
 */
private DataStorageConfiguration getDataStorageConfiguration() {
    DataStorageConfiguration dbCfg = new DataStorageConfiguration();

    dbCfg.setPageSize(PAGE_SIZE);

    dbCfg.setFileIOFactory(new SlowIOFactory());

    dbCfg.setDefaultDataRegionConfiguration(new DataRegionConfiguration()
        .setMaxSize(100 * 1024 * 1024)
        .setPersistenceEnabled(true));

    return dbCfg;
}
 
Example 8
Source File: IgnitePdsPartitionFilesDestroyTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setConsistentId(igniteInstanceName);

    DataStorageConfiguration dsCfg = new DataStorageConfiguration()
        .setWalMode(WALMode.LOG_ONLY)
        .setCheckpointFrequency(10 * 60 * 1000)
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setMaxSize(512 * 1024 * 1024)
                .setPersistenceEnabled(true)
        );

    if (failFileIo)
        dsCfg.setFileIOFactory(new FailingFileIOFactory(new RandomAccessFileIOFactory()));

    cfg.setDataStorageConfiguration(dsCfg);

    CacheConfiguration ccfg = defaultCacheConfiguration()
        .setBackups(1)
        .setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC)
        .setAffinity(new RendezvousAffinityFunction(false, PARTS_CNT));

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
Example 9
Source File: IgnitePdsCacheWalDisabledOnRebalancingTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    // This is required because some tests do full clearing of persistence folder losing BLT info on next join.
    cfg.setConsistentId(igniteInstanceName);

    CacheConfiguration ccfg1 = new CacheConfiguration(CACHE1_NAME)
        .setAtomicityMode(CacheAtomicityMode.ATOMIC)
        .setCacheMode(CacheMode.REPLICATED)
        .setAffinity(new RendezvousAffinityFunction(false, CACHE1_PARTS_NUM));

    CacheConfiguration ccfg2 = new CacheConfiguration(CACHE2_NAME)
        .setBackups(1)
        .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
        .setCacheMode(CacheMode.PARTITIONED)
        .setAffinity(new RendezvousAffinityFunction(false, CACHE2_PARTS_NUM));

    CacheConfiguration ccfg3 = new CacheConfiguration(CACHE3_NAME)
        .setBackups(2)
        .setAtomicityMode(CacheAtomicityMode.ATOMIC)
        .setCacheMode(CacheMode.PARTITIONED)
        .setAffinity(new RendezvousAffinityFunction(false, CACHE3_PARTS_NUM));

    cfg.setCacheConfiguration(ccfg1, ccfg2, ccfg3);

    if (!"client".equals(igniteInstanceName)) {
        DataStorageConfiguration dsCfg = new DataStorageConfiguration()
            .setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4)
            .setWalMode(WALMode.LOG_ONLY)
            .setDefaultDataRegionConfiguration(
                new DataRegionConfiguration()
                    .setPersistenceEnabled(true)
                    .setMaxSize(256 * 1024 * 1024));

        if (useBlockingFileIO)
            dsCfg.setFileIOFactory(new BlockingCheckpointFileIOFactory());

        cfg.setDataStorageConfiguration(dsCfg);
    }

    TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
    commSpi.blockMessages(blockMessagePredicate);

    cfg.setCommunicationSpi(commSpi);

    return cfg;
}
 
Example 10
Source File: IgniteLogicalRecoveryTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    cfg.setIncludeEventTypes(EVTS_DISABLED);

    cfg.setConsistentId(igniteInstanceName);

    cfg.setCacheConfiguration(
        cacheConfiguration(CACHE_PREFIX + 0, CacheMode.PARTITIONED, CacheAtomicityMode.ATOMIC),
        cacheConfiguration(CACHE_PREFIX + 1, CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL),
        cacheConfiguration(CACHE_PREFIX + 2, CacheMode.REPLICATED, CacheAtomicityMode.ATOMIC),
        cacheConfiguration(CACHE_PREFIX + 3, CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL),
        cacheConfiguration(CACHE_PREFIX + 4, SHARED_GROUP_NAME, CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL),
        cacheConfiguration(CACHE_PREFIX + 5, SHARED_GROUP_NAME, CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL)
    );

    DataStorageConfiguration dsCfg = new DataStorageConfiguration()
        .setWalMode(WALMode.LOG_ONLY)
        .setCheckpointFrequency(1024 * 1024 * 1024) // Disable automatic checkpoints.
        .setDefaultDataRegionConfiguration(
            new DataRegionConfiguration()
                .setName("dflt")
                .setInitialSize(256 * 1024 * 1024)
                .setMaxSize(256 * 1024 * 1024)
                .setPersistenceEnabled(true)
        );

    cfg.setDataStorageConfiguration(dsCfg);

    if (ioFactory != null)
        dsCfg.setFileIOFactory(ioFactory);

    TestRecordingCommunicationSpi spi = new TestRecordingCommunicationSpi();

    spi.record(GridDhtPartitionDemandMessage.class);

    cfg.setCommunicationSpi(spi);

    return cfg;
}
 
Example 11
Source File: IgnitePdsNoSpaceLeftOnDeviceTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    final DataStorageConfiguration dataStorageConfiguration = new DataStorageConfiguration();

    dataStorageConfiguration.getDefaultDataRegionConfiguration().setPersistenceEnabled(true).setMaxSize(1 << 24);
    dataStorageConfiguration.setFileIOFactory(new FailingFileIOFactory());

    cfg.setDataStorageConfiguration(dataStorageConfiguration);

    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
    ccfg.setName(DEFAULT_CACHE_NAME);
    ccfg.setBackups(1);

    cfg.setCacheConfiguration(ccfg);

    cfg.setFailureHandler(new StopNodeFailureHandler());

    return cfg;
}