This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait Result | |
class Success extends Result | |
class Failed extends Result | |
// For some types A, B, C, D, we have these async computations which may fail: | |
def f1(a: A): Future[Either[Failed, B]] = ??? | |
def f2(b: B): Future[Either[Failed, C]] = ??? | |
def f3(c: C): Future[Either[Failed, D]] = ??? | |
def f4(d: D): Future[Either[Failed, Result]] = ??? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestsExecutionRecorder { | |
private String namespace; | |
private Stopwatch stopwatch; | |
private long duration; | |
TestsExecutionRecorder(TestType testType) { | |
this.namespace = "test." + testType; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CampaignServiceImpl { | |
private static final double budgetMarginPercent = 0.03; | |
private final CampaignCostService campaignCostService; | |
/**** | |
* Read this and try to answer: when does a campaign have available funds? | |
* | |
* Hard to answer because method deals with different abstraction levels - | |
* mixing the important business logic with the insignificant low-level details |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AnodotReporterConfiguration anodotConf = | |
new DefaultAnodotReporterConfiguration("your-token", 60, "https://api.anodot.com/api/v1/metrics"); | |
Anodot3ReporterBuilder.builderFor(anodotConf) | |
.build(metricRegistry) | |
.start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Inspired by https://gist.github.com/abesto/cdcdd38263eacf1cbb51 | |
// Task creates a .dot file with all inter-module dependencies | |
// Supports any depth of nested modules | |
task moduleDependencyReport { | |
doLast { | |
def file = new File("project-dependencies.dot") | |
file.delete() | |
file << "digraph {\n" | |
file << "splines=ortho\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.SparkContext | |
import org.apache.spark.sql.expressions.{MutableAggregationBuffer, UserDefinedAggregateFunction} | |
import org.apache.spark.sql.types._ | |
import org.apache.spark.sql.{Column, Row, SQLContext} | |
/*** | |
* UDAF combining maps, overriding any duplicate key with "latest" value | |
* @param keyType DataType of Map key | |
* @param valueType DataType of Value key | |
* @param merge function to merge values of identical keys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.{File, IOException} | |
import java.net.InetAddress | |
import org.apache.spark.SparkContext | |
import org.apache.spark.rdd.RDD | |
import org.slf4j.{Logger, LoggerFactory} | |
import scala.util.{Failure, Try} | |
object LocalDiskHealthCheck { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.SimpleDateFormat | |
import java.util.Date | |
import org.json4s._ | |
import org.json4s.jackson.JsonMethods.parse | |
import scala.io.Source.fromURL | |
object SparkAppStats { | |
val url = "http://<host>:4040/api/v1/applications/<app-name>/jobs" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.yammer.metrics.Metrics | |
import com.yammer.metrics.core.Gauge | |
import org.apache.spark.SparkContext | |
/** | |
* Created by tzachz on 10/21/15 | |
*/ | |
object SparkContextInstrumentor { | |
def instrument(context: SparkContext): SparkContext = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.kenshoo.kripke.core | |
import com.yammer.metrics.Metrics | |
import com.yammer.metrics.core.{MetricName, Counter} | |
import org.apache.spark.Accumulator | |
import org.apache.spark.rdd.RDD | |
import scala.reflect.ClassTag | |
object CounterBackedAccumulatorUtil { |