Skip to content

Commit

Permalink
Fix data engine temp folder housekeeping issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mwu authored and zhiqiangqian committed Jul 22, 2014
1 parent 714c4ba commit 8fcee48
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
package org.eclipse.birt.data.aggregation.impl.rank;

import java.io.File;
import java.io.IOException;

import org.eclipse.birt.data.aggregation.impl.RunningAccumulator;
import org.eclipse.birt.data.engine.api.DataEngineThreadLocal;
import org.eclipse.birt.data.engine.api.ICloseListener;
import org.eclipse.birt.data.engine.cache.BasicCachedArray;
import org.eclipse.birt.data.engine.core.DataException;
import org.eclipse.birt.data.engine.core.security.FileSecurity;
Expand All @@ -24,7 +26,8 @@
* The most common part of all Top and Bottom accumulator.
*
*/
public abstract class BaseTopBottomAccumulator extends RunningAccumulator {
public abstract class BaseTopBottomAccumulator extends RunningAccumulator implements ICloseListener
{

//
protected BasicCachedListExt cachedValues;
Expand Down Expand Up @@ -55,6 +58,7 @@ public BaseTopBottomAccumulator( )
+ File.separator;
}
targetValue = new BasicCachedArray( tempDir, 0 );
DataEngineThreadLocal.getInstance( ).getCloseListener( ).add( this );
}

/*
Expand All @@ -67,7 +71,7 @@ public void start( ) throws DataException
passNo++;

if (passNo == 1) {
cachedValues = new BasicCachedListExt(tempDir);
cachedValues = new BasicCachedListExt( tempDir );
N = -1;
}
else
Expand Down Expand Up @@ -173,24 +177,20 @@ private Boolean populateValue( )
* @return
*/
protected abstract int adjustNValue( double N );

/*
* (non-Javadoc)
* @see org.eclipse.birt.data.engine.api.aggregation.Accumulator#finish()
* @see org.eclipse.birt.data.engine.api.ICloseListener#close()
*/
public void finish( )
public void close( ) throws IOException
{
//the calculation has been finish, so we can release the resources
if( this.passNo >1 )
File tempFile = new File( tempDir );
if ( !FileSecurity.fileExist( tempFile )
|| !FileSecurity.fileIsDirectory( tempFile ) )
{
File tempFile = new File( tempDir );
if ( !FileSecurity.fileExist( tempFile )
|| !FileSecurity.fileIsDirectory( tempFile ) )
{
return;
}
deleteDirectory( tempFile );
return;
}
deleteDirectory( tempFile );
}

/**
Expand Down

0 comments on commit 8fcee48

Please sign in to comment.