Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
2a5ffb81
Commit
2a5ffb81
authored
12 years ago
by
kohleman
Browse files
Options
Downloads
Patches
Plain Diff
Make file operations monitored in SegmentedStoreUtils.
SVN: 26552
parent
c1cfb705
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/SegmentedStoreUtils.java
+25
-15
25 additions, 15 deletions
...openbis/dss/generic/shared/utils/SegmentedStoreUtils.java
with
25 additions
and
15 deletions
datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/SegmentedStoreUtils.java
+
25
−
15
View file @
2a5ffb81
...
...
@@ -32,12 +32,15 @@ import java.util.regex.Pattern;
import
org.apache.commons.io.FileUtils
;
import
ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel
;
import
ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked
;
import
ch.systemsx.cisd.base.utilities.OSUtilities
;
import
ch.systemsx.cisd.common.exceptions.ConfigurationFailureException
;
import
ch.systemsx.cisd.common.exceptions.EnvironmentFailureException
;
import
ch.systemsx.cisd.common.exceptions.UserFailureException
;
import
ch.systemsx.cisd.common.filesystem.FileOperations
;
import
ch.systemsx.cisd.common.filesystem.FileUtilities
;
import
ch.systemsx.cisd.common.filesystem.HostAwareFile
;
import
ch.systemsx.cisd.common.filesystem.IFileOperations
;
import
ch.systemsx.cisd.common.filesystem.IFreeSpaceProvider
;
import
ch.systemsx.cisd.common.filesystem.rsync.RsyncCopier
;
import
ch.systemsx.cisd.common.logging.ISimpleLogger
;
...
...
@@ -86,7 +89,7 @@ public class SegmentedStoreUtils
@Override
public
boolean
accept
(
File
pathname
)
{
if
(
pathname
.
isDirectory
()
==
false
)
if
(
FileOperations
.
getMonitoredInstanceForCurrentThread
()
.
isDirectory
(
pathname
)
==
false
)
{
return
false
;
}
...
...
@@ -100,7 +103,9 @@ public class SegmentedStoreUtils
*/
public
static
File
[]
getShares
(
File
storeRootDir
)
{
File
[]
files
=
storeRootDir
.
listFiles
(
FILTER_ON_SHARES
);
File
[]
files
=
FileOperations
.
getMonitoredInstanceForCurrentThread
().
listFiles
(
storeRootDir
,
FILTER_ON_SHARES
);
if
(
files
==
null
)
{
throw
new
ConfigurationFailureException
(
...
...
@@ -116,12 +121,13 @@ public class SegmentedStoreUtils
*/
public
static
String
findIncomingShare
(
File
incomingFolder
,
File
storeRoot
,
ISimpleLogger
logger
)
{
if
(
incomingFolder
.
isDirectory
()
==
false
)
final
IFileOperations
fileOp
=
FileOperations
.
getMonitoredInstanceForCurrentThread
();
if
(
fileOp
.
isDirectory
(
incomingFolder
)
==
false
)
{
throw
new
ConfigurationFailureException
(
"Incoming folder does not exist or is not a folder: "
+
incomingFolder
);
}
if
(
storeRoot
.
isDirectory
()
==
false
)
if
(
fileOp
.
isDirectory
(
storeRoot
)
==
false
)
{
throw
new
ConfigurationFailureException
(
"Store root does not exist or is not a folder: "
+
storeRoot
);
...
...
@@ -129,8 +135,8 @@ public class SegmentedStoreUtils
File
testFile
=
new
File
(
incomingFolder
,
".DDS_TEST"
);
try
{
testF
ile
.
createNewFile
();
}
catch
(
IOException
ex
)
f
ile
Op
.
createNewFile
(
testFile
);
}
catch
(
IOException
Unchecked
ex
)
{
throw
new
ConfigurationFailureException
(
"Couldn't create a test file in the following incoming folder: "
...
...
@@ -216,7 +222,8 @@ public class SegmentedStoreUtils
}
else
{
File
dataSetInStore
=
new
File
(
share
.
getShare
(),
dataSet
.
getDataSetLocation
());
if
(
dataSetInStore
.
exists
())
if
(
FileOperations
.
getMonitoredInstanceForCurrentThread
()
.
exists
(
dataSetInStore
))
{
if
(
dataSet
.
getDataSetSize
()
==
null
)
{
...
...
@@ -406,7 +413,7 @@ public class SegmentedStoreUtils
File
source
,
File
destinationRoot
,
File
destination
,
IChecksumProvider
checksumProvider
)
{
assertSameName
(
source
,
destination
);
if
(
source
.
isFile
())
if
(
FileOperations
.
getMonitoredInstanceForCurrentThread
()
.
isFile
(
source
))
{
assertFile
(
destination
);
return
assertSameSizeAndCheckSum
(
dataSetCode
,
sourceRoot
,
source
,
destinationRoot
,
...
...
@@ -443,8 +450,9 @@ public class SegmentedStoreUtils
private
static
long
assertSameSizeAndCheckSum
(
String
dataSetCode
,
File
sourceRoot
,
File
source
,
File
destinationRoot
,
File
destination
,
IChecksumProvider
checksumProvider
)
{
long
sourceSize
=
source
.
length
();
long
destinationSize
=
destination
.
length
();
final
IFileOperations
fileOp
=
FileOperations
.
getMonitoredInstanceForCurrentThread
();
long
sourceSize
=
fileOp
.
length
(
source
);
long
destinationSize
=
fileOp
.
length
(
destination
);
if
(
sourceSize
!=
destinationSize
)
{
throw
new
EnvironmentFailureException
(
"Destination file '"
...
...
@@ -501,11 +509,12 @@ public class SegmentedStoreUtils
private
static
void
assertFile
(
File
file
)
{
if
(
file
.
exists
()
==
false
)
final
IFileOperations
fileOp
=
FileOperations
.
getMonitoredInstanceForCurrentThread
();
if
(
fileOp
.
exists
(
file
)
==
false
)
{
throw
new
EnvironmentFailureException
(
"File does not exist: "
+
file
.
getAbsolutePath
());
}
if
(
file
.
isFile
()
==
false
)
if
(
file
Op
.
isFile
(
file
)
==
false
)
{
throw
new
EnvironmentFailureException
(
"File is a directory: "
+
file
.
getAbsolutePath
());
}
...
...
@@ -513,12 +522,13 @@ public class SegmentedStoreUtils
private
static
void
assertDirectory
(
File
file
)
{
if
(
file
.
exists
()
==
false
)
final
IFileOperations
fileOp
=
FileOperations
.
getMonitoredInstanceForCurrentThread
();
if
(
fileOp
.
exists
(
file
)
==
false
)
{
throw
new
EnvironmentFailureException
(
"Directory does not exist: "
+
file
.
getAbsolutePath
());
}
if
(
file
.
isDirectory
()
==
false
)
if
(
file
Op
.
isDirectory
(
file
)
==
false
)
{
throw
new
EnvironmentFailureException
(
"Directory is a file: "
+
file
.
getAbsolutePath
());
}
...
...
@@ -526,7 +536,7 @@ public class SegmentedStoreUtils
private
static
File
[]
getFiles
(
File
file
)
{
File
[]
files
=
f
ile
.
listFiles
();
File
[]
files
=
F
ile
Operations
.
getMonitoredInstanceForCurrentThread
()
.
listFiles
(
file
);
Arrays
.
sort
(
files
);
return
files
;
}
...
...
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