Navigation Menu

Skip to content

Commit

Permalink
pool: Kill sweeper thread on shutdown
Browse files Browse the repository at this point in the history
Target: trunk
Require-notes: no
Require-book: no
Acked-by: Paul Millar <paul.millar@desy.de>
Patch: https://rb.dcache.org/r/7397/
  • Loading branch information
gbehrmann committed Oct 27, 2014
1 parent 4a0c600 commit d934502
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Expand Up @@ -56,6 +56,7 @@ protected SimpleDateFormat initialValue()
private Repository _repository;

private Account _account;
private Thread _thread;

public SpaceSweeper2()
{
Expand All @@ -70,7 +71,18 @@ public void setRepository(Repository repository)
public void setAccount(Account account)
{
_account = account;
new Thread(this, "sweeper").start();
}

public void start()
{
_thread = new Thread(this, "sweeper");
_thread.start();
}

public void stop() throws InterruptedException
{
_thread.interrupt();
_thread.join(1000);
}

/**
Expand Down
Expand Up @@ -106,7 +106,8 @@
<constructor-arg value="${pool.path}"/>
</bean>

<bean id="sweeper" class="${pool.plugins.sweeper}">
<bean id="sweeper" class="${pool.plugins.sweeper}"
init-method="start" destroy-method="stop">
<description>Pool garbage collector</description>
<property name="repository" ref="rep"/>
<property name="account" ref="account"/>
Expand Down
Expand Up @@ -193,9 +193,6 @@ private void initRepository()
repository.addListener(this);
repository.setSpaceSweeperPolicy(sweeper);
repository.setMaxDiskSpace(5120);

sweeper.setAccount(account);
sweeper.setRepository(repository);
}

@Before
Expand Down Expand Up @@ -263,12 +260,17 @@ public void setUp()
/* Create repository.
*/
initRepository();

sweeper.setAccount(account);
sweeper.setRepository(repository);
sweeper.start();
}

@After
public void tearDown()
throws InterruptedException
{
sweeper.stop();
repository.shutdown();
metaDataStore.close();
if (root != null) {
Expand Down

0 comments on commit d934502

Please sign in to comment.