import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.SimpleStatement;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.SimpleStatement;
import com.datastax.driver.core.TableMetadata;
import com.datastax.driver.core.exceptions.AlreadyExistsException;
import com.datastax.driver.core.exceptions.InvalidQueryException;
import com.datastax.driver.core.TableMetadata;
import com.datastax.driver.core.exceptions.AlreadyExistsException;
import com.datastax.driver.core.exceptions.InvalidQueryException;
public void setCluster(Cluster cluster) {
EnumNameCodec<LockType> lockTypeCodec = new EnumNameCodec<LockType>(LockType.class);
cluster.getConfiguration().getCodecRegistry().register(lockTypeCodec);
public void setCluster(Cluster cluster) {
EnumNameCodec<LockType> lockTypeCodec = new EnumNameCodec<LockType>(LockType.class);
cluster.getConfiguration().getCodecRegistry().register(lockTypeCodec);
poolingOptions
.setConnectionsPerHost(HostDistance.LOCAL, 4, 10)
.setConnectionsPerHost(HostDistance.REMOTE, 2, 4);
poolingOptions
.setConnectionsPerHost(HostDistance.LOCAL, 4, 10)
.setConnectionsPerHost(HostDistance.REMOTE, 2, 4);
Cluster cluster;
if(MusicUtil.getCassName() != null && MusicUtil.getCassPwd() != null) {
String cassPwd = CipherUtil.decryptPKC(MusicUtil.getCassPwd());
logger.info(EELFLoggerDelegate.applicationLogger,
"Building with credentials "+MusicUtil.getCassName()+" & "+ MusicUtil.getCassPwd());
cluster = Cluster.builder().withPort(MusicUtil.getCassandraPort())
Cluster cluster;
if(MusicUtil.getCassName() != null && MusicUtil.getCassPwd() != null) {
String cassPwd = CipherUtil.decryptPKC(MusicUtil.getCassPwd());
logger.info(EELFLoggerDelegate.applicationLogger,
"Building with credentials "+MusicUtil.getCassName()+" & "+ MusicUtil.getCassPwd());
cluster = Cluster.builder().withPort(MusicUtil.getCassandraPort())
- .withCredentials(MusicUtil.getCassName(), cassPwd)
- //.withLoadBalancingPolicy(new RoundRobinPolicy())
- .withoutJMXReporting()
- .withPoolingOptions(poolingOptions)
- .addContactPoints(addresses).build();
+ .withCredentials(MusicUtil.getCassName(), cassPwd)
+ //.withLoadBalancingPolicy(new RoundRobinPolicy())
+ .withoutJMXReporting()
+ .withPoolingOptions(poolingOptions)
+ .withSocketOptions(
+ new SocketOptions().setConnectTimeoutMillis(MusicUtil.getCassandraConnectTimeOutMS())
+ .setReadTimeoutMillis(MusicUtil.getCassandraReadTimeOutMS()))
+ .addContactPoints(addresses).build();
- .withoutJMXReporting()
- .withPoolingOptions(poolingOptions)
- .addContactPoints(addresses)
- .build();
+ .withoutJMXReporting()
+ .withPoolingOptions(poolingOptions)
+ .withSocketOptions(new SocketOptions()
+ .setConnectTimeoutMillis(MusicUtil.getCassandraConnectTimeOutMS())
+ .setReadTimeoutMillis(MusicUtil.getCassandraReadTimeOutMS()))
+ .addContactPoints(addresses)
+ .build();
this.setCluster(cluster);
Metadata metadata = this.cluster.getMetadata();
logger.info(EELFLoggerDelegate.applicationLogger, "Connected to cassa cluster "
this.setCluster(cluster);
Metadata metadata = this.cluster.getMetadata();
logger.info(EELFLoggerDelegate.applicationLogger, "Connected to cassa cluster "
try {
session = this.cluster.connect();
} catch (Exception ex) {
logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(),AppMessages.CASSANDRACONNECTIVITY,
try {
session = this.cluster.connect();
} catch (Exception ex) {
logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(),AppMessages.CASSANDRACONNECTIVITY,
- *
- * @param keyspace
- * @param tableName
- * @return TableMetadata
- */
- public KeyspaceMetadata returnKeyspaceMetadata(String keyspace) {
- return cluster.getMetadata().getKeyspace(keyspace);
- }
+ *
+ * @param keyspace
+ * @param tableName
+ * @return TableMetadata
+ */
+ public KeyspaceMetadata returnKeyspaceMetadata(String keyspace) {
+ return cluster.getMetadata().getKeyspace(keyspace);
+ }
*/
public Map<String, HashMap<String, Object>> marshalData(ResultSet results) {
Map<String, HashMap<String, Object>> resultMap =
*/
public Map<String, HashMap<String, Object>> marshalData(ResultSet results) {
Map<String, HashMap<String, Object>> resultMap =
getBlobValue(row, definition.getName(), definition.getType()));
} else {
resultOutput.put(definition.getName(),
getBlobValue(row, definition.getName(), definition.getType()));
} else {
resultOutput.put(definition.getName(),
public boolean executePut(PreparedQueryObject queryObject, String consistency)
throws MusicServiceException, MusicQueryException {
return executePut(queryObject, consistency, 0);
public boolean executePut(PreparedQueryObject queryObject, String consistency)
throws MusicServiceException, MusicQueryException {
return executePut(queryObject, consistency, 0);
* @throws MusicQueryException
*/
public boolean executePut(PreparedQueryObject queryObject, String consistency,long timeSlot)
* @throws MusicQueryException
*/
public boolean executePut(PreparedQueryObject queryObject, String consistency,long timeSlot)
boolean result = false;
long timeOfWrite = System.currentTimeMillis();
if (!MusicUtil.isValidQueryObject(!queryObject.getValues().isEmpty(), queryObject)) {
logger.error(EELFLoggerDelegate.errorLogger, queryObject.getQuery(),AppMessages.QUERYERROR, ErrorSeverity.ERROR, ErrorTypes.QUERYERROR);
throw new MusicQueryException("Ill formed queryObject for the request = " + "["
boolean result = false;
long timeOfWrite = System.currentTimeMillis();
if (!MusicUtil.isValidQueryObject(!queryObject.getValues().isEmpty(), queryObject)) {
logger.error(EELFLoggerDelegate.errorLogger, queryObject.getQuery(),AppMessages.QUERYERROR, ErrorSeverity.ERROR, ErrorTypes.QUERYERROR);
throw new MusicQueryException("Ill formed queryObject for the request = " + "["
- "In preprared Execute Put: the actual insert query:"
- + queryObject.getQuery() + "; the values"
- + queryObject.getValues());
+ "In preprared Execute Put: the actual insert query:"
+ + queryObject.getQuery() + "; the values"
+ + queryObject.getValues());
// logger.error(EELFLoggerDelegate.errorLogger,e.getClass().toString() + ":" + e.getMessage(),AppMessages.SESSIONFAILED + " ["
// + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR, e);
throw new MusicServiceException("Executing Session Failure for Request = " + "["
// logger.error(EELFLoggerDelegate.errorLogger,e.getClass().toString() + ":" + e.getMessage(),AppMessages.SESSIONFAILED + " ["
// + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR, e);
throw new MusicServiceException("Executing Session Failure for Request = " + "["
* This method performs DDL operations on Cassandra using consistency level ONE.
*
* @param queryObject Object containing cassandra prepared query and values.
* This method performs DDL operations on Cassandra using consistency level ONE.
*
* @param queryObject Object containing cassandra prepared query and values.
- *//**
- *
- * This method performs DDL operation on Cassandra using consistency level QUORUM.
- *
- * @param queryObject Object containing cassandra prepared query and values.
- * @return ResultSet
- * @throws MusicServiceException
- * @throws MusicQueryException
- *//*
+ *//**
+ *
+ * This method performs DDL operation on Cassandra using consistency level QUORUM.
+ *
+ * @param queryObject Object containing cassandra prepared query and values.
+ * @return ResultSet
+ * @throws MusicServiceException
+ * @throws MusicQueryException
+ *//*
public ResultSet executeCriticalGet(PreparedQueryObject queryObject)
throws MusicServiceException, MusicQueryException {
if (!MusicUtil.isValidQueryObject(!queryObject.getValues().isEmpty(), queryObject)) {
public ResultSet executeCriticalGet(PreparedQueryObject queryObject)
throws MusicServiceException, MusicQueryException {
if (!MusicUtil.isValidQueryObject(!queryObject.getValues().isEmpty(), queryObject)) {
public ResultSet executeGet(PreparedQueryObject queryObject,String consistencyLevel) throws MusicQueryException, MusicServiceException {
if (!MusicUtil.isValidQueryObject(!queryObject.getValues().isEmpty(), queryObject)) {
logger.error(EELFLoggerDelegate.errorLogger, "",AppMessages.QUERYERROR+ " [" + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR);
throw new MusicQueryException("Error processing Prepared Query Object for the request = " + "["
public ResultSet executeGet(PreparedQueryObject queryObject,String consistencyLevel) throws MusicQueryException, MusicServiceException {
if (!MusicUtil.isValidQueryObject(!queryObject.getValues().isEmpty(), queryObject)) {
logger.error(EELFLoggerDelegate.errorLogger, "",AppMessages.QUERYERROR+ " [" + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR);
throw new MusicQueryException("Error processing Prepared Query Object for the request = " + "["
}
ResultSet results = null;
try {
SimpleStatement statement = new SimpleStatement(queryObject.getQuery(), queryObject.getValues().toArray());
}
ResultSet results = null;
try {
SimpleStatement statement = new SimpleStatement(queryObject.getQuery(), queryObject.getValues().toArray());
}
results = session.execute(statement);
} catch (Exception ex) {
logger.error(EELFLoggerDelegate.errorLogger, "Execute Get Error" + ex.getMessage(),AppMessages.UNKNOWNERROR+ "[" + queryObject
}
results = session.execute(statement);
} catch (Exception ex) {
logger.error(EELFLoggerDelegate.errorLogger, "Execute Get Error" + ex.getMessage(),AppMessages.UNKNOWNERROR+ "[" + queryObject
- .getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR, ex);
+ .getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR, ex);
/**
* This method performs DDL operations on Cassandra using consistency level ONE.
*
* @param queryObject Object containing cassandra prepared query and values.
*/
public ResultSet executeOneConsistencyGet(PreparedQueryObject queryObject)
/**
* This method performs DDL operations on Cassandra using consistency level ONE.
*
* @param queryObject Object containing cassandra prepared query and values.
*/
public ResultSet executeOneConsistencyGet(PreparedQueryObject queryObject)
* @param queryObject Object containing cassandra prepared query and values.
*/
public ResultSet executeLocalQuorumConsistencyGet(PreparedQueryObject queryObject)
* @param queryObject Object containing cassandra prepared query and values.
*/
public ResultSet executeLocalQuorumConsistencyGet(PreparedQueryObject queryObject)
* @param queryObject Object containing cassandra prepared query and values.
*/
public ResultSet executeQuorumConsistencyGet(PreparedQueryObject queryObject)
* @param queryObject Object containing cassandra prepared query and values.
*/
public ResultSet executeQuorumConsistencyGet(PreparedQueryObject queryObject)