mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-11-23 09:16:37 -06:00
make ThreadLocals transient for gson compat in Java 17
This commit is contained in:
parent
3a0186fef4
commit
9c765f29a8
@ -16,7 +16,7 @@ public class ThreadLocalNamedTimers {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger(ThreadLocalNamedTimers.class);
|
||||
|
||||
public final static ThreadLocal<ThreadLocalNamedTimers> TL_INSTANCE = ThreadLocal.withInitial(ThreadLocalNamedTimers::new);
|
||||
public transient final static ThreadLocal<ThreadLocalNamedTimers> TL_INSTANCE = ThreadLocal.withInitial(ThreadLocalNamedTimers::new);
|
||||
private final static Map<String, Timer> timers = new HashMap<>();
|
||||
private final Map<String, Timer.Context> contexts = new HashMap<>();
|
||||
|
||||
|
@ -27,7 +27,7 @@ import java.util.function.LongToIntFunction;
|
||||
@ThreadSafeMapper
|
||||
public class StringMapClob implements LongFunction<String> {
|
||||
|
||||
private final static ThreadLocal<StringBuilder> tl_sb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
private transient final static ThreadLocal<StringBuilder> tl_sb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
|
||||
private final LongToIntFunction sizeFunc;
|
||||
private final LongFunction[] keyFuncs;
|
||||
|
@ -3,7 +3,7 @@ package io.nosqlbench.activitytype.cql.datamappers.functions.rainbow;
|
||||
import java.util.function.IntToLongFunction;
|
||||
|
||||
public abstract class TokenMapFileBaseFunction implements IntToLongFunction {
|
||||
protected static ThreadLocal<TokenMapFileAPIService> tl_DataSvc;
|
||||
protected transient static ThreadLocal<TokenMapFileAPIService> tl_DataSvc;
|
||||
|
||||
public TokenMapFileBaseFunction(String filename, boolean loopdata, boolean instanced, boolean ascending) {
|
||||
tl_DataSvc = ThreadLocal.withInitial(() -> new TokenMapFileAPIService(filename, loopdata, instanced, ascending));
|
||||
|
@ -19,7 +19,7 @@ public class HashedCQLErrorHandler extends HashedErrorHandler<Throwable, ErrorSt
|
||||
// add(ResultSetVerificationException.class);
|
||||
// }};
|
||||
private final ExceptionCountMetrics exceptionCountMetrics;
|
||||
private static final ThreadLocal<Integer> tlResultCode = ThreadLocal.withInitial(() -> (0));
|
||||
private transient static final ThreadLocal<Integer> tlResultCode = ThreadLocal.withInitial(() -> (0));
|
||||
|
||||
public HashedCQLErrorHandler(ExceptionCountMetrics exceptionCountMetrics) {
|
||||
this.exceptionCountMetrics = exceptionCountMetrics;
|
||||
|
@ -18,7 +18,7 @@ import java.util.stream.Collectors;
|
||||
public class Save implements RowCycleOperator {
|
||||
private final static Logger logger = LogManager.getLogger(Save.class);
|
||||
|
||||
ThreadLocal<HashMap<String, Object>> tl_objectMap = SharedState.tl_ObjectMap;
|
||||
private final transient ThreadLocal<HashMap<String, Object>> tl_objectMap = SharedState.tl_ObjectMap;
|
||||
|
||||
private final String[] varnames;
|
||||
|
||||
|
@ -14,7 +14,7 @@ import java.util.List;
|
||||
*/
|
||||
public class SaveThreadVars implements RowCycleOperator {
|
||||
|
||||
ThreadLocal<HashMap<String, Object>> tl_objectMap = SharedState.tl_ObjectMap;
|
||||
private final transient ThreadLocal<HashMap<String, Object>> tl_objectMap = SharedState.tl_ObjectMap;
|
||||
|
||||
@Override
|
||||
public int apply(Row row, long cycle) {
|
||||
|
@ -24,7 +24,7 @@ public class TraceLogger implements ResultSetCycleOperator, StatementModifier {
|
||||
private final long modulo;
|
||||
private final String filename;
|
||||
private final FileWriter writer;
|
||||
private final ThreadLocal<StringBuilder> tlsb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
private final transient ThreadLocal<StringBuilder> tlsb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
|
||||
public TraceLogger(SimpleConfig conf) {
|
||||
this(
|
||||
|
@ -14,7 +14,7 @@ import java.util.List;
|
||||
*/
|
||||
public class SaveThreadVars implements RowCycleOperator {
|
||||
|
||||
ThreadLocal<HashMap<String, Object>> tl_objectMap = SharedState.tl_ObjectMap;
|
||||
private final transient ThreadLocal<HashMap<String, Object>> tl_objectMap = SharedState.tl_ObjectMap;
|
||||
|
||||
@Override
|
||||
public int apply(Row row, long cycle) {
|
||||
|
@ -24,7 +24,7 @@ public class TraceLogger implements ResultSetCycleOperator, StatementModifier {
|
||||
private final long modulo;
|
||||
private final String filename;
|
||||
private final FileWriter writer;
|
||||
private final ThreadLocal<StringBuilder> tlsb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
private final transient ThreadLocal<StringBuilder> tlsb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
|
||||
public TraceLogger(SimpleConfig conf) {
|
||||
this(
|
||||
|
@ -56,7 +56,7 @@ public class ReadyGraphStatementTemplate {
|
||||
implements ValuesBinder<SimpleGraphStatement, SimpleGraphStatement> {
|
||||
private final String[] fields;
|
||||
private final Map valuesMap = new HashMap();
|
||||
private final ThreadLocal<Map<String, Object>> mapTL;
|
||||
private final transient ThreadLocal<Map<String, Object>> mapTL;
|
||||
|
||||
public ParameterizedGraphStatementValuesBinder(String[] fields) {
|
||||
this.fields = fields;
|
||||
@ -76,4 +76,4 @@ public class ReadyGraphStatementTemplate {
|
||||
public ReadyGraphStatement resolve() {
|
||||
return new ReadyGraphStatement(contextualBindingsTemplate.resolveBindings());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import io.nosqlbench.engine.api.activityapi.core.ActivityType;
|
||||
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
|
||||
@Service(value = ActivityType.class, selector = "pulsar")
|
||||
@Service(value= ActivityType.class, selector="pulsar")
|
||||
public class PulsarActivityType implements ActivityType<PulsarActivity> {
|
||||
|
||||
@Override
|
||||
|
@ -10,8 +10,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class PulsarBatchProducerStartOp extends SyncPulsarOp {
|
||||
|
||||
// TODO: ensure sane container lifecycle management
|
||||
public final static ThreadLocal<List<CompletableFuture<MessageId>>> threadLocalBatchMsgContainer = new ThreadLocal<>();
|
||||
public final static ThreadLocal<Producer<?>> threadLocalProducer = new ThreadLocal<>();
|
||||
public final transient static ThreadLocal<List<CompletableFuture<MessageId>>> threadLocalBatchMsgContainer = new ThreadLocal<>();
|
||||
public final transient static ThreadLocal<Producer<?>> threadLocalProducer = new ThreadLocal<>();
|
||||
|
||||
public PulsarBatchProducerStartOp(Producer<?> batchProducer) {
|
||||
threadLocalProducer.set(batchProducer);
|
||||
|
@ -37,9 +37,9 @@ import java.util.*;
|
||||
*/
|
||||
public class Bindings {
|
||||
private final static Logger logger = LogManager.getLogger(Bindings.class);
|
||||
private BindingsTemplate template;
|
||||
private final BindingsTemplate template;
|
||||
private List<DataMapper<?>> dataMappers = new ArrayList<DataMapper<?>>();
|
||||
private ThreadLocal<Map<String, DataMapper<?>>> nameCache;
|
||||
private final transient ThreadLocal<Map<String, DataMapper<?>>> nameCache;
|
||||
|
||||
public Bindings(BindingsTemplate template, List<DataMapper<?>> dataMappers) {
|
||||
this.template = template;
|
||||
@ -346,7 +346,7 @@ public class Bindings {
|
||||
return new LazyValuesMap(this, input);
|
||||
}
|
||||
|
||||
public static interface FieldSetter {
|
||||
public interface FieldSetter {
|
||||
void setField(String name, Object value);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import java.util.stream.Collectors;
|
||||
@ThreadSafeMapper
|
||||
public class DigestToByteBuffer implements LongFunction<ByteBuffer> {
|
||||
|
||||
private static ThreadLocal<TL_State> tl_state;
|
||||
private transient static ThreadLocal<TL_State> tl_state;
|
||||
|
||||
public DigestToByteBuffer(String digestType) {
|
||||
|
||||
|
@ -26,7 +26,7 @@ import java.util.function.LongToIntFunction;
|
||||
public class HashedByteBufferExtract implements LongFunction<ByteBuffer> {
|
||||
|
||||
private final LongToIntFunction sizefunc;
|
||||
private final ThreadLocal<ByteBuffer> bbaccessor;
|
||||
private final transient ThreadLocal<ByteBuffer> bbaccessor;
|
||||
private final Hash inthash = new Hash();
|
||||
|
||||
public HashedByteBufferExtract(Object initFunc, Object sizeFunc) {
|
||||
|
@ -18,7 +18,7 @@ import java.util.function.LongFunction;
|
||||
public class ToMD5ByteBuffer implements LongFunction<ByteBuffer> {
|
||||
|
||||
private final MessageDigest md5;
|
||||
private static final ThreadLocal<TLState> tl_state = ThreadLocal.withInitial(TLState::new);
|
||||
private transient static final ThreadLocal<TLState> tl_state = ThreadLocal.withInitial(TLState::new);
|
||||
|
||||
@Example({"MD5ByteBuffer()","convert the a input to an md5 digest of its bytes"})
|
||||
public ToMD5ByteBuffer() {
|
||||
|
@ -12,8 +12,8 @@ import java.util.function.LongToIntFunction;
|
||||
@Categories({Category.general})
|
||||
public class Hash implements LongToIntFunction {
|
||||
|
||||
ThreadLocal<ByteBuffer> bb_TL = ThreadLocal.withInitial(() -> ByteBuffer.allocate(Long.BYTES));
|
||||
ThreadLocal<Murmur3F> murmur3f_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
private final transient ThreadLocal<ByteBuffer> bb_TL = ThreadLocal.withInitial(() -> ByteBuffer.allocate(Long.BYTES));
|
||||
private final transient ThreadLocal<Murmur3F> murmur3f_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
|
||||
@Override
|
||||
public int applyAsInt(long value) {
|
||||
|
@ -12,8 +12,8 @@ import java.util.function.LongToIntFunction;
|
||||
@Categories({Category.general})
|
||||
public class SignedHash implements LongToIntFunction {
|
||||
|
||||
ThreadLocal<ByteBuffer> bb_TL = ThreadLocal.withInitial(() -> ByteBuffer.allocate(Long.BYTES));
|
||||
ThreadLocal<Murmur3F> murmur3f_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
private final transient ThreadLocal<ByteBuffer> bb_TL = ThreadLocal.withInitial(() -> ByteBuffer.allocate(Long.BYTES));
|
||||
private final transient ThreadLocal<Murmur3F> murmur3f_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
|
||||
@Override
|
||||
public int applyAsInt(long value) {
|
||||
|
@ -19,7 +19,7 @@ import java.util.function.LongUnaryOperator;
|
||||
@Categories({Category.general, Category.general})
|
||||
public class Hash implements LongUnaryOperator {
|
||||
|
||||
private final ThreadLocal<Murmur3F> murmur3f_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
private final transient ThreadLocal<Murmur3F> murmur3f_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
|
||||
@Override
|
||||
public long applyAsLong(long value) {
|
||||
|
@ -48,7 +48,7 @@ public class HashedFileExtractToString implements LongFunction<String> {
|
||||
private final CharBuffer buf;
|
||||
private final LongToIntFunction sizeFunc;
|
||||
private final LongToIntFunction positionRange = new HashRange(0, Integer.MAX_VALUE);
|
||||
private final static ThreadLocal<StringBuilder> tl_sb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
private final static transient ThreadLocal<StringBuilder> tl_sb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
private final String filename;
|
||||
|
||||
@Example({"HashedFileExtractToString('data/adventures.txt',100,200)", "return a fragment from adventures.txt between 100 and 200 characters long"})
|
||||
|
@ -20,7 +20,7 @@ import java.util.function.LongFunction;
|
||||
public class MD5HexString implements LongFunction<String> {
|
||||
|
||||
private final MessageDigest md5;
|
||||
private static final ThreadLocal<TLState> tl_state = ThreadLocal.withInitial(TLState::new);
|
||||
private static final transient ThreadLocal<TLState> tl_state = ThreadLocal.withInitial(TLState::new);
|
||||
|
||||
@Example({"MD5String()","Convert a long input to an md5 digest over its bytes, and then to a hexadecimal string."})
|
||||
public MD5HexString() {
|
||||
|
@ -36,7 +36,7 @@ import java.util.function.LongFunction;
|
||||
@DeprecatedFunction("This function is easily replaced with other simpler functions.")
|
||||
public class Murmur3DivToString implements LongFunction<String> {
|
||||
|
||||
private final ThreadLocal<Murmur3F> murmur3F_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
private final transient ThreadLocal<Murmur3F> murmur3F_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
private final DivideToLong divideToLongMapper;
|
||||
|
||||
public Murmur3DivToString(long divisor) {
|
||||
|
@ -35,7 +35,7 @@ import java.util.function.LongFunction;
|
||||
@Categories({Category.general,Category.premade})
|
||||
public class NumberNameToString implements LongFunction<String> {
|
||||
|
||||
private final static ThreadLocal<StringBuilder> tlsb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
private final transient static ThreadLocal<StringBuilder> tlsb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
|
||||
private final static String THOUSAND = "thousand";
|
||||
private final static String MILLION = "million";
|
||||
|
@ -16,7 +16,7 @@ import java.util.function.LongFunction;
|
||||
@ThreadSafeMapper
|
||||
public class ToBase64String implements LongFunction<String> {
|
||||
|
||||
private final static ThreadLocal<TLState> tl_state = ThreadLocal.withInitial(TLState::new);
|
||||
private final transient static ThreadLocal<TLState> tl_state = ThreadLocal.withInitial(TLState::new);
|
||||
|
||||
@Example({"ToBase64String()","Convert the bytes of a long input into a base64 String"})
|
||||
public ToBase64String() {
|
||||
|
@ -39,7 +39,7 @@ import java.util.regex.Pattern;
|
||||
public class ThreadNumToLong implements LongUnaryOperator {
|
||||
|
||||
private static final Pattern pattern = Pattern.compile("^.*?(\\d+).*$");
|
||||
private final ThreadLocal<Long> threadLocalInt = new ThreadLocal<Long>() {
|
||||
private final transient ThreadLocal<Long> threadLocalInt = new ThreadLocal<Long>() {
|
||||
@Override
|
||||
protected Long initialValue() {
|
||||
Matcher matcher = pattern.matcher(Thread.currentThread().getName());
|
||||
|
@ -38,8 +38,7 @@ import java.util.regex.Pattern;
|
||||
public class ThreadNum implements LongToIntFunction {
|
||||
|
||||
private static final Pattern pattern = Pattern.compile("^.*?(\\d+).*$");
|
||||
|
||||
private final ThreadLocal<Integer> threadLocalInt = new ThreadLocal<Integer>() {
|
||||
private final transient ThreadLocal<Integer> threadLocalInt = new ThreadLocal<Integer>() {
|
||||
@Override
|
||||
protected Integer initialValue() {
|
||||
if (Thread.currentThread() instanceof Indexed ) {
|
||||
|
@ -32,7 +32,7 @@ import java.util.regex.Pattern;
|
||||
public class ThreadNum implements LongUnaryOperator {
|
||||
|
||||
private static final Pattern pattern = Pattern.compile("^.*?(\\d+).*$");
|
||||
private final ThreadLocal<Long> threadLocalInt = new ThreadLocal<Long>() {
|
||||
private final transient ThreadLocal<Long> threadLocalInt = new ThreadLocal<Long>() {
|
||||
@Override
|
||||
protected Long initialValue() {
|
||||
if (Thread.currentThread() instanceof Indexed) {
|
||||
|
@ -17,7 +17,7 @@ import java.util.function.Function;
|
||||
public class Show implements Function<Object,String> {
|
||||
|
||||
private final String[] names;
|
||||
private final ThreadLocal<StringBuilder> tl_sb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
private final transient ThreadLocal<StringBuilder> tl_sb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
|
||||
@Example({"Show()","Show all values in a json-like format"})
|
||||
public Show() {
|
||||
|
@ -14,7 +14,7 @@ import java.util.function.LongFunction;
|
||||
public class Show implements LongFunction<String> {
|
||||
|
||||
private final String[] names;
|
||||
private final ThreadLocal<StringBuilder> tl_sb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
private final transient ThreadLocal<StringBuilder> tl_sb = ThreadLocal.withInitial(StringBuilder::new);
|
||||
|
||||
@Example({"Show()","Show all values in a json-like format"})
|
||||
public Show() {
|
||||
|
@ -12,7 +12,7 @@ import java.util.function.IntUnaryOperator;
|
||||
@Categories({Category.general})
|
||||
public class Hash implements IntUnaryOperator {
|
||||
|
||||
private final ThreadLocal<Murmur3F> murmur3f_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
private final transient ThreadLocal<Murmur3F> murmur3f_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
|
||||
@Override
|
||||
public int applyAsInt(int operand) {
|
||||
|
@ -14,7 +14,7 @@ import java.util.function.Function;
|
||||
@ThreadSafeMapper
|
||||
public class ToBase64String implements Function<String,String> {
|
||||
|
||||
private final static ThreadLocal<TLState> tl_state = ThreadLocal.withInitial(TLState::new);
|
||||
private final transient static ThreadLocal<TLState> tl_state = ThreadLocal.withInitial(TLState::new);
|
||||
|
||||
@Example({"ToBase64String()","encode any input as Base64"})
|
||||
public ToBase64String() {
|
||||
|
@ -16,7 +16,7 @@ public class ThreadSafeHash implements LongUnaryOperator {
|
||||
|
||||
// private ByteBuffer bb = ByteBuffer.allocate(Long.BYTES);
|
||||
// private Murmur3F murmur3F= new Murmur3F();
|
||||
private static ThreadLocal<HashState> tlstate = ThreadLocal.withInitial(HashState::new);
|
||||
private final transient static ThreadLocal<HashState> tlstate = ThreadLocal.withInitial(HashState::new);
|
||||
|
||||
@Override
|
||||
public long applyAsLong(long value) {
|
||||
|
Loading…
Reference in New Issue
Block a user