use of org.alfresco.repo.node.StoreArchiveMap in project alfresco-repository by Alfresco.
the class ArchiveAndRestoreTest method testArchiveVsDeletePerformance.
/**
* Attempt to measure how much archiving affects the deletion performance.
*/
public void testArchiveVsDeletePerformance() throws Exception {
// Start by deleting the node structure and then recreating it.
// Only measure the delete speed
int iterations = 100;
long cumulatedArchiveTimeNs = 0;
long cumulatedRestoreTimeNs = 0;
for (int i = 0; i < iterations; i++) {
// timed delete
long start = System.nanoTime();
nodeService.deleteNode(b);
long end = System.nanoTime();
cumulatedArchiveTimeNs += (end - start);
// flush
// AlfrescoTransactionSupport.flush();
// now restore
start = System.nanoTime();
nodeService.restoreNode(b_, null, null, null);
end = System.nanoTime();
cumulatedRestoreTimeNs += (end - start);
}
double averageArchiveTimeMs = (double) cumulatedArchiveTimeNs / 1E6 / (double) iterations;
double averageRestoreTimeMs = (double) cumulatedRestoreTimeNs / 1E6 / (double) iterations;
System.out.println("Average archive time: " + averageArchiveTimeMs + " ms");
System.out.println("Average restore time: " + averageRestoreTimeMs + " ms");
// Now force full deletions and creations
StoreArchiveMap archiveMap = (StoreArchiveMap) ctx.getBean("storeArchiveMap");
archiveMap.clear();
long cumulatedDeleteTimeNs = 0;
long cumulatedCreateTimeNs = 0;
for (int i = 0; i < iterations; i++) {
// timed delete
long start = System.nanoTime();
nodeService.deleteNode(b);
long end = System.nanoTime();
cumulatedDeleteTimeNs += (end - start);
// delete 'a' as well
nodeService.deleteNode(a);
// now rebuild
start = System.nanoTime();
createNodeStructure();
end = System.nanoTime();
cumulatedCreateTimeNs += (end - start);
}
double averageDeleteTimeMs = (double) cumulatedDeleteTimeNs / 1E6 / (double) iterations;
double averageCreateTimeMs = (double) cumulatedCreateTimeNs / 1E6 / (double) iterations;
System.out.println("Average delete time: " + averageDeleteTimeMs + " ms");
System.out.println("Average create time: " + averageCreateTimeMs + " ms");
}
use of org.alfresco.repo.node.StoreArchiveMap in project alfresco-repository by Alfresco.
the class ArchiveAndRestoreTest method setUp.
@Override
public void setUp() throws Exception {
ctx = ApplicationContextHelper.getApplicationContext();
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
nodeArchiveService = (NodeArchiveService) ctx.getBean("nodeArchiveService");
nodeService = serviceRegistry.getNodeService();
permissionService = serviceRegistry.getPermissionService();
authenticationService = serviceRegistry.getAuthenticationService();
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
ownableService = (OwnableService) ctx.getBean("ownableService");
transactionService = serviceRegistry.getTransactionService();
DictionaryDAO dictionaryDao = (DictionaryDAO) ctx.getBean("dictionaryDAO");
ClassLoader cl = ArchiveAndRestoreTest.class.getClassLoader();
// load the test model
InputStream modelStream = cl.getResourceAsStream("org/alfresco/repo/node/archive/archiveTest_model.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
// Start a transaction
txn = transactionService.getUserTransaction();
txn.begin();
// downgrade integrity checks
IntegrityChecker.setWarnInTransaction();
try {
authenticationComponent.setSystemUserAsCurrentUser();
// Create the work store
workStoreRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, getName() + System.currentTimeMillis());
workStoreRootNodeRef = nodeService.getRootNode(workStoreRef);
archiveStoreRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "archive" + getName() + System.currentTimeMillis());
archiveStoreRootNodeRef = nodeService.getRootNode(archiveStoreRef);
// Map the work store to the archive store. This will already be wired into the NodeService.
StoreArchiveMap archiveMap = (StoreArchiveMap) ctx.getBean("storeArchiveMap");
archiveMap.put(workStoreRef, archiveStoreRef);
TestWithUserUtils.createUser(USER_A, USER_A, workStoreRootNodeRef, nodeService, authenticationService);
TestWithUserUtils.createUser(USER_B, USER_B, workStoreRootNodeRef, nodeService, authenticationService);
TestWithUserUtils.createUser(USER_C, USER_C, workStoreRootNodeRef, nodeService, authenticationService);
// grant A and B rights to the work store
permissionService.setPermission(workStoreRootNodeRef, USER_A, PermissionService.ALL_PERMISSIONS, true);
permissionService.setPermission(workStoreRootNodeRef, USER_B, PermissionService.ALL_PERMISSIONS, true);
permissionService.setPermission(workStoreRootNodeRef, USER_C, PermissionService.ALL_PERMISSIONS, false);
} finally {
authenticationComponent.clearCurrentSecurityContext();
}
// authenticate as normal user
authenticationService.authenticate(USER_A, USER_A.toCharArray());
createNodeStructure();
}
use of org.alfresco.repo.node.StoreArchiveMap in project alfresco-repository by Alfresco.
the class BaseVersionStoreTest method before.
/**
* Called during the transaction setup
*/
@Before
public void before() throws Exception {
// Set the multi value if required
if (this.multiValue == null) {
this.multiValue = new ArrayList<String>();
this.multiValue.add(MULTI_VALUE_1);
this.multiValue.add(MULTI_VALUE_2);
}
// Get the services by name from the application context
this.dbNodeService = (NodeService) applicationContext.getBean("dbNodeService");
this.contentService = (ContentService) applicationContext.getBean("contentService");
this.authenticationService = (MutableAuthenticationService) applicationContext.getBean("authenticationService");
this.transactionService = (TransactionService) this.applicationContext.getBean("transactionComponent");
this.txnHelper = (RetryingTransactionHelper) applicationContext.getBean("retryingTransactionHelper");
this.authenticationDAO = (MutableAuthenticationDao) applicationContext.getBean("authenticationDao");
this.nodeArchiveService = (NodeArchiveService) applicationContext.getBean("nodeArchiveService");
this.nodeService = (NodeService) applicationContext.getBean("nodeService");
this.permissionService = (PermissionService) this.applicationContext.getBean("permissionService");
this.checkOutCheckInService = (CheckOutCheckInService) applicationContext.getBean("checkOutCheckInService");
this.versionSearchService = (SearchService) this.applicationContext.getBean("versionSearchService");
this.dictionaryService = (DictionaryService) this.applicationContext.getBean("dictionaryService");
this.policyComponent = (PolicyComponent) this.applicationContext.getBean("policyComponent");
this.policyBehaviourFilter = (BehaviourFilter) this.applicationContext.getBean("policyBehaviourFilter");
setVersionService((VersionService) applicationContext.getBean("versionService"));
authenticationService.clearCurrentSecurityContext();
// Create the test model
createTestModel();
// Create a bag of properties for later use
this.versionProperties = new HashMap<String, Serializable>();
versionProperties.put(VERSION_PROP_1, VALUE_1);
versionProperties.put(VERSION_PROP_2, VALUE_2);
versionProperties.put(VERSION_PROP_3, VALUE_3);
// Create the node properties
this.nodeProperties = new HashMap<QName, Serializable>();
this.nodeProperties.put(PROP_1, VALUE_1);
this.nodeProperties.put(PROP_2, VALUE_2);
this.nodeProperties.put(PROP_3, VALUE_3);
this.nodeProperties.put(MULTI_PROP, (Serializable) multiValue);
this.nodeProperties.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8"));
// Add mlText property
this.mlText = new MLText(Locale.UK, "UK value");
this.mlText.addValue(Locale.US, "Y'all US value");
this.nodeProperties.put(MLTEXT_PROP, this.mlText);
// Create a workspace that contains the 'live' nodes
this.testStoreRef = this.dbNodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
StoreRef archiveStoreRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "archive" + getName() + System.currentTimeMillis());
// Map the work store to the archive store. This will already be wired into the NodeService.
StoreArchiveMap archiveMap = (StoreArchiveMap) applicationContext.getBean("storeArchiveMap");
archiveMap.put(testStoreRef, archiveStoreRef);
// Get a reference to the root node
this.rootNodeRef = this.dbNodeService.getRootNode(this.testStoreRef);
if (!authenticationDAO.userExists(AuthenticationUtil.getAdminUserName())) {
authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), PWD.toCharArray());
}
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
}
Aggregations