You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "Bill Havanki (JIRA)" <ji...@apache.org> on 2014/07/01 17:27:24 UTC

[jira] [Commented] (ACCUMULO-2966) ZooReaderWriter.getInstance ignores changes in params

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

Bill Havanki commented on ACCUMULO-2966:
----------------------------------------

ACCUMULO-2212 introduced a new {{ZooReaderWriterFactory}} class in 1.6.x and higher to replace this static factory method. The factory class does have the same issue, that of using the same instance for repeated calls, even with different parameters.

The implementer here therefore has the option of backporting {{ZooReaderWriterFactory}} to 1.5.x as part of the work.

Even though the factory class is available, it isn't widely used yet; those changes were too numerous for the original ticket. So, they could be included here, or this could be the impetus for a separate ticket to make those changes.

> ZooReaderWriter.getInstance ignores changes in params
> -----------------------------------------------------
>
>                 Key: ACCUMULO-2966
>                 URL: https://issues.apache.org/jira/browse/ACCUMULO-2966
>             Project: Accumulo
>          Issue Type: Bug
>          Components: fate
>    Affects Versions: 1.5.0, 1.5.1, 1.6.0
>            Reporter: Sean Busbey
>            Priority: Minor
>              Labels: newbie
>             Fix For: 1.5.2, 1.6.1, 1.7.0
>
>
> the factory methods on ZooReaderWriter take parameters for servers, timeout, and authentication, but ignores if those parameters are different from the first invocation.
> {code}
>   public static synchronized ZooReaderWriter getInstance(String zookeepers, int timeInMillis, String scheme, byte[] auth) {
>     if (instance == null)
>       instance = new ZooReaderWriter(zookeepers, timeInMillis, scheme, auth);
>     return instance;
>   }
>   /**
>    * get an instance that retries when zookeeper connection errors occur
>    * 
>    * @return an instance that retries when Zookeeper connection errors occur.
>    */
>   public static synchronized IZooReaderWriter getRetryingInstance(String zookeepers, int timeInMillis, String scheme, byte[] auth) {
>     if (retryingInstance == null) {
>       IZooReaderWriter inst = getInstance(zookeepers, timeInMillis, scheme, auth);
>       InvocationHandler ih = new RetryingInvocationHandler(inst);
>       retryingInstance = (IZooReaderWriter) Proxy.newProxyInstance(ZooReaderWriter.class.getClassLoader(), new Class[] {IZooReaderWriter.class}, ih);
>     }
>     return retryingInstance;
>   }
> {code}
> It should either keep a cache keyed on the parameter values or it should throw an exception when they differ from the existing instance.
> Which one depends on wether the intent is to reuse objects or to have ZooReaderWriter be a proper singleton. I'm not sure from context, but I think the cache is the way to go.



--
This message was sent by Atlassian JIRA
(v6.2#6252)