Skip to content

Instantly share code, notes, and snippets.

View Kurukshetran's full-sized avatar
🎯
Focusing

Kurukshetran Kurukshetran

🎯
Focusing
View GitHub Profile
@Kurukshetran
Kurukshetran / apache-balancer.sh
Created June 25, 2020 07:11 — forked from SeonghoonKim/apache-balancer.sh
Apache HTTPD balancer-manager control script
#! /bin/sh
# Set up a default search path
PATH="/usr/bin:/bin"
CURL=`which curl`
if [ -z "$CURL" ]; then
echo "curl not found"
exit 1
fi
@Kurukshetran
Kurukshetran / AMQMOnitorConf.py
Created January 3, 2020 06:53 — forked from Abhinav2510/AMQMOnitorConf.py
AMQ Monitoring and Email Alerts script
#Replace localhost with your servername
#Change username and password accordingly
#Alert can be applied on JVM Heap and Queue parameters
#Alert format is
# param=Name of parameter on whose value you want to put alert
# thresholdVal= Value againsts which current value of param will be evaluated as per condition
# condition= denotes how to compare thresholdVal and current value of parameter.
# Possible values are as below:
# lt - Alert will be raised if current value is less than thresholdVal
# gt - Alert will be raised if current value is greater than thresholdVal
@Kurukshetran
Kurukshetran / Google Script Cache-Busting IMPORTHTML.md
Created October 22, 2019 15:22 — forked from willinspire/Google Script Cache-Busting IMPORTHTML.md
It is not easy to refresh the IMPORTHTML functions in Google Sheets due to cashe limitations. The resulting limitations are old data instead of new data being pulled into the Sheet upon running a Script to reload the IMPORTHTML function. This Google Script is a "Cache-Busting" function which circumvents this problem.
// Set your variables below
SHEET_NAME="MC-Import-Data"
URL="https://coinmarketcap.com/currencies/views/all/"

// Create a trigger to refresh every 5 minutes
function myFunctionA() {
  ScriptApp.newTrigger("getData")
  .timeBased()
 .everyMinutes(5)

Motivation

Integrate JMH (Java Microbenchmarking Harness) with Spring (Boot) and make developing and running benchmarks as easy and convinent as writing tests.

Idea

Wrap the necessary JMH boilerplate code within JUnit to benefit from all the existing test infrastructure Spring (Boot) provides. It should be as easy and convinent to write benchmarks as it is to write tests.

TL;DR;

@Kurukshetran
Kurukshetran / HttpClientConfiguration.java
Created July 31, 2019 06:46 — forked from mikeapr4/HttpClientConfiguration.java
Java Spring Configuration to provide the Apache HttpClient as per recommendations from http://www.baeldung.com/httpclient-connection-management
import org.apache.http.HeaderElement;
import org.apache.http.HeaderElementIterator;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
@Kurukshetran
Kurukshetran / FileLockSimulator.java
Created July 19, 2019 11:05 — forked from stefanrufer/FileLockSimulator.java
FileLockSimulator: a small application for simulate the behavior of FileAppender in prudent mode
/**
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 1999-2011, QOS.ch. All rights reserved.
*
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
*
* or (per the licensee's choosing)
*

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

@Kurukshetran
Kurukshetran / gist:812736354f087e386b36112fe7b517a6
Created July 15, 2019 06:26 — forked from ravin-singh/gist:8654b654163c508cdb227a621fe078f0
Micrometer metrics exporter for apache http connection pool
1. Create a scheduler to add new routes
@Scheduled(fixedRate = 300000)
public void updateHttpRoutes() {
Set<HttpRoute> routes = poolingHttpClientConnectionManager.getRoutes();
for (HttpRoute route : routes) {
httpMetricsTracker.add(route, poolingHttpClientConnectionManager);
}
}
@Kurukshetran
Kurukshetran / ClientHttpPoolConfiguration.java
Created July 11, 2019 06:25 — forked from soverby/ClientHttpPoolConfiguration.java
RestTemplate backed by Apache HttpClient Connection Pool. Addresses RestTemplate HttpConnection exhaustion. Note this implementation is not route tunable and should be expanded when tuning by route is required. Example error: I/O error on POST request for "https://someendpoint": Timeout waiting for connection from pool; nested exception is org.a…
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ClientHttpPoolConfiguration {
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ApacheLogParser {