Skip to content

Commit

Permalink
Add step name and step index
Browse files Browse the repository at this point in the history
  • Loading branch information
MDeLuise authored and Coduz committed Jan 31, 2023
1 parent 0ef9118 commit 16e170f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ public void open(Serializable arg0) throws Exception {
JobLogger jobLogger = jobContextWrapper.getJobLogger();
jobLogger.setClassLog(LOG);

jobLogger.info("Opening cursor...");
int stepIndex = stepContextWrapper.getStepIndex();
String stepName = stepContextWrapper.getKapuaStepName();

jobLogger.info("Reading target chunk. Step:{} (index:{})...", stepName, stepIndex);

//
// Job Id and JobTarget status filtering
Expand Down Expand Up @@ -107,7 +110,7 @@ public void open(Serializable arg0) throws Exception {
// Wrap the JobTargets in a wrapper object to store additional informations
jobTargets.getItems().forEach(jt -> wrappedJobTargets.add(new JobTargetWrapper(jt)));

jobLogger.info("Opening cursor... DONE!");
jobLogger.info("Reading target chunk. Step:{} (index:{})...DONE", stepName, stepIndex);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ public void writeItems(List<Object> items) throws Exception {
JobLogger jobLogger = jobContextWrapper.getJobLogger();
jobLogger.setClassLog(LOG);

jobLogger.info("Writing items...");
int stepIndex = stepContextWrapper.getStepIndex();
String stepName = stepContextWrapper.getKapuaStepName();

jobLogger.info("Writing chunk results. Step:{} (index:{})...", stepName, stepIndex);

for (Object item : items) {
JobTargetWrapper processedWrappedJobTarget = (JobTargetWrapper) item;
Expand Down Expand Up @@ -96,6 +99,6 @@ public void writeItems(List<Object> items) throws Exception {
}
}

jobLogger.info("Writing items... DONE!");
jobLogger.info("Writing chunk results. Step:{} (index:{})... DONE!", stepName, stepIndex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ public interface StepContextPropertyNames {
* @since 1.0.0
*/
String STEP_NEXT_INDEX = "step.nextStepIndex";

/**
* @since 2.0.0
*/
String STEP_NAME = "step.name";
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,13 @@ public Exception getException() {
public Metric[] getMetrics() {
return stepContext.getMetrics();
}

public String getKapuaStepName() {
Properties stepContextProperties = stepContext.getProperties();
String stepName = stepContextProperties.getProperty(StepContextPropertyNames.STEP_NAME);
if (Strings.isNullOrEmpty(stepName)) {
throw KapuaRuntimeException.internalError("stepName is not available in the StepContext.properties");
}
return stepName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ public static JSLProperties buildStepProperties(@NotNull JobStepDefinition jobSt
jslStepIndexProperty.setValue(String.valueOf(jobStep.getStepIndex()));
jslPropertyList.add(jslStepIndexProperty);

Property jslStepNameProperty = new Property();
jslStepNameProperty.setName(StepContextPropertyNames.STEP_NAME);
jslStepNameProperty.setValue(jobStep.getName());
jslPropertyList.add(jslStepNameProperty);

if (hasNext) {
Property jslStepNextIndexProperty = new Property();
jslStepNextIndexProperty.setName(StepContextPropertyNames.STEP_NEXT_INDEX);
Expand Down

0 comments on commit 16e170f

Please sign in to comment.