Liberty server properties file setup - websphere-liberty

I have properties file in local to which I am reading in code by below method
String pathOfFile = System.getProperties("arg.get.prop");
How to set this system properties to get my property file's path in liberty server.xml

You can specify environment variables in the server.env file placed either in ${wlp.install.dir}/etc/server.env or ${server.config.dir}/server.env. The server will also pick up variables from the current shell environment (server.env files take precedence). Then you can access the variables in the server.xml using the following notation:
${env.<variable name>}
For example, you can have the following in your server.env file:
HTTP_PORT=9001
and then in your server.xml:
<httpEndpoint id="defaultHttpEndpoint"
httpPort="${env.HTTP_PORT}"
httpsPort="9443" />
For more information on customizing the Liberty environment see: https://www.ibm.com/support/knowledgecenter/en/SSAW57_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/twlp_admin_customvars.html

If you need to define system property the recommended way is to use jvm.options file and put your property there like:
# Set a system property.
-Darg.get.prop=ExampleValue
you may need to create that file in the ${server.config.dir} directory. For some more details check Customizing the Liberty environment

if your property file is in "variable=value" format .. then, you can include in in bootstrap.properties file of your liberty install.
bootstrap.properties can be used to supply variable values to liberty configuration. you can include additional files by specifying
bootstrap.include=

Related

Unable to pass arguments to a .jmx files from build.gradle file through jmRun

i am facing multiple problems with my .jmx file.
I am working with bzm-concurrency thread group
1) it is not recognising the standard format of passing the user defined values
like: ${__P(SERVER_NAME,localhost)} instead of passing "localhost" to my script it is appending "${__P(SERVER_NAME,localhost)}" to my url.
After passing only the value i.e (localhost) it is working fine
2) Also, iam running my jmeter script from build.gradle file and iam unable to pass the url and other details from them
|SERVER_NAME|${__P(SERVER_NAME,localhost)}| --> this code is not working
|SERVER_NAME|localhost| --> this code is working fine
jmeter {
jmTestFiles = [file("src/main/Jmetrscript.jmx")]
jmSystemPropertiesFiles= [file(path of my properties file)] //to add additional system properties
jmUserProperties = ["SERVER_NAME ="+System.getProperty('SERVER_NAME','localhost'), "SERVER_PORT ="+System.getProperty('SERVER_PORT','9080') ]
enableExtendedReports = true //produce Graphical and CSV reports
}
when i run this using gradlew jmRun -DSERVER_NAME=localhost it is not passing the value.
As per JMeter Gradle Plugin - Advanced Usage
Supported JMeter commandline arguments (see full list here):
-p, --propfile {argument}, the jmeter property file to use
-q, --addprop {argument}, additional property file(s)
-t, --testfile {argument}, the jmeter test(.jmx) file to run
-J, --jmeterproperty {argument}={value}, Define additional JMeter properties
-D, --systemproperty {argument}={value}, Define additional System properties
-S, --systemPropertyFile {filename}, a property file to be added as System properties
-r, --runremote (non-GUI only), Start remote servers (as defined by the jmeter property remote_hosts)
-G, --globalproperty (argument)[=(value)], Define Global properties (sent to servers), e.g. -Gport=123, or -Gglobal.properties
So you should pass JMeter Properties via -J command-line argument like:
jmRun -JSERVER_NAME=localhost etc
References:
Overriding Properties Via The Command Line
Apache JMeter Properties Customization Guide

Loading multiple config file from spring cloud config server

Hey I got to know how to check properties in config server i.e. http://{Config server URL}:{Port}/{ServiceID}/{Profile}
Right now I am facing a problem where I've to read multiple properties file from cloud config server. Ex: Right now I've to read properties file(huge file) from a single property file i.e. employee.properties
I don't want huge list of properties file in single folder. like
employee-dev.properties
employee-dit.properties
employee-sit.properties
employee-uat.properties
employee-preprod.properties
employee-prod.properties
customers-dev.properties
customers-dit.properties
customers-sit.properties
customers-uat.properties
customers-preprod.properties
customers-prod.properties
.
.
.
and soo on.
My requirement is I need to maitain a list of properties file and config server will provide me these values. like :
**{env}/employee.properties**
**{env}/customers.properties**
Here env could be any environment like dit, sit, prod etc.
Hope I'll get answer here.
If you don't want to have all properties files in an only folder, so you need to add this configuration on config server properties file.
1. Match all options
spring.cloud.config.server.native.searchLocations = [classpath:/, classpath:/config, classpath:/config/{application}, classpath:/config/{application}/{profile}]
2. Match only /application-name/application-name-profile.properties
spring.cloud.config.server.native.searchLocations = classpath:config/{application}
Then you'll have matched based on application name folder for example.
resources/config/application-name/application-name-properties.

How can I specify location of property file in OSGi blueprint?

I would like to specify location of property file, from which OSGi blueprint property placeholder should read properties values:
<cm:property-placeholder persistent-id="myBundle"/>
<bean
id="myCoolBean"
class="test.properties.MyCoolBean">
<property
name="echo"
value="${echo}"/>
</bean>
UPDATE:
Configuration felix.configadmin + felix.fileinstall works for me.
I installed:
org.apache.felix.configadmin-1.8.0.jar
org.apache.felix.fileinstall-3.1.4.jar
org.eclipse.equinox.cm-3.2.0.jar
I specified VM argument -Dfelix.fileinstall.dir=C:/eclipse/config
The myBundle.cfg file has value:
echo=Echo
The property placeholder in blueprint does not work with files. Instead it uses the persistent id to retreive a config from ConfigurationAdmin service.
So the solution is to install felix config admin together with felixfileinstall. So configs will be retrieved from a folder and updated in ConfigurationAdmin.
In apache karaf this is already configured but you can also do it on your own. See my karaf tutorial about config admin.
If you want to go with plain felix then you can take a look what karaf does to solve it. So for example in config.properties there are the settings for felix fileinstall. There you have to e.g. set he directory containing your configs. In plain felix that would be framework properties.
This is what karaf sets:
felix.fileinstall.enableConfigSave = true
felix.fileinstall.dir = ${karaf.etc}
felix.fileinstall.filter = .*\\.cfg
felix.fileinstall.poll = 1000
felix.fileinstall.noInitialDelay = true
felix.fileinstall.log.level = 3

Jmeter variable filepath is not resolved in FileToString function

I am using:
${__eval( ${__FileToString(${filePath}\x.xml)})}
to get an XML String from a file. The variable filePath is not resolved and I'm always getting the error "FileNotFound exception". If the absolute path is given, it works. It seems the variable is not resolved before the FileToString function call. Is there a way to use a relative path?
JMeter uses FileServer class to determine it's base directory.
If you look into JMeter log you'll be able to see something like:
2014/07/14 15:32:12 INFO - jmeter.services.FileServer: Default base='/opt/jmeter/bin'
In my case it's /opt/jmeter/bin
So if I drop x.xml file into /opt/jmeter/bin folder it would be resolved via ${__FileToString(x.xml,,)} function.
There is a property which can control base directory for relative paths resolution:
# Prefix used to identify filenames that are relative to the current base
#jmeter.save.saveservice.base_prefix=~/
You can set it to any other folder and JMeter will use it as the base for paths resolution.
The property can be changed in:
jmeter.properties file
user.properties file
overriden via -J command-line argument as
jmeter -Jjmeter.save.saveservice.base_prefix=c:/xml_payload/
jmeter.properties and user.properties files live under /bin folder of your JMeter installation, FileServer base is usually the same folder.
See Apache JMeter Properties Customization Guide for more details on JMeter tuning using properties.

Magento - Use config value inside module config file

Is it possible to use a config value inside another modules config file - in much the same way you can grab a config file using getStoreConfig().
If so, how?
No. All the (static) config XML files are read from the filesystem before any config values are retrieved from the database.
Yes, it's possible. You can get any value from any of your xml files (all of them - config.xml, admin.xml etc are merged into one) like this:
$config = Mage::getConfig()->getNode('global/sales/order/statuses');
Zend_Debug::dump($config);

Resources