Skip to content

Instantly share code, notes, and snippets.

View khaosans's full-sized avatar
:octocat:

SourC khaosans

:octocat:
View GitHub Profile
#!/bin/sh
USER_ARGS="-Dsomething=$1"
COMPILATION_CLASSPATH=`find -L ./target -maxdepth 1 -name "*.jar" -type f -exec printf :{} ';'`
JAVA_OPTS="-server -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms512M -Xmx2048M -XX:+HeapDumpOnOutOfMemoryError -XX:+AggressiveOpts -XX:+OptimizeStringConcat -XX:+UseFastAccessorMethods -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv6Addresses=false ${JAVA_OPTS}"
java $JAVA_OPTS $USER_ARGS -cp $COMPILATION_CLASSPATH io.gatling.app.Gatling -s your.simulation.FullClassName
import xml.etree.ElementTree as ET
def main():
configs = {'in-memory-format': 'BINARY',
'backup-count': '1',
'eviction-policy': 'LRU',
'eviction-percentage': '25',
'min-eviction-check-millis': '100',
'merge-policy': 'com.hazelcast.map.merge.PutIfAbsentMapMergePolicy'}
import hazelcast, logging, sys
import signal
def log_cache_info(cache, client):
cache = client.get_map(cache).blocking()
logging.info(
"CacheName: " + cache.name + " CacheSize: " + str(cache.size()) + " KlusterSize: " + str(client.cluster.size())
)
package com.jamasoftware.search.util.analyzer;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
jamasearch.enabled=true  
jamasearch.url=http://localhost:7500
envers.enabled=true
jamasearch.multithreadindex.chunksize=2000
jamasearch.multithreadindex.enabled=true
jamasearch.multithreadindex.poolsize=10
jamasearch.indexRefactorEnabled=true
jamasearch.indexRefactorCompareEnabled=false
@khaosans
khaosans / gist:280950dcdfd8c6c735cc
Created February 19, 2016 20:59
change this to a stream
private void compareDocs(Map<String, Object> responseMap, List<IndexField> listOfIndexFields, VerificationResponse verificationFailureResponse) {
for (int i = 0; i < listOfIndexFields.size(); ++i) {
@SuppressWarnings("unchecked") //Indexed are always object lists
ArrayList<Object> value = (ArrayList<Object>) responseMap.get(listOfIndexFields.get(i).getFieldName());
if (!listOfIndexFields.get(i).getFieldValues()[0].equals(value.get(0))) {
MisMatchFields misMatchFields = new MisMatchFields(value.get(i).toString(), listOfIndexFields.get(i).getFieldValues()[0]);
misMatchFields.setField(listOfIndexFields.get(i).getFieldName());
verificationFailureResponse.addToListOfMisMatchedFields(misMatchFields);
}
}
public void indexItemsForOpenTenants() {
Integer numberOfTries = 0;
List<String> itemsToIndex = TenantManager.getTenants().stream().filter(isOpenTenant).collect(Collectors.toList());
try {
while (!itemsToIndex.isEmpty()) {
if (abort.get() || numberOfTries >= counterThreshold) { // break if abort is true or counter is more than 10 hours
logger.warn(String.format("Aborting indexAllTenants: abort: %s, counter: %s", abort.get(), numberOfTries));
break;
package com.concretepage.util.concurrent;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public class CompletableFutureOneExample {
public static void main(String[] args) throws InterruptedException {
List<Integer> list = Arrays.asList(10,20,30,40);
list.stream().map(data->CompletableFuture.supplyAsync(()->getNumber(data))).
map(compFuture->compFuture.thenApply(n->n*n)).map(t->t.join())
.forEach(s->System.out.println(s));
DocumentServiceImpl.java
DocumentServiceImpl.java