@Override public IMonitoringRecord deserializeNextRecord() throws ConnectorDataTransmissionException, ConnectorEndOfDataException { try { return this.recordQueue.take(); } catch (final InterruptedException ex) { throw new ConnectorDataTransmissionException("Connector has been interrupted", ex); } }
@Override public void run() { try { CLIServerMain.this.shutdown(); } catch (final ConnectorDataTransmissionException e) { CLIServerMain.getLogger().error("Graceful shutdown failed."); CLIServerMain.getLogger().error("Cause {}", e.getMessage()); } } });
/** * Initialize a service connector and trigger a failure on error. */ protected void initialize() { try { LOGGER.info("Initialize connector {}", this.connector.getClass().toString()); this.connector.initialize(); } catch (final ConnectorDataTransmissionException e) { Assert.fail("Connector initialization failed: " + e.getMessage()); } }
@Override public IMonitoringRecord deserializeNextRecord() throws ConnectorDataTransmissionException, ConnectorEndOfDataException { try { return this.recordQueue.take(); } catch (final InterruptedException ex) { throw new ConnectorDataTransmissionException("Connector has been interrupted", ex); } }
@Override public void run() { try { CLIServerMain.this.shutdown(); } catch (final ConnectorDataTransmissionException e) { CLIServerMain.getLog().error("Graceful shutdown failed."); CLIServerMain.getLog().error("Cause " + e.getMessage()); } } });
@Override public void close() throws ConnectorDataTransmissionException { try { this.server.stop(); this.server.join(); } catch (final Exception ex) { // NOPMD NOCS (Jetty does that) throw new ConnectorDataTransmissionException("Could not stop server", ex); } }
/** * Close a service connector and trigger a failure on errors. * * @param numberOfRecords * number of expected records */ protected void close(final int numberOfRecords) { try { LOGGER.info("Terminate connector {}", this.connector.getClass().toString()); this.connector.close(); } catch (final ConnectorDataTransmissionException e) { Assert.fail("Connector termination failed: " + e.getMessage()); } Assert.assertEquals("Number of send records is not equal to number of received records", numberOfRecords, this.getRecordCount()); }
@Override public void close() throws ConnectorDataTransmissionException { try { this.server.stop(); this.server.join(); } catch (final Exception ex) { // NOPMD NOCS (Jetty does that) throw new ConnectorDataTransmissionException("Could not stop server", ex); } }
this.usage(commander, 2, "Configuration error: " + e.getMessage()); } catch (final ConnectorDataTransmissionException e) { this.usage(commander, 3, "Communication error: " + e.getMessage());
/** * Closes the data stream and socket. * * @throws ConnectorDataTransmissionException * if an IOException occurs during the close operation */ @Override public void close() throws ConnectorDataTransmissionException { try { this.in.close(); this.socket.close(); } catch (final IOException e) { throw new ConnectorDataTransmissionException("Error occured during socket close.", e); } }
this.usage(commander, 2, "Configuration error: " + e.getMessage()); } catch (final ConnectorDataTransmissionException e) { this.usage(commander, 3, "Communication error: " + e.getMessage());
/** * Closes the data stream and socket. * * @throws ConnectorDataTransmissionException * if an IOException occurs during the close operation */ @Override public void close() throws ConnectorDataTransmissionException { try { this.in.close(); this.socket.close(); } catch (final IOException e) { throw new ConnectorDataTransmissionException("Error occured during socket close.", e); } }
this.recordCount++; } catch (final ConnectorDataTransmissionException e) { Assert.fail("Error receiving data: " + e.getMessage()); } catch (final ConnectorEndOfDataException e) { Assert.fail("Connector has not terminated: " + e.getMessage());
/** * Create the connection to a remote service providing records. * * @throws ConnectorDataTransmissionException * if the given host or IP cannot be found, or an IOException occurs */ @Override public void initialize() throws ConnectorDataTransmissionException { try { this.socket = new Socket(this.hostname, this.port); this.in = new DataInputStream(this.socket.getInputStream()); } catch (final UnknownHostException e) { throw new ConnectorDataTransmissionException("The given host " + this.hostname + " could not be found.", e); } catch (final IOException e) { throw new ConnectorDataTransmissionException(e.getMessage(), e); } }
/** * Close the server connection. * * @throws ConnectorDataTransmissionException * if the closing fails */ @Override public void close() throws ConnectorDataTransmissionException { try { this.in.close(); this.serverSocket.close(); } catch (final IOException e) { throw new ConnectorDataTransmissionException(e.getMessage(), e); } }
/** * Close the server connection. * * @throws ConnectorDataTransmissionException * if the closing fails */ @Override public void close() throws ConnectorDataTransmissionException { try { this.in.close(); this.serverSocket.close(); } catch (final IOException e) { throw new ConnectorDataTransmissionException(e.getMessage(), e); } }
/** * Create the connection to a remote service providing records. * * @throws ConnectorDataTransmissionException * if the given host or IP cannot be found, or an IOException occurs */ @Override public void initialize() throws ConnectorDataTransmissionException { try { this.socket = new Socket(this.hostname, this.port); this.in = new DataInputStream(this.socket.getInputStream()); } catch (final UnknownHostException e) { throw new ConnectorDataTransmissionException("The given host " + this.hostname + " could not be found.", e); } catch (final IOException e) { throw new ConnectorDataTransmissionException(e.getMessage(), e); } }
/** * Initializes a server socket and data stream for a single connection. * * @throws ConnectorDataTransmissionException * it the socket could not be established */ @Override public void initialize() throws ConnectorDataTransmissionException { try { this.serverSocket = new ServerSocket(this.port); this.in = new DataInputStream(this.serverSocket.accept().getInputStream()); } catch (final IOException e) { throw new ConnectorDataTransmissionException(e.getMessage(), e); } }
/** * Initializes a server socket and data stream for a single connection. * * @throws ConnectorDataTransmissionException * it the socket could not be established */ @Override public void initialize() throws ConnectorDataTransmissionException { try { this.serverSocket = new ServerSocket(this.port); this.in = new DataInputStream(this.serverSocket.accept().getInputStream()); } catch (final IOException e) { throw new ConnectorDataTransmissionException(e.getMessage(), e); } }
@Override public void initialize() throws ConnectorDataTransmissionException { try { this.server = new Server(this.port); final Servlet servlet = new MonitoringReceiverServlet(this.recordQueue); final ServletHolder servletHolder = new ServletHolder(servlet); final ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); contextHandler.setContextPath(this.context); contextHandler.addServlet(servletHolder, this.restURL); this.server.setHandler(contextHandler); this.server.start(); } catch (final Exception ex) { // NOPMD NOCS (Jetty does that) throw new ConnectorDataTransmissionException("Could not start server", ex); } }