You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stratos.apache.org by Nirmal Fernando <ni...@gmail.com> on 2014/12/03 02:15:29 UTC

Deploying concurrent Applications simultaneously

Hi,

AFAIS, currently all the Applications statically uses an
org.apache.stratos.autoscaler.applications.ApplicationHolder
object and acquires locks before reading from/writing to it.

After going through the places we acquire locks, it appears that deploying
concurrent Applications will lead lot of Applications to wait so long to
get started. Is my observation correct?


​

-- 
Best Regards,
Nirmal

Nirmal Fernando.
PPMC Member & Committer of Apache Stratos,
Senior Software Engineer, WSO2 Inc.

Blog: http://nirmalfdo.blogspot.com/

Re: Deploying concurrent Applications simultaneously

Posted by Reka Thirunavukkarasu <re...@wso2.com>.
+1 to use hierarchical locking in the applications Topology as well. That
will improve the performance in lot of places..

Thanks,
Reka

On Wed, Dec 3, 2014 at 9:55 AM, Isuru Haththotuwa <is...@apache.org> wrote:

> Hi Lahiru,
>
> On Wed, Dec 3, 2014 at 9:30 AM, Lahiru Sandaruwan <la...@wso2.com>
> wrote:
>
>> Isuru,
>>
>> Need to find out if "getLockForApplication(idOfComponent)" returns the
>> locks for group components as well. If not, can we do that?
>>
> When you lock an application, the entire application hierarchy
> (application + any sub groups will be locked). However, you need to lock
> the clusters separately, as Applications model and Topology model are
> maintained separately.
>
>>
>> Thanks.
>>
>> On Wed, Dec 3, 2014 at 9:27 AM, Lahiru Sandaruwan <la...@wso2.com>
>> wrote:
>>
>>> We already have hierarchical locking. It seems some points we can
>>> improve the usage,
>>>
>>> E.g. In StatusChecker class,
>>>
>>> Following code,
>>>
>>>         try {
>>>
>>>             *ApplicationHolder.acquireWriteLock();*
>>>
>>>             if (idOfComponent.equals(appId)) {
>>>
>>>                 //it is an application
>>>
>>>                 component = ApplicationHolder.getApplications().
>>>
>>>                         getApplication(appId);
>>>
>>>             } else {
>>>
>>>                 //it is a group
>>>
>>>                 component = ApplicationHolder.getApplications().
>>>
>>>
>>> getApplication(appId).getGroupRecursively(idOfComponent);
>>>
>>>             }
>>>
>>>             groups = component.getAliasToGroupMap();
>>>
>>>             clusterData = component.getClusterDataMap();
>>>
>>>             if(component.isGroupScalingEnabled()) {
>>>
>>>                 //TODO
>>>
>>>                 handleStateWithGroupScalingEnabled();
>>>
>>>             } else {
>>>
>>>                 handleStateChangeGroupScalingDisabled(component, appId,
>>> instanceId, groups, clusterData);
>>>
>>>             }
>>>
>>>         } finally {
>>>
>>>            * ApplicationHolder.releaseWriteLock();*
>>>
>>>         }
>>>
>>> Can be improved as,
>>>         try {
>>>             *ApplicationHolder.acquireReadLock();*
>>>             if (idOfComponent.equals(appId)) {
>>>                 //it is an application
>>>                 component = ApplicationHolder.getApplications().
>>>                         getApplication(appId);
>>>             } else {
>>>                 //it is a group
>>>                 component = ApplicationHolder.getApplications().
>>>
>>> getApplication(appId).getGroupRecursively(idOfComponent);
>>>             }
>>>         } finally {
>>>
>>>            * ApplicationHolder.acquireReadLock();*
>>>         }
>>>         try{
>>>
>>>
>>> *ApplicationLockHierarchy.getInstance().getLockForApplication(idOfComponent).acquireWriteLock();*
>>>             groups = component.getAliasToGroupMap();
>>>             clusterData = component.getClusterDataMap();
>>>
>>>             if(component.isGroupScalingEnabled()) {
>>>                 //TODO
>>>                 handleStateWithGroupScalingEnabled();
>>>             } else {
>>>                 handleStateChangeGroupScalingDisabled(component, appId,
>>> instanceId, groups, clusterData);
>>>             }
>>>         } finally {
>>>
>>>
>>> *ApplicationLockHierarchy.getInstance().getLockForApplication(idOfComponent).releaseWritelock();*
>>>         }
>>>
>>> On Wed, Dec 3, 2014 at 6:45 AM, Nirmal Fernando <ni...@gmail.com>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> AFAIS, currently all the Applications statically uses an org.apache.stratos.autoscaler.applications.ApplicationHolder
>>>> object and acquires locks before reading from/writing to it.
>>>>
>>>> After going through the places we acquire locks, it appears that
>>>> deploying concurrent Applications will lead lot of Applications to wait so
>>>> long to get started. Is my observation correct?
>>>>
>>>>
>>>> ​
>>>>
>>>> --
>>>> Best Regards,
>>>> Nirmal
>>>>
>>>> Nirmal Fernando.
>>>> PPMC Member & Committer of Apache Stratos,
>>>> Senior Software Engineer, WSO2 Inc.
>>>>
>>>> Blog: http://nirmalfdo.blogspot.com/
>>>>
>>>
>>>
>>>
>>> --
>>> --
>>> Lahiru Sandaruwan
>>> Committer and PMC member, Apache Stratos,
>>> Senior Software Engineer,
>>> WSO2 Inc., http://wso2.com
>>> lean.enterprise.middleware
>>>
>>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>>
>>>
>>
>>
>> --
>> --
>> Lahiru Sandaruwan
>> Committer and PMC member, Apache Stratos,
>> Senior Software Engineer,
>> WSO2 Inc., http://wso2.com
>> lean.enterprise.middleware
>>
>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>> linked-in:
>> http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>
>> --
>> <http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146>
>> <http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146>
>> Thanks and Regards,
>>
>> Isuru H.
>> <http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146>
>> +94 716 358 048 <http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146>*
>> <http://wso2.com/>*
>>
>>
>> * <http://wso2.com/>*
>>
>>
>>


-- 
Reka Thirunavukkarasu
Senior Software Engineer,
WSO2, Inc.:http://wso2.com,
Mobile: +94776442007

Re: Deploying concurrent Applications simultaneously

Posted by Isuru Haththotuwa <is...@apache.org>.
Hi Lahiru,

On Wed, Dec 3, 2014 at 9:30 AM, Lahiru Sandaruwan <la...@wso2.com> wrote:

> Isuru,
>
> Need to find out if "getLockForApplication(idOfComponent)" returns the
> locks for group components as well. If not, can we do that?
>
When you lock an application, the entire application hierarchy (application
+ any sub groups will be locked). However, you need to lock the clusters
separately, as Applications model and Topology model are maintained
separately.

>
> Thanks.
>
> On Wed, Dec 3, 2014 at 9:27 AM, Lahiru Sandaruwan <la...@wso2.com>
> wrote:
>
>> We already have hierarchical locking. It seems some points we can improve
>> the usage,
>>
>> E.g. In StatusChecker class,
>>
>> Following code,
>>
>>         try {
>>
>>             *ApplicationHolder.acquireWriteLock();*
>>
>>             if (idOfComponent.equals(appId)) {
>>
>>                 //it is an application
>>
>>                 component = ApplicationHolder.getApplications().
>>
>>                         getApplication(appId);
>>
>>             } else {
>>
>>                 //it is a group
>>
>>                 component = ApplicationHolder.getApplications().
>>
>>
>> getApplication(appId).getGroupRecursively(idOfComponent);
>>
>>             }
>>
>>             groups = component.getAliasToGroupMap();
>>
>>             clusterData = component.getClusterDataMap();
>>
>>             if(component.isGroupScalingEnabled()) {
>>
>>                 //TODO
>>
>>                 handleStateWithGroupScalingEnabled();
>>
>>             } else {
>>
>>                 handleStateChangeGroupScalingDisabled(component, appId,
>> instanceId, groups, clusterData);
>>
>>             }
>>
>>         } finally {
>>
>>            * ApplicationHolder.releaseWriteLock();*
>>
>>         }
>>
>> Can be improved as,
>>         try {
>>             *ApplicationHolder.acquireReadLock();*
>>             if (idOfComponent.equals(appId)) {
>>                 //it is an application
>>                 component = ApplicationHolder.getApplications().
>>                         getApplication(appId);
>>             } else {
>>                 //it is a group
>>                 component = ApplicationHolder.getApplications().
>>
>> getApplication(appId).getGroupRecursively(idOfComponent);
>>             }
>>         } finally {
>>
>>            * ApplicationHolder.acquireReadLock();*
>>         }
>>         try{
>>
>>
>> *ApplicationLockHierarchy.getInstance().getLockForApplication(idOfComponent).acquireWriteLock();*
>>             groups = component.getAliasToGroupMap();
>>             clusterData = component.getClusterDataMap();
>>
>>             if(component.isGroupScalingEnabled()) {
>>                 //TODO
>>                 handleStateWithGroupScalingEnabled();
>>             } else {
>>                 handleStateChangeGroupScalingDisabled(component, appId,
>> instanceId, groups, clusterData);
>>             }
>>         } finally {
>>
>>
>> *ApplicationLockHierarchy.getInstance().getLockForApplication(idOfComponent).releaseWritelock();*
>>         }
>>
>> On Wed, Dec 3, 2014 at 6:45 AM, Nirmal Fernando <ni...@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> AFAIS, currently all the Applications statically uses an org.apache.stratos.autoscaler.applications.ApplicationHolder
>>> object and acquires locks before reading from/writing to it.
>>>
>>> After going through the places we acquire locks, it appears that
>>> deploying concurrent Applications will lead lot of Applications to wait so
>>> long to get started. Is my observation correct?
>>>
>>>
>>> ​
>>>
>>> --
>>> Best Regards,
>>> Nirmal
>>>
>>> Nirmal Fernando.
>>> PPMC Member & Committer of Apache Stratos,
>>> Senior Software Engineer, WSO2 Inc.
>>>
>>> Blog: http://nirmalfdo.blogspot.com/
>>>
>>
>>
>>
>> --
>> --
>> Lahiru Sandaruwan
>> Committer and PMC member, Apache Stratos,
>> Senior Software Engineer,
>> WSO2 Inc., http://wso2.com
>> lean.enterprise.middleware
>>
>> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
>> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>>
>>
>
>
> --
> --
> Lahiru Sandaruwan
> Committer and PMC member, Apache Stratos,
> Senior Software Engineer,
> WSO2 Inc., http://wso2.com
> lean.enterprise.middleware
>
> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>
> --
> <http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146>
> <http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146>
> Thanks and Regards,
>
> Isuru H.
> <http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146>
> +94 716 358 048 <http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146>*
> <http://wso2.com/>*
>
>
> * <http://wso2.com/>*
>
>
>

Re: Deploying concurrent Applications simultaneously

Posted by Lahiru Sandaruwan <la...@wso2.com>.
Isuru,

Need to find out if "getLockForApplication(idOfComponent)" returns the
locks for group components as well. If not, can we do that?

Thanks.

On Wed, Dec 3, 2014 at 9:27 AM, Lahiru Sandaruwan <la...@wso2.com> wrote:

> We already have hierarchical locking. It seems some points we can improve
> the usage,
>
> E.g. In StatusChecker class,
>
> Following code,
>
>         try {
>
>             *ApplicationHolder.acquireWriteLock();*
>
>             if (idOfComponent.equals(appId)) {
>
>                 //it is an application
>
>                 component = ApplicationHolder.getApplications().
>
>                         getApplication(appId);
>
>             } else {
>
>                 //it is a group
>
>                 component = ApplicationHolder.getApplications().
>
>
> getApplication(appId).getGroupRecursively(idOfComponent);
>
>             }
>
>             groups = component.getAliasToGroupMap();
>
>             clusterData = component.getClusterDataMap();
>
>             if(component.isGroupScalingEnabled()) {
>
>                 //TODO
>
>                 handleStateWithGroupScalingEnabled();
>
>             } else {
>
>                 handleStateChangeGroupScalingDisabled(component, appId,
> instanceId, groups, clusterData);
>
>             }
>
>         } finally {
>
>            * ApplicationHolder.releaseWriteLock();*
>
>         }
>
> Can be improved as,
>         try {
>             *ApplicationHolder.acquireReadLock();*
>             if (idOfComponent.equals(appId)) {
>                 //it is an application
>                 component = ApplicationHolder.getApplications().
>                         getApplication(appId);
>             } else {
>                 //it is a group
>                 component = ApplicationHolder.getApplications().
>
> getApplication(appId).getGroupRecursively(idOfComponent);
>             }
>         } finally {
>
>            * ApplicationHolder.acquireReadLock();*
>         }
>         try{
>
>
> *ApplicationLockHierarchy.getInstance().getLockForApplication(idOfComponent).acquireWriteLock();*
>             groups = component.getAliasToGroupMap();
>             clusterData = component.getClusterDataMap();
>
>             if(component.isGroupScalingEnabled()) {
>                 //TODO
>                 handleStateWithGroupScalingEnabled();
>             } else {
>                 handleStateChangeGroupScalingDisabled(component, appId,
> instanceId, groups, clusterData);
>             }
>         } finally {
>
>
> *ApplicationLockHierarchy.getInstance().getLockForApplication(idOfComponent).releaseWritelock();*
>         }
>
> On Wed, Dec 3, 2014 at 6:45 AM, Nirmal Fernando <ni...@gmail.com>
> wrote:
>
>> Hi,
>>
>> AFAIS, currently all the Applications statically uses an org.apache.stratos.autoscaler.applications.ApplicationHolder
>> object and acquires locks before reading from/writing to it.
>>
>> After going through the places we acquire locks, it appears that
>> deploying concurrent Applications will lead lot of Applications to wait so
>> long to get started. Is my observation correct?
>>
>>
>> ​
>>
>> --
>> Best Regards,
>> Nirmal
>>
>> Nirmal Fernando.
>> PPMC Member & Committer of Apache Stratos,
>> Senior Software Engineer, WSO2 Inc.
>>
>> Blog: http://nirmalfdo.blogspot.com/
>>
>
>
>
> --
> --
> Lahiru Sandaruwan
> Committer and PMC member, Apache Stratos,
> Senior Software Engineer,
> WSO2 Inc., http://wso2.com
> lean.enterprise.middleware
>
> email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
> linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146
>
>


-- 
--
Lahiru Sandaruwan
Committer and PMC member, Apache Stratos,
Senior Software Engineer,
WSO2 Inc., http://wso2.com
lean.enterprise.middleware

email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146

Re: Deploying concurrent Applications simultaneously

Posted by Lahiru Sandaruwan <la...@wso2.com>.
We already have hierarchical locking. It seems some points we can improve
the usage,

E.g. In StatusChecker class,

Following code,

        try {

            *ApplicationHolder.acquireWriteLock();*

            if (idOfComponent.equals(appId)) {

                //it is an application

                component = ApplicationHolder.getApplications().

                        getApplication(appId);

            } else {

                //it is a group

                component = ApplicationHolder.getApplications().


getApplication(appId).getGroupRecursively(idOfComponent);

            }

            groups = component.getAliasToGroupMap();

            clusterData = component.getClusterDataMap();

            if(component.isGroupScalingEnabled()) {

                //TODO

                handleStateWithGroupScalingEnabled();

            } else {

                handleStateChangeGroupScalingDisabled(component, appId,
instanceId, groups, clusterData);

            }

        } finally {

           * ApplicationHolder.releaseWriteLock();*

        }

Can be improved as,
        try {
            *ApplicationHolder.acquireReadLock();*
            if (idOfComponent.equals(appId)) {
                //it is an application
                component = ApplicationHolder.getApplications().
                        getApplication(appId);
            } else {
                //it is a group
                component = ApplicationHolder.getApplications().

getApplication(appId).getGroupRecursively(idOfComponent);
            }
        } finally {

           * ApplicationHolder.acquireReadLock();*
        }
        try{


*ApplicationLockHierarchy.getInstance().getLockForApplication(idOfComponent).acquireWriteLock();*
            groups = component.getAliasToGroupMap();
            clusterData = component.getClusterDataMap();

            if(component.isGroupScalingEnabled()) {
                //TODO
                handleStateWithGroupScalingEnabled();
            } else {
                handleStateChangeGroupScalingDisabled(component, appId,
instanceId, groups, clusterData);
            }
        } finally {


*ApplicationLockHierarchy.getInstance().getLockForApplication(idOfComponent).releaseWritelock();*
        }

On Wed, Dec 3, 2014 at 6:45 AM, Nirmal Fernando <ni...@gmail.com>
wrote:

> Hi,
>
> AFAIS, currently all the Applications statically uses an org.apache.stratos.autoscaler.applications.ApplicationHolder
> object and acquires locks before reading from/writing to it.
>
> After going through the places we acquire locks, it appears that deploying
> concurrent Applications will lead lot of Applications to wait so long to
> get started. Is my observation correct?
>
>
> ​
>
> --
> Best Regards,
> Nirmal
>
> Nirmal Fernando.
> PPMC Member & Committer of Apache Stratos,
> Senior Software Engineer, WSO2 Inc.
>
> Blog: http://nirmalfdo.blogspot.com/
>



-- 
--
Lahiru Sandaruwan
Committer and PMC member, Apache Stratos,
Senior Software Engineer,
WSO2 Inc., http://wso2.com
lean.enterprise.middleware

email: lahirus@wso2.com blog: http://lahiruwrites.blogspot.com/
linked-in: http://lk.linkedin.com/pub/lahiru-sandaruwan/16/153/146

Re: Deploying concurrent Applications simultaneously

Posted by Isuru Haththotuwa <is...@apache.org>.
On Wed, Dec 3, 2014 at 6:45 AM, Nirmal Fernando <ni...@gmail.com>
wrote:

> Hi,
>
> AFAIS, currently all the Applications statically uses an org.apache.stratos.autoscaler.applications.ApplicationHolder
> object and acquires locks before reading from/writing to it.
>
> After going through the places we acquire locks, it appears that deploying
> concurrent Applications will lead lot of Applications to wait so long to
> get started. Is my observation correct?
>
Yes, this is the same for Topology model in CC as well. We have
hierarchical locking in the messaging component, and we can use the same
here as well.

>
>
> ​
>
> --
> Best Regards,
> Nirmal
>
> Nirmal Fernando.
> PPMC Member & Committer of Apache Stratos,
> Senior Software Engineer, WSO2 Inc.
>
> Blog: http://nirmalfdo.blogspot.com/
>
> --
> <http://nirmalfdo.blogspot.com/>
> <http://nirmalfdo.blogspot.com/>
> Thanks and Regards,
>
> Isuru H.
> <http://nirmalfdo.blogspot.com/>
> +94 716 358 048 <http://nirmalfdo.blogspot.com/>* <http://wso2.com/>*
>
>
> * <http://wso2.com/>*
>
>
>