Search in sources :

Example 1 with JdbcStringBasedStoreConfigurationBuilder

use of org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder in project infinispan by infinispan.

the class IracJDBCStoreTest method configure.

@Override
protected void configure(ConfigurationBuilder builder) {
    JdbcStringBasedStoreConfigurationBuilder jdbcBuilder = builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class);
    UnitTestDatabaseManager.buildTableManipulation(jdbcBuilder.table());
    UnitTestDatabaseManager.configureUniqueConnectionFactory(jdbcBuilder);
}
Also used : JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder)

Example 2 with JdbcStringBasedStoreConfigurationBuilder

use of org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder in project infinispan by infinispan.

the class MigratorConfigurationTest method testDbPropertiesLoaded.

public void testDbPropertiesLoaded() {
    Properties properties = createBaseProperties();
    properties.putAll(createBaseProperties(TARGET));
    Element[] storeTypes = new Element[] { SOURCE, TARGET };
    for (Element storeType : storeTypes) {
        properties.put(propKey(storeType, DB, MAJOR_VERSION), "1");
        properties.put(propKey(storeType, DB, MINOR_VERSION), "1");
        properties.put(propKey(storeType, DB, DISABLE_INDEXING), "true");
        properties.put(propKey(storeType, DB, DISABLE_UPSERT), "true");
        for (Element store : Arrays.asList(STRING, BINARY)) {
            properties.put(propKey(storeType, TABLE, store, TABLE_NAME_PREFIX), "mock_table_name");
            properties.put(propKey(storeType, TABLE, store, ID, NAME), "mock_id_column_name");
            properties.put(propKey(storeType, TABLE, store, ID, TYPE), "mock_id_column_type");
            properties.put(propKey(storeType, TABLE, store, DATA, NAME), "mock_data_column_name");
            properties.put(propKey(storeType, TABLE, store, DATA, TYPE), "mock_data_column_type");
            properties.put(propKey(storeType, TABLE, store, TIMESTAMP, NAME), "mock_timestamp_column_name");
            properties.put(propKey(storeType, TABLE, store, TIMESTAMP, TYPE), "mock_timestamp_column_type");
            properties.put(propKey(storeType, TABLE, store, SEGMENT, NAME), "mock_segment_column_name");
            properties.put(propKey(storeType, TABLE, store, SEGMENT, TYPE), "mock_segment_column_type");
        }
    }
    for (Element storeType : storeTypes) {
        StoreProperties props = new StoreProperties(storeType, properties);
        JdbcStringBasedStoreConfigurationBuilder builder = new ConfigurationBuilder().persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class);
        Configuration cacheConfig = JdbcConfigurationUtil.configureStore(props, builder).build();
        JdbcStringBasedStoreConfiguration config = (JdbcStringBasedStoreConfiguration) cacheConfig.persistence().stores().get(0);
        assertEquals((Integer) 1, config.dbMajorVersion());
        assertEquals((Integer) 1, config.dbMinorVersion());
        assertTrue(Boolean.parseBoolean(config.properties().getProperty(TableManagerFactory.INDEXING_DISABLED)));
        assertTrue(Boolean.parseBoolean(config.properties().getProperty(TableManagerFactory.UPSERT_DISABLED)));
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder) JdbcStringBasedStoreConfiguration(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) JdbcStringBasedStoreConfiguration(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfiguration) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder) Properties(java.util.Properties)

Example 3 with JdbcStringBasedStoreConfigurationBuilder

use of org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder in project infinispan by infinispan.

the class TargetStoreFactory method getInitializedStoreBuilder.

private static StoreConfigurationBuilder getInitializedStoreBuilder(StoreProperties props) {
    PersistenceConfigurationBuilder persistenceBuilder = new ConfigurationBuilder().persistence();
    StoreType storeType = StoreType.valueOf(props.get(TYPE).toUpperCase());
    switch(storeType) {
        case LEVELDB:
        case JDBC_BINARY:
        case JDBC_MIXED:
            throw new CacheConfigurationException(String.format("%s cannot be a target store as it no longer exists", storeType));
        case JDBC_STRING:
            return JdbcConfigurationUtil.configureStore(props, new JdbcStringBasedStoreConfigurationBuilder(persistenceBuilder));
        case ROCKSDB:
            props.required(LOCATION);
            String location = props.get(LOCATION);
            RocksDBStoreConfigurationBuilder builder = new RocksDBStoreConfigurationBuilder(persistenceBuilder);
            builder.location(location).expiredLocation(location + "-expired-");
            String compressionType = props.get(COMPRESSION);
            if (compressionType != null)
                builder.compressionType(CompressionType.valueOf(compressionType.toUpperCase()));
            return builder;
        case SINGLE_FILE_STORE:
            props.required(LOCATION);
            return new SingleFileStoreConfigurationBuilder(persistenceBuilder).location(props.get(LOCATION));
        case SOFT_INDEX_FILE_STORE:
            props.required(LOCATION);
            props.required(INDEX_LOCATION);
            return new SoftIndexFileStoreConfigurationBuilder(persistenceBuilder).dataLocation(props.get(LOCATION)).indexLocation(props.get(INDEX_LOCATION));
        default:
            throw new CacheConfigurationException(String.format("Unknown store type '%s'", storeType));
    }
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) SoftIndexFileStoreConfigurationBuilder(org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder) StoreConfigurationBuilder(org.infinispan.configuration.cache.StoreConfigurationBuilder) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder) RocksDBStoreConfigurationBuilder(org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder) SingleFileStoreConfigurationBuilder(org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder) PersistenceConfigurationBuilder(org.infinispan.configuration.cache.PersistenceConfigurationBuilder) RocksDBStoreConfigurationBuilder(org.infinispan.persistence.rocksdb.configuration.RocksDBStoreConfigurationBuilder) SoftIndexFileStoreConfigurationBuilder(org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfigurationBuilder) CacheConfigurationException(org.infinispan.commons.CacheConfigurationException) PersistenceConfigurationBuilder(org.infinispan.configuration.cache.PersistenceConfigurationBuilder) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder) SingleFileStoreConfigurationBuilder(org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder)

Example 4 with JdbcStringBasedStoreConfigurationBuilder

use of org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder in project infinispan by infinispan.

the class JdbcConfigurationUtil method getStoreConfig.

static JdbcStringBasedStoreConfiguration getStoreConfig(StoreProperties props) {
    JdbcStringBasedStoreConfigurationBuilder builder = new ConfigurationBuilder().persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class);
    configureStore(props, builder);
    return builder.create();
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder)

Example 5 with JdbcStringBasedStoreConfigurationBuilder

use of org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder in project infinispan by infinispan.

the class JdbcStoreReader method createBinaryTableConfig.

private JdbcStringBasedStoreConfiguration createBinaryTableConfig() {
    if (props.storeType() == StoreType.JDBC_STRING)
        return null;
    JdbcStringBasedStoreConfigurationBuilder builder = new ConfigurationBuilder().persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class);
    JdbcConfigurationUtil.createTableConfig(props, BINARY, builder);
    return builder.create();
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder)

Aggregations

JdbcStringBasedStoreConfigurationBuilder (org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder)18 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)10 TestObjectStreamMarshaller (org.infinispan.marshall.TestObjectStreamMarshaller)2 DummyInitializationContext (org.infinispan.persistence.DummyInitializationContext)2 ConnectionFactoryConfiguration (org.infinispan.persistence.jdbc.common.configuration.ConnectionFactoryConfiguration)2 PooledConnectionFactoryConfiguration (org.infinispan.persistence.jdbc.common.configuration.PooledConnectionFactoryConfiguration)2 SimpleConnectionFactoryConfiguration (org.infinispan.persistence.jdbc.common.configuration.SimpleConnectionFactoryConfiguration)2 JdbcStringBasedStoreConfiguration (org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfiguration)2 BeforeClass (org.testng.annotations.BeforeClass)2 Properties (java.util.Properties)1 CacheConfigurationException (org.infinispan.commons.CacheConfigurationException)1 Configuration (org.infinispan.configuration.cache.Configuration)1 PersistenceConfigurationBuilder (org.infinispan.configuration.cache.PersistenceConfigurationBuilder)1 SingleFileStoreConfigurationBuilder (org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder)1 StoreConfigurationBuilder (org.infinispan.configuration.cache.StoreConfigurationBuilder)1 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)1 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 PersistenceMarshaller (org.infinispan.marshall.persistence.PersistenceMarshaller)1 PooledConnectionFactory (org.infinispan.persistence.jdbc.common.impl.connectionfactory.PooledConnectionFactory)1