Friday, February 24, 2017

angularjs - access value of ng-model in a controller

To access the value of ng-model in a controller, you have to have a dot in there.
With a format like object.property you'll be good to go.

In my case "add.device.storage" does not work. And  "addDevice.storage" is good.

In view(.html):

<input type="text" id="input-id-dd-password" ng-model="addDevice.password"
    placeholder="type here">

In controller(.js): access it with $scope.addDevice.password

Thursday, February 16, 2017

java cmd cheatsheet

1. List files in a jar package:
 $ jar tvf my.jar

2. Extract files out of a jar package:
 $ jar xvf my.jar

3. Package current directory with Manifest file:
 $ jar cvfm my.jar META-INF/MANIFEST.MF ./

 4. javap is like nm in *NIX

5. jps like ps in *NIX
    jps -lvm

6. Print flags of a JVM process
    jinfo -flags

7. jconsole, other than jps/jinfo commands you can use jconsole to monitor a JVM process. It provides lots of information you need to tune your process.

8. jvisualvm, similar as jconsole

9. jstack, print process stack information

Wednesday, February 15, 2017

Adding getter/setter for Java class members

"Source" -> "Generate Getters and Setters".

Wednesday, January 25, 2017

boost ptree

This is an awesome post on how to use ptree for json processing. http://zenol.fr/blog/boost-property-tree/en.html

Thursday, January 12, 2017

JSON in Java

Add to your Maven dependency
1
2
3
4
5
<dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.json</artifactId>
    <version>1.0.4</version>
</dependency>
Demo:
1
2
3
4
5
6
7
String json = "{\"id\":3}";
JsonReader reader = Json.createReader(new StringReader(json));
JsonObject rootObject = reader.readObject();
reader.close();

int devID = rootObject.getInt("id");
String sDevID = Integer.toString(devID);

Tuesday, December 6, 2016

Add a new Ambari Service

1. get java home
    from resource_management import Script
   
    config = Script.get_config()
    java_home = config['hostLevelParams']['java_home']

    # /usr/lib/jvm/java

2. default log directory
/var/lib/ambari-agent/data


Friday, December 2, 2016

Add ports mapping to the HDP 2.5 VMware Sandbox

HDP 2.5 Sandbox VM:
    ssh root@IP -p 22

HDP 2.5 Sandbox Container
    ssh root@IP -p 2222

Note: here the IP is the public IP address for VM. It's NOT the IP for Container.

1) login to the Sandbox VM

$ ssh root@IP -p 22

2) Disable sandbox.service

$ systemctl disable sandbox.service

3) Reboot the VM

$ init 6

4) Modify sandbox start script

$ vi /root/start_scripts/start_sandbox.sh

Go search "-p 2222:22 \"
Add a new line after that, like:
    -p 1234:1234 \
save and exit.

5) Delete existing sandbox container

$ docker rm sandbox

6) Enable sandbox.service

systemctl enable sandbox.service

7) Reboot the VM

$ init 6

8) Verify new ports

$ docker ps |grep 1234

You should see that 1234 is now in the list.

9) Bring up webapp listening at port 1234


10) Verify that you can access IP:1234 via browser from a 3rd machine.