Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Shervin Nourbakhsh
cameo
Commits
5361b715
Commit
5361b715
authored
Nov 26, 2019
by
legoc
Browse files
Removed Instance.now() method and added Instance.getActualState() and Instance.getLastState()
parent
b55bf6cf
Changes
3
Hide whitespace changes
Inline
Side-by-side
cameo-api/CHANGELOG.md
View file @
5361b715
0.1.5
-----
*
Added cancel(), isCanceled(), isEnded() methods to classes with blocking methods.
*
Reviewed cancel strategy for EventStreamSocket and OutputStreamSocket.
*
Removed Instance.now() method and added Instance.getActualState() and Instance.getLastState().
0.
1.4
-----
...
...
cameo-api/src/main/java/fr/ill/ics/cameo/Application.java
View file @
5361b715
...
...
@@ -383,11 +383,13 @@ public class Application {
impl
.
cancelWaitFor
();
}
/**
* The call is not blocking but pops the entire content of the queue and returns the last received state, i.e. the current state.
*/
public
int
now
()
{
return
impl
.
now
();
public
int
getLastState
()
{
// The call is not blocking but pops the entire content of the queue and returns the last received state, i.e. the current state.
return
impl
.
waitFor
(
0
,
null
,
false
);
}
public
int
getActualState
()
{
return
impl
.
getActualState
();
}
/**
...
...
cameo-api/src/main/java/fr/ill/ics/cameo/impl/InstanceImpl.java
View file @
5361b715
...
...
@@ -16,7 +16,11 @@
package
fr.ill.ics.cameo.impl
;
import
java.util.List
;
import
fr.ill.ics.cameo.Application
;
import
fr.ill.ics.cameo.Application.Info
;
import
fr.ill.ics.cameo.Application.State
;
import
fr.ill.ics.cameo.CancelEvent
;
import
fr.ill.ics.cameo.ConnectionTimeout
;
import
fr.ill.ics.cameo.Event
;
...
...
@@ -183,7 +187,7 @@ public class InstanceImpl extends EventListener {
* The call is blocking until a terminal state is received i.e. SUCCESS, STOPPED, KILLED, ERROR.
* The method is not thread-safe and must not be called concurrently.
*/
p
rivate
int
waitFor
(
int
states
,
String
eventName
,
boolean
blocking
)
{
p
ublic
int
waitFor
(
int
states
,
String
eventName
,
boolean
blocking
)
{
if
(!
exists
())
{
return
lastState
;
...
...
@@ -280,17 +284,22 @@ public class InstanceImpl extends EventListener {
return
waitFor
(
0
);
}
/**
* The call is not blocking but pops the entire content of the queue and returns the last received state, i.e. the current state.
*/
public
int
now
()
{
return
waitFor
(
0
,
null
,
false
);
}
public
void
cancelWaitFor
()
{
cancel
(
id
);
}
public
int
getActualState
()
{
List
<
Info
>
infos
=
server
.
getApplicationInfos
(
name
);
for
(
Info
info
:
infos
)
{
if
(
info
.
getId
()
==
id
)
{
return
info
.
getApplicationState
();
}
}
return
State
.
UNKNOWN
;
}
public
void
terminate
()
{
// Unregister the status.
server
.
unregisterStatusListener
(
this
);
...
...
@@ -374,4 +383,5 @@ public class InstanceImpl extends EventListener {
public
String
toString
()
{
return
name
+
"."
+
id
+
"@"
+
server
.
getEndpoint
();
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment