Search in sources :

Example 1 with NotificationServiceException

use of org.ovirt.engine.core.notifier.NotificationServiceException in project ovirt-engine by oVirt.

the class EventsManager method markOldEventsAsProcessed.

public void markOldEventsAsProcessed(int daysToSendOnStartup) {
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DATE, -daysToSendOnStartup);
    Timestamp ts = new Timestamp(calendar.getTimeInMillis());
    int updatedRecords;
    try (Connection connection = ds.getConnection();
        PreparedStatement statement = connection.prepareStatement("UPDATE audit_log " + "SET  processed = 'true' " + "WHERE processed = 'false' AND log_time < ? ;")) {
        statement.setTimestamp(1, ts);
        updatedRecords = statement.executeUpdate();
        if (updatedRecords > 0) {
            log.debug("{} old records were marked as processed in the \"audit_log\" table.", updatedRecords);
        }
    } catch (SQLException e) {
        throw new NotificationServiceException("Failed mark old events as processed.", e);
    }
}
Also used : NotificationServiceException(org.ovirt.engine.core.notifier.NotificationServiceException) SQLException(java.sql.SQLException) Calendar(java.util.Calendar) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) Timestamp(java.sql.Timestamp)

Example 2 with NotificationServiceException

use of org.ovirt.engine.core.notifier.NotificationServiceException in project ovirt-engine by oVirt.

the class Snmp method createSnmp3.

private org.snmp4j.Snmp createSnmp3(Profile profile) {
    try {
        TransportMapping<?> transport = new DefaultUdpTransportMapping();
        org.snmp4j.Snmp snmp = new org.snmp4j.Snmp(transport);
        SecurityProtocols securityProtocols = SecurityProtocols.getInstance();
        securityProtocols.addDefaultProtocols();
        securityProtocols.addAuthenticationProtocol(new AuthMD5());
        securityProtocols.addAuthenticationProtocol(new AuthSHA());
        securityProtocols.addPrivacyProtocol(new PrivAES128());
        securityProtocols.addPrivacyProtocol(new PrivAES192());
        securityProtocols.addPrivacyProtocol(new PrivAES256());
        USM usm = new USM(securityProtocols, profile.engineId, 0);
        ((org.snmp4j.mp.MPv3) snmp.getMessageProcessingModel(org.snmp4j.mp.MPv3.ID)).setLocalEngineID(profile.engineId.getValue());
        ((org.snmp4j.mp.MPv3) snmp.getMessageProcessingModel(org.snmp4j.mp.MPv3.ID)).getSecurityModels().addSecurityModel(usm);
        SecurityModels.getInstance().addSecurityModel(usm);
        transport.listen();
        snmp.getUSM().addUser(profile.username, getUsmUser(profile));
        return snmp;
    } catch (IOException e) {
        throw new NotificationServiceException("error creating version 3 snmp " + getClass().getName());
    }
}
Also used : NotificationServiceException(org.ovirt.engine.core.notifier.NotificationServiceException) SecurityProtocols(org.snmp4j.security.SecurityProtocols) DefaultUdpTransportMapping(org.snmp4j.transport.DefaultUdpTransportMapping) AuthSHA(org.snmp4j.security.AuthSHA) IOException(java.io.IOException) USM(org.snmp4j.security.USM) PrivAES192(org.snmp4j.security.PrivAES192) PrivAES128(org.snmp4j.security.PrivAES128) PrivAES256(org.snmp4j.security.PrivAES256) AuthMD5(org.snmp4j.security.AuthMD5)

Aggregations

NotificationServiceException (org.ovirt.engine.core.notifier.NotificationServiceException)2 IOException (java.io.IOException)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1 Timestamp (java.sql.Timestamp)1 Calendar (java.util.Calendar)1 AuthMD5 (org.snmp4j.security.AuthMD5)1 AuthSHA (org.snmp4j.security.AuthSHA)1 PrivAES128 (org.snmp4j.security.PrivAES128)1 PrivAES192 (org.snmp4j.security.PrivAES192)1 PrivAES256 (org.snmp4j.security.PrivAES256)1 SecurityProtocols (org.snmp4j.security.SecurityProtocols)1 USM (org.snmp4j.security.USM)1 DefaultUdpTransportMapping (org.snmp4j.transport.DefaultUdpTransportMapping)1