protected int doRun() {
        VisitorParameters visitorParameters = params.getVisitorParameters();
        // If progress file already exists, create resume token from it
        if (visitorParameters.getResumeFileName() != null &&
            !"".equals(visitorParameters.getResumeFileName()))
        {
            try {
                var progressFileContents = Files.readString(Path.of(visitorParameters.getResumeFileName()));
                visitorParameters.setResumeToken(new ProgressToken(progressFileContents));

                if (params.isVerbose()) {
                    System.err.format("Resuming visitor already %.1f %% finished.\n",
                            visitorParameters.getResumeToken().percentFinished());
                }
            } catch (NoSuchFileException e) {
                // Ignore; file has not been created yet but will be shortly.
            } catch (IOException e) {
                System.err.println("Could not open progress file: " + visitorParameters.getResumeFileName());
                e.printStackTrace(System.err);
                return 1;
            }
        }

        initShutdownHook();
        sessionAccessor = sessionAccessorFactory.createVisitorSessionAccessor();

        VdsVisitHandler handler;

        var handlerParams = new StdOutVisitorHandler.Params();
        handlerParams.printIds             = params.isPrintIdsOnly();
        handlerParams.indentXml            = params.isVerbose();
        handlerParams.showProgress         = params.isVerbose();
        handlerParams.showStatistics       = params.isVerbose();
        handlerParams.doStatistics         = params.getStatisticsParts() != null;
        handlerParams.abortOnClusterDown   = params.getAbortOnClusterDown();
        handlerParams.processTimeMilliSecs = params.getProcessTime();
        handlerParams.outputFormat         = params.stdOutHandlerOutputFormat();
        handlerParams.tensorShortForm      = params.tensorShortForm();
        handlerParams.tensorDirectValues   = params.tensorDirectValues();
        handlerParams.nullRender           = params.nullRender();
        handler = new StdOutVisitorHandler(handlerParams);

        if (visitorParameters.getResumeFileName() != null) {
            handler.setProgressFileName(visitorParameters.getResumeFileName());
        }

        visitorParameters.setControlHandler(handler.getControlHandler());
        if (visitorParameters.getRemoteDataHandler() == null) {
            visitorParameters.setLocalDataHandler(handler.getDataHandler());
        }

        if (params.getStatisticsParts() != null) {
            String[] parts = params.getStatisticsParts().split(",");
            for (String s : parts) {
                visitorParameters.setLibraryParameter(s, "true");
            }
        }

        try {
            session = sessionAccessor.createVisitorSession(visitorParameters);
            while (true) {
                try {
                    if (session.waitUntilDone(params.getFullTimeout())) break;
                } catch (InterruptedException e) {}
            }

            if (visitorParameters.getTraceLevel() > 0) {
                System.out.println(session.getTrace().toString());
            }
        } catch (ParseException e) {
            onDocumentSelectionException(e);
        } catch (IllegalArgumentException e) {
            onIllegalArgumentException(e);
        } catch (Exception e) {
            System.err.println("Document selection string was: " + visitorParameters.getDocumentSelection());
            System.err.println("Caught unexpected exception: ");
            e.printStackTrace(System.err);
            return 1;
        }
        if (visitorParameters.getControlHandler().getResult().code
                == VisitorControlHandler.CompletionCode.SUCCESS)
        {
            return 0;
        } else {
            return 1;
        }
    }
If not specified in options, will get form cluster list
vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java