Search in sources :

Example 1 with DataTransferJob

use of org.jkiss.dbeaver.tools.transfer.DataTransferJob in project dbeaver by serge-rider.

the class DTTaskHandlerTransfer method executeWithSettings.

public void executeWithSettings(@NotNull DBRRunnableContext runnableContext, DBTTask task, @NotNull Locale locale, @NotNull Log log, @NotNull DBTTaskExecutionListener listener, DataTransferSettings settings) throws DBException {
    // Start consumers
    listener.taskStarted(settings);
    List<DataTransferPipe> dataPipes = settings.getDataPipes();
    try {
        runnableContext.run(true, false, monitor -> {
            monitor.beginTask("Initialize pipes", dataPipes.size());
            try {
                for (int i = 0; i < dataPipes.size(); i++) {
                    DataTransferPipe pipe = dataPipes.get(i);
                    pipe.initPipe(settings, i, dataPipes.size());
                    pipe.getConsumer().startTransfer(monitor);
                    monitor.worked(1);
                }
            } catch (DBException e) {
                throw new InvocationTargetException(e);
            } finally {
                monitor.done();
            }
        });
    } catch (InvocationTargetException e) {
        throw new DBException("Error starting data transfer", e.getTargetException());
    } catch (InterruptedException e) {
        return;
    }
    // Schedule jobs for data providers
    int totalJobs = settings.getDataPipes().size();
    if (totalJobs > settings.getMaxJobCount()) {
        totalJobs = settings.getMaxJobCount();
    }
    Throwable error = null;
    for (int i = 0; i < totalJobs; i++) {
        DataTransferJob job = new DataTransferJob(settings, task, locale, log, listener);
        try {
            runnableContext.run(true, true, job);
        } catch (InvocationTargetException e) {
            error = e.getTargetException();
        } catch (InterruptedException e) {
            break;
        }
        listener.subTaskFinished(error);
    }
    listener.taskFinished(settings, error);
}
Also used : DBException(org.jkiss.dbeaver.DBException) DataTransferJob(org.jkiss.dbeaver.tools.transfer.DataTransferJob) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.DataTransferPipe) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with DataTransferJob

use of org.jkiss.dbeaver.tools.transfer.DataTransferJob in project dbeaver by dbeaver.

the class DTTaskHandlerTransfer method executeWithSettings.

public void executeWithSettings(@NotNull DBRRunnableContext runnableContext, DBTTask task, @NotNull Locale locale, @NotNull Log log, @NotNull DBTTaskExecutionListener listener, DataTransferSettings settings) throws DBException {
    // Start consumers
    listener.taskStarted(settings);
    List<DataTransferPipe> dataPipes = settings.getDataPipes();
    try {
        runnableContext.run(true, false, monitor -> {
            monitor.beginTask("Initialize pipes", dataPipes.size());
            try {
                for (int i = 0; i < dataPipes.size(); i++) {
                    DataTransferPipe pipe = dataPipes.get(i);
                    pipe.initPipe(settings, i, dataPipes.size());
                    pipe.getConsumer().startTransfer(monitor);
                    monitor.worked(1);
                }
            } catch (DBException e) {
                throw new InvocationTargetException(e);
            } finally {
                monitor.done();
            }
        });
    } catch (InvocationTargetException e) {
        throw new DBException("Error starting data transfer", e.getTargetException());
    } catch (InterruptedException e) {
        return;
    }
    // Schedule jobs for data providers
    int totalJobs = settings.getDataPipes().size();
    if (totalJobs > settings.getMaxJobCount()) {
        totalJobs = settings.getMaxJobCount();
    }
    Throwable error = null;
    for (int i = 0; i < totalJobs; i++) {
        DataTransferJob job = new DataTransferJob(settings, task, locale, log, listener);
        try {
            runnableContext.run(true, true, job);
        } catch (InvocationTargetException e) {
            error = e.getTargetException();
        } catch (InterruptedException e) {
            break;
        }
        listener.subTaskFinished(error);
    }
    listener.taskFinished(settings, error);
}
Also used : DBException(org.jkiss.dbeaver.DBException) DataTransferJob(org.jkiss.dbeaver.tools.transfer.DataTransferJob) DataTransferPipe(org.jkiss.dbeaver.tools.transfer.DataTransferPipe) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)2 DBException (org.jkiss.dbeaver.DBException)2 DataTransferJob (org.jkiss.dbeaver.tools.transfer.DataTransferJob)2 DataTransferPipe (org.jkiss.dbeaver.tools.transfer.DataTransferPipe)2