MCPcopy
hub / github.com/statsd/statsd / flush

Method flush

examples/StatsdClient.java:235–263  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

233 }
234
235 public synchronized boolean flush() {
236 try {
237 final int sizeOfBuffer = sendBuffer.position();
238
239 if(sizeOfBuffer <= 0) { return false; } // empty buffer
240
241 // send and reset the buffer
242 sendBuffer.flip();
243 final int nbSentBytes = _channel.send(sendBuffer, _address);
244 sendBuffer.limit(sendBuffer.capacity());
245 sendBuffer.rewind();
246
247 if (sizeOfBuffer == nbSentBytes) {
248 return true;
249 } else {
250 log.error(String.format(
251 "Could not send entirely stat %s to host %s:%d. Only sent %d bytes out of %d bytes", sendBuffer.toString(),
252 _address.getHostName(), _address.getPort(), nbSentBytes, sizeOfBuffer));
253 return false;
254 }
255
256 } catch (IOException e) {
257 /* This would be a good place to close the channel down and recreate it. */
258 log.error(
259 String.format("Could not send stat %s to host %s:%d", sendBuffer.toString(), _address.getHostName(),
260 _address.getPort()), e);
261 return false;
262 }
263 }
264}

Callers 5

finalizeMethod · 0.95
setBufferSizeMethod · 0.95
runMethod · 0.95
doSendMethod · 0.95
ConsoleBackendFunction · 0.80

Calls 2

formatMethod · 0.80
sendMethod · 0.45

Tested by

no test coverage detected