Пример #1
0
	    //private ExecutorService executor;

        public VideoDbBasicImpl(List<String> contactPoints, String keyspace) 
        {
		    cluster = Cluster
			        .Builder()
			        .AddContactPoints(contactPoints.ToArray())
			        .WithRetryPolicy(Policies.DefaultRetryPolicy)
			        .Build();

		    session = cluster.Connect(keyspace);

		    getUserByNamePreparedStatement = session.Prepare(GET_USER_BY_USERNAME);
		    setUser = session.Prepare(SET_USER);
		    getVideosByUsernamePreparedStatement = session
				    .Prepare(GET_VIDEOS_BY_USERNAME);
            getVideoByIDPreparedStatement = session.Prepare(GET_VIDEO_BY_ID);
            getVideosByTagPreparedStatement = session.Prepare(GET_VIDEOS_BY_TAG);
		    getRatingByVideoPreparedStatement = session
                    .Prepare(GET_RATING_BY_VIDEO);
            setCommentByVideo = session.Prepare(SET_COMMENT_BY_VIDEO);
            setCommentByUsername = session.Prepare(SET_COMMENT_BY_USERNAME);
            getCommentByUsername = session.Prepare(GET_COMMENT_BY_USERNAME);
            getCommentByVideoId = session.Prepare(GET_COMMENT_BY_VIDEOID);

		    timeOfDayRetryPolicy = new TimeOfDayRetryPolicy(9, 17);

		    // Create a thread pool equal to the number of cores
            /*
		    executor = Executors.newFixedThreadPool(Runtime.getRuntime()
				    .availableProcessors());
             */
	    }
Пример #2
0
 public PreparedStatement PrepareQuery(Session session, string query, string messageInstead = null)
 {
     if (messageInstead != null)
         Console.WriteLine("CQL<\t" + messageInstead);
     else
         Console.WriteLine("CQL< Prepared Query:\t" + query);
     var ret = session.Prepare(query);
     Console.WriteLine("CQL> (OK).");
     return ret;
 }