use of com.hazelcast.internal.util.TriTuple in project hazelcast by hazelcast.
the class ConfigFactoryTest method should_create_compact_serialization_config_with_reflective_serializer.
@Test
public void should_create_compact_serialization_config_with_reflective_serializer() {
Map<String, TriTuple<String, String, String>> registrations = new HashMap<>();
TriTuple<String, String, String> registration = TriTuple.of("a", "a", null);
registrations.put("a", registration);
CompactSerializationConfig config = ConfigFactory.newCompactSerializationConfig(true, registrations);
assertThat(config.isEnabled()).isTrue();
assertThat(CompactSerializationConfigAccessor.getNamedRegistrations(config)).isEqualTo(registrations);
}
use of com.hazelcast.internal.util.TriTuple in project hazelcast by hazelcast.
the class TestFullApplicationContext method testCompactSerializationConfig.
@Test
public void testCompactSerializationConfig() {
CompactSerializationConfig compactSerializationConfig = config.getSerializationConfig().getCompactSerializationConfig();
assertTrue(compactSerializationConfig.isEnabled());
Map<String, TriTuple<String, String, String>> namedRegistrations = CompactSerializationConfigAccessor.getNamedRegistrations(compactSerializationConfig);
assertEquals(2, namedRegistrations.size());
String reflectivelySerializableClassName = DummyReflectiveSerializable.class.getName();
TriTuple<String, String, String> reflectiveClassRegistration = TriTuple.of(reflectivelySerializableClassName, reflectivelySerializableClassName, null);
TriTuple<String, String, String> actualReflectiveRegistration = namedRegistrations.get(reflectivelySerializableClassName);
assertEquals(reflectiveClassRegistration, actualReflectiveRegistration);
String compactSerializableClassName = DummyCompactSerializable.class.getName();
String compactSerializerClassName = DummyCompactSerializer.class.getName();
String typeName = "dummy";
TriTuple<String, String, String> explicitClassRegistration = TriTuple.of(compactSerializableClassName, typeName, compactSerializerClassName);
TriTuple<String, String, String> actualExplicitRegistration = namedRegistrations.get(typeName);
assertEquals(explicitClassRegistration, actualExplicitRegistration);
}
use of com.hazelcast.internal.util.TriTuple in project hazelcast by hazelcast.
the class TestClientApplicationContext method tesCompactSerializationConfig.
@Test
public void tesCompactSerializationConfig() {
CompactSerializationConfig compactSerializationConfig = clientWithCompactSerialization.getClientConfig().getSerializationConfig().getCompactSerializationConfig();
assertTrue(compactSerializationConfig.isEnabled());
Map<String, TriTuple<String, String, String>> namedRegistrations = CompactSerializationConfigAccessor.getNamedRegistrations(compactSerializationConfig);
assertEquals(2, namedRegistrations.size());
String reflectivelySerializableClassName = DummyReflectiveSerializable.class.getName();
TriTuple<String, String, String> reflectiveClassRegistration = TriTuple.of(reflectivelySerializableClassName, reflectivelySerializableClassName, null);
TriTuple<String, String, String> actualReflectiveRegistration = namedRegistrations.get(reflectivelySerializableClassName);
assertEquals(reflectiveClassRegistration, actualReflectiveRegistration);
String compactSerializableClassName = DummyCompactSerializable.class.getName();
String compactSerializerClassName = DummyCompactSerializer.class.getName();
String typeName = "dummy";
TriTuple<String, String, String> explicitClassRegistration = TriTuple.of(compactSerializableClassName, typeName, compactSerializerClassName);
TriTuple<String, String, String> actualExplicitRegistration = namedRegistrations.get(typeName);
assertEquals(explicitClassRegistration, actualExplicitRegistration);
}
use of com.hazelcast.internal.util.TriTuple in project hazelcast by hazelcast.
the class MetricsMBean method getMBeanInfo.
@Override
public MBeanInfo getMBeanInfo() {
MBeanAttributeInfo[] array = new MBeanAttributeInfo[metrics.size()];
int i = 0;
for (Entry<String, TriTuple<String, AtomicReference<Number>, Type>> entry : metrics.entrySet()) {
array[i++] = new MBeanAttributeInfo(entry.getKey(), entry.getValue().element3.type, "Unit: " + entry.getValue().element1, true, false, false);
}
return new MBeanInfo("Metric", "", array, null, null, null, null);
}
use of com.hazelcast.internal.util.TriTuple in project hazelcast by hazelcast.
the class CompactStreamSerializer method registerConfiguredNamedSerializers.
private void registerConfiguredNamedSerializers(CompactSerializationConfig compactSerializationConfig) {
Map<String, TriTuple<String, String, String>> namedRegistries = CompactSerializationConfigAccessor.getNamedRegistrations(compactSerializationConfig);
for (TriTuple<String, String, String> registry : namedRegistries.values()) {
String className = registry.element1;
String typeName = registry.element2;
String serializerClassName = registry.element3;
Class clazz;
try {
clazz = ClassLoaderUtil.loadClass(classLoader, className);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Cannot load the class " + className);
}
CompactSerializer serializer;
if (serializerClassName != null) {
try {
serializer = ClassLoaderUtil.newInstance(classLoader, serializerClassName);
} catch (Exception e) {
throw new IllegalArgumentException("Cannot create an instance of " + serializerClassName);
}
} else {
if (javaRecordSerializer.isRecord(clazz)) {
serializer = javaRecordSerializer;
} else {
serializer = reflectiveSerializer;
}
}
CompactSerializableRegistration registration = new CompactSerializableRegistration(clazz, typeName, serializer);
classToRegistrationMap.put(clazz, registration);
typeNameToRegistrationMap.put(typeName, registration);
}
}
Aggregations