ChangeIndexedListener: pass project name information
Pass the project name associated to every change reindexed. This is key to achieve NoteDb compatiblity where the change is stored into the project repository. This is a mandatory change to make any plugin dealing with indexed events working properly with NoteDb. Bug: Issue 8931 Change-Id: I84086b72a49ff6e8fdb6e2ed473ce231ea12f358
This commit is contained in:
committed by
Hugo Arès
parent
918cb4fdb2
commit
97d3dc6593
@@ -3773,7 +3773,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
private final AtomicLongMap<Integer> countsByChange = AtomicLongMap.create();
|
||||
|
||||
@Override
|
||||
public void onChangeIndexed(int id) {
|
||||
public void onChangeIndexed(String projectName, int id) {
|
||||
countsByChange.incrementAndGet(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,13 @@ import com.google.gerrit.extensions.annotations.ExtensionPoint;
|
||||
/** Notified whenever a change is indexed or deleted from the index. */
|
||||
@ExtensionPoint
|
||||
public interface ChangeIndexedListener {
|
||||
/** Invoked when a change is indexed. */
|
||||
void onChangeIndexed(int id);
|
||||
/**
|
||||
* Invoked when a change is indexed.
|
||||
*
|
||||
* @param projectName project containing the change
|
||||
* @param id indexed change id
|
||||
*/
|
||||
void onChangeIndexed(String projectName, int id);
|
||||
|
||||
/** Invoked when a change is deleted from the index. */
|
||||
void onChangeDeleted(int id);
|
||||
|
||||
@@ -206,7 +206,7 @@ public class ChangeIndexer {
|
||||
for (Index<?, ChangeData> i : getWriteIndexes()) {
|
||||
i.replace(cd);
|
||||
}
|
||||
fireChangeIndexedEvent(cd.getId().get());
|
||||
fireChangeIndexedEvent(cd.project().get(), cd.getId().get());
|
||||
|
||||
// Always double-check whether the change might be stale immediately after
|
||||
// interactively indexing it. This fixes up the case where two writers write
|
||||
@@ -229,10 +229,10 @@ public class ChangeIndexer {
|
||||
autoReindexIfStale(cd);
|
||||
}
|
||||
|
||||
private void fireChangeIndexedEvent(int id) {
|
||||
private void fireChangeIndexedEvent(String projectName, int id) {
|
||||
for (ChangeIndexedListener listener : indexedListeners) {
|
||||
try {
|
||||
listener.onChangeIndexed(id);
|
||||
listener.onChangeIndexed(projectName, id);
|
||||
} catch (Exception e) {
|
||||
logEventListenerError(listener, e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user