Search in sources :

Example 11 with JdbcStringBasedStoreConfigurationBuilder

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

the class JdbcStoreCompatibilityTest method configurePersistence.

@Override
protected void configurePersistence(ConfigurationBuilder builder, boolean generatingData) {
    JdbcStringBasedStoreConfigurationBuilder jdbcB = builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class);
    jdbcB.segmented(oldSegmented);
    jdbcB.table().createOnStart(generatingData).tableNamePrefix("ISPN_STRING_TABLE").idColumnName("ID_COLUMN").idColumnType("VARCHAR(255)").dataColumnName("DATA_COLUMN").dataColumnType("BINARY").timestampColumnName("TIMESTAMP_COLUMN").timestampColumnType("BIGINT").segmented(false);
    jdbcB.connectionPool().driverClass(org.h2.Driver.class).connectionUrl(String.format("jdbc:h2:%s;DB_CLOSE_DELAY=0", combinePath(tmpDirectory, "jdbc_db"))).username("sa");
}
Also used : JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder)

Example 12 with JdbcStringBasedStoreConfigurationBuilder

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

the class TableManagerTest method testConnectionLeakGuessDialect.

public void testConnectionLeakGuessDialect() {
    JdbcStringBasedStoreConfigurationBuilder storeBuilder = TestCacheManagerFactory.getDefaultCacheConfiguration(false).persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class);
    UnitTestDatabaseManager.buildTableManipulation(storeBuilder.table());
    PooledConnectionFactory connectionFactory = new PooledConnectionFactory();
    ConnectionFactoryConfiguration config = UnitTestDatabaseManager.configureUniqueConnectionFactory(storeBuilder).create();
    connectionFactory.start(config, Thread.currentThread().getContextClassLoader());
    // JdbcStringBasedStoreConfiguration defaults to null dialect, so dialect and versions must be guessed
    TableManager tableManager = TableManagerFactory.getManager(ctx, connectionFactory, storeBuilder.create(), "GuessDialect");
    tableManager.start();
    UnitTestDatabaseManager.verifyConnectionLeaks(connectionFactory);
    tableManager.stop();
    connectionFactory.stop();
}
Also used : PooledConnectionFactory(org.infinispan.persistence.jdbc.common.impl.connectionfactory.PooledConnectionFactory) TableManager(org.infinispan.persistence.jdbc.impl.table.TableManager) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder) PooledConnectionFactoryConfiguration(org.infinispan.persistence.jdbc.common.configuration.PooledConnectionFactoryConfiguration) ConnectionFactoryConfiguration(org.infinispan.persistence.jdbc.common.configuration.ConnectionFactoryConfiguration) SimpleConnectionFactoryConfiguration(org.infinispan.persistence.jdbc.common.configuration.SimpleConnectionFactoryConfiguration)

Example 13 with JdbcStringBasedStoreConfigurationBuilder

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

the class StringStoreWithManagedConnectionTest method buildConfig.

@Override
protected Configuration buildConfig(ConfigurationBuilder configurationBuilder) {
    JdbcStringBasedStoreConfigurationBuilder storeBuilder = configurationBuilder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class);
    storeBuilder.dataSource().jndiUrl(getDatasourceLocation());
    UnitTestDatabaseManager.buildTableManipulation(storeBuilder.table());
    return configurationBuilder.build();
}
Also used : JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder)

Example 14 with JdbcStringBasedStoreConfigurationBuilder

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

the class AbstractStringBasedCacheStore method configureCacheManager.

public EmbeddedCacheManager configureCacheManager(boolean passivation, boolean preload, boolean eviction) {
    GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder().nonClusteredDefault().defaultCacheName("StringBasedCache");
    ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false);
    JdbcStringBasedStoreConfigurationBuilder storeBuilder = builder.persistence().passivation(passivation).addStore(JdbcStringBasedStoreConfigurationBuilder.class).preload(preload);
    connectionFactory = getConnectionFactory(storeBuilder);
    setTableManipulation(storeBuilder);
    if (eviction) {
        builder.memory().evictionType(EvictionType.COUNT).size(2);
    } else {
        builder.memory().evictionType(EvictionType.COUNT).size(-1);
    }
    tableConfiguration = storeBuilder.create().table();
    EmbeddedCacheManager defaultCacheManager = TestCacheManagerFactory.newDefaultCacheManager(true, gcb, builder);
    String cacheName = defaultCacheManager.getCache().getName();
    PersistenceMarshaller marshaller = defaultCacheManager.getCache().getAdvancedCache().getComponentRegistry().getPersistenceMarshaller();
    InitializationContext ctx = new DummyInitializationContext(null, null, marshaller, null, null, null, null, null, null, null);
    tableManager = TableManagerFactory.getManager(ctx, connectionFactory, storeBuilder.create(), cacheName);
    return defaultCacheManager;
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) DummyInitializationContext(org.infinispan.persistence.DummyInitializationContext) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) DummyInitializationContext(org.infinispan.persistence.DummyInitializationContext) InitializationContext(org.infinispan.persistence.spi.InitializationContext) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder) PersistenceMarshaller(org.infinispan.marshall.persistence.PersistenceMarshaller) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Example 15 with JdbcStringBasedStoreConfigurationBuilder

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

the class JdbcStringBasedStoreAltMapperTest method createCacheStore.

@BeforeClass
public void createCacheStore() throws PersistenceException {
    ConfigurationBuilder builder = TestCacheManagerFactory.getDefaultCacheConfiguration(false);
    JdbcStringBasedStoreConfigurationBuilder storeBuilder = createJdbcConfig(builder);
    UnitTestDatabaseManager.buildTableManipulation(storeBuilder.table());
    UnitTestDatabaseManager.configureUniqueConnectionFactory(storeBuilder);
    JdbcStringBasedStore jdbcStringBasedStore = new JdbcStringBasedStore();
    cacheStore = new WaitDelegatingNonBlockingStore(jdbcStringBasedStore, SingleSegmentKeyPartitioner.getInstance());
    marshaller = new TestObjectStreamMarshaller(TestDataSCI.INSTANCE);
    cacheStore.startAndWait(PersistenceMockUtil.createContext(getClass(), builder.build(), marshaller));
    tableManager = jdbcStringBasedStore.getTableManager();
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder) JdbcStringBasedStoreConfigurationBuilder(org.infinispan.persistence.jdbc.configuration.JdbcStringBasedStoreConfigurationBuilder) TestObjectStreamMarshaller(org.infinispan.marshall.TestObjectStreamMarshaller) WaitDelegatingNonBlockingStore(org.infinispan.persistence.support.WaitDelegatingNonBlockingStore) BeforeClass(org.testng.annotations.BeforeClass)

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