Skip to content

Instantly share code, notes, and snippets.

View itaifrenkel's full-sized avatar

Itai Friendinger itaifrenkel

  • Forter
  • Tel Aviv
View GitHub Profile
UpstreamLatency = (CurrentTime - RequestReceivedTimestamp)
DownstreamLatency = Approximate time needed to return a response to the client after this I/O operation completes.
Timeout = Global Timeout - (UpstreamLatency + DownstreamLatency)
if (Timeout > MaximumTimeout) Timeout = MaximumTimeout
if (Timeout < MinimumTimeout) Timeout = MinimumTimeout
@itaifrenkel
itaifrenkel / mochariemann.js
Last active August 29, 2015 14:17
Integrating mocha tests with riemann
var failedTests = [];
new Mocha()
.ui("bdd")
.reporter("tap")
.addFile(__dirname + '/' + testSuiteName + '.js')
.run()
.on('fail', function (test, err) {
failedTests.push(test);
})
.on('end', function () {
@itaifrenkel
itaifrenkel / floating_ip_recipe.groovy
Last active December 31, 2015 12:18
Cloudify cloud driver access from recipe
// The following recipe snippet shows custom commands that forward the requests to the network cloud driver
// See also:
// https://github.com/CloudifySource/Cloudify-iTests/blob/master/src/main/resources/apps/USM/usm/networks/openstack/floatingips/floatingips-service.groovy
customCommands ([
"getMachineIp" : { return context.getPrivateAddress() },
"getPublicAddress" : { return context.getPublicAddress() },
"getFloatingIp" : { return context.attributes.thisInstance["floatingIp"] },
"getApplicationNetworkIp" : { return System.getenv()['CLOUDIFY_APPLICATION_NETWORK_IP'] },
"assignFloatingIp" : {
// Calculates the sum of all instances metrics and divides by the number of instances (average)
instancesStatistics Statistics.average
// Selects the instance metric with the greatest value (maximum)
instancesStatistics Statistics.maximum
// Selects the instance metric with the smallest value (minimum)
instancesStatistics Statistics.minimum
// Selects the instance metric that is greater than 10% of the other metrics and
@itaifrenkel
itaifrenkel / DefaultEventHandlerMonitorAspect.java
Created April 20, 2013 21:01
Hack to monitor Kafka 0.8 producers
import kafka.producer.KeyedMessage;
import kafka.producer.async.DefaultEventHandler;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import scala.collection.JavaConversions;
import scala.collection.Seq;
@itaifrenkel
itaifrenkel / executor1_1355983011.json
Created December 20, 2012 01:19
servicegrid2 media types for restful task API
{
"timestamp" : "1355983011",
"ipaddress" : "10.0.0.1",
"tasks" : [ "http://broker/tasks/task1.json" ],
"executor" : "cloud-executor"
}
@itaifrenkel
itaifrenkel / TweetArchiveFilter.java
Created November 19, 2012 14:08
Archiving processed tweets to Cassandra
public class TweetArchiveFilter implements EventTemplateProvider {
public SQLQuery<SpaceDocument> getTemplate() {
return new SQLQuery<SpaceDocument>("Tweet", "Processed = ?", true);
}
}
@itaifrenkel
itaifrenkel / TweetParser.java
Created November 19, 2012 14:05
Tokenizing unprocessed tweets in-memory
public class TweetParser {
SQLQuery<SpaceDocument> getTemplate() {
return new SQLQuery<SpaceDocument>("Tweet", "Processed = ?", false);
}
public SpaceDocument eventListener(SpaceDocument tweet) {
Long id = (Long) tweet.getProperty("Id");
String text = tweet.getProperty("Text");
@itaifrenkel
itaifrenkel / in-memory-archiving-to-disk.txt
Created November 19, 2012 14:05
Real time processing in memory and archiving to disk
+-------------+ +-------------+
| In-memory | | Disk |
| (XAP) | | (Cassandra) |
| ---- archiver ---> |
| Realtime | | Queries |
| Processing | | |
+-------------+ +-------------+
class A {
}