Author name: greg

Kryo (missing no-arg constructor): java.nio.HeapByteBuffer

While serializing ByteBuffer using Kryo we will run into the following issue. Class cannot be created (missing no-arg constructor): java.nio.HeapByteBuffer To fix this we can create a custom serializer that will take a ByteBuffer and serialize it to and from Kryo. Serializer is rather simple all we need is two pieces of data, length of …

Kryo (missing no-arg constructor): java.nio.HeapByteBuffer Read More »

EventEmitter

Our EventEmitter in PhantomSQL is based on NodeJS version so they should be compatible. Here are couple examples on how to use the emitter. Basic usage of registering and listening to an event. "use strict";   const {EventEmitter} = require(’events’);   // Dump all the args em.on(’hello-event’, (…arg)=> {console.info("Hello event handler : " + arg)}); …

EventEmitter Read More »

Creating Javascript accessible object from C++ / CEF

Example with Chromium Embedded Framework (CEF) on how to create an object in C++ and make it accessible via Javascript. console.inof(api) Object {ready: true, version: "psql.0.0.1", info: Object, getVersion: function}console.inof(api) Object {ready: true, version: "psql.0.0.1", info: Object, getVersion: function} void ExtractEngineApp::OnContextCreated( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) {   auto info = CefV8Value::CreateObject(NULL, NULL); info->SetValue("major", …

Creating Javascript accessible object from C++ / CEF Read More »

Data retrieval service with exponential backoff

Here we will create Data retrieval service with exponential backoff that we covered in the previous post. Implementation   package com.rms.blueprint.data;   import java.util.Date; import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.function.ObjLongConsumer; import java.util.function.Supplier;   import org.slf4j.Logger; import org.slf4j.LoggerFactory;   public class DataRetrievalWithBackoff implements Runnable { public final Logger LOGGER = LoggerFactory.getLogger(DataRetrievalWithBackoff.class);   private final …

Data retrieval service with exponential backoff Read More »

Exponential backoff

In a variety of computer networks, binary exponential backoff or truncated binary exponential backoff refers to an algorithm used to space out repeated retransmissions of the same block of data, often as part of network congestion avoidance. Wikipedia Exponential backoff Here is an implementation in Java /** * Calculate Exponential backoff * * @param attempt …

Exponential backoff Read More »

Run MD5 check sum against all files in a directory

Couple snippets that allow us to run checksum and get unique md5 checksums. This is two step process. First, we obtain our md5 checksum for all files find -type f -exec md5sum "{}" + > /opt/checklist.chkfind -type f -exec md5sum "{}" + > /opt/checklist.chk This produces file with following contents 71cc452a8ac5a27c32a83e6a0909e7ae ./PID_190_7344_0_47710322.tif6712032974632727465.tiff 71cc452a8ac5a27c32a83e6a0909e7ae ./PID_190_7344_0_47710322.tif174464329785828524.tiff 71cc452a8ac5a27c32a83e6a0909e7ae …

Run MD5 check sum against all files in a directory Read More »