[jira] [Commented] (OAK-3390) Avoid instanceof check in DocumentNodeStore

2015-09-15 Thread Marcel Reutegger (JIRA)

[ 
https://issues.apache.org/jira/browse/OAK-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14744991#comment-14744991
 ] 

Marcel Reutegger commented on OAK-3390:
---

This issue is specifically about the instanceof check in DocumentNodeStore 
which was broken because of the wrapper classes that may be present. I agree, 
the current fix is not the final solution, but it is a first step. As mentioned 
before, I think the Builder class should be split into backend specific 
implementations. That way the MongoDB builder implementation would override the 
factory method without the need to perform an instanceof check. It already 
knows it created a MongoDocumentStore.

For the LastRevRecoveryAgent I created OAK-3405.

> Avoid instanceof check in DocumentNodeStore
> ---
>
> Key: OAK-3390
> URL: https://issues.apache.org/jira/browse/OAK-3390
> Project: Jackrabbit Oak
>  Issue Type: Bug
>  Components: core, mongomk
>Affects Versions: 1.3.4
>Reporter: Marcel Reutegger
>Assignee: Marcel Reutegger
> Fix For: 1.3.7
>
>
> The instanceof MongoDocumentStore check does not work anymore when the store 
> is wrapped with e.g. the LeaseCheckDocumentStoreWrapper.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OAK-3390) Avoid instanceof check in DocumentNodeStore

2015-09-14 Thread Julian Reschke (JIRA)

[ 
https://issues.apache.org/jira/browse/OAK-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14743614#comment-14743614
 ] 

Julian Reschke commented on OAK-3390:
-

Hmmm.

1) This doesn't remove the "instanceof", it just moves it into a different 
class.

2) We still have the "instanceof" in LastRevRecoveryAgent.


> Avoid instanceof check in DocumentNodeStore
> ---
>
> Key: OAK-3390
> URL: https://issues.apache.org/jira/browse/OAK-3390
> Project: Jackrabbit Oak
>  Issue Type: Bug
>  Components: core, mongomk
>Affects Versions: 1.3.4
>Reporter: Marcel Reutegger
>Assignee: Marcel Reutegger
> Fix For: 1.3.7
>
>
> The instanceof MongoDocumentStore check does not work anymore when the store 
> is wrapped with e.g. the LeaseCheckDocumentStoreWrapper.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OAK-3390) Avoid instanceof check in DocumentNodeStore

2015-09-14 Thread Stefan Egli (JIRA)

[ 
https://issues.apache.org/jira/browse/OAK-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14743049#comment-14743049
 ] 

Stefan Egli commented on OAK-3390:
--

my take on doing a generic {{Adaptable}} is that that makes sense in a Silng 
Resource context since Resource is going to be very frequently used and will 
have many different adapter classes - while as with {{DocumentNodeStore}} we're 
inside an implementation and the number of adapter classes will be very few and 
are mostly known beforehand.

> Avoid instanceof check in DocumentNodeStore
> ---
>
> Key: OAK-3390
> URL: https://issues.apache.org/jira/browse/OAK-3390
> Project: Jackrabbit Oak
>  Issue Type: Bug
>  Components: core, mongomk
>Affects Versions: 1.3.4
>Reporter: Marcel Reutegger
> Fix For: 1.3.7
>
>
> The instanceof MongoDocumentStore check does not work anymore when the store 
> is wrapped with e.g. the LeaseCheckDocumentStoreWrapper.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OAK-3390) Avoid instanceof check in DocumentNodeStore

2015-09-14 Thread Julian Reschke (JIRA)

[ 
https://issues.apache.org/jira/browse/OAK-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14743062#comment-14743062
 ] 

Julian Reschke commented on OAK-3390:
-

More breakage in a different place: 
https://issues.apache.org/jira/browse/OAK-3389 (and I don't believe we'd want 
to handle that with Builder extensions). Also, we know that the multiplexing 
implementation will have the same problem.

> Avoid instanceof check in DocumentNodeStore
> ---
>
> Key: OAK-3390
> URL: https://issues.apache.org/jira/browse/OAK-3390
> Project: Jackrabbit Oak
>  Issue Type: Bug
>  Components: core, mongomk
>Affects Versions: 1.3.4
>Reporter: Marcel Reutegger
> Fix For: 1.3.7
>
>
> The instanceof MongoDocumentStore check does not work anymore when the store 
> is wrapped with e.g. the LeaseCheckDocumentStoreWrapper.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OAK-3390) Avoid instanceof check in DocumentNodeStore

2015-09-14 Thread Julian Reschke (JIRA)

[ 
https://issues.apache.org/jira/browse/OAK-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14743056#comment-14743056
 ] 

Julian Reschke commented on OAK-3390:
-

If that was true, why do we have the current breakage then? :-)

> Avoid instanceof check in DocumentNodeStore
> ---
>
> Key: OAK-3390
> URL: https://issues.apache.org/jira/browse/OAK-3390
> Project: Jackrabbit Oak
>  Issue Type: Bug
>  Components: core, mongomk
>Affects Versions: 1.3.4
>Reporter: Marcel Reutegger
> Fix For: 1.3.7
>
>
> The instanceof MongoDocumentStore check does not work anymore when the store 
> is wrapped with e.g. the LeaseCheckDocumentStoreWrapper.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OAK-3390) Avoid instanceof check in DocumentNodeStore

2015-09-14 Thread Marcel Reutegger (JIRA)

[ 
https://issues.apache.org/jira/browse/OAK-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14743057#comment-14743057
 ] 

Marcel Reutegger commented on OAK-3390:
---

I agree with Stefan. We are talking about as single instanceof we would like to 
get rid of. As mentioned before my preference is to move this factory method to 
a place where we know what kind of backend store is used. This is currently the 
DocumentMK.Builder, but in the long run we should probably split it up into a 
generic Builder and introduce two new builders: one for MongoDB and another one 
for RDB.

> Avoid instanceof check in DocumentNodeStore
> ---
>
> Key: OAK-3390
> URL: https://issues.apache.org/jira/browse/OAK-3390
> Project: Jackrabbit Oak
>  Issue Type: Bug
>  Components: core, mongomk
>Affects Versions: 1.3.4
>Reporter: Marcel Reutegger
> Fix For: 1.3.7
>
>
> The instanceof MongoDocumentStore check does not work anymore when the store 
> is wrapped with e.g. the LeaseCheckDocumentStoreWrapper.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OAK-3390) Avoid instanceof check in DocumentNodeStore

2015-09-11 Thread Julian Reschke (JIRA)

[ 
https://issues.apache.org/jira/browse/OAK-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14740701#comment-14740701
 ] 

Julian Reschke commented on OAK-3390:
-

[~mreutegg] note that the changes for OAK-3313 now cause 
{{LastRevRecoveryAgentTest}} to not test the Mongo variant anymore.

> Avoid instanceof check in DocumentNodeStore
> ---
>
> Key: OAK-3390
> URL: https://issues.apache.org/jira/browse/OAK-3390
> Project: Jackrabbit Oak
>  Issue Type: Bug
>  Components: core, mongomk
>Affects Versions: 1.3.4
>Reporter: Marcel Reutegger
> Fix For: 1.3.7
>
>
> The instanceof MongoDocumentStore check does not work anymore when the store 
> is wrapped with e.g. the LeaseCheckDocumentStoreWrapper.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OAK-3390) Avoid instanceof check in DocumentNodeStore

2015-09-10 Thread Stefan Egli (JIRA)

[ 
https://issues.apache.org/jira/browse/OAK-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14738798#comment-14738798
 ] 

Stefan Egli commented on OAK-3390:
--

or .. we could also demand DocumentStore to provide an adapter for the three 
cases we currently have (MissingLastRevSeeker, BlobReferenceIterator and 
VersionGCSupport) via a {{DocumentStore.adaptTo()}} - we could of course 
generalize this in an interface but so far the use cases are very limited and 
known..

> Avoid instanceof check in DocumentNodeStore
> ---
>
> Key: OAK-3390
> URL: https://issues.apache.org/jira/browse/OAK-3390
> Project: Jackrabbit Oak
>  Issue Type: Bug
>  Components: core, mongomk
>Affects Versions: 1.3.4
>Reporter: Marcel Reutegger
> Fix For: 1.3.7
>
>
> The instanceof MongoDocumentStore check does not work anymore when the store 
> is wrapped with e.g. the LeaseCheckDocumentStoreWrapper.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OAK-3390) Avoid instanceof check in DocumentNodeStore

2015-09-10 Thread Julian Reschke (JIRA)

[ 
https://issues.apache.org/jira/browse/OAK-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14738814#comment-14738814
 ] 

Julian Reschke commented on OAK-3390:
-

I think we shouldn't conflate the two issues. 1) is making the DS APIs powerful 
enough so that callers do not special-case certain implementations. 2) is the 
problem of wrapper classes and extension interfaces. For 1) we have Thomas' 
proposal (https://issues.apache.org/jira/browse/OAK-3213), for 2) I'd prefer 
something like my proposal above.

> Avoid instanceof check in DocumentNodeStore
> ---
>
> Key: OAK-3390
> URL: https://issues.apache.org/jira/browse/OAK-3390
> Project: Jackrabbit Oak
>  Issue Type: Bug
>  Components: core, mongomk
>Affects Versions: 1.3.4
>Reporter: Marcel Reutegger
> Fix For: 1.3.7
>
>
> The instanceof MongoDocumentStore check does not work anymore when the store 
> is wrapped with e.g. the LeaseCheckDocumentStoreWrapper.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OAK-3390) Avoid instanceof check in DocumentNodeStore

2015-09-10 Thread Marcel Reutegger (JIRA)

[ 
https://issues.apache.org/jira/browse/OAK-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14738803#comment-14738803
 ] 

Marcel Reutegger commented on OAK-3390:
---

I would rather move this kind of factory method into the Builder. That way the 
builder can decide what BlobReferenceIterator needs to be created.

> Avoid instanceof check in DocumentNodeStore
> ---
>
> Key: OAK-3390
> URL: https://issues.apache.org/jira/browse/OAK-3390
> Project: Jackrabbit Oak
>  Issue Type: Bug
>  Components: core, mongomk
>Affects Versions: 1.3.4
>Reporter: Marcel Reutegger
> Fix For: 1.3.7
>
>
> The instanceof MongoDocumentStore check does not work anymore when the store 
> is wrapped with e.g. the LeaseCheckDocumentStoreWrapper.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OAK-3390) Avoid instanceof check in DocumentNodeStore

2015-09-10 Thread Stefan Egli (JIRA)

[ 
https://issues.apache.org/jira/browse/OAK-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14738782#comment-14738782
 ] 

Stefan Egli commented on OAK-3390:
--

What about introducing {{DocumentStore.unwrap()}} which would provide the 
underlying documentstore should it be wrapped, or this ?

> Avoid instanceof check in DocumentNodeStore
> ---
>
> Key: OAK-3390
> URL: https://issues.apache.org/jira/browse/OAK-3390
> Project: Jackrabbit Oak
>  Issue Type: Bug
>  Components: core, mongomk
>Affects Versions: 1.3.4
>Reporter: Marcel Reutegger
> Fix For: 1.3.7
>
>
> The instanceof MongoDocumentStore check does not work anymore when the store 
> is wrapped with e.g. the LeaseCheckDocumentStoreWrapper.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OAK-3390) Avoid instanceof check in DocumentNodeStore

2015-09-10 Thread Julian Reschke (JIRA)

[ 
https://issues.apache.org/jira/browse/OAK-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14738787#comment-14738787
 ] 

Julian Reschke commented on OAK-3390:
-

Recommendation: borrow from both 
http://docs.oracle.com/javase/6/docs/api/java/sql/Wrapper.html and Sling's 
Adaptable.

- checker function canAdaptTo
- adapter function adaptTo, potentially returning null

The reason for having the checker is that sometimes it can be expensive to 
adapt, and the caller just needs to know whether adapting would be possible.

Define interface in oak-commons, and make DocumentStore implement that.


> Avoid instanceof check in DocumentNodeStore
> ---
>
> Key: OAK-3390
> URL: https://issues.apache.org/jira/browse/OAK-3390
> Project: Jackrabbit Oak
>  Issue Type: Bug
>  Components: core, mongomk
>Affects Versions: 1.3.4
>Reporter: Marcel Reutegger
> Fix For: 1.3.7
>
>
> The instanceof MongoDocumentStore check does not work anymore when the store 
> is wrapped with e.g. the LeaseCheckDocumentStoreWrapper.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (OAK-3390) Avoid instanceof check in DocumentNodeStore

2015-09-10 Thread Julian Reschke (JIRA)

[ 
https://issues.apache.org/jira/browse/OAK-3390?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14738974#comment-14738974
 ] 

Julian Reschke commented on OAK-3390:
-

Proposed interface:

{code}
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.jackrabbit.oak.commons;

/**
 * Identifies objects which can be adapted to other types or representations of 
the same object.
 * 
 * Inspired by Apache Sling's Adaptable and Java SQL's Wrapper 
interfaces.
 */
public interface Adaptable {

/**
 * Checks whether the adaptable can be converted to the specified type.
 * 
 * @param type
 *The generic type to check for
 * @return {@code true} if a call to {link {@link #adaptTo(Class)}} is
 * likely to succeed
 */
public boolean isAdaptable(Class type);

/**
 * Adapts the adaptable to another type.
 * 
 * Please note that it is explicitly left as an implementation detail
 * whether each call to this method with the same type yields the same
 * object or a new object on each call.
 * 
 * Implementations of this method should document their adapted types as
 * well as their behavior with respect to returning newly created or not
 * instance on each call.
 * 
 * @param 
 *The generic type to which this object is adapted to
 * @param type
 *The generic type to which this object is adapted to
 * @return The adapter target or {@code null} if the object cannot adapt to
 * the requested type
 */
public  AdapterType adaptTo(Class type);
}
{code}

> Avoid instanceof check in DocumentNodeStore
> ---
>
> Key: OAK-3390
> URL: https://issues.apache.org/jira/browse/OAK-3390
> Project: Jackrabbit Oak
>  Issue Type: Bug
>  Components: core, mongomk
>Affects Versions: 1.3.4
>Reporter: Marcel Reutegger
> Fix For: 1.3.7
>
>
> The instanceof MongoDocumentStore check does not work anymore when the store 
> is wrapped with e.g. the LeaseCheckDocumentStoreWrapper.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)