Search in sources :

Example 1 with VespaFeedHandler

use of com.yahoo.feedhandler.VespaFeedHandler in project vespa by vespa-engine.

the class VespaFeeder method parseFiles.

void parseFiles(InputStream stdin, PrintStream output) throws Exception {
    FeedContext context = new FeedContext(args.getPropertyProcessor(), args.getSessionFactory(), manager, new ClusterList(), new NullFeedMetric());
    final BufferedInputStream input = new BufferedInputStream(stdin);
    VespaFeedHandler handler = VespaFeedHandler.createFromContext(context, threadPool);
    if (args.getFiles().isEmpty()) {
        InputStreamRequest req = new InputStreamRequest(input);
        setProperties(req, input);
        FeedResponse response = (FeedResponse) handler.handle(req.toRequest(), createProgressCallback(output));
        if (!response.isSuccess()) {
            throw renderErrors(response.getErrorList());
        }
    } else {
        if (args.isVerbose()) {
            for (String fileName : args.getFiles()) {
                long thisSize = new File(fileName).length();
                output.println("Size of file '" + fileName + "' is " + thisSize + " B.");
            }
        }
        for (String fileName : args.getFiles()) {
            File f = new File(fileName);
            FileRequest req = new FileRequest(f);
            final BufferedInputStream inputSnooper = new BufferedInputStream(new FileInputStream(fileName));
            setProperties(req, inputSnooper);
            inputSnooper.close();
            FeedResponse response = (FeedResponse) handler.handle(req.toRequest(), createProgressCallback(output));
            if (!response.isSuccess()) {
                throw renderErrors(response.getErrorList());
            }
        }
    }
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) FeedContext(com.yahoo.feedapi.FeedContext) VespaFeedHandler(com.yahoo.feedhandler.VespaFeedHandler) FeedResponse(com.yahoo.feedhandler.FeedResponse) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric)

Aggregations

FeedContext (com.yahoo.feedapi.FeedContext)1 FeedResponse (com.yahoo.feedhandler.FeedResponse)1 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)1 VespaFeedHandler (com.yahoo.feedhandler.VespaFeedHandler)1 ClusterList (com.yahoo.vespaclient.ClusterList)1