aboutsummaryrefslogtreecommitdiffstats
path: root/mdbc-server
diff options
context:
space:
mode:
authorstatta <statta@research.att.com>2019-07-01 15:09:39 -0400
committerstatta <statta@research.att.com>2019-07-01 15:14:25 -0400
commite5193d27f0f6d0ded1c59360f89e0543ee7f10aa (patch)
tree2b698413f0f417de4b4f8d4e82a8c3071d1d18cb /mdbc-server
parent07ea54cfc9341cfc5cc64526e1d357981e6841ed (diff)
Parse OrderBy
Issue-ID: MUSIC-423 Also add debugging logic Change-Id: I665675a5da1617f53163e045990ea9f804a8b3ec Signed-off-by: statta <statta@research.att.com>
Diffstat (limited to 'mdbc-server')
-rwxr-xr-xmdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java20
-rw-r--r--mdbc-server/src/main/java/org/onap/music/mdbc/ownership/Dag.java4
-rw-r--r--mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java47
-rw-r--r--mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java4
4 files changed, 69 insertions, 6 deletions
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java
index 61ce6bd..9c19c36 100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java
@@ -34,10 +34,15 @@ import java.sql.SQLXML;
import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.UUID;
import java.util.concurrent.Executor;
-
-import org.apache.commons.lang3.NotImplementedException;
import org.onap.music.exceptions.MDBCServiceException;
import org.onap.music.exceptions.QueryException;
import org.onap.music.logging.EELFLoggerDelegate;
@@ -55,7 +60,6 @@ import org.onap.music.mdbc.ownership.OwnershipAndCheckpoint;
import org.onap.music.mdbc.query.QueryProcessor;
import org.onap.music.mdbc.query.SQLOperation;
import org.onap.music.mdbc.query.SQLOperationType;
-import org.onap.music.mdbc.tables.MusicTxDigestDaemon;
import org.onap.music.mdbc.tables.MusicRangeInformationRow;
import org.onap.music.mdbc.tables.StagingTable;
import org.onap.music.mdbc.tables.TxCommitProgress;
@@ -501,6 +505,14 @@ public class MdbcConnection implements Connection {
* @param sql the SQL statement that is about to be executed
*/
public void preStatementHook(final String sql) throws MDBCServiceException, SQLException {
+
+ // some debug specific logic
+ if(sql.startsWith("DEBUG")) {
+ // if the SQL follows this convention: "DEBUG:TABLE_A,TABLE_B",
+ // DAG information pertaining to the tables will get printed
+ throw new SQLException("\nThis call was made for debugging purposes only\n" + statemanager.getOwnAndCheck().getDebugInfo(mi,sql.split(":")[1]));
+ }
+
//TODO: verify ownership of keys here
//Parse tables from the sql query
Map<String, List<SQLOperation>> tableToQueryType = QueryProcessor.parseSqlQuery(sql, table_set);
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/Dag.java b/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/Dag.java
index 07a5fe6..ff2102f 100644
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/Dag.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/Dag.java
@@ -304,6 +304,10 @@ public class Dag {
addNewNode(row,dependencies);
}
+ /**
+ *
+ * @return All ranges in every node of the DAG
+ */
public Set<Range> getAllRanges(){
Set<Range> ranges = new HashSet<>();
for(DagNode node : nodes.values()){
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java b/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java
index 854eb5f..0a9f6c8 100644
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java
@@ -25,7 +25,6 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang3.tuple.Pair;
import org.onap.music.exceptions.MDBCServiceException;
import org.onap.music.logging.EELFLoggerDelegate;
@@ -36,7 +35,6 @@ import org.onap.music.mdbc.mixins.LockRequest;
import org.onap.music.mdbc.mixins.LockResult;
import org.onap.music.mdbc.mixins.MusicInterface;
import org.onap.music.mdbc.mixins.MusicInterface.OwnershipReturn;
-import org.onap.music.mdbc.mixins.MusicMixin;
import org.onap.music.mdbc.query.SQLOperationType;
import org.onap.music.mdbc.tables.MriReference;
import org.onap.music.mdbc.tables.MusicRangeInformationRow;
@@ -380,6 +378,51 @@ public class OwnershipAndCheckpoint{
}
}
+ public String getDebugInfo(MusicInterface mi, String rangesStr) {
+
+ List<Range> ranges = new ArrayList<Range>();
+ Arrays.stream(rangesStr.split(",")).forEach(a -> ranges.add(new Range(a)));
+
+ StringBuffer buffer = new StringBuffer();
+ List<Range> rangesToOwn;
+ try {
+ rangesToOwn = mi.getRangeDependencies(ranges);
+ List<MusicRangeInformationRow> rangesToOwnRows = extractRowsForRange(mi,rangesToOwn, false);
+ Dag toOwn = Dag.getDag(rangesToOwnRows,rangesToOwn);
+ while(toOwn.hasNextToOwn()){
+ DagNode node = null;
+ try {
+ node = toOwn.nextToOwn();
+ MusicRangeInformationRow row = node.getRow();
+
+ buffer.append("\n-------------\n");
+ buffer.append(row.getDBPartition()).append(",");
+ buffer.append(row.getPrevRowIndexes()).append(",");
+ buffer.append(row.getIsLatest()).append("");
+
+
+ } catch (Exception e) {
+ buffer.append("\n------missing MRI------\n");
+ } finally {
+
+ if(node != null) {
+ toOwn.setOwn(node);
+ }
+
+ }
+
+ }
+
+
+ } catch (MDBCServiceException e) {
+ buffer.setLength(0);
+ buffer.append(" Debugging info could not be determined");
+ }
+
+ return buffer.toString();
+
+ }
+
public void reloadAlreadyApplied(DatabasePartition partition) throws MDBCServiceException {
List<Range> snapshot = partition.getSnapshot();
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java b/mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java
index a31a2a0..6d6c661 100644
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java
@@ -35,6 +35,7 @@ import org.apache.calcite.sql.SqlInsert;
import org.apache.calcite.sql.SqlJoin;
import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOrderBy;
import org.apache.calcite.sql.SqlSelect;
import org.apache.calcite.sql.SqlUpdate;
import org.apache.calcite.sql.fun.SqlInOperator;
@@ -122,6 +123,9 @@ public class QueryProcessor {
case SELECT:
parseSelect((SqlSelect) sqlNode, tableOpsMap);
break;
+ case ORDER_BY:
+ parseSelect((SqlSelect)((SqlOrderBy) sqlNode).query, tableOpsMap);
+ break;
default:
logger.error("Unhandled sql query type " + sqlNode.getKind() +" for query " + query);
}