Package voldemort.common.service

Examples of voldemort.common.service.SchedulerService


        clientConfig.setBootstrapUrls(bootstrapUrl);
        SocketStoreClientFactory storeClientFactory = new SocketStoreClientFactory(clientConfig);

        sysRepository = new SystemStoreRepository(clientConfig);
        // Start up the scheduler
        scheduler = new SchedulerService(clientConfig.getAsyncJobThreadPoolSize(),
                                         SystemTime.INSTANCE,
                                         true);

        storeClient = new ZenStoreClient<String, String>(STORE_NAME,
                                                         null,
View Full Code Here


    }

    @Test
    public void testCleanupFrequency() {

        SchedulerService scheduler = new SchedulerService(1, time);

        try {
            Date now = new Date();

            // clean up will purge everything older than last 2 seconds
            Runnable cleanupJob = new DataCleanupJob<ByteArray, byte[], byte[]>(engine,
                                                                                new ScanPermitWrapper(1),
                                                                                2 * Time.MS_PER_SECOND,
                                                                                SystemTime.INSTANCE,
                                                                                new EventThrottler(1),
                                                                                null);

            // and will run every 5 seconds starting now
            scheduler.schedule("cleanup-freq-test", cleanupJob, now, 5 * Time.MS_PER_SECOND);

            // load some data
            for(int i = 0; i < 10; i++) {
                ByteArray b = new ByteArray(Integer.toString(i).getBytes());
                engine.put(b, new Versioned<byte[]>(b.get()), null);
            }
            // sleep for 2 seconds
            Thread.sleep(2 * Time.MS_PER_SECOND);

            // None of the keys should have been deleted, i.e data cleanup
            // should n't have run.
            for(int i = 0; i < 10; i++) {
                ByteArray b = new ByteArray(Integer.toString(i).getBytes());
                List<Versioned<byte[]>> found = engine.get(b, null);
                assertTrue("Did not find key '" + i + "' in store!", found.size() > 0);
            }

            // wait till 4 seconds from start
            Thread.sleep(System.currentTimeMillis() - (now.getTime() + 4 * Time.MS_PER_SECOND));
            // load some more data
            for(int i = 10; i < 20; i++) {
                ByteArray b = new ByteArray(Integer.toString(i).getBytes());
                engine.put(b, new Versioned<byte[]>(b.get()), null);
            }

            // give time for data cleanup to finally run
            Thread.sleep(System.currentTimeMillis() - (now.getTime() + 6 * Time.MS_PER_SECOND));

            // first batch of writes should have been deleted
            for(int i = 0; i < 10; i++) {
                ByteArray b = new ByteArray(Integer.toString(i).getBytes());
                List<Versioned<byte[]>> found = engine.get(b, null);
                assertTrue("Expected key '" + i + "' to be deleted!", found.size() == 0);
            }
            // and later ones retained.
            for(int i = 10; i < 20; i++) {
                ByteArray b = new ByteArray(Integer.toString(i).getBytes());
                List<Versioned<byte[]>> found = engine.get(b, null);
                assertTrue("Expected key '" + i + "' to be retained!", found.size() > 0);
            }

        } catch(Exception e) {

        } finally {
            scheduler.stop();
        }
    }
View Full Code Here

* Test {@link voldemort.server.protocol.admin.AsyncOperationService}
*/
public class AsyncOperationTest extends TestCase {

    public void testAsyncOperationService() throws Exception {
        SchedulerService schedulerService = new SchedulerService(2, SystemTime.INSTANCE);
        AsyncOperationService asyncOperationService = new AsyncOperationService(schedulerService,
                                                                                10);

        final AtomicBoolean op0Complete = new AtomicBoolean(false);
        final AtomicBoolean op1Complete = new AtomicBoolean(false);
View Full Code Here

        sysVersionStore = systemStoreFactory.createSystemStore(SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name());
        repository = new SystemStoreRepository(clientConfig);

        repository.addSystemStore(sysVersionStore,
                                  SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name());
        this.scheduler = new SchedulerService(2, SystemTime.INSTANCE, true);
    }
View Full Code Here

            };
            asyncMetadataManager = new AsyncMetadataVersionManager(sysRepository,
                                                                   rebootstrapCallback,
                                                                   null);

            schedulerService = new SchedulerService(1, SystemTime.INSTANCE, true);
            schedulerService.schedule(asyncMetadataManager.getClass().getName(),
                                      asyncMetadataManager,
                                      new Date(),
                                      this.coordinatorConfig.getMetadataCheckIntervalInMs());
        } catch(BootstrapFailureException be) {
View Full Code Here

    public void setUp() {
        config.setEnableServerRouting(true); // this is turned off by default
        metadataDir = new File(config.getMetadataDirectory());
        metadataDir.mkdir();
        config.setBdbCacheSize(100000);
        this.scheduler = new SchedulerService(1, new MockTime());
        this.storeRepository = new StoreRepository();
        storage = new StorageService(storeRepository, mdStore, scheduler, config);
        storage.start();
    }
View Full Code Here

        File temp = TestUtils.createTempDir();
        VoldemortConfig config = new VoldemortConfig(0, temp.getAbsolutePath());
        new File(config.getMetadataDirectory()).mkdir();
        this.serverMap = new HashMap<Integer, VoldemortServer>();
        this.scheduler = new SchedulerService(1, new MockTime());
        this.cluster = VoldemortTestConstants.getNineNodeCluster();
        StoreDefinitionsMapper mapper = new StoreDefinitionsMapper();
        this.storeDefs = mapper.readStoreList(new StringReader((VoldemortTestConstants.getSingleStore322Xml())));
        this.storeRepository = new StoreRepository();
        this.metadataStore = ServerTestUtils.createMetadataStore(cluster, storeDefs);
View Full Code Here

        if(!isZenStoreResourcesInited.get()) {
            // since the method is synchronized, only one winning thread will
            // make it here.
            this.sysRepository = new SystemStoreRepository(config);
            // Start up the scheduler
            this.scheduler = new SchedulerService(config.getAsyncJobThreadPoolSize(),
                                                  SystemTime.INSTANCE,
                                                  true);
            this.scheduler.start();
            isZenStoreResourcesInited.set(true);
        }
View Full Code Here

    private List<VoldemortService> createBasicServices() {

        /* Services are given in the order they must be started */
        List<VoldemortService> services = new ArrayList<VoldemortService>();
        SchedulerService scheduler = new SchedulerService(voldemortConfig.getSchedulerThreads(),
                                                          SystemTime.INSTANCE,
                                                          voldemortConfig.canInterruptService());
        storageService = new StorageService(storeRepository, metadata, scheduler, voldemortConfig);
        asyncService = new AsyncOperationService(scheduler, ASYNC_REQUEST_CACHE_SIZE);
        jmxService = null;
View Full Code Here

        sysVersionStore = systemStoreFactory.createSystemStore(SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name());

        repository = new SystemStoreRepository(clientConfig);
        repository.addSystemStore(sysVersionStore,
                                  SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name());
        this.scheduler = new SchedulerService(2, SystemTime.INSTANCE, true);

        Callable<Void> rebootstrapCallback = new Callable<Void>() {

            @Override
            public Void call() throws Exception {
View Full Code Here

TOP

Related Classes of voldemort.common.service.SchedulerService

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.