本文整理匯總了Java中io.dropwizard.db.DataSourceFactory.setMinSize方法的典型用法代碼示例。如果您正苦於以下問題:Java DataSourceFactory.setMinSize方法的具體用法?Java DataSourceFactory.setMinSize怎麽用?Java DataSourceFactory.setMinSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.dropwizard.db.DataSourceFactory
的用法示例。
在下文中一共展示了DataSourceFactory.setMinSize方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: applyMigrations
import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
private static void applyMigrations(DataSourceFactory dbConfig, MetricRegistry metrics) throws Exception {
Stopwatch migrationsTimer = Stopwatch.createStarted();
// Borrowed from AbstractLiquibaseCommand.
DataSourceFactory lbConfig = EbeanConfigUtils.clone(dbConfig);
lbConfig.setMaxSize(1);
lbConfig.setMinSize(1);
lbConfig.setInitialSize(1);
try (CloseableLiquibase liquibase = new CloseableLiquibase(dbConfig.build(metrics, "liquibase"))) {
log.info("Checking for database migrations.");
liquibase.update("");
migrationsTimer.stop();
metrics.timer(MetricRegistry.name(EbeanBundle.class, "migrations")).update(migrationsTimer.elapsed(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS);
log.info("Database migrations complete in {} ms.", migrationsTimer.elapsed(TimeUnit.MILLISECONDS));
} catch (ValidationFailedException e) {
e.printDescriptiveError(System.err);
throw e;
}
}
示例2: setUp
import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
final Environment environment = mock(Environment.class);
when(environment.lifecycle()).thenReturn(mock(LifecycleEnvironment.class));
when(environment.metrics()).thenReturn(new MetricRegistry());
when(this.bundle.getSessionHolders()).thenReturn(this.sessionHolders);
final DataSourceFactory dataSourceFactory = new DataSourceFactory();
dataSourceFactory.setUrl("jdbc:hsqldb:mem:unit-of-work-" + UUID.randomUUID().toString());
dataSourceFactory.setUser("sa");
dataSourceFactory.setDriverClass("org.hsqldb.jdbcDriver");
dataSourceFactory.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS");
dataSourceFactory.setProperties(ImmutableMap.of("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"));
dataSourceFactory.setMinSize(1);
this.sessionFactory = new SessionFactoryFactory()
.build(this.bundle, environment, dataSourceFactory, ImmutableList.<Class<?>>of(), RemoteCredentialHibernateBundle.DEFAULT_NAME);
when(this.bundle.getSessionFactory()).thenReturn(this.sessionFactory);
final Session session = this.sessionFactory.openSession();
try {
session.createSQLQuery("create table user_sessions (token varchar(64) primary key, username varchar(16))")
.executeUpdate();
session.createSQLQuery("insert into user_sessions values ('67ab89d', 'jeff_28')")
.executeUpdate();
} finally {
session.close();
}
}
開發者ID:mtakaki,項目名稱:CredentialStorageService-dw-hibernate,代碼行數:30,代碼來源:UnitOfWorkAwareProxyFactoryTest.java
示例3: setUp
import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
@BeforeClass
public static void setUp() throws Exception {
final EntityManagerBundle<?> bundle = mock(EntityManagerBundle.class);
final Environment environment = mock(Environment.class);
when(bundle.name()).thenReturn("test-bundle");
when(environment.lifecycle()).thenReturn(mock(LifecycleEnvironment.class));
when(environment.metrics()).thenReturn(new MetricRegistry());
final DataSourceFactory dataSourceFactory = new DataSourceFactory();
dataSourceFactory.setUrl("jdbc:hsqldb:mem:unit-of-work-" + UUID.randomUUID().toString());
dataSourceFactory.setUser("sa");
dataSourceFactory.setDriverClass("org.hsqldb.jdbcDriver");
dataSourceFactory.setValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS");
dataSourceFactory.setProperties(ImmutableMap.of("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"));
dataSourceFactory.setInitialSize(1);
dataSourceFactory.setMinSize(1);
entityManagerFactory = new EntityManagerFactoryFactory()
.build(bundle, environment, dataSourceFactory, ImmutableList.<Class<?>>of());
final EntityManager entityManager = entityManagerFactory.createEntityManager();
try {
EntityTransaction entityTransaction = entityManager.getTransaction();
entityTransaction.begin();
entityManager.createNativeQuery("create table user_sessions (token varchar(64) primary key, username varchar(16))")
.executeUpdate();
entityManager.createNativeQuery("insert into user_sessions values ('67ab89d', 'jeff_28')")
.executeUpdate();
entityTransaction.commit();
} finally {
entityManager.close();
}
final EntityManagerContext entityManagerContext = new EntityManagerContext(entityManagerFactory);
sharedEntityManager = new SharedEntityManagerFactory().build(entityManagerContext);
}
示例4: clone
import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
public static DataSourceFactory clone(DataSourceFactory dbConfig) {
DataSourceFactory newConfig = new DataSourceFactory();
newConfig.setUser(dbConfig.getUser());
newConfig.setPassword(dbConfig.getPassword());
newConfig.setUrl(dbConfig.getUrl());
newConfig.setDriverClass(dbConfig.getDriverClass());
newConfig.setMaxSize(dbConfig.getMaxSize());
newConfig.setMinSize(dbConfig.getMinSize());
newConfig.setInitialSize(dbConfig.getInitialSize());
return newConfig;
}
示例5: ThreadableCommand
import io.dropwizard.db.DataSourceFactory; //導入方法依賴的package包/類
public ThreadableCommand(final AbstractRoutingLiquibaseCommand<T> command, final DataSourceRoute route,
final Namespace namespace) {
LOGGER.error("Inside ThreadableCommand constructor - Timestamp:{}", System.currentTimeMillis());
this.command = command;
final DataSourceFactory factory = route.getDatabase();
factory.setMaxSize(1);
factory.setMinSize(1);
factory.setInitialSize(1);
this.factory = factory;
this.namespace = namespace;
}