Skip to content

Commit 403fa58

Browse files
authored
v1.6.15 - Continued Bulk Full Recalc Work (#566)
* Standardizes prefixing System namespace for logging levels, which was inconsistent * updates polling time in Full Recalc app from 3 seconds to 10 seconds between polls to minimize number of logs produced while waiting for full recalcs to finish * fixes an inconsistency across batch full recalc runs where state tracking could fail if parents present in disparate batch chunks - say, chunks 1, 3, 5, etc... - had children qualify in only some of those batches. This has been a complicated and pernicious issue, and in many ways is a return to some prior version of the parent tracking present in prior versions of Apex Rollup. I've added some logging to the end of each batch chunk to monitor how this affects LDV orgs
1 parent 7270aa9 commit 403fa58

31 files changed

+162
-146
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ As well, don't miss [the Wiki](../../wiki), which includes even more info for co
2424

2525
## Deployment & Setup
2626

27-
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008OaYrAAK">
27+
<a href="https://login.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008OaZ6AAK">
2828
<img alt="Deploy to Salesforce"
2929
src="./media/deploy-package-to-prod.png">
3030
</a>
3131

32-
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008OaYrAAK">
32+
<a href="https://test.salesforce.com/packaging/installPackage.apexp?p0=04t6g000008OaZ6AAK">
3333
<img alt="Deploy to Salesforce Sandbox"
3434
src="./media/deploy-package-to-sandbox.png">
3535
</a>
@@ -1020,8 +1020,8 @@ You have several options for custom logging plugins for Rollup (all Rollup Plugi
10201020
public class RollupLogger {
10211021

10221022
public interface ILogger {
1023-
void log(String logString, LoggingLevel logLevel);
1024-
void log(String logString, Object logObject, LoggingLevel logLevel);
1023+
void log(String logString, System.LoggingLevel logLevel);
1024+
void log(String logString, Object logObject, System.LoggingLevel logLevel);
10251025
void save();
10261026
}
10271027
}
@@ -1030,7 +1030,7 @@ public class RollupLogger {
10301030

10311031
You can implement `RollupLogger.ILogger` with your own code and specify that class name in the `Rollup Plugin` CMDT records. _Alternatively_, you can also _extend_ `RollupLogger` itself and override its own logging methods; this gives you the benefit of built-in message formatting through the use of the protected method `getLogStringFromObject`, found in `RollupLogger.cls`. For more info, refer to that class and its methods. Either way, the API name for the CMDT record **must** include `Logger` in order to work (eg: `RollupCustomObjectLogger`, `RollupNebulaLoggerAdapter`).
10321032

1033-
You can use the included `Rollup Plugin Parameter` CMDT record `Logging Debug Level` to fine-tune the logging level you'd like to use when making use of Apex debug logs (from method #3, above). Valid entries conform to the `LoggingLevel` enum: ERROR, WARN, INFO, DEBUG, FINE, FINER, FINEST. FINEST provides the highest level of detail; ERROR provides the least. INFO will provide a high-level overview, while DEBUG will contain data about individual parent records being rolled up. The granularity of the data logged will continue to get finer as you move towards FINEST as the logging level.
1033+
You can use the included `Rollup Plugin Parameter` CMDT record `Logging Debug Level` to fine-tune the logging level you'd like to use when making use of Apex debug logs (from method #3, above). Valid entries conform to the `System.LoggingLevel` enum: ERROR, WARN, INFO, DEBUG, FINE, FINER, FINEST. FINEST provides the highest level of detail; ERROR provides the least. INFO will provide a high-level overview, while DEBUG will contain data about individual parent records being rolled up. The granularity of the data logged will continue to get finer as you move towards FINEST as the logging level.
10341034

10351035
### Other Rollup Plugins
10361036

extra-tests/classes/RollupLoggerTests.cls

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ private class RollupLoggerTests {
99
static void shouldLogUsingCustomLoggerWhenSupplied() {
1010
setup();
1111

12-
RollupLogger.Instance.log('hi', LoggingLevel.DEBUG);
12+
RollupLogger.Instance.log('hi', System.LoggingLevel.DEBUG);
1313

1414
System.assertEquals('hi', locallogString);
15-
System.assertEquals(LoggingLevel.DEBUG, localLogLevel);
15+
System.assertEquals(System.LoggingLevel.DEBUG, localLogLevel);
1616
}
1717

1818
@IsTest
1919
static void shouldLogCustomObjectWhenSupplied() {
2020
setup();
2121
Account acc = new Account();
2222

23-
RollupLogger.Instance.log('hello', acc, LoggingLevel.FINE);
23+
RollupLogger.Instance.log('hello', acc, System.LoggingLevel.FINE);
2424

2525
System.assertEquals('hello', locallogString);
2626
System.assertEquals(acc, localLogObject);
27-
System.assertEquals(LoggingLevel.FINE, localLogLevel);
27+
System.assertEquals(System.LoggingLevel.FINE, localLogLevel);
2828
}
2929

3030
@IsTest
@@ -61,15 +61,15 @@ private class RollupLoggerTests {
6161
Rollup.defaultControl = new RollupControl__mdt(IsRollupLoggingEnabled__c = false);
6262
RollupPlugin.pluginMocks = new List<RollupPlugin__mdt>{ new RollupPlugin__mdt(DeveloperName = ControlUpdatingLogger.class.getName()) };
6363

64-
RollupLogger.Instance.log('Should not be logged', LoggingLevel.DEBUG);
64+
RollupLogger.Instance.log('Should not be logged', System.LoggingLevel.DEBUG);
6565
System.assertEquals('logging isn\'t enabled, no further output', localLogString);
6666

6767
RollupLogger.Instance.updateRollupControl(new RollupControl__mdt(IsRollupLoggingEnabled__c = true));
6868
String expectedLogMessage = 'hi';
69-
RollupLogger.Instance.log(expectedLogMessage, LoggingLevel.INFO);
69+
RollupLogger.Instance.log(expectedLogMessage, System.LoggingLevel.INFO);
7070

7171
System.assertEquals(expectedLogMessage, localLogString);
72-
System.assertEquals(LoggingLevel.INFO, localLogLevel);
72+
System.assertEquals(System.LoggingLevel.INFO, localLogLevel);
7373
}
7474

7575
private static void setup() {
@@ -79,11 +79,11 @@ private class RollupLoggerTests {
7979

8080
// Type.forName requires public visibility
8181
public class ExampleLogger implements RollupLogger.ILogger {
82-
public void log(String logString, LoggingLevel logLevel) {
82+
public void log(String logString, System.LoggingLevel logLevel) {
8383
locallogString = logString;
8484
localLogLevel = logLevel;
8585
}
86-
public void log(String logString, Object logObject, LoggingLevel logLevel) {
86+
public void log(String logString, Object logObject, System.LoggingLevel logLevel) {
8787
locallogString = logString;
8888
localLogObject = logObject;
8989
localLogLevel = logLevel;

extra-tests/classes/RollupTestUtils.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class RollupTestUtils {
2929
public class DMLMock extends RollupSObjectUpdater {
3030
public List<SObject> Records = new List<SObject>();
3131
public override void doUpdate(List<SObject> recordsToUpdate) {
32-
RollupLogger.Instance.log('mock received the following for update:', recordsToUpdate, LoggingLevel.DEBUG);
32+
RollupLogger.Instance.log('mock received the following for update:', recordsToUpdate, System.LoggingLevel.DEBUG);
3333
this.Records = recordsToUpdate;
3434
}
3535
}

extra-tests/classes/RollupTests.cls

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,30 +1749,30 @@ private class RollupTests {
17491749
static void shouldPassRecalcValueForConcatDistinct() {
17501750
rollupOp = Rollup.Op.CONCAT_DISTINCT;
17511751
RollupCalculator.Factory = new FactoryMock();
1752-
RollupTestUtils.loadAccountIdMock(new List<ContactPointAddress>{ new ContactPointAddress(PreferenceRank = 5) });
1752+
RollupTestUtils.DMLMock mock = RollupTestUtils.loadAccountIdMock(new List<ContactPointAddress>{ new ContactPointAddress(Name = 'Hi', PreferenceRank = 5) });
17531753
Rollup.apexContext = TriggerOperation.AFTER_INSERT;
17541754

17551755
Test.startTest();
1756-
Rollup.concatDistinctFromApex(ContactPointAddress.PreferenceRank, ContactPointAddress.ParentId, Account.Id, Account.AnnualRevenue, Account.SObjectType, 'a')
1757-
.runCalc();
1756+
Rollup.concatDistinctFromApex(ContactPointAddress.Name, ContactPointAddress.ParentId, Account.Id, Account.Description, Account.SObjectType, 'a').runCalc();
17581757
Test.stopTest();
17591758

17601759
System.assertEquals('a', testMetadata.FullRecalculationDefaultStringValue__c);
1760+
System.assertEquals('a', mock.Records.get(0).get(Account.Description));
17611761
}
17621762

17631763
@IsTest
17641764
static void shouldPassRecalcValueForConcat() {
17651765
rollupOp = Rollup.Op.CONCAT;
17661766
RollupCalculator.Factory = new FactoryMock();
1767-
RollupTestUtils.loadAccountIdMock(new List<ContactPointAddress>{ new ContactPointAddress(PreferenceRank = 5) });
1767+
RollupTestUtils.DMLMock mock = RollupTestUtils.loadAccountIdMock(new List<ContactPointAddress>{ new ContactPointAddress(Name = 'Hi', PreferenceRank = 5) });
17681768
Rollup.apexContext = TriggerOperation.AFTER_INSERT;
17691769

17701770
Test.startTest();
1771-
Rollup.concatFromApex(ContactPointAddress.PreferenceRank, ContactPointAddress.ParentId, Account.Id, Account.AnnualRevenue, Account.SObjectType, 'a')
1772-
.runCalc();
1771+
Rollup.concatFromApex(ContactPointAddress.Name, ContactPointAddress.ParentId, Account.Id, Account.Description, Account.SObjectType, 'a').runCalc();
17731772
Test.stopTest();
17741773

17751774
System.assertEquals('a', testMetadata.FullRecalculationDefaultStringValue__c);
1775+
System.assertEquals('a', mock.Records.get(0).get(Account.Description));
17761776
}
17771777

17781778
@IsTest

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apex-rollup",
3-
"version": "1.6.14",
3+
"version": "1.6.15",
44
"description": "Fast, configurable, elastically scaling custom rollup solution. Apex Invocable action, one-liner Apex trigger/CMDT-driven logic, and scheduled Apex-ready.",
55
"repository": {
66
"type": "git",

plugins/CustomObjectRollupLogger/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ To install this plugin and get it setup within your org properly:
1616
2. Navigate to the Rollup Plugin CMDT (Setup -> Custom Metadata Types -> Manage Records next to Rollup Plugin -> New)
1717
3. (This should already be done for you, upon install, but always good to double-check) - Enter `RollupCustomObjectLogger` into the `Rollup Plugin Name` field, choose the `Org_Default` rollup control record (and ensure `Is Rollup Logging Enabled?` is checked off on that record); the label can be whatever you'd like
1818

19-
That's it! Logs will now start flowing through on all rollup operations to `RollupLog__c`. A permission set, `Rollup Log Viewer` is included so that you can grant Rollup Log access to users other than yourself (should you be so inclined). You can use the included `Rollup Plugin Parameter` CMDT record `Custom Logging Debug Level` to fine-tune the logging level you'd like to use. Valid entries conform to the `LoggingLevel` enum: ERROR, WARN, INFO, DEBUG, FINE, FINER, FINEST. FINEST provides the highest level of detail; ERROR provides the least.
19+
That's it! Logs will now start flowing through on all rollup operations to `RollupLog__c`. A permission set, `Rollup Log Viewer` is included so that you can grant Rollup Log access to users other than yourself (should you be so inclined). You can use the included `Rollup Plugin Parameter` CMDT record `Custom Logging Debug Level` to fine-tune the logging level you'd like to use. Valid entries conform to the `System.LoggingLevel` enum: ERROR, WARN, INFO, DEBUG, FINE, FINER, FINEST. FINEST provides the highest level of detail; ERROR provides the least.
2020

2121
---
2222

plugins/CustomObjectRollupLogger/classes/RollupCustomObjectLogger.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class RollupCustomObjectLogger extends RollupLogger {
1111
this.rollupLogEvents.clear();
1212
}
1313

14-
protected override void innerLog(String logString, Object logObject, LoggingLevel logLevel) {
14+
protected override void innerLog(String logString, Object logObject, System.LoggingLevel logLevel) {
1515
logString = this.getBaseLoggingMessage() + logString + '\n' + this.getLogStringFromObject(logObject);
1616
if (logString.length() >= MAX_LENGTH) {
1717
// normally we could do this with the AllowFieldTruncation property on Database.DMLOptions

plugins/CustomObjectRollupLogger/classes/RollupLogBatchPurger.cls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ global without sharing class RollupLogBatchPurger implements Database.Batchable<
3636
}
3737

3838
public void finish(Database.BatchableContext bc) {
39-
RollupLogger.Instance.log('RollupLogBatchPurger finishing up after having deleted ' + this.recordCount + ' rollup logs', LoggingLevel.DEBUG);
39+
RollupLogger.Instance.log('RollupLogBatchPurger finishing up after having deleted ' + this.recordCount + ' rollup logs', System.LoggingLevel.DEBUG);
4040

4141
String orphanedLogsQuery = 'SELECT Count() FROM RollupLog__c WHERE NumberOfLogEntries__c = 0 AND IsDeleted = false';
4242
if (Database.countQuery(orphanedLogsQuery) > 0 && this.hasDeletedOrphanedLogs == false) {
4343
orphanedLogsQuery = orphanedLogsQuery.replace('Count()', 'Id');
4444
this.hasDeletedOrphanedLogs = true;
45-
RollupLogger.Instance.log('Deleting orphaned logs ...', LoggingLevel.DEBUG);
45+
RollupLogger.Instance.log('Deleting orphaned logs ...', System.LoggingLevel.DEBUG);
4646
delete Database.query(orphanedLogsQuery);
4747
}
4848
RollupLogger.Instance.save();

plugins/CustomObjectRollupLogger/classes/RollupLogEventHandler.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public without sharing class RollupLogEventHandler {
55

66
for (RollupLogEvent__e logEvent : logEvents) {
77
RollupLog__c rollupLog = new RollupLog__c(
8-
ErrorWouldHaveBeenThrown__c = logEvent.LoggingLevel__c == LoggingLevel.ERROR.name(),
8+
ErrorWouldHaveBeenThrown__c = logEvent.LoggingLevel__c == System.LoggingLevel.ERROR.name(),
99
LoggedBy__c = Id.valueOf(logEvent.LoggedBy__c),
1010
TransactionId__c = logEvent.TransactionId__c
1111
);

plugins/CustomObjectRollupLogger/customMetadata/RollupPluginParameter.CustomLoggingDebugLevel.md-meta.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<CustomMetadata
3+
xmlns="http://soap.sforce.com/2006/04/metadata"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
6+
>
37
<label>Custom Logging Debug Level</label>
48
<protected>false</protected>
59
<values>
610
<field>Description__c</field>
7-
<value xsi:type="xsd:string">Conforms to the standard LoggingLevel enum - valid values are ERROR, WARN, INFO, DEBUG, FINE, FINER, FINEST. FINEST provides the highest level of detail; ERROR provides the least.</value>
11+
<value
12+
xsi:type="xsd:string"
13+
>Conforms to the standard System.LoggingLevel enum - valid values are ERROR, WARN, INFO, DEBUG, FINE, FINER, FINEST. FINEST provides the highest level of detail; ERROR provides the least.</value>
814
</values>
915
<values>
1016
<field>RollupPlugin__c</field>

0 commit comments

Comments
 (0)