Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hpc-workflow-manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FIJI
hpc-workflow-manager
Commits
5ed6b51c
Commit
5ed6b51c
authored
6 years ago
by
Jan Kožusznik
Browse files
Options
Downloads
Patches
Plain Diff
code: format
parent
3baedad1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
haas-java-client/src/main/java/cz/it4i/fiji/haas_java_client/MidlewareTunnel.java
+27
-20
27 additions, 20 deletions
...n/java/cz/it4i/fiji/haas_java_client/MidlewareTunnel.java
with
27 additions
and
20 deletions
haas-java-client/src/main/java/cz/it4i/fiji/haas_java_client/MidlewareTunnel.java
+
27
−
20
View file @
5ed6b51c
...
...
@@ -29,23 +29,28 @@ import cz.it4i.fiji.haas_java_client.proxy.DataTransferWsSoap;
public
class
MidlewareTunnel
implements
Closeable
{
public
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
cz
.
it4i
.
fiji
.
haas_java_client
.
MidlewareTunnel
.
class
);
private
static
final
int
TIMEOUT
=
1000
;
private
static
final
int
DEFAULT_BACKLOG
=
50
;
private
final
long
jobId
;
private
ServerSocket
ss
;
private
final
DataTransferWsSoap
dataTransfer
;
private
Future
<?>
mainFuture
;
private
CountDownLatch
mainLatch
;
private
final
String
ipAddress
;
private
final
String
sessionCode
;
private
final
ExecutorService
executorService
;
private
final
ExecutorService
executorService
;
public
MidlewareTunnel
(
ExecutorService
executorService
,
long
jobId
,
String
hostIp
,
String
sessionCode
)
{
public
MidlewareTunnel
(
ExecutorService
executorService
,
long
jobId
,
String
hostIp
,
String
sessionCode
)
{
this
.
jobId
=
jobId
;
this
.
dataTransfer
=
new
DataTransferWs
().
getDataTransferWsSoap12
();
((
BindingProvider
)
dataTransfer
).
getRequestContext
().
put
(
"javax.xml.ws.client.connectionTimeout"
,
""
+
TIMEOUT
);
...
...
@@ -54,15 +59,16 @@ public class MidlewareTunnel implements Closeable {
this
.
sessionCode
=
sessionCode
;
this
.
executorService
=
executorService
;
}
public
void
open
(
int
port
)
throws
UnknownHostException
,
IOException
{
open
(
0
,
port
);
}
public
void
open
(
int
localport
,
int
port
)
throws
UnknownHostException
,
IOException
{
open
(
localport
,
port
,
DEFAULT_BACKLOG
);
}
public
void
open
(
int
localport
,
int
port
,
int
backlog
)
throws
UnknownHostException
,
IOException
{
public
void
open
(
int
localport
,
int
port
,
int
backlog
)
throws
UnknownHostException
,
IOException
{
if
(
ss
!=
null
)
{
throw
new
IllegalStateException
();
}
...
...
@@ -84,7 +90,7 @@ public class MidlewareTunnel implements Closeable {
}
finally
{
log
.
info
(
"MiddlewareTunnel - interrupted"
);
mainLatch
.
countDown
();
}
});
}
...
...
@@ -122,7 +128,7 @@ public class MidlewareTunnel implements Closeable {
});
connection
.
setServerHandler
(
c
->
readFromMiddleware
(
c
));
connection
.
establish
();
log
.
info
(
"END: doTransfer"
);
}
...
...
@@ -133,7 +139,7 @@ public class MidlewareTunnel implements Closeable {
int
len
;
byte
[]
buffer
=
new
byte
[
4096
];
while
(!
connection
.
isServerClosed
()
&&
-
1
!=
(
len
=
is
.
read
(
buffer
)))
{
if
(
connection
.
isServerClosed
())
{
if
(
connection
.
isServerClosed
())
{
break
;
}
byte
[]
sending
;
...
...
@@ -174,7 +180,7 @@ public class MidlewareTunnel implements Closeable {
byte
[]
received
=
null
;
while
(!
connection
.
isClientClosed
()
&&
null
!=
(
received
=
dataTransfer
.
readDataFromJobNode
(
jobId
,
ipAddress
,
sessionCode
)))
{
if
(
connection
.
isClientClosed
())
{
if
(
connection
.
isClientClosed
())
{
break
;
}
if
(
received
.
length
>
0
)
{
...
...
@@ -200,7 +206,7 @@ public class MidlewareTunnel implements Closeable {
private
final
Socket
socket
;
private
final
Runnable
[]
runnable
=
new
Runnable
[
2
];
private
final
Runnable
[]
runnable
=
new
Runnable
[
2
];
private
final
Future
<?>[]
futures
=
new
Future
[
2
];
...
...
@@ -223,19 +229,19 @@ public class MidlewareTunnel implements Closeable {
public
void
clientClosed
()
{
setClosed
(
FROM_CLIENT
);
}
public
void
serverClosed
()
{
setClosed
(
FROM_SERVER
);
}
public
boolean
isClientClosed
()
{
return
isClosed
(
FROM_CLIENT
);
}
public
boolean
isServerClosed
()
{
return
isClosed
(
FROM_SERVER
);
}
public
void
establish
()
{
CountDownLatch
localLatch
=
new
CountDownLatch
(
2
);
for
(
int
i
=
0
;
i
<
runnable
.
length
;
i
++)
{
...
...
@@ -246,14 +252,15 @@ public class MidlewareTunnel implements Closeable {
return
null
;
});
}
try
{
localLatch
.
await
();
}
catch
(
InterruptedException
e
)
{
stop
(
localLatch
);
Thread
.
currentThread
().
interrupt
();
};
}
;
}
private
void
stop
(
CountDownLatch
localLatch
)
{
...
...
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