The primary goal of this task is to assess proficiency in the following areas in Java.
- working with the JDK libraries
- multi-threading and concurrency
- memory safety
I hereby claim:
To claim this, I am signing this object:
List<ConsumerRecord<byte[], byte[]>> lastRecords = new ArrayList<>(); | |
try (KafkaConsumer<byte[], byte[]> consumer = new KafkaConsumer<>(consumerProps)) { | |
for (PartitionInfo info : consumer.partitionsFor(topic)) { | |
List<TopicPartition> list = new ArrayList<>(); | |
list.add(new TopicPartition(topic, info.partition())); | |
consumer.assign(list); | |
consumer.seekToEnd(list); | |
ConsumerRecord<byte[], byte[]> last = consumer.poll(10000).iterator().next(); | |
lastRecords.add(last); |
ByteBuffer seekKey = ByteBuffer.allocateDirect(4).putInt(4); | |
try (Cursor cursor = db.openCursor(tx)) { | |
if (cursor.get(seekKey, MDB_SET_KEY)) { | |
// regular users | |
ByteBuffer key = cursor.key(); | |
ByteBuffer val = cursor.val(); | |
do { | |
// advanced users | |
long keyAddress = cursor.keyAddress(); |
// Generated by JavaCPP version 1.2: DO NOT EDIT THIS FILE | |
#ifdef _WIN32 | |
#define _JAVASOFT_JNI_MD_H_ | |
#define JNIEXPORT __declspec(dllexport) | |
#define JNIIMPORT __declspec(dllimport) | |
#define JNICALL __stdcall |
import io.reactivesocket.*; | |
import io.reactivesocket.aeron.client.AeronClientDuplexConnection; | |
import io.reactivesocket.aeron.client.AeronClientDuplexConnectionFactory; | |
import io.reactivesocket.aeron.server.ReactiveSocketAeronServer; | |
import org.reactivestreams.Publisher; | |
import rx.Observable; | |
import rx.RxReactiveStreams; | |
import uk.co.real_logic.aeron.driver.MediaDriver; | |
import uk.co.real_logic.aeron.driver.ThreadingMode; | |
import uk.co.real_logic.agrona.concurrent.BackoffIdleStrategy; |
import io.netty.buffer.ByteBuf; | |
import io.netty.buffer.Unpooled; | |
import io.reactivex.netty.RxNetty; | |
import io.reactivex.netty.channel.ObservableConnection; | |
import io.reactivex.netty.server.RxServer; | |
public class RxNettyTest { | |
public static void main(String[] args) throws Exception { | |
RxServer<ByteBuf, ByteBuf> tcpServer = RxNetty.createTcpServer(1111, connection -> { |
import io.netty.buffer.ByteBuf; | |
import io.netty.buffer.Unpooled; | |
import io.reactivex.netty.RxNetty; | |
import io.reactivex.netty.channel.ObservableConnection; | |
import io.reactivex.netty.server.RxServer; | |
import java.util.Iterator; | |
import java.util.concurrent.atomic.AtomicInteger; | |
public class RxNettyTestWorking { |
import io.netty.buffer.ByteBuf; | |
import io.netty.buffer.Unpooled; | |
import io.reactivex.netty.RxNetty; | |
import io.reactivex.netty.channel.ObservableConnection; | |
import io.reactivex.netty.server.RxServer; | |
import rx.Observable; | |
public class RxNettyTest { | |
public static void main(String[] args) throws Exception { | |
RxServer<ByteBuf, ByteBuf> tcpServer = RxNetty.createTcpServer(1111, connection -> { |
@BenchmarkMode(Mode.AverageTime) | |
@OutputTimeUnit(TimeUnit.NANOSECONDS) | |
@State(Scope.Group) | |
@Measurement(iterations = 5) | |
@Warmup(iterations = 5) | |
@Fork(value = 1) | |
public class Mpsc { | |
static long NANO_DELAY = 10; | |
static int SIZE = 4096; | |
private static final Integer ONE = 777; |