Example usage for org.apache.commons.vfs FileObject delete

List of usage examples for org.apache.commons.vfs FileObject delete

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileObject delete.

Prototype

public boolean delete() throws FileSystemException;

Source Link

Document

Deletes this file.

Usage

From source file:org.josso.tooling.gshell.install.installer.VFSInstaller.java

public boolean backupGatewayConfigurations(boolean remove) {
    try {// w  w  w.  j  a va  2s . co m
        FileObject[] libs = targetJOSSOConfDir.getChildren();
        for (int i = 0; i < libs.length; i++) {
            FileObject cfgFile = libs[i];

            if (!cfgFile.getType().getName().equals(FileType.FILE.getName())) {
                // ignore folders
                continue;
            }
            if (cfgFile.getName().getBaseName().startsWith("josso-")
                    && !cfgFile.getName().getBaseName().startsWith("josso-agent")
                    && (cfgFile.getName().getBaseName().endsWith(".xml")
                            || (cfgFile.getName().getBaseName().endsWith(".properties")))) {
                //backup files in the same folder they're installed in
                backupFile(cfgFile, cfgFile.getParent());
                if (remove) {
                    cfgFile.delete();
                }
            }
        }
    } catch (Exception e) {
        getPrinter().printErrStatus("BackupGatewayConfigurations", e.getMessage());
        return false;
    }
    return true;
}

From source file:org.josso.tooling.gshell.install.installer.VFSInstaller.java

public boolean backupAgentConfigurations(boolean remove) {
    try {/*w w w . ja va2 s.c o  m*/
        // backup josso-agent-config.xml
        FileObject agentConfigFile = targetJOSSOConfDir.resolveFile("josso-agent-config.xml");
        if (agentConfigFile.exists()) {
            // backup file in the same folder it is installed
            backupFile(agentConfigFile, agentConfigFile.getParent());
            if (remove) {
                agentConfigFile.delete();
            }
        }
    } catch (Exception e) {
        getPrinter().printErrStatus("BackupAgentConfigurations", e.getMessage());
        return false;
    }
    return true;
}

From source file:org.josso.tooling.gshell.install.installer.VFSInstaller.java

public boolean removeOldComponents(boolean backup) {
    try {//from w ww  .  j  ava  2s .c o  m
        FileObject[] sharedLibs = targetJOSSOSharedLibDir.getChildren();
        for (int i = 0; i < sharedLibs.length; i++) {
            FileObject jarFile = sharedLibs[i];

            if (!jarFile.getType().getName().equals(FileType.FILE.getName())) {
                // ignore folders
                continue;
            }
            if (jarFile.getName().getBaseName().startsWith("josso-")
                    && jarFile.getName().getBaseName().endsWith(".jar")) {
                if (backup) {
                    // backup files in the same folder they're installed in
                    backupFile(jarFile, jarFile.getParent());
                }
                jarFile.delete();
            }
        }

        FileObject[] libs = targetJOSSOLibDir.getChildren();
        for (int i = 0; i < libs.length; i++) {
            FileObject jarFile = libs[i];

            if (!jarFile.getType().getName().equals(FileType.FILE.getName())) {
                // ignore folders
                continue;
            }
            if (jarFile.getName().getBaseName().startsWith("josso-")
                    && jarFile.getName().getBaseName().endsWith(".jar")) {
                if (backup) {
                    // backup files in the same folder they're installed in
                    backupFile(jarFile, jarFile.getParent());
                }
                jarFile.delete();
            }
        }
    } catch (Exception e) {
        getPrinter().printErrStatus("RemoveOldComponents", e.getMessage());
        return false;
    }
    return true;
}

From source file:org.josso.tooling.gshell.install.installer.VFSInstaller.java

public boolean removeOldJar(String fullJarName, FileObject destDir, boolean backup) {
    try {/*ww w  .  j  av  a  2 s  .  c o  m*/
        if (fullJarName.endsWith(".jar") && fullJarName.lastIndexOf("-") != -1) {
            String jarNameWithoutVersion = fullJarName.substring(0, fullJarName.lastIndexOf("-"));

            FileObject[] files = destDir.getChildren();
            for (int i = 0; i < files.length; i++) {
                FileObject file = files[i];

                if (!file.getType().getName().equals(FileType.FILE.getName())) {
                    // ignore folders
                    continue;
                }

                String fileName = file.getName().getBaseName();
                if (fileName.startsWith(jarNameWithoutVersion) && fileName.endsWith(".jar")
                        && fileName
                                .substring(jarNameWithoutVersion.length(), jarNameWithoutVersion.length() + 2)
                                .matches("-[0-9]|\\.j")) {
                    if (backup) {
                        // backup files in the same folder they're installed in
                        backupFile(file, file.getParent());
                    }
                    file.delete();
                    break;
                }
            }
        }
    } catch (Exception e) {
        getPrinter().printErrStatus("RemoveOldJar", e.getMessage());
        return false;
    }
    return true;
}

From source file:org.kalypso.dwd.servlet.dwdfilecopy.DWDCopyTask.java

@Override
public void run() {
    FileObject newFile = null;

    try {//from   w  ww.  j  a va  2  s  .co  m
        /* Check for the file or the base file (this could be a directory). */
        m_fo = m_fsManager.resolveFile(m_URI);

        if (m_fo.getType() != FileType.FOLDER) {
            System.out.println("The URI " + m_URI + " is no folder.");
            return;
        }

        /* Get all elements in this directory. */
        m_list = m_fo.getChildren();

        if (m_list.length == 0) {
            DWDFileCopyServlet.LOG.warning("There are no files in the Source:" + m_fo.getName().toString());
            return;
        }

        /* Find the newest file. */
        newFile = getNewestFile();

        if (newFile == null)
            return;

        DWDFileCopyServlet.LOG.info("Newest file: " + newFile.getName().getBaseName().toString());
    } catch (FileSystemException e) {
        DWDFileCopyServlet.LOG.warning("Error resolving the URI: " + e.getLocalizedMessage());
        return;
    } finally {
    }

    // looping twice over this code in the case an exception
    // occurs, we try it again...
    for (int i = 0; i < 2; i++) {
        FileOutputStream os = null;
        InputStream is = null;

        try {
            final Date newestDate = getDateFromRaster(newFile, m_dateFormat);
            final Date destFileDate = getDateFromRasterContent(m_destFile);

            DWDFileCopyServlet.LOG.info("Date of newest file: " + newestDate);
            DWDFileCopyServlet.LOG.info("Date of destination file: " + destFileDate);

            // if dest file either does not exist or is not up to date, overwrite with current DWD forecast
            if (destFileDate == null || newestDate.after(destFileDate)) {
                /* Copy the newest file. */
                DWDFileCopyServlet.LOG.info("Copying ...");

                final File dwdDest;

                if (m_destUpdate)
                    dwdDest = new File(m_destFile.getParentFile(), newFile.getName().getBaseName());
                else
                    dwdDest = m_destFile;

                DWDFileCopyServlet.LOG.info("Copying DWD-File \"" + newFile.getName().getBaseName() + "\" to: "
                        + dwdDest.getAbsolutePath());

                os = new FileOutputStream(dwdDest);
                is = newFile.getContent().getInputStream();

                /* The copy operation. */
                IOUtils.copy(is, os);

                os.close();
                is.close();

                // update file contents
                if (m_destUpdate) {
                    DWDFileCopyServlet.LOG.info("Updating " + m_destFile.getName() + " from " + dwdDest);
                    DWDRasterHelper.updateDWDFileContents(dwdDest, m_destFile, m_dateFormat);

                    m_destFile.setLastModified(newFile.getContent().getLastModifiedTime());

                    final boolean deleted = dwdDest.delete();

                    if (!deleted)
                        DWDFileCopyServlet.LOG
                                .warning("Could not delete temp DWD-File \"" + dwdDest.getName() + "\"");
                }
            }

            // delete source file if flag is set
            if (m_srcDel) {
                try {
                    /* Delete the old files. */
                    DWDFileCopyServlet.LOG.info("Deleting " + newFile.getName().getBaseName());

                    final boolean deleted = newFile.delete();
                    if (!deleted)
                        DWDFileCopyServlet.LOG.warning(
                                "Could not delete DWD-File \"" + newFile.getName().getBaseName() + "\"");
                } catch (final IOException e) {
                    DWDFileCopyServlet.LOG
                            .warning("Could not delete DWD-File \"" + newFile.getName().getBaseName() + "\"");

                    if (m_debug)
                        e.printStackTrace();
                }
            }

            // no exception, so end loop here
            return;
        } catch (final IOException e) {
            DWDFileCopyServlet.LOG.warning("Could not copy DWD-File \"" + newFile.getName().getBaseName()
                    + "\" to folder: " + m_destFile.getAbsolutePath() + " due to: " + e.getLocalizedMessage());

            if (m_debug)
                e.printStackTrace();
        } catch (final DWDException e) {
            DWDFileCopyServlet.LOG.warning("DWD-File could not be updated: " + e.getLocalizedMessage());
        } finally {
            IOUtils.closeQuietly(is);
            IOUtils.closeQuietly(os);
        }

        try {
            // make some pause before continuing
            Thread.sleep(500);
        } catch (final InterruptedException ignored) {
            // empty
        }
    }
}

From source file:org.objectweb.proactive.extensions.dataspaces.vfs.VFSNodeScratchSpaceImpl.java

public synchronized void close() throws IllegalStateException {
    logger.debug("Closing node scratch space");
    checkIfConfigured();/*from  ww  w .j  av  a  2 s. c o  m*/

    try {
        final FileObject fRuntime = partialSpaceFile.getParent();

        // rm -r node
        partialSpaceFile.delete(Selectors.SELECT_ALL);

        // try to remove runtime file
        // IMPORTANT FIXME: it seems that despite of VFS FileObject documentation,
        // looking at AbstractFileObject docs suggests that it does not implement this
        // delete-if-empty behavior! at least, it appears to be not atomic (and probably may be never atomic
        // as some protocols may not support this kind of atomic operation?)
        // refreshing file before deleting may minimize the risk of delete-when-non-empty behavior
        fRuntime.refresh();
        try {
            final boolean deleted = fRuntime.delete();
            if (deleted)
                logger.debug("Scratch directory for whole runtime was deleted (considered as empty)");
            else
                logger.debug("Scratch directory for whole runtime was not deleted (not considered as empty)");
        } catch (org.apache.commons.vfs.FileSystemException x) {
            logger.debug("Could not delete scratch directory for whole runtime - perhaps it was not empty", x);
        }

        // it is probably not needed to close files if manager is closed, but with VFS you never know...
        fRuntime.close();
        partialSpaceFile.close();
    } catch (org.apache.commons.vfs.FileSystemException x) {
        ProActiveLogger.logEatedException(logger, "Could not close correctly node scratch space", x);
    } finally {
        this.fileSystemManager.close();
    }
    logger.debug("Closed node scratch space");
}

From source file:org.openbi.kettle.plugins.parquetoutput.ParquetOutput.java

public void openNewFile(String baseFilename) throws KettleException {
    if (baseFilename == null) {
        throw new KettleFileException(BaseMessages.getString(PKG, "ParquetOutput.Exception.FileNameNotSet"));
    }//ww  w.  j a v a 2  s. c  o m

    String filename = buildFilename(environmentSubstitute(baseFilename));

    try {
        // Check for parent folder creation only if the user asks for it
        //
        if (meta.isCreateParentFolder()) {
            createParentFolder(filename);
        }

        if (log.isDetailed()) {
            logDetailed("Opening output file in default encoding");
        }

        String compressionCodec = environmentSubstitute(meta.getCompressionCodec());

        if (Const.isEmpty(compressionCodec) || compressionCodec.equalsIgnoreCase("none")) {
            compressionCodec = "uncompressed";
        }

        CompressionCodecName compressionCodecName = CompressionCodecName.fromConf(compressionCodec);

        //Convert to bytes
        int blockSize = -1;

        blockSize = Const.toInt(environmentSubstitute(meta.getBlockSize()), -1) * 1024 * 1024;

        if (blockSize <= 0) {
            throw new KettleException("Error setting block size.  Must be greater than 0.");
        }

        int pageSize = Const.toInt(environmentSubstitute(meta.getPageSize()), -1) * 1024;

        if (pageSize <= 0) {
            throw new KettleException("Error setting page size.  Must be greater than 0.");
        }

        /* HadoopConfiguration hadoopConfiguration =
           HadoopConfigurationBootstrap.getHadoopConfigurationProvider().getActiveConfiguration();
         HadoopShim shim = hadoopConfiguration.getHadoopShim();
         Configuration conf = shim.createConfiguration();
                
         FileSystem fs = shim.getFileSystem( conf );
         Path path = fs.asPath( file.getName().getURI() );
         */

        FileObject file = KettleVFS.getFileObject(filename);

        //Path path = shim.getFileSystem( conf ).asPath( file.getName().getURI() );
        Path path = new Path(file.getName().getURI());

        if (meta.isCleanOutput() && file.exists()) {
            file.delete();
        }

        data.parquetWriters
                .add(new AvroParquetWriter(path, data.avroSchema, compressionCodecName, blockSize, pageSize));
        data.openFiles.add(baseFilename);

        if (log.isDetailed()) {
            logDetailed("Opened new file with name [" + filename + "]");
        }
    } catch (Exception e) {
        throw new KettleException("Error opening new file : " + e.toString(), e);
    }

    data.splitnr++;

    if (meta.isAddToResult()) {
        // Add this to the result file names...
        ResultFile resultFile = new ResultFile(ResultFile.FILE_TYPE_GENERAL,
                getFileObject(filename, getTransMeta()), getTransMeta().getName(), getStepname());
        resultFile.setComment(BaseMessages.getString(PKG, "AvroOutput.AddResultFile"));
        addResultFile(resultFile);
    }
}

From source file:org.openbi.kettle.plugins.refreshtableauextract.RefreshTableauExtract.java

public Result execute(Result previousResult, int nr) throws KettleException {
    Result result = previousResult;
    result.setResult(validate());/*  w w w.  j  a v  a2  s  . com*/
    if (!result.getResult()) {
        return result;
    }
    String[] commands;
    String tableauCommand = getRealValue(getTableauClient()).trim();
    if (tableauCommand.toLowerCase().endsWith(".exe")) {
        tableauCommand = tableauCommand.substring(0, tableauCommand.length() - 4);
    }
    tableauCommand = "\"" + tableauCommand + "\"";
    if (getRefreshType() == 0 || getRefreshType() == 1) {
        tableauCommand += " refreshextract";
    } else if (getRefreshType() == 2) {
        tableauCommand += " addfiletoextract";
    } else {
        logError(BaseMessages.getString(PKG, "RefreshTableauExtract.Error.InvalidRefreshType"));
        result.setResult(false);
        return result;
    }

    tableauCommand += " --server " + protocolList[getProtocol()] + "://" + getRealValue(getServer());
    if (getRealValue(getServerPort()) != null && !getRealValue(getServerPort()).isEmpty()) {
        tableauCommand += ":" + getRealValue(getServerPort());
    }

    tableauCommand += " --username " + getRealValue(getServerUser());
    tableauCommand += " --password " + getRealValue(getServerPassword());
    tableauCommand += " --datasource \"" + getRealValue(getDataSource()) + "\"";

    if (getRealValue(getSiteName()) != null && !getRealValue(getSiteName()).isEmpty()) {
        tableauCommand += " --site \"" + getRealValue(getSiteName()) + "\"";
    }
    if (getRealValue(getProject()) != null && !getRealValue(getProject()).isEmpty()) {
        tableauCommand += " --project \"" + getRealValue(getProject()) + "\"";
    }
    if (getRealValue(getProxyUser()) != null && !getRealValue(getProxyUser()).isEmpty()) {
        tableauCommand += " --proxy-username " + getRealValue(getProxyUser());
    }
    if (getRealValue(getProxyPassword()) != null && !getRealValue(getProxyPassword()).isEmpty()) {
        tableauCommand += " --proxy-password " + getRealValue(getProxyPassword());
    }

    if (getRefreshType() == 0) {
        commands = new String[1];
        tableauCommand += " --original-file \"" + getRealValue(getExtractFile()) + "\"";
        commands[0] = new String(tableauCommand);
    } else if (getRefreshType() == 1) {
        commands = new String[1];
        if (getFullRefresh()) {
            tableauCommand += " --force-full-refresh";
        }
        if (getRealValue(getSourceUser()) != null && !getRealValue(getSourceUser()).isEmpty()) {
            tableauCommand += " --source-username " + getRealValue(getSourceUser());
        }
        if (getRealValue(getSourcePassword()) != null & !getRealValue(getSourcePassword()).isEmpty()) {
            tableauCommand += " --source-password " + getRealValue(getSourcePassword());
        }
        commands[0] = new String(tableauCommand);
    } else {
        String[] fileStrings = null;
        if (processResultFiles) {
            if (result != null && previousResult.getResultFiles().size() > 0) {

                int size = previousResult.getResultFiles().size();
                if (log.isBasic()) {
                    logBasic(BaseMessages.getString(PKG, "RefreshTableauExtract.FilesFound", "" + size));
                }
                try {
                    List<ResultFile> resultFiles = previousResult.getResultFilesList();
                    List<String> files = new ArrayList<String>();
                    Iterator<ResultFile> it = resultFiles.iterator();
                    while (it.hasNext()) {
                        ResultFile f = it.next();
                        FileObject o = f.getFile();
                        if (o.getType().equals(FileType.FILE)) {
                            if (o.exists()) {
                                files.add(o.getName().toString().startsWith("file:///")
                                        ? o.getName().toString().substring(8)
                                        : o.getName().toString());
                            } else {
                                logBasic(BaseMessages.getString(PKG, "RefreshTableauExtract.FileNotExist",
                                        "" + o.getName()));
                            }
                        } else {
                            logBasic(BaseMessages.getString(PKG, "RefreshTableauExtract.ResultNotFile",
                                    "" + o.getName()));
                        }
                    }
                    if (files.size() > 0) {
                        Iterator<String> ite = files.iterator();
                        fileStrings = new String[files.size()];
                        int i = 0;
                        while (ite.hasNext()) {
                            fileStrings[i] = ite.next();
                            i++;
                        }

                    } else {
                        logBasic(BaseMessages.getString(PKG, "RefreshTableauExtract.NoFilesOnResult"));
                        result.setResult(true);
                        return result;
                    }
                } catch (Exception ex) {
                    logError(ex.toString());
                    result.setResult(false);
                    return result;
                }
            } else {
                logBasic(BaseMessages.getString(PKG, "RefreshTableauExtract.NoFilesOnResult"));
                result.setResult(true);
                return result;
            }
        } else {
            // Get source and destination files, also wildcard
            String[] vFilePaths = filePaths;
            String[] vWildcards = wildcards;
            boolean[] includeSubfolders = new boolean[vFilePaths.length];
            String[] fileRequired = new String[vFilePaths.length];

            for (int i = 0; i < includeSubfolders.length; i++) {
                includeSubfolders[i] = false;
            }
            FileInputList files = FileInputList.createFileList(this, vFilePaths, vWildcards, fileRequired,
                    includeSubfolders);
            fileStrings = new String[files.getFileStrings().length];
            fileStrings = files.getFileStrings();
        }
        commands = new String[fileStrings.length];
        for (int i = 0; i < fileStrings.length; i++) {
            commands[i] = new String(tableauCommand + " --file \"" + fileStrings[i] + "\"");
        }
    }

    FileObject fileObject = null;
    String realScript = "";
    FileObject tempFile = null;

    for (int i = 0; i < commands.length; i++) {
        //    realScript+="echo Running: "+commands[i]+"\n";
        realScript += commands[i] + "\n";
        if (log.isDetailed()) {
            logDetailed(BaseMessages.getString(PKG, "RefreshTableauExtract.Commands", commands[i]));
        }
    }
    try {
        // What's the exact command?
        String[] command;

        if (log.isBasic()) {
            logBasic(BaseMessages.getString(PKG, "RefreshTableuaExtract.RunningOn", Const.getOS()));
        }

        if (Const.getOS().equals("Windows 95")) {
            //base = new String[] { "command.com", "/C" };
            tempFile = KettleVFS.createTempFile("kettle", "shell.bat", null, this);
            fileObject = createTemporaryShellFile(tempFile, realScript);
            command = new String[] { "command.com", "/C",
                    "\"" + Const.optionallyQuoteStringByOS(KettleVFS.getFilename(fileObject)) + "\"" };
        } else if (Const.getOS().startsWith("Windows")) {
            //base = new String[] { "cmd.exe", "/C" };
            tempFile = KettleVFS.createTempFile("kettle", "shell.bat", null, this);
            fileObject = createTemporaryShellFile(tempFile, realScript);
            command = new String[] { "cmd.exe", "/C",
                    "\"" + Const.optionallyQuoteStringByOS(KettleVFS.getFilename(fileObject)) + "\"" };
        } else {
            tempFile = KettleVFS.createTempFile("kettle", "shell", null, this);
            fileObject = createTemporaryShellFile(tempFile, realScript);
            command = new String[] { Const.optionallyQuoteStringByOS(KettleVFS.getFilename(fileObject)) };
        }

        ProcessBuilder pb = new ProcessBuilder(command);

        Map<String, String> env = pb.environment();
        String[] variables = listVariables();
        for (int i = 0; i < variables.length; i++) {
            env.put(variables[i], getVariable(variables[i]));
        }

        if (getWorkingDirectory() != null && !Const.isEmpty(Const.rtrim(getRealValue(getWorkingDirectory())))) {
            String vfsFilename = environmentSubstitute(getRealValue(getWorkingDirectory()));
            File file = new File(KettleVFS.getFilename(KettleVFS.getFileObject(vfsFilename, this)));
            pb.directory(file);
        }

        if (log.isDetailed()) {
            logDetailed(BaseMessages.getString(PKG, "RefreshTableauExtract.CommandStarted"));
        }
        Process proc = pb.start();
        // any error message?
        StreamLogger errorLogger = new StreamLogger(log, proc.getErrorStream(), "(stderr)");

        // any output?
        StreamLogger outputLogger = new StreamLogger(log, proc.getInputStream(), "(stdout)");

        // kick them off
        new Thread(errorLogger).start();
        new Thread(outputLogger).start();

        proc.waitFor();

        if (log.isDetailed()) {
            logDetailed(BaseMessages.getString(PKG, "RefreshTableauExtract.CommandFinished"));
        }
        // What's the exit status?
        result.setExitStatus(proc.exitValue());
        if (result.getExitStatus() != 0) {
            logError(BaseMessages.getString(PKG, "RefreshTableauExtract.ExitStatus",
                    "" + result.getExitStatus()));
            result.setResult(false);
        }

        // close the streams
        // otherwise you get "Too many open files, java.io.IOException" after a lot of iterations
        proc.getErrorStream().close();
        proc.getOutputStream().close();

    } catch (Exception ex) {
        logError(ex.toString());
        result.setResult(false);
    } finally {
        // If we created a temporary file, remove it...
        //
        if (tempFile != null) {
            try {
                tempFile.delete();
            } catch (Exception e) {
                BaseMessages.getString(PKG, "RefreshTableauExtract.UnexpectedError", tempFile.toString(),
                        e.toString());
            }
        }
    }

    return result;

}

From source file:org.openbi.kettle.plugins.tableauDataExtract.TDEOutput.java

private void checkFileExists(String filename) throws Exception {
    FileObject file = null;
    FileObject parentfolder = null;

    if (!meta.isCreateParentFolder()) {
        parentfolder = KettleVFS.getFileObject(filename).getParent();
        if (!parentfolder.exists()) {
            throw new KettleException(BaseMessages.getString(PKG, "TDEOutput.Error.ParentFolderDoesNotExist"));
        }//w w w.j  a  v a  2s .  c o m
    }

    file = KettleVFS.getFileObject(filename);
    if (!meta.isFileAppended() && file.exists()) {
        file.delete();
        if (isDetailed())
            logDetailed(BaseMessages.getString(PKG, "TDEOutput.Log.FileDeleted", filename));
    } else {
        if (isDetailed())
            logDetailed(BaseMessages.getString(PKG, "TDEOutput.Log.FileDoesNotExist"));
    }

}

From source file:org.pentaho.di.cluster.PartitioningTest.java

/**
 * This test reads a CSV file in parallel on the cluster, one copy per slave.<br>
 * It then partitions the data on id in 12 partitions (4 per slave) and keeps the data partitioned until written to
 * file.<br>/*from w w w  .j a  va 2 s . c  om*/
 * As such we expect 12 files on disk.<br>
 * File: "partitioning-swimming-lanes-on-cluster.ktr"<br>
 */
public void testPartitioningSwimmingLanesOnCluster() throws Exception {
    init();

    ClusterGenerator clusterGenerator = new ClusterGenerator();
    try {
        clusterGenerator.launchSlaveServers();

        TransMeta transMeta = loadAndModifyTestTransformation(clusterGenerator,
                "test/org/pentaho/di/cluster/partitioning-swimming-lanes-on-cluster.ktr");
        TransExecutionConfiguration config = createClusteredTransExecutionConfiguration();
        TransSplitter transSplitter = Trans.executeClustered(transMeta, config);
        long nrErrors = Trans.monitorClusteredTransformation(
                new LogChannel("cluster unit test <testParallelFileReadOnMaster>"), transSplitter, null, 1);
        assertEquals(0L, nrErrors);

        String[] results = new String[] { "8", "9", "9", "9", "9", "8", "8", "8", "8", "8", "8", "8", };
        String[] files = new String[] { "000", "001", "002", "003", "004", "005", "006", "007", "008", "009",
                "010", "011", };
        for (int i = 0; i < results.length; i++) {
            String filename = "${java.io.tmpdir}/partitioning-swimming-lanes-on-cluster-" + files[i] + ".txt";
            String result = loadFileContent(transMeta, filename);
            assertEqualsIgnoreWhitespacesAndCase(results[i], result);

            // Remove the output file : we don't want to leave too much clutter around
            //
            FileObject file = KettleVFS.getFileObject(transMeta.environmentSubstitute(filename));
            file.delete();
        }

    } catch (Exception e) {
        e.printStackTrace();
        fail(e.toString());
    } finally {
        try {
            clusterGenerator.stopSlaveServers();
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.toString());
        }
    }
}