Tuesday, 22 March 2016

Kafka Basics Commands

Instructions:

#install zookeper
sudo apt-get install zookeeperd

#check listening port zookeeper
sudo netstat -nlpt | grep ':2181'

telnet 2181

#download kafka specific version
wget http://www.us.apache.org/dist/kafka/0.8.2.2/kafka_2.9.2-0.8.2.2.tgz

#untar for setup
tar xvzf kafka_2.9.2-0.8.2.2.tgz --strip 1

#set kafka bin path in ~/.bashrc

#Start kafka server
nohup /home/kapil/kafka-2.8.0/bin/kafka-server-start.sh /home/kapil/kafka-2.8.0/config/server.properties > /home/kapil/kafka-2.8.0/kafka.log 2>&1 &

netstat -nlpt

#stop zookeper service
sudo service zookeeper stop

#check location for zookeper property
ls /home/kapil/kafka-2.8.0/config

#start zookeeper
/home/kapil/kafka-2.8.0/bin/zookeeper-server-start.sh /home/kapil/kafka-2.8.0/config/zookeeper.properties

#producer
echo "Hello, Kafka kapil here" | /home/kapil/kafka-2.8.0/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic MyTopic > /dev/null

#Consumer
/home/kapil/kafka-2.8.0/bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic MyTopic --from-beginning

#topic
/home/kapil/kafka-2.8.0/bin/kafka-topics.sh --list --zookeeper localhost:2181

Tuesday, 8 March 2016

FILTERS IN HBASE

HBASE FILTER




FILTER TYPE
 DESCRIPTION
scan 'emp',{FILTER ="KeyOnlyFilter()"}
This filter does not take any arguments. It returns only the key component of each key-value.
scan 'emp',{FILTER ="FirstKeyOnlyFilter()"}
This filter doesn't take any arguments. It returns only the first key-value from each row.
scan 'emp',{FILTER ="(PrefixFilter ('1'))"}
This filter takes one argument  a prefix of a row key. It returns only those key-values present in a row that starts with the specified row prefix
scan 'emp',{FILTER ="(PrefixFilter ('1')) AND ColumnPrefixFilter('name')"}
This filter takes one argument  a column prefix. It returns only those key-values present in a column that starts with the specified column prefix. The column prefix must be of the form qualifier
scan 'emp',{FILTER ="MultipleColumnPrefixFilter('name','salary')"}
This filter takes a list of column prefixes. It returns key-values that are present in a column that starts with any of the specified column prefixes. Each of the column prefixes must be of the form qualifier
scan 'emp',{FILTER ="ColumnCountGetFilter(1)"}
This filter takes one argument  a limit. It returns the first limit number of columns in the table.
scan 'emp',{FILTER ="PageFilter(1)"}    
This filter takes one argument  a page size. It returns page size number of rows from the table.
scan 'emp',{FILTER ="InclusiveStopFilter('1')"}
This filter takes one argument  a row key on which to stop scanning. It returns all key-values present in rows up to and including the specified row.
scan 'emp',{FILTER ="QualifierFilter(=,'binary:name')"} 
This filter takes a compare operator and a comparator. It compares each qualifier name with the comparator using the compare operator and if the comparison returns true, it returns all the key-values in that column.
scan 'emp',{FILTER ="MultipleColumnPrefixFilter('name') AND (ValueFilter(=,'binary:kapil'))" }
This filter takes a compare operator and a comparator. It compares each value with the comparator using the compare operator and if the comparison returns true, it returns that key-value.