Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
praxis-core
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
praxis
praxis-core
Commits
2f31fa20
Commit
2f31fa20
authored
14 years ago
by
BIGARET Sebastien
Browse files
Options
Downloads
Patches
Plain Diff
Removed inner class, everything is handled by the main class.
parent
88884200
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/eu/telecom_bretagne/praxis/platform/PlatformToClientBridge.java
+102
-132
102 additions, 132 deletions
...ecom_bretagne/praxis/platform/PlatformToClientBridge.java
with
102 additions
and
132 deletions
src/eu/telecom_bretagne/praxis/platform/PlatformToClientBridge.java
+
102
−
132
View file @
2f31fa20
...
...
@@ -24,38 +24,41 @@ import eu.telecom_bretagne.praxis.core.execution.Result;
import
eu.telecom_bretagne.praxis.core.workflow.WorkflowID
;
import
eu.telecom_bretagne.praxis.server.execution.platform.WorkflowExecutionEngine
;
/**
* @author Sébastien Bigaret
*
*/
public
class
PlatformToClientBridge
{
/**
* This platform forwards the request of its "downstream" server {@code Sd} to a client connected to another,
* "upstream", server {@code Su}. It collaborates with a {@link WorkflowExecutionEngine} to execute workflows
* directly. It also registers itself as a listener of messages sent by the server {@code Su} and takes care of
* forwarding the execution results to its server {@code Sd}.
* @author Sébastien Bigaret
*
*/
public
static
class
Platform
extends
AbstractPlatform
implements
ServerToClientEventListener
public
class
Platform
ToClientBridge
extends
AbstractPlatform
implements
ServerToClientEventListener
{
protected
Client
client
;
protected
HashMap
<
WorkflowID
,
WorkflowID
>
originalWorkflowIDs
=
new
HashMap
<
WorkflowID
,
WorkflowID
>();
public
static
Platform
launchPlatform
(
Client
client
,
Document
configuration
,
String
[]
connection
)
throws
IOException
public
PlatformToClientBridge
(
CommunicationFacade
cnx
,
Document
configuration
,
String
[]
client_connection
)
throws
IOException
{
CommunicationFacade
cnx
=
CommunicationFacade
.
buildConnection
(
"Platform"
,
connection
);
cnx
.
start
();
Platform
p
=
new
Platform
(
client
,
cnx
,
configuration
);
return
p
;
super
(
cnx
,
configuration
);
this
.
client
=
new
Client
();
launchClient
(
client_connection
);
}
p
ublic
Platform
(
Client
client
,
CommunicationFacade
cnx
,
Document
configura
tion
)
p
rotected
void
launchClient
(
String
[]
connection
)
throws
IOExcep
tion
{
super
(
cnx
,
configuration
);
this
.
client
=
client
;
if
(
!
Environment
.
useLooseCredentials
()
)
{
Log
.
log
.
warning
(
"CSLC unset, cannot start client in bridge"
);
throw
new
IOException
(
"Cannot start the client in the bridge"
);
}
String
login
=
PraxisPreferences
.
get
(
"client"
,
Environment
.
getLooseCredentialsConfigurationName
());
client
.
initConnection
(
connection
);
client
.
getConnection
().
addListener
(
this
);
client
.
connectAndWaitAnswer
(
login
,
login
,
false
);
}
@Override
public
void
receivedAuthentificationStatus
(
ServerToClientEvent
event
)
{
...
...
@@ -127,64 +130,31 @@ public class PlatformToClientBridge
originalWorkflowIDs
.
put
(
executionEngine
.
getResult
().
workflowID
(),
executionEngine
.
getOriginalWorkflowID
());
client
.
requestExecution
(
executionEngine
.
getResult
());
}
}
private
Platform
platform
;
private
RemoteComponents
remoteComponents
;
/**
*
* @param downStream
* @param upStream
*/
public
PlatformToClientBridge
(
String
id
,
String
[]
downStream
,
String
[]
upStream
)
throws
IOException
{
Client
client
=
new
Client
();
launchPlatform
(
client
,
id
,
upStream
);
launchClient
(
client
,
downStream
);
}
protected
void
launchPlatform
(
Client
client
,
String
id
,
String
[]
upStream
)
throws
IOException
{
Document
conf
;
conf
=
AbstractPlatform
.
initConfiguration
(
Configuration
.
get
(
"platform."
+
id
));
/* Retrieve the resources declared on the upStream server, and declare them as our resources */
remoteComponents
=
new
RemoteComponents
(
upStream
[
0
],
upStream
[
1
],
Integer
.
parseInt
(
upStream
[
2
]));
// TODO NumberFormatException
remoteComponents
.
init
();
Element
programs
=
conf
.
getRootElement
().
getChild
(
"programs"
);
for
(
String
resource:
remoteComponents
.
getResourceRepository
().
getResources
())
programs
.
addContent
(
new
Element
(
"program"
).
setAttribute
(
"id"
,
resource
));
platform
=
Platform
.
launchPlatform
(
client
,
conf
,
upStream
);
}
protected
void
launchClient
(
Client
client
,
String
[]
connection
)
throws
IOException
{
if
(
!
Environment
.
useLooseCredentials
()
)
{
Log
.
log
.
warning
(
"CSLC unset, cannot start client in bridge"
);
throw
new
IOException
(
"Cannot start the client in the bridge"
);
}
String
login
=
PraxisPreferences
.
get
(
"client"
,
Environment
.
getLooseCredentialsConfigurationName
());
client
.
initConnection
(
connection
);
client
.
getConnection
().
addListener
(
platform
);
client
.
connectAndWaitAnswer
(
login
,
login
,
false
);
}
public
static
void
launch
()
throws
IOException
{
// Get the bridge to launch...
String
bridge_id
=
Configuration
.
get
(
"bridge"
);
// ...and the appropriate connection
// ...and the appropriate connection
s
String
[]
platform_conn
=
Utile
.
serverForString
(
Configuration
.
get
(
"bridge.platform.connection"
));
String
[]
client_conn
=
Utile
.
serverForString
(
Configuration
.
get
(
"bridge.client.connection"
));
if
(
""
.
equals
(
bridge_id
))
return
;
new
PlatformToClientBridge
(
bridge_id
,
client_conn
,
platform_conn
);
Document
conf
;
conf
=
AbstractPlatform
.
initConfiguration
(
Configuration
.
get
(
"platform."
+
bridge_id
));
/* Retrieve the resources declared on the upStream server, and declare them as our resources */
RemoteComponents
remoteComponents
=
new
RemoteComponents
(
platform_conn
[
0
],
platform_conn
[
1
],
Integer
.
parseInt
(
platform_conn
[
2
]));
// TODO NumberFormatException
remoteComponents
.
init
();
Element
programs
=
conf
.
getRootElement
().
getChild
(
"programs"
);
for
(
String
resource:
remoteComponents
.
getResourceRepository
().
getResources
())
programs
.
addContent
(
new
Element
(
"program"
).
setAttribute
(
"id"
,
resource
));
CommunicationFacade
cnx
=
CommunicationFacade
.
buildConnection
(
"Platform"
,
platform_conn
);
cnx
.
start
();
new
PlatformToClientBridge
(
cnx
,
conf
,
client_conn
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment