private void onIdleTimerExpired() { ScheduledFuture<?> expiredIdleTimer = idleTimer; synchronized (this) { if (expiredIdleTimer != idleTimer) { LOG.debug("Detect restart of Idle timer for {}", sock); } else { LOG.info("Idle timeout for {} expired", sock); idleTimer = null; closeSocket(); } } }
private synchronized ActiveConnection activeConnection() throws IncompatibleConnectionException { ActiveConnection activeConnection = this.activeConnection; if (activeConnection != null) return activeConnection; Device arrDev = this.arrDevice; if (arrDevice == null) throw new IllegalStateException("No AuditRecordRepositoryDevice initalized"); AuditRecordRepository arr = arrDev.getDeviceExtension(AuditRecordRepository.class); if (arr == null) throw new IllegalStateException("AuditRecordRepositoryDevice " + arrDevice.getDeviceName() + " does not provide Audit Record Repository"); for (Connection remoteConn : arr.getConnections()) if (remoteConn.isInstalled() && remoteConn.isServer()) for (Connection conn : conns) if (conn.isInstalled() && conn.isCompatible(remoteConn)) { return (this.activeConnection = conn.getProtocol().isTCP() ? new TCPConnection(conn, remoteConn) : new UDPConnection(conn, remoteConn)); } throw new IncompatibleConnectionException( "No compatible connection to AuditRecordRepository @ Device " + arr.getDevice().getDeviceName() + " available on AuditLogger @ Device " + device.getDeviceName()); }
private synchronized ActiveConnection activeConnection() throws IncompatibleConnectionException { ActiveConnection activeConnection = this.activeConnection; if (activeConnection != null) return activeConnection; Device arrDev = this.arrDevice; if (arrDevice == null) throw new IllegalStateException("No AuditRecordRepositoryDevice initalized"); AuditRecordRepository arr = arrDev.getDeviceExtension(AuditRecordRepository.class); if (arr == null) throw new IllegalStateException("AuditRecordRepositoryDevice " + arrDevice.getDeviceName() + " does not provide Audit Record Repository"); for (Connection remoteConn : arr.getConnections()) if (remoteConn.isInstalled() && remoteConn.isServer()) for (Connection conn : conns) if (conn.isInstalled() && conn.isCompatible(remoteConn)) { return (this.activeConnection = conn.getProtocol().isTCP() ? new TCPConnection(conn, remoteConn) : new UDPConnection(conn, remoteConn)); } throw new IncompatibleConnectionException( "No compatible connection to AuditRecordRepository @ Device " + arr.getDevice().getDeviceName() + " available on AuditLogger @ Device " + device.getDeviceName()); }
@Override synchronized void sendMessage(DatagramPacket packet) throws IOException, IncompatibleConnectionException, GeneralSecurityException { stopIdleTimer(); connect(); try { trySendMessage(packet); } catch (IOException e) { LOG.info("Failed to send audit message to {} - reconnect", sock, e); close(); connect(); trySendMessage(packet); } startIdleTimer(); }
@Override public synchronized void close() { stopIdleTimer(); closeSocket(); }
@Override synchronized void sendMessage(DatagramPacket packet) throws IOException, IncompatibleConnectionException, GeneralSecurityException { stopIdleTimer(); connect(); try { trySendMessage(packet); } catch (IOException e) { LOG.info("Failed to send audit message to {} - reconnect", sock, e); close(); connect(); trySendMessage(packet); } startIdleTimer(); }
@Override public synchronized void close() { stopIdleTimer(); closeSocket(); }
private void onIdleTimerExpired() { ScheduledFuture<?> expiredIdleTimer = idleTimer; synchronized (this) { if (expiredIdleTimer != idleTimer) { LOG.debug("Detect restart of Idle timer for {}", sock); } else { LOG.info("Idle timeout for {} expired", sock); idleTimer = null; closeSocket(); } } }