@ SuppressWarnings ( "unchecked" ) public void load ( File propertiesFile ) throws IOException { String paramName ; String paramValue ; Reader reader = new FileReader ( propertiesFile ) ; _properties . load ( reader ) ; reader . close ( ) ; paramName = StoreParams . PARAM_INDEXES_CACHED ; paramValue = _properties . getProperty ( paramName ) ; setIndexesCached ( parseBoolean ( paramName , paramValue , StoreParams . INDEXES_CACHED_DEFAULT ) ) ; paramName = StoreParams . PARAM_BATCH_SIZE ; paramValue = _properties . getProperty ( paramName ) ; setBatchSize ( parseInt ( paramName , paramValue , StoreParams . BATCH_SIZE_DEFAULT ) ) ; paramName = StoreParams . PARAM_NUM_SYNC_BATCHES ; paramValue = _properties . getProperty ( paramName ) ; setNumSyncBatches ( parseInt ( paramName , paramValue , StoreParams . NUM_SYNC_BATCHES_DEFAULT ) ) ; paramName = StoreParams . PARAM_SEGMENT_FILE_SIZE_MB ; paramValue = _properties . getProperty ( paramName ) ; setSegmentFileSizeMB ( parseInt ( paramName , paramValue , StoreParams . SEGMENT_FILE_SIZE_MB_DEFAULT ) ) ; paramName = StoreParams . PARAM_SEGMENT_COMPACT_FACTOR ; paramValue = _properties . getProperty ( paramName ) ; setSegmentCompactFactor ( parseDouble ( paramName , paramValue , StoreParams . SEGMENT_COMPACT_FACTOR_DEFAULT ) ) ; paramName = StoreParams . PARAM_HASH_LOAD_FACTOR ; paramValue = _properties . getProperty ( paramName ) ; setHashLoadFactor ( parseDouble ( paramName , paramValue , StoreParams . HASH_LOAD_FACTOR_DEFAULT ) ) ; // Create _segmentFactory paramName = StoreParams . PARAM_SEGMENT_FACTORY_CLASS ; paramValue = _properties . getProperty ( paramName ) ; SegmentFactory segmentFactory = null ; if ( paramValue != null ) { try { segmentFactory = Class . forName ( paramValue ) . asSubclass ( SegmentFactory . class ) . newInstance ( ) ; } catch ( Exception e ) { _logger . warn ( "Invalid SegmentFactory class: " + paramValue ) ; } } if ( segmentFactory == null ) { segmentFactory = new MappedSegmentFactory ( ) ; } setSegmentFactory ( segmentFactory ) ; // Create _hashFunction paramName = StoreParams . PARAM_HASH_FUNCTION_CLASS ; paramValue = _properties . getProperty ( paramName ) ; HashFunction < byte [ ] > hashFunction = null ; if ( paramValue != null ) { try { hashFunction = ( HashFunction < byte [ ] > ) Class . forName ( paramValue ) . newInstance ( ) ; } catch ( Exception e ) { _logger . warn ( "Invalid HashFunction<byte[]> class: " + paramValue ) ; } } if ( hashFunction == null ) { hashFunction = new FnvHashFunction ( ) ; } setHashFunction ( hashFunction ) ; // Create _dataHandler paramName = StoreParams . PARAM_DATA_HANDLER_CLASS ; paramValue = _properties . getProperty ( paramName ) ; DataHandler dataHandler = null ; if ( paramValue != null ) { try { dataHandler = ( DataHandler ) Class . forName ( paramValue ) . newInstance ( ) ; } catch ( Exception e ) { _logger . warn ( "Invalid DataHandler class: " + paramValue ) ; } } if ( dataHandler != null ) { setDataHandler ( dataHandler ) ; } }
Loads configuration from a properties file .