UploaderService is now a thing.

Created a Service. Refactored the completeQueuedTasks() to use polymorphism. Switching on a type was evil, so I created a retry() method in each task. The tasks that need to be retried implement the abstract method.

Little more refactoring in each task so that instead of calling EventBus directly, they call a method in AbstractDataManagerTask to tryPushLater(). This has the effect of calling DataManager.startUploaderService().

Please, don't start UploaderService yourself. I have no idea what happens if two of them are running at once. Use DataManager.startUploaderService() if you really have to (but you shouldn't).

Also, did a bunch of magic with concurrent collections so that it should work. Used a BlockingQueue instead of an ArrayList in the EventBus. Synchronized keywords abound. Also, some neat queue stuff in UploaderService so we don't have an infinite loop trying to upload stuff while offline.

Loads and loads of comments everywhere explaining magic things I think were a good idea at the time :P. 

@stephenjust should look at how I check network connectivity in remoteDataStore using the hasAccess() method. It may make sense to replace what I put in there with a dummy call to ElasticSearch and see if it works.


http://www.vogella.com/legal.html - If you end up using this, you have to make note in the readme or credits file or whatever it is EPL requires.