Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Jersey-grizzly redis-cli monitor no show anything. #124

Open
hushino opened this issue Aug 24, 2018 · 1 comment
Open

Using Jersey-grizzly redis-cli monitor no show anything. #124

hushino opened this issue Aug 24, 2018 · 1 comment

Comments

@hushino
Copy link

hushino commented Aug 24, 2018

The dao its very simple and the other settings are by default.
I tried many things nothing works.
The log shows normality.
The same configuration works with tomcat.
Tested with redis 2 and 4.

public static SessionFactory getSessionFactory() {
	if (sessionFactory == null) {
		try {
			StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder();
			
			Map<String, Object> settings = new HashMap<>();
			settings.put(Environment.DRIVER, "com.mysql.cj.jdbc.Driver");
			settings.put(Environment.URL, "jdbc:mysql://localhost:3306/jersey");
			settings.put(Environment.USER, "root");
			settings.put(Environment.PASS, "");
			settings.put(Environment.HBM2DDL_AUTO, "update");
			settings.put(Environment.SHOW_SQL, "true");
			settings.put(Environment.DIALECT, "org.hibernate.dialect.MySQL5Dialect");
			//settings.put(Environment.VALIDATE_QUERY_PARAMETERS, "SELECT 1");
			// Enable second level cache (default value is true)
			settings.put(Environment.USE_SECOND_LEVEL_CACHE, true);
			settings.put(Environment.USE_QUERY_CACHE, true);
			
			// settings.put(Environment.GENERATE_STATISTICS, true);
			
			// Specify cache region factory class
			settings.put(Environment.CACHE_REGION_FACTORY,
					org.hibernate.cache.redis.hibernate52.SingletonRedisRegionFactory.class.getName());
			settings.put(Environment.CACHE_REGION_PREFIX, "hibernate");
			
			// Specify cache provider
			settings.put(Environment.CACHE_PROVIDER_CONFIG, "hibernate-redis.properties");
			
			// HikariCP settings
			settings.put("cachePrepStmts", "true");
			settings.put("prepStmtCacheSize", "250");
			settings.put("prepStmtCacheSqlLimit", "2048");
			settings.put("useServerPrepStmts", "true");
			settings.put("cacheServerConfiguration", "true");
			settings.put("cacheResultSetMetadata", "true");
			// Maximum waiting time for a connection from the pool
			settings.put("hibernate.hikari.connectionTimeout", "10000");
			// Minimum number of ideal connections in the pool
			settings.put("hibernate.hikari.minimumIdle", "2");
			// Maximum number of actual connection in the pool
			settings.put("hibernate.hikari.maximumPoolSize", "4");
			// Maximum time that a connection is allowed to sit ideal in the pool
			settings.put("hibernate.hikari.idleTimeout", "30000");
			
			registryBuilder.applySettings(settings);
			
			registry = registryBuilder.build();
			MetadataSources sources = new MetadataSources(registry)
					.addAnnotatedClass(Tested.class);
			Metadata metadata = sources.getMetadataBuilder().build();
			sessionFactory = metadata.getSessionFactoryBuilder().build();
			
		}catch (Exception e) {
			if (registry != null) {
				StandardServiceRegistryBuilder.destroy(registry);
			}
			e.printStackTrace();
		}
	}
	return sessionFactory;
}

public static void shutdown() {
	if (registry != null) {
		StandardServiceRegistryBuilder.destroy(registry);
	}
}
@hushino
Copy link
Author

hushino commented Sep 3, 2018

I solved this
its not a real problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant