1 /*******************************************************************************
2 * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved.
3 *******************************************************************************/
6 import java.io.IOException;
8 import com.att.authz.env.AuthzTrans;
9 import org.onap.aaf.inno.env.APIException;
10 import org.onap.aaf.inno.env.Env;
11 import org.onap.aaf.inno.env.TimeTaken;
12 import org.onap.aaf.inno.env.impl.Log4JLogTarget;
13 import com.datastax.driver.core.ResultSet;
14 import com.datastax.driver.core.exceptions.InvalidQueryException;
16 public abstract class CassBatch extends Batch {
18 protected CassBatch(AuthzTrans trans, String log4JName) throws APIException, IOException {
20 // Flow all Env Logs to Log4j
21 Log4JLogTarget.setLog4JEnv(log4JName, env);
23 TimeTaken tt = trans.start("Connect to Cluster", Env.REMOTE);
25 session = cluster.connect();
32 protected void _close(AuthzTrans trans) {
34 trans.info().log("Closed Session");
37 public ResultSet executeQuery(String cql) {
38 return executeQuery(cql,"");
41 public ResultSet executeQuery(String cql, String extra) {
42 if(isDryRun() && !cql.startsWith("SELECT")) {
43 if(extra!=null)env.info().log("Would query" + extra + ": " + cql);
45 if(extra!=null)env.info().log("query" + extra + ": " + cql);
47 return session.execute(cql);
48 } catch (InvalidQueryException e) {
50 env.info().log("query: " + cql);