You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "denis-chudov (via GitHub)" <gi...@apache.org> on 2024/01/29 11:11:26 UTC
[PR] IGNITE-21247 Log enhancements for LeaseUpdater [ignite-3]
denis-chudov opened a new pull request, #3109:
URL: https://github.com/apache/ignite-3/pull/3109
https://issues.apache.org/jira/browse/IGNITE-21247
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21247 Log enhancements for LeaseUpdater [ignite-3]
Posted by "vldpyatkov (via GitHub)" <gi...@apache.org>.
vldpyatkov commented on code in PR #3109:
URL: https://github.com/apache/ignite-3/pull/3109#discussion_r1475858283
##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/LeaseUpdater.java:
##########
@@ -286,6 +288,13 @@ public void run() {
if (active()) {
updateLeaseBatchInternal();
}
+ } catch (Throwable e) {
+ LOG.error("Error occurred when updating the leases.", e);
Review Comment:
Move it after the handling Error.
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableManager.java:
##########
@@ -1282,6 +1287,29 @@ private CompletableFuture<Void> createTableLocally(
return createPartsFut.thenApply(ignore -> null);
}
+ private static String assignmentListToString(List<Set<Assignment>> assignments) {
Review Comment:
Java doc.
##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/LeaseUpdater.java:
##########
@@ -461,6 +492,99 @@ private boolean isLeaseOutdated(Lease lease) {
}
}
+ private static class LeaseUpdateStatistics {
+ static final int PRINT_ONCE_PER_ITERATIONS = 10;
+
+ /** This field should be accessed only from updater thread. */
+ private int statisticsLogCounter;
+
+ /** This field is iteration-local and should be accessed only from updater thread. */
+ private LeaseUpdateStatisticsParameters iteration = new LeaseUpdateStatisticsParameters(0, 0, 0);
+
+ private final LeaseUpdateStatisticsParameters total = new LeaseUpdateStatisticsParameters(0, 0, 0);
+
+ /**
+ * Should be called only from the updater thread.
+ */
+ private void onLeaseCreate() {
+ iteration.leasesCreated++;
+ }
+
+ /**
+ * Should be called only from the updater thread.
+ */
+ private void onLeasePublish() {
+ iteration.leasesPublished++;
+ }
+
+ /**
+ * Should be called only from the updater thread.
+ */
+ private void onLeaseProlong() {
+ iteration.leasesProlonged++;
+ }
+
+ /**
+ * Should be called only from the updater thread.
+ */
+ private LeaseUpdateStatisticsParameters leasesUpdatedInCurrentIteration() {
+ return new LeaseUpdateStatisticsParameters(iteration.leasesCreated, iteration.leasesPublished, iteration.leasesProlonged);
+ }
+
+ /**
+ * Should be called only from the updater thread.
+ */
+ private boolean shouldLogLeaseStatistics() {
+ boolean result = ++statisticsLogCounter > PRINT_ONCE_PER_ITERATIONS;
+
+ if (result) {
+ statisticsLogCounter = 0;
+ }
+
+ return result;
+ }
+
+ /**
+ * Should be called only from the updater thread.
+ */
+ private void onNewIteration() {
+ iteration = new LeaseUpdateStatisticsParameters(0, 0, 0);
+ }
+
+ /**
+ * Updates the total count of updated leases after the successful update.
+ *
+ * @param iterationParameters Leases updated in current iteration.
+ * @return Updated value of total updated leases.
+ */
+ private synchronized LeaseUpdateStatisticsParameters onSuccessfulIteration(LeaseUpdateStatisticsParameters iterationParameters) {
+ total.leasesCreated += iterationParameters.leasesCreated;
+ total.leasesPublished += iterationParameters.leasesPublished;
+ total.leasesProlonged += iterationParameters.leasesProlonged;
+
+ return total;
+ }
+ }
+
+ private static class LeaseUpdateStatisticsParameters {
+ long leasesCreated;
+ long leasesPublished;
+ long leasesProlonged;
+
+ public LeaseUpdateStatisticsParameters(long leasesCreated, long leasesPublished, long leasesProlonged) {
+ this.leasesCreated = leasesCreated;
+ this.leasesPublished = leasesPublished;
+ this.leasesProlonged = leasesProlonged;
+ }
+
+ @Override
+ public String toString() {
+ return "[leasesCreated=" + leasesCreated
+ + ", leasesPublished=" + leasesPublished
+ + ", leasesProlonged=" + leasesProlonged + ']';
Review Comment:
S.toString is a better way to do this.
##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/LeaseUpdater.java:
##########
@@ -387,6 +403,15 @@ private void updateLeaseBatchInternal() {
return;
}
+ LeaseUpdateStatisticsParameters totalLeases = leaseUpdateStatistics.onSuccessfulIteration(leasesUpdatedInCurrentIteration);
+
+ if (shouldLogLeaseStatistics) {
+ LOG.info("Leases updated (printed once per " + LeaseUpdateStatistics.PRINT_ONCE_PER_ITERATIONS + " iterations): ["
+ + "currentIteration=" + leasesUpdatedInCurrentIteration
+ + ", total=" + totalLeases
+ + ", currentAssignmentsSize=" + currentAssignmentsSize + "]");
+ }
Review Comment:
I'd rather insert this printinc logik into the lease statistic object.
Also, this statistic should have functionality to disable it.
##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/LeaseUpdater.java:
##########
@@ -387,6 +403,15 @@ private void updateLeaseBatchInternal() {
return;
}
+ LeaseUpdateStatisticsParameters totalLeases = leaseUpdateStatistics.onSuccessfulIteration(leasesUpdatedInCurrentIteration);
+
+ if (shouldLogLeaseStatistics) {
+ LOG.info("Leases updated (printed once per " + LeaseUpdateStatistics.PRINT_ONCE_PER_ITERATIONS + " iterations): ["
Review Comment:
Avoid concut strings in loggers because it has an effective parametrazed method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21247 Log enhancements for LeaseUpdater [ignite-3]
Posted by "denis-chudov (via GitHub)" <gi...@apache.org>.
denis-chudov commented on code in PR #3109:
URL: https://github.com/apache/ignite-3/pull/3109#discussion_r1479499330
##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/LeaseUpdater.java:
##########
@@ -387,6 +403,15 @@ private void updateLeaseBatchInternal() {
return;
}
+ LeaseUpdateStatisticsParameters totalLeases = leaseUpdateStatistics.onSuccessfulIteration(leasesUpdatedInCurrentIteration);
+
+ if (shouldLogLeaseStatistics) {
+ LOG.info("Leases updated (printed once per " + LeaseUpdateStatistics.PRINT_ONCE_PER_ITERATIONS + " iterations): ["
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21247 Log enhancements for LeaseUpdater [ignite-3]
Posted by "denis-chudov (via GitHub)" <gi...@apache.org>.
denis-chudov commented on code in PR #3109:
URL: https://github.com/apache/ignite-3/pull/3109#discussion_r1479503618
##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/LeaseUpdater.java:
##########
@@ -387,6 +403,15 @@ private void updateLeaseBatchInternal() {
return;
}
+ LeaseUpdateStatisticsParameters totalLeases = leaseUpdateStatistics.onSuccessfulIteration(leasesUpdatedInCurrentIteration);
+
+ if (shouldLogLeaseStatistics) {
+ LOG.info("Leases updated (printed once per " + LeaseUpdateStatistics.PRINT_ONCE_PER_ITERATIONS + " iterations): ["
+ + "currentIteration=" + leasesUpdatedInCurrentIteration
+ + ", total=" + totalLeases
+ + ", currentAssignmentsSize=" + currentAssignmentsSize + "]");
+ }
Review Comment:
added system property: LEASE_STATISTICS_PRINT_ONCE_PER_ITERATIONS
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21247 Log enhancements for LeaseUpdater [ignite-3]
Posted by "vldpyatkov (via GitHub)" <gi...@apache.org>.
vldpyatkov merged PR #3109:
URL: https://github.com/apache/ignite-3/pull/3109
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-21247 Log enhancements for LeaseUpdater [ignite-3]
Posted by "denis-chudov (via GitHub)" <gi...@apache.org>.
denis-chudov commented on code in PR #3109:
URL: https://github.com/apache/ignite-3/pull/3109#discussion_r1479495905
##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/LeaseUpdater.java:
##########
@@ -461,6 +492,99 @@ private boolean isLeaseOutdated(Lease lease) {
}
}
+ private static class LeaseUpdateStatistics {
+ static final int PRINT_ONCE_PER_ITERATIONS = 10;
+
+ /** This field should be accessed only from updater thread. */
+ private int statisticsLogCounter;
+
+ /** This field is iteration-local and should be accessed only from updater thread. */
+ private LeaseUpdateStatisticsParameters iteration = new LeaseUpdateStatisticsParameters(0, 0, 0);
+
+ private final LeaseUpdateStatisticsParameters total = new LeaseUpdateStatisticsParameters(0, 0, 0);
+
+ /**
+ * Should be called only from the updater thread.
+ */
+ private void onLeaseCreate() {
+ iteration.leasesCreated++;
+ }
+
+ /**
+ * Should be called only from the updater thread.
+ */
+ private void onLeasePublish() {
+ iteration.leasesPublished++;
+ }
+
+ /**
+ * Should be called only from the updater thread.
+ */
+ private void onLeaseProlong() {
+ iteration.leasesProlonged++;
+ }
+
+ /**
+ * Should be called only from the updater thread.
+ */
+ private LeaseUpdateStatisticsParameters leasesUpdatedInCurrentIteration() {
+ return new LeaseUpdateStatisticsParameters(iteration.leasesCreated, iteration.leasesPublished, iteration.leasesProlonged);
+ }
+
+ /**
+ * Should be called only from the updater thread.
+ */
+ private boolean shouldLogLeaseStatistics() {
+ boolean result = ++statisticsLogCounter > PRINT_ONCE_PER_ITERATIONS;
+
+ if (result) {
+ statisticsLogCounter = 0;
+ }
+
+ return result;
+ }
+
+ /**
+ * Should be called only from the updater thread.
+ */
+ private void onNewIteration() {
+ iteration = new LeaseUpdateStatisticsParameters(0, 0, 0);
+ }
+
+ /**
+ * Updates the total count of updated leases after the successful update.
+ *
+ * @param iterationParameters Leases updated in current iteration.
+ * @return Updated value of total updated leases.
+ */
+ private synchronized LeaseUpdateStatisticsParameters onSuccessfulIteration(LeaseUpdateStatisticsParameters iterationParameters) {
+ total.leasesCreated += iterationParameters.leasesCreated;
+ total.leasesPublished += iterationParameters.leasesPublished;
+ total.leasesProlonged += iterationParameters.leasesProlonged;
+
+ return total;
+ }
+ }
+
+ private static class LeaseUpdateStatisticsParameters {
+ long leasesCreated;
+ long leasesPublished;
+ long leasesProlonged;
+
+ public LeaseUpdateStatisticsParameters(long leasesCreated, long leasesPublished, long leasesProlonged) {
+ this.leasesCreated = leasesCreated;
+ this.leasesPublished = leasesPublished;
+ this.leasesProlonged = leasesProlonged;
+ }
+
+ @Override
+ public String toString() {
+ return "[leasesCreated=" + leasesCreated
+ + ", leasesPublished=" + leasesPublished
+ + ", leasesProlonged=" + leasesProlonged + ']';
Review Comment:
fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org