@@ -25,8 +25,10 @@ import java.util.concurrent.Executors
2525import java.util.concurrent.TimeUnit
2626import java.util.concurrent.atomic.AtomicBoolean
2727
28-
29- class RemoteServer (private val devSpacesContext : DevSpacesContext ) {
28+ /* *
29+ * Represent an IDE server running in a CDE.
30+ */
31+ class RemoteIDEServer (private val devSpacesContext : DevSpacesContext ) {
3032 var pod: V1Pod
3133 private var container: V1Container
3234 private var readyTimeout: Long = 60
@@ -37,7 +39,10 @@ class RemoteServer(private val devSpacesContext: DevSpacesContext) {
3739 container = findContainer()
3840 }
3941
40- fun getProjectStatus (): ProjectStatus {
42+ /* *
43+ * Asks the CDE for the remote IDE server status.
44+ */
45+ fun getStatus (): RemoteIDEServerStatus {
4146 Pods (devSpacesContext.client)
4247 .exec(
4348 pod,
@@ -56,44 +61,44 @@ class RemoteServer(private val devSpacesContext: DevSpacesContext) {
5661 )
5762 .trim()
5863 .also {
59- return if (Strings .isNullOrEmpty(it)) ProjectStatus .empty()
60- else Gson ().fromJson(it, ProjectStatus ::class .java)
64+ return if (Strings .isNullOrEmpty(it)) RemoteIDEServerStatus .empty()
65+ else Gson ().fromJson(it, RemoteIDEServerStatus ::class .java)
6166 }
6267 }
6368
6469 @Throws(IOException ::class )
65- fun waitProjectsReady () {
66- doWaitProjectsState (true , readyTimeout)
70+ fun waitServerReady () {
71+ doWaitServerState (true , readyTimeout)
6772 .also {
6873 if (! it) throw IOException (
6974 String .format(
70- " Projects are not ready after %d seconds." ,
75+ " Remote IDE server is not ready after %d seconds." ,
7176 readyTimeout
7277 )
7378 )
7479 }
7580 }
7681
7782 @Throws(IOException ::class )
78- fun waitProjectsTerminated (): Boolean {
79- return doWaitProjectsState (false , terminationTimeout)
83+ fun waitServerTerminated (): Boolean {
84+ return doWaitServerState (false , terminationTimeout)
8085 }
8186
8287 @Throws(IOException ::class )
83- fun doWaitProjectsState (isReadyState : Boolean , timeout : Long ): Boolean {
88+ fun doWaitServerState (isReadyState : Boolean , timeout : Long ): Boolean {
8489 val projectsInDesiredState = AtomicBoolean ()
8590 val executor = Executors .newSingleThreadScheduledExecutor()
8691 executor.scheduleAtFixedRate(
8792 {
8893 try {
89- getProjectStatus ().also {
94+ getStatus ().also {
9095 if (isReadyState == ! Arrays .isNullOrEmpty(it.projects)) {
9196 projectsInDesiredState.set(true )
9297 executor.shutdown()
9398 }
9499 }
95100 } catch (e: Exception ) {
96- thisLogger().debug(" Failed to check project status " , e)
101+ thisLogger().debug(" Failed to check remote IDE server state. " , e)
97102 }
98103 }, 0 , 5 , TimeUnit .SECONDS
99104 )
0 commit comments