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
2fc45134
Commit
2fc45134
authored
7 years ago
by
Jan Kožusznik
Browse files
Options
Downloads
Patches
Plain Diff
code: refactor
parent
079ddc4f
Branches
Branches containing commit
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
+30
-27
30 additions, 27 deletions
...n/java/cz/it4i/fiji/haas_java_client/MidlewareTunnel.java
with
30 additions
and
27 deletions
haas-java-client/src/main/java/cz/it4i/fiji/haas_java_client/MidlewareTunnel.java
+
30
−
27
View file @
2fc45134
...
@@ -39,6 +39,9 @@ public class MidlewareTunnel implements Closeable {
...
@@ -39,6 +39,9 @@ public class MidlewareTunnel implements Closeable {
}
}
public
void
open
(
int
port
)
throws
UnknownHostException
,
IOException
{
public
void
open
(
int
port
)
throws
UnknownHostException
,
IOException
{
if
(
ss
!=
null
)
{
throw
new
IllegalStateException
();
}
ss
=
new
ServerSocket
(
0
,
50
,
InetAddress
.
getByName
(
"localhost"
));
ss
=
new
ServerSocket
(
0
,
50
,
InetAddress
.
getByName
(
"localhost"
));
ss
.
setSoTimeout
(
TIMEOUT
);
ss
.
setSoTimeout
(
TIMEOUT
);
...
@@ -48,7 +51,7 @@ public class MidlewareTunnel implements Closeable {
...
@@ -48,7 +51,7 @@ public class MidlewareTunnel implements Closeable {
public
void
run
()
{
public
void
run
()
{
while
(!
Thread
.
interrupted
()
&&
!
ss
.
isClosed
())
{
while
(!
Thread
.
interrupted
()
&&
!
ss
.
isClosed
())
{
try
(
Socket
soc
=
ss
.
accept
())
{
try
(
Socket
soc
=
ss
.
accept
())
{
doTransfer
(
soc
);
doTransfer
(
soc
,
port
);
}
catch
(
SocketTimeoutException
e
)
{
}
catch
(
SocketTimeoutException
e
)
{
// ignore and check interruption
// ignore and check interruption
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
@@ -58,32 +61,6 @@ public class MidlewareTunnel implements Closeable {
...
@@ -58,32 +61,6 @@ public class MidlewareTunnel implements Closeable {
}
}
}
}
private
void
doTransfer
(
Socket
soc
)
{
TestCommunicationWithNodes
.
log
.
info
(
"START: doTransfer"
);
Thread
helpingThread
=
new
Thread
()
{
@Override
public
void
run
()
{
readFromMiddleware
(
soc
);
}
};
DataTransferMethodExt
transfer
=
dataTransfer
.
getDataTransferMethod
(
ipAddress
,
port
,
jobId
,
sessionCode
);
helpingThread
.
start
();
sendToMiddleware
(
soc
);
TestCommunicationWithNodes
.
log
.
info
(
"endDataTransfer"
);
dataTransfer
.
endDataTransfer
(
transfer
,
sessionCode
);
TestCommunicationWithNodes
.
log
.
info
(
"endDataTransfer - DONE"
);
helpingThread
.
interrupt
();
try
{
helpingThread
.
join
();
}
catch
(
InterruptedException
e
)
{
Thread
.
currentThread
().
interrupt
();
}
TestCommunicationWithNodes
.
log
.
info
(
"END: doTransfer"
);
}
};
};
thread
.
start
();
thread
.
start
();
}
}
...
@@ -107,6 +84,32 @@ public class MidlewareTunnel implements Closeable {
...
@@ -107,6 +84,32 @@ public class MidlewareTunnel implements Closeable {
return
ss
.
getLocalPort
();
return
ss
.
getLocalPort
();
}
}
private
void
doTransfer
(
Socket
soc
,
int
port
)
{
TestCommunicationWithNodes
.
log
.
info
(
"START: doTransfer"
);
Thread
helpingThread
=
new
Thread
()
{
@Override
public
void
run
()
{
readFromMiddleware
(
soc
);
}
};
DataTransferMethodExt
transfer
=
dataTransfer
.
getDataTransferMethod
(
ipAddress
,
port
,
jobId
,
sessionCode
);
helpingThread
.
start
();
sendToMiddleware
(
soc
);
TestCommunicationWithNodes
.
log
.
info
(
"endDataTransfer"
);
dataTransfer
.
endDataTransfer
(
transfer
,
sessionCode
);
TestCommunicationWithNodes
.
log
.
info
(
"endDataTransfer - DONE"
);
helpingThread
.
interrupt
();
try
{
helpingThread
.
join
();
}
catch
(
InterruptedException
e
)
{
Thread
.
currentThread
().
interrupt
();
}
TestCommunicationWithNodes
.
log
.
info
(
"END: doTransfer"
);
}
private
void
sendToMiddleware
(
Socket
soc
)
{
private
void
sendToMiddleware
(
Socket
soc
)
{
TestCommunicationWithNodes
.
log
.
info
(
"START: sendToMiddleware"
);
TestCommunicationWithNodes
.
log
.
info
(
"START: sendToMiddleware"
);
try
{
try
{
...
...
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