You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Göktürk Gezer <go...@gmail.com> on 2012/05/16 05:58:10 UTC

Problem of JDBM being hard(impossible) to reconfigure once it is initialized

Hi Everyone,

As i told you in OSGI branch update, JDBM is so immutable in runtime.
Almost every setter calls checkInitialized() method first which throws an
exception when its already initialized.

We have to change that behavior in as much aspects of it as we can.
Otherwise there is no point in going into OSGI. However i can't always be
sure what my changes might lead on runtime. I need some serious help here,
especially from those are actively working on JDBM, otherwise i'll jump
into trial and error cycle which will probably last long.

Here is the current configuration points for JdbmPartition:

   - cacheSize(int)
   - optimizerEnabled(boolean)
   - partitionPath(File)
   - suffixDn(Dn)
   - syncOnWrite(boolean)
   - indexedAttributes(List<Index>)

Currently none of them is reconfigurable, once the partition is
initialized. However i need to know which are actually reconfigurable among
these ones. And which are not really reconfigurable and why?

Every reconfiguration will invoke some setter method at desired
configuration point. So i guess we can make this reconfigurations work
actually based on it's initialized or not, rather than throwing an
exception blindly.

For your information, as we have the lifecycle control capability of
components created from within ApacheDS, we can implement some fancy stuff.
Like re-instantiating a component when one of its immutable property is
changed, or stop it and remove from DirectoryService when one of its
immutable property is changed to prevent accepting operations while
reconfiguring. These migtht be implemented in case there is " no
possibility! " to handle reconfigurations in live and initialized
JdbmPartition reference.

I appreciate every single idea on this matter !

Thanks,
Gokturk

Re: Problem of JDBM being hard(impossible) to reconfigure once it is initialized

Posted by Göktürk Gezer <go...@gmail.com>.
On Wed, May 23, 2012 at 1:36 AM, Emmanuel Lécharny <el...@gmail.com>wrote:

> Le 5/23/12 12:01 AM, Selcuk AYA a écrit :
>
>  I  do not know the OSGI jargon but I believe,  at the end, changing
>> these should reduce to something like this:
>>
>> 1) quiesce the necessary ldap operations: The simplest thing to do
>> would be to block all operations quiesce all the outstanding
>> operations. In some cases, it would be enough to block only searches.
>> There might be some cases where you do not need any blocking at all. I
>> do not
>>
>
> I'm not comfortable with the idea of quiscing the ldap operations. The
> server is supposed to work 24x7, and if we do add some way to modify the
> backend config on the fly, then the user should not notice that.
>
Quiscing the Ldap Operations is necessary at some point. Either in
DefaultOperationManager level of JdbmPartition level. If we handle that
other than DefaultOperationManager level, then we and 3th party developers
houldhave to ensure locking is ensured in consistent manner. I believe
quiscing the operations at DefaultOperationManager is our best shot, and
reconfiguration is not something occurs frequently. Clients will only get
late answers to their query when some reconfiguration is in place. Not a
big deal IMO?

>
> See my comments below.
>
>
>> 2) do the configuration: In the end I am assuming the configuration is
>> delegated to the component itself to do the reconfig.
>>
>> 3) unblock the operations.
>>
>>
>> For index add:
>>
>> * queisce any ldap operation that might modify the data. Then notify
>> the partition to add the index. Partition will scan the master table
>> and build the index and swap its indexed attributes. Then unlock the
>> operations.
>>
> Adding an index should be done while the server is still able to process
> requests. The thing is that the newly added server should not be available
> until it has been created. The real problem is that we won't be able to
> parse the master table fast enough to have all the subscequent
> modifications into it, so this is a two steps operation :
> - do a full scan search on the master table, and create the additional
> index. We should be safe here, because we will use the current version of
> the master table when we start the search.
> - then for every modification done after the beginning of step 1, apply
> those changes to the index. If we have some more changes since we started
> this step, then do it again.
>
What happens if some modification is done while we're executing step2 !
Again, we need locking at some level.

>
> Now, we can use this index.
>
>
>> For index delete:
>> * block all operations, and remove the index from the indexes list.
>> Maybe commit this change in partition config. unlock changes. Then
>> continue deleting  index file.
>>
>
> Here, it's simpler. The operation using this index will continue to use
> it, until they are done. New operations won't be allowed to use it. Once
> the number of requests using this index is 0, then the index can be
> deleted. I don't think we need to block any operation here.


If we enter the deletion code while some operation is using indexes without
waiting for that operation to exit, this'll be clearly a concurrency
problem. Operation might reference to a deleted index at some point. We
need to wait for all operations to return, we shouldn't allow any new
operation using this index until we deleted the index. So we can set some
locking around index retrieval code, however this would be hard to
implement sacrifice to prevent contention. We can't run away from
contention at Jdbm, we can only divide it to sublevels anyway.

>
>
>>
>> For suffixdn change:
>>
>> * I believe this is a rename operation. again block all operations and
>> do the rename. Then unblock.
>>
> changing teh suffix DN is just a matter of modifying the configuration,
> and the DnNode structure. The problem is that we rebuild all the entries'
> DN using the partition suffixDn, so we have to be careful when doing so.
> The request being processed when the rename occurs should be fulfilled with
> the initial suffixDn.

I have a question here:
Does the suffix dn should be compatible with context entry for that
partition ?

>
>
>> Working directory change;
>> * Block all opreations and let the parition change its config dir. For
>> jdbm, this would be a copy of it working directory.
>>
>
> Here, this is an administrative task. Not sure we want to do that on a
> running server...

Yeah we shouldn't move partition files around directories. I believe if
partition path is changed, it must trigger partition implementation to look
at specified directory to initialize itself from scratch based on given
directory's content.

I recommend looking at the things we discussed with Alex on this thread. We
should implement some immutability concept for some component types.
According to this discussion here is what we may do for JdbmPartition.

* Any reconfiguration will try to create a new instance of JdbmPartition
with new configuration.
* If instance creation is failed due to wrong configuration,
reconfiguration is aborted
  else:
  We will switch runtime instance with created instance while quiscing
Operations, and initialize the DirectoryService and new Partition reference.

That way:
* we won't change code of JdbmPartition at all.
* We'll let operations run while we're creating new instance, removing
contention at some degree.
* Contention will only occur while we switch runtime references of
Partition and initialize new reference inside DirectoryService.

But to do that, we must be sure that side-by-side references can be created
with same configuration. For example for LdapServer whis wouldn't be
possible, because of its 'network socket' usage, it wouldn't be possible to
create new instance if it for reconfiguration operation.

>
>
>
> --
> Regards,
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com
>
>

Re: Problem of JDBM being hard(impossible) to reconfigure once it is initialized

Posted by Alex Karasulu <ak...@apache.org>.
On Wed, May 23, 2012 at 1:36 AM, Emmanuel Lécharny <el...@gmail.com> wrote:
> Le 5/23/12 12:01 AM, Selcuk AYA a écrit :
>
>> I  do not know the OSGI jargon but I believe,  at the end, changing
>> these should reduce to something like this:
>>
>> 1) quiesce the necessary ldap operations: The simplest thing to do
>> would be to block all operations quiesce all the outstanding
>> operations. In some cases, it would be enough to block only searches.
>> There might be some cases where you do not need any blocking at all. I
>> do not
>
>
> I'm not comfortable with the idea of quiscing the ldap operations. The
> server is supposed to work 24x7, and if we do add some way to modify the
> backend config on the fly, then the user should not notice that.

+1

I agree with Emmanuel here. Such changes should not interrupt the
operation of the server.

> See my comments below.
>
>>
>> 2) do the configuration: In the end I am assuming the configuration is
>> delegated to the component itself to do the reconfig.
>>
>> 3) unblock the operations.
>>
>>
>> For index add:
>>
>> * queisce any ldap operation that might modify the data. Then notify
>> the partition to add the index. Partition will scan the master table
>> and build the index and swap its indexed attributes. Then unlock the
>> operations.
>
> Adding an index should be done while the server is still able to process
> requests. The thing is that the newly added server should not be available
> until it has been created.

I guess you mean the newly added index here above.

The real problem is that we won't be able to
> parse the master table fast enough to have all the subscequent modifications
> into it, so this is a two steps operation :
> - do a full scan search on the master table, and create the additional
> index. We should be safe here, because we will use the current version of
> the master table when we start the search.
> - then for every modification done after the beginning of step 1, apply
> those changes to the index. If we have some more changes since we started
> this step, then do it again.
>
> Now, we can use this index.

OK let me see if I understand. To add an index we:

1). Note the version (V0) when the request to build the index arrives.
Start a full master table scan at version V0 to build the new index.

2). Once the index has been built for this version acquire an
exclusive write lock to prevent writes.

3a). If no changes occurred while building the index, meaning we're
still at V0. Then we enable the index and release the exclusive write
lock.

3b). If changes have occurred while building the index, then we update
the index with changes V1-V0. Then we enable the index and release the
exclusive write lock.

>>
>> For index delete:
>> * block all operations, and remove the index from the indexes list.
>> Maybe commit this change in partition config. unlock changes. Then
>> continue deleting  index file.
>
>
> Here, it's simpler. The operation using this index will continue to use it,
> until they are done. New operations won't be allowed to use it. Once the
> number of requests using this index is 0, then the index can be deleted. I
> don't think we need to block any operation here.

We just need an index state. It should be marked as deleted or offline
so when a new search comes in while waiting for the others to finish
using this index we simply do not use the index. So we need some index
state information.

>>
>>
>> For suffixdn change:
>>
>> * I believe this is a rename operation. again block all operations and
>> do the rename. Then unblock.
>
> changing teh suffix DN is just a matter of modifying the configuration, and
> the DnNode structure. The problem is that we rebuild all the entries' DN
> using the partition suffixDn, so we have to be careful when doing so. The
> request being processed when the rename occurs should be fulfilled with the
> initial suffixDn.

+1

>>
>> Working directory change;
>> * Block all opreations and let the parition change its config dir. For
>> jdbm, this would be a copy of it working directory.
>
>
> Here, this is an administrative task. Not sure we want to do that on a
> running server...

What other option is there?

You should not have to stop and re-start the server just to rename a
partition suffix. We simply need to mark (as we did for indices) the
partition as offline waiting until all current in progress operations
complete on that partition. New requests should not be processed for
it. Maybe we can return an unwilling to perform result response.

Then bring the partition online in the new suffix after doing the copy
and making all the needed changes. This should be a really fast
operation because the file system operation is rename. The other
suffix configuration changes are point changes. It should not take
long regardless of the size of the partition.

-- 
Best Regards,
-- Alex

Re: Problem of JDBM being hard(impossible) to reconfigure once it is initialized

Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 5/23/12 12:01 AM, Selcuk AYA a écrit :
> I  do not know the OSGI jargon but I believe,  at the end, changing
> these should reduce to something like this:
>
> 1) quiesce the necessary ldap operations: The simplest thing to do
> would be to block all operations quiesce all the outstanding
> operations. In some cases, it would be enough to block only searches.
> There might be some cases where you do not need any blocking at all. I
> do not

I'm not comfortable with the idea of quiscing the ldap operations. The 
server is supposed to work 24x7, and if we do add some way to modify the 
backend config on the fly, then the user should not notice that.

See my comments below.
>
> 2) do the configuration: In the end I am assuming the configuration is
> delegated to the component itself to do the reconfig.
>
> 3) unblock the operations.
>
>
> For index add:
>
> * queisce any ldap operation that might modify the data. Then notify
> the partition to add the index. Partition will scan the master table
> and build the index and swap its indexed attributes. Then unlock the
> operations.
Adding an index should be done while the server is still able to process 
requests. The thing is that the newly added server should not be 
available until it has been created. The real problem is that we won't 
be able to parse the master table fast enough to have all the 
subscequent modifications into it, so this is a two steps operation :
- do a full scan search on the master table, and create the additional 
index. We should be safe here, because we will use the current version 
of the master table when we start the search.
- then for every modification done after the beginning of step 1, apply 
those changes to the index. If we have some more changes since we 
started this step, then do it again.

Now, we can use this index.
>
> For index delete:
> * block all operations, and remove the index from the indexes list.
> Maybe commit this change in partition config. unlock changes. Then
> continue deleting  index file.

Here, it's simpler. The operation using this index will continue to use 
it, until they are done. New operations won't be allowed to use it. Once 
the number of requests using this index is 0, then the index can be 
deleted. I don't think we need to block any operation here.
>
>
> For suffixdn change:
>
> * I believe this is a rename operation. again block all operations and
> do the rename. Then unblock.
changing teh suffix DN is just a matter of modifying the configuration, 
and the DnNode structure. The problem is that we rebuild all the 
entries' DN using the partition suffixDn, so we have to be careful when 
doing so. The request being processed when the rename occurs should be 
fulfilled with the initial suffixDn.
>
> Working directory change;
> * Block all opreations and let the parition change its config dir. For
> jdbm, this would be a copy of it working directory.

Here, this is an administrative task. Not sure we want to do that on a 
running server...


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com


Re: Problem of JDBM being hard(impossible) to reconfigure once it is initialized

Posted by Selcuk AYA <ay...@gmail.com>.
I  do not know the OSGI jargon but I believe,  at the end, changing
these should reduce to something like this:

1) quiesce the necessary ldap operations: The simplest thing to do
would be to block all operations quiesce all the outstanding
operations. In some cases, it would be enough to block only searches.
There might be some cases where you do not need any blocking at all. I
do not

2) do the configuration: In the end I am assuming the configuration is
delegated to the component itself to do the reconfig.

3) unblock the operations.


For index add:

* queisce any ldap operation that might modify the data. Then notify
the partition to add the index. Partition will scan the master table
and build the index and swap its indexed attributes. Then unlock the
operations.

For index delete:
* block all operations, and remove the index from the indexes list.
Maybe commit this change in partition config. unlock changes. Then
continue deleting  index file.


For suffixdn change:

* I believe this is a rename operation. again block all operations and
do the rename. Then unblock.

Working directory change;
* Block all opreations and let the parition change its config dir. For
jdbm, this would be a copy of it working directory.

Using the same techniques:

* We should be able to add/remove and interceptor
* add a partition. This should not require blocking of operations.
* remove a partition.

thanks
Selcuk

On Sun, May 20, 2012 at 8:22 PM, Göktürk Gezer <go...@gmail.com> wrote:
>
>
> On Mon, May 21, 2012 at 1:12 AM, Alex Karasulu <ak...@apache.org> wrote:
>>
>> On Wed, May 16, 2012 at 6:58 AM, Göktürk Gezer <go...@gmail.com>
>> wrote:
>> > Hi Everyone,
>> >
>> > As i told you in OSGI branch update, JDBM is so immutable in runtime.
>> > Almost
>> > every setter calls checkInitialized() method first which throws an
>> > exception
>> > when its already initialized.
>>
>> This may be unavoidable but I am not qualified to make this call. At
>> the present moment I am not familiar enough with the internals to
>> understand how each setting would impact a reconfiguration. It may be
>> trivial with some settings like for example cache settings by changing
>> just a few things in JDBM.
>
> Most of checkInitialized() calls are necessary for current design of
> Jdbm/AbstractBTree Partition.
>>
>>
>> In the worst case, if reinitialization with re-configuration must take
>> place then the proper management can be handled. For example changing
>> the files/directory path for the record manager for example can occur
>> with a move of the actual files after the shutdown before the
>> re-configuration, and before restarting the record manager service
>> with the new setting for the the db file. Just giving this as one
>> example. The other settings might require less management overheads.
>
> Moving system files of partition is only necessary when we change its
> partitionId as i see?
> And i believe moving partition files around directories is conflicting with
> partitionId property's purpose.
> Using partitionId property as a pointer to where partition system files are
> is more consistent IMO. So when
> somebody changes some partition's partitionId, then this partition instance
> must be reinitialized to use the partition files
> under specified directory. If new specified directory has incompatible
> content then we switch back to previous partitionId.
> ( ComponentHub system supports what i described: when some active component
> is reconfigured in a state which is not valid,
>  then reconfiguration is reverted. further explained below.)
>>
>>
>> > We have to change that behavior in as much aspects of it as we can.
>> > Otherwise there is no point in going into OSGI. However i can't always
>> > be
>> > sure what my changes might lead on runtime. I need some serious help
>> > here,
>> > especially from those are actively working on JDBM, otherwise i'll jump
>> > into
>> > trial and error cycle which will probably last long.
>> >
>> > Here is the current configuration points for JdbmPartition:
>>
>> OK Jdbm partition unlike jdbm internals proper I have some suggestions
>> on. Some settings are not that difficult to deal with on
>> re-configuration events.
>>
>> These should be easier to handle:
>>
>> > cacheSize(int)
>> > optimizerEnabled(boolean)
>> > syncOnWrite(boolean)
>
> First 2 don't have checkInitialized() checks already. syncOnWrite() has that
> check, but i guess we can remove it.
> We only have to insert sync() call before setting this property to ensure
> none remains in buffers. Right?
>>
>>
>> These below I suspect will impose many more management issues to
>> properly reconfigure on the fly due to file movements and the creation
>> of new indices (deletion of old indices).
>
> Yes, they're currently not reconfigurable and it seems hard to make them.
> All three is designed to be read at beginning and no altering mechanism is
> supplied.
>
>>
>>
>> > indexedAttributes(List<Index>)
>> > partitionPath(File)
>> > suffixDn(Dn)
>> >
>> > Currently none of them is reconfigurable, once the partition is
>> > initialized.
>>
>> Right.
>>
>> > However i need to know which are actually reconfigurable among these
>> > ones.
>> > And which are not really reconfigurable and why?
>> >
>> > Every reconfiguration will invoke some setter method at desired
>> > configuration point. So i guess we can make this reconfigurations work
>> > actually based on it's initialized or not, rather than throwing an
>> > exception
>> > blindly.
>>
>> Of course we want re-configuration to be hot because that's really
>> cool. Sometimes you just don't have the option of shutting down the
>> server. Then there are software updates to the actual component and
>> that adds yet another dimension of problems to hot reconfiguration. In
>> the case of the JDBM partition some changes that change the structure
>> will make it so the jdbm db files are no longer compatible. So hot
>> deploys of new versions are not easy or may require long running
>> changes.
>
> This dynamism can be handled, but i'll cause pain of course, but not much.
> .db files being incompatible with new version is
> something JdbmPartition implementation must handle by itself IMO. It must
> have mechanisms to migrate old .db files to its own format at initialization
> time.
>
> And i remember now that i forgot to implement hot bundle replacements(cold
> replacements are supported which is simply replacing bundle when none of its
> components are instantiated). But no worries, with cold replacement
> implemented, it is easy to implement hot reconfiguration in minutes.
>>
>>
>> Another option or approach can be to handle some of these long running
>> reconfiguration or software component (bundle) update events not hot
>> (live) while the server is up and running but after a restart. However
>> I do not recommend this. There are easy ways to mitigate all these
>> problems.
>
> No, it would not be good. Conflicting with OSGI anyway.
>>
>>
>> > For your information, as we have the lifecycle control capability of
>> > components created from within ApacheDS, we can implement some fancy
>> > stuff.
>> > Like re-instantiating a component when one of its immutable property is
>> > changed, or stop it and remove from DirectoryService when one of its
>> > immutable property is changed to prevent accepting operations while
>> > reconfiguring. These migtht be implemented in case there is " no
>> > possibility! " to handle reconfigurations in live and initialized
>> > JdbmPartition reference.
>>
>> This is the difference between two different modes of reconfiguration:
>>
>> (1) An "in-place" re-configuration event recovery by a reconfigured
>> component while it continues to operate.
>> (2) A component instance swap out where the reconfiguration causes a
>> new instance of the component to be constructed and configured with
>> the new settings while on standby. Until the standby is started and
>> operational the old component continues to operate. Then the old is
>> shutdown after a swap out.
>>
>> Overall the #2 approach is much better in my opinion. Why? Because you
>> can never predict the outcome of in place modifications to settings.
>> Changing the component directly may not be something the bundle
>> developer accounted for right?
>
> Here is how i handled it, (could be changed of course):
>  When configuration of some component is changed(via config partition or
> webconsole plugin which i'll implement later...),
> new configuration's validity is checked. Valid means all property values are
> compatible with the property types defined in component's metadata.
>  * for primitives no check is performed, because they are ensured by Ldap
> schema which is being created for that component specifically.
>  * for reference types, it's checked that referenced component's type is
> compatible with property's type.
>  * for collection types, same with reference types + check if all collection
> items are compatible with specified collection item type.
>  * some more consistency checks.
> So after these checks, new configuration is considered valid and it's sent
> to underlying component framework which is used to create the component in
> first hand to reconfigure that component. So at that point, it is guaranteed
> that underlying component framework will not complain about any type
> clashes.
>
> However, component implementation can reject some configuration options even
> if it is valid schematically. At that point component implementation can
> choose to set some default value for this property or simply raise an
> exception. If exception is thrown, then reconfigured component is
> deactivated completely and it is set as dirty, meaning any further
> reconfiguration will cause it to be instantiated again.
>
> So this is how it works now. It is some kind a mixture of 1. and 2. way you
> proposed. And it does real reconfiguration on components rather than what 2.
> option suggest.
>
> However using 2. option would be in my favor too, Though it is not really a
> reconfiguration, it is much easier to manage and it covers much more error
> scenario which my be thrown while reconfiguration. And by employing such
> mechanism we don't have to worry about Jdbm begin immutable. Because we'll
> create new instance anyway, if there are no some lock-file mechanism inside
> partition directory, we're golden.
>
> Also there is a facility which makes it closer to 2. option, "immutable
> properties". When you reconfigure an immutable property of some component it
> is deleted first from system and component listeners, and then it's created
> with new configuration and introduces into system again. By
> deactivating-and-activating in order rather than swapping the active
> instance on the fly, we ensure that hub can detect structural
> inconsistencies which may come along with that reconfiguration, for example
> if SystemPartition's partitionId is changed from "system" to "dummy", hub
> will abort that reconfiguration because ApacheDS can't work without system
> partition. If we were handled it by swapping instances on the fly, server
> would continue working but then on the next run it wouldn't start because
> it's lacking partition with "system" id.
>
> If we'll change the reconfiguration schema to 2. option, then we should put
> 'immutable properties' into consideration here too. Because we just can not
> modify some properties which are hardwired to DirectoryService without
> checking if modification is valid to defined constraints on that property.
> Otherwise next run of server may not take place properly.
>>
>>
>> Of course there's the events that are propagated by the OSGi container
>> when such an event does occur. I imagine these events have fired and
>> then the actual getter/setter configuration method is invoked in the
>> framework. Is this correct to presume?
>
> Yes, All frameworks have different invoking policies but in ComponentHub we
> only care about configuration change. We have activated configuration in one
> hand and altered configuration in other hand. We validate the altered
> configuration and send it to underlying component framework.
>>
>>
>> I think with option #2 we can be more certain that reconfigurations
>> are better accounted for by bundle developers.
>
> While it destroys hot reconfiguration, yes it is much more accountable. Not
> so performance wise, but reconfigurations are seldom to appear, so it won't
> be a problem.
>
> So its your call, i'm good with every option. We can go with option 1 to
> make real hot reconfigurations, or we can go with option 2 to create an
> illusion of hot reconfigurations while keeping existing code.
> FYI Switching from 1. to 2. reconfiguration policy in ComponentHub is
> trivial as i see it.
>
> Thanks,
> Gokturk
>>
>>
>> --
>> Best Regards,
>> -- Alex
>
>

Re: Problem of JDBM being hard(impossible) to reconfigure once it is initialized

Posted by Göktürk Gezer <go...@gmail.com>.
On Mon, May 21, 2012 at 1:12 AM, Alex Karasulu <ak...@apache.org> wrote:

> On Wed, May 16, 2012 at 6:58 AM, Göktürk Gezer <go...@gmail.com>
> wrote:
> > Hi Everyone,
> >
> > As i told you in OSGI branch update, JDBM is so immutable in runtime.
> Almost
> > every setter calls checkInitialized() method first which throws an
> exception
> > when its already initialized.
>
> This may be unavoidable but I am not qualified to make this call. At
> the present moment I am not familiar enough with the internals to
> understand how each setting would impact a reconfiguration. It may be
> trivial with some settings like for example cache settings by changing
> just a few things in JDBM.
>
Most of checkInitialized() calls are necessary for current design of
Jdbm/AbstractBTree Partition.

>
> In the worst case, if reinitialization with re-configuration must take
> place then the proper management can be handled. For example changing
> the files/directory path for the record manager for example can occur
> with a move of the actual files after the shutdown before the
> re-configuration, and before restarting the record manager service
> with the new setting for the the db file. Just giving this as one
> example. The other settings might require less management overheads.
>
Moving system files of partition is only necessary when we change its
partitionId as i see?
And i believe moving partition files around directories is conflicting with
partitionId property's purpose.
Using partitionId property as a pointer to where partition system files are
is more consistent IMO. So when
somebody changes some partition's partitionId, then this partition instance
must be reinitialized to use the partition files
under specified directory. If new specified directory has incompatible
content then we switch back to previous partitionId.
( ComponentHub system supports what i described: when some active component
is reconfigured in a state which is not valid,
 then reconfiguration is reverted. further explained below.)

>
> > We have to change that behavior in as much aspects of it as we can.
> > Otherwise there is no point in going into OSGI. However i can't always be
> > sure what my changes might lead on runtime. I need some serious help
> here,
> > especially from those are actively working on JDBM, otherwise i'll jump
> into
> > trial and error cycle which will probably last long.
> >
> > Here is the current configuration points for JdbmPartition:
>
> OK Jdbm partition unlike jdbm internals proper I have some suggestions
> on. Some settings are not that difficult to deal with on
> re-configuration events.
>
> These should be easier to handle:
>
> > cacheSize(int)
> > optimizerEnabled(boolean)
> > syncOnWrite(boolean)
>
First 2 don't have checkInitialized() checks already. syncOnWrite() has
that check, but i guess we can remove it.
We only have to insert sync() call before setting this property to ensure
none remains in buffers. Right?

>
> These below I suspect will impose many more management issues to
> properly reconfigure on the fly due to file movements and the creation
> of new indices (deletion of old indices).
>
Yes, they're currently not reconfigurable and it seems hard to make them.
All three is designed to be read at beginning and no altering mechanism is
supplied.


>
> > indexedAttributes(List<Index>)
> > partitionPath(File)
> > suffixDn(Dn)
> >
> > Currently none of them is reconfigurable, once the partition is
> initialized.
>
> Right.
>
> > However i need to know which are actually reconfigurable among these
> ones.
> > And which are not really reconfigurable and why?
> >
> > Every reconfiguration will invoke some setter method at desired
> > configuration point. So i guess we can make this reconfigurations work
> > actually based on it's initialized or not, rather than throwing an
> exception
> > blindly.
>
> Of course we want re-configuration to be hot because that's really
> cool. Sometimes you just don't have the option of shutting down the
> server. Then there are software updates to the actual component and
> that adds yet another dimension of problems to hot reconfiguration. In
> the case of the JDBM partition some changes that change the structure
> will make it so the jdbm db files are no longer compatible. So hot
> deploys of new versions are not easy or may require long running
> changes.
>
This dynamism can be handled, but i'll cause pain of course, but not much.
.db files being incompatible with new version is
something JdbmPartition implementation must handle by itself IMO. It must
have mechanisms to migrate old .db files to its own format at
initialization time.

And i remember now that i forgot to implement hot bundle replacements(cold
replacements are supported which is simply replacing bundle when none of
its components are instantiated). But no worries, with cold replacement
implemented, it is easy to implement hot reconfiguration in minutes.

>
> Another option or approach can be to handle some of these long running
> reconfiguration or software component (bundle) update events not hot
> (live) while the server is up and running but after a restart. However
> I do not recommend this. There are easy ways to mitigate all these
> problems.
>
No, it would not be good. Conflicting with OSGI anyway.

>
> > For your information, as we have the lifecycle control capability of
> > components created from within ApacheDS, we can implement some fancy
> stuff.
> > Like re-instantiating a component when one of its immutable property is
> > changed, or stop it and remove from DirectoryService when one of its
> > immutable property is changed to prevent accepting operations while
> > reconfiguring. These migtht be implemented in case there is " no
> > possibility! " to handle reconfigurations in live and initialized
> > JdbmPartition reference.
>
> This is the difference between two different modes of reconfiguration:
>
> (1) An "in-place" re-configuration event recovery by a reconfigured
> component while it continues to operate.
> (2) A component instance swap out where the reconfiguration causes a
> new instance of the component to be constructed and configured with
> the new settings while on standby. Until the standby is started and
> operational the old component continues to operate. Then the old is
> shutdown after a swap out.
>
> Overall the #2 approach is much better in my opinion. Why? Because you
> can never predict the outcome of in place modifications to settings.
> Changing the component directly may not be something the bundle
> developer accounted for right?
>
Here is how i handled it, (could be changed of course):
 When configuration of some component is changed(via config partition or
webconsole plugin which i'll implement later...),
new configuration's validity is checked. Valid means all property values
are compatible with the property types defined in component's metadata.
 * for primitives no check is performed, because they are ensured by Ldap
schema which is being created for that component specifically.
 * for reference types, it's checked that referenced component's type is
compatible with property's type.
 * for collection types, same with reference types + check if all
collection items are compatible with specified collection item type.
 * some more consistency checks.
So after these checks, new configuration is considered valid and it's sent
to underlying component framework which is used to create the component in
first hand to reconfigure that component. So at that point, it is
guaranteed that underlying component framework will not complain about any
type clashes.

However, component implementation can reject some configuration options
even if it is valid schematically. At that point component implementation
can choose to set some default value for this property or simply raise an
exception. If exception is thrown, then reconfigured component is
deactivated completely and it is set as dirty, meaning any further
reconfiguration will cause it to be instantiated again.

So this is how it works now. It is some kind a mixture of 1. and 2. way you
proposed. And it does real reconfiguration on components rather than what
2. option suggest.

However using 2. option would be in my favor too, Though it is not really a
reconfiguration, it is much easier to manage and it covers much more error
scenario which my be thrown while reconfiguration. And by employing such
mechanism we don't have to worry about Jdbm begin immutable. Because we'll
create new instance anyway, if there are no some lock-file mechanism inside
partition directory, we're golden.

Also there is a facility which makes it closer to 2. option, "immutable
properties". When you reconfigure an immutable property of some component
it is deleted first from system and component listeners, and then it's
created with new configuration and introduces into system again. By
deactivating-and-activating in order rather than swapping the active
instance on the fly, we ensure that hub can detect structural
inconsistencies which may come along with that reconfiguration, for example
if SystemPartition's partitionId is changed from "system" to "dummy", hub
will abort that reconfiguration because ApacheDS can't work without system
partition. If we were handled it by swapping instances on the fly, server
would continue working but then on the next run it wouldn't start because
it's lacking partition with "system" id.

If we'll change the reconfiguration schema to 2. option, then we should put
'immutable properties' into consideration here too. Because we just can not
modify some properties which are hardwired to DirectoryService without
checking if modification is valid to defined constraints on that property.
Otherwise next run of server may not take place properly.

>
> Of course there's the events that are propagated by the OSGi container
> when such an event does occur. I imagine these events have fired and
> then the actual getter/setter configuration method is invoked in the
> framework. Is this correct to presume?
>
Yes, All frameworks have different invoking policies but in ComponentHub we
only care about configuration change. We have activated configuration in
one hand and altered configuration in other hand. We validate the altered
configuration and send it to underlying component framework.

>
> I think with option #2 we can be more certain that reconfigurations
> are better accounted for by bundle developers.
>
While it destroys hot reconfiguration, yes it is much more accountable. Not
so performance wise, but reconfigurations are seldom to appear, so it won't
be a problem.

So its your call, i'm good with every option. We can go with option 1 to
make real hot reconfigurations, or we can go with option 2 to create an
illusion of hot reconfigurations while keeping existing code.
FYI Switching from 1. to 2. reconfiguration policy in ComponentHub is
trivial as i see it.

Thanks,
Gokturk

>
> --
> Best Regards,
> -- Alex
>

Re: Problem of JDBM being hard(impossible) to reconfigure once it is initialized

Posted by Alex Karasulu <ak...@apache.org>.
On Wed, May 16, 2012 at 6:58 AM, Göktürk Gezer <go...@gmail.com> wrote:
> Hi Everyone,
>
> As i told you in OSGI branch update, JDBM is so immutable in runtime. Almost
> every setter calls checkInitialized() method first which throws an exception
> when its already initialized.

This may be unavoidable but I am not qualified to make this call. At
the present moment I am not familiar enough with the internals to
understand how each setting would impact a reconfiguration. It may be
trivial with some settings like for example cache settings by changing
just a few things in JDBM.

In the worst case, if reinitialization with re-configuration must take
place then the proper management can be handled. For example changing
the files/directory path for the record manager for example can occur
with a move of the actual files after the shutdown before the
re-configuration, and before restarting the record manager service
with the new setting for the the db file. Just giving this as one
example. The other settings might require less management overheads.

> We have to change that behavior in as much aspects of it as we can.
> Otherwise there is no point in going into OSGI. However i can't always be
> sure what my changes might lead on runtime. I need some serious help here,
> especially from those are actively working on JDBM, otherwise i'll jump into
> trial and error cycle which will probably last long.
>
> Here is the current configuration points for JdbmPartition:

OK Jdbm partition unlike jdbm internals proper I have some suggestions
on. Some settings are not that difficult to deal with on
re-configuration events.

These should be easier to handle:

> cacheSize(int)
> optimizerEnabled(boolean)
> syncOnWrite(boolean)

These below I suspect will impose many more management issues to
properly reconfigure on the fly due to file movements and the creation
of new indices (deletion of old indices).

> indexedAttributes(List<Index>)
> partitionPath(File)
> suffixDn(Dn)
>
> Currently none of them is reconfigurable, once the partition is initialized.

Right.

> However i need to know which are actually reconfigurable among these ones.
> And which are not really reconfigurable and why?
>
> Every reconfiguration will invoke some setter method at desired
> configuration point. So i guess we can make this reconfigurations work
> actually based on it's initialized or not, rather than throwing an exception
> blindly.

Of course we want re-configuration to be hot because that's really
cool. Sometimes you just don't have the option of shutting down the
server. Then there are software updates to the actual component and
that adds yet another dimension of problems to hot reconfiguration. In
the case of the JDBM partition some changes that change the structure
will make it so the jdbm db files are no longer compatible. So hot
deploys of new versions are not easy or may require long running
changes.

Another option or approach can be to handle some of these long running
reconfiguration or software component (bundle) update events not hot
(live) while the server is up and running but after a restart. However
I do not recommend this. There are easy ways to mitigate all these
problems.

> For your information, as we have the lifecycle control capability of
> components created from within ApacheDS, we can implement some fancy stuff.
> Like re-instantiating a component when one of its immutable property is
> changed, or stop it and remove from DirectoryService when one of its
> immutable property is changed to prevent accepting operations while
> reconfiguring. These migtht be implemented in case there is " no
> possibility! " to handle reconfigurations in live and initialized
> JdbmPartition reference.

This is the difference between two different modes of reconfiguration:

(1) An "in-place" re-configuration event recovery by a reconfigured
component while it continues to operate.
(2) A component instance swap out where the reconfiguration causes a
new instance of the component to be constructed and configured with
the new settings while on standby. Until the standby is started and
operational the old component continues to operate. Then the old is
shutdown after a swap out.

Overall the #2 approach is much better in my opinion. Why? Because you
can never predict the outcome of in place modifications to settings.
Changing the component directly may not be something the bundle
developer accounted for right?

Of course there's the events that are propagated by the OSGi container
when such an event does occur. I imagine these events have fired and
then the actual getter/setter configuration method is invoked in the
framework. Is this correct to presume?

I think with option #2 we can be more certain that reconfigurations
are better accounted for by bundle developers.

-- 
Best Regards,
-- Alex

Re: Problem of JDBM being hard(impossible) to reconfigure once it is initialized

Posted by Göktürk Gezer <go...@gmail.com>.
Hi,

We had a private discussion with Selcuk about blocking reconfigurations
while Partitions are on use and came up with this approach.

Every operation into Partitions are going through
DefaultOperationManager.We'll maintain one main RWLock for ComponentHub and
then in every operation in OperationManager we lock on read-mode, and in
while reconfiguring some component in ComponentHub we get exclusive lock.
This is more simple to implement in my first proposed rwlock per component
approach. And because reconfigurations are not likely to occur frequently
and they are occuring one by one, this will not create any contention on
server at all.

We might move the locking point to RequestHandler level in LdapServer to
catch some minor inconsisteny points. I'll further investigate LdapServer
code to evaluate necessity for this.

WDYT about this solution?


And with this issue solved, we can move into real reconfiguration task of
JdbmPartition as it is throwing exceptions right now once it is
initialized. I'm pasting my previous main's contents here to refresh the
topic here.

Here is the current configuration points for JdbmPartition:

   - cacheSize(int)
   - optimizerEnabled(boolean)
   - partitionPath(File)
   - suffixDn(Dn)
   - syncOnWrite(boolean)
   - indexedAttributes(List<Index>)

Currently cacheSize and optimizerEnabled properties are enabled to changed
at runtime. Others call checkInitialized() first and throws exception. How
should i progress through changing other properties to be reconfigurable at
runtime and does not break anything?

Thanks,
Gokturk

On Thu, May 17, 2012 at 9:35 PM, Göktürk Gezer <go...@gmail.com>wrote:

>
> On May 17, 2012 8:18 PM, "Selcuk AYA" <ay...@gmail.com> wrote:
> >
> > On Thu, May 17, 2012 at 2:37 AM, Göktürk Gezer <go...@gmail.com>
> wrote:
> > > Hi,
> > >
> > > To let all of us think in a way that is compatible with new design. I
> felt
> > > like i have to share some basic knowledge of how it works.
> > >
> > > Every entry in config partition is tried to be instantiated by
> > > component-hub. There are some things that need to be satisfied to be
> able to
> > > instantiate an entry into an actual object, like its complex typed
> > > dependencies(component or collection) must be instantiated first and of
> > > course the ComponentFactory owning that entry must be present in OSGI.
> These
> > > aspects and some more are tracked by ComponentHub and the corresponding
> > > DirectoryComponent reference is activated and deactivated in regard.
> > >
> > > DirectoryComponent is an base type for handling components in and
> outside
> > > the ComponentHub. It's a container of information for component
> containing
> > > type,configuration,nature and runtime attachments of component.
> > >
> > > To access these DirectoryComponent references in ComponentHub one must
> > > register AbstractHubClient implementation with the ComponentHub. For
> > > example:
> > >
> > > InterceptorHubClient ic;
> > > hub.registerHubClient(ic, Interceptor.class);
> > >
> > > after this registration, 'ic' reference will begin receiving events of
> > > DirectoryComponent wrappers of Interceptor implementations as they're
> > > activated and deactivated by ComponentHub.
> > >
> > > Then some HubClient can call DirectoryComponent.getRuntime().getPojo()
> > > method to access actual Object, cast it to Interceptor and use it as
> normal
> > > Interceptor. Casting will succeed, which is ensured by ComponentHub.
> > >
> > > So with these basic knowledges in mind. i've come up with two ideas in
> mind,
> > > !!! again, these are in case if it's not possible to handle
> reconfigurations
> > > in JdbmPartition concurrently. !!!
> > >
> > > 1- Currently AbstractHubClient references are used to track only
> > > ACTIVATED,DEACTIVATED and DEACTIVATING events for DirectoryComponents.
> Only
> > > special event here is DEACTIVATING which is sent when it is possible to
> > > abort deactivation of component, for example when user is deleting
> > > component's corresponding entry in DIT, so HubClient can abort this
> deletion
> > > if it's going to put server in inconsistent configuration.
> > >
> > > We can add two more event here, RECONFIGURING and RECONFIGURED. So
> with this
> > > event in pocket, HubClient for Partition.class (which will be heavily
> > > connected with PartitionNexus, or we can implement it right inside
> > > PartitionNexus) can choose to detach reconfiguring Partition from
> > > PartitionNexus and attach it again when UPDATED event is received.
> While
> > > HubClient implementation for Partition.class works that way, we can
> just
> > > ignore UPDATE* events in HubClient for Interceptor.class
> > >
> > > Pros:
> > >  * We can keep accesses to components as native Object references
> > > Cons:
> > >  * We have to add some more methods in PartitionNexus to deactivate and
> > > activate Partitions without initializing them at activation.
> > >
> > > 2- We insert an additional RWLock into every DirectoryComponent. And
> keep
> > > components as DirectoryComponent in code(DirectoryService and
> PartitionNexus
> > > mainly). So when PartitionNexus access one of its Partition reference
> to
> > > proxy some operation, it first locks on read-mode on its wrapping
> > > DirectoryComponent. And all reconfigurations on ComponentHub side
> locks on
> > > write-mode.
> >
> > If this read write lock is implemented at the level when nexus
> > interfaces the partitions, it might not be possible for a single
> > operation to see a consistent state of the server. This is because a
> > single operation might come down to nexus level several times.
> >
> I have some questions...
>
> Are these multiple nexus level accesses are coming from interceptors?
>
> Is it inconsistent or inconvenient. I mean when some operation O access
> the partition at X and Y times, if we for example update user attribute
> indexes between X and Y, is there a possibility for Y to fail? Or is there
> any configuration change type which can cause Y to fail?
>
> > 1)One way to handle this would be to detect the configuration change
> > and abort the operation and retry it. This would be possible to do
> > with txns.
> Yeah absolutely.
>
> >
> > 2) Another would be to use the RW lock in such a way that all
> > operations are quiesced before they begin executing within the server.
> > >
> I don't know right know if there is a spot where I can put locks to ensure
> this behaviour. I'll look into that.
>
> > > Pros:
> > >  * No attachment and detachment of components(Partitions) from their
> holder.
> > > Cons:
> > >  * We must keep DirectoryComponent reference rather than their native
> > > reference type to access their lock.(Actually in HubClient for
> > > Partition.class, we can embed this lock into JdbmPartition reference
> once we
> > > got its DirectoryComponent reference, and we just change
> PartitionNexus to
> > > retrieve Lock objects of AbstractBTreePartition references just before
> > > invoking their operations. So this approach invalidated the need of
> keeping
> > > DirectoryComponent reference with this approach, just with a minimal
> cost to
> > > change AbstractBTreePartition code to have an additional RWLock object)
> > >
> > >
> > > Thoughts?
> > >
> > > Regards,
> > > Gokturk
> >
> > thanks
> > Selcuk
>
> Thanks,
> Göktürk
>

Re: Problem of JDBM being hard(impossible) to reconfigure once it is initialized

Posted by Göktürk Gezer <go...@gmail.com>.
On May 17, 2012 8:18 PM, "Selcuk AYA" <ay...@gmail.com> wrote:
>
> On Thu, May 17, 2012 at 2:37 AM, Göktürk Gezer <go...@gmail.com>
wrote:
> > Hi,
> >
> > To let all of us think in a way that is compatible with new design. I
felt
> > like i have to share some basic knowledge of how it works.
> >
> > Every entry in config partition is tried to be instantiated by
> > component-hub. There are some things that need to be satisfied to be
able to
> > instantiate an entry into an actual object, like its complex typed
> > dependencies(component or collection) must be instantiated first and of
> > course the ComponentFactory owning that entry must be present in OSGI.
These
> > aspects and some more are tracked by ComponentHub and the corresponding
> > DirectoryComponent reference is activated and deactivated in regard.
> >
> > DirectoryComponent is an base type for handling components in and
outside
> > the ComponentHub. It's a container of information for component
containing
> > type,configuration,nature and runtime attachments of component.
> >
> > To access these DirectoryComponent references in ComponentHub one must
> > register AbstractHubClient implementation with the ComponentHub. For
> > example:
> >
> > InterceptorHubClient ic;
> > hub.registerHubClient(ic, Interceptor.class);
> >
> > after this registration, 'ic' reference will begin receiving events of
> > DirectoryComponent wrappers of Interceptor implementations as they're
> > activated and deactivated by ComponentHub.
> >
> > Then some HubClient can call DirectoryComponent.getRuntime().getPojo()
> > method to access actual Object, cast it to Interceptor and use it as
normal
> > Interceptor. Casting will succeed, which is ensured by ComponentHub.
> >
> > So with these basic knowledges in mind. i've come up with two ideas in
mind,
> > !!! again, these are in case if it's not possible to handle
reconfigurations
> > in JdbmPartition concurrently. !!!
> >
> > 1- Currently AbstractHubClient references are used to track only
> > ACTIVATED,DEACTIVATED and DEACTIVATING events for DirectoryComponents.
Only
> > special event here is DEACTIVATING which is sent when it is possible to
> > abort deactivation of component, for example when user is deleting
> > component's corresponding entry in DIT, so HubClient can abort this
deletion
> > if it's going to put server in inconsistent configuration.
> >
> > We can add two more event here, RECONFIGURING and RECONFIGURED. So with
this
> > event in pocket, HubClient for Partition.class (which will be heavily
> > connected with PartitionNexus, or we can implement it right inside
> > PartitionNexus) can choose to detach reconfiguring Partition from
> > PartitionNexus and attach it again when UPDATED event is received. While
> > HubClient implementation for Partition.class works that way, we can just
> > ignore UPDATE* events in HubClient for Interceptor.class
> >
> > Pros:
> >  * We can keep accesses to components as native Object references
> > Cons:
> >  * We have to add some more methods in PartitionNexus to deactivate and
> > activate Partitions without initializing them at activation.
> >
> > 2- We insert an additional RWLock into every DirectoryComponent. And
keep
> > components as DirectoryComponent in code(DirectoryService and
PartitionNexus
> > mainly). So when PartitionNexus access one of its Partition reference to
> > proxy some operation, it first locks on read-mode on its wrapping
> > DirectoryComponent. And all reconfigurations on ComponentHub side locks
on
> > write-mode.
>
> If this read write lock is implemented at the level when nexus
> interfaces the partitions, it might not be possible for a single
> operation to see a consistent state of the server. This is because a
> single operation might come down to nexus level several times.
>
I have some questions...

Are these multiple nexus level accesses are coming from interceptors?

Is it inconsistent or inconvenient. I mean when some operation O access the
partition at X and Y times, if we for example update user attribute indexes
between X and Y, is there a possibility for Y to fail? Or is there any
configuration change type which can cause Y to fail?

> 1)One way to handle this would be to detect the configuration change
> and abort the operation and retry it. This would be possible to do
> with txns.
Yeah absolutely.
>
> 2) Another would be to use the RW lock in such a way that all
> operations are quiesced before they begin executing within the server.
> >
I don't know right know if there is a spot where I can put locks to ensure
this behaviour. I'll look into that.
> > Pros:
> >  * No attachment and detachment of components(Partitions) from their
holder.
> > Cons:
> >  * We must keep DirectoryComponent reference rather than their native
> > reference type to access their lock.(Actually in HubClient for
> > Partition.class, we can embed this lock into JdbmPartition reference
once we
> > got its DirectoryComponent reference, and we just change PartitionNexus
to
> > retrieve Lock objects of AbstractBTreePartition references just before
> > invoking their operations. So this approach invalidated the need of
keeping
> > DirectoryComponent reference with this approach, just with a minimal
cost to
> > change AbstractBTreePartition code to have an additional RWLock object)
> >
> >
> > Thoughts?
> >
> > Regards,
> > Gokturk
>
> thanks
> Selcuk

Thanks,
Göktürk

Re: Problem of JDBM being hard(impossible) to reconfigure once it is initialized

Posted by Selcuk AYA <ay...@gmail.com>.
On Thu, May 17, 2012 at 2:37 AM, Göktürk Gezer <go...@gmail.com> wrote:
> Hi,
>
> To let all of us think in a way that is compatible with new design. I felt
> like i have to share some basic knowledge of how it works.
>
> Every entry in config partition is tried to be instantiated by
> component-hub. There are some things that need to be satisfied to be able to
> instantiate an entry into an actual object, like its complex typed
> dependencies(component or collection) must be instantiated first and of
> course the ComponentFactory owning that entry must be present in OSGI. These
> aspects and some more are tracked by ComponentHub and the corresponding
> DirectoryComponent reference is activated and deactivated in regard.
>
> DirectoryComponent is an base type for handling components in and outside
> the ComponentHub. It's a container of information for component containing
> type,configuration,nature and runtime attachments of component.
>
> To access these DirectoryComponent references in ComponentHub one must
> register AbstractHubClient implementation with the ComponentHub. For
> example:
>
> InterceptorHubClient ic;
> hub.registerHubClient(ic, Interceptor.class);
>
> after this registration, 'ic' reference will begin receiving events of
> DirectoryComponent wrappers of Interceptor implementations as they're
> activated and deactivated by ComponentHub.
>
> Then some HubClient can call DirectoryComponent.getRuntime().getPojo()
> method to access actual Object, cast it to Interceptor and use it as normal
> Interceptor. Casting will succeed, which is ensured by ComponentHub.
>
> So with these basic knowledges in mind. i've come up with two ideas in mind,
> !!! again, these are in case if it's not possible to handle reconfigurations
> in JdbmPartition concurrently. !!!
>
> 1- Currently AbstractHubClient references are used to track only
> ACTIVATED,DEACTIVATED and DEACTIVATING events for DirectoryComponents. Only
> special event here is DEACTIVATING which is sent when it is possible to
> abort deactivation of component, for example when user is deleting
> component's corresponding entry in DIT, so HubClient can abort this deletion
> if it's going to put server in inconsistent configuration.
>
> We can add two more event here, RECONFIGURING and RECONFIGURED. So with this
> event in pocket, HubClient for Partition.class (which will be heavily
> connected with PartitionNexus, or we can implement it right inside
> PartitionNexus) can choose to detach reconfiguring Partition from
> PartitionNexus and attach it again when UPDATED event is received. While
> HubClient implementation for Partition.class works that way, we can just
> ignore UPDATE* events in HubClient for Interceptor.class
>
> Pros:
>  * We can keep accesses to components as native Object references
> Cons:
>  * We have to add some more methods in PartitionNexus to deactivate and
> activate Partitions without initializing them at activation.
>
> 2- We insert an additional RWLock into every DirectoryComponent. And keep
> components as DirectoryComponent in code(DirectoryService and PartitionNexus
> mainly). So when PartitionNexus access one of its Partition reference to
> proxy some operation, it first locks on read-mode on its wrapping
> DirectoryComponent. And all reconfigurations on ComponentHub side locks on
> write-mode.

If this read write lock is implemented at the level when nexus
interfaces the partitions, it might not be possible for a single
operation to see a consistent state of the server. This is because a
single operation might come down to nexus level several times.

1)One way to handle this would be to detect the configuration change
and abort the operation and retry it. This would be possible to do
with txns.

2) Another would be to use the RW lock in such a way that all
operations are quiesced before they begin executing within the server.
>
> Pros:
>  * No attachment and detachment of components(Partitions) from their holder.
> Cons:
>  * We must keep DirectoryComponent reference rather than their native
> reference type to access their lock.(Actually in HubClient for
> Partition.class, we can embed this lock into JdbmPartition reference once we
> got its DirectoryComponent reference, and we just change PartitionNexus to
> retrieve Lock objects of AbstractBTreePartition references just before
> invoking their operations. So this approach invalidated the need of keeping
> DirectoryComponent reference with this approach, just with a minimal cost to
> change AbstractBTreePartition code to have an additional RWLock object)
>
>
> Thoughts?
>
> Regards,
> Gokturk

thanks
Selcuk

Re: Problem of JDBM being hard(impossible) to reconfigure once it is initialized

Posted by Göktürk Gezer <go...@gmail.com>.
Hi,

To let all of us think in a way that is compatible with new design. I felt
like i have to share some basic knowledge of how it works.

Every entry in config partition is tried to be instantiated by
component-hub. There are some things that need to be satisfied to be able
to instantiate an entry into an actual object, like its complex typed
dependencies(component or collection) must be instantiated first and of
course the ComponentFactory owning that entry must be present in OSGI.
These aspects and some more are tracked by ComponentHub and the
corresponding DirectoryComponent reference is activated and deactivated in
regard.

DirectoryComponent is an base type for handling components in and outside
the ComponentHub. It's a container of information for component containing
type,configuration,nature and runtime attachments of component.

To access these DirectoryComponent references in ComponentHub one must
register AbstractHubClient implementation with the ComponentHub. For
example:

*InterceptorHubClient ic;*
*hub.registerHubClient(ic, Interceptor.class);*

after this registration, 'ic' reference will begin receiving events of
DirectoryComponent wrappers of Interceptor implementations as they're
activated and deactivated by ComponentHub.

Then some HubClient can call DirectoryComponent.getRuntime().getPojo()
method to access actual Object, cast it to Interceptor and use it as normal
Interceptor. Casting will succeed, which is ensured by ComponentHub.

So with these basic knowledges in mind. i've come up with two ideas in
mind, !!! again, these are in case if it's not possible to handle
reconfigurations in JdbmPartition concurrently. !!!

*1- *Currently AbstractHubClient references are used to track only
ACTIVATED,DEACTIVATED and DEACTIVATING events for DirectoryComponents. Only
special event here is DEACTIVATING which is sent when it is possible to
abort deactivation of component, for example when user is deleting
component's corresponding entry in DIT, so HubClient can abort this
deletion if it's going to put server in inconsistent configuration.

We can add two more event here, RECONFIGURING and RECONFIGURED. So with
this event in pocket, HubClient for Partition.class (which will be heavily
connected with PartitionNexus, or we can implement it right inside
PartitionNexus) can choose to detach reconfiguring Partition from
PartitionNexus and attach it again when UPDATED event is received. While
HubClient implementation for Partition.class works that way, we can just
ignore UPDATE* events in HubClient for Interceptor.class

Pros:
 * We can keep accesses to components as native Object references
Cons:
 * We have to add some more methods in PartitionNexus to deactivate and
activate Partitions without initializing them at activation.

*2-* We insert an additional RWLock into every DirectoryComponent. And keep
components as DirectoryComponent in code(DirectoryService and
PartitionNexus mainly). So when PartitionNexus access one of its Partition
reference to proxy some operation, it first locks on read-mode on its
wrapping DirectoryComponent. And all reconfigurations on ComponentHub side
locks on write-mode.

Pros:
 * No attachment and detachment of components(Partitions) from their holder.
Cons:
 * We must keep DirectoryComponent reference rather than their native
reference type to access their lock.(Actually in HubClient for
Partition.class, we can embed this lock into JdbmPartition reference once
we got its DirectoryComponent reference, and we just change PartitionNexus
to retrieve Lock objects of AbstractBTreePartition references just before
invoking their operations. So this approach invalidated the need of keeping
DirectoryComponent reference with this approach, just with a minimal cost
to change AbstractBTreePartition code to have an additional RWLock object)


Thoughts?

Regards,
Gokturk

Re: Problem of JDBM being hard(impossible) to reconfigure once it is initialized

Posted by Emmanuel Lecharny <el...@apache.org>.
hi Göktürk, I'll check that tonite. I'm a bit on hold atm, dealing with
some familly stuff.

thanks
Le 16 mai 2012 05:58, "Göktürk Gezer" <go...@gmail.com> a écrit :

> Hi Everyone,
>
> As i told you in OSGI branch update, JDBM is so immutable in runtime.
> Almost every setter calls checkInitialized() method first which throws an
> exception when its already initialized.
>
> We have to change that behavior in as much aspects of it as we can.
> Otherwise there is no point in going into OSGI. However i can't always be
> sure what my changes might lead on runtime. I need some serious help here,
> especially from those are actively working on JDBM, otherwise i'll jump
> into trial and error cycle which will probably last long.
>
> Here is the current configuration points for JdbmPartition:
>
>    - cacheSize(int)
>    - optimizerEnabled(boolean)
>    - partitionPath(File)
>    - suffixDn(Dn)
>    - syncOnWrite(boolean)
>    - indexedAttributes(List<Index>)
>
> Currently none of them is reconfigurable, once the partition is
> initialized. However i need to know which are actually reconfigurable among
> these ones. And which are not really reconfigurable and why?
>
> Every reconfiguration will invoke some setter method at desired
> configuration point. So i guess we can make this reconfigurations work
> actually based on it's initialized or not, rather than throwing an
> exception blindly.
>
> For your information, as we have the lifecycle control capability of
> components created from within ApacheDS, we can implement some fancy stuff.
> Like re-instantiating a component when one of its immutable property is
> changed, or stop it and remove from DirectoryService when one of its
> immutable property is changed to prevent accepting operations while
> reconfiguring. These migtht be implemented in case there is " no
> possibility! " to handle reconfigurations in live and initialized
> JdbmPartition reference.
>
> I appreciate every single idea on this matter !
>
> Thanks,
> Gokturk
>