mooli tayer has posted comments on this change. Change subject: tools: notifier - simple first match include/exclude. ......................................................................
Patch Set 2: (7 comments) http://gerrit.ovirt.org/#/c/24018/2/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/NotificationService.java File backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/NotificationService.java: Line 85: deleteObsoleteHistoryData(); Line 86: log.debug("Finished event notification service iteration"); Line 87: } catch (Throwable t) { Line 88: log.error("Exception while querying for notifications.", t); Line 89: if (t instanceof SQLException) { > or: I'm not sure what you meant. I can do: catch (SQLException e) { distributeDbDownEvent(); log.error(String.format("Failed to run the service."), ); } catch (Exception e) { if (!Thread.interrupted()) { log.error(String.format("Failed to run the service."), e); } } Line 90: distributeDbDownEvent(); Line 91: } Line 92: if (!Thread.interrupted()) { Line 93: log.error(String.format("Failed to run the service."), t); http://gerrit.ovirt.org/#/c/24018/2/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/filter/FilterEntry.java File backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/filter/FilterEntry.java: Line 12: Line 13: private FilterEntry(String eventName, boolean exclude, String transportCandidate, String address) { Line 14: this.eventName = eventName; Line 15: this.exclude = exclude; Line 16: this.transportCandidate = transportCandidate; > it is the transport of the recipient... for the recipient this is the trans It does't matter that transport is per recipient. What I am saying is that at this time it is simply a string we read from configuration and can be anything. this is why I want to mark it as such. Line 17: this.address = address; Line 18: } Line 19: Line 20: public static FilterEntry createEntryFromRecipient( Line 13: private FilterEntry(String eventName, boolean exclude, String transportCandidate, String address) { Line 14: this.eventName = eventName; Line 15: this.exclude = exclude; Line 16: this.transportCandidate = transportCandidate; Line 17: this.address = address; > this is also wrong, using address... most will not use address, but some na see my comment on FirstMatchSimpleFilter line 71. FROM NOW ON we will only have recipient=name & transport/transportCandidate Line 18: } Line 19: Line 20: public static FilterEntry createEntryFromRecipient( Line 21: String eventName, Line 16: this.transportCandidate = transportCandidate; Line 17: this.address = address; Line 18: } Line 19: Line 20: public static FilterEntry createEntryFromRecipient( > I revised this in my last source I sent, please sync. Done Line 21: String eventName, Line 22: boolean exclude, Line 23: String recipient) { Line 24: if ("*".equals(eventName)) { http://gerrit.ovirt.org/#/c/24018/2/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/filter/FirstMatchSimpleFilter.java File backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/filter/FirstMatchSimpleFilter.java: Line 84: log.debug(String.format("parse: handling '%s'", m.group(0))); Line 85: boolean exclude = "exclude".equals(m.group("exclude")); Line 86: String event = m.group("event"); Line 87: String recipient = m.group("recipient"); Line 88: ret.add(FilterEntry.createEntryFromRecipient(event, exclude, recipient)); > the '*' is part of parsing, not part of class interface, please move it bac What I don't get I why this is part of the class: recipient.split(":", 2); ... Yes the * logic is not. The best solution to me would be to have a static factory method inside the class with a clear name, something like: public FilterEntry createFromConfigurationString(...) Line 89: } Line 90: return ret; Line 91: } http://gerrit.ovirt.org/#/c/24018/2/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/transport/mail/SMTP.java File backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/transport/mail/SMTP.java: Line 84: try { Line 85: mailSender.send(address, message.getMessageSubject(), message.getMessageBody()); Line 86: setChanged(); Line 87: notifyObservers(DispatchData.success(event, address, EventNotificationMethod.EMAIL)); Line 88: return; > whatever makes flow consistent... one entry two leave (normal, exception). Done Line 89: } catch (MessagingException ex) { Line 90: errorMessage = ex.getMessage(); Line 91: } Line 92: http://gerrit.ovirt.org/#/c/24018/2/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/NotificationProperties.java File backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/NotificationProperties.java: Line 224: if (!StringUtils.isEmpty(filter)) { Line 225: String[] filterElements = filter.split("\\s+"); Line 226: for (String filterElement : filterElements) { Line 227: if (!StringUtils.isEmpty(filterElement)) { Line 228: if (!FILTER_ELEMENT_PATTERN.matcher(filterElement).matches()) { > please use the class to parse and validate, do not create duplication. If I do validation here and I do not duplicate pattern, and I allow wrong transports is it ok? Line 229: throw new IllegalArgumentException( Line 230: String.format("%s Illegal value for %s , (%s)", Line 231: GENERIC_MESSAGE, Line 232: FILTER, -- To view, visit http://gerrit.ovirt.org/24018 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ia0b94ee8665ff8030b36b463207e50beea44b47d Gerrit-PatchSet: 2 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: mooli tayer <mta...@redhat.com> Gerrit-Reviewer: Alon Bar-Lev <alo...@redhat.com> Gerrit-Reviewer: Barak Azulay <bazu...@redhat.com> Gerrit-Reviewer: Martin Peřina <mper...@redhat.com> Gerrit-Reviewer: Yair Zaslavsky <yzasl...@redhat.com> Gerrit-Reviewer: mooli tayer <mta...@redhat.com> Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches