Search in sources :

Example 1 with IWorkflowEngineRunConfiguration

use of org.apache.hop.workflow.config.IWorkflowEngineRunConfiguration in project hop by apache.

the class RemoteWorkflowEngine method startExecution.

@Override
public Result startExecution() {
    try {
        executionStartDate = new Date();
        // Create a new log channel when we start the action
        // It's only now that we use it
        // 
        logChannel = new LogChannel(workflowMeta, parentLoggingObject, gatheringMetrics);
        loggingObject = new LoggingObject(this);
        logLevel = logChannel.getLogLevel();
        workflowTracker = new WorkflowTracker(workflowMeta);
        if (previousResult == null) {
            result = new Result();
        } else {
            result = previousResult;
        }
        IWorkflowEngineRunConfiguration engineRunConfiguration = workflowRunConfiguration.getEngineRunConfiguration();
        if (!(engineRunConfiguration instanceof RemoteWorkflowRunConfiguration)) {
            throw new HopException("The remote workflow engine expects a remote workflow configuration");
        }
        remoteWorkflowRunConfiguration = (RemoteWorkflowRunConfiguration) workflowRunConfiguration.getEngineRunConfiguration();
        String hopServerName = resolve(remoteWorkflowRunConfiguration.getHopServerName());
        if (StringUtils.isEmpty(hopServerName)) {
            throw new HopException("No remote Hop server was specified to run the workflow on");
        }
        String remoteRunConfigurationName = remoteWorkflowRunConfiguration.getRunConfigurationName();
        if (StringUtils.isEmpty(remoteRunConfigurationName)) {
            throw new HopException("No run configuration was specified to the remote workflow with");
        }
        if (metadataProvider == null) {
            throw new HopException("The remote workflow engine didn't receive a metadata to load hop server '" + hopServerName + "'");
        }
        logChannel.logBasic("Executing this workflow using the Remote Workflow Engine with run configuration '" + workflowRunConfiguration.getName() + "'");
        serverPollDelay = Const.toLong(resolve(remoteWorkflowRunConfiguration.getServerPollDelay()), 1000L);
        serverPollInterval = Const.toLong(resolve(remoteWorkflowRunConfiguration.getServerPollInterval()), 2000L);
        hopServer = metadataProvider.getSerializer(HopServer.class).load(hopServerName);
        if (hopServer == null) {
            throw new HopException("Hop server '" + hopServerName + "' could not be found");
        }
        WorkflowExecutionConfiguration workflowExecutionConfiguration = new WorkflowExecutionConfiguration();
        workflowExecutionConfiguration.setRunConfiguration(remoteRunConfigurationName);
        if (logLevel != null) {
            workflowExecutionConfiguration.setLogLevel(logLevel);
        }
        if (previousResult != null) {
            // This contains result rows, files, ...
            // 
            workflowExecutionConfiguration.setPreviousResult(previousResult);
        }
        workflowExecutionConfiguration.setGatheringMetrics(gatheringMetrics);
        // Pass all variables to the parameters map...
        // 
        Map<String, String> parametersMap = workflowExecutionConfiguration.getParametersMap();
        for (String variableName : this.getVariableNames()) {
            String variableValue = this.getVariable(variableName);
            if (variableName != null && variableValue != null) {
                parametersMap.put(variableName, variableValue);
            }
        }
        sendToHopServer(this, workflowMeta, workflowExecutionConfiguration, metadataProvider);
        fireWorkflowStartedListeners();
        initialized = true;
        monitorRemoteWorkflowUntilFinished();
        fireWorkflowFinishListeners();
        executionEndDate = new Date();
    } catch (Exception e) {
        logChannel.logError("Error starting workflow", e);
        result.setNrErrors(result.getNrErrors() + 1);
        try {
            fireWorkflowFinishListeners();
        } catch (Exception ex) {
            logChannel.logError("Error executing workflow finished listeners", ex);
            result.setNrErrors(result.getNrErrors() + 1);
        }
    }
    return result;
}
Also used : IWorkflowEngineRunConfiguration(org.apache.hop.workflow.config.IWorkflowEngineRunConfiguration) HopException(org.apache.hop.core.exception.HopException) WorkflowTracker(org.apache.hop.core.gui.WorkflowTracker) HopException(org.apache.hop.core.exception.HopException) WebResult(org.apache.hop.www.WebResult) Result(org.apache.hop.core.Result)

Example 2 with IWorkflowEngineRunConfiguration

use of org.apache.hop.workflow.config.IWorkflowEngineRunConfiguration in project hop by apache.

the class WorkflowEngineFactory method createWorkflowEngine.

private static final <T extends WorkflowMeta> IWorkflowEngine<T> createWorkflowEngine(WorkflowRunConfiguration workflowRunConfiguration, T workflowMeta, ILoggingObject parentLogging) throws HopException {
    IWorkflowEngineRunConfiguration engineRunConfiguration = workflowRunConfiguration.getEngineRunConfiguration();
    if (engineRunConfiguration == null) {
        throw new HopException("There is no pipeline execution engine specified in run configuration '" + workflowRunConfiguration.getName() + "'");
    }
    String enginePluginId = engineRunConfiguration.getEnginePluginId();
    // Load this engine from the plugin registry
    // 
    PluginRegistry pluginRegistry = PluginRegistry.getInstance();
    IPlugin plugin = pluginRegistry.findPluginWithId(WorkflowEnginePluginType.class, enginePluginId);
    if (plugin == null) {
        throw new HopException("Unable to find pipeline engine plugin type with ID '" + enginePluginId + "'");
    }
    IWorkflowEngine<T> workflowEngine = pluginRegistry.loadClass(plugin, IWorkflowEngine.class);
    workflowEngine.setWorkflowRunConfiguration(workflowRunConfiguration);
    if (workflowEngine instanceof LocalWorkflowEngine) {
        ((LocalWorkflowEngine) workflowEngine).setParentLoggingObject(parentLogging);
    }
    workflowEngine.setWorkflowMeta(workflowMeta);
    return workflowEngine;
}
Also used : IWorkflowEngineRunConfiguration(org.apache.hop.workflow.config.IWorkflowEngineRunConfiguration) HopException(org.apache.hop.core.exception.HopException) PluginRegistry(org.apache.hop.core.plugins.PluginRegistry) LocalWorkflowEngine(org.apache.hop.workflow.engines.local.LocalWorkflowEngine) IPlugin(org.apache.hop.core.plugins.IPlugin)

Example 3 with IWorkflowEngineRunConfiguration

use of org.apache.hop.workflow.config.IWorkflowEngineRunConfiguration in project hop by apache.

the class WorkflowRunConfigurationEditor method populateMetaMap.

private Map<String, IWorkflowEngineRunConfiguration> populateMetaMap() {
    metaMap = new HashMap<>();
    List<IPlugin> plugins = PluginRegistry.getInstance().getPlugins(WorkflowEnginePluginType.class);
    for (IPlugin plugin : plugins) {
        try {
            IWorkflowEngine<?> engine = PluginRegistry.getInstance().loadClass(plugin, IWorkflowEngine.class);
            // Get the default run configuration for the engine.
            // 
            IWorkflowEngineRunConfiguration engineRunConfiguration = engine.createDefaultWorkflowEngineRunConfiguration();
            engineRunConfiguration.setEnginePluginId(plugin.getIds()[0]);
            engineRunConfiguration.setEnginePluginName(plugin.getName());
            metaMap.put(engineRunConfiguration.getEnginePluginName(), engineRunConfiguration);
        } catch (Exception e) {
            HopGui.getInstance().getLog().logError("Error instantiating workflow run configuration plugin", e);
        }
    }
    return metaMap;
}
Also used : IWorkflowEngineRunConfiguration(org.apache.hop.workflow.config.IWorkflowEngineRunConfiguration) HopException(org.apache.hop.core.exception.HopException) IPlugin(org.apache.hop.core.plugins.IPlugin)

Example 4 with IWorkflowEngineRunConfiguration

use of org.apache.hop.workflow.config.IWorkflowEngineRunConfiguration in project hop by apache.

the class WorkflowRunConfigurationEditor method changeWorkingEngineConfiguration.

private void changeWorkingEngineConfiguration(WorkflowRunConfiguration meta) {
    String pluginName = wPluginType.getText();
    IWorkflowEngineRunConfiguration engineRunConfiguration = metaMap.get(pluginName);
    if (engineRunConfiguration != null) {
        // Switch to the right plugin type
        // 
        meta.setEngineRunConfiguration(engineRunConfiguration);
    } else {
        meta.setEngineRunConfiguration(null);
    }
}
Also used : IWorkflowEngineRunConfiguration(org.apache.hop.workflow.config.IWorkflowEngineRunConfiguration)

Aggregations

IWorkflowEngineRunConfiguration (org.apache.hop.workflow.config.IWorkflowEngineRunConfiguration)4 HopException (org.apache.hop.core.exception.HopException)3 IPlugin (org.apache.hop.core.plugins.IPlugin)2 Result (org.apache.hop.core.Result)1 WorkflowTracker (org.apache.hop.core.gui.WorkflowTracker)1 PluginRegistry (org.apache.hop.core.plugins.PluginRegistry)1 LocalWorkflowEngine (org.apache.hop.workflow.engines.local.LocalWorkflowEngine)1 WebResult (org.apache.hop.www.WebResult)1