Your advice on gathered data sending approach

Discussion in 'Plugin Development' started by UltraMC, Dec 7, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    UltraMC

    I'm developing a Java plugin that makes server gather data. I want your opinion on my approach and advice.


    Considerations
    Data gathered is on game events like `picking up an item` or `destroying a block`, but despite of what data is, there are considerations to be made on sending it to database.


    Database query & resource-wise usage
    Plugin is not going to query database every time an event is fired, but will send it to plugin's registry instead. Only on certain events like `on player quit` or `on server stop` data will be eventually send in parts or as a whole from registry to database.


    That's for balanced resources usage, as data in database is not going to be live representation of registry, but a snapshot of it from not distant past. It’s because updating it on every event would kill performance.


    Drawbacks
    Advice I need is on presentation layer when a web app is getting data from database. In this point data is required to be as accurate as possible, so there is need for forcing a plugin to send it's registry as whole to database and give an sign (by a webservice?) that operation was successful.

    The question is, what technology to use here and is it a valid approach in the first place?

     
  2. Offline

    UltraMC

  3. Offline

    Njol

    You can just send the data in a different thread than the main server thread (e.g. an async Bukkit task). This will not slow down the server more that what you currently intend to do, and will keep the database up-to-date.
     
  4. Offline

    UltraMC

    But I ask how to force plugin to send data via webservice
     
  5. Offline

    NathanWolf

    Turning your plugin into a webservice is non-trivial! Make sure you need and want that before going that route. You would need to make your plugin open a web socket and listen on it, much like dynmap does.

    Is this just so you can force a flush of the most recent data?

    There may be an easier or better way, like have a file you scan every few seconds, if the file has changed then update. That way you can leave the web service stuff to something like Apache, which would then just have to touch that file.

    Otherwise- are you certain you cannot update your database in real time? If all you are doing is logging, and your table structure isn't crazy, and you're doing async inserts I don't think it should be a problem. Inserts are usually pretty cheap, versus updates and queries.

    I may be confused about your question, too. If all you're asking is how to do the presentation layer, that probably should not be part of your plugin. I'd recommend looking at PHP for that, wrapping a GUI around a Db is what PHP does best :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  6. Offline

    UltraMC

    data is required to be as accurate as possible, so there is need for forcing a plugin to send it's registry as whole to database and give an sign (by a webservice?) that operation was successful.

    Touching a file every second or so is most lame thing you can do
     
  7. Offline

    NathanWolf

    You would not touch the file every second, you would check it every second, and touch it when you want an update. Using files for simple IPC is not "lame", it's a common practice.

    If you want to basically implement a web server in your plugin, that is not really a topic for bukkit dev, and you will need a lot of experience with sockets and network programming, or use and embed something like Jetty. Personally from a server admin perspective, I'd rather not use such a heavy plugin unless there's a really good reason. Dynmap does it well, there are probably some server admin plugins that are worth it- but if that's not the main focus of your plugin, it's a lot of potentially dangerous overhead.

    Are you certain you can't update the database in realtime?
     
  8. Offline

    UltraMC

    Thanks for first valuable information across all internetz - "Jetty"
     
    NathanWolf likes this.
Thread Status:
Not open for further replies.

Share This Page