Skip to content

Commit

Permalink
improves error messages
Browse files Browse the repository at this point in the history
refs #6872
  • Loading branch information
robfrank committed Dec 28, 2016
1 parent 51b4266 commit a2eaf66
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,18 @@ protected OSQLFilter getIfFilter() {
}

protected void log(final Level iLevel, String iText, final Object... iArgs) {
// if (logLevel.ordinal() >= iLevel.ordinal()) {
log(iLevel, iText, null, iArgs);
}

protected void log(final Level iLevel, String iText, Exception exception, final Object... iArgs) {
final Long extractedNum = context != null ? (Long) context.getVariable("extractedNum") : null;
if (extractedNum != null) {
// System.out.println("[" + extractedNum + ":" + getName() + "] " + iLevel + " " + String.format(iText, iArgs));

OLogManager.instance()
.log(this, iLevel, "[" + extractedNum + ":" + getName() + "] " + iLevel + " " + iText, null, iArgs);

.log(this, iLevel, "[" + extractedNum + ":" + getName() + "] " + iLevel + " " + iText, exception, iArgs);
} else {
// System.out.println("[" + getName() + "] " + iLevel + " " + String.format(iText, iArgs));

OLogManager.instance()
.log(this, iLevel, "[" + getName() + "] " + iLevel + " " + iText, null, iArgs);
.log(this, iLevel, "[" + getName() + "] " + iLevel + " " + iText, exception, iArgs);
}

// }
}

protected String stringArray2Json(final Object[] iObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ protected Object execute(final OETLExtractedItem source) {
for (OETLTransformer t : transformers) {
current = t.transform(current);
if (current == null) {
// if (logLevel == DEBUG) {
OLogManager.instance().warn(this, "Transformer [%s] returned null, skip rest of pipeline execution", t);
// break;
// }
}
}
if (current != null) {
Expand All @@ -102,10 +99,8 @@ protected Object execute(final OETLExtractedItem source) {
} catch (ONeedRetryException e) {
loader.rollback(databaseProvider);
retry++;
OLogManager.instance().info(this, "Error in pipeline execution, retry = %d/%d (exception=%s)", retry, maxRetries, e);
// processor.out(INFO, "Error in pipeline execution, retry = %d/%d (exception=%s)", retry, maxRetries, e);
OLogManager.instance().info(this, "Error in pipeline execution, retry = %d/%d (exception=)", retry, maxRetries, e);
} catch (OETLProcessHaltedException e) {
// processor.out(ERROR, "Pipeline execution halted");
OLogManager.instance().error(this, "Pipeline execution halted");

processor.getStats().incrementErrors();
Expand All @@ -114,8 +109,7 @@ protected Object execute(final OETLExtractedItem source) {
throw e;

} catch (Exception e) {
// processor.out(ERROR, "Error in Pipeline execution: %s", e);
OLogManager.instance().error(this, "Error in Pipeline execution: %s", e);
OLogManager.instance().error(this, "Error in Pipeline execution:", e);

processor.getStats().incrementErrors();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@ protected void configRunBehaviour(OCommandContext context) {

}

public void out_NO(final Level iLogLevel, final String iText, final Object... iArgs) {
// if (logLevel.ordinal() >= iLogLevel.ordinal())
System.out.println(String.format(iText, iArgs));

}

public OETLProcessorStats getStats() {
return stats;
}
Expand Down Expand Up @@ -273,8 +267,6 @@ protected void end() {
dumpTask.cancel();
}

// out(LOG_LEVELS.INFO, "END ETL PROCESSOR");

OLogManager.instance().info(this, "END ETL PROCESSOR");
dumpProgress();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ protected OClass getOrCreateClass(ODatabaseDocument db, final String iClassName,
if (clusterName != null) {
int clusterIdByName = db.getClusterIdByName(clusterName);
if (clusterIdByName == -1) {
System.out.println("add cluster :: " + clusterName);
log(logLevel, "add cluster :: " + clusterName);
cls.addCluster(clusterName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,18 @@ public Object executeTransform(final Object input) {
if (input instanceof OIdentifiable)
params.put("record", ((OIdentifiable) input).getRecord());

Object result = cmd.executeInContext(context, params);
try {
Object result = cmd.executeInContext(context, params);

log(Level.FINE, "executed code=%s, result=%s", cmd, result);
log(Level.FINE, "executed code=%s, result=%s", cmd, result);
return result;

} catch (Exception e) {

log(Level.SEVERE, "exception=%s - input=%s - command=%s ", e.getMessage(), input, cmd);

throw e;
}

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,25 @@ public Object executeTransform(final Object input) {
final OCommandRequest cmd;
if (language.equals("sql")) {
cmd = new OCommandSQL(runtimeCommand);

log(Level.FINE, "executing command=%s", runtimeCommand);
} else if (language.equals("gremlin")) {
cmd = new OCommandGremlin(runtimeCommand);
} else {
cmd = new OCommandScript(language, runtimeCommand);
}
cmd.setContext(context);
try {

Object result = databaseProvider.getDocumentDatabase().command(cmd).execute();

log(Level.FINE, "input=%s - command=%s - result=%s", input, cmd, result);

return result;
} catch (Exception e) {

Object result = databaseProvider.getDocumentDatabase().command(cmd).execute();
log(Level.FINE, "executed command=%s, result=%s", cmd, result);
return result;
log(Level.SEVERE, "exception=%s - input=%s - command=%s ", e.getMessage(), input, cmd);

throw e;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.storage.ORecordDuplicatedException;
import com.tinkerpop.blueprints.impls.orient.OrientBaseGraph;
import com.tinkerpop.blueprints.impls.orient.OrientVertex;
import com.tinkerpop.blueprints.impls.orient.OrientVertexType;
Expand Down Expand Up @@ -71,24 +70,9 @@ public Object executeTransform(final Object input) {
OrientBaseGraph graph = databaseProvider.getGraphDatabase();
final OrientVertex v = graph.getVertex(input);

if (v == null) {
return null;
if (v != null && vertexClass != null && !vertexClass.equals(v.getRecord().getClassName())) {
v.getRecord().setClassName(vertexClass);
}

if (vertexClass != null && !vertexClass.equals(v.getRecord().getClassName()))
try {

v.getRecord().setClassName(vertexClass);
// v.save(clusterName);
} catch (ORecordDuplicatedException e) {
if (skipDuplicates) {
return null;
} else {
throw e;
}
} finally {

}
return v;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,11 @@ public void testSave() {
process("{source: { content: { value: 'name,surname\nJay,Miner' } }, " + "extractor : { csv: {} }, " + "transformers: ["
+ "{field:{log:'FINE',fieldName:'@class', value:'Test'}}, "
+ "{field:{log:'FINE', fieldName:'test', value: 33, save:true}}" + "], "
+ "loader: { orientdb: { dbURL: 'memory:"+name.getMethodName()+"' } } }");
+ "loader: { orientdb: { dbURL: 'memory:" + name.getMethodName() + "' } } }");

OSchema schema = graph.getRawGraph().getMetadata().getSchema();
schema.reload();

// schema.getClasses().forEach(c -> System.out.println(c.toString()));

assertThat(schema.getClass("Test")).isNotNull();
assertEquals(1, graph.countVertices("Test"));
}
Expand Down

0 comments on commit a2eaf66

Please sign in to comment.