Skip to content

Instantly share code, notes, and snippets.

@jamescway
jamescway / Gen.scala
Last active October 12, 2015 16:50
fpinscala-testing
import org.scalatest.FunSpec
import Stream._
import State._s
// import parallelism._
import Par._
import Gen._
import Prop._
import java.util.concurrent.{Executors,ExecutorService}
@jamescway
jamescway / main.scala
Last active August 29, 2015 14:26
Zipkin kafka usage change main.scala
import com.twitter.zipkin.thriftscala.{Span => ThriftSpan}
import com.twitter.finagle.stats.StatsReceiver
import com.twitter.server.TwitterServer
import com.twitter.util.{Await, Future}
import com.twitter.zipkin.cassandra.CassieSpanStoreFactory
import com.twitter.zipkin.collector.{SpanReceiver, ZipkinQueuedCollectorFactory}
import com.twitter.zipkin.common._
import com.twitter.zipkin.receiver.kafka.KafkaSpanReceiverFactory
import com.twitter.zipkin.storage.WriteSpanStore
import com.twitter.zipkin.zookeeper.ZooKeeperClientFactory
# $bundle exec jruby hermann_test.rb
require 'hermann'
# require 'hermann/provider/java_simple_consumer'
require 'hermann/consumer'
require 'hermann_jars'
# zookeeper = "localhost:2181"
zookeeper = "localhost:2181"
deploy:
provider: rubygems
gemspec: zipkin-gems/zipkin-tracer/zipkin-tracer.gemspec
on:
branch: lookout
tags: true
api_key:
secure: NlAfnRn2v6aVQfVMWc/8+hkZ+fRvex7c4F6V0MNDu1In8KYkpE/HIqRarHM34PWDqxlizuRIB2RdikfAN8oNetfC4d+ip8oMkkxioD4pRFvR7MAs2D/hbMOqLgUJuPLtk+w4MpkqHUz+3Ov3FsBEPLrGAvDKZA+6nln6AriNkck=
Fix Leader election Problems
[Note] this method may work every time
[Note] this was initially caused by deleting the kafka hosts and reprovisioning
delete the topic using zkCli.sh
rmr /brokers/topics/test2
sudo service kafka restart (on all the broker hosts using rundeck)
change to a different topic in your producer
you might see the number of LeaderNotAvailableException go down, maybe its doing some kind of replication here
at this point the consumer should be able to get messages and if u produce more, it should have fewer exceptions or 0
From: /Users/jway/code/faraday-zipkin/lib/faraday-zipkin/trace_headers.rb @ line 53 Faraday::Zipkin::TraceHeaders#call:
48: trace_id = ::Trace.id
49: ::Trace.push(trace_id.next_id)
50: B3_HEADERS.each do |method, header|
51: Pry.config.input = STDIN
52: Pry.config.output = STDOUT
=> 53: binding.pry
54: env[:request_headers][header] = ::Trace.id.send(method).to_s
55: end
@jamescway
jamescway / statsdreceiver.scala
Created January 13, 2015 21:55
Finagle Statsd receiver
//https://groups.google.com/forum/#!topic/finaglers/0g2ySTVtZsg
import com.twitter.finagle.stats.{Counter, Gauge, Stat, StatsReceiver}
/**
* Created by mmlac on 8/13/14.
*/
class StatsDStatsReceiver extends StatsReceiver {
override val repr: AnyRef = this
/zipkin|master:bin/collector
[info] Loading project definition from /Users/jway/code/zipkin/project
[warn] Multiple resolvers having different access mechanism configured with same name 'local'. To avoid conflict, Remove duplicate project resolvers (`resolvers`) or rename publishing resolver (`publishTo`).
[info] Set current project to zipkin (in build file:/Users/jway/code/zipkin/)
[info] Set current project to zipkin-collector-service (in build file:/Users/jway/code/zipkin/)
[info] Writing build properties to: /Users/jway/code/zipkin/zipkin-collector-service/target/resource_managed/main/com/twitter/zipkin/build.properties
[error] I 1204 16:31:37.815 THREAD1 org.apache.zookeeper.Environment.logEnv: Client environment:user.dir=/Users/jway/code/zipkin
[error] I 1204 16:31:37.816 THREAD1 org.apache.zookeeper.ZooKeeper.<init>: Initiating client connection, connectString=localhost:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@19b27f92
[error] I 1204 16:31:42.918 THREAD43 org.apache.zookeeper.Clien
@jamescway
jamescway / gist:f7c8a9e7cb1ce4c8458b
Created December 4, 2014 16:23
kafkaReceiver put into main.scala
import com.twitter.zipkin.gen.{Span => ThriftSpan}
import com.twitter.finagle.stats.StatsReceiver
import com.twitter.server.TwitterServer
import com.twitter.util.{Await, Future}
import com.twitter.zipkin.cassandra.CassieSpanStoreFactory
import com.twitter.zipkin.collector.{SpanReceiver, ZipkinQueuedCollectorFactory}
import com.twitter.zipkin.common._
import com.twitter.zipkin.receiver.kafka.KafkaSpanReceiverFactory
import com.twitter.zipkin.storage.WriteSpanStore
import com.twitter.zipkin.zookeeper.ZooKeeperClientFactory
def get_interface(tdb_id, server)
Decom.log.debug "Finding eth0 interface"
eth0_interface = server['interfaces'].find{|interface| interface['name'] == 'eth0' }; Decom.log.debug "server eth0 interface: #{eth0_interface.inspect}"
eth0_interface = thingsdb["interfaces/#{eth0_interface['id']}"].get; Decom.log.debug "eth0 interface: #{eth0_interface.inspect}"
eth0_interface
end