Wednesday, March 17, 2021

Change version of maven module and sub-module

 After a release or during a simple hot fix, you might want to modify the version of your maven-based service 


This is the trick: 


mvn versions:set -DgenerateBackupPoms=false -DnewVersion=1.42.0.1-SNAPSHOT

Monday, December 14, 2020

Elastic - quick search syntax

 Search over several fields 


All the condition must match 

curl -XPOST my_index/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "accountId": "le79612186"
          }
        },
        {
          "match": {
            "docType": "transfer_conversation"
          }
        },
        {
          "exists": {
            "field": "eventTime"
          }
        }
      ]
    }
  }
}

Sunday, November 15, 2020

Sven interesting shell command -

hadoop fs -text /liveperson/data/remote/DC=VA/storage_Shared/data_Platform/dwh_le/event_type=SatisfactionEvent/year=2020/month=11/day=11/* | grep "\"conversationHandlerAccountId\":{\"string\"" | sed -E 's/.*\"accountId\":\{\"string\":\"([0-9]+)\"\}.*/\1/g' | sort --human-numeric-sort | uniq | wc -l hadoop fs -text /liveperson/data/remote/DC=VA/storage_Shared/data_Platform/dwh_le/event_type=SatisfactionEvent/year=2020/month=11/day=11/* | grep -v "\"conversationHandlerAccountId\":{\"string\"" | sed -E 's/.*\"accountId\":\{\"string\":\"([0-9]+)\"\}.*/\1/g' | sort --human-numeric-sort | uniq | wc -l Pay attention to this sed -E 's/.*\"accountId\":\{\"string\":\"([0-9]+)\"\}.*/\1/g' Which means to take the accountID value right after the "accountId":{"string":" {"header":{"schemaRevision":"5.0.0.1266","eventTimeStamp":1605078051486,"eventUniqueId":{"string":"7AkrXepoQD2zRajMk3LDnA"},"globalSessionId":null,"globalUserId":null,"accountId":{"string":"60270350"},"encrypted":"NONE","platform":"DEFAULT","component So, if I understand, it search for "accountId":{"string":"[0-9]+ regex and fetch the number [0-9]+ represented by this \1 token in the sed syntxt Pay attention to this sort --human-numeric-sort Pay attention to this uniq as well

Sunday, February 23, 2020

Spring Mockito and injection


I had a UnitTest to create.
I wanted to check a bean class , with some logical code.

This bean class had an internal Autowired internal bean, that I didn't care of , didn't want to check .

So how to setup a test around the original class without having to setup the internal Autowired class ...


The @InjectMocks means that this is the main class that we want to test, where we inject into it, if possible , the other Mock.
The @Mock  means that we want to wrap the class and to control it from outside , without taking care of its internal code.

Important:
do not forget the call
        MockitoAnnotations.initMocks(this);
which activate the injection



Here is the example code :


mport org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.util.ArrayList;
import java.util.List;

import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;

public class ConsumerPrivateMessageConversationMessageDataConverterTest {


    @InjectMocks    ConversationMessageDataConverter conversationMessageDataConverter = new ConversationMessageDataConverter();


    @Mock    UserACItemRetriever userACItemRetriever;

    @BeforeClass    public void setMockOutput() throws AccountConfigClientException {
        MockitoAnnotations.initMocks(this);
        when(userACItemRetriever.getItem(anyString(), anyLong())).thenReturn(null);
    }

    @Test    public void checkPrivateMessageFiltering() {
        conversationMessageDataConverter.convertToConversationHistoryMessageData(conversationDTO);

    }
}




The ConversationMessageDataConverter class uses  inside its code the UserACItemRetriever class 

@Componentpublic class ConversationMessageDataConverter {

    @Autowired    private UserACItemRetriever userACItemRetriever;


    public void convertToConversationHistoryMessageData( .... )  {
    }

}

Adjustement: 
17 Jan 2021 : I just paid attention that there's a difference between 
@Mock and @MockBean 
If you want your instance to be wrapped as a Mock but also considered 
and injected as a bean, the, you should use:
@MockBean

Here for more info 
https://stackoverflow.com/questions/42641853/spring-boot-integration-testing-with-mocked-services-components

Thursday, November 21, 2019

Elastic Search - recovery of shards

In order to understand the status of the Elastic Cluster shard recovery (how many shards and in what percentage of data are still to be consumed by the elastic node):



watch -n 1 -d "curl -sS localhost:9200/_cat/recovery | grep -v done | sort"


curl -sS localhost:2013/_cat/recovery | grep -v done | sort
chat_events_2018_10        0  1080986 replica index    svpr-els219 svpr-els222 n/a n/a 99  99.0%  9245443931 99.4%  99  9245443931  0       100.0% 0
chat_events_2018_10        12 880628  replica index    svpr-els219 svpr-els225 n/a n/a 118 80.5%  9507834833 50.9%  118 9507834833  0       100.0% 0
chat_events_2018_10        4  1080998 replica index    svpr-els217 svpr-els222 n/a n/a 120 98.3%  9212348531 84.1%  120 9212348531  0       0.0%   549128
chat_events_2018_10        6  48448   gateway translog avpr-els217 avpr-els217 n/a n/a 0   100.0% 0          100.0% 120 9111543410  314413  -1.0%  -1
chat_events_2018_10        7  37318   gateway translog svpr-els239 svpr-els239 n/a n/a 0   100.0% 0          100.0% 119 9355121451  215907  -1.0%  -1
chat_events_2018_11        15 246460  replica index    svpr-els221 svpr-els230 n/a n/a 94  92.6%  7473306012 59.9%  94  7473306012  0       0.0%   207497
chat_events_2018_12        17 561707  replica index    svpr-els217 svpr-els225 n/a n/a 78  83.3%  5985100320 0.1%   78  5985100320  0       100.0% 0
chat_events_2019_01        10 403900  replica index    svpr-els222 svpr-els230 n/a n/a 162 68.5%  5824180424 0.3%   162 5824180424  0       0.0%   166305
chat_events_2019_02        1  377381  replica index    svpr-els222 svpr-els228 n/a n/a 154 72.1%  5509742229 0.2%   154 5509742229  0       0.0%   122191
chat_events_2019_02        16 561676  replica index    svpr-els220 svpr-els245 n/a n/a 150 95.3%  4684545993 80.1%  150 4684545993  0       0.0%   122191
chat_events_2019_03        3  936237  replica index    svpr-els217 svpr-els242 n/a n/a 158 75.9%  5212773307 7.8%   158 5212773307  0       0.0%   1527414

Sunday, October 6, 2019

lpnova - create OpenStack VM

Clone (clone server similar to avor-wto134 - 2 instances)
lpnova --clone avor-wto134 -H avor-wto -Q 2 -D virginia -U fawzea

in case of failure (because of F5 for ex , assuming avor-wto109 and 122 was created but failed in the middle) 

lpnova --clone avor-wto134 -H avor-wto109 -H avor-wto122   -D virginia -U fawzea --load 

Tuesday, September 24, 2019

Puppet sandbox


In order to check your puppet script in a sandox, go to any linux server and create the following directory structure:



Create dir


/tmp/mypuppet/


Under this directory 


./modules./modules/test./modules/test/templates./modules/test/templates/test.erb./modules/test/manifests./modules/test/manifests/init.pp



Here's your manifest: 
./test.pp

puppet apply --modulepath /tmp/mypuppet/modules .  test.pp

In my example , this was the manifest:

test.pp :
node qtvr-wto134 {class { 'test::config': }
} 

the modules modules/test/manifests/init.pp :


class test::config ($routingRulesList = ['zzffline1', 'zzffline2', 'zzffline3'],) {
file { "/home/michael_puppet_sandbox/mypuppet/locations.include":ensure => present,content => template("test/test.erb"),}
}

 and the template modules/test/templates/test.erb :
<% @routingRulesList.each do |routingRule| -%><%=routingRule%><% end %>


and then click on

 puppet apply --modulepath /tmp/mypuppet/modules .  test.pp 


The command puppet apply --modulepath /tmp/mypuppet/modules . test.pp  will create the following output file :



puppet apply --modulepath /tmp/mypuppet/modules . test.pp
zzffline1zzffline2zzffline3

Thursday, February 7, 2019

Run specific Junit unit test on Maven

How to run specific test within Maven mvn 

  1. Click on the module Run... button
  2. Add your own argument : for ex, instead of clean deploy , write
     test  -Dtest=**PeriodicFlow*Test#simpleChatAndCheckChatExposureLatencyAndMCS  -DfailIfNoTests=false
    This argument stands for 
    For running the Java Test file PeriodicFlow (like PeriodicFlowAlphaTest , PeriodicFlowColoTest etc ) 
    and will run only this test method simpleChatAndCheckChatExposureLatencyAndMCS
  3. you can also run an entire file / package etc ...

Thursday, October 11, 2018

Working environment ... for mac / apple

Clipboard manager
https://clipy-app.com/

KeepPass
https://www.keepassx.org/downloads

CheatSheet
https://www.mediaatelier.com/CheatSheet/

BetterTouch (no free)
https://folivora.ai/downloads



brew cask install minikube

+ you'll need to install virtualbox:
brew cask install virtualbox

When starting the minikube use the bellow command
minikube start --kubernetes-version=v1.6.3 --cpus=4 --memory=4096 --disk-size=20g; eval $(minikube docker-env)

If you get the following error during the installation:Error: Unknown command: cask
​Run the following first, and then re-run the installation.
cd $(brew --repo); git fetch; git reset --hard origin/master; brew update​



Thursday, March 8, 2018

for loop example - for remote ssh

instead of mcollective:

for server in qtvr-els03  qtvr-els04  qtvr-els05  qtor-els601  qtor-els602  qtor-els603  qtvr-els005  qtvr-els0029 ; do ssh root@$server "hostname; /etc/init.d/elasticsearch status "; done


Or also
for server in `zoom --HF lpcluster=z2_elasticsearch_agent_manager_01 -f hostname`; do ssh $server 'echo $HOSTNAME'; done;



in another word:

for server in server1 server2 server3 ; do ssh root@$server "hostname; echo do something"; done


Very useful!

Tuesday, November 28, 2017

SSH Login without password

If you want to access a remote terminal without being required to type your password, you have to do the following:


ssh-keygen
You can accept all the default
This will create a file with a public key under your $HOME directory

$HOME/.ssh/id_rsa.pub
this look as following :
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDgDnpDHO5U/Ba8xKZezlm7OpwbV0WBvJXelshOO2LZJxZCI8h5QRlbjYws5Gy+oxuNftQHliXFFfHJlFtRk4xo27JkdeYmrI33qHjDSZ4fWx4RJA1HODBqcmscisMrv4D8ELdP0pFXkL8+GM8l2bxu8U1HS2yuC//33mxn7auo2GJUr1vOGzsLtp7qS/kdLqf2Vo4YG6MtNmEw8Y+tlbSe0zO0uRR7sTj9aq+YM+KtLU2xxzzffsiAMqlxXnZd6c/PmVsJ/1d1ypk3Xrx69R7OlTB5rWApqB/eK9Mc53uCqUhFrzkKWWNyoP3/jEwJGJTfpuhL4gYmJtKdAl3RuXl4EB

Then, in order to enable ssh to a remote host without being required to type a password, you just have to add this public key to the remote host :

Type: 
ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
like for ex 
ssh-copy-id -i ~/.ssh/id_rsa.pub root@qtvr-els003 

This will automatically append your public key into the remote file (but this is something you can do manually as well) 

[root@qtvr-els0003 ~]# cat ~/.ssh/authorized_keys
# HEADER: This file was autogenerated at Mon Oct 30 10:42:29 +0200 2017
# HEADER: by puppet.  While it can still be managed manually, it
# HEADER: is definitely not recommended.
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuTtqxO/t+gebf+INEaBQwUmfckztextfJTBA3BstQifX6aqtnelgf9Mqu3OtjFhg3ddgErz2ft1aF6x/rF8Q0kzq8OR8ohmZrIPW+ZjxbOc9uvW1sniChCJFCtua+Hmm84zlIHwwwM0nK1jzBazVJ/zQR4jtY3V9F/sIVGTxowgiSNlszveeWWs0EN6xc5Uh7vE4ZICoXMKEkNhb30k9WZ0H2sNALzAghgmjSUv7CK/fGZ1UHG0Kh6z7J9aensCOHEKS5carGBFjrtfCI/ArCxwwwwqMg/ukJ8fWd2ekVNwKrm+J0iCVBlZ9pA6wV2BkJF77ZBlfPlW6q5T7r8Q23kJ2M5w== root@tlvmanager.tlv.lpnet.com
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDgDnpDHO5U/Ba8xKZezlm7OpwbV0WBvJXelshOO2LZJxZCI8h5QRlbjYws5Gy+oxuNftQHliXFFfHJlFtRk4xo27JkdeYmrI33qHjDSZ4fWx4RJA1HODBqcmscisMrv4D8ELdP0pFXkL8+GM8l2bxu8U1HS2yuC//33mxn7auo2GJUr1vOGzsLtp7qS/kdLqf2Vo4YG6MtNmEw8Y+tlbSe0zO0uRR7sTj9aq+YM+KtLU2xxzzffsiAMqlxXnZd6c/PmVsJ/1d1ypk3Xrx69R7OlTB5rWApqB/eK9Mc53uCqUhFrzkKWWNyoP3/jEwJGJTfpuhL4gYmJtKdAl3RuXl4EB


For MAC OS User: 
I found this link for installing the ssh-copy-id command, which was missing from my laptop: 

https://stackoverflow.com/questions/25655450/how-do-you-install-ssh-copy-id-on-a-mac

Basically, download the code from here and make it accessible for all users: 

sudo curl https://raw.githubusercontent.com/beautifulcode/ssh-copy-id-for-OSX/master/ssh-copy-id.sh -o /usr/local/bin/ssh-copy-id sudo chmod +x /usr/local/bin/ssh-copy-id

Thursday, July 20, 2017

Socat - a Simple Tcp Proxy

In order to setup a simple TCP proxy, I've used the following :

yum install socat

socat TCP4-LISTEN:2003,fork TCP4:app.graphite.lpdomain.com:2003


This listen to port 2003 and send everything to the remote server app.graphite.lpdomain.com , to remote port 2003

I've done that in order to be able to send metric value to a remote graphite server that was not accessible from my server.
In order to send value to graphite , I've used the following :


echo Centralized.service.sandbox.test3   1234  `date +%s --date='30 minutes ago'` | nc -v my-proxy-server 2003


BTW, I was also suggested to use nc command, but it appears that this proxy tool is more primitive and doesn't support multiple connection apparently :

mkfifo backpipe
nc -k -l 2003    <backpipe | nc app.graphite.lpdomain.com 2003  1>backpipe 

Tuesday, November 8, 2016

tcpdump


In order to record the traffic, you can use tcpdump on linux


tcpdump -G 15 -W 1 -i any -nn  -w /tmp/slor-wto176.cap' -t 60


This will record for 15 sec , with rollover file of 1 only (taken from http://stackoverflow.com/questions/25731643/how-to-schedule-tcpdump-to-run-for-a-specfic-time-of-period) 

We listen to all network card (-i any) and output the file into a file.

Then, you can open the .cap file into WireShark 

For filter, you can use elasticsearch , for ex, or tcp.flags.reset ==1 or tcp.stream eq 28 or ip.dst_host == 10.32.134.203 etc ...


Here's some snapshot of wireshark usage: 


and when clicking on "Follow Stream" : 


Tuesday, July 14, 2015

how to fix the RPM stuck problem

how to fix the RPM stuck problem 
when running rpm -qa |grep something , then it gets stuck forever ...

It's problably due to the a huge number of RPM process ...

I was suggested to do the following: 
  • ps -ef|grep rpm |awk '{print $2}' | xargs kill -9
  • cd /var/lib/rpm/
  • ls
  • rm -f  __*


Other related links: 
http://unix.stackexchange.com/questions/166966/rpm-command-stuck-freeze-when-installing-rpm-file



rpm may be waiting for a lock to be freed.
First, run ps -ef | grep rpm to see if you have any RPM commands running. If you do, kill them using kill -9.
Next, delete any leftover locks rm -rf /var/lib/rpm/__db.0*

Tuesday, June 23, 2015

NFS and Shared Folder creation between servers


Install NFS on all your servers

yum install nfs-utils -y
service rpcbind start
service nfs start
service autofs restart

NFS server side

Then, in your "NFS server", create the shared folder (aka the folder to be shared)

mkdir /home/mich/SHARED_FOLDER
chmod a+w /home/mich/SHARED_FOLDER



Define the mount folder:

vi /etc/exports /home/mich/SHARED_FOLDER 192.168.1.0/24(rw,sync,no_root_squash,no_all_squash)
where the  192.168.1.0/24 is the IP range of the servers authorized to access this mounted folders

In order to make the export change effective, type:
exportfs -a

then, do not forget to start nfs
/etc/init.d/nfs start

or even to start it automatically in startup:
for ex:

cat /etc/rc.d/rc.local 

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
depmod -a
modprobe acpiphp
if [ -f /etc/rc.firstboot ]
then
        /etc/rc.firstboot | tee /var/log/firstboot.log
        cp /etc/rc.firstboot /usr/local/etc/
        rm /etc/rc.firstboot
        reboot
fi
touch /var/lock/subsys/local
/etc/init.d/nfs start

NFS CLIENT side


Then, on each client side, that want to use this mount :


mkdir /nfs/shared
mount -t nfs 192.168.20.11:/home/mich/SHARED_FOLDER/ /nfs/shared/


where 192.168.20.11 is the IP of the NFS server that you've configured in the previous paragraph

or do it automatically after startup:
vi /etc/fstab

add something like:
192.168.20.11:/home/mich/SHARED_FOLDER/ /nfs/shared/  nfs rsize=8192,wsize=8192,timeo=14,intr

if you want to test it without reboot your machine, do simply
mount -a

All those instructions were freely and quite fully inspired from this link:


Thursday, June 18, 2015

Cannot delete file in Windows - it says Already

Ever tried to delete / move / rename a file , but Windows refuses, saying the file is already used by another program ...


In order to find this f$@@%! other file that prevent you to handle this file, you can use ProcessExplorer




Press on Find / Find Handle or DLL
write the name of your file



Credits goes to
http://superuser.com/questions/399659/how-can-i-identify-what-application-is-using-a-given-file


Thursday, March 12, 2015

Network Connection

In order to understand the spec of the network card being used by your server:

lspci | grep -i net

Here, as example of the status on my job's cloud : 


ro -a -o . -h els2 -s shared -irc %/ lspci | grep -i net
[ virginia / svpr-els204 ] - 03:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01)        <<== which means 1 GB only
[ virginia / svpr-els204 ] - 03:00.1 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01)
[ virginia / svpr-els204 ] - 03:00.2 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01)
[ virginia / svpr-els204 ] - 03:00.3 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01)
[ virginia / svpr-els205 ] - 03:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01)
[ virginia / svpr-els205 ] - 03:00.1 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01)
[ virginia / svpr-els205 ] - 03:00.2 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01)
[ virginia / svpr-els205 ] - 03:00.3 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01)
[ virginia / svpr-els206 ] - 03:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01)
[ virginia / svpr-els206 ] - 03:00.1 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01)
[ virginia / svpr-els206 ] - 03:00.2 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01)
[ virginia / svpr-els206 ] - 03:00.3 Ethernet controller: Broadcom Corporation NetXtreme BCM5719 Gigabit Ethernet PCIe (rev 01)
[ virginia / svpr-els207 ] - 04:00.0 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)             <<== this means the card is 10Gb/sec 
[ virginia / svpr-els207 ] - 04:00.1 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els208 ] - 04:00.0 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els208 ] - 04:00.1 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els209 ] - 04:00.0 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els209 ] - 04:00.1 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els21 ] - 04:00.0 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els21 ] - 04:00.1 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els210 ] - 04:00.0 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els210 ] - 04:00.1 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els211 ] - 04:00.0 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els211 ] - 04:00.1 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els212 ] - 04:00.0 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els212 ] - 04:00.1 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els22 ] - 04:00.0 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)
[ virginia / svpr-els22 ] - 04:00.1 Ethernet controller: Emulex Corporation OneConnect 10Gb NIC (be3) (rev 01)


In addition, in order to understand the SWAP memory usage :

free -g 


 free -g             total       used       free     shared    buffers     cachedMem:           125        110         15          0          3         67-/+ buffers/cache:         39         86Swap:          128          0        128


==> Means that the OS has about 67+15 GB available

If you don't want to use swap (it may slow your server/application etc) 


  • swapoff -a   ==> do never use swap
  • sysctl vm.swappiness=0   ==> use swap only if you don't have any more choice
  • sysctl vm.swappiness=60   ==> use swap only if you reach more than 60% of the memory
  • swapon -a ==> enable usage of SWAP, according to the swappiness value 
  •  sysctl -a |grep swap  : to understand what is the % policy value.


Using top, you can have the following:

Mem:  132119828k total, 131341592k used,   778236k free,  3505520k buffers
Swap: 134365176k total,    88752k used, 134276424k free, 105451036k cached  <<== this is the FULL RAM available

More info regarding swap can be found: 
http://askubuntu.com/questions/103915/how-do-i-configure-swappiness


Tuesday, February 24, 2015

How to characterize stength of a server

In order to understand your server, what is its strenght, its OS version, how many cpu, here is a short list of commands that may help



free -m
             total       used       free     shared    buffers     cached
Mem:          3832       3605        226          0        375       1038
-/+ buffers/cache:       2192       1640
Swap:         4031        126       3905

In this case, we can see the server has about 4GB RAM .



top  (and then click on 1)

top - 18:26:24 up 169 days,  7:07,  3 users,  load average: 0.03, 0.08, 0.08
Tasks: 133 total,   1 running, 130 sleeping,   0 stopped,   2 zombie
Cpu0  :  2.9%us,  0.7%sy,  0.0%ni, 95.9%id,  0.5%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu1  :  1.4%us,  0.5%sy,  0.0%ni, 97.5%id,  0.6%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   3924684k total,  3658548k used,   266136k free,   380324k buffers
Swap:  4128760k total,   130752k used,  3998008k free,  1035372k cached

Here, we can see that we have 2 CPU (2 core) and still about 4 GB RAM


df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_root-lv_root
                       20G  5.1G   14G  27% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda1             146M   60M   79M  44% /boot
/dev/mapper/vg_root-lv_home
                      4.0G  137M  3.7G   4% /home
/dev/mapper/vg_root-lv_liveperson
                       28G  987M   26G   4% /liveperson
/dev/mapper/vg_root-lv_tmp
                      4.0G  143M  3.6G   4% /tmp

This command enables to understand the disk partition ... How many storage you have etc ,,,


cat /etc/issue
CentOS release 6.6 (Final)
Kernel \r on an \m

This last command shows you which OS you run on and what is its version.
Here, we use CentOS version 6.6 release.

Tuesday, October 7, 2014

Json very nice tool

Given by Greg

Very nice tool !

http://www.jsonschema2pojo.org/

Enable to visualize how will look the generated java POJO code by giving its json schema representation.

For ex:

Assuming the following  Json schema:

{
  "type":"object",
  "properties": {
    "foo": {
      "type": "string"
    },
    "bar": {
      "type": "integer"
    },
    "baz": {
      "type": "boolean"
    }
  }
}

You'll obtain the following JAVA POJO class:
-----------------------------------com.example.Example.java-----------------------------------

package com.example;

import java.util.HashMap;
import java.util.Map;
import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({
"foo",
"bar",
"baz"
})
public class Example {

@JsonProperty("foo")
private String foo;
@JsonProperty("bar")
private Integer bar;
@JsonProperty("baz")
private Boolean baz;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();

@JsonProperty("foo")
public String getFoo() {
return foo;
}

@JsonProperty("foo")
public void setFoo(String foo) {
this.foo = foo;
}

@JsonProperty("bar")
public Integer getBar() {
return bar;
}

@JsonProperty("bar")
public void setBar(Integer bar) {
this.bar = bar;
}

@JsonProperty("baz")
public Boolean getBaz() {
return baz;
}

@JsonProperty("baz")
public void setBaz(Boolean baz) {
this.baz = baz;
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}

@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}

}