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
Merge requests
!15
Iss1051 data transfer
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Iss1051 data transfer
iss1051-dataTransfer
into
master
Overview
55
Commits
11
Pipelines
0
Changes
35
Closed
Jan Kožusznik
requested to merge
iss1051-dataTransfer
into
master
7 years ago
Overview
20
Commits
11
Pipelines
0
Changes
35
Expand
0
0
Merge request reports
Compare
master
version 11
4443a618
7 years ago
version 10
67f4213f
7 years ago
version 9
a824a71b
7 years ago
version 8
c061348b
7 years ago
version 7
3e64abb4
7 years ago
version 6
4f9de5ad
7 years ago
version 5
11045b48
7 years ago
version 4
afdc6ee4
7 years ago
version 3
e39cb915
7 years ago
version 2
b17dbb69
7 years ago
version 1
0675d0da
7 years ago
master (base)
and
version 4
latest version
4443a618
11 commits,
7 years ago
version 11
4443a618
36 commits,
7 years ago
version 10
67f4213f
35 commits,
7 years ago
version 9
a824a71b
33 commits,
7 years ago
version 8
c061348b
33 commits,
7 years ago
version 7
3e64abb4
32 commits,
7 years ago
version 6
4f9de5ad
31 commits,
7 years ago
version 5
11045b48
30 commits,
7 years ago
version 4
afdc6ee4
27 commits,
7 years ago
version 3
e39cb915
26 commits,
7 years ago
version 2
b17dbb69
25 commits,
7 years ago
version 1
0675d0da
24 commits,
7 years ago
35 files
+
1650
−
538
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
35
Search (e.g. *.vue) (Ctrl+P)
haas-imagej-client/src/main/java/cz/it4i/fiji/haas/data_transfer/PersistentIndex.java
0 → 100644
+
78
−
0
Options
package
cz.it4i.fiji.haas.data_transfer
;
import
java.io.BufferedReader
;
import
java.io.BufferedWriter
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.util.LinkedHashSet
;
import
java.util.Queue
;
import
java.util.Set
;
import
java.util.function.Function
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
PersistentIndex
<
T
>
{
public
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
cz
.
it4i
.
fiji
.
haas
.
data_transfer
.
PersistentIndex
.
class
);
private
Path
workingFile
;
private
Set
<
T
>
files
=
new
LinkedHashSet
<>();
private
Function
<
String
,
T
>
fromString
;
public
PersistentIndex
(
Path
workingFile
,
Function
<
String
,
T
>
fromString
)
throws
IOException
{
this
.
workingFile
=
workingFile
;
this
.
fromString
=
fromString
;
loadFromFile
();
}
public
synchronized
void
storeToFile
()
throws
IOException
{
try
(
BufferedWriter
bw
=
Files
.
newBufferedWriter
(
workingFile
))
{
for
(
T
file
:
files
)
{
bw
.
write
(
file
.
toString
()
+
"\n"
);
}
}
}
public
synchronized
boolean
insert
(
T
file
)
{
return
files
.
add
(
file
);
}
public
synchronized
void
remove
(
T
p
)
{
files
.
remove
(
p
);
}
public
synchronized
void
fillQueue
(
Queue
<
T
>
toUpload
)
{
toUpload
.
addAll
(
files
);
}
public
synchronized
void
clear
()
throws
IOException
{
files
.
clear
();
storeToFile
();
}
public
synchronized
boolean
contains
(
Path
file
)
{
return
files
.
contains
(
file
);
}
private
void
loadFromFile
()
throws
IOException
{
files
.
clear
();
if
(
Files
.
exists
(
workingFile
))
{
try
(
BufferedReader
br
=
Files
.
newBufferedReader
(
workingFile
))
{
String
line
;
while
(
null
!=
(
line
=
br
.
readLine
()))
{
processLine
(
line
);
}
}
}
}
private
void
processLine
(
String
line
)
{
files
.
add
(
fromString
.
apply
(
line
));
}
}
Loading