Command-line JMX Client set value - java

I m using Command-line JMX Client to be able to query ActiveMQ Server. At the same time I want to be able to set values dynamically to the server. such as MemoryLimit.
Is it possible to set values via Command-Line JMX client, if yes , how can i set the memory limit?
This is how i was able to query.
java -jar cmdline-jmxclient-0.10.3.jar - localhost:1099 org.apache.activemq:BrokerName=defaultBroker,Destination=Testing,Type=Queue MemoryLimit
but how can i set memorylimit?
I tried below:
java -jar cmdline-jmxclient-0.10.3.jar - localhost:1099 org.apache.activemq:BrokerName=defaultBroker,Destination=Testing,Type=Queue setMemoryLimit=300000`
and failed as below.
11/18/2011 11:56:28 -0800 org.archive.jmx.Client setMemoryLimit=300000: Operation setMemoryLimit not found.

Edit
I'd recommend dropping that jmxclient and switching to:
http://wiki.cyclopsgroup.org/jmxterm
It looks to be supported and better documented. I suspect that it will work and give you access to the setters -- if they exist.
If the set method does exist then the following should work:
java -jar cmdline-jmxclient-0.10.3.jar - localhost:1099 \
org.apache.activemq:BrokerName=defaultBroker,Destination=Testing,Type=Queue \
setMemoryLimit=...
Here are the docs:
http://crawler.archive.org/cmdline-jmxclient/
To find out which attributes are available for setting and getting, I'd use jconsole. If you are using a Java6+ jconsole, you field click on the bean you want to get information from. That should show you the ObjectName to use on the command line. Then if you open the attributes list, the name of the attribute should have a corresponding get method. If the value is colored blue then there should be a corresponding set method.
For example, if you open up the java.lang folder in jconsole, you should be able to click on ClassLoading. That shows you the ObjectName to use is java.lang:type=ClassLoading. You can then do the following to list the various attributes and operations available:
java -jar cmdline-jmxclient-0.10.3.jar - localhost:1099 \
java.lang:type=ClassLoading
You should see the getters and the setters. Here's how you get the Verbose attribute:
java -jar cmdline-jmxclient-0.10.3.jar - localhost:1099 \
java.lang:type=ClassLoading Verbose
For some reason my version cmdline-jmxclient does not know how to do boolean type so it doesn't show up as a setter. If it did you should be able to do:
java -jar cmdline-jmxclient-0.10.3.jar - localhost:1099 \
java.lang:type=ClassLoading setVerbose=true

Related

Weka - Can't find a permissible class

I'm integrating Weka into a plug-in I'm writing for another application. I included weka.jar in my class path and for the most part, things seem to be working well. Unfortunately, when I get to the point of changing the options for some classifiers, I run into problems specific to being unable to find certain classes. For example, when I try to change the name of the classifier in the AdaBoost options, I get an error that ends like so:
java.lang.Exception: Can't find a permissible class called: weka.classifiers.bayes.BayesNet
Model options set to: -P 50 -S 1 -I 10 -W weka.classifiers.bayes.BayesNet
at weka.core.ResourceUtils.forName(ResourceUtils.java:84)
at weka.core.Utils.forName(Utils.java:1080)
at weka.classifiers.AbstractClassifier.forName(AbstractClassifier.java:91)
at weka.classifiers.SingleClassifierEnhancer.setOptions(SingleClassifierEnhancer.java:108)
at weka.classifiers.IteratedSingleClassifierEnhancer.setOptions(IteratedSingleClassifierEnhancer.java:115)
at weka.classifiers.RandomizableIteratedSingleClassifierEnhancer.setOptions(RandomizableIteratedSingleClassifierEnhancer.java:93)
at weka.classifiers.meta.AdaBoostM1.setOptions(AdaBoostM1.java:375)
I'm thinking that this might have something to do with me using the JAR in an OSGi bundle, but I'm not sure. Any ideas? Other than this issue, I'm able to train these classifiers just fine using the default options for them.
Thanks.
Solve this problem via set all parameters via setters.
This problem when you use like this
BayesNet processes = new BayesNet();
String options = "-D -Q weka.classifiers.bayes.net.search.local.K2 -- -P 1 -S BAYES -E weka.classifiers.bayes.net.estimate.SimpleEstimator -- -A 0.5";
processes.setOptions(weka.core.Utils.splitOptions(options));
Change set all param like this.(Here not all option, small example)
BayesNet processes = new BayesNet();
SimpleEstimator newBayesNetEstimator = new SimpleEstimator();
newBayesNetEstimator.setAlpha(0.5);
processes.setEstimator(newBayesNetEstimator);

Use docker-machine create from java

I have an application that (I want to) uses Java to start and stop Docker containers. It seems that the way to do this is using docker-machine create, which works fine when I test from the command line.
However, when running using Commons-Exec from Java I get the error:
(aa4567c1-058f-46ae-9e97-56fb8b45211c) Creating SSH key...
Error creating machine: Error in driver during machine creation: /usr/local/bin/VBoxManage modifyvm aa4567c1-058f-46ae-9e97-56fb8b45211c --firmware bios --bioslogofadein off --bioslogofadeout off --bioslogodisplaytime 0 --biosbootmenu disabled --ostype Linux26_64 --cpus 1 --memory 1024 --acpi on --ioapic on --rtcuseutc on --natdnshostresolver1 off --natdnsproxy1 on --cpuhotplug off --pae on --hpet on --hwvirtex on --nestedpaging on --largepages on --vtxvpid on --accelerate3d off --boot1 dvd failed:
VBoxManage: error: Could not find a registered machine with UUID {aa4567c1-058f-46ae-9e97-56fb8b45211c}
VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 500 of file VBoxManageModifyVM.cpp
I have set my VBOX_USER_HOME variable in an initializationScript that I'm using to start the machine:
export WORKERID=$1
export VBOX_USER_HOME=/Users/me/Library/VirtualBox
# create the machine
docker-machine create $WORKERID && \ # create the worker using docker-machine
eval $(docker-machine env $WORKERID) && \ # load the env of the newly created machine
docker run -d myimage
And I'm executing this from Java via the Commons Exec CommandLine class:
CommandLine cmdline = new CommandLine("/bin/sh");
cmdline.addArgument(initializeWorkerScript.getAbsolutePath());
cmdline.addArgument("test");
Executor executor = new DefaultExecutor();
If there is another library that can interface with docker-machine from Java I'm happy to use that, or to change out Commons Exec if that's the issue (though I don't understand why). The basic requirement is that I have some way to get docker-machine to create a machine using Java and then later to be able to use docker-machine to stop that machine.
As it turns out the example that I posted should work, the issue that I was having is that I was provisioning machines with a UUID name. That name contained dash (-) characters which apparently break VBoxManage. This might be because of some kind of path problem but I'm just speculating. When I changed my UUID to have dot (.) instead of dash it loaded and started the machine just fine.
I'm happy to remove this post if the moderators want, but will leave it up here in case people are looking for solutions to problems with docker-machine create naming issues.

Docker communication between two container with Java

I don't find my answer on any post.
I use a container with a project under PHP on a container which works fine. I want to link Java which is launch on another container.
I use the "java:8" image configure like this :
engine:
build: ./docker/engine/
volumes:
- ".:/home/docker:rw"
- "./docker/engine/php.ini:/usr/local/etc/php/conf.d/custom.ini:ro"
links:
- "db:db"
- "java:java"
working_dir: "/home/docker"
java:
image: java:8
tty: true
ports:
- "999:999"
On my docker PHP container (call "engine"), I have this environment variable.
JAVA_1_ENV_CA_CERTIFICATES_JAVA_VERSION=20140324
JAVA_1_ENV_JAVA_DEBIAN_VERSION=8u72-b15-1~bpo8+1
JAVA_1_ENV_JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
JAVA_1_ENV_JAVA_VERSION=8u72
JAVA_1_ENV_LANG=C.UTF-8
JAVA_1_NAME=/recetteetudiant_engine_1/java_1
JAVA_1_PORT=tcp://172.17.0.3:999
JAVA_1_PORT_999_TCP=tcp://172.17.0.3:999
JAVA_1_PORT_999_TCP_ADDR=172.17.0.3
JAVA_1_PORT_999_TCP_PORT=999
JAVA_1_PORT_999_TCP_PROTO=tcp
JAVA_ENV_CA_CERTIFICATES_JAVA_VERSION=20140324
JAVA_ENV_JAVA_DEBIAN_VERSION=8u72-b15-1~bpo8+1
JAVA_ENV_JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
JAVA_ENV_JAVA_VERSION=8u72
JAVA_ENV_LANG=C.UTF-8
JAVA_NAME=/recetteetudiant_engine_1/java
JAVA_PORT=tcp://172.17.0.3:999
JAVA_PORT_999_TCP=tcp://172.17.0.3:999
JAVA_PORT_999_TCP_ADDR=172.17.0.3
JAVA_PORT_999_TCP_PORT=999
JAVA_PORT_999_TCP_PROTO=tcp
RECETTEETUDIANT_JAVA_1_ENV_CA_CERTIFICATES_JAVA_VERSION=20140324
RECETTEETUDIANT_JAVA_1_ENV_JAVA_DEBIAN_VERSION=8u72-b15-1~bpo8+1
RECETTEETUDIANT_JAVA_1_ENV_JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
RECETTEETUDIANT_JAVA_1_ENV_JAVA_VERSION=8u72
RECETTEETUDIANT_JAVA_1_ENV_LANG=C.UTF-8
RECETTEETUDIANT_JAVA_1_NAME=/recetteetudiant_engine_1/recetteetudiant_java_1
RECETTEETUDIANT_JAVA_1_PORT=tcp://172.17.0.3:999
RECETTEETUDIANT_JAVA_1_PORT_999_TCP=tcp://172.17.0.3:999
RECETTEETUDIANT_JAVA_1_PORT_999_TCP_ADDR=172.17.0.3
RECETTEETUDIANT_JAVA_1_PORT_999_TCP_PORT=999
RECETTEETUDIANT_JAVA_1_PORT_999_TCP_PROTO=tcp
Ping command works fine. But how can I use java with that? I try to use that command
root#639144f7c95f:/home/docker# echo $JAVA_1_PORT$RECETTEETUDIANT_JAVA_1_ENV_JAVA_HOME
tcp://172.17.0.3:999/usr/lib/jvm/java-8-openjdk-amd64
root#639144f7c95f:/home/docker# /recetteetudiant_engine_1/java_1
bash: /recetteetudiant_engine_1/java_1: No such file or directory
root#639144f7c95f:/home/docker# $JAVA_1_PORT$RECETTEETUDIANT_JAVA_1_ENV_JAVA_HOME
bash: tcp://172.17.0.3:999/usr/lib/jvm/java-8-openjdk-amd64: No such file or directory
root#639144f7c95f:/home/docker#
Maybe I have to share a volume ? Can I use Java through TCP protocol?
You have 2 containers in your compose file. The one which seems to host a php application and one which has java installed.
From "inside" the containers, it behaves as if you had 2 different machines (they are not machines, but containers): one "machine" with a hostname called "engine" and one "machine" with a hostname called "java".
You somehow what to connect to the "machine" called "engine" and run java there. Java application is installed on the other "machine".
What you are trying to do does not seem to make sense.
You can't (or at the very least should not) use java over TCP - not in the way you want to, which seems to be to somehow invoke java executable which is basically on another machine (or docker container in this case). Maybe there is some way to achieve this with some remote call, but even if possible it would still be wrong. Simply add JRE to your php container. Or make your jar work like a WS.
Docker containers are not meant to be used in a way that container1 has java executable so call it from there, container2 has vi, container3 grep etc...
Some ways "interacting" between containers(with one common volume):
Orchestrate in host.
docker exec -t php command-prepare
docker exec -t java-app-jdk java -jar yuicompressor.jar bla-bla
docker exec -t php command-post
Create simple app who listen port and start command in JavaContainer (IMHO best way)
Create "cron" who look volume in JavaContainer, for example,
a) phpContainer put files to volume and put "indicator" file
b) javaContainer look "indicator" file, and start work. Post complete remove "indicator" file and put "work log" file.
c) phpContainer wait some time, and get "work log" file. Work depending on the result parse "work log" file.
UPD.
Also you can do something similar to docker.spotter https://github.com/discordianfish/docker-spotter.

Starting Mule for remote debugging without modifying wrapper.conf

I'm stuck on Mule version 3.4.0 due to requirements at work. I'm writing a service script to manage the service lifecycle of Mule and would really like to be able to have it hang and wait for a debugger to connect based on whether a certain option is present in the parameters.
I'm comfortable with Bash and implementing this, but I'm having an extremely hard time trying to get Mule to pass along the
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9989
to the underlying Java process, as it uses its own (stupid) wrapper to address Java.
I'm trying to modify the bin/mule script to have a mode called debug which will pass the above debugger options to the JVM when invoked with:
bin/mule debug
My current work can be found here on PasteBin, and here is the relevant part near line 511:
debug() {
echo "Debugging $APP_LONG_NAME..."
getpid
if [ "X$pid" = "X" ]
then
# The string passed to eval must handle spaces in paths correctly.
COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=$APP_NAME wrapper.pidfile=\"$PIDFILE\" $ANCHORPROP $LOCKPROP"
######################################################################
# Customized for Mule
######################################################################
echo "command line: $COMMAND_LINE"
echo "mule opts: $MULE_OPTS"
echo "JPDA_OPTS: $JPDA_OPTS"
eval $COMMAND_LINE $JPDA_OPTS $MULE_OPTS
######################################################################
else
echo "$APP_LONG_NAME is already running."
exit 1
fi
}
I cannot upgrade to a newer version of Mule. I need to find a way to modify this script to simply wait for a debugger when invoked with bin/mule debug. I've modified it enough to get into this debug function I've defined which is basically a copy of their own console function for starting in console mode. I can't seem to figure out how to get my debug opts passed to the JVM. Any ideas?
The parameter -debug, following documentation, was present in 3.4.x:
./mule -debug
Give it a try.

Not able to in initiating x11, java handling error

I have a Solaris-10 non global zone. I am using MobaXterm. I login on box with root and then "su - caddrd" and then "/usr/local/bin/sudo -u cadwebppc /cad/envs/qa-cm/cadwccDomain/ucm/cs/bin/UserAdmin". This is supposed to open a GUI console, but it is failing and I am not able to figure out. Can somebody help on this ?
It gives me error -
No X11 DISPLAY variable was set, but this program performed an operation which requires it
Update - I am refining this question more. I am able to run xclock via root, via caddrd and via cadwebppc also. But when I am using it with sudo, it is giving error. So it seems something like, having issue with passing variables.
Try to set DISPLAY variable. If you are on the main display this command should do:
export DISPLAY=:0.0
I found this link to be helpful:
http://www.snapdba.com/2013/02/ssh-x-11-forwarding-and-magic-cookies/
When switching to my oracle user (or in your case caddrd) the X11 forwarding information is lost. You can use xauth to copy it to the user's .Xauthority file
So, as root do:
echo xauth add xauth list ${DISPLAY#localhost}
copy this command, sudo to your user and execute this command there.

Categories

Resources