/** * Gets the number of available cores. Uses explicit number from system * setting if available. Detects number of cores from current server runtime * if not. * * @return the number of available cores. */ private int getProcessNo() { Integer cores = (Integer) systemSettingManager.getSystemSetting( SettingKey.DATABASE_SERVER_CPUS ); return (cores == null || cores == 0) ? SystemUtils.getCpuCores() : cores; } }
@PostConstruct public void init() { Long expiration = dhisConfig.getAnalyticsCacheExpiration(); boolean enabled = expiration > 0 && !SystemUtils.isTestRun(); queryCache = cacheProvider.newCacheBuilder( Grid.class ).forRegion( CACHE_REGION ) .expireAfterWrite( expiration, TimeUnit.SECONDS ).withMaximumSize( enabled ? MAX_CACHE_ENTRIES : 0 ).build(); log.info( String.format( "Event analytics server-side cache is enabled: %b with expiration: %d s", enabled, expiration ) ); }
@Override public void execute( JobConfiguration jobConfiguration ) { final int cpuCores = SystemUtils.getCpuCores(); Clock clock = new Clock().startClock().logTime( "Aggregate process started, number of CPU cores: " + cpuCores + ", " + SystemUtils.getMemoryString() ); clock.logTime( "Starting to send messages in outbound" ); notifier.notify( jobConfiguration, INFO, "Start to send messages in outbound", true ); sendMessages(); clock.logTime( "Sending messages in outbound completed" ); notifier.notify( jobConfiguration, INFO, "Sending messages in outbound completed", true ); }
@PostConstruct public void init() { Long expiration = dhisConfig.getAnalyticsCacheExpiration(); boolean enabled = expiration > 0 && !SystemUtils.isTestRun(); queryCache = cacheProvider.newCacheBuilder( Grid.class ).forRegion( CACHE_REGION ) .expireAfterWrite( expiration, TimeUnit.SECONDS ).withMaximumSize( enabled ? MAX_CACHE_ENTRIES : 0 ).build(); log.info( String.format( "Analytics server-side cache is enabled: %b with expiration: %d s", enabled, expiration ) ); }
info.setOsVersion( props.getProperty( "os.version" ) ); info.setMemoryInfo( SystemUtils.getMemoryString() ); info.setCpuCores( SystemUtils.getCpuCores() ); info.setEncryption( dhisConfig.getEncryptionStatus().isOk() );
@PostConstruct public void init() { settingCache = cacheProvider.newCacheBuilder( Serializable.class ).forRegion( "systemSetting" ) .expireAfterAccess( 1, TimeUnit.HOURS ).withMaximumSize( SystemUtils.isTestRun() ? 0 : 400 ).build(); }
/** * Gets the number of available cores. Uses explicit number from system * setting if available. Detects number of cores from current server runtime * if not. Subtracts one to the number of cores if greater than two to allow * one core for general system operations. */ private int getProcessNo() { Integer cores = (Integer) systemSettingManager.getSystemSetting( SettingKey.DATABASE_SERVER_CPUS ); cores = ( cores == null || cores == 0 ) ? SystemUtils.getCpuCores() : cores; return cores > 2 ? ( cores - 1 ) : cores; } }
@PostConstruct public void init() { IS_APPROVED_CACHE = cacheProvider.newCacheBuilder( Boolean.class ) .forRegion( "isDataApproved" ) .expireAfterAccess( 12, TimeUnit.HOURS ) .withMaximumSize( SystemUtils.isTestRun() ? 0 : 20000 ).build(); }
/** * Determines how many threads we should use for testing validation rules. * * @param context validation run context * @return number of threads we should use for testing validation rules */ private static int getThreadPoolSize( ValidationRunContext context ) { int threadPoolSize = SystemUtils.getCpuCores(); if ( threadPoolSize > 2 ) { threadPoolSize--; } int numberOfTasks = context.getNumberOfTasks(); if ( threadPoolSize > numberOfTasks ) { threadPoolSize = numberOfTasks; } return threadPoolSize; }
@PostConstruct public void init() { userSettingCache = cacheProvider.newCacheBuilder( Serializable.class ).forRegion( "userSetting" ) .expireAfterAccess( 1, TimeUnit.HOURS ).withMaximumSize( SystemUtils.isTestRun() ? 0 : 10000 ).build(); }
public void init() { checkDatabaseConnectivity(); boolean spatialSupport = false; // Check if postgis is installed. If not, fail startup. if ( !SystemUtils.isTestRun() ) { spatialSupport = isSpatialSupport(); if ( !spatialSupport ) { log.error( POSTGIS_MISSING_ERROR ); throw new IllegalStateException( POSTGIS_MISSING_ERROR ); } } String url = config.getProperty( ConfigurationKey.CONNECTION_URL ); String user = config.getProperty( ConfigurationKey.CONNECTION_USERNAME ); String password = config.getProperty( ConfigurationKey.CONNECTION_PASSWORD ); info = new DatabaseInfo(); info.setName( getNameFromConnectionUrl( url ) ); info.setUser( user ); info.setPassword( password ); info.setUrl( url ); info.setSpatialSupport( spatialSupport ); info.setDatabaseVersion( getDatabaseVersion() ); }
private Properties getHibernateProperties() { Properties props = new Properties(); putIfExists( configurationProvider.getProperty( ConfigurationKey.CONNECTION_DIALECT ), Environment.DIALECT, props ); putIfExists( configurationProvider.getProperty( ConfigurationKey.CONNECTION_DRIVER_CLASS ), Environment.DRIVER, props ); putIfExists( configurationProvider.getProperty( ConfigurationKey.CONNECTION_URL ), Environment.URL, props ); putIfExists( configurationProvider.getProperty( ConfigurationKey.CONNECTION_USERNAME ), Environment.USER, props ); putIfExists( configurationProvider.getProperty( ConfigurationKey.CONNECTION_PASSWORD ), Environment.PASS, props ); putIfExists( configurationProvider.getProperty( ConfigurationKey.CONNECTION_POOL_MAX_SIZE ), Environment.C3P0_MAX_SIZE, props ); if ( SystemUtils.isTestRun() ) { putIfExists( configurationProvider.getProperty( ConfigurationKey.CONNECTION_SCHEMA ), Environment.HBM2DDL_AUTO, props ); putIfExists( "false", "hibernate.cache.use_second_level_cache", props ); putIfExists( "false", "hibernate.cache.use_query_cache", props ); } return props; }