print("Execute " + insert[i]);
try {
// insert
context.setSql(insert[i]);
druidParser.generatePlan(context);
Plan plan = context.getPlan();
if (plan instanceof InsertPlan) {
InsertPlan insertPlan = (InsertPlan) plan;
List<InsertAction> units = insertPlan.getActions();
Assert.assertEquals(units.size(), 1);
// EntityGroup execute insert
OperationStatus status = eg.insert(units.get(0));
if (status.getOperationStatusCode() != org.apache.hadoop.hbase.HConstants.OperationStatusCode.SUCCESS) {
success = false;
}
Redo redo = eg.getLog();
try {
while (redo.peekLastUnCommitedTransaction() != null) {
Thread.sleep(500);
}
} catch (Exception e) {
success = false;
}
} else if (plan instanceof UpdatePlan) {
UpdatePlan updatePlan = (UpdatePlan) plan;
List<UpdateAction> units = updatePlan.getActions();
Assert.assertEquals(units.size(), 1);
// EntityGroup execute insert
OperationStatus status = eg.update(units.get(0));
if (status.getOperationStatusCode() != org.apache.hadoop.hbase.HConstants.OperationStatusCode.SUCCESS) {
success = false;
}
Redo redo = eg.getLog();
try {
while (redo.peekLastUnCommitedTransaction() != null) {
Thread.sleep(500);
}
} catch (Exception e) {
success = false;
}
} else if (plan instanceof DeletePlan) {
LOG.info(" DeletePlan is " + plan.toString());
DeletePlan deletePlan = (DeletePlan) plan;
List<DeleteAction> units = deletePlan.getActions();
Assert.assertEquals(units.size(), 1);
OperationStatus status = eg.delete(units.get(0));
if (status.getOperationStatusCode() != org.apache.hadoop.hbase.HConstants.OperationStatusCode.SUCCESS) {
success = false;
}
Redo redo = eg.getLog();
try {
while (redo.peekLastUnCommitedTransaction() != null) {
Thread.sleep(500);
}
} catch (Exception e) {
success = false;
}
} else {
Assert.assertTrue(false);
}
context.setSql(select[i]);
druidParser.generatePlan(context);
plan = context.getPlan();
LOG.info("Plan is " + plan.toString());
if (plan instanceof LocalQueryPlan) {
LocalQueryPlan localQueryPlan = (LocalQueryPlan) plan;
GetAction getAction = localQueryPlan.getGetAction();
if (getAction != null) {
LOG.info("GetAction " + getAction.toString());