mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Add analytics
This commit is contained in:
@@ -36,6 +36,7 @@ import net.openhft.chronicle.hash.serialization.impl.BytesMarshallableReaderWrit
|
||||
import net.openhft.chronicle.hash.serialization.impl.MarshallableReaderWriter;
|
||||
import net.openhft.chronicle.hash.serialization.impl.SerializationBuilder;
|
||||
import net.openhft.chronicle.hash.serialization.impl.TypedMarshallableReaderWriter;
|
||||
import net.openhft.chronicle.map.internal.AnalyticsHolder;
|
||||
import net.openhft.chronicle.map.replication.MapRemoteOperations;
|
||||
import net.openhft.chronicle.set.ChronicleSetBuilder;
|
||||
import net.openhft.chronicle.values.ValueModel;
|
||||
@@ -1626,6 +1627,7 @@ public final class ChronicleMapBuilder<K, V> implements
|
||||
public ChronicleMap<K, V> recoverPersistedTo(@NotNull final File file,
|
||||
final boolean sameBuilderConfigAndLibraryVersion,
|
||||
@Nullable final ChronicleHashCorruption.Listener corruptionListener) throws IOException {
|
||||
AnalyticsHolder.instance().sendEvent("recover");
|
||||
return clone().createWithFile(file, true, sameBuilderConfigAndLibraryVersion, corruptionListener);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import net.openhft.chronicle.hash.serialization.SizedReader;
|
||||
import net.openhft.chronicle.hash.serialization.impl.SerializationBuilder;
|
||||
import net.openhft.chronicle.map.impl.*;
|
||||
import net.openhft.chronicle.map.impl.ret.InstanceReturnValue;
|
||||
import net.openhft.chronicle.map.internal.AnalyticsHolder;
|
||||
import net.openhft.chronicle.set.ChronicleSet;
|
||||
import net.openhft.chronicle.wire.WireIn;
|
||||
import net.openhft.chronicle.wire.WireOut;
|
||||
@@ -45,6 +46,8 @@ import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
@@ -109,6 +112,13 @@ public class VanillaChronicleMap<K, V, R>
|
||||
|
||||
initTransientsFromBuilder(builder);
|
||||
initTransients();
|
||||
|
||||
final Map<String, String> additionalEventParameters = new HashMap<>();
|
||||
additionalEventParameters.put("key_type", keyClass.getTypeName());
|
||||
additionalEventParameters.put("value_type", valueClass.getTypeName());
|
||||
additionalEventParameters.put("entries", Long.toString(builder.entries()));
|
||||
|
||||
AnalyticsHolder.instance().sendEvent("started", additionalEventParameters);
|
||||
}
|
||||
|
||||
public static long alignAddr(final long addr, final long alignment) {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.openhft.chronicle.map.internal;
|
||||
|
||||
import net.openhft.chronicle.core.analytics.AnalyticsFacade;
|
||||
import net.openhft.chronicle.core.pom.PomProperties;
|
||||
|
||||
public enum AnalyticsHolder {;
|
||||
|
||||
// Todo: VERSION is "unknown" for some reason
|
||||
private static final String VERSION = PomProperties.version("net.openhft", "chronicle-map");
|
||||
|
||||
private static final AnalyticsFacade ANALYTICS = AnalyticsFacade.standardBuilder(
|
||||
"G-TDTJG5CT6G",
|
||||
"J8qsWGHgQP6CLs43mQ10KQ",
|
||||
VERSION)
|
||||
.withReportDespiteJUnit()
|
||||
.build();
|
||||
|
||||
public static AnalyticsFacade instance() {
|
||||
return ANALYTICS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.openhft.chronicle.map.internal;
|
||||
|
||||
import net.openhft.chronicle.map.ChronicleMap;
|
||||
import net.openhft.chronicle.map.ChronicleMapBuilder;
|
||||
|
||||
public final class AnalyticsMain {
|
||||
|
||||
public static final String BASE_MAP_NAME = "analytics_test_map";
|
||||
public static final String MAP_NAME1 = BASE_MAP_NAME + "1";
|
||||
public static final String MAP_NAME2 = BASE_MAP_NAME + "2";
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Creating two maps and sending analytics...");
|
||||
System.out.println("Currently, there is a limit of one message per h per JVM instance so only one analytics message will be sent upstream.");
|
||||
|
||||
try (ChronicleMap<CharSequence, CharSequence> m1 = createMap(CharSequence.class, CharSequence.class, MAP_NAME1)) {
|
||||
try (ChronicleMap<Long, CharSequence> m2 = createMap(Long.class, CharSequence.class, MAP_NAME2)) {
|
||||
m1.put("A", "1");
|
||||
m2.put(2L, "Two");
|
||||
}
|
||||
}
|
||||
System.out.println("Completed successfully");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
private static <K, V> ChronicleMap<K, V> createMap(Class<K> keyType, Class<V> valueType, String name) {
|
||||
return ChronicleMapBuilder.of(keyType, valueType)
|
||||
.name(name)
|
||||
.averageKeySize(32)
|
||||
.averageValueSize(32)
|
||||
.entries(1_000)
|
||||
.create();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* This package and any and all sub-packages contains strictly internal classes for this Chronicle library.
|
||||
* Internal classes shall <em>never</em> be used directly.
|
||||
* <p>
|
||||
* Specifically, the following actions (including, but not limited to) are not allowed
|
||||
* on internal classes and packages:
|
||||
* <ul>
|
||||
* <li>Casting to</li>
|
||||
* <li>Reflection of any kind</li>
|
||||
* <li>Explicit Serialize/deserialize</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* The classes in this package and any sub-package are subject to
|
||||
* changes at any time for any reason.
|
||||
*/
|
||||
package net.openhft.chronicle.map.internal;
|
||||
Reference in New Issue
Block a user