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
| { | |
| "request": { | |
| "method": "GET", | |
| "url": "/videos" | |
| }, | |
| "response": { | |
| "status": 200, | |
| "bodyFileName": "videos.json", | |
| "fixedDelayMilliseconds": 2000 | |
| } |
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
| stubFor(get(urlEqualTo("/videos")).willReturn( | |
| aResponse() | |
| .withStatus(200) | |
| .withBodyFile("path/to/videos.json") | |
| .withFixedDelay(2000))); |
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
| { | |
| "request": { | |
| "method": "GET", | |
| "url": "/videos" | |
| }, | |
| "response": { | |
| "status": 200, | |
| "bodyFileName": "videos.json" | |
| } | |
| } |
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
| stubFor(get(urlEqualTo("/videos")) | |
| .willReturn(aResponse() | |
| .withStatus(200) | |
| .withBodyFile("path/to/videos.json"))); |
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
| def main(args: Array[String]) { | |
| // Prepare your environment | |
| val ssc = new StreamingContext(conf, Seconds(batchDurationInSec)) | |
| // Do your processing | |
| sys.ShutdownHookThread { | |
| log.info("Gracefully stopping Spark Streaming Application") |
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 Main { | |
| public static void main(String[] args) throws ExecutionException, InterruptedException { | |
| for (int i = 0; i < 20; i++) { | |
| String s1 = new CircuitBreakerCommand("World"+i).execute(); | |
| System.out.println(s1); | |
| } | |
| Hystrix.reset(); |
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 CircuitBreakerCommand extends HystrixCommand<String>{ | |
| private final String message; | |
| public CircuitBreakerCommand(String message) { | |
| super(HystrixCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("MyGroup")) | |
| .andCommandPropertiesDefaults( | |
| HystrixCommandProperties.Setter() | |
| .withCircuitBreakerEnabled(true) | |
| .withCircuitBreakerRequestVolumeThreshold(5) |
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
| aggregatedRDD.saveToCassandra("keySpaceName", "columnFamilyName", SomeColumns("word", "count")) |
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
| ... | |
| aggregatedRDD.foreach(element => store(element)) | |
| ... | |
| def store(element: YourModel): Unit = { | |
| // 1. build your Cassandra statement | |
| // 2. execute the statement | |
| } |
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
| ... | |
| val casoutputCF = aggregatedRDD.map { | |
| case (productId, saleCount) => { | |
| val outColFamKey = Map("prod_id" -> ByteBufferUtil.bytes(productId)) | |
| val outKey: java.util.Map[String, ByteBuffer] = outColFamKey | |
| var outColFamVal = new ListBuffer[ByteBuffer] | |
| outColFamVal += ByteBufferUtil.bytes(saleCount) | |
| val outVal: java.util.List[ByteBuffer] = outColFamVal | |
| (outKey, outVal) |
NewerOlder