Package org.opensolaris.opengrok.configuration

Examples of org.opensolaris.opengrok.configuration.RuntimeEnvironment


     * @param executor An executor to run the job
     * @throws IOException if an error occurs
     */
    static void optimizeAll(ExecutorService executor) throws IOException {
        List<IndexDatabase> dbs = new ArrayList<>();
        RuntimeEnvironment env = RuntimeEnvironment.getInstance();
        if (env.hasProjects()) {
            for (Project project : env.getProjects()) {
                dbs.add(new IndexDatabase(project));
            }
        } else {
            dbs.add(new IndexDatabase());
        }
View Full Code Here


     *
     * @param path the path to a file
     * @return true if the file is local to the current repository
     */
    private boolean isLocal(String path) {
        RuntimeEnvironment env = RuntimeEnvironment.getInstance();
        String srcRoot = env.getSourceRootPath();

        boolean local = false;

        if (path.startsWith(srcRoot)) {
            if (env.hasProjects()) {
                String relPath = path.substring(srcRoot.length());
                if (project.equals(Project.getProject(relPath))) {
                    // File is under the current project, so it's local.
                    local = true;
                }
View Full Code Here

     * @param subFiles Subdirectories for the various projects to list the files
     * for (or null or an empty list to dump all projects)
     * @throws IOException if an error occurs
     */
    public static void listAllFiles(List<String> subFiles) throws IOException {
        RuntimeEnvironment env = RuntimeEnvironment.getInstance();
        if (env.hasProjects()) {
            if (subFiles == null || subFiles.isEmpty()) {
                for (Project project : env.getProjects()) {
                    IndexDatabase db = new IndexDatabase(project);
                    db.listFiles();
                }
            } else {
                for (String path : subFiles) {
View Full Code Here

    }

    static void listFrequentTokens(List<String> subFiles) throws IOException {
        final int limit = 4;

        RuntimeEnvironment env = RuntimeEnvironment.getInstance();
        if (env.hasProjects()) {
            if (subFiles == null || subFiles.isEmpty()) {
                for (Project project : env.getProjects()) {
                    IndexDatabase db = new IndexDatabase(project);
                    db.listTokens(4);
                }
            } else {
                for (String path : subFiles) {
View Full Code Here

     * cannot be located.
     */
    public static IndexReader getIndexReader(String path) {
        IndexReader ret = null;

        RuntimeEnvironment env = RuntimeEnvironment.getInstance();
        File indexDir = new File(env.getDataRootFile(), INDEX_DIR);

        if (env.hasProjects()) {
            Project p = Project.getProject(path);
            if (p == null) {
                return null;
            }
            indexDir = new File(indexDir, p.getPath());
View Full Code Here

     * @throws ClassNotFoundException if the class for the stored definitions
     * instance cannot be found
     */
    public static Definitions getDefinitions(File file)
            throws IOException, ParseException, ClassNotFoundException {
        RuntimeEnvironment env = RuntimeEnvironment.getInstance();
        String path = env.getPathRelativeToSourceRoot(file, 0);
        //sanitize windows path delimiters
        //in order not to conflict with Lucene escape character
        path=path.replace("\\", "/");

        IndexReader ireader = getIndexReader(path);
View Full Code Here

            // only increase the file IO...
            if (!xrefFile.getParentFile().mkdirs()) {
                assert xrefFile.getParentFile().exists();
            }

            RuntimeEnvironment env = RuntimeEnvironment.getInstance();

            boolean compressed = env.isCompressXref();
            File file = new File(xrefDir, path + (compressed ? ".gz" : ""));
            return new BufferedWriter(new OutputStreamWriter(
                    compressed ?
                        new GZIPOutputStream(new FileOutputStream(file)) :
                        new FileOutputStream(file)));
View Full Code Here

     * @throws java.io.IOException If an error occurs while reading the stream
     */
    @Override
    public void processStream(InputStream input) throws IOException {
        DateFormat df = repository.getDateFormat();
        RuntimeEnvironment env = RuntimeEnvironment.getInstance();

        BufferedReader in = new BufferedReader(new InputStreamReader(input));
        String s;

        HistoryEntry entry = null;
        int state = 0;
        while ((s = in.readLine()) != null) {
            if ("------------------------------------------------------------".equals(s)) {
                if (entry != null && state > 2) {
                    entries.add(entry);
                }
                entry = new HistoryEntry();
                entry.setActive(true);
                state = 0;
                continue;
            }

            switch (state) {
                case 0:
                    // First, go on until revno is found.
                    if (s.startsWith("revno:")) {
                        String rev[] = s.substring("revno:".length()).trim().split(" ");
                        entry.setRevision(rev[0]);
                        ++state;
                    }
                    break;
                case 1:
                    // Then, look for committer.
                    if (s.startsWith("committer:")) {
                        entry.setAuthor(s.substring("committer:".length()).trim());
                        ++state;
                    }
                    break;
                case 2:
                    // And then, look for timestamp.
                    if (s.startsWith("timestamp:")) {
                        try {
                            Date date = df.parse(s.substring("timestamp:".length()).trim());
                            entry.setDate(date);
                        } catch (ParseException e) {
                            OpenGrokLogger.getLogger().log(Level.WARNING,
                                    "Failed to parse history timestamp:" + s, e);
                        }
                        ++state;
                    }
                    break;
                case 3:
                    // Expect the commit message to follow immediately after
                    // the timestamp, and that everything up to the list of
                    // modified, added and removed files is part of the commit
                    // message.
                    if (s.startsWith("modified:") || s.startsWith("added:") || s.startsWith("removed:")) {
                        ++state;
                    } else if (s.startsWith("  ")) {
                        // Commit messages returned by bzr log -v are prefixed
                        // with two blanks.
                        entry.appendMessage(s.substring(2));
                    }
                    break;
                case 4:
                    // Finally, store the list of modified, added and removed
                    // files. (Except the labels.)
                    if (!(s.startsWith("modified:") || s.startsWith("added:") || s.startsWith("removed:"))) {
                        // The list of files is prefixed with blanks.
                        s = s.trim();

                        int idx = s.indexOf(" => ");
                        if (idx != -1) {
                            s = s.substring(idx + 4);
                        }

                        File f = new File(myDir, s);
                        String name = env.getPathRelativeToSourceRoot(f, 0);
                        entry.addFile(name);
                    }
                    break;
                default:
                    OpenGrokLogger.getLogger().warning("Unknown parser state: " + state);
View Full Code Here

            // we can recreate it from scratch.
            cache.clear(this);
        }

        // We need to refresh list of tags for incremental reindex.
        RuntimeEnvironment env = RuntimeEnvironment.getInstance();
        if (env.isTagsEnabled() && this.hasFileBasedTags()) {
            this.buildTagList(new File(this.directoryName));
        }

        if (history != null) {
            cache.store(history, this);
View Full Code Here

        QueryBuilder queryBuilder = createQueryBuilder();

        try {
            query = queryBuilder.build();
            if (query != null) {
                RuntimeEnvironment env = RuntimeEnvironment.getInstance();
                File root = new File(env.getDataRootFile(), IndexDatabase.INDEX_DIR);

                if (env.hasProjects()) {
                    // search all projects
                    //TODO support paging per project (in search.java)
                    //TODO optimize if only one project by falling back to SingleDatabase ?
                    searchMultiDatabase(env.getProjects(), false);
                } else {
                    // search the index database
                    searchSingleDatabase(root, true);
                }
            }
View Full Code Here

TOP

Related Classes of org.opensolaris.opengrok.configuration.RuntimeEnvironment

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.