return true; if (!getFormatterName().equals(otherHandler.getFormatterName())) { return true; if (!compare(messageTransfer, otherHandler.messageTransfer)){ return true; if (!compare(tlsTrustStorePath, otherHandler.tlsTrustStorePath)){ return true; if (!compare(tlsTrustStoreRelativeTo, otherHandler.tlsTrustStoreRelativeTo)){ return true; if (!compare(tlsTrustStorePassword, otherHandler.tlsTrustStorePassword)){ return true; if (!compare(tlsClientCertStorePath, otherHandler.tlsClientCertStorePath)){ return true; if (!compare(tlsClientCertStoreRelativeTo, otherHandler.tlsClientCertStoreRelativeTo)){ return true; if (!compare(tlsClientCertStorePassword, otherHandler.tlsClientCertStorePassword)){ return true; if (!compare(tlsClientCertStoreKeyPassword, otherHandler.tlsClientCertStoreKeyPassword)){ return true;
private boolean isReconnect() { return hasTooManyFailures() && isActive(); }
final SyslogAuditLogHandler handler = new SyslogAuditLogHandler(name, formatterName, maxFailureCount, pathManager, service); handler.setFacility(SyslogAuditLogHandler.Facility.valueOf(FACILITY.resolveModelAttribute(context, handlerModel).asString())); handler.setHostName(environmentReader.getHostName() != null ? environmentReader.getHostName() + ":" + environmentReader.getServerName() : environmentReader.getServerName()); } else { handler.setHostName(environmentReader.getHostName()); handler.setAppName(resolveAppName(context, handlerModel.get(APP_NAME.getName()), environmentReader)); handler.setSyslogType(SyslogHandler.SyslogType.valueOf(SYSLOG_FORMAT.resolveModelAttribute(context, handlerModel).asString())); handler.setTruncate(TRUNCATE.resolveModelAttribute(context, handlerModel).asBoolean()); if (handlerModel.hasDefined(MAX_LENGTH.getName())) { handler.setMaxLength(MAX_LENGTH.resolveModelAttribute(context, handlerModel).asInt()); handler.setTransport(transport); try { handler.setSyslogServerAddress( InetAddress.getByName( SyslogAuditLogProtocolResourceDefinition.HOST.resolveModelAttribute(context, protocol.getModel()).asString())); handler.setPort(SyslogAuditLogProtocolResourceDefinition.PORT.resolveModelAttribute(context, protocol.getModel()).asInt()); if (transport != SyslogAuditLogHandler.Transport.UDP) { handler.setMessageTransfer( SyslogAuditLogHandler.MessageTransfer.valueOf( SyslogAuditLogProtocolResourceDefinition.Tcp.MESSAGE_TRANSFER.resolveModelAttribute(context, protocol.getModel()).asString())); handler.setReconnectTimeout(SyslogAuditLogProtocolResourceDefinition.Tcp.RECONNECT_TIMEOUT.resolveModelAttribute(context, protocol.getModel()).asInt()); String type = storeEntry.getPathElement().getValue();
@Override public void updateSyslogHandlerFacility(String name, Facility facility) { config.lock(); try { SyslogAuditLogHandler handler = (SyslogAuditLogHandler)config.getConfiguredHandler(name); handler.setFacility(facility); } finally { config.unlock(); } }
@Override public void updateSyslogHandlerAppName(String name, String appName) { config.lock(); try { SyslogAuditLogHandler handler = (SyslogAuditLogHandler)config.getConfiguredHandler(name); handler.setAppName(appName); } finally { config.unlock(); } }
@Override void writeLogItem(String formattedItem) throws IOException { boolean reconnect = isReconnect(); if (!reconnect) { handler.publish(new ExtLogRecord(Level.WARN, formattedItem, SyslogAuditLogHandler.class.getName())); errorManager.getAndThrowError(); } else { ControllerLogger.MGMT_OP_LOGGER.attemptingReconnectToSyslog(name, reconnectTimeout); try { // Reinitialise the delegating syslog handler if required, if we're already connected we don't need to // establish a new connection if (!connected) { stop(); initialize(); } handler.publish(new ExtLogRecord(Level.WARN, formattedItem, SyslogAuditLogHandler.class.getName())); errorManager.getAndThrowError(); lastErrorTime = -1; } catch (Exception e) { // A failure has occurred and initialization should be reattempted connected = false; lastErrorTime = System.currentTimeMillis(); errorManager.throwAsIoOrRuntimeException(e); } } }
@Override public void updateSyslogHandlerReconnectTimeout(String name, int reconnectTimeout) { config.lock(); try { SyslogAuditLogHandler handler = (SyslogAuditLogHandler)config.getConfiguredHandler(name); handler.setReconnectTimeout(reconnectTimeout); } finally { config.unlock(); } } // Immediate updates
@Override boolean isActive() { if (hasTooManyFailures()) { if (reconnectTimeout >= 0) { long end = lastErrorTime + reconnectTimeout * 1000; return System.currentTimeMillis() > end; } return false; } return true; }
void throwAsIoOrRuntimeException(Throwable t) throws IOException { if (t instanceof PortUnreachableException && transport == Transport.UDP) { //This is an exception that may or may not happen, see the javadoc for DatagramSocket.send(). //We don't want something this unreliable polluting the failure count. //With UDP syslogging set up against a non-existent syslog server: //On OS X this exception never happens. //On Linux this seems to happens every other send, so we end up with a loop // odd send works; failure count = 0 // even send fails; failure count = 1 // odd send works; failure count reset to 0 // //Also, we don't want the full stack trace for this which would get printed by StandardFailureCountHandler.StandardFailureCountHandler.failure(), //which also handles the failure count, so we swallow the exception and print a warning. ControllerLogger.MGMT_OP_LOGGER.udpSyslogServerUnavailable(getName(), t.getLocalizedMessage()); return; } if (t instanceof IOException) { throw (IOException)t; } if (t instanceof RuntimeException) { throw (RuntimeException)t; } throw new RuntimeException(t); } }
final SyslogAuditLogHandler handler = new SyslogAuditLogHandler(name, formatterName, maxFailureCount, pathManager, service); handler.setFacility(SyslogAuditLogHandler.Facility.valueOf(FACILITY.resolveModelAttribute(context, handlerModel).asString())); handler.setHostName(environmentReader.getHostName() != null ? environmentReader.getHostName() + ":" + environmentReader.getServerName() : environmentReader.getServerName()); } else { handler.setHostName(environmentReader.getHostName()); handler.setAppName(resolveAppName(context, handlerModel.get(APP_NAME.getName()), environmentReader)); handler.setSyslogType(SyslogHandler.SyslogType.valueOf(SYSLOG_FORMAT.resolveModelAttribute(context, handlerModel).asString())); handler.setTruncate(TRUNCATE.resolveModelAttribute(context, handlerModel).asBoolean()); if (handlerModel.hasDefined(MAX_LENGTH.getName())) { handler.setMaxLength(MAX_LENGTH.resolveModelAttribute(context, handlerModel).asInt()); handler.setTransport(transport); try { handler.setSyslogServerAddress( InetAddress.getByName( SyslogAuditLogProtocolResourceDefinition.HOST.resolveModelAttribute(context, protocol.getModel()).asString())); handler.setPort(SyslogAuditLogProtocolResourceDefinition.PORT.resolveModelAttribute(context, protocol.getModel()).asInt()); if (transport != SyslogAuditLogHandler.Transport.UDP) { handler.setMessageTransfer( SyslogAuditLogHandler.MessageTransfer.valueOf( SyslogAuditLogProtocolResourceDefinition.Tcp.MESSAGE_TRANSFER.resolveModelAttribute(context, protocol.getModel()).asString())); handler.setReconnectTimeout(SyslogAuditLogProtocolResourceDefinition.Tcp.RECONNECT_TIMEOUT.resolveModelAttribute(context, protocol.getModel()).asInt()); String type = storeEntry.getPathElement().getValue();
@Override public void updateSyslogHandlerFacility(String name, Facility facility) { config.lock(); try { SyslogAuditLogHandler handler = (SyslogAuditLogHandler)config.getConfiguredHandler(name); handler.setFacility(facility); } finally { config.unlock(); } }
@Override public void updateSyslogHandlerAppName(String name, String appName) { config.lock(); try { SyslogAuditLogHandler handler = (SyslogAuditLogHandler)config.getConfiguredHandler(name); handler.setAppName(appName); } finally { config.unlock(); } }
@Override void writeLogItem(String formattedItem) throws IOException { boolean reconnect = isReconnect(); if (!reconnect) { handler.publish(new ExtLogRecord(Level.WARN, formattedItem, SyslogAuditLogHandler.class.getName())); errorManager.getAndThrowError(); } else { ControllerLogger.MGMT_OP_LOGGER.attemptingReconnectToSyslog(name, reconnectTimeout); try { // Reinitialise the delegating syslog handler if required, if we're already connected we don't need to // establish a new connection if (!connected) { stop(); initialize(); } handler.publish(new ExtLogRecord(Level.WARN, formattedItem, SyslogAuditLogHandler.class.getName())); errorManager.getAndThrowError(); lastErrorTime = -1; } catch (Exception e) { // A failure has occurred and initialization should be reattempted connected = false; lastErrorTime = System.currentTimeMillis(); errorManager.throwAsIoOrRuntimeException(e); } } }
@Override public void updateSyslogHandlerReconnectTimeout(String name, int reconnectTimeout) { config.lock(); try { SyslogAuditLogHandler handler = (SyslogAuditLogHandler)config.getConfiguredHandler(name); handler.setReconnectTimeout(reconnectTimeout); } finally { config.unlock(); } } // Immediate updates
@Override boolean isActive() { if (hasTooManyFailures()) { if (reconnectTimeout >= 0) { long end = lastErrorTime + reconnectTimeout * 1000; return System.currentTimeMillis() > end; } return false; } return true; }
void throwAsIoOrRuntimeException(Throwable t) throws IOException { if (t instanceof PortUnreachableException && transport == Transport.UDP) { //This is an exception that may or may not happen, see the javadoc for DatagramSocket.send(). //We don't want something this unreliable polluting the failure count. //With UDP syslogging set up against a non-existent syslog server: //On OS X this exception never happens. //On Linux this seems to happens every other send, so we end up with a loop // odd send works; failure count = 0 // even send fails; failure count = 1 // odd send works; failure count reset to 0 // //Also, we don't want the full stack trace for this which would get printed by StandardFailureCountHandler.StandardFailureCountHandler.failure(), //which also handles the failure count, so we swallow the exception and print a warning. ControllerLogger.MGMT_OP_LOGGER.udpSyslogServerUnavailable(getName(), t.getLocalizedMessage()); return; } if (t instanceof IOException) { throw (IOException)t; } if (t instanceof RuntimeException) { throw (RuntimeException)t; } throw new RuntimeException(t); } }
return true; if (!getFormatterName().equals(otherHandler.getFormatterName())) { return true; if (!compare(messageTransfer, otherHandler.messageTransfer)){ return true; if (!compare(tlsTrustStorePath, otherHandler.tlsTrustStorePath)){ return true; if (!compare(tlsTrustStoreRelativeTo, otherHandler.tlsTrustStoreRelativeTo)){ return true; if (!compare(tlsTrustStorePassword, otherHandler.tlsTrustStorePassword)){ return true; if (!compare(tlsClientCertStorePath, otherHandler.tlsClientCertStorePath)){ return true; if (!compare(tlsClientCertStoreRelativeTo, otherHandler.tlsClientCertStoreRelativeTo)){ return true; if (!compare(tlsClientCertStorePassword, otherHandler.tlsClientCertStorePassword)){ return true; if (!compare(tlsClientCertStoreKeyPassword, otherHandler.tlsClientCertStoreKeyPassword)){ return true;
@Override public void updateSyslogHandlerFacility(String name, Facility facility) { config.lock(); try { SyslogAuditLogHandler handler = (SyslogAuditLogHandler)config.getConfiguredHandler(name); handler.setFacility(facility); } finally { config.unlock(); } }
@Override public void updateSyslogHandlerAppName(String name, String appName) { config.lock(); try { SyslogAuditLogHandler handler = (SyslogAuditLogHandler)config.getConfiguredHandler(name); handler.setAppName(appName); } finally { config.unlock(); } } // Immediate updates
private boolean isReconnect() { return hasTooManyFailures() && isActive(); }