Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove historycache entries automatically #1675

Merged
merged 10 commits into from
Jul 26, 2017

Conversation

vladak
Copy link
Member

@vladak vladak commented Jul 21, 2017

fixes #767

Also, done some semi-related code cleanup.

* Clear entry for single file from history cache.
* @param file path to the file
*/
void clearFile(String file);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why isn't this a File instead of a path?

Copy link
Member Author

@vladak vladak Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the path is relative to source root. It cannot be a File object because that would bypass HistoryGuru as a generic interface to concrete history cache backend (remember the days when OpenGrok supported JavaDB history cache next to File history cache).

Copy link
Contributor

@tulinkry tulinkry Jul 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, then maybe it could be mentioned in the javadoc that it is relative to the src

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment added

@@ -37,6 +38,9 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.opensolaris.opengrok.configuration.Project;
import org.opensolaris.opengrok.history.HistoryGuru;
import org.opensolaris.opengrok.history.RepositoryFactory;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import ordering is wrong in this case I think

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Netbeans does not complain however they should be better grouped.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird

@@ -45,22 +49,31 @@

private static TestRepository repository;

private final static String ctagsProperty = "org.opensolaris.opengrok.analysis.Ctags";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this declared somewhere else? Ctags or elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, it's defined in number of places throughout test/ directory. filed #1694

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect

@@ -629,9 +629,7 @@ public void createCache(Collection<String> repositories) {
public List<Repository> clearCache(Collection<String> repositories) throws HistoryException {
List<Repository> repos = getReposFromString(repositories);
HistoryCache cache = historyCache;
if (cache == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is not needed anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can't happen - the historyCache is created in HistoryGuru constructor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the constructor it is in an statement if (env.useHistoryCache()) {, is it ensured that this clearCache is not called when this is not in effect?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch; added bunch of useCache() calls.

* Clear entry for single file from history cache.
* @param file path to the file
*/
void clearFile(String file);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any kind of return value which could be useful for the caller in the future?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It mimicks the clear() interface. It just logs the error and goes on. The same thing is done for removal of xref files. It can be changed to boolean or int and just ignore the values in IndexDatabase#removeFile() however this seems unnecessary to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okey

private void checkDataExistence(String fileName, boolean shouldExist) {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();

for (String dirName : new String[]{"historycache", IndexDatabase.XREF_DIR}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FileHistoryCache.HISTORY_DIR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather keep it not exposed. Changing the field to protected does not help.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


// Remove the file and reindex using IndexDatabase directly.
File file = new File(repository.getSourceRoot(), projectName + File.separator + fileName);
file.delete();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertTrue(file.delete(), "file not deleted");

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like having actions done in asserts, makes the code less readable I think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@tulinkry tulinkry added this to the 1.1 milestone Jul 24, 2017
@tarzanek
Copy link
Contributor

feel free to merge, lgtm
(I hope this won't be too memory hungry)

@vladak
Copy link
Member Author

vladak commented Jul 26, 2017

As for "memory hungy" I bet you're referring to IndexDatabase#getFiles() however that is dead code and it is not called.

@tulinkry
Copy link
Contributor

ok to me now

@vladak vladak merged commit d3dbeac into oracle:master Jul 26, 2017
@vladak vladak deleted the remove_history_files branch July 10, 2018 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

remove history cache automatically
3 participants