Search in sources :

Example 11 with RollbackRequest

use of com.google.spanner.v1.RollbackRequest in project grpc-gcp-java by GoogleCloudPlatform.

the class Rollback method rollbackCall.

public void rollbackCall() {
    System.out.println("\n:: Rolling Back Transaction ::\n");
    if (Main.transactionId == null) {
        System.out.println("WARNING:  No current transaction open, run BeginTransaction first...");
        return;
    } else {
        System.out.println("Found Transaction ID '" + Main.transactionId.toString() + "'.  Committing....");
    }
    FirestoreBlockingStub blockingStub = new GRPCFirebaseClientFactory().createFirebaseClient().getBlockingStub();
    RollbackRequest rollbackRequest = RollbackRequest.newBuilder().setTransaction(Main.transactionId).setDatabase("projects/firestoretestclient/databases/(default)").build();
    try {
        blockingStub.rollback(rollbackRequest);
    } catch (Exception e) {
        System.out.println("Error during call: " + e.getMessage() + e.getCause());
        return;
    }
    System.out.println("Success!");
    Menu menu = new Menu();
    menu.draw();
}
Also used : GRPCFirebaseClientFactory(org.roguewave.grpc.util.GRPCFirebaseClientFactory) FirestoreBlockingStub(com.google.firestore.v1beta1.FirestoreGrpc.FirestoreBlockingStub) Menu(org.roguewave.grpc.util.gfx.Menu) RollbackRequest(com.google.firestore.v1beta1.RollbackRequest)

Aggregations

ByteString (com.google.protobuf.ByteString)5 Empty (com.google.protobuf.Empty)5 RollbackRequest (com.google.spanner.v1.RollbackRequest)5 RollbackRequest (com.google.firestore.v1.RollbackRequest)4 Test (org.junit.Test)4 AbstractMessage (com.google.protobuf.AbstractMessage)3 BeginTransactionResponse (com.google.firestore.v1.BeginTransactionResponse)2 CommitRequest (com.google.firestore.v1.CommitRequest)2 CommitResponse (com.google.firestore.v1.CommitResponse)2 Document (com.google.firestore.v1.Document)2 GetDocumentRequest (com.google.firestore.v1.GetDocumentRequest)2 SessionPoolTransactionContext (com.google.cloud.spanner.SessionPool.SessionPoolTransactionContext)1 TransactionContextImpl (com.google.cloud.spanner.TransactionRunnerImpl.TransactionContextImpl)1 FirestoreTemplate (com.google.cloud.spring.data.firestore.FirestoreTemplate)1 FirestoreDefaultClassMapper (com.google.cloud.spring.data.firestore.mapping.FirestoreDefaultClassMapper)1 FirestoreMappingContext (com.google.cloud.spring.data.firestore.mapping.FirestoreMappingContext)1 FirestoreBlockingStub (com.google.firestore.v1beta1.FirestoreGrpc.FirestoreBlockingStub)1 RollbackRequest (com.google.firestore.v1beta1.RollbackRequest)1 Session (com.google.spanner.v1.Session)1 SessionName (com.google.spanner.v1.SessionName)1