Search in sources :

Example 1 with SingleSocketTcpWriter

use of kieker.monitoring.writer.tcp.SingleSocketTcpWriter in project iobserve-analysis by research-iobserve.

the class TcpProbeController method createNewTcpWriter.

private SingleSocketTcpWriter createNewTcpWriter(final String hostname, final int port) throws RemoteControlFailedException {
    final Configuration configuration = new Configuration();
    configuration.setProperty(SingleSocketTcpWriter.CONFIG_HOSTNAME, hostname);
    configuration.setProperty(SingleSocketTcpWriter.CONFIG_PORT, port);
    configuration.setProperty(SingleSocketTcpWriter.CONFIG_CONN_TIMEOUT_IN_MS, TcpProbeController.CONN_TIMEOUT_IN_MS);
    configuration.setProperty(SingleSocketTcpWriter.CONFIG_FLUSH, true);
    configuration.setProperty(SingleSocketTcpWriter.CONFIG_BUFFERSIZE, 65535);
    final SingleSocketTcpWriter tcpWriter;
    try {
        tcpWriter = new SingleSocketTcpWriter(configuration);
        tcpWriter.onStarting();
    } catch (final IOException | ConnectionTimeoutException e) {
        // runtime exception is thrown after timeout
        if (TcpProbeController.LOGGER.isDebugEnabled()) {
            TcpProbeController.LOGGER.debug("Could not create TCP connections to " + hostname + " on port " + port, e);
        }
        throw new RemoteControlFailedException("Could not create TCP connections to " + hostname + " on port " + port + ", writer was not created ");
    }
    return tcpWriter;
}
Also used : ConnectionTimeoutException(kieker.monitoring.writer.tcp.ConnectionTimeoutException) Configuration(kieker.common.configuration.Configuration) SingleSocketTcpWriter(kieker.monitoring.writer.tcp.SingleSocketTcpWriter) IOException(java.io.IOException)

Example 2 with SingleSocketTcpWriter

use of kieker.monitoring.writer.tcp.SingleSocketTcpWriter in project iobserve-analysis by research-iobserve.

the class TcpProbeController method sendTcpCommand.

private void sendTcpCommand(final String ip, final int port, final String hostname, final IRemoteControlEvent monitoringRecord) throws RemoteControlFailedException {
    final String writerKey = ip + ":" + port;
    final SingleSocketTcpWriter tcpWriter;
    TcpControlConnection currentConnection = this.knownAddresses.get(writerKey);
    // if host was never used or an other module was there before, create a new connection
    if (currentConnection == null || currentConnection.getHostname() != hostname) {
        currentConnection = new TcpControlConnection(ip, port, hostname, this.createNewTcpWriter(ip, port));
        this.knownAddresses.put(writerKey, currentConnection);
    }
    tcpWriter = currentConnection.getTcpWriter();
    if (tcpWriter == null) {
        throw new RemoteControlFailedException("TCP Writer was not found");
    }
    // currently we have no means to check if the write process was successful or the channel is
    // still active
    tcpWriter.writeMonitoringRecord(monitoringRecord);
    if (TcpProbeController.LOGGER.isDebugEnabled()) {
        TcpProbeController.LOGGER.debug("Send record " + monitoringRecord.getClass().getName() + " to " + ip + " on port: " + port);
    }
}
Also used : SingleSocketTcpWriter(kieker.monitoring.writer.tcp.SingleSocketTcpWriter)

Aggregations

SingleSocketTcpWriter (kieker.monitoring.writer.tcp.SingleSocketTcpWriter)2 IOException (java.io.IOException)1 Configuration (kieker.common.configuration.Configuration)1 ConnectionTimeoutException (kieker.monitoring.writer.tcp.ConnectionTimeoutException)1