Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

Feature Request - configurable number-of-instances, max-instances-per-vm

Hi, Due to number-of-instances and max-instances-per-vm are coded as Integers, you cannot use PropertyPlaceholderConfigurer to set those variables as a property value.

I would like to be able to do in the pu.xml file:

<bean id="propertiesConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
<os-sla:sla cluster-schema="partitioned" number-of-instances="${number-instances}" max-instances-per-vm="${number-instances-per-vm}">

Where ${number-instances} and ${number-instances-per-vm} are both defined in the temp.properties file.

The reason for the request is to allow us set different default deployment instances for different deployment environments. This should be a fairly simple change in Openspaces code. Please let me know if what I am requesting makes sense, and if there are any work-arounds avaialble, thanks!

Sean Zhong ( bigfishgames.com )

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=2880]{quote}

asked 2009-02-13 12:55:23 -0500

sean.zhong gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2009-02-19 23:54:31 -0500

shay hassidim gravatar image
edit flag offensive delete link more


Thanks Shay. I understand how to use PropertyPlaceholderConfigurer in the pu.xml. We are using it all over the place. The problem is that I can't get it to work with the SLA bean. It seems that the space is loading the SLA bean directly without calling PropertyPlaceholderConfigurer to replace the variables.


sean.zhong gravatar imagesean.zhong ( 2009-02-20 13:32:15 -0500 )edit

I have checked this - this option is not supported.
We will make sure the doc will reflect this info.
So your Feature Request is valid. :-)

You can submit it via the support portal:

shay hassidim gravatar imageshay hassidim ( 2009-02-20 16:56:03 -0500 )edit

Thank you. Just submitted a proper feature request through the customer service tool. Hope to see this feature soon :)


sean.zhong gravatar imagesean.zhong ( 2009-02-20 18:24:03 -0500 )edit

Please see this post from April 2008: [//question/6527/property-placeholders-not-resolved-in-os-coresecurity/&tstart=480]

It reports an issue with using PropertyPlaceholderConfigurer with OpenSpaces namespaces.

Even though my stand-alone PU running under GigaSpaces XAP 6.0.5 made no use of the SLA bean, Spring successfully created the SLA bean for me as I described it in a previous message. Exceptions were thrown when the worker.instances property was missing or had a value that wasn't a number.

HTH --Vanio

vanio gravatar imagevanio ( 2009-02-22 12:04:08 -0500 )edit

Did you try using plain XML definition instead of OpenSpaces namespaces?

Something like: <bean id="SLA" class="org.openspaces.pu.sla.SLA"> <property name="clusterSchema" value="partitioned"/> <property name="numberOfInstances" value="${number-instances}"/> <property name="maxInstancesPerVM" value="${number-instances-per-vm}"/> </bean>

HTH -- Vanio

answered 2009-02-13 16:13:55 -0500

vanio gravatar image
edit flag offensive delete link more


yes, I've tried this option and here's the error I got:

Error deploying [worker-service]:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SLA' defined in resource loaded from byte array: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [int] for property 'numberOfInstances'; nested exception is java.lang.NumberFormatException: For input string: "${worker.instances}"

<!-- Defining SLA for the pu service -->
<bean id="SLA" class="org.openspaces.pu.sla.SLA">
    <property name="numberOfInstances" value="${worker.instances}" />
    <property name="maxInstancesPerVM" value="1" />

worker.instances is defined in a properties file loaded with:

<bean id="propertiesConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">

I know this should work, and I don't understand why I get these errors. Would you be able to test this out to see if you are getting the same error? thanks


sean.zhong gravatar imagesean.zhong ( 2009-02-18 20:44:03 -0500 )edit

Hm...it works for me using plain XML definition for the "SLA" bean.

I placed worker.properties file in the PU's deploy directory and had a worker.instances property in the file. For example: worker.instances=9

You may want to double check if the file has a "worker.instances" property and what is its value.

-- Vanio

vanio gravatar imagevanio ( 2009-02-19 14:26:23 -0500 )edit

Still no luck for me, but I did find out something interesting:

If I replace the SLA bean name with something arbitrary, such as "a" instead of "SLA", then there are no errors. So it seems the SLA bean is loaded before the other beans (such as PropertyPlaceholderConfigure), and so it does not resolve the variable ${worker.instances}

I'm not sure how you got this to work, can you please give me a zip of the pu? I would like to see if I'm doing anything different. Thanks


sean.zhong gravatar imagesean.zhong ( 2009-02-19 16:55:34 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2009-02-13 12:55:23 -0500

Seen: 112 times

Last updated: Feb 19 '09