coolbeevip commented on a change in pull request #609: WIP [SCB-1627] Omega
side CallbackContext send the compensation result event to Alpha
URL: https://github.com/apache/servicecomb-pack/pull/609#discussion_r354076371
##########
File path:
alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/fsm/GrpcOmegaCallback.java
##########
@@ -19,32 +19,71 @@
import com.google.protobuf.ByteString;
import io.grpc.stub.StreamObserver;
+import java.lang.invoke.MethodHandles;
import org.apache.servicecomb.pack.alpha.core.OmegaCallback;
import org.apache.servicecomb.pack.alpha.core.TxEvent;
+import
org.apache.servicecomb.pack.alpha.core.exception.CompensateAskFailedException;
+import
org.apache.servicecomb.pack.alpha.core.exception.CompensateConnectException;
+import org.apache.servicecomb.pack.alpha.core.fsm.CompensateAskType;
import org.apache.servicecomb.pack.contract.grpc.GrpcCompensateCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
class GrpcOmegaCallback implements OmegaCallback {
+ private static final Logger LOG =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private final StreamObserver<GrpcCompensateCommand> observer;
+ private CompensateAskWait compensateAskWait;
GrpcOmegaCallback(StreamObserver<GrpcCompensateCommand> observer) {
this.observer = observer;
}
@Override
public void compensate(TxEvent event) {
- GrpcCompensateCommand command = GrpcCompensateCommand.newBuilder()
- .setGlobalTxId(event.globalTxId())
- .setLocalTxId(event.localTxId())
- .setParentTxId(event.parentTxId() == null ? "" : event.parentTxId())
- .setCompensationMethod(event.compensationMethod())
- .setPayloads(ByteString.copyFrom(event.payloads()))
- .build();
- observer.onNext(command);
+ compensateAskWait = new CompensateAskWait(1);
+ try {
+ GrpcCompensateCommand command = GrpcCompensateCommand.newBuilder()
+ .setGlobalTxId(event.globalTxId())
+ .setLocalTxId(event.localTxId())
+ .setParentTxId(event.parentTxId() == null ? "" : event.parentTxId())
+ .setCompensationMethod(event.compensationMethod())
+ .setPayloads(ByteString.copyFrom(event.payloads()))
+ .build();
+ observer.onNext(command);
+ compensateAskWait.await();
Review comment:
> As this change will break the old code, I think it could be better if you
create another PR for this part of change.
OK,I have created a JIRA https://issues.apache.org/jira/browse/SCB-1646 for
it
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services