public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException
    {
        long startTimestamp;
        long endTimestamp;
        long totalTime;
        int request;
        List<User> userList = new ArrayList();
        List<Feed> feedList = new ArrayList();

        Cluster cluster = HFactory.getOrCreateCluster("TestCluster", "localhost:9160");
        DataReadWriteService service = new DataReadWriteService(cluster);

        // Create sample data for user and feed
        for (int i = 0; i < Constants.UserCount; i++)
        {
            User user = new User("tinvk " + i, i);
            service.insertUser(user);
            userList.add(user);
        }

        for (int i = 0; i < Constants.FeedCount; i++)
        {
            // Get random owner
            int userOrder = (int) (Math.random() * Constants.UserCount);
            User user = userList.get(userOrder);
            Feed feed = new Feed(user.getUserId(), "Hello World", "Image link");
            feedList.add(feed);
            service.insertFeed(feed.getFeedId(), feed.getOwnerId(),
                    feed.getContent(), feed.getThumbnail());
        }

        // Insert user like to a feed
        request = 0;
        startTimestamp = System.currentTimeMillis();
        for (int i = 0; i < Constants.FeedCount; i++)
        {
            Feed feed = feedList.get(i);
            int userCount = (int) (Math.random() * Constants.UserCount);
            userCount = Constants.UserCount;
            request += userCount;
            for (int j = 0; j < userCount; j++)
            {
                User user = userList.get(j);
                service.insertUserLike(feed.getFeedId(), user);
            }
        }
        endTimestamp = System.currentTimeMillis();
        totalTime = endTimestamp - startTimestamp;
        System.out.println("\nTest insert " + request + " records");
        System.out.println("\tTotal time: " + totalTime + "ms");
        System.out.println("\tTime per request: " + (float) totalTime / request + "ms");

        try
        {
            PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("cassandra_test_result.txt", true)));
            out.println("\nTest insert " + request + " records");
            out.println("Total time: " + totalTime + "ms");
            out.println("Time per request: " + (float) totalTime / request + "ms");
            out.close();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }

        // Show list of user that like a feed
        // Create random feed 
        int feedOrder = (int) (Math.random() * Constants.FeedCount);
        Feed feed = feedList.get(feedOrder);
        request = 1000;
        startTimestamp = System.currentTimeMillis();
        List<User> userLiKeList = service.getUserLikeList(feed.getFeedId(), 100);
        endTimestamp = System.currentTimeMillis();
        totalTime = endTimestamp - startTimestamp;
        System.out.println("\nTest : get " + userLiKeList.size() + " user from user like list");
        System.out.println("\tTotal time: " + totalTime + "ms");
        System.out.println("\tTime per request: " + totalTime + "ms");
        try
        {
            PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("cassandra_test_result.txt", true)));
            out.println("\nTest : get " + userLiKeList.size() + " user from user like list");
            out.println("Total time: " + totalTime + "ms");
            out.println("Time per request: " + totalTime + "ms");
            out.close();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        for (User user : userLiKeList)
        {
            System.out.printf("id = %s; name = %s\n", user.getUserId().toString(), user.getName());
        }

        // Close connection
        cluster.getConnectionManager().shutdown();
    }