Closed gianluca-nitti closed 7 years ago
Update: while doing some additional testing I noticed that the WebSocket connection between the server and the web interface was frequently dropping when using this feature. After researching a bit of information about the exception that was being thrown by some Jetty internal class, I found out that there was a concurrency issue - multiple threads sometimes were trying to send WebSocket messages at the same time (when the write
method of a WritableResource
returns, an ActionResult
whose content depends on whether the method threw a ResourceAccessException
or not is sent to the client, but inside that method ModuleInstallerResource
starts a parallel task to download the new modules which can send messages to report progress), and the previously used method didn't support this.
So I solved this issue in the latest commit by simply switching to another override of the sendString
method of the RemoteEndpoint
Jetty class; the currently used version is non-blocking, returns immediately and then calls a callback after the message has been sent. Looks like everything works correctly now. The method's javadoc isn't very exhaustive but the comment in the Jetty bug tracker talks about an internal buffer so in my understanding the messages are queued and then sent once at a time to the underlying socket.
Great find about the Jetty "deficiency".
Engine PR has been merged, I think this one can be as well now :-)
Thanks @Cervator and @gianluca-nitti of course.
This small pull request adds the feature which allows server administrators to install modules in the server using the web interface or API.
The added resource,
ModuleInstallerResource
:WritableResource<Name[]>
in the sense that you can write to it (i.e. with a POST HTTP request or with the appropriate WebSocket message) a list of modules you want to install (which does not need to include all the dependencies; the dependency resolution happens server-side and the server adds the required dependencies - if any - to the download list automatically)ObservableReadableResource<String>
in the sense that you can read from it the current status of the installation, and every connected WebSocket client is automatically notified when the status changes (i.e. a progress in the download is made, or the installation has been completed).Important: for this to work, the engine must be built including my commits on pull request MovingBlocks/Terasology#3028; FacadeServer won't compile if classes introduced in that PR, like
ModuleInstallManager
, are missing.