-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhanced statistics, added hana driver, added query element based commit scope #7
base: master
Are you sure you want to change the base?
Changes from all commits
9396d2a
dc0d583
235f885
568d589
e279746
23bd6ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
public abstract class ScriptingElement extends XmlConfigurableBase { | ||
private String connectionId; | ||
private String ifExpr; | ||
private String commit; | ||
private DialectBasedContentEl contentEl; | ||
private ScriptingElement parent; | ||
|
||
|
@@ -55,7 +56,15 @@ public String getIf() { | |
public void setIf(final String ifExpr) { | ||
this.ifExpr = ifExpr; | ||
} | ||
|
||
|
||
public String getCommit(){ | ||
return commit; | ||
} | ||
|
||
public void setCommit(final String commit){ | ||
this.commit = commit; | ||
} | ||
|
||
public Resource getContent() { | ||
return contentEl.getContent(null); | ||
} | ||
|
@@ -73,6 +82,7 @@ public void configure(final XmlElement element) { | |
setLocation(element); | ||
setProperty(element, "connection-id", "connectionId"); | ||
setProperty(element, "if"); | ||
setProperty(element, "commit"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use setCommit(element.getBooleanAttribute("commit", false)); |
||
contentEl = new DialectBasedContentEl(element); | ||
contentEl.setLocation(getLocation()); | ||
} | ||
|
@@ -81,7 +91,7 @@ public void configure(final XmlElement element) { | |
public String toString() { | ||
return "connectionId='" + connectionId + '\'' + | ||
", location=" + getLocation() + | ||
", ifExpr='" + ifExpr + '\''; | ||
|
||
", ifExpr='" + ifExpr + '\'' + | ||
", commit='" + commit + '\''; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,14 +61,16 @@ private void initNestedExecutors() { | |
} | ||
} | ||
} | ||
|
||
|
||
|
||
protected void execute(Connection connection, Resource resource, DynamicContext ctx) { | ||
final QueryCtxDecorator ctxDecorator = new QueryCtxDecorator(ctx); | ||
if (debug) { | ||
log.fine("Executing query " + getLocation()); | ||
} | ||
connection.executeQuery(resource, ctx, ctxDecorator); | ||
if (getElement().getCommit().equalsIgnoreCase("TRUE")){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now this can be getElement().isCommit() |
||
ctx.getGlobalContext().getSession().commit(); | ||
} | ||
if (debug) { | ||
if (ctxDecorator.rownum == 0) { | ||
log.fine("Query " + getLocation() + " returned no results."); | ||
|
@@ -103,6 +105,10 @@ public QueryCtxDecorator(DynamicContext context) { | |
|
||
public void processRow(final ParametersCallback parameters) { | ||
EtlCancelledException.checkEtlCancelled(); | ||
if (rownum == 0){ | ||
statisticsBuilder.elementProcessingStarted(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why statisticsBuilder is updated here and not in the StatisticInterceptor? |
||
} | ||
statisticsBuilder.incrementNestedExecutionCount(); | ||
rownum++; | ||
params = parameters; | ||
cachedParams.clear(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
* @version 1.0 | ||
*/ | ||
public final class ScriptExecutor extends ContentExecutor<ScriptEl> { | ||
private boolean firstExecution = true; | ||
public ScriptExecutor(ScriptEl scriptEl) { | ||
super(scriptEl); | ||
} | ||
|
@@ -45,6 +46,10 @@ protected void execute(Connection connection, Resource resource, DynamicContext | |
if (debug) { | ||
log.fine("Executing script " + getLocation()); | ||
} | ||
if (firstExecution){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not use tabs for indentation, only spaces |
||
firstExecution = false; | ||
ctx.statisticsBuilder.elementProcessingStarted(); | ||
} | ||
boolean repeat; | ||
OnErrorHandler onErrorHandler = null; | ||
do { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,11 +104,11 @@ public String toString() { | |
for (ElementInfo ei : elements) { | ||
sb.append(ei.id).append(":"); | ||
|
||
if (ei.okCount > 0) { | ||
if (ei.successfulExecutionCount > 0) { | ||
sb.append(" Element successfully executed"); | ||
if (ei.okCount > 1) { | ||
if (ei.successfulExecutionCount > 1) { | ||
sb.append(' '); | ||
appendPlural(sb, ei.okCount, "time"); | ||
appendPlural(sb, ei.successfulExecutionCount, "time"); | ||
} | ||
if (ei.statements > 0) { | ||
sb.append(" ("); | ||
|
@@ -117,9 +117,9 @@ public String toString() { | |
sb.append('.'); | ||
} | ||
|
||
if (ei.failedCount > 0) { | ||
if (ei.failedExecutionCount > 0) { | ||
sb.append(" Element failed "); | ||
appendPlural(sb, ei.failedCount, "time"); | ||
appendPlural(sb, ei.failedExecutionCount, "time"); | ||
sb.append('.'); | ||
} | ||
sb.append(" Working time ").append(ei.workingTime / 1000000).append(" milliseconds."); | ||
|
@@ -248,21 +248,50 @@ void setFinished(Date finished) { | |
|
||
|
||
public static class ElementInfo { | ||
int okCount; | ||
Connection connection; | ||
Connection connection; | ||
int successfulExecutionCount; | ||
int filteredExecutionCount; | ||
int failedExecutionCount; | ||
int nestedExecutionCount; | ||
long statementsOnStart; | ||
long statements; | ||
int failedCount; | ||
long started; | ||
Date execStart; | ||
Date processingStart; | ||
Date execEnd; | ||
long workingTime; | ||
String id; | ||
|
||
|
||
public Date getProcessingStart(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a space before the curly bracket. Here and in other cases |
||
return processingStart; | ||
} | ||
|
||
public Date getExecStart(){ | ||
return execStart; | ||
} | ||
|
||
public Date getExecEnd(){ | ||
return execEnd; | ||
} | ||
|
||
public int getTotalExecutionCount(){ | ||
return filteredExecutionCount + successfulExecutionCount + failedExecutionCount; | ||
} | ||
|
||
public int getFilteredExecutionCount(){ | ||
return filteredExecutionCount; | ||
} | ||
|
||
public int getSuccessfulExecutionCount() { | ||
return okCount; | ||
return successfulExecutionCount; | ||
} | ||
|
||
public int getFailedExecutionCount() { | ||
return failedCount; | ||
return failedExecutionCount; | ||
} | ||
|
||
public int getNestedExecutionCount(){ | ||
return nestedExecutionCount; | ||
} | ||
|
||
/** | ||
|
@@ -284,15 +313,23 @@ public long getStatementsCount() { | |
public long getWorkingTime() { | ||
return workingTime; | ||
} | ||
|
||
/** | ||
* | ||
* @return total execution time in seconds. | ||
*/ | ||
public long getExecTime() { | ||
return (execEnd.getTime()-execStart.getTime())/1000; | ||
} | ||
|
||
/** | ||
* Returns throughput t=statements/workingTimeSeconds. The | ||
* throughput has statement/second unit. | ||
* Returns throughput t=statements/execTimeSeconds. The | ||
* throughput has statements/second unit. | ||
* | ||
* @return statement/second thoughput or -1 if no statements info available or working time is zero. | ||
* @return stmt/second thoughput or -1 if no statements info available or execution time is zero. | ||
*/ | ||
public double getThroughput() { | ||
return statements <= 0 || workingTime <= 0 ? -1 : 1000000000d * statements / workingTime; | ||
return statements <= 0 || getExecTime() <= 0 ? -1 : getStatementsCount() / getExecTime(); | ||
} | ||
|
||
public String getId() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it boolean. Update getter and setter