CCCPaste

db85d46859946

public void transfusion(RequestInitiatingMigration request) {
        URI senderURI = URI.create(request.getSender());
        URI receiverURI = URI.create(request.getReceiver());

        tarantoolClient.graphql(TdgJsonUtils.paginationQuery(request), senderURI.getHost(), senderURI.getPort())
                .onSuccess(httpResp -> {
                    List mutations = TdgJsonUtils.convertToListMutations(httpResp.bodyAsJsonObject(), request);
                    String cursor = TdgJsonUtils.getLastCursor(httpResp.bodyAsJsonObject(), request);
                    while (!cursor.equals("empty")) {
                        JsonObject response = tarantoolClient.graphql(
                                TdgJsonUtils.paginationQuery(request, cursor), senderURI.getHost(), senderURI.getPort())
                                .result().bodyAsJsonObject();
                        mutations.addAll(TdgJsonUtils.convertToListMutations(response, request));
                        cursor = TdgJsonUtils.getLastCursor(response, request);
                    }

                    for (JsonObject mutation : mutations) {
                        tarantoolClient.mutation(mutation, receiverURI.getHost(), receiverURI.getPort(), request.getToken());
                    }
                });

    }