Hi Pumudu,

LocalSubscriptions are local to the node. You can deliver messages only to
the Localsubscriptions. Clustersubscription is the object carrying basic
info about subscriptions which does not have an actual channel associated
with it.

To solve the problem I have introduce a method to get a mock local
subscription using the cluster subscription.

Thanks

On Tue, Aug 18, 2015 at 6:22 PM, Pumudu Ruhunage <pum...@wso2.com> wrote:

> Adding some info to first question.
> As I understood there are two types of andes subscriptions for cluster and
> local. When I try to call removeLocalSubscription() inside
> createDisconnectOrRemoveClusterSubscription() to remove subscriptions from
> local database i'm getting following exception[1].
> This prevents removing redundant subscriptions from database during
> startup while initializing in cluster mode.
>
> Why do we need two type of andes subscriptions? can't we keep same
> subscription type for both cluster and local in MB?
>
>
>
> [1] Caused by: java.lang.ClassCastException:
> org.wso2.andes.subscription.BasicSubscription cannot be cast to
> org.wso2.andes.kernel.LocalSubscription
>
> at
> org.wso2.andes.subscription.SubscriptionStore.removeLocalSubscription(SubscriptionStore.java:645)
>
> at
> org.wso2.andes.subscription.SubscriptionStore.createDisconnectOrRemoveClusterSubscription(SubscriptionStore.java:487)
>
> at
> org.wso2.andes.kernel.AndesSubscriptionManager.updateClusterSubscriptionMaps(AndesSubscriptionManager.java:234)
>
> at
> org.wso2.andes.server.cluster.coordination.ClusterCoordinationHandler.handleClusterSubscriptionsChanged(ClusterCoordinationHandler.java:134)
>
> at
> org.wso2.andes.kernel.AndesSubscriptionManager.notifyClusterSubscriptionHasChanged(AndesSubscriptionManager.java:298)
>
> at
> org.wso2.andes.kernel.AndesSubscriptionManager.reloadSubscriptionsFromStorage(AndesSubscriptionManager.java:275)
>
> at
> org.wso2.andes.kernel.AndesRecoveryTask.reloadSubscriptions(AndesRecoveryTask.java:188)
>
> at
> org.wso2.andes.kernel.AndesRecoveryTask.recoverExchangesQueuesBindingsSubscriptions(AndesRecoveryTask.java:94)
>
> at
> org.wso2.andes.kernel.AndesKernelBoot.syncNodeWithClusterState(AndesKernelBoot.java:443)
>
> at
> org.wso2.andes.kernel.AndesKernelBoot.bootAndesKernel(AndesKernelBoot.java:116)
>
> at org.wso2.andes.server.Broker.startupImpl(Broker.java:290)
>
>
>
> Thanks,
> Pumudu
>
> On Tue, Aug 18, 2015 at 4:43 PM, Pumudu Ruhunage <pum...@wso2.com> wrote:
>
>> Hi All,
>>
>> I faced two issues while fixing this.
>>
>> 1. There is a method for clear cluster subscriptions
>> ('closeAllClusterSubscriptionsOfNode()' in 'andesSubscriptionManager')
>> while initializing a cluster node. But it dosen't clean up database when
>> executed. Is there a specific reason not to delete non-durable
>> subscriptions from database when call this method?
>>
>> 2. Currently all subscriptions(durable/non-durable) are stored in
>> MB_DURABLE_SUBSCRIPTION table. Is there a reason for this? Can't we change
>> this table name to something meaningful if we continue to keep all
>> subscriptions in same table?
>>
>> WDYT?
>>
>> Thanks,
>> Pumudu
>>
>> On Thu, Aug 13, 2015 at 2:41 PM, Pumudu Ruhunage <pum...@wso2.com> wrote:
>>
>>> Hi All,
>>>
>>> Thanks for the inputs. +1 for implementing both cases.
>>> will do both implementations.
>>>
>>> Regards,
>>> Pumudu
>>>
>>> On Thu, Aug 13, 2015 at 11:40 AM, Hemika Kodikara <hem...@wso2.com>
>>> wrote:
>>>
>>>> Hi All,
>>>>
>>>> We have already done a similar implementation for durable topics on
>>>> member removed.
>>>>
>>>> +1 for Asanka's suggestion to remove non-topic subscriptions on both
>>>> occasions.
>>>>
>>>> Regards,
>>>> Hemika
>>>>
>>>> Hemika Kodikara
>>>> Software Engineer
>>>> WSO2 Inc.
>>>> lean . enterprise . middleware
>>>> http://wso2.com
>>>>
>>>> Mobile : +94777688882
>>>>
>>>> On Thu, Aug 13, 2015 at 11:09 AM, Asitha Nanayakkara <asi...@wso2.com>
>>>> wrote:
>>>>
>>>>>
>>>>> On Thu, Aug 13, 2015 at 3:17 PM, Asanka Abeyweera <asank...@wso2.com>
>>>>> wrote:
>>>>>
>>>>>> Hi Asitha,
>>>>>>
>>>>>> I don't think we can achieve this by only doing the cleanup at the
>>>>>> coordinator selection point. We have to clean the topic subscriptions 
>>>>>> for a
>>>>>> non-coordinator node when it leaves (In this case a new coordinator will
>>>>>> not be elected).
>>>>>>
>>>>>> Oh! yes agreed!
>>>>>
>>>>>>
>>>>>> On Thu, Aug 13, 2015 at 5:04 AM, Asitha Nanayakkara <asi...@wso2.com>
>>>>>> wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Aug 12, 2015 at 10:53 PM, Asanka Abeyweera <
>>>>>>> asank...@wso2.com> wrote:
>>>>>>>
>>>>>>>> Hi Pumudu,
>>>>>>>>
>>>>>>>> I think we have to do the clean up in both places. Case 1 is
>>>>>>>> required when the only node in the cluster leaves and come back. Case 
>>>>>>>> 2 is
>>>>>>>> required when a single node leaves in a multi node cluster.
>>>>>>>>
>>>>>>>> On Wed, Aug 12, 2015 at 5:38 PM, Pumudu Ruhunage <pum...@wso2.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> Currently if MB node got killed unexpectedly non-durable topic
>>>>>>>>> subscriptions bind to that node will remain in cluster. This can cause
>>>>>>>>> unexpected behaviors in cluster since that node has already removed.
>>>>>>>>>
>>>>>>>>> IMO these topic subscriptions can clean up in two methods.
>>>>>>>>>
>>>>>>>>> 1. During each MB node start up, remove all non-durable topic
>>>>>>>>> subscriptions for it's local node id. (This will ensure newly started 
>>>>>>>>> node
>>>>>>>>> won't receive any non-durable topic messages related to previously 
>>>>>>>>> killed
>>>>>>>>> MB node with same node id)
>>>>>>>>>
>>>>>>>>
>>>>>>>> I think  we can do this in org.wso2.andes.kernel.AndesKernelBoot or
>>>>>>>> in a similar class. May be we can do this similar to the way we do the 
>>>>>>>> slot
>>>>>>>> recovery task.
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> 2. Cluster coordinator should remove all non-durable topic
>>>>>>>>> subscriptions when a member left from cluster. (This can be a problem 
>>>>>>>>> if
>>>>>>>>> coordinator node killed. If there's a method to get previous 
>>>>>>>>> coordinator
>>>>>>>>> node id by newly elected coordinator this method can be implemented)
>>>>>>>>>
>>>>>>>>
>>>>>>>> For this case we can do the clean up in
>>>>>>>> org.wso2.andes.server.cluster.ClusterManager#memberRemoved method after
>>>>>>>> checking if the current node is the coordinator. This will work even 
>>>>>>>> if the
>>>>>>>> coordinator node get killed.
>>>>>>>>
>>>>>>>
>>>>>>> When a new coordinator is elected can't we let that newly elected
>>>>>>> coordinator do this ? Even at startup there is a coordinator election
>>>>>>> right? if that's the case we can cover both scenarios IMO?
>>>>>>>
>>>>>>>
>>>>>>>>>
>>>>>>>> How should we do the clean up. WDYT?
>>>>>>>>>
>>>>>>>>> Regards,
>>>>>>>>> Pumudu
>>>>>>>>> --
>>>>>>>>> Pumudu Ruhunage
>>>>>>>>> Associate Software Engineer | WSO2 Inc
>>>>>>>>> M: +94 779 664493  | http://wso2.com
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Dev mailing list
>>>>>>>>> Dev@wso2.org
>>>>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Asanka Abeyweera
>>>>>>>> Software Engineer
>>>>>>>> WSO2 Inc.
>>>>>>>>
>>>>>>>> Phone: +94 712228648
>>>>>>>> Blog: a5anka.github.io
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Dev mailing list
>>>>>>>> Dev@wso2.org
>>>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> *Asitha Nanayakkara*
>>>>>>> Software Engineer
>>>>>>> WSO2, Inc. http://wso2.com/
>>>>>>> Mob: + 94 77 85 30 682
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Asanka Abeyweera
>>>>>> Software Engineer
>>>>>> WSO2 Inc.
>>>>>>
>>>>>> Phone: +94 712228648
>>>>>> Blog: a5anka.github.io
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *Asitha Nanayakkara*
>>>>> Software Engineer
>>>>> WSO2, Inc. http://wso2.com/
>>>>> Mob: + 94 77 85 30 682
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> Dev@wso2.org
>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> Dev@wso2.org
>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>
>>>>
>>>
>>>
>>> --
>>> Pumudu Ruhunage
>>> Associate Software Engineer | WSO2 Inc
>>> M: +94 779 664493  | http://wso2.com
>>>
>>
>>
>>
>> --
>> Pumudu Ruhunage
>> Associate Software Engineer | WSO2 Inc
>> M: +94 779 664493  | http://wso2.com
>>
>
>
>
> --
> Pumudu Ruhunage
> Associate Software Engineer | WSO2 Inc
> M: +94 779 664493  | http://wso2.com
>



-- 
*Hasitha Abeykoon*
Senior Software Engineer; WSO2, Inc.; http://wso2.com
*cell:* *+94 719363063*
*blog: **abeykoon.blogspot.com* <http://abeykoon.blogspot.com>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to