This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git

commit ef52aea2a2f6a18df224990f0c4862f3d83a33a6
Author: Daniel Qian <chanjars...@gmail.com>
AuthorDate: Sun Apr 1 16:28:30 2018 +0800

    Refactor TxEventRepository.findFirstCompensatedEventByIdGreaterThan() method
    
    Change method signature from findFirstCompensatedEventByIdGreaterThan(long 
id, String type) to
    findFirstCompensatedEventByIdGreaterThan(long id).
    
    The purpose of this method implied by name is to find a TxCompensatedEvent, 
so the type param is redundant.
---
 .../java/org/apache/servicecomb/saga/alpha/core/EventScanner.java  | 3 +--
 .../org/apache/servicecomb/saga/alpha/core/TxEventRepository.java  | 7 +++----
 .../servicecomb/saga/alpha/core/TxConsistentServiceTest.java       | 2 +-
 .../servicecomb/saga/alpha/server/SpringTxEventRepository.java     | 6 ++++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/EventScanner.java
 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/EventScanner.java
index 0e84066..e18075e 100644
--- 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/EventScanner.java
+++ 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/EventScanner.java
@@ -21,7 +21,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static org.apache.servicecomb.saga.alpha.core.TaskStatus.NEW;
 import static org.apache.servicecomb.saga.common.EventType.SagaEndedEvent;
 import static org.apache.servicecomb.saga.common.EventType.TxAbortedEvent;
-import static org.apache.servicecomb.saga.common.EventType.TxCompensatedEvent;
 import static org.apache.servicecomb.saga.common.EventType.TxEndedEvent;
 import static org.apache.servicecomb.saga.common.EventType.TxStartedEvent;
 
@@ -103,7 +102,7 @@ public class EventScanner implements Runnable {
   }
 
   private void updateCompensatedCommands() {
-    
eventRepository.findFirstCompensatedEventByIdGreaterThan(nextCompensatedEventId,
 TxCompensatedEvent.name())
+    
eventRepository.findFirstCompensatedEventByIdGreaterThan(nextCompensatedEventId)
         .ifPresent(event -> {
           log.info("Found compensated event {}", event);
           nextCompensatedEventId = event.id();
diff --git 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEventRepository.java
 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEventRepository.java
index 2474f85..09cebd0 100644
--- 
a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEventRepository.java
+++ 
b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEventRepository.java
@@ -100,18 +100,17 @@ public interface TxEventRepository {
   List<TxEvent> findFirstUncompensatedEventByIdGreaterThan(long id, String 
type);
 
   /**
-   * Find first {@link TxEvent} which satisfies below requirements:
+   * Find a {@link TxEvent} which satisfies below requirements:
    *
    * <ol>
-   *   <li>{@link TxEvent#type} equals to param <code>type</code></li>
+   *   <li>{@link TxEvent#type} equals to {@link 
EventType#TxCompensatedEvent}</li>
    *   <li>{@link TxEvent#surrogateId} greater than param <code>id</code></li>
    * </ol>
    *
    * @param id
-   * @param type
    * @return
    */
-  Optional<TxEvent> findFirstCompensatedEventByIdGreaterThan(long id, String 
type);
+  Optional<TxEvent> findFirstCompensatedEventByIdGreaterThan(long id);
 
   /**
    * Delete duplicated {@link TxEvent}s which {@link TxEvent#type} equals 
param <code>type</code>.
diff --git 
a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxConsistentServiceTest.java
 
b/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxConsistentServiceTest.java
index 9c0b103..e80d5a8 100644
--- 
a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxConsistentServiceTest.java
+++ 
b/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxConsistentServiceTest.java
@@ -78,7 +78,7 @@ public class TxConsistentServiceTest {
     }
 
     @Override
-    public Optional<TxEvent> findFirstCompensatedEventByIdGreaterThan(long id, 
String type) {
+    public Optional<TxEvent> findFirstCompensatedEventByIdGreaterThan(long id) 
{
       return Optional.empty();
     }
 
diff --git 
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxEventRepository.java
 
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxEventRepository.java
index 3f1acdc..ca6b795 100644
--- 
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxEventRepository.java
+++ 
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxEventRepository.java
@@ -24,6 +24,8 @@ import org.apache.servicecomb.saga.alpha.core.TxEvent;
 import org.apache.servicecomb.saga.alpha.core.TxEventRepository;
 import org.springframework.data.domain.PageRequest;
 
+import static org.apache.servicecomb.saga.common.EventType.TxCompensatedEvent;
+
 class SpringTxEventRepository implements TxEventRepository {
   private static final PageRequest SINGLE_TX_EVENT_REQUEST = new 
PageRequest(0, 1);
   private final TxEventEnvelopeRepository eventRepo;
@@ -63,8 +65,8 @@ class SpringTxEventRepository implements TxEventRepository {
   }
 
   @Override
-  public Optional<TxEvent> findFirstCompensatedEventByIdGreaterThan(long id, 
String type) {
-    return eventRepo.findFirstByTypeAndSurrogateIdGreaterThan(type, id);
+  public Optional<TxEvent> findFirstCompensatedEventByIdGreaterThan(long id) {
+    return 
eventRepo.findFirstByTypeAndSurrogateIdGreaterThan(TxCompensatedEvent.name(), 
id);
   }
 
   @Override

-- 
To stop receiving notification emails like this one, please contact
ningji...@apache.org.

Reply via email to