Search in sources :

Example 1 with UndefinedPropertyException

use of voldemort.utils.UndefinedPropertyException in project voldemort by voldemort.

the class HadoopUtils method getPropsFromJob.

public static Props getPropsFromJob(Configuration conf) {
    String propsString = conf.get("azkaban.props");
    if (propsString == null)
        throw new UndefinedPropertyException("The required property azkaban.props was not found in the Configuration.");
    try {
        ByteArrayInputStream input = new ByteArrayInputStream(propsString.getBytes("UTF-8"));
        Properties properties = new Properties();
        properties.load(input);
        return new Props(properties);
    } catch (IOException e) {
        throw new RuntimeException("This is not possible!", e);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) Properties(java.util.Properties) Props(voldemort.utils.Props) UndefinedPropertyException(voldemort.utils.UndefinedPropertyException)

Example 2 with UndefinedPropertyException

use of voldemort.utils.UndefinedPropertyException in project voldemort by voldemort.

the class DefaultWorkload method init.

/**
     * Initialize the workload. Called once, in the main client thread, before
     * any operations are started.
     */
@Override
public void init(Props props) {
    int readPercent = props.getInt(Benchmark.READS, 0);
    int writePercent = props.getInt(Benchmark.WRITES, 0);
    int deletePercent = props.getInt(Benchmark.DELETES, 0);
    int mixedPercent = props.getInt(Benchmark.MIXED, 0);
    int valueSize = props.getInt(Benchmark.VALUE_SIZE, 1024);
    this.value = new String(TestUtils.randomBytes(valueSize));
    this.sampleSize = props.getInt(Benchmark.SAMPLE_SIZE, 0);
    int cachedPercent = props.getInt(Benchmark.PERCENT_CACHED, 0);
    String keyType = props.getString(Benchmark.KEY_TYPE, Benchmark.STRING_KEY_TYPE);
    String recordSelection = props.getString(Benchmark.RECORD_SELECTION, Benchmark.UNIFORM_RECORD_SELECTION);
    boolean hasTransforms = props.getString(Benchmark.HAS_TRANSFORMS, "false").compareTo("true") == 0;
    double readProportion = (double) readPercent / (double) 100;
    double writeProportion = (double) writePercent / (double) 100;
    double deleteProportion = (double) deletePercent / (double) 100;
    double mixedProportion = (double) mixedPercent / (double) 100;
    // Using default read only
    if (Math.abs(writeProportion + readProportion + mixedProportion + deleteProportion) != 1.0) {
        throw new VoldemortException("The sum of all workload percentage is NOT 100% \n" + " Read=" + (double) readPercent / (double) 100 + " Write=" + (double) writePercent / (double) 100 + " Delete=" + (double) deletePercent / (double) 100 + " Mixed=" + (double) mixedPercent / (double) 100);
    }
    List<Integer> keysFromFile = null;
    int recordCount = 0;
    if (props.containsKey(Benchmark.REQUEST_FILE)) {
        try {
            String fileRecordSelectionFile = props.getString(Benchmark.REQUEST_FILE);
            if (!new File(fileRecordSelectionFile).exists()) {
                throw new UndefinedPropertyException("File does not exist");
            }
            keysFromFile = loadKeys(new File(fileRecordSelectionFile));
            recordSelection = new String(Benchmark.FILE_RECORD_SELECTION);
        } catch (Exception e) {
            // Falling back to default uniform selection
            recordSelection = new String(Benchmark.UNIFORM_RECORD_SELECTION);
        }
    } else {
        recordCount = props.getInt(Benchmark.RECORD_COUNT, -1);
    }
    // 2. sample_size shall be no greater than # of keys in the request_file
    if (sampleSize > 0) {
        if (recordSelection.compareTo(Benchmark.FILE_RECORD_SELECTION) != 0) {
            sampleSize = 0;
            logger.warn(Benchmark.SAMPLE_SIZE + " will be ignored because " + Benchmark.REQUEST_FILE + " is not specified.");
        } else if (keysFromFile.size() < sampleSize) {
            sampleSize = keysFromFile.size();
            logger.warn(Benchmark.SAMPLE_SIZE + " is reduced to " + sampleSize + " because it was larger than number of keys in " + Benchmark.REQUEST_FILE);
        }
    }
    int opCount = props.getInt(Benchmark.OPS_COUNT);
    Class<?> keyTypeClass = getKeyTypeClass(keyType);
    int insertStart = props.getInt(Benchmark.START_KEY_INDEX, 0);
    IntegerGenerator warmUpKeySequence = new CounterGenerator(insertStart);
    this.warmUpKeyProvider = getKeyProvider(keyTypeClass, warmUpKeySequence, 0);
    this.transformsChooser = null;
    if (hasTransforms) {
        this.transformsChooser = new DiscreteGenerator();
        List<String> transforms = BenchmarkViews.getTransforms();
        for (String transform : transforms) {
            this.transformsChooser.addValue(1.0, transform);
        }
    }
    operationChooser = new DiscreteGenerator();
    if (readProportion > 0) {
        operationChooser.addValue(readProportion, Benchmark.READS);
    }
    if (mixedProportion > 0) {
        operationChooser.addValue(mixedProportion, Benchmark.MIXED);
    }
    if (writeProportion > 0) {
        operationChooser.addValue(writeProportion, Benchmark.WRITES);
    }
    if (deleteProportion > 0) {
        operationChooser.addValue(deleteProportion, Benchmark.DELETES);
    }
    CounterGenerator insertKeySequence = null;
    if (recordCount > 0) {
        insertKeySequence = new CounterGenerator(recordCount);
    } else {
        Random randomizer = new Random();
        insertKeySequence = new CounterGenerator(randomizer.nextInt(Integer.MAX_VALUE));
    }
    IntegerGenerator keyGenerator = null;
    if (recordSelection.compareTo(Benchmark.UNIFORM_RECORD_SELECTION) == 0) {
        int keySpace = (recordCount > 0) ? recordCount : Integer.MAX_VALUE;
        keyGenerator = new UniformIntegerGenerator(0, keySpace - 1);
    } else if (recordSelection.compareTo(Benchmark.ZIPFIAN_RECORD_SELECTION) == 0) {
        int expectedNewKeys = (int) (opCount * writeProportion * 2.0);
        keyGenerator = new ScrambledZipfianGenerator(recordCount + expectedNewKeys);
    } else if (recordSelection.compareTo(Benchmark.LATEST_RECORD_SELECTION) == 0) {
        keyGenerator = new SkewedLatestGenerator(insertKeySequence);
    } else if (recordSelection.compareTo(Benchmark.FILE_RECORD_SELECTION) == 0) {
        keyGenerator = new FileIntegerGenerator(0, keysFromFile);
    }
    this.keyProvider = getKeyProvider(keyTypeClass, keyGenerator, cachedPercent);
    this.randomSampler = new Random(System.currentTimeMillis());
}
Also used : CounterGenerator(voldemort.performance.benchmark.generator.CounterGenerator) DiscreteGenerator(voldemort.performance.benchmark.generator.DiscreteGenerator) FileIntegerGenerator(voldemort.performance.benchmark.generator.FileIntegerGenerator) VoldemortException(voldemort.VoldemortException) UndefinedPropertyException(voldemort.utils.UndefinedPropertyException) VoldemortException(voldemort.VoldemortException) IOException(java.io.IOException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) UniformIntegerGenerator(voldemort.performance.benchmark.generator.UniformIntegerGenerator) IntegerGenerator(voldemort.performance.benchmark.generator.IntegerGenerator) FileIntegerGenerator(voldemort.performance.benchmark.generator.FileIntegerGenerator) Random(java.util.Random) SkewedLatestGenerator(voldemort.performance.benchmark.generator.SkewedLatestGenerator) File(java.io.File) UndefinedPropertyException(voldemort.utils.UndefinedPropertyException) ScrambledZipfianGenerator(voldemort.performance.benchmark.generator.ScrambledZipfianGenerator) UniformIntegerGenerator(voldemort.performance.benchmark.generator.UniformIntegerGenerator)

Aggregations

IOException (java.io.IOException)2 UndefinedPropertyException (voldemort.utils.UndefinedPropertyException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 Properties (java.util.Properties)1 Random (java.util.Random)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 VoldemortException (voldemort.VoldemortException)1 CounterGenerator (voldemort.performance.benchmark.generator.CounterGenerator)1 DiscreteGenerator (voldemort.performance.benchmark.generator.DiscreteGenerator)1 FileIntegerGenerator (voldemort.performance.benchmark.generator.FileIntegerGenerator)1 IntegerGenerator (voldemort.performance.benchmark.generator.IntegerGenerator)1 ScrambledZipfianGenerator (voldemort.performance.benchmark.generator.ScrambledZipfianGenerator)1 SkewedLatestGenerator (voldemort.performance.benchmark.generator.SkewedLatestGenerator)1 UniformIntegerGenerator (voldemort.performance.benchmark.generator.UniformIntegerGenerator)1 Props (voldemort.utils.Props)1