1 /*
2 * Copyright (C) 2003-2012 David E. Berry
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 *
18 * A copy of the GNU Lesser General Public License may also be found at
19 * http://www.gnu.org/licenses/lgpl.txt
20 */
21
22 package org.synchronoss.cpo.cassandra;
23
24 import com.datastax.driver.core.Cluster;
25 import com.datastax.driver.core.Session;
26
27 /**
28 * Created with IntelliJ IDEA.
29 * User: dberry
30 * Date: 11/10/13
31 * Time: 13:44 PM
32 * To change this template use File | Settings | File Templates.
33 */
34 public class ClusterDataSource {
35 private Cluster cluster = null;
36 private String keySpace = null;
37 private Session session = null;
38
39 private ClusterDataSource(){
40 }
41
42 public ClusterDataSource(Cluster cluster, String keySpace){
43 this.cluster=cluster;
44 this.keySpace=keySpace;
45
46 if (cluster==null)
47 throw new IllegalArgumentException("Cluster cannot be null");
48 if (keySpace==null)
49 throw new IllegalArgumentException("KeySpace cannot be null");
50 session = cluster.connect(keySpace);
51 }
52
53 Session getSession() {
54 return session;
55 }
56 }