Skip to content

Commit

Permalink
Implement mirroring client (googleapis#3322 copy) (googleapis#3616)
Browse files Browse the repository at this point in the history
* Initial implementation of hbase1.x Mirroring Client (#1)

* Initial implementation of hbase1.x Mirroring Client

* MirroringTable and AsyncTableWrapper (#4)

* MirroringTable and AsyncTableWrapper

- Initial implementation of MirroringTable.
- Wrapper around HBase 1.x Table enabling scheduling asynchronous operations.
- Asynchronous verification of get/exists results.

* Add missing licence header to TestResultComparator (googleapis#6)

* Setup running tests in GitHub Actions (googleapis#7)

* Asynchronous ResultScanner (googleapis#5)

* Asynchronous ResultScanner

* Implement faillog.Appender (#2)

`faillog.Appender` is the lowermost component of the infrastructure for
dumping failed mutations in the `MirroringClient`. `faillog/README.md`
explains the design decisions in a bit more detail.

`faillog.Appender` essentially logs arbitrary data asynchronously,
through a separate thread reading from a bounded buffer.

* ListenableReferenceCounter (googleapis#8)

* Count references in asynchronous tasks before closing Table/Scanner.

* Flow controller (googleapis#10)

* Flow Controller
* Flow Control strategy based on single requests queue

* Mirroring table: writes (googleapis#12)

* Add missing condition in result comparator (googleapis#15)

* Add more mirroring config opitons (googleapis#16)

* MismatchDetector implementation.
* FlowControllerStrategy implementation.
* Maximal number of outstanding requests used by FlowControllerStrategy.
* Primary/Secondary connection implementation option now accepts
  "default" value which can be used when default HBase Connection
  implementation should be used by MirroringConnection.

* Make AsyncTableWrapper ListenableCloseable (googleapis#20)

Implements our standard interface for objects that can run callbacks
after asynchronous close to simplify reference counting of
MirroringTable.

* MirroringConnection: use new config options (googleapis#17)

* MirroringResultScanner improvements (googleapis#18)

* Count references to MirroringResultScanner

Current implementation of MirroringResultScanner doesn't count
verificaiton requests that it has scheduled and allows to close
instances while verificaiton requests are in-flight. This causes lost
verifications.

This PR fixes this issue by counting references to MirroringResultScanner
instances when scheduling verification requests. Moreover, ListenableClosable
interface is implemented for consistency with other classes that use this
scheme, because now the MirroringResultScanner instances will be closed
asynchronously, when all scheduled requests have finished.

* MirroringTable: count references to scanners and secondary wrapper (googleapis#21)

Current MirroringTable implementaion does not count its references held
by MirroringResultScanners and SecondaryAsyncWrapper, thus
MirroringConnection consideres it closed before we are sure that all
asynchronous operations have completed.

This PR adds correct reference counting of MirroringTable based on work
done in previously merged PRs.

* Result Scanner - ensure verification ordering (googleapis#22)

Current implementation assumes that next() operations on primary and
secondary scanners are called in the same order and uses this assumption
to match results for verification.

However, next()s on secondary database are called asynchronusly and
their order is not defined, which causes invalid mismatch reports.

This PR fixes this problem by placing data to be verified - results of
next()s called on primary scanner - and details of next() call - number
of requested elements - call on a queue. Each asynchronous call to
next() is synchonized and pops a single element from that queue.
Appropriate next is called based on number of requested elements.
Then results of that request and results from the queue are verified.
This ensures that results of next()s passed to verification are
correctly matched and ordered.

* Integration tests (googleapis#23)

HBase 1.x integration tests

* Add trace logging. (googleapis#24)

* Estimate memory overhead in RequestResourceDescription (googleapis#25)

* Tests: extract executor service to TestRule (googleapis#26)

Extract executor service utilities into TestRule to facilitate code
reuse in other test classes.

* Integration tests: read configuration from xml files

* MirroringBufferedMutator

* MirroringBufferedMutator: integration tests (googleapis#9)

* Fix error introduced in rebase (googleapis#11)

* Obtain resource reservation before scheduling secondary calls (#4)

Fixes a bug when secondary database request Future was created before obtaining resources from FlowController.

* Integration tests - MirroringTable operations (googleapis#10)

* MirroringAsyncConfiguration (googleapis#5)

Add configuration class to be used by MirroringAsyncConnection.

* SecondaryWriteErrorConsumer in MirroringTable (googleapis#15)

Use SecondaryWriteErrorConsumer to handle write errors in secondary database in MirroringTable's writes.

* Use Put to implement Increment and Append (googleapis#16)

* refactor: extract functions using reflection into package utils.reflection

* refactor: extract BatchHelpers into utils

Extract common part of batch() helpers into a class and add Predicate argument to nested classes' constructors making it possible to reuse the code in 2.x client.

* feat: Initial implementation of a subset of asynchronous HBase 2.x Mirroring Client

Contains basic implementation of MirroringAsyncConnection and MirroringAsyncTable.

* refactor: extract FlowController's request cancellation into a method

* fix: Increment ITs fail with Bigtable as primary (googleapis#21)

We were setting timerange on Increment objects used in integration tests
without any reason and Bigtable doesn't support this operation. Setting
timerange in ITs was removed.

* fix: RequestScheduling should handle rejected resource reservations (googleapis#24)

Custom FlowControlerStrategy implementations might, contrary to the
default implementation, resolve reservation requests with exception,
what we should handle by not performing the action that had to acquire
the resources.

* feat: Add OpenCensus tracing and metrics. (googleapis#14)

* fix: make BatchHelpers skip verification of empty read results

BatchHelpers provides error handling of batch() when there may be some partial results.
Before the commit, matching successful reads were redundantly verified if there were none of them.
This commit brings back the behaviour from up to 5a29253: when there are no successful matching reads, a MismatchDetector isn't called on empty arrays.

* refactor: make MirroringAsync{Connection,Table} use SecondaryWriteErrorConsumerWithMetrics

BatchHelpers require using SecondaryWriteErrorConsumerWithMetrics API.

* refactor: make AsyncRequestScheduling accept CompletableFuture<ResourceReservation> instead of ResourceReservation

This change is split off from commit introducing MirroringAsyncTable#batch()

* feat: implement batch() in MirroringAsyncTable

Implementation of MirroringAsyncTable's batch() and
MirroringAsyncTable's methods such as get(List<Get) and put(List<Put>) using it.

* feat: implement failed mutations log (googleapis#19)

Failed secondary mutations are written to disk in JSON format, which the user can parse programmatically or inspect visually.

Each failure is logged as a separate line, which makes it compatible with solutions like logstash.

* refactor: split SplitBatchResponse (googleapis#40)

SplitBatchResponse was refactored into two parts: splitting into
reads/writes and failed/successful. This makes the code simpler and
easier to maintain.

* refactor: extract helper methods in tests (googleapis#48)

* refactor: remove redundant writeWithControlFlow argument

* feat: copy HBase operations' input lists (googleapis#57)

* refactor: remove redundant field from MirroringConnection (googleapis#55)

* feat: verification with sampling (googleapis#28)

* fix: mirror Increment/Append in batch() using Put. (googleapis#47)

* refactor: Move HBaseOperation into WriteOperationInfo (googleapis#68)

* refactor: remove redundant parameter from scheduleWriteWithControlFlow (googleapis#69)

* fix: integration tests - fix build (googleapis#70)

* fix: count references to batch operations (googleapis#63)

* fix: close underlying connections when MirroringConnection is closed (googleapis#49)

* refactor: fix IDE warnings in MirroringAsyncTable test (googleapis#64)

* fix: integration tests - check if write errors were reported (googleapis#71)

* feat: make SecondaryWriteErrorConsumer accept error cause and operation (googleapis#65)

* fix: do not call callbacks with lock held (googleapis#53)

* refactor: use AccumulatedExceptions where appropriate (googleapis#54)

* fix: fix key used in verification sampling ITs (googleapis#77)

* feat: use faillog for handling write errors (googleapis#66)

* refactor: add utilities for Futures (FutureUtils)

* feat: defer closing connections until async operations complete (googleapis#37)

Mirroring client schedules asynchronous operations - to mirror the mutations and to verify reads. Before this PR, closing the MirroringAsyncConnection would result in closing the underlying connections immediately. This made the pending asynchronous operations fail. This PR defers closing the underlying connections until all pending operations complete. It is achieved by reference counting the operations.

* feat: implement AsyncTableBuilder (googleapis#42)

* feat: implement MirroringAsyncTable#checkAndMutate (googleapis#43)

* fix: Implement single Append and Increment as Put (googleapis#38)

* refactor: simplify SecondaryWriteErrorConsumer API (googleapis#78)

* feat: concurrent writes in MirroringTable (googleapis#79)

* test: fix failing concurrent write test (googleapis#120)

* refactor: renames and moves in RequestScheduling (googleapis#87)

* wip: handover session comments

Co-authored-by: Mateusz Walkiewicz <mwalkiewicz@unoperate.com>
Co-authored-by: Adam Czajkowski <prawilny@unoperate.com>
  • Loading branch information
3 people authored May 11, 2022
1 parent b4fe87e commit d850d55
Show file tree
Hide file tree
Showing 115 changed files with 19,235 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Verify

on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
tests_1_x:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('bigtable-hbase-mirroring-client-1.x-parent/bigtable-hbase-mirroring-client-1.x/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: verify 1.x
run: mvn --batch-mode --update-snapshots verify -pl bigtable-hbase-mirroring-client-1.x-parent/bigtable-hbase-mirroring-client-1.x
tests_2_x:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('bigtable-hbase-mirroring-client-2.x-parent/bigtable-hbase-mirroring-client-2.x/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: verify 2.x
run: mvn --batch-mode --update-snapshots verify -pl bigtable-hbase-mirroring-client-1.x-parent/bigtable-hbase-mirroring-client-1.x,bigtable-hbase-mirroring-client-2.x-parent/bigtable-hbase-mirroring-client-2.x
Loading

0 comments on commit d850d55

Please sign in to comment.