Package com.sun.faban.driver.util

Examples of com.sun.faban.driver.util.Random


    }

    public void prepare() {
    id = getSequence() + 1;
        ThreadResource tr = ThreadResource.getInstance();
        Random r = tr.getRandom();
        int count = r.random(2, 28);

        LinkedHashSet<Integer> friendSet = new LinkedHashSet<Integer>(count);
        for (int i = 0; i < count; i++) {
            int friendId;
            do { // Prevent friend to be the same user.
                friendId = r.random(1, ScaleFactors.users);
            } while (friendId == id || !friendSet.add(friendId));
        }

        friends = new int[friendSet.size()];
        int idx = 0;
View Full Code Here


    }

    public void prepare() {
    eventId = getSequence() + 1;
        ThreadResource tr = ThreadResource.getInstance();
        Random r = tr.getRandom();
        int commentCount = r.random(0, 20);
        users = new int[commentCount];
        comments = new String[commentCount];
        ratings = new int[commentCount];
        for (int i = 0; i < users.length; i++) {
            users[i] = r.random(1, ScaleFactors.users);;
            comments[i] = r.makeCString(250, 1024);
            ratings[i] = r.random(2, 5);
        }
        createdTimestamp = r.makeDateInInterval( //createdtimestamp
                BASE_DATE, -540, 0);
    }
View Full Code Here

    }

    public void prepare() {
    eventId = getSequence() + 1;
        ThreadResource tr = ThreadResource.getInstance();
        Random r = tr.getRandom();
        int numTags = r.random(1, 7); // Avg is 4 tags per event
        LinkedHashSet<Integer> tagSet = new LinkedHashSet<Integer>(numTags);
        for (int i = 0; i < numTags; i++)
            while (!tagSet.add(RandomUtil.randomTagId(r, 0.1d)));

        tagIds = new int[tagSet.size()];
View Full Code Here

        return "truncate table addresses";
    }
   
    public void prepare() {
        ThreadResource tr = ThreadResource.getInstance();
        Random r = tr.getRandom();
        StringBuilder buffer = tr.getBuffer();
        buffer.append(r.makeNString(1, 5)).append(' '); // number
        RandomUtil.randomName(r, buffer, 1, 11); // street
        String streetExt = STREETEXTS[r.random(0, STREETEXTS.length - 1)];
        if (streetExt.length() > 0)
            buffer.append(' ').append(streetExt);

        fields[0] = buffer.toString();

        int toggle = r.random(0, 1); // street2
        if (toggle > 0)
            fields[1] = r.makeCString(5, 20);

        fields[2] = r.makeCString(4, 14); // city
        fields[3] = r.makeCString(2, 2).toUpperCase(); // state
        fields[4] = r.makeNString(5, 5)// zip

        toggle = r.random(0, 1);
        if (toggle == 0) {
            fields[5] = "USA";
        } else {
            buffer.setLength(0);
            fields[5] = RandomUtil.randomName(r, buffer, 6, 16).toString();
        }
        // Latitude, we do not get addresses in polar circles. So the limit
        fields[6] = String.format("%.6f", r.drandom(-66.560556d, 66.560556d));

        fields[7] = String.format("%.6f", r.drandom(-179.999999d, 180d));
    }
View Full Code Here

    }

    public void prepare() {
    eventId = getSequence() + 1;
        ThreadResource tr = ThreadResource.getInstance();
        Random r = tr.getRandom();
        int attendees = r.random(10, 100);
        userIdSet = new LinkedHashSet<Integer>(attendees);
        for (int i = 0; i <attendees; i++)
            while(!userIdSet.add(r.random(1, ScaleFactors.users)));
    }
View Full Code Here

    public void prepare() {
    id = getSequence();
        ++id;
      imageId = ScaleFactors.events + id;
        ThreadResource tr = ThreadResource.getInstance();
        Random r = tr.getRandom();
        StringBuilder b = tr.getBuffer();
        fields[0] = UserName.getUserName(id);
        fields[1] = String.valueOf(id);
        fields[2] = RandomUtil.randomName(r, b, 2, 12).toString();
        b.setLength(0);
        fields[3] = RandomUtil.randomName(r, b, 5, 15).toString();
        fields[4] = r.makeCString(3, 10);
        fields[4] = fields[2] + '_' + fields[3] + '@' + fields[4] + ".com";
        b.setLength(0);
        fields[5] = RandomUtil.randomPhone(r, b);
        fields[6] = RandomUtil.randomText(r, 250, 2500);
        fields[7] = "PST";
        addressId = r.random(1, ScaleFactors.users);
        thumbnail = imageId;
    }
View Full Code Here

        this.id = id;
        this.driverClass = driverClass;
        this.timer = timer;
        this.runInfo = RunInfo.getInstance();
        this.agent = agent;
        random = new Random(System.nanoTime() + hashCode());
        className = getClass().getName();
        driverConfig = runInfo.driverConfig;
        name = type + '[' + agentId + "]." + id;
        setName(name);
        logger = Logger.getLogger(className + '.' + id);
View Full Code Here

     * @return Always the same random value generator
     * @see com.sun.faban.driver.DriverContext#getRandom()
     */
  public Random getRandom() {
        if (random == null) {
      random = new Random();
    }
        return random;
    }
View Full Code Here

TOP

Related Classes of com.sun.faban.driver.util.Random

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.