Search in sources :

Example 6 with TriTuple

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);
}
Also used : TriTuple(com.hazelcast.internal.util.TriTuple) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 7 with TriTuple

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);
}
Also used : TriTuple(com.hazelcast.internal.util.TriTuple) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 8 with TriTuple

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);
}
Also used : TriTuple(com.hazelcast.internal.util.TriTuple) CompactSerializationConfig(com.hazelcast.config.CompactSerializationConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with TriTuple

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);
}
Also used : TriTuple(com.hazelcast.internal.util.TriTuple) MBeanInfo(javax.management.MBeanInfo) MBeanAttributeInfo(javax.management.MBeanAttributeInfo)

Example 10 with TriTuple

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);
    }
}
Also used : TriTuple(com.hazelcast.internal.util.TriTuple) CompactSerializer(com.hazelcast.nio.serialization.compact.CompactSerializer) HazelcastSerializationException(com.hazelcast.nio.serialization.HazelcastSerializationException) IOException(java.io.IOException)

Aggregations

TriTuple (com.hazelcast.internal.util.TriTuple)10 CompactSerializationConfig (com.hazelcast.config.CompactSerializationConfig)6 Test (org.junit.Test)6 CompactSerializer (com.hazelcast.nio.serialization.compact.CompactSerializer)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 EmployeeDTOSerializer (example.serialization.EmployeeDTOSerializer)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CPSubsystemConfig (com.hazelcast.config.cp.CPSubsystemConfig)1 FencedLockConfig (com.hazelcast.config.cp.FencedLockConfig)1 SemaphoreConfig (com.hazelcast.config.cp.SemaphoreConfig)1 JaasAuthenticationConfig (com.hazelcast.config.security.JaasAuthenticationConfig)1 KerberosAuthenticationConfig (com.hazelcast.config.security.KerberosAuthenticationConfig)1 KerberosIdentityConfig (com.hazelcast.config.security.KerberosIdentityConfig)1 LdapAuthenticationConfig (com.hazelcast.config.security.LdapAuthenticationConfig)1 RealmConfig (com.hazelcast.config.security.RealmConfig)1 SimpleAuthenticationConfig (com.hazelcast.config.security.SimpleAuthenticationConfig)1 TlsAuthenticationConfig (com.hazelcast.config.security.TlsAuthenticationConfig)1 TokenIdentityConfig (com.hazelcast.config.security.TokenIdentityConfig)1