Package krati.core

Examples of krati.core.StorePartitionConfig


   
    protected void setUpStorePartitionConfig() {
        tearDown();
       
        try {
            _config = new StorePartitionConfig(FileUtils.getTestDir(getClass()), 100000, 100);
            _config.setBatchSize(1000);
            _config.setNumSyncBatches(5);
            _config.setSegmentFileSizeMB(8);
            _config.setSegmentFactory(new MappedSegmentFactory());
        } catch (IOException e) {
View Full Code Here


   
    protected void setUpStorePartitionConfig() {
        tearDown();
       
        try {
            _config = new StorePartitionConfig(FileUtils.getTestDir(getClass()), 100000, 100);
            _config.setBatchSize(1000);
            _config.setNumSyncBatches(5);
            _config.setSegmentFileSizeMB(8);
            _config.setSegmentFactory(new MappedSegmentFactory());
        } catch (IOException e) {
View Full Code Here

   
    @Override
    protected ArrayStore createStore(File homeDir) throws Exception {
        int idStart = _rand.nextInt(100);
        int idCount = _rand.nextInt(100) + 1000;
        StorePartitionConfig config = new StorePartitionConfig(homeDir, idStart, idCount);
        config.setBatchSize(100);
        config.setNumSyncBatches(5);
        config.setSegmentFileSizeMB(Segment.minSegmentFileSizeMB);
        return StoreFactory.createArrayStorePartition(config);
    }
View Full Code Here

        SourceWaterMarks sourceWaterMarks = new SourceWaterMarks(new File(homeDir, "sourceWaterMarks.scn"));
        WaterMarksClock waterMarksClock = new SourceWaterMarksClock(sources, sourceWaterMarks);
       
        // STEP-3
        // Create store configuration template
        StoreConfig configTemplate = new StorePartitionConfig(homeDir, arrayStoreIndexStart, arrayStoreCapacity);
        configTemplate.setSegmentCompactFactor(0.68);
        configTemplate.setSegmentFactory(new MappedSegmentFactory());
        configTemplate.setSegmentFileSizeMB(32);
        configTemplate.setNumSyncBatches(2);
        configTemplate.setBatchSize(100);
       
        // Create multi-tenant store responder
        ArrayStoreFactory storeFactory = new StaticArrayStoreFactory();
        StoreResponderFactory responderFactory = new BasicArrayStoreResponderFactory(storeFactory);
        MultiTenantStoreResponder mtStoreResponder = new MultiTenantStoreResponder(homeDir, configTemplate, responderFactory);
View Full Code Here

                                     File homeDir,
                                     SegmentFactory segmentFactory,
                                     int segmentFileSizeMB,
                                     double segmentCompactFactor,
                                     boolean checked) throws Exception {
        _config = new StorePartitionConfig(homeDir, idStart, idCount);
        _config.setBatchSize(batchSize);
        _config.setNumSyncBatches(numSyncBatches);
        _config.setSegmentFactory(segmentFactory);
        _config.setSegmentFileSizeMB(segmentFileSizeMB);
        _config.setSegmentCompactFactor(segmentCompactFactor);
View Full Code Here

   
    public void testApiBasics() throws IOException {
        int partitionStart = getPartitionStart();
        int partitionCount = getPartitionCount();
       
        StorePartitionConfig config = new StorePartitionConfig(getHomeDir(), partitionStart, partitionCount);
       
        assertEquals(partitionStart, config.getPartitionStart());
        assertEquals(partitionCount, config.getPartitionCount());
       
        assertEquals(StoreParams.INDEXES_CACHED_DEFAULT, config.isIndexesCached());
        assertEquals(StoreParams.INDEXES_CACHED_DEFAULT, config.getIndexesCached());
       
        assertEquals(StoreParams.BATCH_SIZE_DEFAULT, config.getBatchSize());
        assertEquals(StoreParams.NUM_SYNC_BATCHES_DEFAULT, config.getNumSyncBatches());
       
        assertEquals(StoreParams.SEGMENT_FILE_SIZE_MB_DEFAULT, config.getSegmentFileSizeMB());
        assertEquals(StoreParams.SEGMENT_COMPACT_FACTOR_DEFAULT, config.getSegmentCompactFactor());
        assertEquals(StoreParams.HASH_LOAD_FACTOR_DEFAULT, config.getHashLoadFactor());
       
        assertEquals(MappedSegmentFactory.class, config.getSegmentFactory().getClass());
        assertEquals(MappedSegmentFactory.class.getName(), config.getProperty(StoreParams.PARAM_SEGMENT_FACTORY_CLASS));
       
        assertEquals(FnvHashFunction.class, config.getHashFunction().getClass());
        assertEquals(FnvHashFunction.class.getName(), config.getProperty(StoreParams.PARAM_HASH_FUNCTION_CLASS));
       
        boolean indexesCached = false;
        config.setIndexesCached(indexesCached);
        assertEquals(indexesCached, config.isIndexesCached());
        assertEquals(indexesCached, config.getIndexesCached());
       
        int batchSize = StoreParams.BATCH_SIZE_DEFAULT + 100;
        config.setBatchSize(batchSize);
        assertEquals(batchSize, config.getBatchSize());
       
        int numSyncBatches = StoreParams.NUM_SYNC_BATCHES_DEFAULT + 5;
        config.setNumSyncBatches(numSyncBatches);
        assertEquals(numSyncBatches, config.getNumSyncBatches());
       
        int segmentFileSizeMB = StoreParams.SEGMENT_FILE_SIZE_MB_DEFAULT - 10;
        config.setSegmentFileSizeMB(segmentFileSizeMB);
        assertEquals(segmentFileSizeMB, config.getSegmentFileSizeMB());
       
        double segmentCompactFactor = StoreParams.SEGMENT_COMPACT_FACTOR_DEFAULT + 0.07;
        config.setSegmentCompactFactor(segmentCompactFactor);
        assertEquals(segmentCompactFactor, config.getSegmentCompactFactor());
       
        double hashLoadFactor = StoreParams.HASH_LOAD_FACTOR_DEFAULT - 0.07;
        config.setHashLoadFactor(hashLoadFactor);
        assertEquals(hashLoadFactor, config.getHashLoadFactor());
       
        config.validate();
        config.save();
       
        StorePartitionConfig config2 = new StorePartitionConfig(getHomeDir(), partitionStart, partitionCount);
       
        assertEquals(config.isIndexesCached(), config2.isIndexesCached());
        assertEquals(config.getIndexesCached(), config2.getIndexesCached());
       
        assertEquals(config.getBatchSize(), config2.getBatchSize());
        assertEquals(config.getNumSyncBatches(), config2.getNumSyncBatches());
       
        assertEquals(config.getSegmentFileSizeMB(), config.getSegmentFileSizeMB());
        assertEquals(config.getSegmentCompactFactor(), config.getSegmentCompactFactor());
        assertEquals(config.getHashLoadFactor(), config.getHashLoadFactor());
       
        File propertiesFile = new File(getHomeDir(), StorePartitionConfig.CONFIG_PROPERTIES_FILE+".new");
       
        config.setHashFunction(new Fnv1aHash64());
        config.setSegmentFactory(new MemorySegmentFactory());
        config.setSegmentFileSizeMB(StoreParams.SEGMENT_FILE_SIZE_MB_MIN);
        config.setNumSyncBatches(StoreParams.BATCH_SIZE_MIN);
        config.setBatchSize(StoreParams.BATCH_SIZE_MIN);
        config.save(propertiesFile, null);
       
        config2.load(propertiesFile);
        assertEquals(MemorySegmentFactory.class, config2.getSegmentFactory().getClass());
        assertEquals(MemorySegmentFactory.class.getName(), config2.getProperty(StoreParams.PARAM_SEGMENT_FACTORY_CLASS));
        assertEquals(Fnv1aHash64.class, config2.getHashFunction().getClass());
        assertEquals(Fnv1aHash64.class.getName(), config2.getProperty(StoreParams.PARAM_HASH_FUNCTION_CLASS));
        assertEquals(StoreParams.SEGMENT_FILE_SIZE_MB_MIN, config2.getSegmentFileSizeMB());
        assertEquals(StoreParams.NUM_SYNC_BATCHES_MIN, config2.getNumSyncBatches());
        assertEquals(StoreParams.BATCH_SIZE_MIN, config2.getBatchSize());
       
        config2.validate();
    }
View Full Code Here

        assertEquals(start, store.getIndexStart());
        store.clear();
        store.close();
       
        // Use StoreConfig
        StorePartitionConfig config = new StorePartitionConfig(homeDir, start, count);
        config.setBatchSize(batchSize);
        config.setNumSyncBatches(numSyncBatches);
        config.setSegmentFileSizeMB(segmentFileSizeMB);
        config.setSegmentFactory(segmentFactory);
        config.setSegmentCompactFactor(segmentCompactFactor);
        store = StoreFactory.createArrayStorePartition(config);
       
        assertEquals(length, store.length());
        assertEquals(length, store.capacity());
        assertEquals(start, store.getIndexStart());
View Full Code Here

       
        config2.validate();
    }
   
    public void testCornerCases() throws IOException {
        StorePartitionConfig config = null;
       
        try {
            config = new StorePartitionConfig(getHomeDir(), -1, 100);
            assertFalse(true);
        } catch (IllegalArgumentException e) {}
       
        try {
            config = new StorePartitionConfig(getHomeDir(), 10, 0);
            assertFalse(true);
        } catch (IllegalArgumentException e) {}
       
        try {
            config = new StorePartitionConfig(getHomeDir(), 1, Integer.MAX_VALUE);
            assertFalse(true);
        } catch (InvalidStoreConfigException e) {}
       
        config = new StorePartitionConfig(getHomeDir(), 0, Integer.MAX_VALUE);
        assertEquals(0, config.getPartitionStart());
        assertEquals(Integer.MAX_VALUE, config.getPartitionEnd());
        assertEquals(Integer.MAX_VALUE, config.getPartitionCount());
        assertEquals(Integer.MAX_VALUE, config.getInitialCapacity());
    }
View Full Code Here

*/
public class TestArrayStorePartitionIterator extends AbstractTestArrayStoreIterator {
   
    @Override
    protected ArrayStore createStore(File homeDir) throws Exception {
        StorePartitionConfig config = new StorePartitionConfig(homeDir, 101, 1000);
        return StoreFactory.createArrayStorePartition(config);
    }
View Full Code Here

        int partitionCount = config.getInitialCapacity();
        config.setProperty(StoreParams.PARAM_PARTITION_COUNT, "" +  partitionCount);
        config.setProperty(StoreParams.PARAM_PARTITION_START, "" + partitionStart);
        config.save();
       
        StorePartitionConfig config3 = (StorePartitionConfig)StoreConfig.newInstance(new File(getHomeDir(), StoreConfig.CONFIG_PROPERTIES_FILE));
        StorePartitionConfig config4 = (StorePartitionConfig)StoreConfig.newInstance(getHomeDir());
       
        assertEquals(config.getInitialCapacity(), config3.getInitialCapacity());
        assertEquals(config.getInitialCapacity(), config4.getInitialCapacity());
        assertEquals(StorePartitionConfig.class, config3.getClass());
        assertEquals(StorePartitionConfig.class, config4.getClass());
       
        assertEquals(partitionStart, config3.getPartitionStart());
        assertEquals(partitionCount, config3.getPartitionCount());
        assertEquals(partitionStart, config4.getPartitionStart());
        assertEquals(partitionCount, config4.getPartitionCount());
    }
View Full Code Here

TOP

Related Classes of krati.core.StorePartitionConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.