[ 
https://issues.apache.org/jira/browse/HBASE-19356?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16271890#comment-16271890
 ] 

Appy commented on HBASE-19356:
------------------------------

There are two diff problems here:
1) Interfaces which have no internal implementations. For eg. *Observer 
interfaces. Like [~zyork] and [~stack] said above, our move to using default 
keywords in those should solve their problem.
2) Interfaces which have our internal implementations, For eg. RegionScanner, 
Table, etc. The only correct way they can augment their own functionality on 
top of our internal implementations (which are private) is via use of 
delegates. Using default keyword in this case doesn't solve the problem 
(rather, i think, it creates more problem, explained below).
(If RegionScanner is no longer in hbase2, maybe ignore that class, but if we 
have more type 2 cases, the general problem still stands)

First, why are we talking about delegates? We haven't encountered them yet.
Taking a simple case of type 2.
{noformat}
---------------- HBase world ----------------
IA.Public
interface Foo {
  void featureA();
  void featureB();
}

IA.Private
class FooImpl implements Foo {
  @Override void featureA() { /* we do our internal stuff */ }
  @Override void featureB() { /* we do our internal stuff */ }
}

---------------- Downstream world ----------------
class ExtendedFoo implements Foo {

  Foo delegateForHbaseInternal;

  ExtendedFoo(Foo delegate) {
    delegateForHbaseInternal = delegate
  }

  @Override void featureA() {
    // augment feature A
    .....
    // make sure hbase internal stuff works
    delegateForHbaseInternal.featureA();
  }

  @Override void featureB() {
    // We don't want anything to do with featureB, directly call delegate.
    delegateForHbaseInternal.featureB();
  }
}
{noformat}

The problem is when we add {{void featureC()}} in our interface.
Without default keyword, their delegate will break. Fix is simple, but i agree, 
doing it every release for many interfaces should be painful.
With default keyword, their delegate won't break. But now, it's silently 
failing by not calling {{delegateForHbaseInternal.featureC(); }}. That's what i 
meant by "default keyword doesn't work well with delegates".

My change of opinion here from 'we shouldn't to this' to 'maybe we should do 
this' was mainly because this may be most common (in fact, only way) 
downstreamers use it.
But let's punt it to 2.1, lot has changed in CP in 2.0. Your old problems might 
be gone, and there will be new ones [~jamestaylor]. Let's discuss it then.

> Provide delegators and base implementation for Phoenix implemented interfaces
> -----------------------------------------------------------------------------
>
>                 Key: HBASE-19356
>                 URL: https://issues.apache.org/jira/browse/HBASE-19356
>             Project: HBase
>          Issue Type: Improvement
>            Reporter: James Taylor
>
> Many of the changes Phoenix needs to make for various branches to support 
> different versions of HBase are due to new methods being added to interfaces. 
> Often times Phoenix can  use a noop or simply needs to add the new method to 
> it's delegate implementor. It'd be helpful if HBase provided base 
> implementations and delegates that Phoenix could use instead. Here are some 
> that come to mind:
> - RegionScanner
> - HTableInterface (Table interface now?)
> - RegionObserver
> There are likely others that [~rajeshbabu], [[email protected]], and 
> [~elserj] would remember.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to