mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
MNT-16709 : Metadata extraction on 200MB PDF file causes large heap utilization
- added concurrent extraction limit - added max document size limit git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@131709 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||
* %%
|
||||
* This file is part of the Alfresco software.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.repo.content.metadata;
|
||||
|
||||
import java.io.File;
|
||||
@@ -48,8 +48,6 @@ public class PoiMetadataExtracterTest extends AbstractMetadataExtracterTest
|
||||
{
|
||||
private static final int MINIMAL_EXPECTED_PROPERTIES_AMOUNT = 3;
|
||||
|
||||
private static final int IGNORABLE_TIMEOUT = -1;
|
||||
|
||||
// private static final int TIMEOUT_FOR_QUICK_EXTRACTION = 2000;
|
||||
|
||||
private static final int DEFAULT_FOOTNOTES_LIMIT = 50;
|
||||
@@ -67,6 +65,9 @@ public class PoiMetadataExtracterTest extends AbstractMetadataExtracterTest
|
||||
|
||||
|
||||
private PoiMetadataExtracter extracter;
|
||||
|
||||
private Long extractionTimeWithDefaultFootnotesLimit;
|
||||
private Long extractionTimeWithLargeFootnotesLimit;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
@@ -245,7 +246,7 @@ public class PoiMetadataExtracterTest extends AbstractMetadataExtracterTest
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testFootnotesLimitParameterUsing() throws Exception
|
||||
public void testFootnotesLimitParameterUsingDefault() throws Exception
|
||||
{
|
||||
PoiMetadataExtracter extractor = (PoiMetadataExtracter) getExtracter();
|
||||
|
||||
@@ -256,23 +257,42 @@ public class PoiMetadataExtracterTest extends AbstractMetadataExtracterTest
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
long startTime = System.currentTimeMillis();
|
||||
extractor.extract(sourceReader, properties);
|
||||
long extractionTimeWithDefaultFootnotesLimit = System.currentTimeMillis() - startTime;
|
||||
extractionTimeWithDefaultFootnotesLimit = System.currentTimeMillis() - startTime;
|
||||
|
||||
assertExtractedProperties(properties);
|
||||
assertFalse("Reader was not closed", sourceReader.isChannelOpen());
|
||||
if (extractionTimeWithLargeFootnotesLimit != null)
|
||||
{
|
||||
assertTrue("The second metadata extraction operation must be longer!", extractionTimeWithLargeFootnotesLimit > extractionTimeWithDefaultFootnotesLimit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test for MNT-577: Alfresco is running 100% CPU for over 10 minutes while extracting metadata for Word office document
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testFootnotesLimitParameterUsingLarge() throws Exception
|
||||
{
|
||||
PoiMetadataExtracter extractor = (PoiMetadataExtracter) getExtracter();
|
||||
|
||||
File sourceFile = AbstractContentTransformerTest.loadNamedQuickTestFile(PROBLEM_FOOTNOTES_DOCUMENT_NAME);
|
||||
ContentReader sourceReader = new FileContentReader(sourceFile);
|
||||
sourceReader.setMimetype(MimetypeMap.MIMETYPE_OPENXML_WORDPROCESSING);
|
||||
|
||||
// Just let the extractor do the job...
|
||||
configureExtractorLimits(extractor, ALL_MIMETYPES_FILTER, IGNORABLE_TIMEOUT);
|
||||
extractor.setPoiFootnotesLimit(LARGE_FOOTNOTES_LIMIT);
|
||||
extractor.afterPropertiesSet();
|
||||
properties = new HashMap<QName, Serializable>();
|
||||
startTime = System.currentTimeMillis();
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
long startTime = System.currentTimeMillis();
|
||||
extractor.extract(sourceReader, properties);
|
||||
long extractionTimeWithLargeFootnotesLimit = System.currentTimeMillis() - startTime;
|
||||
extractionTimeWithLargeFootnotesLimit = System.currentTimeMillis() - startTime;
|
||||
|
||||
assertExtractedProperties(properties);
|
||||
assertTrue("The second metadata extraction operation must be longer!", extractionTimeWithLargeFootnotesLimit > extractionTimeWithDefaultFootnotesLimit);
|
||||
assertFalse("Reader was not closed", sourceReader.isChannelOpen());
|
||||
if (extractionTimeWithDefaultFootnotesLimit != null)
|
||||
{
|
||||
assertTrue("The second metadata extraction operation must be longer!", extractionTimeWithLargeFootnotesLimit > extractionTimeWithDefaultFootnotesLimit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user