Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Fix for IT Nexus3939.
Browse files Browse the repository at this point in the history
It happened to me on local full builds, that this IT got "stuck"
and was restarting Nexus over and over again.

If you take a peek at sources, you will see it will restart Nexus as
many times as the number of "cfs" Lucene segments grow over 7. After stopping
build and inspecting workdir, I realized that in my case, Timeline has almost 20
files, but only 3 of them had "cfs" extension.

This fix simply makes "easier" to corrupt Timeline Lucene index (this is what IT actually
tests, Nexus recovering from corrupted timeline) by taking in account any Lucene segment file
_except_ the segment index (that causes other problem then index corruption)
  • Loading branch information
cstamas committed Feb 7, 2012
1 parent 75858db commit c1815e4
Showing 1 changed file with 26 additions and 4 deletions.
Expand Up @@ -18,6 +18,7 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.io.FileUtils;
Expand All @@ -43,15 +44,15 @@ public void oncePerClassSetUp()

stopNexus();

File tl = new File( nexusWorkDir, "timeline/index" );
while ( FileUtils.listFiles( tl, new String[] { "cfs" }, false ).size() < 7 )
final File tl = new File( nexusWorkDir, "timeline/index" );
while ( getTimelineLuceneSegments( tl ).size() < 7 )
{
startNexus();
stopNexus();
}

@SuppressWarnings( "unchecked" )
List<File> cfs = new ArrayList<File>( FileUtils.listFiles( tl, new String[] { "cfs" }, false ) );
List<File> cfs = getTimelineLuceneSegments( tl );
// just delete some files to wreck the index
FileUtils.forceDelete( cfs.get( 0 ) );
FileUtils.forceDelete( cfs.get( 2 ) );
FileUtils.forceDelete( cfs.get( 5 ) );
Expand All @@ -61,6 +62,27 @@ public void oncePerClassSetUp()
}
}

protected List<File> getTimelineLuceneSegments( final File timelineLuceneIndexDirectory )
{
@SuppressWarnings( "unchecked" )
final List<File> luceneFiles =
new ArrayList<File>( FileUtils.listFiles( timelineLuceneIndexDirectory, new String[] { "cfs", "fnm", "fdt",
"fdx", "frm", "frq", "nrm", "prx", "tii", "tis" }, false ) );

// filter it
final Iterator<File> lfi = luceneFiles.iterator();
while ( lfi.hasNext() )
{
final File luceneFile = lfi.next();
if ( luceneFile.isFile() && luceneFile.getName().startsWith( "segments." ) )
{
lfi.remove();
}
}

return luceneFiles;
}

@Test
public void login()
throws Exception
Expand Down

0 comments on commit c1815e4

Please sign in to comment.