How to get only the active bundles in karaf - osgi

I need a command to get only the active bundles in osgi / karaf,
I know that scr:list / osgi:list will list all the bundles irrespective of state.
Is there any other easy way to check all the bundles are active in karaf?
Regards,
Harry

How about:
la | grep -i active
where la is a shortcut for osgi:list with list all bundles including system.

Use
la | grep '| Active |'
Since this will avoid any false positives due to a bundle which has 'active' in its name.

Related

How to work with packages in Liquibase

We use liquibase with oracle. So we have some packages with procedures inside.
In our case changelog structure looks like:
master.xml
|
| release1
| |
| release-maser.xml
| release2
| |
| release-maser.xml
| softObjects
| |
| package-master.xml
| packages
| |
| somePackage.pkb
| somePackage.pks
change sets inside "releases" with runOnChange=false and "softObjects"(that can be create used CREATE OR REPLACE) with runOnChange=true like in best practices:
Try to maintain separate changelog for Stored Procedures and use
runOnChange=”true”. This flag forces LiquiBase to check if the
changeset was modified. If so, liquibase executes the change again.
So every update intall some "delta" change sets from "release" and AFTER reinstal all "softObjects" that was changed and in usual case all is OK.
But if I need to setup new DB, I will get a problem:
in change set from second release I use somePackage(v1), but in next release i need to change logic/API somePackage so I will get somePackage(v2) that can not be used in previously created change sets. So for now I have change set that on update will try to use wrong package version.
For avoid this I can add soft objects directly inside release folder without runOnChange=true when i create it. When I need to change it, i should just copy previous version of file to my new release and make changes inside a COPY.
This approach has some disadvantages:
you make a lot of copy files that can consist from thousands lines of
code(yes I know that it isn`t good)
version control system recognize it as a new file (good challenge for
reviewers)
What i undestand wrong? How should I work with "softObjects", if this objects might be changed?

How to install and use the JMeter plugin "Standard Set"

Hi I have downloaded the Standard Set from the JMeter plugin site.
I installed it as it says here:
http://jmeter-plugins.org/wiki/PluginInstall/
The problem is that I don't get to see any option in the Listener Menu that let me add a new Graphs Generator Listener as described here:
http://jmeter-plugins.org/wiki/GraphsGeneratorListener/
I need to create a Transactions per Second graph , but I don't know how to do it.
I really appreciate if you could help me out.
Thanks in advance.
If you do not see the extra elements in the menu, there is something wrong with your jmeter-plugins installation.
Make sure you unpacked the zip in the folder above 'bin', that is not clear in the instructions.
At the same folder level as 'bin' there should also be a 'lib', and beneath this, 'ext'.
Check that the 'ext' folder contains the jmeter plugin jar and other support files.
it should look like this:
|-apache-jmeter-2.11
| |-bin
| | |-jmeter.bat
| | |-ApacheJMeter.jar
| | |-...
| |-lib
| | |-ext
| | | |-JMeterPlugin-Standard.jar
| | | |-...
| | |-...
| |-...
|-...
Make sure you restart jmeter after moving these files. If you have the jar in the right place, the extensions will be loaded and available from menu options.
To install the JMeter Plugins,
-> Copy the JMeterPlugins.jar file from JMeterPlugins-VERSION.zip
-> Paste the file to JMETER_INSTALL_DIR/libexec/lib/ext

Why I cannot scale openshift cart having an environment variable defined?

I am trying to integrate Hazelcast in Tomcat cartridge (https://github.com/worldline/openshift-cartridge-tomcat). The problem is to retrieve ip:ports of gears of a scalable application. I looked at how vert.x does it and it is perfectly fine. It uses pub/sub mechanist to set ip and port in the future environment variable. I can see this in hook folder "set-vertex-cluster" file.
echo $list > $OPENSHIFT_VERTX_DIR/env/OPENSHIFT_VERTX_HAZELCAST_CLUSTER
I did id the same way replacing VERTX by TOMCAT (short name of cart).
But after creating the app there is no OPENSHIFT_TOMCAT_HAZELCAST_CLUSTER env variable.
I looked at how JbossEAP does it. It has
touch ${OPENSHIFT_JBOSSEAP_DIR}/env/OPENSHIFT_JBOSSEAP_CLUSTER
https://github.com/openshift/origin-server/blob/master/cartridges/openshift-origin-cartridge-jbosseap/bin/install
It worked for me, and finally I see OPENSHIFT_VERTX_HAZELCAST_CLUSTER env var and it is populated by gear_ip:gear_port.It's good. But when I scale the app I get the error:
Activation of new gears failed: 53d2ed31e0b8cd2bba00051f: Error activating gear: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/53d2ed31e0b8cd2bba00051f/tomcat
Unable to complete the requested operation due to: An invalid exit code (1) was returned from the server ex-std-node92.prod.rhcloud.com. This indicates an unexpected problem during the execution of your request.
Reference ID: 0b4e8a465d1901e8317a18739586e6d1
OPENSHIFT_VERTX_HAZELCAST_CLUSTER is populated by gear1_ip:gear1_port and gear2_ip:gear2_port but of course the second gear failed to start.
When I remove
touch ${OPENSHIFT_TOMCAT_DIR}/env/OPENSHIFT_TOMCAT_HAZELCAST_CLUSTER
from bin/install file everything is fine! Except that I don't have list of cluster members...
I am going mad, struggling with the problem all day long. Can anybody help me, please?
UPDATED:
• Customer A create an OpenShift Application A1 with the Git downloadable cartridge
• OpenShift install the downloadable cartridge into Node N1 and install it into the Application A1.
• Customer A now want to scale the application A1.
• OpenShift try to scale the application A1 by acquiring a new gear in Node N2 (notice that it is different from N1 above) and copy the content from A1 into N2 (but somehow will not copy all the environment variables and necessary settings). In .env folder of every gear
• The gear creation now fail on N2, because the downable cartridge content is not available on N2, because of following commands in bin/tomcat
# Filter user-owned configuration files through sed to replace all
# ${OPENSHIFT_*} variables with their actual values, and write the
# resulting filtered files to the live Tomcat configuration location.
sed_replace_env=$(print_sed_exp_replace_env_var)
replacement_conf_files=(
"server.xml"
"context.xml"
)
for conf_file in "${replacement_conf_files[#]}"; do
sed ${sed_replace_env} ${OPENSHIFT_REPO_DIR}/.openshift/config/${conf_file} > ${OPENSHIFT_TOMCAT_DIR}/conf/${conf_file}
done
The particular function
function print_sed_exp_replace_env_var {
sed_exp=""
for openshift_var in $(env | grep OPENSHIFT_ | awk -F '=' '{print $1}')
do
# environment variable values that contain " or / need to be escaped
# or they will cause problems in the sed command line.
variable_val=$(echo "${!openshift_var}" | sed -e "s#\/#\\\\/#g" | sed -e "s/\"/\\\\\"/g")
# the entire sed s/search/replace/g command needs to be quoted in case the variable value
# contains a space.
sed_exp="${sed_exp} -e \"s/\\\${env.${openshift_var}}/${variable_val}/g\""
done
printf "%s\n" "$sed_exp"
}
As you can see, there is a dangerous of the sed command that may replace entire file into blank file for server.xml and context.xml if the environment variables are not present.
The correct order that OpenShift should perform is:
Customer A create an OpenShift Application A1 with the Git downloadable cartridge
• OpenShift install the downloadable cartridge into Node N1 and install it into the Application A1.
• Customer A now want to scale the application A1.
• OpenShift try to scale the application A1 by acquiring a new gear in Node N2 (notice that it is different from N1 above). Copy all necessary environment variables into the new gears as well
• There is a script within your cartridge that require the server.xml and context.xml template from downloadable cartridge, it can now be successfully found and copy.

List bundle ID's only on servicemix

I'm using ServiceMix and I was trying to list some bundles and retrieve only there bundle ID.
I'm trying to do the following:
osgi:list | grep -i | awk xxx
I tried to use awk but that's not provided in ServiceMix.
I also tried to use shell:exec like this:
osgi:list | grep -i | shell:exec awk 'xxx'
But that doesn't work either, maybe my approach is completely wrong.
Does anybody else have some experience how I could achieve my goal of only retrieving the id's of a bundle?
You can always make use of Karaf's shell language (Works as of karaf 2.3.1)
bundles = $.context bundles ;
echo "Printing bundle information" ;
each ($bundles) {
symbolicName = $it symbolicName ;
bundleId = (($it bundleid) toString) ;
echo "Symbolic name : " $symbolicName " Bundle Id : " $bundleId ;
}
When ran this will output something similiar to :
Symbolic name : org.apache.felix.framework Bundle Id : 0
Symbolic name : org.ops4j.pax.url.mvn Bundle Id : 1
Symbolic name : org.ops4j.pax.url.wrap Bundle Id : 2
Symbolic name : org.ops4j.pax.logging.pax-logging-service Bundle Id : 3
I dont think there is a sed/awk command. And the list command cannot only just show the bundle id.
You can log a JIRA ticket for an enhancement. Maybe for options to the list command to select what to list only (bundle id, bundle version, state etc.)
http://karaf.apache.org/index/community/support.html

Setting proxy on .Rprofile on OSX fails

In order to access CRAN packages from within R on OSX I've been using
Sys.setenv(http_proxy="http://blah_blah:1234/")
as the first command in the R GUI for a while, but would really like to set this proxy automatically.
I've tried unsuccessfully to get the same command to work in a .Rprofile file in ~/
I've also tried http_proxy="http://blah_blah:1234/", but this fails too.
The error I get when I try to view packages is a drop-down window that says:
Fetching Package List Failed
Please consult R Console output for details
The GUI then gives:
Error in read.dcf(file = tmpf) : Line starting '<head> ...' is malformed!
The .Rprofile file itself seems to be loading (checked using cat("my profile works\n"))
Couldn't you just use .First ?
http://cran.r-project.org/doc/manuals/R-intro.html#Customizing-the-environment
This thread appears first when searching for setting R proxy on OS X, so here's what I use in my .Rprofile:
Sys.setenv(http_proxy=system("networksetup -getwebproxy Ethernet | awk {'print $2'} | awk {'getline l2; getline l3; print \"http://\"l2\":\"l3'} | head -n 1",intern=TRUE))
Change Ethernet to Airport if necessary.
Credit for the awk part goes to Chealion
I think I have managed to solve this using trial and error...
A combination of .First and Sys.setenv() works.
If anyone has any ideas I'd be interested to know why.

Resources