Package org.apache.olio.workload.loader.framework

Examples of org.apache.olio.workload.loader.framework.ThreadConnection


        ifields[0] = r.random(1, ScaleFactors.users); // addressId
        // The rest is initialized to 0 anyway, leave it that way.
    }
   
     public void load() {
        ThreadConnection c = ThreadConnection.getInstance();
        try {
            PreparedStatement s = c.prepareStatement(STATEMENT);
            for (int i = 0; i < fields.length; i++)
                if (fields[i] != null)
                    s.setString(i + 1, fields[i]);
                else
                    s.setNull(i + 1, Types.VARCHAR);
            s.setDate(10, createdTimestamp);
            for (int i = 0; i < ifields.length; i++)
                s.setInt(11 + i, ifields[i]);
            c.addBatch();
        } catch (SQLException e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }
View Full Code Here


     /**
     * For tags, we won't know the refcount till all the data is loaded.
     * So we update the table at postload.
     */
    public void postLoad() {
        ThreadConnection c = ThreadConnection.getInstance();
        try {
            //update id
             logger.fine("before updating socialEventID");            
            
             c.prepareStatement("INSERT INTO ID_GEN " +
                    "(GEN_KEY, GEN_VALUE) " +
                    "VALUES ('SOCIAL_EVENT_ID', "+ ScaleFactors.events +1 + ")");
             c.executeUpdate();                         
            
            /*
             c.prepareStatement("update ID_GEN set GEN_VALUE = " +
                    "(select count(*) +1 from SOCIALEVENT) " +
                    "where GEN_KEY='SOCIAL_EVENT_ID'");
View Full Code Here

        //for (int friendId : friendSet)
         //   friends[idx++] = UserName.getUserName(friendId);
    }

    public void load() {
        ThreadConnection c = ThreadConnection.getInstance();
        try {
        //    for (String friend : friends) {
        for (Integer friend : friendSet) {
                PreparedStatement s = c.prepareStatement(STATEMENT);
                //s.setString(1, userName);
                //s.setString(2, friend);
        s.setInt(1, id);
        s.setInt(2, friend);
                c.addBatch();
            }
        } catch (SQLException e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
            //LoadController.increaseErrorCount();
        }
View Full Code Here

        tag = UserName.getUserName(id);
    }


    public void load() {
        ThreadConnection c = ThreadConnection.getInstance();
        try {
            PreparedStatement s = c.prepareStatement(STATEMENT);
            s.setString(1, tag);
            s.setInt(2, 0); // Initialize it to 0 first, count and add later.
            c.addBatch();
        } catch (SQLException e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
            Loader.increaseErrorCount();
        }
    }
View Full Code Here

    /**
     * For tags, we won't know the refcount till all the data is loaded.
     * So we update the table at postload.
     */
    public void postLoad() {
        ThreadConnection c = ThreadConnection.getInstance();
        try {
            c.prepareStatement("update SOCIALEVENTTAG set refcount = " +
                    "(select count(*) from SOCIALEVENTTAG_SOCIALEVENT " +
                    "where socialeventtagid = " +
                    "SOCIALEVENTTAG.socialeventtagid)");
            c.executeUpdate();
            //update id
           
            logger.fine("updating Tag ID_GEN ID");
             /*
             c.prepareStatement("update ID_GEN set GEN_VALUE = " +
                    "(select count(*) +1 from SOCIALEVENTTAG) " +
                    "where GEN_KEY='SOCIAL_EVENT_TAG_ID'");
             c.executeUpdate();
             */                       
             c.prepareStatement("INSERT INTO ID_GEN " +
                    "(GEN_KEY, GEN_VALUE) " +
                    "VALUES ('SOCIAL_EVENT_TAG_ID', "+ ScaleFactors.tagCount + ")");
             c.executeUpdate();
            
            logger.fine("After updating Tag ID_GEN ID");
        } catch (SQLException e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
        }
View Full Code Here

    }


    public void load() {
        ThreadConnection c = ThreadConnection.getInstance();
        try {
            for (int i = 0; i < userNames.length; i++) {
                PreparedStatement s = c.prepareStatement(STATEMENT);
                s.setString(1, userNames[i]);
                s.setInt(2, eventId);
                s.setString(3, comments[i]);
                s.setInt(4, ratings[i]);
                s.setDate(5, created_at);
                c.addBatch();
               
            }
        } catch (SQLException e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
            //LoadController.increaseErrorCount();
View Full Code Here

       /**
     * For address, update ID after all the data is loaded.
     * So we update the ID_GEN table at postload and add 1 to count.
     */
    public void postLoad() {
        ThreadConnection c = ThreadConnection.getInstance();
        try {
            //update id
           
            //bug exists in JPA where we are using one ID generator (address)
            //for now, update to a ridiculous high number to avoid duplicate key
            //exceptions
           
           
             logger.fine("updating Comments_Rating ID");
             /*
             c.prepareStatement("update ID_GEN set GEN_VALUE = " +
                    "(select count(*) + 1 from COMMENTS_RATING) " +
                    "where GEN_KEY='COMMENTS_RATING_ID'");
             c.executeUpdate();
             */
           
             logger.fine("Updating Comments_Rating ID");
            
             c.prepareStatement("INSERT INTO ID_GEN " +
                    "(GEN_KEY, GEN_VALUE) " +
                    "VALUES ('COMMENTS_RATING_ID', "+ ScaleFactors.events +1 + ")");
             c.executeUpdate();
             
           
           
             logger.fine("After updating Comments_Rating ID");
        } catch (SQLException e) {
View Full Code Here

        for (int friendId : inviteeSet)
            friends[idx++] = UserName.getUserName(friendId);
    }

    public void load() {
        ThreadConnection c = ThreadConnection.getInstance();
        try {
            for (String friend : friends) {
                PreparedStatement s = c.prepareStatement(STATEMENT);
                int alternate=0;
                if (alternate%2 == 0){
                    s.setInt(1, 0);
                }else{
                    s.setInt(1, 1);
                }
                s.setString(2, requestorUsername);
                s.setString(3, friend);
                
                alternate++;
                c.addBatch();
            }
        } catch (SQLException e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
            System.out.println("the exception is "+ e.getMessage());
            //LoadController.increaseErrorCount();
View Full Code Here

        /**
     * For address, update ID after all the data is loaded.
     * So we update the ID_GEN table at postload and add 1 to count.
     */
    public void postLoad() {
        ThreadConnection c = ThreadConnection.getInstance();
        try {
            //update id
           
            //bug exists in JPA where we are using one ID generator (address)
            //for now, update to a ridiculous high number to avoid duplicate key
            //exceptions
           
           
             logger.fine("Updating Invitation ID");
             c.prepareStatement("INSERT INTO ID_GEN " +
                    "(GEN_KEY, GEN_VALUE) " +
                    "VALUES ('INVITATION_ID', "+ ScaleFactors.users +1 + ")");
             c.executeUpdate();
           
           
           
             logger.fine("After updating Invitation ID");
        } catch (SQLException e) {
View Full Code Here

            tagIds[idx++] = tagId;
    }


    public void load() {
        ThreadConnection c = ThreadConnection.getInstance();
        try {
            for (int tagId : tagIds) {
                PreparedStatement s = c.prepareStatement(STATEMENT);
                s.setInt(1, tagId);
                s.setInt(2, eventId);
                c.addBatch();
            }
        } catch (SQLException e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.olio.workload.loader.framework.ThreadConnection

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.