Skip to content

Instantly share code, notes, and snippets.

View khaosans's full-sized avatar
:dependabot:

SourC khaosans

:dependabot:
  • Chainable
  • Portland, OR
  • 07:57 (UTC -12:00)
View GitHub Profile
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;
@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);
}
}
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
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
*
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())
)
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'}
#!/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
package com.jamasoftware.contour.report.service.impl.helper;
import com.jamasoftware.contour.api.exception.ContourRuntimeException;
import com.jamasoftware.contour.view.birt.BirtViewConstants;
import org.apache.log4j.Logger;
import org.hibernate.jdbc.Work;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.OutputStream;
import java.sql.Connection;
@khaosans
khaosans / gist:0de924ddaf2a0fed9e9d456017c59f4c
Created December 21, 2016 00:17
Put into the hazelcast cache
public static void main(String[] args) throws InterruptedException {
ClientConfig clientConfig = new ClientConfig();
List<String> addressList = new ArrayList<String>();
addressList.add("localhost:5701");
clientConfig.getNetworkConfig().setAddresses(addressList).setConnectionAttemptLimit(1000);
HazelcastInstance hazelcasetInstance = HazelcastClient.newHazelcastClient(clientConfig);
for (int i = 0; i < 10000; i++) {
IMap<String, String> map = hazelcasetInstance.getMap("map");
@khaosans
khaosans / gist:26af02f5de71b062faf5fa379ab1661c
Created December 21, 2016 00:29
Transaction Map for hazelcast put test
public static void main(String[] args) throws InterruptedException {
ClientConfig clientConfig = new ClientConfig();
List addressList = new ArrayList();
addressList.add("localhost:5701");
clientConfig.getNetworkConfig().setAddresses(addressList).setConnectionAttemptLimit(1000).setRedoOperation(true);
HazelcastInstance hazelcasetInstance = HazelcastClient.newHazelcastClient(clientConfig);
for (int i = 0; i < 10000; i++) {