public void iterateData()

in bigtop-bigpetstore/bigpetstore-transaction-queue/src/main/java/org/apache/bigtop/bigpetstore/qstream/LoadGen.java [123:173]


    public void iterateData(LinkedBlockingQueue<Transaction> queue,long rseed) throws Throwable {
        long start = System.currentTimeMillis();
        final InputData inputData = new DataLoader().loadData();
        final SeedFactory seedFactory = new SeedFactory(rseed);

        System.out.println("Generating stores...");
        final ArrayList<Store> stores = new ArrayList<Store>();
        final StoreGenerator storeGenerator = new StoreGenerator(inputData, seedFactory);
        for (int i = 0; i < nStores; i++) {
            Store store = storeGenerator.generate();
            stores.add(store);
        }

        System.out.println("Generating customers...");

        final List<Customer> customers = Lists.newArrayList();
        final CustomerGenerator custGen = new CustomerGenerator(inputData, stores, seedFactory);
        for (int i = 0; i < nCustomers; i++) {
            Customer customer = custGen.generate();
            customers.add(customer);
        }

        System.out.println("...Generated " + customers.size());

        Long nextSeed = seedFactory.getNextSeed();

        Collection<ProductCategory> products = inputData.getProductCategories();
        Iterator<Customer> custIter = customers.iterator();

        if(! custIter.hasNext())
            throw new RuntimeException("No customer data ");
        //Create a new purchasing profile.
        PurchasingProfileGenerator profileGen = new PurchasingProfileGenerator(products, seedFactory);
        PurchasingProfile profile = profileGen.generate();

        /** Stop either if
        * 1) the queue is full
        * 2) run out of customers).
        */
        while(queue.remainingCapacity()>0 && custIter.hasNext()){
            Customer cust = custIter.next();
            int transactionsForThisCustomer = 0;
            TransactionGenerator transGen = new TransactionGenerator(cust, profile, stores, products, seedFactory);
            Transaction trC = transGen.generate();
            while(trC.getDateTime()<simulationLength) {
                queue.put(trC);
                trC=transGen.generate();
            }
        }

    }