Liran Zelkha has posted comments on this change.

Change subject: tools: required changes in events data mapping.
......................................................................


Patch Set 5:

(9 comments)

http://gerrit.ovirt.org/#/c/23107/5/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLogEvent.java
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLogEvent.java:

Line 4: import org.ovirt.engine.core.compat.Guid;
Line 5: 
Line 6: import java.util.Date;
Line 7: 
Line 8: public class AuditLogEvent {
Usually our business entities extends IVdcQueryable and implements 
BusinessEntity<Guid>
Line 9: 
Line 10:     private long id;
Line 11: 
Line 12:     private String logTypeName;


http://gerrit.ovirt.org/#/c/23107/5/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLogEventSubscriber.java
File 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLogEventSubscriber.java:

Line 4: import org.ovirt.engine.core.compat.Guid;
Line 5: 
Line 6: import java.io.Serializable;
Line 7: 
Line 8: public class AuditLogEventSubscriber implements Serializable, 
EventFilter {
Usually our business entities extends IVdcQueryable and implements 
BusinessEntity<Guid>
Line 9: 
Line 10:     private EventNotificationMethod eventNotificationMethod;
Line 11: 
Line 12:     private String methodAddress;


http://gerrit.ovirt.org/#/c/23107/5/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/NotificationServiceException.java
File 
backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/NotificationServiceException.java:

Line 2: 
Line 3: /**
Line 4:  * An exception of the notification service
Line 5:  */
Line 6: public class NotificationServiceException extends RuntimeException {
Why RuntimeException?
Line 7: 
Line 8:     private static final long serialVersionUID = 1L;
Line 9: 
Line 10:     public NotificationServiceException(String message) {


http://gerrit.ovirt.org/#/c/23107/5/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/dao/EventsManager.java
File 
backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/dao/EventsManager.java:

Line 27: import java.util.List;
Line 28: 
Line 29: public class EventsManager {
Line 30: 
Line 31:     DataSource ds;
private
Line 32: 
Line 33:     public EventsManager() throws NotificationServiceException {
Line 34:         try {
Line 35:             ds = new StandaloneDataSource();


Line 35:             ds = new StandaloneDataSource();
Line 36:         } catch (SQLException e) {
Line 37:             throw new NotificationServiceException("Failed to obtain 
database connectivity", e);
Line 38:         }
Line 39:     }
I understand this is a standalone tool - but can you still use our dal 
infrastructure?
Line 40: 
Line 41:     public List<AuditLogEventSubscriber> getAuditLogEventSubscribers() 
{
Line 42:         Connection connection = null;
Line 43:         PreparedStatement ps = null;


Line 51:                             "       event_subscriber.method_address, 
event_subscriber.notification_method, " +
Line 52:                             "       event_map.event_down_name, 
users.username " +
Line 53:                             "FROM event_subscriber " +
Line 54:                             "INNER JOIN event_map USING ( 
event_up_name ) " +
Line 55:                             "INNER JOIN users ON 
event_subscriber.subscriber_id = users.user_id;");
You can create a view for that
Line 56: 
Line 57:             rs = ps.executeQuery();
Line 58:             while (rs.next()) {
Line 59:                 
eventSubscribers.add(extractAuditLogEventSubscriber(rs));


Line 77:             ResultSet rs = null;
Line 78:             try {
Line 79:                 connection = ds.getConnection();
Line 80:                 ps =
Line 81:                         connection.prepareStatement("" +
We usually have views for these types of queries
Line 82:                                 "SELECT al.audit_log_id, 
al.log_type_name, " +
Line 83:                                 "       em_up.event_up_name, 
em_down.event_down_name," +
Line 84:                                 "       al.user_id, al.user_name, " +
Line 85:                                 "       al.vm_id, al.vm_name, 
al.vm_template_id, al.vm_template_name, " +


http://gerrit.ovirt.org/#/c/23107/5/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/sender/mail/EventMailSender.java
File 
backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/utils/sender/mail/EventMailSender.java:

Line 59:         if (StringUtils.isEmpty(recipient)) {
Line 60:             log.error("Email recipient is not known, please check user 
table ( email )" +
Line 61:                     " or event_subscriber ( method_address )," +
Line 62:                     " unable to send email for subscriber " + 
subscriber.getSubscriberId() + "," +
Line 63:                     " message was " + message.getMessageSubject() + 
":" + message.getMessageBody());
String.format?
Line 64:             result.setSent(false);
Line 65:             return result;
Line 66:         }
Line 67:         log.info(String.format("Send email to [%s]%n subject:%n [%s]",


Line 80:             shouldRetry = true;
Line 81:         }
Line 82: 
Line 83:         // Attempt additional 3 retries in case of failure
Line 84:         for (int i = 0; i < 3 && shouldRetry; ++i) {
3 - configuration?
Line 85:             shouldRetry = false;
Line 86:             try {
Line 87:                 // hold the next send attempt for 30 seconds in case 
of a busy mail server
Line 88:                 Thread.sleep(30000);


-- 
To view, visit http://gerrit.ovirt.org/23107
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I3350d1c1caa6d730a3c7916ee0581f1aaa4a582a
Gerrit-PatchSet: 5
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: mooli tayer <[email protected]>
Gerrit-Reviewer: Liran Zelkha <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to