Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
RadioObservatory
LOFAR
Commits
5ea3b2ed
Commit
5ea3b2ed
authored
18 years ago
by
Arthur Coolen
Browse files
Options
Downloads
Patches
Plain Diff
BugID: 604
added file upload and download
parent
cf195576
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jOTDBserver.java
+20
-0
20 additions, 0 deletions
...OTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jOTDBserver.java
SAS/OTB/jOTDB2/test/tRemoteFile.java
+61
-0
61 additions, 0 deletions
SAS/OTB/jOTDB2/test/tRemoteFile.java
with
81 additions
and
0 deletions
SAS/OTB/jOTDB2/src/nl/astron/lofar/sas/otb/jotdb2/jOTDBserver.java
+
20
−
0
View file @
5ea3b2ed
...
...
@@ -22,6 +22,8 @@
package
nl.astron.lofar.sas.otb.jotdb2
;
import
java.rmi.registry.*
;
import
java.rmi.server.RMISocketFactory
;
import
nl.astron.lofar.lofarutils.remoteFileAdapter
;
import
nl.astron.lofar.lofarutils.remoteFileInterface
;
import
org.apache.log4j.Logger
;
import
org.apache.log4j.PropertyConfigurator
;
...
...
@@ -36,6 +38,7 @@ public class jOTDBserver {
private
static
jTreeValueAdapter
jTreeValueAdapter
;
private
static
jConverter
jConverterAdaptee
;
private
static
jConverterAdapter
jConverterAdapter
;
private
static
remoteFileAdapter
remoteFileAdapter
;
static
{
...
...
@@ -141,6 +144,23 @@ public class jOTDBserver {
localRegistry
.
rebind
(
jConverterInterface
.
SERVICENAME
,
jConverterAdapter
);
logger
.
info
(
"Published jConverterInterface as service "
+
jConverterInterface
.
SERVICENAME
+
". Ready..."
);
// Export remoteFile
remoteFileAdapter
=
new
remoteFileAdapter
(
remoteFileInterface
.
SERVICENAME
);
//A custom port was specified, export the object using the port specified
if
(
objectPort
!=
0
){
remoteFileAdapter
.
unexportObject
(
remoteFileAdapter
,
true
);
remoteFileAdapter
.
exportObject
(
remoteFileAdapter
,
objectPort
);
}
logger
.
info
(
"jOTDBserver publishing service "
+
remoteFileInterface
.
SERVICENAME
+
" in local registry..."
);
localRegistry
.
rebind
(
remoteFileInterface
.
SERVICENAME
,
remoteFileAdapter
);
logger
.
info
(
"Published remoteFileInterface as service "
+
remoteFileInterface
.
SERVICENAME
+
". Ready..."
);
String
statusmessage
=
"jOTDBserver is ready for incoming calls"
;
if
(
args
.
length
>
4
)
{
Integer
rmiPort
=
new
Integer
(
args
[
4
]);
...
...
This diff is collapsed.
Click to expand it.
SAS/OTB/jOTDB2/test/tRemoteFile.java
0 → 100644
+
61
−
0
View file @
5ea3b2ed
import
java.io.BufferedInputStream
;
import
java.io.BufferedOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.rmi.Naming
;
import
nl.astron.lofar.lofarutils.remoteFileInterface
;
public
class
tRemoteFile
{
public
static
String
RMIRegistryName
=
remoteFileInterface
.
SERVICENAME
;
public
static
void
main
(
String
[]
argv
)
{
if
(
argv
.
length
!=
3
)
{
System
.
out
.
println
(
"Usage: java tRemoteFile fileName machineName machinePort"
);
System
.
out
.
println
(
"Where file is a file on the client."
);
System
.
exit
(
0
);
}
String
aRF
=
"rmi://"
+
argv
[
1
]+
":"
+
argv
[
2
]+
"/"
+
RMIRegistryName
;
try
{
// do the test
System
.
out
.
println
(
"Starting..."
);
remoteFileInterface
fi
=
(
remoteFileInterface
)
Naming
.
lookup
(
aRF
);
System
.
out
.
println
(
"Starting upload"
);
File
aFile
=
new
File
(
argv
[
0
]);
byte
uldata
[]
=
new
byte
[(
int
)
aFile
.
length
()];
System
.
out
.
println
(
"File opened: "
+
aFile
.
getName
()+
" bytesize: "
+
uldata
.
length
);
BufferedInputStream
input
=
new
BufferedInputStream
(
new
FileInputStream
(
aFile
));
input
.
read
(
uldata
,
0
,
uldata
.
length
);
input
.
close
();
if
(
fi
.
uploadFile
(
uldata
,
argv
[
0
]+
".uploaded"
))
{
System
.
out
.
println
(
"upload finished"
);
}
else
{
System
.
out
.
println
(
"upload failed"
);
}
System
.
out
.
println
(
"Starting download"
);
byte
[]
dldata
=
fi
.
downloadFile
(
argv
[
0
]+
".uploaded"
);
File
file
=
new
File
(
argv
[
0
]+
".downloaded"
);
System
.
out
.
println
(
"opening File: "
+
file
.
getName
());
BufferedOutputStream
output
=
new
BufferedOutputStream
(
new
FileOutputStream
(
file
.
getName
()));
System
.
out
.
println
(
"Received buffer length: "
+
dldata
.
length
);
output
.
write
(
dldata
,
0
,
dldata
.
length
);
output
.
flush
();
output
.
close
();
System
.
out
.
println
(
"Download finished"
);
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"FileServer exception: "
+
e
.
getMessage
());
e
.
printStackTrace
();
}
}
}
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