Get project,ref,changekey without calling supplier
Instead of calling the Supplier<ChangeAttribute>.get for retrieving the change key and its project and ref, we can store the attributes when the event is created and avoid a lot of DB calls afterwards. Change-Id: I901fc67eef51967722e18443b72a88b475c112d5
This commit is contained in:
committed by
David Pursehouse
parent
92112508b3
commit
56b945d42b
@@ -394,7 +394,7 @@ public class ChangeHookRunner implements ChangeHooks, EventDispatcher,
|
|||||||
@Override
|
@Override
|
||||||
public void doPatchsetCreatedHook(Change change,
|
public void doPatchsetCreatedHook(Change change,
|
||||||
PatchSet patchSet, ReviewDb db) throws OrmException {
|
PatchSet patchSet, ReviewDb db) throws OrmException {
|
||||||
PatchSetCreatedEvent event = new PatchSetCreatedEvent();
|
PatchSetCreatedEvent event = new PatchSetCreatedEvent(change);
|
||||||
Supplier<AccountState> uploader =
|
Supplier<AccountState> uploader =
|
||||||
getAccountSupplier(patchSet.getUploader());
|
getAccountSupplier(patchSet.getUploader());
|
||||||
Supplier<AccountState> owner = getAccountSupplier(change.getOwner());
|
Supplier<AccountState> owner = getAccountSupplier(change.getOwner());
|
||||||
@@ -431,7 +431,7 @@ public class ChangeHookRunner implements ChangeHooks, EventDispatcher,
|
|||||||
@Override
|
@Override
|
||||||
public void doDraftPublishedHook(Change change, PatchSet patchSet,
|
public void doDraftPublishedHook(Change change, PatchSet patchSet,
|
||||||
ReviewDb db) throws OrmException {
|
ReviewDb db) throws OrmException {
|
||||||
DraftPublishedEvent event = new DraftPublishedEvent();
|
DraftPublishedEvent event = new DraftPublishedEvent(change);
|
||||||
Supplier<AccountState> uploader =
|
Supplier<AccountState> uploader =
|
||||||
getAccountSupplier(patchSet.getUploader());
|
getAccountSupplier(patchSet.getUploader());
|
||||||
Supplier<AccountState> owner = getAccountSupplier(change.getOwner());
|
Supplier<AccountState> owner = getAccountSupplier(change.getOwner());
|
||||||
@@ -467,7 +467,7 @@ public class ChangeHookRunner implements ChangeHooks, EventDispatcher,
|
|||||||
public void doCommentAddedHook(final Change change, Account account,
|
public void doCommentAddedHook(final Change change, Account account,
|
||||||
PatchSet patchSet, String comment, final Map<String, Short> approvals,
|
PatchSet patchSet, String comment, final Map<String, Short> approvals,
|
||||||
ReviewDb db) throws OrmException {
|
ReviewDb db) throws OrmException {
|
||||||
CommentAddedEvent event = new CommentAddedEvent();
|
CommentAddedEvent event = new CommentAddedEvent(change);
|
||||||
Supplier<AccountState> owner = getAccountSupplier(change.getOwner());
|
Supplier<AccountState> owner = getAccountSupplier(change.getOwner());
|
||||||
|
|
||||||
event.change = changeAttributeSupplier(change);
|
event.change = changeAttributeSupplier(change);
|
||||||
@@ -528,7 +528,7 @@ public class ChangeHookRunner implements ChangeHooks, EventDispatcher,
|
|||||||
public void doChangeMergedHook(Change change, Account account,
|
public void doChangeMergedHook(Change change, Account account,
|
||||||
PatchSet patchSet, ReviewDb db, String mergeResultRev)
|
PatchSet patchSet, ReviewDb db, String mergeResultRev)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
ChangeMergedEvent event = new ChangeMergedEvent();
|
ChangeMergedEvent event = new ChangeMergedEvent(change);
|
||||||
Supplier<AccountState> owner = getAccountSupplier(change.getOwner());
|
Supplier<AccountState> owner = getAccountSupplier(change.getOwner());
|
||||||
|
|
||||||
event.change = changeAttributeSupplier(change);
|
event.change = changeAttributeSupplier(change);
|
||||||
@@ -563,7 +563,7 @@ public class ChangeHookRunner implements ChangeHooks, EventDispatcher,
|
|||||||
public void doMergeFailedHook(Change change, Account account,
|
public void doMergeFailedHook(Change change, Account account,
|
||||||
PatchSet patchSet, String reason,
|
PatchSet patchSet, String reason,
|
||||||
ReviewDb db) throws OrmException {
|
ReviewDb db) throws OrmException {
|
||||||
MergeFailedEvent event = new MergeFailedEvent();
|
MergeFailedEvent event = new MergeFailedEvent(change);
|
||||||
Supplier<AccountState> owner = getAccountSupplier(change.getOwner());
|
Supplier<AccountState> owner = getAccountSupplier(change.getOwner());
|
||||||
|
|
||||||
event.change = changeAttributeSupplier(change);
|
event.change = changeAttributeSupplier(change);
|
||||||
@@ -598,7 +598,7 @@ public class ChangeHookRunner implements ChangeHooks, EventDispatcher,
|
|||||||
public void doChangeAbandonedHook(Change change, Account account,
|
public void doChangeAbandonedHook(Change change, Account account,
|
||||||
PatchSet patchSet, String reason, ReviewDb db)
|
PatchSet patchSet, String reason, ReviewDb db)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
ChangeAbandonedEvent event = new ChangeAbandonedEvent();
|
ChangeAbandonedEvent event = new ChangeAbandonedEvent(change);
|
||||||
AccountState owner = accountCache.get(change.getOwner());
|
AccountState owner = accountCache.get(change.getOwner());
|
||||||
|
|
||||||
event.change = changeAttributeSupplier(change);
|
event.change = changeAttributeSupplier(change);
|
||||||
@@ -633,7 +633,7 @@ public class ChangeHookRunner implements ChangeHooks, EventDispatcher,
|
|||||||
public void doChangeRestoredHook(Change change, Account account,
|
public void doChangeRestoredHook(Change change, Account account,
|
||||||
PatchSet patchSet, String reason, ReviewDb db)
|
PatchSet patchSet, String reason, ReviewDb db)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
ChangeRestoredEvent event = new ChangeRestoredEvent();
|
ChangeRestoredEvent event = new ChangeRestoredEvent(change);
|
||||||
AccountState owner = accountCache.get(change.getOwner());
|
AccountState owner = accountCache.get(change.getOwner());
|
||||||
|
|
||||||
event.change = changeAttributeSupplier(change);
|
event.change = changeAttributeSupplier(change);
|
||||||
@@ -709,7 +709,7 @@ public class ChangeHookRunner implements ChangeHooks, EventDispatcher,
|
|||||||
@Override
|
@Override
|
||||||
public void doReviewerAddedHook(Change change, Account account,
|
public void doReviewerAddedHook(Change change, Account account,
|
||||||
PatchSet patchSet, ReviewDb db) throws OrmException {
|
PatchSet patchSet, ReviewDb db) throws OrmException {
|
||||||
ReviewerAddedEvent event = new ReviewerAddedEvent();
|
ReviewerAddedEvent event = new ReviewerAddedEvent(change);
|
||||||
Supplier<AccountState> owner = getAccountSupplier(change.getOwner());
|
Supplier<AccountState> owner = getAccountSupplier(change.getOwner());
|
||||||
|
|
||||||
event.change = changeAttributeSupplier(change);
|
event.change = changeAttributeSupplier(change);
|
||||||
@@ -739,7 +739,7 @@ public class ChangeHookRunner implements ChangeHooks, EventDispatcher,
|
|||||||
public void doTopicChangedHook(Change change, Account account,
|
public void doTopicChangedHook(Change change, Account account,
|
||||||
String oldTopic, ReviewDb db)
|
String oldTopic, ReviewDb db)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
TopicChangedEvent event = new TopicChangedEvent();
|
TopicChangedEvent event = new TopicChangedEvent(change);
|
||||||
AccountState owner = accountCache.get(change.getOwner());
|
AccountState owner = accountCache.get(change.getOwner());
|
||||||
|
|
||||||
event.change = changeAttributeSupplier(change);
|
event.change = changeAttributeSupplier(change);
|
||||||
@@ -778,7 +778,7 @@ public class ChangeHookRunner implements ChangeHooks, EventDispatcher,
|
|||||||
public void doHashtagsChangedHook(Change change, Account account,
|
public void doHashtagsChangedHook(Change change, Account account,
|
||||||
Set<String> added, Set<String> removed, Set<String> hashtags, ReviewDb db)
|
Set<String> added, Set<String> removed, Set<String> hashtags, ReviewDb db)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
HashtagsChangedEvent event = new HashtagsChangedEvent();
|
HashtagsChangedEvent event = new HashtagsChangedEvent(change);
|
||||||
AccountState owner = accountCache.get(change.getOwner());
|
AccountState owner = accountCache.get(change.getOwner());
|
||||||
|
|
||||||
event.change = changeAttributeSupplier(change);
|
event.change = changeAttributeSupplier(change);
|
||||||
|
|||||||
@@ -15,13 +15,15 @@
|
|||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.data.AccountAttribute;
|
import com.google.gerrit.server.data.AccountAttribute;
|
||||||
|
|
||||||
public class ChangeAbandonedEvent extends PatchSetEvent {
|
public class ChangeAbandonedEvent extends PatchSetEvent {
|
||||||
|
static final String TYPE = "change-abandoned";
|
||||||
public Supplier<AccountAttribute> abandoner;
|
public Supplier<AccountAttribute> abandoner;
|
||||||
public String reason;
|
public String reason;
|
||||||
|
|
||||||
public ChangeAbandonedEvent() {
|
public ChangeAbandonedEvent(Change change) {
|
||||||
super("change-abandoned");
|
super(TYPE, change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,22 +22,28 @@ import com.google.gerrit.server.data.ChangeAttribute;
|
|||||||
|
|
||||||
public abstract class ChangeEvent extends RefEvent {
|
public abstract class ChangeEvent extends RefEvent {
|
||||||
public Supplier<ChangeAttribute> change;
|
public Supplier<ChangeAttribute> change;
|
||||||
|
public Project.NameKey projectNameKey;
|
||||||
|
public String refName;
|
||||||
|
public Change.Key changeKey;
|
||||||
|
|
||||||
protected ChangeEvent(String type) {
|
protected ChangeEvent(String type, Change change) {
|
||||||
super(type);
|
super(type);
|
||||||
|
this.projectNameKey = change.getProject();
|
||||||
|
this.refName = RefNames.fullName(change.getDest().get());
|
||||||
|
this.changeKey = change.getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Project.NameKey getProjectNameKey() {
|
public Project.NameKey getProjectNameKey() {
|
||||||
return new Project.NameKey(change.get().project);
|
return projectNameKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRefName() {
|
public String getRefName() {
|
||||||
return RefNames.fullName(change.get().branch);
|
return refName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Change.Key getChangeKey() {
|
public Change.Key getChangeKey() {
|
||||||
return new Change.Key(change.get().id);
|
return changeKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,15 @@
|
|||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.data.AccountAttribute;
|
import com.google.gerrit.server.data.AccountAttribute;
|
||||||
|
|
||||||
public class ChangeMergedEvent extends PatchSetEvent {
|
public class ChangeMergedEvent extends PatchSetEvent {
|
||||||
|
static final String TYPE = "change-merged";
|
||||||
public Supplier<AccountAttribute> submitter;
|
public Supplier<AccountAttribute> submitter;
|
||||||
public String newRev;
|
public String newRev;
|
||||||
|
|
||||||
public ChangeMergedEvent() {
|
public ChangeMergedEvent(Change change) {
|
||||||
super("change-merged");
|
super(TYPE, change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,15 @@
|
|||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.data.AccountAttribute;
|
import com.google.gerrit.server.data.AccountAttribute;
|
||||||
|
|
||||||
public class ChangeRestoredEvent extends PatchSetEvent {
|
public class ChangeRestoredEvent extends PatchSetEvent {
|
||||||
|
static final String TYPE = "change-restored";
|
||||||
public Supplier<AccountAttribute> restorer;
|
public Supplier<AccountAttribute> restorer;
|
||||||
public String reason;
|
public String reason;
|
||||||
|
|
||||||
public ChangeRestoredEvent () {
|
public ChangeRestoredEvent (Change change) {
|
||||||
super("change-restored");
|
super(TYPE, change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,15 +15,17 @@
|
|||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.data.AccountAttribute;
|
import com.google.gerrit.server.data.AccountAttribute;
|
||||||
import com.google.gerrit.server.data.ApprovalAttribute;
|
import com.google.gerrit.server.data.ApprovalAttribute;
|
||||||
|
|
||||||
public class CommentAddedEvent extends PatchSetEvent {
|
public class CommentAddedEvent extends PatchSetEvent {
|
||||||
|
static final String TYPE = "comment-added";
|
||||||
public Supplier<AccountAttribute> author;
|
public Supplier<AccountAttribute> author;
|
||||||
public Supplier<ApprovalAttribute[]> approvals;
|
public Supplier<ApprovalAttribute[]> approvals;
|
||||||
public String comment;
|
public String comment;
|
||||||
|
|
||||||
public CommentAddedEvent() {
|
public CommentAddedEvent(Change change) {
|
||||||
super("comment-added");
|
super(TYPE, change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
|
|||||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||||
|
|
||||||
public class CommitReceivedEvent extends RefEvent {
|
public class CommitReceivedEvent extends RefEvent {
|
||||||
|
static final String TYPE = "commit-received";
|
||||||
public ReceiveCommand command;
|
public ReceiveCommand command;
|
||||||
public Project project;
|
public Project project;
|
||||||
public String refName;
|
public String refName;
|
||||||
@@ -28,7 +29,7 @@ public class CommitReceivedEvent extends RefEvent {
|
|||||||
public IdentifiedUser user;
|
public IdentifiedUser user;
|
||||||
|
|
||||||
public CommitReceivedEvent() {
|
public CommitReceivedEvent() {
|
||||||
super("commit-received");
|
super(TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommitReceivedEvent(ReceiveCommand command, Project project,
|
public CommitReceivedEvent(ReceiveCommand command, Project project,
|
||||||
|
|||||||
@@ -15,12 +15,14 @@
|
|||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.data.AccountAttribute;
|
import com.google.gerrit.server.data.AccountAttribute;
|
||||||
|
|
||||||
public class DraftPublishedEvent extends PatchSetEvent {
|
public class DraftPublishedEvent extends PatchSetEvent {
|
||||||
|
static final String TYPE = "draft-published";
|
||||||
public Supplier<AccountAttribute> uploader;
|
public Supplier<AccountAttribute> uploader;
|
||||||
|
|
||||||
public DraftPublishedEvent() {
|
public DraftPublishedEvent(Change change) {
|
||||||
super("draft-published");
|
super(TYPE, change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,30 +22,31 @@ public class EventTypes {
|
|||||||
private static final Map<String, Class<?>> typesByString = new HashMap<>();
|
private static final Map<String, Class<?>> typesByString = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
registerClass(new ChangeAbandonedEvent());
|
register(ChangeAbandonedEvent.TYPE, ChangeAbandonedEvent.class);
|
||||||
registerClass(new ChangeMergedEvent());
|
register(ChangeMergedEvent.TYPE, ChangeMergedEvent.class);
|
||||||
registerClass(new ChangeRestoredEvent());
|
register(ChangeRestoredEvent.TYPE, ChangeRestoredEvent.class);
|
||||||
registerClass(new CommentAddedEvent());
|
register(CommentAddedEvent.TYPE, CommentAddedEvent.class);
|
||||||
registerClass(new CommitReceivedEvent());
|
register(CommitReceivedEvent.TYPE, CommitReceivedEvent.class);
|
||||||
registerClass(new DraftPublishedEvent());
|
register(DraftPublishedEvent.TYPE, DraftPublishedEvent.class);
|
||||||
registerClass(new HashtagsChangedEvent());
|
register(HashtagsChangedEvent.TYPE, HashtagsChangedEvent.class);
|
||||||
registerClass(new MergeFailedEvent());
|
register(MergeFailedEvent.TYPE, MergeFailedEvent.class);
|
||||||
registerClass(new RefUpdatedEvent());
|
register(RefUpdatedEvent.TYPE, RefUpdatedEvent.class);
|
||||||
registerClass(new RefReceivedEvent());
|
register(RefReceivedEvent.TYPE, RefReceivedEvent.class);
|
||||||
registerClass(new ReviewerAddedEvent());
|
register(ReviewerAddedEvent.TYPE, ReviewerAddedEvent.class);
|
||||||
registerClass(new PatchSetCreatedEvent());
|
register(PatchSetCreatedEvent.TYPE, PatchSetCreatedEvent.class);
|
||||||
registerClass(new TopicChangedEvent());
|
register(TopicChangedEvent.TYPE, TopicChangedEvent.class);
|
||||||
registerClass(new ProjectCreatedEvent());
|
register(ProjectCreatedEvent.TYPE, ProjectCreatedEvent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Register an event.
|
/**
|
||||||
|
* Register an event type and associated class.
|
||||||
*
|
*
|
||||||
* @param event The event to register.
|
* @param eventType The event type to register.
|
||||||
* registered.
|
* @param eventClass The event class to register.
|
||||||
**/
|
**/
|
||||||
public static void registerClass(Event event) {
|
public static void register(String eventType,
|
||||||
String type = event.getType();
|
Class<? extends Event> eventClass) {
|
||||||
typesByString.put(type, event.getClass());
|
typesByString.put(eventType, eventClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the class for an event type.
|
/** Get the class for an event type.
|
||||||
|
|||||||
@@ -15,15 +15,17 @@
|
|||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.data.AccountAttribute;
|
import com.google.gerrit.server.data.AccountAttribute;
|
||||||
|
|
||||||
public class HashtagsChangedEvent extends ChangeEvent {
|
public class HashtagsChangedEvent extends ChangeEvent {
|
||||||
|
static final String TYPE = "hashtags-changed";
|
||||||
public Supplier<AccountAttribute> editor;
|
public Supplier<AccountAttribute> editor;
|
||||||
public String[] added;
|
public String[] added;
|
||||||
public String[] removed;
|
public String[] removed;
|
||||||
public String[] hashtags;
|
public String[] hashtags;
|
||||||
|
|
||||||
public HashtagsChangedEvent () {
|
public HashtagsChangedEvent (Change change) {
|
||||||
super("hashtags-changed");
|
super(TYPE, change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,13 +15,15 @@
|
|||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.data.AccountAttribute;
|
import com.google.gerrit.server.data.AccountAttribute;
|
||||||
|
|
||||||
public class MergeFailedEvent extends PatchSetEvent {
|
public class MergeFailedEvent extends PatchSetEvent {
|
||||||
|
static final String TYPE = "merge-failed";
|
||||||
public Supplier<AccountAttribute> submitter;
|
public Supplier<AccountAttribute> submitter;
|
||||||
public String reason;
|
public String reason;
|
||||||
|
|
||||||
public MergeFailedEvent() {
|
public MergeFailedEvent(Change change) {
|
||||||
super("merge-failed");
|
super(TYPE, change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,14 @@
|
|||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.data.AccountAttribute;
|
import com.google.gerrit.server.data.AccountAttribute;
|
||||||
|
|
||||||
public class PatchSetCreatedEvent extends PatchSetEvent {
|
public class PatchSetCreatedEvent extends PatchSetEvent {
|
||||||
|
static final String TYPE = "patchset-created";
|
||||||
public Supplier<AccountAttribute> uploader;
|
public Supplier<AccountAttribute> uploader;
|
||||||
|
|
||||||
public PatchSetCreatedEvent() {
|
public PatchSetCreatedEvent(Change change) {
|
||||||
super("patchset-created");
|
super(TYPE, change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,13 @@
|
|||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.data.PatchSetAttribute;
|
import com.google.gerrit.server.data.PatchSetAttribute;
|
||||||
|
|
||||||
public class PatchSetEvent extends ChangeEvent {
|
public class PatchSetEvent extends ChangeEvent {
|
||||||
public Supplier<PatchSetAttribute> patchSet;
|
public Supplier<PatchSetAttribute> patchSet;
|
||||||
|
|
||||||
protected PatchSetEvent(String type) {
|
protected PatchSetEvent(String type, Change change) {
|
||||||
super(type);
|
super(type, change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,12 @@ package com.google.gerrit.server.events;
|
|||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
|
|
||||||
public class ProjectCreatedEvent extends ProjectEvent {
|
public class ProjectCreatedEvent extends ProjectEvent {
|
||||||
|
static final String TYPE = "project-created";
|
||||||
public String projectName;
|
public String projectName;
|
||||||
public String headName;
|
public String headName;
|
||||||
|
|
||||||
public ProjectCreatedEvent() {
|
public ProjectCreatedEvent() {
|
||||||
super("project-created");
|
super(TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -19,12 +19,13 @@ import com.google.gerrit.server.IdentifiedUser;
|
|||||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||||
|
|
||||||
public class RefReceivedEvent extends RefEvent {
|
public class RefReceivedEvent extends RefEvent {
|
||||||
|
static final String TYPE = "ref-received";
|
||||||
public ReceiveCommand command;
|
public ReceiveCommand command;
|
||||||
public Project project;
|
public Project project;
|
||||||
public IdentifiedUser user;
|
public IdentifiedUser user;
|
||||||
|
|
||||||
public RefReceivedEvent() {
|
public RefReceivedEvent() {
|
||||||
super("ref-received");
|
super(TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ import com.google.gerrit.server.data.AccountAttribute;
|
|||||||
import com.google.gerrit.server.data.RefUpdateAttribute;
|
import com.google.gerrit.server.data.RefUpdateAttribute;
|
||||||
|
|
||||||
public class RefUpdatedEvent extends RefEvent {
|
public class RefUpdatedEvent extends RefEvent {
|
||||||
|
static final String TYPE = "ref-updated";
|
||||||
public Supplier<AccountAttribute> submitter;
|
public Supplier<AccountAttribute> submitter;
|
||||||
public Supplier<RefUpdateAttribute> refUpdate;
|
public Supplier<RefUpdateAttribute> refUpdate;
|
||||||
|
|
||||||
public RefUpdatedEvent() {
|
public RefUpdatedEvent() {
|
||||||
super("ref-updated");
|
super(TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -15,12 +15,14 @@
|
|||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.data.AccountAttribute;
|
import com.google.gerrit.server.data.AccountAttribute;
|
||||||
|
|
||||||
public class ReviewerAddedEvent extends PatchSetEvent {
|
public class ReviewerAddedEvent extends PatchSetEvent {
|
||||||
|
static final String TYPE = "reviewer-added";
|
||||||
public Supplier<AccountAttribute> reviewer;
|
public Supplier<AccountAttribute> reviewer;
|
||||||
|
|
||||||
public ReviewerAddedEvent() {
|
public ReviewerAddedEvent(Change change) {
|
||||||
super("reviewer-added");
|
super(TYPE, change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,15 @@
|
|||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.data.AccountAttribute;
|
import com.google.gerrit.server.data.AccountAttribute;
|
||||||
|
|
||||||
public class TopicChangedEvent extends ChangeEvent {
|
public class TopicChangedEvent extends ChangeEvent {
|
||||||
|
static final String TYPE = "topic-changed";
|
||||||
public Supplier<AccountAttribute> changer;
|
public Supplier<AccountAttribute> changer;
|
||||||
public String oldTopic;
|
public String oldTopic;
|
||||||
|
|
||||||
public TopicChangedEvent() {
|
public TopicChangedEvent(Change change) {
|
||||||
super("topic-changed");
|
super(TYPE, change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,14 @@ import org.junit.Test;
|
|||||||
|
|
||||||
public class EventTypesTest {
|
public class EventTypesTest {
|
||||||
public static class TestEvent extends Event {
|
public static class TestEvent extends Event {
|
||||||
|
private static final String TYPE = "test-event";
|
||||||
public TestEvent() {
|
public TestEvent() {
|
||||||
super("test-event");
|
super(TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AnotherTestEvent extends Event {
|
public static class AnotherTestEvent extends Event {
|
||||||
|
private static final String TYPE = "another-test-event";
|
||||||
public AnotherTestEvent() {
|
public AnotherTestEvent() {
|
||||||
super("another-test-event");
|
super("another-test-event");
|
||||||
}
|
}
|
||||||
@@ -33,10 +35,10 @@ public class EventTypesTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEventTypeRegistration() {
|
public void testEventTypeRegistration() {
|
||||||
EventTypes.registerClass(new TestEvent());
|
EventTypes.register(TestEvent.TYPE, TestEvent.class);
|
||||||
EventTypes.registerClass(new AnotherTestEvent());
|
EventTypes.register(AnotherTestEvent.TYPE, AnotherTestEvent.class);
|
||||||
assertThat(EventTypes.getClass("test-event")).isEqualTo(TestEvent.class);
|
assertThat(EventTypes.getClass(TestEvent.TYPE)).isEqualTo(TestEvent.class);
|
||||||
assertThat(EventTypes.getClass("another-test-event"))
|
assertThat(EventTypes.getClass(AnotherTestEvent.TYPE))
|
||||||
.isEqualTo(AnotherTestEvent.class);
|
.isEqualTo(AnotherTestEvent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,15 +80,14 @@ final class StreamEvents extends BaseCommand {
|
|||||||
|
|
||||||
/** Special event to notify clients they missed other events. */
|
/** Special event to notify clients they missed other events. */
|
||||||
private static final class DroppedOutputEvent extends Event {
|
private static final class DroppedOutputEvent extends Event {
|
||||||
|
private final static String TYPE = "dropped-output";
|
||||||
public DroppedOutputEvent() {
|
public DroppedOutputEvent() {
|
||||||
super("dropped-output");
|
super(TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final DroppedOutputEvent droppedOutputEvent = new DroppedOutputEvent();
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
EventTypes.registerClass(droppedOutputEvent);
|
EventTypes.register(DroppedOutputEvent.TYPE, DroppedOutputEvent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final EventListener listener = new EventListener() {
|
private final EventListener listener = new EventListener() {
|
||||||
@@ -118,7 +117,7 @@ final class StreamEvents extends BaseCommand {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** True if {@link #droppedOutputEvent} needs to be sent. */
|
/** True if {@link DroppedOutputEvent} needs to be sent. */
|
||||||
private volatile boolean dropped;
|
private volatile boolean dropped;
|
||||||
|
|
||||||
/** Lock to protect {@link #queue}, {@link #task}, {@link #done}. */
|
/** Lock to protect {@link #queue}, {@link #task}, {@link #done}. */
|
||||||
@@ -229,7 +228,7 @@ final class StreamEvents extends BaseCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dropped) {
|
if (dropped) {
|
||||||
write(droppedOutputEvent);
|
write(new DroppedOutputEvent());
|
||||||
dropped = false;
|
dropped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Submodule plugins/replication updated: e4aa03008f...6a83ff45bb
Reference in New Issue
Block a user