Skip to content

Instantly share code, notes, and snippets.

@jacoelho
jacoelho / create.rb
Created July 12, 2016 18:13
Example topic recipe
example_topic "example" do
partitions 1
replication 1
end
@jacoelho
jacoelho / matchers.rb
Created July 12, 2016 17:59
Simple chefspec matcher
if defined?(ChefSpec)
def create_example_topic(resource_name)
ChefSpec::Matchers::ResourceMatcher.new(:example_topic, :create, resource_name)
end
end
@jacoelho
jacoelho / matchers.rb
Created July 12, 2016 17:52
custom resource matcher
if defined?(ChefSpec)
[:create, :update].each do |action|
self.class.send(:define_method, "#{action}_example_topic") do |resource|
ChefSpec::Matchers::ResourceMatcher.new(:example_topic, action, resource)
end
end
end
{
"version":1,
"partitions":[
{
"topic":"foo",
"partition":0,
"replicas":[
5,
6,
7
@jacoelho
jacoelho / reassign-partitions.sh
Last active July 11, 2016 14:00
kafka increase replication factor
bin/kafka-reassign-partitions.sh \
--zookeeper $ZK \
--reassignment-json-file increase-replication-factor.json \
--execute
@jacoelho
jacoelho / alter_topic.sh
Created July 11, 2016 13:33
kafka change partition number
bin/kafka-topics.sh \
--zookeeper $ZK \
--alter \
--topic <name> \
--partitions <partitions>
@jacoelho
jacoelho / create_topic.sh
Created July 11, 2016 13:29
kafka - create topic
bin/kafka-topics.sh
--zookeeper $ZK
--create
--topic <name>
--replication-factor <value>
--partitions <value>
@jacoelho
jacoelho / describe.sh
Created July 11, 2016 13:23
describe kafka topic
bin/kafka-topics.sh \
--zookeeper $ZK \
--describe \
--topic <name>
@jacoelho
jacoelho / topic.rb
Last active July 12, 2016 17:43
topic first step
property :topic, String, name_property: true
property :partitions, Fixnum, default: 3
property :replicas, Fixnum, default: 3
property :zookeeper, String, default: "localhost:2181"
property :directory, String, default: "/kafka"
action :create do
cmd = %W(
#{directory}/bin/kafka-topics.sh
--zookeeper #{zookeeper}
@jacoelho
jacoelho / scala.yml
Last active July 3, 2016 21:17
install scala ansible 2.1
- hosts: localhost
become: yes
connection: local
tasks:
- apt_key:
keyserver: keyserver.ubuntu.com
id: 642AC823
- apt_repository: