use of org.apache.hop.pipeline.debug.TransformDebugMeta in project hop by apache.
the class HopGuiPipelineGraph method showLastPreviewResults.
public synchronized void showLastPreviewResults() {
if (lastPipelineDebugMeta == null || lastPipelineDebugMeta.getTransformDebugMetaMap().isEmpty()) {
return;
}
final List<String> transformnames = new ArrayList<>();
final List<IRowMeta> rowMetas = new ArrayList<>();
final List<List<Object[]>> rowBuffers = new ArrayList<>();
//
for (TransformMeta transformMeta : lastPipelineDebugMeta.getTransformDebugMetaMap().keySet()) {
TransformDebugMeta transformDebugMeta = lastPipelineDebugMeta.getTransformDebugMetaMap().get(transformMeta);
transformnames.add(transformMeta.getName());
rowMetas.add(transformDebugMeta.getRowBufferMeta());
rowBuffers.add(transformDebugMeta.getRowBuffer());
}
hopDisplay().asyncExec(() -> {
EnterPreviewRowsDialog dialog = new EnterPreviewRowsDialog(hopShell(), SWT.NONE, transformnames, rowMetas, rowBuffers);
dialog.open();
});
}
use of org.apache.hop.pipeline.debug.TransformDebugMeta in project hop by apache.
the class PipelineDebugDialog method showTransformDebugInformation.
private void showTransformDebugInformation() {
//
for (Control control : wComposite.getChildren()) {
control.dispose();
}
wComposite.layout(true, true);
int[] selectionIndices = wTransforms.table.getSelectionIndices();
if (selectionIndices == null || selectionIndices.length != 1) {
return;
}
previousIndex = selectionIndices[0];
// What transform did we click on?
//
final TransformMeta transformMeta = pipelineDebugMeta.getPipelineMeta().getTransform(selectionIndices[0]);
// What is the transform debugging metadata?
// --> This can be null (most likely scenario)
//
final TransformDebugMeta transformDebugMeta = transformDebugMetaMap.get(transformMeta);
// At the top we'll put a few common items like first[x], etc.
//
// The row count (e.g. number of rows to keep)
//
wRowCount = new LabelText(wComposite, BaseMessages.getString(PKG, "PipelineDebugDialog.RowCount.Label"), BaseMessages.getString(PKG, "PipelineDebugDialog.RowCount.ToolTip"));
FormData fdRowCount = new FormData();
fdRowCount.left = new FormAttachment(0, 0);
fdRowCount.right = new FormAttachment(100, 0);
fdRowCount.top = new FormAttachment(0, 0);
wRowCount.setLayoutData(fdRowCount);
wRowCount.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
ok(false);
}
});
// Do we retrieve the first rows passing?
//
wFirstRows = new Button(wComposite, SWT.CHECK);
props.setLook(wFirstRows);
wFirstRows.setText(BaseMessages.getString(PKG, "PipelineDebugDialog.FirstRows.Label"));
wFirstRows.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.FirstRows.ToolTip"));
FormData fdFirstRows = new FormData();
fdFirstRows.left = new FormAttachment(middle, 0);
fdFirstRows.right = new FormAttachment(100, 0);
fdFirstRows.top = new FormAttachment(wRowCount, margin);
wFirstRows.setLayoutData(fdFirstRows);
// Do we pause on break point, when the condition is met?
//
wPauseBreakPoint = new Button(wComposite, SWT.CHECK);
props.setLook(wPauseBreakPoint);
wPauseBreakPoint.setText(BaseMessages.getString(PKG, "PipelineDebugDialog.PauseBreakPoint.Label"));
wPauseBreakPoint.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.PauseBreakPoint.ToolTip"));
FormData fdPauseBreakPoint = new FormData();
fdPauseBreakPoint.left = new FormAttachment(middle, 0);
fdPauseBreakPoint.right = new FormAttachment(100, 0);
fdPauseBreakPoint.top = new FormAttachment(wFirstRows, margin);
wPauseBreakPoint.setLayoutData(fdPauseBreakPoint);
// The condition to pause for...
//
condition = null;
if (transformDebugMeta != null) {
condition = transformDebugMeta.getCondition();
}
if (condition == null) {
condition = new Condition();
}
// The input fields...
IRowMeta transformInputFields;
try {
transformInputFields = pipelineDebugMeta.getPipelineMeta().getTransformFields(variables, transformMeta);
} catch (HopTransformException e) {
transformInputFields = new RowMeta();
}
Label wlCondition = new Label(wComposite, SWT.RIGHT);
props.setLook(wlCondition);
wlCondition.setText(BaseMessages.getString(PKG, "PipelineDebugDialog.Condition.Label"));
wlCondition.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.Condition.ToolTip"));
FormData fdlCondition = new FormData();
fdlCondition.left = new FormAttachment(0, 0);
fdlCondition.right = new FormAttachment(middle, -margin);
fdlCondition.top = new FormAttachment(wPauseBreakPoint, margin);
wlCondition.setLayoutData(fdlCondition);
ConditionEditor wCondition = new ConditionEditor(wComposite, SWT.BORDER, condition, transformInputFields);
FormData fdCondition = new FormData();
fdCondition.left = new FormAttachment(middle, 0);
fdCondition.right = new FormAttachment(100, 0);
fdCondition.top = new FormAttachment(wPauseBreakPoint, margin);
fdCondition.bottom = new FormAttachment(100, 0);
wCondition.setLayoutData(fdCondition);
getTransformDebugData(transformDebugMeta);
// Add a "clear" button at the bottom on the left...
//
Button wClear = new Button(wComposite, SWT.PUSH);
props.setLook(wClear);
wClear.setText(BaseMessages.getString(PKG, "PipelineDebugDialog.Clear.Label"));
wClear.setToolTipText(BaseMessages.getString(PKG, "PipelineDebugDialog.Clear.ToolTip"));
FormData fdClear = new FormData();
fdClear.left = new FormAttachment(0, 0);
fdClear.bottom = new FormAttachment(100, 0);
wClear.setLayoutData(fdClear);
wClear.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
// Clear the preview transform information for this transform...
//
transformDebugMetaMap.remove(transformMeta);
wTransforms.table.setSelection(new int[] {});
previousIndex = -1;
// refresh the transforms list...
//
refreshTransformList();
showTransformDebugInformation();
}
});
wComposite.layout(true, true);
}
use of org.apache.hop.pipeline.debug.TransformDebugMeta in project hop by apache.
the class PipelineDebugDialog method refreshTransformList.
private void refreshTransformList() {
GuiResource resource = GuiResource.getInstance();
// Add the list of transforms...
//
int maxIconSize = 0;
int indexSelected = -1;
wTransforms.table.removeAll();
for (int i = 0; i < pipelineDebugMeta.getPipelineMeta().getTransforms().size(); i++) {
TransformMeta transformMeta = pipelineDebugMeta.getPipelineMeta().getTransform(i);
TableItem item = new TableItem(wTransforms.table, SWT.NONE);
Image image = resource.getImagesTransforms().get(transformMeta.getTransformPluginId()).getAsBitmapForSize(display, ConstUi.ICON_SIZE, ConstUi.ICON_SIZE);
item.setImage(0, image);
item.setText(0, "");
item.setText(1, transformMeta.getName());
if (image.getBounds().width > maxIconSize) {
maxIconSize = image.getBounds().width;
}
TransformDebugMeta transformDebugMeta = transformDebugMetaMap.get(transformMeta);
if (transformDebugMeta != null) {
// We have debugging information so we mark the row
//
item.setBackground(resource.getColorLight());
if (indexSelected < 0) {
indexSelected = i;
}
}
}
wTransforms.removeEmptyRows();
wTransforms.optWidth(false);
wTransforms.table.getColumn(0).setWidth(maxIconSize + 10);
wTransforms.table.getColumn(0).setAlignment(SWT.CENTER);
//
if (indexSelected >= 0) {
wTransforms.table.setSelection(indexSelected);
showTransformDebugInformation();
}
}
use of org.apache.hop.pipeline.debug.TransformDebugMeta in project hop by apache.
the class PipelineDebugDialog method getTransformDebugMeta.
/**
* Grab the transform debugging information from the dialog. Store it in our private map
*/
private void getTransformDebugMeta() {
int index = wTransforms.getSelectionIndex();
if (previousIndex >= 0) {
//
if (wComposite.getChildren().length == 0) {
return;
}
TransformMeta transformMeta = pipelineDebugMeta.getPipelineMeta().getTransform(previousIndex);
TransformDebugMeta transformDebugMeta = new TransformDebugMeta(transformMeta);
transformDebugMeta.setCondition(condition);
transformDebugMeta.setPausingOnBreakPoint(wPauseBreakPoint.getSelection());
transformDebugMeta.setReadingFirstRows(wFirstRows.getSelection());
transformDebugMeta.setRowCount(Const.toInt(wRowCount.getText(), -1));
transformDebugMetaMap.put(transformMeta, transformDebugMeta);
}
previousIndex = index;
}
use of org.apache.hop.pipeline.debug.TransformDebugMeta in project hop by apache.
the class PipelinePreviewProgressDialog method doPreview.
private void doPreview(final HopGui hopGui, final IProgressMonitor progressMonitor, final boolean showErrorDialogs) {
progressMonitor.beginTask(BaseMessages.getString(PKG, "PipelinePreviewProgressDialog.Monitor.BeginTask.Title"), 100);
// This pipeline is ready to run in preview!
//
pipeline = new LocalPipelineEngine(pipelineMeta, variables, hopGui.getLoggingObject());
pipeline.setPreview(true);
pipeline.setMetadataProvider(hopGui.getMetadataProvider());
//
try {
pipeline.prepareExecution();
} catch (final HopException e) {
if (showErrorDialogs) {
shell.getDisplay().asyncExec(() -> new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "PipelinePreviewProgressDialog.Exception.ErrorPreparingPipeline"), e));
}
//
return;
}
// Add the preview / debugging information...
//
pipelineDebugMeta = new PipelineDebugMeta(pipelineMeta);
for (int i = 0; i < previewTransformNames.length; i++) {
TransformMeta transformMeta = pipelineMeta.findTransform(previewTransformNames[i]);
TransformDebugMeta transformDebugMeta = new TransformDebugMeta(transformMeta);
transformDebugMeta.setReadingFirstRows(true);
transformDebugMeta.setRowCount(previewSize[i]);
pipelineDebugMeta.getTransformDebugMetaMap().put(transformMeta, transformDebugMeta);
}
int previousPct = 0;
final List<String> previewComplete = new ArrayList<>();
// We add a break-point that is called every time we have a transform with a full preview row
// buffer
// That makes it easy and fast to see if we have all the rows we need
//
pipelineDebugMeta.addBreakPointListers((pipelineDebugMeta, transformDebugMeta, rowBufferMeta, rowBuffer) -> {
String transformName = transformDebugMeta.getTransformMeta().getName();
previewComplete.add(transformName);
progressMonitor.subTask(BaseMessages.getString(PKG, "PipelinePreviewProgressDialog.SubTask.TransformPreviewFinished", transformName));
});
// set the appropriate listeners on the pipeline...
//
pipelineDebugMeta.addRowListenersToPipeline(pipeline);
//
try {
pipeline.startThreads();
} catch (final HopException e) {
shell.getDisplay().asyncExec(() -> new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "PipelinePreviewProgressDialog.Exception.ErrorPreparingPipeline"), e));
//
return;
}
while (previewComplete.size() < previewTransformNames.length && !pipeline.isFinished() && !progressMonitor.isCanceled()) {
// How many rows are done?
int nrDone = 0;
int nrTotal = 0;
for (TransformDebugMeta transformDebugMeta : pipelineDebugMeta.getTransformDebugMetaMap().values()) {
nrDone += transformDebugMeta.getRowBuffer().size();
nrTotal += transformDebugMeta.getRowCount();
}
int pct = 100 * nrDone / nrTotal;
int worked = pct - previousPct;
if (worked > 0) {
progressMonitor.worked(worked);
}
previousPct = pct;
// Change the percentage...
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// Ignore errors
}
if (progressMonitor.isCanceled()) {
cancelled = true;
pipeline.stopAll();
}
}
pipeline.stopAll();
// Capture preview activity to a String:
loggingText = HopLogStore.getAppender().getBuffer(pipeline.getLogChannel().getLogChannelId(), true).toString();
progressMonitor.done();
}
Aggregations