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
Instrument Control
NomadCommandSystem
Commits
5487902f
Commit
5487902f
authored
Feb 27, 2017
by
yannick legoc
Browse files
Replaced corba command box accessor.
parent
33c6ebcf
Changes
3
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
5487902f
...
...
@@ -198,11 +198,6 @@
<arg
line=
"${idlFlags} ${idlCoreDir}/commandzone/CommandZoneAccessor.idl"
/>
</exec>
<echo
message=
"Generating CommandBoxAccessor.java"
/>
<exec
executable=
"idl"
>
<arg
line=
"${idlFlags} ${idlCoreDir}/commandzone/CommandBoxAccessor.idl"
/>
</exec>
<echo
message=
"Generating AtomicCommandBoxAccessor.java"
/>
<exec
executable=
"idl"
>
<arg
line=
"${idlFlags} ${idlCoreDir}/commandzone/AtomicCommandBoxAccessor.idl"
/>
...
...
@@ -329,6 +324,11 @@
<exec
executable=
"protoc"
>
<arg
line=
"${protoFlags} ${protoDir}/ConditionManagerRequests.proto"
/>
</exec>
<echo
message=
"Generating CommandBoxRequests.java"
/>
<exec
executable=
"protoc"
>
<arg
line=
"${protoFlags} ${protoDir}/commandzone/CommandBoxRequests.proto"
/>
</exec>
</target>
</configuration>
...
...
src/main/java/fr/ill/ics/nscclient/command/CommandBoxAccessorProxy.java
View file @
5487902f
...
...
@@ -23,19 +23,21 @@ import java.util.Map;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
fr.ill.ics.nomadserver.core.commandzone.CommandBoxAccessor
;
import
fr.ill.ics.nomadserver.core.commandzone.CommandBoxAccessorHelper
;
import
fr.ill.ics.nomadserver.core.commandzone.CommandBoxAccessorPackage.CommandBoxNotFoundException
;
import
fr.ill.ics.nomadserver.core.commandzone.CommandBoxAccessorPackage.ExecutionState
;
import
fr.ill.ics.nscclient.corbabase.CorbaNamingService
;
import
com.google.protobuf.InvalidProtocolBufferException
;
import
fr.ill.ics.cameo.Application
;
import
fr.ill.ics.cameo.RequesterCreationException
;
import
fr.ill.ics.nomadserver.commandzone.CommandBoxRequests
;
import
fr.ill.ics.nomadserver.common.Common
;
import
fr.ill.ics.nscclient.serverconnection.ServerInstance
;
public
class
CommandBoxAccessorProxy
{
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
CommandBoxAccessorProxy
.
class
.
getName
());
private
String
serverId
;
private
CommandBoxAccesso
r
commandBox
Accesso
r
;
private
Application
.
Requeste
r
commandBox
Requeste
r
;
public
enum
ExecutionPhaseState
{
CONSTRUCTION
,
RUNNING
,
FINISHED
,
PAUSED
};
private
static
Map
<
String
,
CommandBoxAccessorProxy
>
instances
=
new
HashMap
<
String
,
CommandBoxAccessorProxy
>();
...
...
@@ -54,117 +56,310 @@ public class CommandBoxAccessorProxy {
public
void
init
()
{
// Connect nomad server.
Application
.
Instance
nomad
=
ServerInstance
.
getInstance
().
getApplicationInstance
(
serverId
);
if
(
nomad
==
null
)
{
System
.
err
.
println
(
"Problem to connect to the nomad server "
+
serverId
);
return
;
}
System
.
out
.
println
(
"Trying to create command box requester"
);
// Create the requester.
try
{
String
contextName
=
"NomadServer"
;
if
(!
serverId
.
equals
(
"real"
))
{
contextName
+=
serverId
;
}
org
.
omg
.
CORBA
.
Object
corbaObj
=
CorbaNamingService
.
getInstance
().
resolveObject
(
contextName
,
"Core"
,
"commandBoxAccessor"
);
commandBoxAccessor
=
CommandBoxAccessorHelper
.
narrow
(
corbaObj
);
}
catch
(
CorbaNamingService
.
CORBAResolveFailureException
rfe
)
{
System
.
err
.
println
(
"Unable to obtain CommandBoxAccessor from Naming Service"
);
}
catch
(
org
.
omg
.
CORBA
.
SystemException
e
)
{
System
.
err
.
println
(
"Unable to obtain CommandBoxAccessor from Naming Service"
);
commandBoxRequester
=
Application
.
Requester
.
create
(
nomad
,
"command_box"
);
}
catch
(
RequesterCreationException
e
)
{
System
.
err
.
println
(
"Problem to connect to the command box responder: "
+
e
.
getMessage
());
return
;
}
System
.
out
.
println
(
"Created requester "
+
commandBoxRequester
);
}
public
void
reset
()
{
}
// Terminate the requester.
commandBoxRequester
.
terminate
();
}
public
void
toggleBackground
(
int
commandBoxID
)
{
try
{
commandBoxAccessor
.
toggleBackground
(
commandBoxID
);
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
ToggleBackground
)
.
build
();
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for CommandBox"
+
commandBoxID
);
// Create the request.
CommandBoxRequests
.
CommandBoxRequest
request
=
CommandBoxRequests
.
CommandBoxRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
LOGGER
.
log
(
Level
.
SEVERE
,
"command box not found for "
+
commandBoxID
);
}
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"toggleBackground"
,
"error in parsing response for command box "
+
commandBoxID
);
}
}
public
void
toggleParallel
(
int
commandBoxID
)
{
try
{
commandBoxAccessor
.
toggleParallel
(
commandBoxID
);
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
ToggleParallel
)
.
build
();
// Create the request.
CommandBoxRequests
.
CommandBoxRequest
request
=
CommandBoxRequests
.
CommandBoxRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for CommandBox"
+
commandBoxID
);
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
LOGGER
.
log
(
Level
.
SEVERE
,
"command box not found for "
+
commandBoxID
);
}
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"toggleParallel"
,
"error in parsing response for command box "
+
commandBoxID
);
}
}
public
boolean
isBackground
(
int
commandBoxID
)
{
try
{
return
commandBoxAccessor
.
isBackground
(
commandBoxID
);
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for CommandBox"
+
commandBoxID
);
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
IsBackground
)
.
build
();
// Create the request.
CommandBoxRequests
.
CommandBoxRequest
request
=
CommandBoxRequests
.
CommandBoxRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
LOGGER
.
log
(
Level
.
SEVERE
,
"command box not found for "
+
commandBoxID
);
}
return
response
.
getValue
();
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"isBackground"
,
"error in parsing response for command box "
+
commandBoxID
);
}
return
false
;
}
public
boolean
isParallel
(
int
commandBoxID
)
{
try
{
return
commandBoxAccessor
.
isParallel
(
commandBoxID
);
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for CommandBox"
+
commandBoxID
);
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
IsParallel
)
.
build
();
// Create the request.
CommandBoxRequests
.
CommandBoxRequest
request
=
CommandBoxRequests
.
CommandBoxRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
LOGGER
.
log
(
Level
.
SEVERE
,
"command box not found for "
+
commandBoxID
);
}
return
response
.
getValue
();
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"isParallel"
,
"error in parsing response for command box "
+
commandBoxID
);
}
return
false
;
}
public
ExecutionPhaseState
getExecutionState
(
int
commandBoxID
)
{
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
GetExecutionState
)
.
build
();
// Create the request.
CommandBoxRequests
.
CommandBoxRequest
request
=
CommandBoxRequests
.
CommandBoxRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
ExecutionState
state
=
commandBoxAccessor
.
getExecutionState
(
commandBoxID
);
if
(
state
==
ExecutionState
.
RUNNING
)
{
CommandBoxRequests
.
ExecutionStateResponse
response
=
CommandBoxRequests
.
ExecutionStateResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
LOGGER
.
log
(
Level
.
SEVERE
,
"command box not found for "
+
commandBoxID
);
}
CommandBoxRequests
.
ExecutionStateResponse
.
ExecutionState
state
=
response
.
getState
();
System
.
out
.
println
(
"getExecutionState "
+
commandBoxID
+
" "
+
state
);
if
(
state
==
CommandBoxRequests
.
ExecutionStateResponse
.
ExecutionState
.
RUNNING
)
{
return
ExecutionPhaseState
.
RUNNING
;
}
else
if
(
state
==
ExecutionState
.
PAUSED
)
{
}
else
if
(
state
==
CommandBoxRequests
.
ExecutionStateResponse
.
ExecutionState
.
PAUSED
)
{
return
ExecutionPhaseState
.
PAUSED
;
}
else
if
(
state
==
ExecutionState
.
FINISHED
)
{
}
else
if
(
state
==
CommandBoxRequests
.
ExecutionStateResponse
.
ExecutionState
.
FINISHED
)
{
return
ExecutionPhaseState
.
FINISHED
;
}
return
ExecutionPhaseState
.
CONSTRUCTION
;
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for CommandBox"
+
commandBoxID
);
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"getExecutionState"
,
"error in parsing response for command box "
+
commandBoxID
);
}
return
ExecutionPhaseState
.
CONSTRUCTION
;
}
public
void
setModifiable
(
int
commandBoxID
,
boolean
isModifiable
)
{
try
{
commandBoxAccessor
.
setModifiable
(
commandBoxID
,
isModifiable
);
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
SetModifiable
)
.
build
();
// Create the request.
CommandBoxRequests
.
CommandBoxSetModifiableRequest
request
=
CommandBoxRequests
.
CommandBoxSetModifiableRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
setModifiable
(
isModifiable
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for CommandBox"
+
commandBoxID
);
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
LOGGER
.
log
(
Level
.
SEVERE
,
"command box not found for "
+
commandBoxID
);
}
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"setModifiable"
,
"error in parsing response for command box "
+
commandBoxID
);
}
}
public
boolean
isModifiable
(
int
commandBoxID
)
{
try
{
return
commandBoxAccessor
.
isModifiable
(
commandBoxID
);
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for CommandBox"
+
commandBoxID
);
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
IsModifiable
)
.
build
();
// Create the request.
CommandBoxRequests
.
CommandBoxRequest
request
=
CommandBoxRequests
.
CommandBoxRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
build
();
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
LOGGER
.
log
(
Level
.
SEVERE
,
"command box not found for "
+
commandBoxID
);
}
return
response
.
getValue
();
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"isModifiable"
,
"error in parsing response for command box "
+
commandBoxID
);
}
return
false
;
}
public
void
stop
(
int
commandBoxId
)
{
try
{
commandBoxAccessor
.
stop
(
commandBoxId
);
public
void
stop
(
int
commandBoxID
)
{
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
Stop
)
.
build
();
// Create the request.
CommandBoxRequests
.
CommandBoxRequest
request
=
CommandBoxRequests
.
CommandBoxRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
build
();
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for CommandBox"
+
commandBoxId
);
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
BooleanResponse
response
=
Common
.
BooleanResponse
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
LOGGER
.
log
(
Level
.
SEVERE
,
"command box not found for "
+
commandBoxID
);
}
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"stop"
,
"error in parsing response for command box "
+
commandBoxID
);
}
}
public
int
getProgression
(
int
commandBoxId
)
{
try
{
return
commandBoxAccessor
.
getProgression
(
commandBoxId
);
public
int
getProgression
(
int
commandBoxID
)
{
// Create the message type.
CommandBoxRequests
.
Message
type
=
CommandBoxRequests
.
Message
.
newBuilder
()
.
setType
(
CommandBoxRequests
.
Message
.
Type
.
GetProgression
)
.
build
();
// Create the request.
CommandBoxRequests
.
CommandBoxRequest
request
=
CommandBoxRequests
.
CommandBoxRequest
.
newBuilder
()
.
setCommandBoxID
(
commandBoxID
)
.
build
();
}
catch
(
CommandBoxNotFoundException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"CommandBoxNotFoundException occured for CommandBox"
+
commandBoxId
);
commandBoxRequester
.
sendTwoParts
(
type
.
toByteArray
(),
request
.
toByteArray
());
try
{
Common
.
Int32Response
response
=
Common
.
Int32Response
.
parseFrom
(
commandBoxRequester
.
receive
());
// Test the error.
if
(
response
.
hasError
())
{
LOGGER
.
log
(
Level
.
SEVERE
,
"command box not found for "
+
commandBoxID
);
}
System
.
out
.
println
(
"getProgression "
+
commandBoxID
+
" "
+
response
.
getValue
());
return
response
.
getValue
();
}
catch
(
InvalidProtocolBufferException
e
)
{
LOGGER
.
logp
(
Level
.
WARNING
,
this
.
getClass
().
getName
(),
"getProgression"
,
"error in parsing response for command box "
+
commandBoxID
);
}
return
0
;
}
...
...
src/main/java/fr/ill/ics/nscclient/sessionmanagement/ServerSessionManager.java
View file @
5487902f
...
...
@@ -162,6 +162,8 @@ public class ServerSessionManager {
ConditionManagerAccessor
.
getInstance
(
serverId
).
reset
();
CommandBoxAccessorProxy
.
getInstance
(
serverId
).
reset
();
currentSession
.
logout
();
currentSession
=
null
;
}
...
...
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