protected void checkIntOption(String optionName, MongoClientOptions.Builder builder) { Integer val = config.getInt(optionName); if (val != null) { try { Method m = MongoClientOptions.Builder.class.getMethod(optionName, int.class); m.invoke(builder, val); } catch (Exception e) { throw new IllegalStateException("Problem configuring int option " + optionName + " for mongo client. Ensure you used correct value (number) and if this option is supported by mongo driver", e); } } }
} else { String host = config.get("host", ServerAddress.defaultHost()); int port = config.getInt("port", ServerAddress.defaultPort());
int globalStatsInterval = config.getInt("globalStatsInterval", -1); if (globalStatsInterval != -1) { properties.put("hibernate.generate_statistics", true);
int owners = config.getInt("sessionsOwners", 2); logger.debugf("Session owners: %d", owners); int l1Lifespan = config.getInt("l1Lifespan", 600000); boolean l1Enabled = l1Lifespan > 0; sessionConfigBuilder.clustering() .hash() .numOwners(owners) .numSegments(config.getInt("sessionsSegments", 60)) .l1() .enabled(l1Enabled)
long socketTimeout = config.getLong("socket-timeout-millis", -1L); long establishConnectionTimeout = config.getLong("establish-connection-timeout-millis", -1L); int maxPooledPerRoute = config.getInt("max-pooled-per-route", 0); int connectionPoolSize = config.getInt("connection-pool-size", 200); boolean disableCookies = config.getBoolean("disable-cookies", true); String clientKeystore = config.get("client-keystore");
@Override public void init(final Config.Scope config) { client = new DefaultOpenShiftClient(); OkHttpClient httpClient = client.adapt(OkHttpClient.class); if(config.getBoolean("enableNonTls", true)) { Integer port = config.getInt("port", 5672); String hostname = config.get("host", "localhost"); try { server = new AmqpServer(hostname, port, config, false, client, httpClient); } catch (RuntimeException e) { LOG.error("Unable to create AMQP Server using non-TLS", e); } } if(config.getBoolean("enableTls", true)) { Integer port = config.getInt("tlsPort", 5671); String hostname = config.get("tlsHost", "0.0.0.0"); try { tlsServer = new AmqpServer(hostname, port, config, true, client, httpClient); } catch (RuntimeException e) { LOG.error("Unable to create AMQP Server using TLS", e); } } }
@Override public void postInit(final KeycloakSessionFactory factory) { KeycloakModelUtils.runJobInTransaction(factory, new KeycloakSessionTask() { @Override public void run(KeycloakSession session) { compatMode = isCompatMode(session); if (compatMode) { compatProviderFactory = new MemUserSessionProviderFactory(); } } }); // Max count of worker errors. Initialization will end with exception when this number is reached final int maxErrors = config.getInt("maxErrors", 20); // Count of sessions to be computed in each segment final int sessionsPerSegment = config.getInt("sessionsPerSegment", 100); factory.register(new ProviderEventListener() { @Override public void onEvent(ProviderEvent event) { if (event instanceof PostMigrationEvent) { loadPersistentSessions(factory, maxErrors, sessionsPerSegment); } } }); }
private void configureRemoteActionTokenCacheStore(ConfigurationBuilder builder, boolean async) { String jdgServer = config.get("remoteStoreHost", "localhost"); Integer jdgPort = config.getInt("remoteStorePort", 11222); builder.persistence() .passivation(false) .addStore(RemoteStoreConfigurationBuilder.class) .fetchPersistentState(false) .ignoreModifications(false) .purgeOnStartup(false) .preload(true) .shared(true) .remoteCacheName(InfinispanConnectionProvider.ACTION_TOKEN_CACHE) .rawValues(true) .forceReturnValues(false) .marshaller(KeycloakHotRodMarshallerFactory.class.getName()) .protocolVersion(getHotrodVersion()) .addServer() .host(jdgServer) .port(jdgPort) .async() .enabled(async); }
private void configureRemoteCacheStore(ConfigurationBuilder builder, boolean async, String cacheName, boolean sessionCache) { String jdgServer = config.get("remoteStoreHost", "localhost"); Integer jdgPort = config.getInt("remoteStorePort", 11222); builder.persistence() .passivation(false) .addStore(RemoteStoreConfigurationBuilder.class) .fetchPersistentState(false) .ignoreModifications(false) .purgeOnStartup(false) .preload(false) .shared(true) .remoteCacheName(cacheName) .rawValues(true) .forceReturnValues(false) .marshaller(KeycloakHotRodMarshallerFactory.class.getName()) .protocolVersion(getHotrodVersion()) .addServer() .host(jdgServer) .port(jdgPort) // .connectionPool() // .maxActive(100) // .exhaustedAction(ExhaustedAction.CREATE_NEW) .async() .enabled(async); }
private int getMaxErrors() { return config.getInt("maxErrors", 20); }
private int getTimeoutForPreloadingSessionsSeconds() { Integer timeout = config.getInt("sessionsPreloadTimeoutInSeconds", null); return timeout != null ? timeout : Environment.getServerStartupTimeout(); }
private int getSessionsPerSegment() { return config.getInt("sessionsPerSegment", 64); }
@Override public void init(Config.Scope config) { minTimeBetweenRequests = config.getInt("minTimeBetweenRequests", 10); log.debugf("minTimeBetweenRequests is %d", minTimeBetweenRequests); }
@Override public void init(Config.Scope config) { int lockWaitTimeout = config.getInt("lockWaitTimeout", 900); this.lockWaitTimeoutMillis = Time.toMillis(lockWaitTimeout); logger.debugf("Liquibase lock provider configured with lockWaitTime: %d seconds", lockWaitTimeout); }
@Override public void init(Config.Scope config) { int lockRecheckTime = config.getInt("lockRecheckTime", 2); int lockWaitTimeout = config.getInt("lockWaitTimeout", 900); this.lockRecheckTimeMillis = Time.toMillis(lockRecheckTime); this.lockWaitTimeoutMillis = Time.toMillis(lockWaitTimeout); logger.debugf("Mongo lock provider configured with lockWaitTime: %d seconds, lockRecheckTime: %d seconds", lockWaitTimeout, lockRecheckTime); }