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
ce591b53
Commit
ce591b53
authored
13 years ago
by
cramakri
Browse files
Options
Downloads
Patches
Plain Diff
MINOR: Fixed warning, reformatted
SVN: 22984
parent
fb0c30ee
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
datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/plugins/SimpleShufflingTest.java
+47
-29
47 additions, 29 deletions
.../systemsx/cisd/etlserver/plugins/SimpleShufflingTest.java
with
47 additions
and
29 deletions
datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/plugins/SimpleShufflingTest.java
+
47
−
29
View file @
ce591b53
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
package
ch.systemsx.cisd.etlserver.plugins
;
package
ch.systemsx.cisd.etlserver.plugins
;
import
static
org
.
apache
.
commons
.
io
.
FileUtils
.
ONE_MB
;
import
static
org
.
apache
.
commons
.
io
.
FileUtils
.
ONE_MB
;
import
java.io.File
;
import
java.io.File
;
...
@@ -54,20 +53,19 @@ import ch.systemsx.cisd.openbis.generic.shared.Constants;
...
@@ -54,20 +53,19 @@ import ch.systemsx.cisd.openbis.generic.shared.Constants;
import
ch.systemsx.cisd.openbis.generic.shared.dto.SimpleDataSetInformationDTO
;
import
ch.systemsx.cisd.openbis.generic.shared.dto.SimpleDataSetInformationDTO
;
/**
/**
*
*
* @author Franz-Josef Elmer
* @author Franz-Josef Elmer
*/
*/
@Friend
(
toClasses
=
SimpleShuffling
.
class
)
@Friend
(
toClasses
=
SimpleShuffling
.
class
)
public
class
SimpleShufflingTest
extends
AbstractFileSystemTestCase
public
class
SimpleShufflingTest
extends
AbstractFileSystemTestCase
{
{
private
static
final
String
DSS_CODE
=
"dss1"
;
private
static
final
String
DSS_CODE
=
"dss1"
;
private
static
final
String
STORE_PATH
=
"01/02/03/"
;
private
static
final
String
STORE_PATH
=
"01/02/03/"
;
private
static
final
class
MockSpaceProvider
implements
IFreeSpaceProvider
private
static
final
class
MockSpaceProvider
implements
IFreeSpaceProvider
{
{
private
final
Map
<
File
,
List
<
Long
>>
freeSpace
=
new
HashMap
<
File
,
List
<
Long
>>();
private
final
Map
<
File
,
List
<
Long
>>
freeSpace
=
new
HashMap
<
File
,
List
<
Long
>>();
void
addFreeSpaceExpectationFor
(
Share
share
,
long
valueInKb
)
void
addFreeSpaceExpectationFor
(
Share
share
,
long
valueInKb
)
{
{
List
<
Long
>
list
=
freeSpace
.
get
(
share
.
getShare
());
List
<
Long
>
list
=
freeSpace
.
get
(
share
.
getShare
());
...
@@ -78,8 +76,7 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
...
@@ -78,8 +76,7 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
}
}
list
.
add
(
valueInKb
);
list
.
add
(
valueInKb
);
}
}
@SuppressWarnings
(
"null"
)
public
long
freeSpaceKb
(
HostAwareFile
path
)
throws
IOException
public
long
freeSpaceKb
(
HostAwareFile
path
)
throws
IOException
{
{
File
file
=
path
.
getFile
();
File
file
=
path
.
getFile
();
...
@@ -88,7 +85,7 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
...
@@ -88,7 +85,7 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
assertFalse
(
"Unexpected invocation for file "
+
file
,
list
.
isEmpty
());
assertFalse
(
"Unexpected invocation for file "
+
file
,
list
.
isEmpty
());
return
list
.
remove
(
0
);
return
list
.
remove
(
0
);
}
}
void
assertIsSatiesfied
()
void
assertIsSatiesfied
()
{
{
Set
<
Entry
<
File
,
List
<
Long
>>>
entrySet
=
freeSpace
.
entrySet
();
Set
<
Entry
<
File
,
List
<
Long
>>>
entrySet
=
freeSpace
.
entrySet
();
...
@@ -99,16 +96,25 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
...
@@ -99,16 +96,25 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
}
}
}
}
}
}
private
MockSpaceProvider
spaceProvider
;
private
MockSpaceProvider
spaceProvider
;
private
Mockery
context
;
private
Mockery
context
;
private
IEncapsulatedOpenBISService
service
;
private
IEncapsulatedOpenBISService
service
;
private
IDataSetMover
dataSetMover
;
private
IDataSetMover
dataSetMover
;
private
ISimpleLogger
logger
;
private
ISimpleLogger
logger
;
private
SimpleShuffling
balancer
;
private
SimpleShuffling
balancer
;
private
File
store
;
private
File
store
;
private
EagerShufflingTask
eagerShufflingTask
;
private
EagerShufflingTask
eagerShufflingTask
;
private
IShareIdManager
shareIdManager
;
private
IShareIdManager
shareIdManager
;
private
IConfigProvider
configProvider
;
private
IConfigProvider
configProvider
;
@BeforeMethod
@BeforeMethod
...
@@ -123,8 +129,10 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
...
@@ -123,8 +129,10 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
logger
=
context
.
mock
(
ISimpleLogger
.
class
);
logger
=
context
.
mock
(
ISimpleLogger
.
class
);
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
SimpleShuffling
.
MINIMUM_FREE_SPACE_KEY
,
"2"
);
properties
.
setProperty
(
SimpleShuffling
.
MINIMUM_FREE_SPACE_KEY
,
"2"
);
properties
.
setProperty
(
EagerShufflingTask
.
SHARE_FINDER_KEY
+
".class"
,
SimpleShufflingShareFinder
.
class
.
getName
());
properties
.
setProperty
(
EagerShufflingTask
.
SHARE_FINDER_KEY
+
".class"
,
properties
.
setProperty
(
EagerShufflingTask
.
SHARE_FINDER_KEY
+
"."
+
SimpleShufflingShareFinder
.
MINIMUM_FREE_SPACE_KEY
,
"2"
);
SimpleShufflingShareFinder
.
class
.
getName
());
properties
.
setProperty
(
EagerShufflingTask
.
SHARE_FINDER_KEY
+
"."
+
SimpleShufflingShareFinder
.
MINIMUM_FREE_SPACE_KEY
,
"2"
);
store
=
new
File
(
workingDirectory
,
"store"
);
store
=
new
File
(
workingDirectory
,
"store"
);
store
.
mkdirs
();
store
.
mkdirs
();
File
ds1
=
new
File
(
store
,
"1/"
+
STORE_PATH
+
"ds1"
);
File
ds1
=
new
File
(
store
,
"1/"
+
STORE_PATH
+
"ds1"
);
...
@@ -142,7 +150,7 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
...
@@ -142,7 +150,7 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
{
{
allowing
(
configProvider
).
getDataStoreCode
();
allowing
(
configProvider
).
getDataStoreCode
();
will
(
returnValue
(
DSS_CODE
));
will
(
returnValue
(
DSS_CODE
));
allowing
(
configProvider
).
getStoreRoot
();
allowing
(
configProvider
).
getStoreRoot
();
will
(
returnValue
(
store
));
will
(
returnValue
(
store
));
}
}
...
@@ -153,7 +161,7 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
...
@@ -153,7 +161,7 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
logger
);
logger
);
balancer
=
new
SimpleShuffling
(
properties
,
eagerShufflingTask
);
balancer
=
new
SimpleShuffling
(
properties
,
eagerShufflingTask
);
}
}
@AfterMethod
@AfterMethod
public
void
afterMethod
(
Method
method
)
public
void
afterMethod
(
Method
method
)
{
{
...
@@ -206,35 +214,45 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
...
@@ -206,35 +214,45 @@ public class SimpleShufflingTest extends AbstractFileSystemTestCase
{
{
allowing
(
service
).
listDataSets
();
allowing
(
service
).
listDataSets
();
will
(
returnValue
(
Arrays
.
asList
(
ds1
,
ds2
,
ds3
,
ds4
)));
will
(
returnValue
(
Arrays
.
asList
(
ds1
,
ds2
,
ds3
,
ds4
)));
one
(
logger
).
log
(
LogLevel
.
INFO
,
"BEGIN Computing number of data sets to be moved for share 1"
);
one
(
logger
).
log
(
LogLevel
.
INFO
,
one
(
logger
).
log
(
LogLevel
.
INFO
,
"\tSpace needed to free: 1994752 bytes (1948.00 kB, 1.90 MB)"
);
"BEGIN Computing number of data sets to be moved for share 1"
);
one
(
logger
).
log
(
LogLevel
.
INFO
,
"\tSpace needed to free: 1994752 bytes (1948.00 kB, 1.90 MB)"
);
one
(
logger
).
log
(
LogLevel
.
INFO
,
"\tInspecting 3 data sets."
);
one
(
logger
).
log
(
LogLevel
.
INFO
,
"\tInspecting 3 data sets."
);
one
(
logger
).
log
(
LogLevel
.
INFO
,
"END Computing number of data sets to move for share 1"
);
one
(
logger
).
log
(
LogLevel
.
INFO
,
one
(
logger
).
log
(
LogLevel
.
INFO
,
"\t2 data sets to move, available space : 102500"
);
"END Computing number of data sets to move for share 1"
);
one
(
logger
).
log
(
LogLevel
.
INFO
,
"\t2 data sets to move, available space : 102500"
);
one
(
shareIdManager
).
getShareId
(
ds3
.
getDataSetCode
());
one
(
shareIdManager
).
getShareId
(
ds3
.
getDataSetCode
());
will
(
returnValue
(
ds3
.
getDataSetShareId
()));
will
(
returnValue
(
ds3
.
getDataSetShareId
()));
one
(
dataSetMover
).
moveDataSetToAnotherShare
(
new
File
(
share1
.
getShare
(),
STORE_PATH
+
"ds3"
),
share3
.
getShare
(),
logger
);
one
(
dataSetMover
).
moveDataSetToAnotherShare
(
one
(
logger
).
log
(
LogLevel
.
INFO
,
"Data set ds3 successfully moved from share 1 to 3."
);
new
File
(
share1
.
getShare
(),
STORE_PATH
+
"ds3"
),
share3
.
getShare
(),
logger
);
one
(
logger
).
log
(
LogLevel
.
INFO
,
"Data set ds3 successfully moved from share 1 to 3."
);
one
(
logger
).
log
(
LogLevel
.
INFO
,
"All 1 data sets should be moved for share 2"
);
one
(
logger
).
log
(
LogLevel
.
INFO
,
"All 1 data sets should be moved for share 2"
);
one
(
shareIdManager
).
getShareId
(
ds2
.
getDataSetCode
());
one
(
shareIdManager
).
getShareId
(
ds2
.
getDataSetCode
());
will
(
returnValue
(
ds2
.
getDataSetShareId
()));
will
(
returnValue
(
ds2
.
getDataSetShareId
()));
one
(
dataSetMover
).
moveDataSetToAnotherShare
(
new
File
(
share1
.
getShare
(),
STORE_PATH
+
"ds2"
),
share4
.
getShare
(),
logger
);
one
(
dataSetMover
).
moveDataSetToAnotherShare
(
one
(
logger
).
log
(
LogLevel
.
INFO
,
"Data set ds2 successfully moved from share 1 to 4."
);
new
File
(
share1
.
getShare
(),
STORE_PATH
+
"ds2"
),
share4
.
getShare
(),
logger
);
one
(
logger
).
log
(
LogLevel
.
INFO
,
"Data set ds2 successfully moved from share 1 to 4."
);
one
(
logger
).
log
(
LogLevel
.
WARN
,
"No share found for shuffling data set ds4."
);
one
(
logger
).
log
(
LogLevel
.
WARN
,
"No share found for shuffling data set ds4."
);
}
}
});
});
balancer
.
shuffleDataSets
(
Arrays
.
asList
(
share1
,
share2
),
balancer
.
shuffleDataSets
(
Arrays
.
asList
(
share1
,
share2
),
Arrays
.
asList
(
share1
,
share2
,
share3
,
share4
),
service
,
dataSetMover
,
logger
);
Arrays
.
asList
(
share1
,
share2
,
share3
,
share4
),
service
,
dataSetMover
,
logger
);
spaceProvider
.
assertIsSatiesfied
();
spaceProvider
.
assertIsSatiesfied
();
}
}
private
SimpleDataSetInformationDTO
dataSet
(
String
code
,
String
shareId
,
long
size
)
private
SimpleDataSetInformationDTO
dataSet
(
String
code
,
String
shareId
,
long
size
)
{
{
SimpleDataSetInformationDTO
dataSet
=
new
SimpleDataSetInformationDTO
();
SimpleDataSetInformationDTO
dataSet
=
new
SimpleDataSetInformationDTO
();
...
...
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