albertogpz commented on a change in pull request #4928:
URL: https://github.com/apache/geode/pull/4928#discussion_r422867687



##########
File path: 
geode-core/src/main/java/org/apache/geode/internal/cache/TXLastEventInTransactionUtils.java
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.ServiceConfigurationError;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.apache.logging.log4j.Logger;
+
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.wan.GatewaySender;
+import org.apache.geode.logging.internal.log4j.api.LogService;
+
+public class TXLastEventInTransactionUtils {
+  private static final Logger logger = LogService.getLogger();
+
+  /**
+   * @param callbacks list of events belonging to a transaction
+   *
+   * @return the last event of the transaction.
+   *         If the regions to which the events belong do not have senders
+   *         that group transactions it returns null.
+   *         If the regions to which the
+   *         events belong have different sets of senders that group 
transactions
+   *         then it throws a ServiceConfigurationError exception.
+   */
+  public static EntryEventImpl getLastTransactionEvent(List<EntryEventImpl> 
callbacks,
+      Cache cache)
+      throws ServiceConfigurationError {
+    if (checkNoSendersGroupTransactionEvents(callbacks, cache)) {
+      return null;
+    }
+
+    List<Set> senderIdsPerEvent = getGroupingSendersPerEvent(callbacks, cache);
+    if (senderIdsPerEvent.stream().distinct().count() > 1) {
+      String info = eventsAndSendersPerEventToString(callbacks, 
senderIdsPerEvent);
+      throw new ServiceConfigurationError(
+          "Not all events go to the same senders that group transactions. " + 
info);
+    } ;

Review comment:
       Good eye!




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to