Package org.apache.oodt.cas.pushpull.retrievalsystem

Examples of org.apache.oodt.cas.pushpull.retrievalsystem.FileRetrievalSystem


    }

    public void retrieveFiles(PropFilesInfo pfi, final DataFilesInfo dfi)
            throws RetrievalMethodException {

        FileRetrievalSystem dataFilesFRS = null;
        try {
            this.startPropFileDownload(pfi);

            (dataFilesFRS = new FileRetrievalSystem(config, siteInfo))
                    .initialize();
            dataFilesFRS.registerDownloadListener(linker);

            File[] propFiles = null;
            while ((propFiles = getCurrentlyDownloadedPropFiles(pfi)).length > 0
                    || downloadingProps) {
                for (File propFile : propFiles) {
                    try {
                        Parser parser = pfi.getParserForFile(propFile);
                        Class<RetrievalMethod> rmClass = config.getParserInfo()
                                .getRetrievalMethod(parser);
                        RetrievalMethod rm = null;
                        if ((rm = this.classToRmMap.get(rmClass)) == null) {
                            LOG.log(Level.INFO, "Creating '"
                                    + rmClass.getCanonicalName()
                                    + "' to download data files");
                            rm = PushPullObjectFactory
                                    .createNewInstance(rmClass);
                            this.classToRmMap.put(rmClass, rm);
                        }
                        rm.processPropFile(dataFilesFRS, parser, propFile, dfi,
                                linker);
                    } catch (ParserException e) {
                        LOG.log(Level.SEVERE, "Failed to parse property file "
                                + propFile + " : " + e.getMessage());
                        linker.markAsFailed(propFile,
                                "Failed to parse property file " + propFile
                                        + " : " + e.getMessage());
                    } catch (Exception e) {
                        LOG.log(Level.SEVERE,
                                "Failed to finish downloading per property files "
                                        + propFile.getAbsolutePath() + " : "
                                        + e.getMessage());
                        linker.markAsFailed(propFile,
                                "Error while downloading per property file "
                                        + propFile.getAbsolutePath() + " : "
                                        + e.getMessage());
                    }
                }

                dataFilesFRS.waitUntilAllCurrentDownloadsAreComplete();

                for (File propFile : propFiles) {
                    try {
                        if (pfi.getLocalDir().equals(pfi.getOnSuccessDir())
                                || pfi.getLocalDir().equals(pfi.getOnFailDir()))
                            alreadyProcessedPropFiles.add(propFile);
                        this.movePropsFileToFinalDestination(pfi, propFile,
                                linker.getErrorsAndEraseLinks(propFile));
                    } catch (Exception e) {
                        e.printStackTrace();
                        LOG.log(Level.SEVERE,
                                "Error occurred while writing errors to error dir for file '"
                                        + propFile + "' : " + e.getMessage());
                    }
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (dataFilesFRS != null)
                dataFilesFRS.shutdown();
            alreadyProcessedPropFiles.clear();
            linker.clear();
        }
    }
View Full Code Here


        if (pfi.needsToBeDownloaded()) {
            this.downloadingProps = true;
            new Thread(new Runnable() {

                public void run() {
                    FileRetrievalSystem frs = null;
                    try {
                        (frs = new FileRetrievalSystem(
                                RetrievalSetup.this
                                        .createPropFilesConfig(config
                                                .getProtocolInfo()), siteInfo))
                                .initialize();

                        LinkedList<File> propDirStructFiles = pfi
                                .getDownloadInfoPropFiles();
                        for (File dirStructFile : propDirStructFiles) {
                            Parser parser = pfi.getParserForFile(dirStructFile);
                            Class<RetrievalMethod> rmClass = config
                                    .getParserInfo().getRetrievalMethod(parser);
                            RetrievalMethod rm = null;
                            if ((rm = RetrievalSetup.this.classToRmMap
                                    .get(rmClass)) == null) {
                                LOG.log(Level.INFO, "Creating '"
                                        + rmClass.getCanonicalName()
                                        + "' to download property files");
                                rm = PushPullObjectFactory
                                        .createNewInstance(rmClass);
                                RetrievalSetup.this.classToRmMap.put(rmClass,
                                        rm);
                            }
                            rm.processPropFile(frs, parser, dirStructFile,
                                    new DataFilesInfo(null, pfi
                                            .getDownloadInfo()), linker);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        if (frs != null)
                            frs.shutdown();
                        RetrievalSetup.this.downloadingProps = false;
                    }
                }

            }).start();
View Full Code Here

    }

    public void retrieveFiles(PropFilesInfo pfi, final DataFilesInfo dfi)
            throws RetrievalMethodException {

        FileRetrievalSystem dataFilesFRS = null;
        try {
            this.startPropFileDownload(pfi);

            (dataFilesFRS = new FileRetrievalSystem(config, siteInfo))
                    .initialize();
            dataFilesFRS.registerDownloadListener(linker);

            File[] propFiles = null;
            while ((propFiles = getCurrentlyDownloadedPropFiles(pfi)).length > 0
                    || downloadingProps) {
                for (File propFile : propFiles) {
                    try {
                        Parser parser = pfi.getParserForFile(propFile);
                        Class<RetrievalMethod> rmClass = config.getParserInfo()
                                .getRetrievalMethod(parser);
                        RetrievalMethod rm = null;
                        if ((rm = this.classToRmMap.get(rmClass)) == null) {
                            LOG.log(Level.INFO, "Creating '"
                                    + rmClass.getCanonicalName()
                                    + "' to download data files");
                            rm = PushPullObjectFactory
                                    .createNewInstance(rmClass);
                            this.classToRmMap.put(rmClass, rm);
                        }
                        rm.processPropFile(dataFilesFRS, parser, propFile, dfi,
                                linker);
                    } catch (ParserException e) {
                        LOG.log(Level.SEVERE, "Failed to parse property file "
                                + propFile + " : " + e.getMessage(), e);
                        linker.markAsFailed(propFile,
                                "Failed to parse property file " + propFile
                                        + " : " + e.getMessage());
                    } catch (Exception e) {
                        LOG.log(Level.SEVERE,
                                "Failed to finish downloading per property files "
                                        + propFile.getAbsolutePath() + " : "
                                        + e.getMessage(), e);
                        linker.markAsFailed(propFile,
                                "Error while downloading per property file "
                                        + propFile.getAbsolutePath() + " : "
                                        + e.getMessage());
                    }
                }

                dataFilesFRS.waitUntilAllCurrentDownloadsAreComplete();

                for (File propFile : propFiles) {
                    try {
                        if (pfi.getLocalDir().equals(pfi.getOnSuccessDir())
                                || pfi.getLocalDir().equals(pfi.getOnFailDir()))
                            alreadyProcessedPropFiles.add(propFile);
                        this.movePropsFileToFinalDestination(pfi, propFile,
                                linker.getErrorsAndEraseLinks(propFile));
                    } catch (Exception e) {
                        e.printStackTrace();
                        LOG.log(Level.SEVERE,
                                "Error occurred while writing errors to error dir for file '"
                                        + propFile + "' : " + e.getMessage());
                    }
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (dataFilesFRS != null)
                dataFilesFRS.shutdown();
            alreadyProcessedPropFiles.clear();
            linker.clear();
        }
    }
View Full Code Here

            this.downloadingProps = true;
            new Thread(new Runnable() {

                @Override
               public void run() {
                    FileRetrievalSystem frs = null;
                    try {
                        (frs = new FileRetrievalSystem(
                                RetrievalSetup.this
                                        .createPropFilesConfig(config
                                                .getProtocolInfo()), siteInfo))
                                .initialize();

                        LinkedList<File> propDirStructFiles = pfi
                                .getDownloadInfoPropFiles();
                        for (File dirStructFile : propDirStructFiles) {
                            Parser parser = pfi.getParserForFile(dirStructFile);
                            Class<RetrievalMethod> rmClass = config
                                    .getParserInfo().getRetrievalMethod(parser);
                            RetrievalMethod rm = null;
                            if ((rm = RetrievalSetup.this.classToRmMap
                                    .get(rmClass)) == null) {
                                LOG.log(Level.INFO, "Creating '"
                                        + rmClass.getCanonicalName()
                                        + "' to download property files");
                                rm = PushPullObjectFactory
                                        .createNewInstance(rmClass);
                                RetrievalSetup.this.classToRmMap.put(rmClass,
                                        rm);
                            }
                            rm.processPropFile(frs, parser, dirStructFile,
                                    new DataFilesInfo(null, pfi
                                            .getDownloadInfo()), linker);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        if (frs != null)
                            frs.shutdown();
                        RetrievalSetup.this.downloadingProps = false;
                    }
                }

            }).start();
View Full Code Here

    }

    public void retrieveFiles(PropFilesInfo pfi, final DataFilesInfo dfi)
            throws RetrievalMethodException {

        FileRetrievalSystem dataFilesFRS = null;
        try {
            this.startPropFileDownload(pfi);

            (dataFilesFRS = new FileRetrievalSystem(config, siteInfo))
                    .initialize();
            dataFilesFRS.registerDownloadListener(linker);

            File[] propFiles = null;
            while ((propFiles = getCurrentlyDownloadedPropFiles(pfi)).length > 0
                    || downloadingProps) {
                for (File propFile : propFiles) {
                    try {
                        Parser parser = pfi.getParserForFile(propFile);
                        Class<RetrievalMethod> rmClass = config.getParserInfo()
                                .getRetrievalMethod(parser);
                        RetrievalMethod rm = null;
                        if ((rm = this.classToRmMap.get(rmClass)) == null) {
                            LOG.log(Level.INFO, "Creating '"
                                    + rmClass.getCanonicalName()
                                    + "' to download data files");
                            rm = PushPullObjectFactory
                                    .createNewInstance(rmClass);
                            this.classToRmMap.put(rmClass, rm);
                        }
                        rm.processPropFile(dataFilesFRS, parser, propFile, dfi,
                                linker);
                    } catch (ParserException e) {
                        LOG.log(Level.SEVERE, "Failed to parse property file "
                                + propFile + " : " + e.getMessage(), e);
                        linker.markAsFailed(propFile,
                                "Failed to parse property file " + propFile
                                        + " : " + e.getMessage());
                    } catch (Exception e) {
                        LOG.log(Level.SEVERE,
                                "Failed to finish downloading per property files "
                                        + propFile.getAbsolutePath() + " : "
                                        + e.getMessage(), e);
                        linker.markAsFailed(propFile,
                                "Error while downloading per property file "
                                        + propFile.getAbsolutePath() + " : "
                                        + e.getMessage());
                    }
                }

                dataFilesFRS.waitUntilAllCurrentDownloadsAreComplete();

                for (File propFile : propFiles) {
                    try {
                        if (pfi.getLocalDir().equals(pfi.getOnSuccessDir())
                                || pfi.getLocalDir().equals(pfi.getOnFailDir()))
                            alreadyProcessedPropFiles.add(propFile);
                        this.movePropsFileToFinalDestination(pfi, propFile,
                                linker.getErrorsAndEraseLinks(propFile));
                    } catch (Exception e) {
                        e.printStackTrace();
                        LOG.log(Level.SEVERE,
                                "Error occurred while writing errors to error dir for file '"
                                        + propFile + "' : " + e.getMessage());
                    }
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (dataFilesFRS != null)
                dataFilesFRS.shutdown();
            alreadyProcessedPropFiles.clear();
            linker.clear();
        }
    }
View Full Code Here

            this.downloadingProps = true;
            new Thread(new Runnable() {

                @Override
               public void run() {
                    FileRetrievalSystem frs = null;
                    try {
                        (frs = new FileRetrievalSystem(
                                RetrievalSetup.this
                                        .createPropFilesConfig(config
                                                .getProtocolInfo()), siteInfo))
                                .initialize();

                        LinkedList<File> propDirStructFiles = pfi
                                .getDownloadInfoPropFiles();
                        for (File dirStructFile : propDirStructFiles) {
                            Parser parser = pfi.getParserForFile(dirStructFile);
                            Class<RetrievalMethod> rmClass = config
                                    .getParserInfo().getRetrievalMethod(parser);
                            RetrievalMethod rm = null;
                            if ((rm = RetrievalSetup.this.classToRmMap
                                    .get(rmClass)) == null) {
                                LOG.log(Level.INFO, "Creating '"
                                        + rmClass.getCanonicalName()
                                        + "' to download property files");
                                rm = PushPullObjectFactory
                                        .createNewInstance(rmClass);
                                RetrievalSetup.this.classToRmMap.put(rmClass,
                                        rm);
                            }
                            rm.processPropFile(frs, parser, dirStructFile,
                                    new DataFilesInfo(null, pfi
                                            .getDownloadInfo()), linker);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        if (frs != null)
                            frs.shutdown();
                        RetrievalSetup.this.downloadingProps = false;
                    }
                }

            }).start();
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.pushpull.retrievalsystem.FileRetrievalSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.