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
| /* | |
| Code for | |
| case class Trade(symbol: String, exchange: String, qty: Int, price: Double) | |
| */ | |
| public class Trade implements Product, Serializable | |
| { | |
| private final String symbol; | |
| public double price(){ | |
| return this.price; |
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
| /* | |
| Code for (String,String,Int,Double) | |
| */ | |
| public class Tuple4<T1, T2, T3, T4> implements Product4<T1, T2, T3, T4>, Serializable | |
| { | |
| private final T1 _1; | |
| public T1 _1(){return (T1)this._1;} | |
| public T2 _2(){ | |
| return (T2)this._2; |
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
| <configuration> | |
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
| <!-- encoders are assigned the type | |
| ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | |
| <encoder> | |
| <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | |
| </encoder> | |
| </appender> |
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
| class MetricsLogbackAppender extends UnsynchronizedAppenderBase[ILoggingEvent] { | |
| override def append(e: ILoggingEvent) = { | |
| //Send this message to elastic search or REST end point | |
| messageCount.compute(Thread.currentThread().getName, mergeValue) | |
| System.out.println(messageCount + " " + e) | |
| } | |
| val messageCount = new ConcurrentHashMap[String, AtomicInteger]() | |
| val mergeValue = new BiFunction[String, AtomicInteger, AtomicInteger] { |
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 newSparkSession(appName: String, master: String) = { | |
| val sparkConf = new SparkConf().setAppName(appName).setMaster(master) | |
| val sparkSession = SparkSession.builder() | |
| .appName(appName) | |
| .config(sparkConf) | |
| .getOrCreate() | |
| sparkSession | |
| } |
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
| 0x00000000031fa22f: and esi,1ff8h | |
| 0x00000000031fa235: cmp esi,0h | |
| 0x00000000031fa238: je 31fa256h ;*getstatic unsafe | |
| ; - java.util.concurrent.atomic.AtomicInteger::incrementAndGet@0 (line 186) | |
| 0x00000000031fa23e: mov eax,1h | |
| 0x00000000031fa243: lock xadd dword ptr [rdx+0ch],eax | |
| 0x00000000031fa248: inc eax | |
| 0x00000000031fa24a: add rsp,40h |
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
| AtomicInteger i = new AtomicInteger(); | |
| int total = 0; | |
| for(int x=0;x<300;x++) { | |
| total = i.incrementAndGet(); | |
| } | |
| System.out.println("Total Value - " + total); |
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 final int getAndAddInt(Object var1, long var2, int var4) { | |
| int var5; | |
| do { | |
| var5 = this.getIntVolatile(var1, var2); | |
| } while(!this.compareAndSwapInt(var1, var2, var5, var5 + var4)); | |
| return var5; | |
| } |
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 LazyFutureTask<V> implements Lazy<V> { | |
| private final FutureTask<V> futureTask; | |
| public LazyFutureTask(Callable<V> codeBlock) { | |
| this.futureTask = new FutureTask<>(codeBlock); | |
| } | |
| @Override | |
| public V get() { |
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 DoubleLock<V> implements Lazy<V> { | |
| private Callable<V> codeBlock; | |
| private V value; | |
| private volatile boolean loaded; | |
| public DoubleLock(Callable<V> codeBlock) { | |
| this.codeBlock = codeBlock; | |
| } |