@Override public void delete(Project project, Long buildId) { Environment env = getEnv(project.getId().toString()); Store store = getStore(env, PREV_COMMITS_STORE); env.executeInTransaction(new TransactionalExecutable() { @Override public void execute(Transaction txn) { store.delete(txn, new LongByteIterable(buildId)); } }); }
@Override public void visit(User user, Project project) { Environment env = getEnv(user.getId().toString()); Store store = getStore(env, PROJECT_VISIT_STORE); env.executeInTransaction(new TransactionalExecutable() { @Override public void execute(Transaction txn) { writeLong(store, txn, new LongByteIterable(project.getId()), System.currentTimeMillis()+1000L); } }); }
@Override public void visitPullRequestCodeComments(User user, PullRequest request) { Environment env = getEnv(request.getTargetProject().getId().toString()); Store store = getStore(env, PULL_REQUEST_CODE_COMMENTS_VISIT_STORE); env.executeInTransaction(new TransactionalExecutable() { @Override public void execute(Transaction txn) { long time = new DateTime().plusSeconds(1).getMillis(); writeLong(store, txn, new LongsByteIterable(Lists.newArrayList(user.getId(), request.getId())), time); } }); }
@Override public void setPullRequestNotified(User user, PullRequest request, boolean notified) { Environment env = getEnv(request.getTargetProject().getId().toString()); Store store = getStore(env, PULL_REQUEST_NOTIFICATION_STORE); env.executeInTransaction(new TransactionalExecutable() { @Override public void execute(Transaction txn) { writeBoolean(store, txn, new LongsByteIterable(Lists.newArrayList(user.getId(), request.getId())), notified); } }); }
@Override public void visitCodeComment(User user, CodeComment comment) { Environment env = getEnv(comment.getProject().getId().toString()); Store store = getStore(env, CODE_COMMENT_VISIT_STORE); env.executeInTransaction(new TransactionalExecutable() { @Override public void execute(Transaction txn) { long time = new DateTime().plusSeconds(1).getMillis(); writeLong(store, txn, new LongsByteIterable(Lists.newArrayList(user.getId(), comment.getId())), time); } }); }
@Override public void setIssueNotified(User user, Issue issue, boolean notified) { Environment env = getEnv(issue.getProject().getId().toString()); Store store = getStore(env, ISSUE_NOTIFICATION_STORE); env.executeInTransaction(new TransactionalExecutable() { @Override public void execute(Transaction txn) { writeBoolean(store, txn, new LongsByteIterable(Lists.newArrayList(user.getId(), issue.getId())), notified); } }); }
@Override public void putAll( final LocalDB.DB db, final Map<String, String> keyValueMap ) throws LocalDBException { checkStatus( true ); environment.executeInTransaction( transaction -> { final Store store = getStore( db ); for ( final Map.Entry<String, String> entry : keyValueMap.entrySet() ) { final ByteIterable k = bindMachine.keyToEntry( entry.getKey() ); final ByteIterable v = bindMachine.valueToEntry( entry.getValue() ); store.put( transaction, k, v ); } } ); outputLogExecutor.conditionallyExecuteTask(); }
@SuppressWarnings("CheckReturnValue") synchronized void executeInTransaction(final Runnable runnable) { this.environment.executeInTransaction( txn -> { try { IndexWriter indexWriter = this.createIndexWriter(this.directory, createIndexConfig(this.analyzer)); runnable.run(); } catch (IOException ex) { txn.abort(); throw new UncheckedIOException(ex); } finally { this.closeIndexSearcher(); this.closeIndexWriter(); } }); }
@Override public void visitIssue(User user, Issue issue) { Environment env = getEnv(issue.getProject().getId().toString()); Store store = getStore(env, ISSUE_VISIT_STORE); env.executeInTransaction(new TransactionalExecutable() { @Override public void execute(Transaction txn) { long time = new DateTime().plusSeconds(1).getMillis(); writeLong(store, txn, new LongsByteIterable(Lists.newArrayList(user.getId(), issue.getId())), time); } }); setIssueNotified(user, issue, false); }
@Override public void visitPullRequest(User user, PullRequest request) { Environment env = getEnv(request.getTargetProject().getId().toString()); Store store = getStore(env, PULL_REQUEST_VISIT_STORE); env.executeInTransaction(new TransactionalExecutable() { @Override public void execute(Transaction txn) { long time = new DateTime().plusSeconds(1).getMillis(); writeLong(store, txn, new LongsByteIterable(Lists.newArrayList(user.getId(), request.getId())), time); } }); setPullRequestNotified(user, request, false); }
@Override public void removeAll( final LocalDB.DB db, final Collection<String> keys ) throws LocalDBException { checkStatus( true ); environment.executeInTransaction( transaction -> { final Store store = getStore( db ); for ( final String key : keys ) { store.delete( transaction, bindMachine.keyToEntry( key ) ); } } ); }
environment.executeInTransaction( txn ->
env.executeInTransaction(new TransactionalExecutable() {
project, lastPullRequestUpdateId, BATCH_SIZE); for (PullRequestUpdate update: unprocessedPullRequestUpdates) { env.executeInTransaction(new TransactionalExecutable() { for (CodeComment comment: unprocessedCodeComments) { if (comment.isValid()) { env.executeInTransaction(new TransactionalExecutable() {
@Override public void truncate( final LocalDB.DB db ) throws LocalDBException { checkStatus( true ); { final long finalSize = this.size( db ); LOGGER.trace( () -> "begin truncate of " + db.toString() + ", size=" + finalSize ); } final Instant startDate = Instant.now(); environment.executeInTransaction( transaction -> { environment.truncateStore( db.toString(), transaction ); final Store newStoreReference = environment.openStore( db.toString(), StoreConfig.USE_EXISTING, transaction ); cachedStoreObjects.put( db, newStoreReference ); } ); { final long finalSize = this.size( db ); LOGGER.trace( () -> "completed truncate of " + db.toString() + " (" + TimeDuration.fromCurrent( startDate ).asCompactString() + ")" + ", size=" + finalSize ); } }
env.executeInTransaction(new TransactionalExecutable() { env.executeInTransaction(new TransactionalExecutable() {