Github user JamesRTaylor commented on the issue:
https://github.com/apache/phoenix/pull/239
I don't think it's necessary to fully understand the functionality to do
the refactoring I've mentioned, @akshita-malhotra. Here's how I'd recommend
approaching it:
* create a new interface solely for the purpose of only abstracting
RegionCoprocessorEnvironment access called RegionContext. The interface would
have at least two methods: getRegion and getConfiguration. We might need more
if other methods are called in RegionCoprocessorEnvironment.
* have two implementations of this interface: RegionCoprocessorContext and
RegionShapshotContext. The constructor of RegionCoprocessorContext would take a
RegionCoprocessorEnvironment as an argument, while the RegionShapshotContext
would take a Region and Configuration.
* do an across the board replace of RegionCoprocessorEnvironment with
RegionContext. You can likely not do this for secondary index related code
(org.apache.phoenix.hbase.index.Indexer and PhoenixTransactionalIndexer).
You'll find out here if other methods are called from
RegionCoprocessorEnvironment or ObserverContext (which can be dealt with in a
variety of ways, for example by throwing an UnsupportedOperationException if
need be in the snapshot implementation).
* in the top level coprocessor methods that pass in
RegionCoprocessorEnvironment (mostly abstract BaseScannerRegionObserver class),
instantiate a RegionCoprocessorContext by passing in the
RegionCoprocessorEnvironment. From this point onward, all access will go
through the RegionContext interface.
You could do this refactoring completely separate from the PHOENIX-3744 so
that you don't mix the two. Then PHOENIX-3744 would have something like a
RegionScannerFactory (your RegionObserverUtil) that gives you back a
RegionScanner given a RegionContext and you'd create a RegionShapshotContext as
the backing implementation in your snapshot reading code.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---