Search in sources :

Example 1 with CacheStorageConfiguration

use of voldemort.store.memory.CacheStorageConfiguration in project voldemort by voldemort.

the class CacheStorageEnginePerformanceTest method main.

public static void main(String[] args) {
    if (args.length != 3)
        Utils.croak("USAGE: java " + CacheStorageEnginePerformanceTest.class.getName() + " num-threads num-requests read-fraction");
    int numThreads = Integer.parseInt(args[0]);
    int numRequests = Integer.parseInt(args[1]);
    double readPercent = Double.parseDouble(args[2]);
    final int valueRange = numRequests / 10;
    final int mod = 100;
    final int readMax = (int) readPercent * mod;
    final Store<ByteArray, byte[], byte[]> store = new CacheStorageConfiguration(null).getStore(TestUtils.makeStoreDefinition("test"), TestUtils.makeSingleNodeRoutingStrategy());
    final AtomicInteger obsoletes = new AtomicInteger(0);
    PerformanceTest readWriteTest = new PerformanceTest() {

        @Override
        public void doOperation(int index) throws Exception {
            try {
                byte[] bytes = Integer.toString(index % valueRange).getBytes();
                ByteArray key = new ByteArray(bytes);
                if (index % mod < readMax)
                    store.get(key, null);
                else
                    store.put(key, new Versioned<byte[]>(bytes), null);
            } catch (ObsoleteVersionException e) {
                obsoletes.incrementAndGet();
            }
        }
    };
    readWriteTest.run(numRequests, numThreads);
    System.out.println("Cache storage engine performance test results:");
    readWriteTest.printStats();
    System.out.println("Number of obsolete puts: " + obsoletes.get());
}
Also used : ObsoleteVersionException(voldemort.versioning.ObsoleteVersionException) Versioned(voldemort.versioning.Versioned) CacheStorageConfiguration(voldemort.store.memory.CacheStorageConfiguration) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ByteArray(voldemort.utils.ByteArray)

Aggregations

AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 CacheStorageConfiguration (voldemort.store.memory.CacheStorageConfiguration)1 ByteArray (voldemort.utils.ByteArray)1 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)1 Versioned (voldemort.versioning.Versioned)1