@@ -25,8 +25,10 @@ import java.util.concurrent.Executors
25
25
import java.util.concurrent.TimeUnit
26
26
import java.util.concurrent.atomic.AtomicBoolean
27
27
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 ) {
30
32
var pod: V1Pod
31
33
private var container: V1Container
32
34
private var readyTimeout: Long = 60
@@ -37,7 +39,10 @@ class RemoteServer(private val devSpacesContext: DevSpacesContext) {
37
39
container = findContainer()
38
40
}
39
41
40
- fun getProjectStatus (): ProjectStatus {
42
+ /* *
43
+ * Asks the CDE for the remote IDE server status.
44
+ */
45
+ fun getStatus (): RemoteIDEServerStatus {
41
46
Pods (devSpacesContext.client)
42
47
.exec(
43
48
pod,
@@ -56,44 +61,44 @@ class RemoteServer(private val devSpacesContext: DevSpacesContext) {
56
61
)
57
62
.trim()
58
63
.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)
61
66
}
62
67
}
63
68
64
69
@Throws(IOException ::class )
65
- fun waitProjectsReady () {
66
- doWaitProjectsState (true , readyTimeout)
70
+ fun waitServerReady () {
71
+ doWaitServerState (true , readyTimeout)
67
72
.also {
68
73
if (! it) throw IOException (
69
74
String .format(
70
- " Projects are not ready after %d seconds." ,
75
+ " Remote IDE server is not ready after %d seconds." ,
71
76
readyTimeout
72
77
)
73
78
)
74
79
}
75
80
}
76
81
77
82
@Throws(IOException ::class )
78
- fun waitProjectsTerminated (): Boolean {
79
- return doWaitProjectsState (false , terminationTimeout)
83
+ fun waitServerTerminated (): Boolean {
84
+ return doWaitServerState (false , terminationTimeout)
80
85
}
81
86
82
87
@Throws(IOException ::class )
83
- fun doWaitProjectsState (isReadyState : Boolean , timeout : Long ): Boolean {
88
+ fun doWaitServerState (isReadyState : Boolean , timeout : Long ): Boolean {
84
89
val projectsInDesiredState = AtomicBoolean ()
85
90
val executor = Executors .newSingleThreadScheduledExecutor()
86
91
executor.scheduleAtFixedRate(
87
92
{
88
93
try {
89
- getProjectStatus ().also {
94
+ getStatus ().also {
90
95
if (isReadyState == ! Arrays .isNullOrEmpty(it.projects)) {
91
96
projectsInDesiredState.set(true )
92
97
executor.shutdown()
93
98
}
94
99
}
95
100
} catch (e: Exception ) {
96
- thisLogger().debug(" Failed to check project status " , e)
101
+ thisLogger().debug(" Failed to check remote IDE server state. " , e)
97
102
}
98
103
}, 0 , 5 , TimeUnit .SECONDS
99
104
)
0 commit comments