class ScribeSender implements EventSender {

    @Override
    public void send(final File file, final CallbackHandler handler)
    {
        if (isClosed.get()) {
            createConnection();
        }

        // Tell the watchdog that we are doing something
        sleeping.set(false);

        // Parse the underlying file and generate the payload for Scribe
        final List<LogEntry> list = createScribePayload(file, handler);
        if (list == null) {
            // Something went wrong
            return;
        }

        try {
            scribeClient.log(list);
            // Get rid of the file. We do it early, because the reconnection may fail
            handler.onSuccess(file);

            messagesSuccessfullySent.addAndGet(list.size());
            messagesSuccessfullySentSinceLastReconnection.addAndGet(list.size());

            // For load balancing capabilities, we don't want to make sticky connections to Scribe.
            // After a certain threshold, force a refresh of the connection.
            if (messagesSuccessfullySentSinceLastReconnection.get() > messagesToSendBeforeReconnecting) {
                log.info("Recycling connection with Scribe");
                messagesSuccessfullySentSinceLastReconnection.set(0);
                createConnection();
            }
        }
        catch (org.apache.thrift.TException e) {
            // Connection flacky?
            log.warn("Error while sending message to Scribe: {}", e.getLocalizedMessage());
            createConnection();
            handler.onError(new Throwable(e), file);
        }
    }

}

class TestScribeSender {

    private ScribeMockClient scribeClient;
    private ScribeSender scribeSender;
    private Event thriftEvent;

    @Test(groups = "fast")
    public void testSend() throws Exception
    {

        int i = 100;
        while (i > 0) {
//            scribeSender.send(thriftEvent, new CallbackHandler()
//            {
//
//                @Override
//                public void onError(Throwable t, File file)
//                {
//                    assertTrue(false);
//                }
//
//                @Override
//                public void onSuccess(File file)
//                {
//                    assertTrue(true);
//                }
//            });
            i--;
        }
    }

}