Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)

64841: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX (4.3/Cloud)
      64800: Skeleton fix for MT upgrade running while default tenant holds open a transaction (MNT-10881)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@66202 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2014-04-02 20:08:56 +00:00
parent 798f24963d
commit 6cf3584770

View File

@@ -430,16 +430,34 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
} }
} }
private String applyImpl() throws Exception private String applyWithTxns() throws Exception
{ {
// downgrade integrity checking
IntegrityChecker.setWarnInTransaction();
if(logger.isDebugEnabled()) if(logger.isDebugEnabled())
{ {
logger.debug("call applyInternal for main context id:" + id); logger.debug("call applyInternal for main context id:" + id);
} }
String report = applyInternal(); RetryingTransactionCallback<String> patchWork = new RetryingTransactionCallback<String>()
{
public String execute() throws Exception
{
// downgrade integrity checking
IntegrityChecker.setWarnInTransaction();
return applyInternal();
}
};
StringBuilder sb = new StringBuilder(128);
if (requiresTransaction())
{
// execute in a transaction
String temp = transactionService.getRetryingTransactionHelper().doInTransaction(patchWork, false, true);
sb.append(temp);
}
else
{
String temp = applyInternal();
sb.append(temp);
}
if ((tenantAdminService != null) && tenantAdminService.isEnabled() && applyToTenants) if ((tenantAdminService != null) && tenantAdminService.isEnabled() && applyToTenants)
{ {
@@ -483,7 +501,7 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
logger, logger,
1000); 1000);
BatchProcessWorker worker = new BatchProcessWorker<Tenant>() BatchProcessWorker<Tenant> worker = new BatchProcessWorker<Tenant>()
{ {
@Override @Override
public String getIdentifier(Tenant entry) public String getIdentifier(Tenant entry)
@@ -501,6 +519,7 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
public void process(Tenant entry) throws Throwable public void process(Tenant entry) throws Throwable
{ {
String tenantDomain = entry.getTenantDomain(); String tenantDomain = entry.getTenantDomain();
@SuppressWarnings("unused")
String tenantReport = AuthenticationUtil.runAs(new RunAsWork<String>() String tenantReport = AuthenticationUtil.runAs(new RunAsWork<String>()
{ {
public String doWork() throws Exception public String doWork() throws Exception
@@ -518,6 +537,7 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
}; };
// Now do the work // Now do the work
@SuppressWarnings("unused")
int numberOfInvocations = batchProcessor.process(worker, true); int numberOfInvocations = batchProcessor.process(worker, true);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
@@ -527,16 +547,16 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
if (batchProcessor.getTotalErrors() > 0) if (batchProcessor.getTotalErrors() > 0)
{ {
report = report + "\n" + " and failure during update of tennants total success: " + batchProcessor.getSuccessfullyProcessedEntries() + " number of errors: " +batchProcessor.getTotalErrors() + " lastError" + batchProcessor.getLastError(); sb.append("\n" + " and failure during update of tennants total success: " + batchProcessor.getSuccessfullyProcessedEntries() + " number of errors: " +batchProcessor.getTotalErrors() + " lastError" + batchProcessor.getLastError());
} }
else else
{ {
report = report + "\n" + " and successful batch update of " + batchProcessor.getTotalResults() + "tennants"; sb.append("\n" + " and successful batch update of " + batchProcessor.getTotalResults() + "tennants");
} }
} }
// done? // Done
return report; return sb.toString();
} }
/** /**
@@ -592,22 +612,7 @@ public abstract class AbstractPatch implements Patch, ApplicationEventPublisher
{ {
public String doWork() throws Exception public String doWork() throws Exception
{ {
if(requiresTransaction()) return applyWithTxns();
{
// execute in a transaction
RetryingTransactionCallback<String> patchWork = new RetryingTransactionCallback<String>()
{
public String execute() throws Exception
{
return applyImpl();
}
};
return transactionService.getRetryingTransactionHelper().doInTransaction(patchWork, false, true);
}
else
{
return applyImpl();
}
} }
}; };
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();