Search in sources :

Example 1 with SqlMappingDdlCodec

use of com.hazelcast.client.impl.protocol.codec.SqlMappingDdlCodec in project hazelcast by hazelcast.

the class SqlClientService method mappingDdl.

/**
 * Gets a SQL Mapping suggestion for the given IMap name.
 *
 * Used by Management Center.
 */
@Nonnull
public CompletableFuture<String> mappingDdl(Member member, String mapName) {
    checkNotNull(mapName);
    ClientInvocation invocation = new ClientInvocation(client, SqlMappingDdlCodec.encodeRequest(mapName), null, member.getUuid());
    return new ClientDelegatingFuture<>(invocation.invoke(), client.getSerializationService(), SqlMappingDdlCodec::decodeResponse);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) SqlMappingDdlCodec(com.hazelcast.client.impl.protocol.codec.SqlMappingDdlCodec) Nonnull(javax.annotation.Nonnull)

Example 2 with SqlMappingDdlCodec

use of com.hazelcast.client.impl.protocol.codec.SqlMappingDdlCodec in project hazelcast by hazelcast.

the class MCMessageTasksTest method test_sqlMappingDdl_existingMap.

@Test
public void test_sqlMappingDdl_existingMap() throws Exception {
    String name = randomMapName();
    instance().getMap(name).put(1, "value-1");
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), SqlMappingDdlCodec.encodeRequest(name), null);
    ClientDelegatingFuture<String> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), SqlMappingDdlCodec::decodeResponse);
    String response = future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS);
    assertStartsWith("CREATE MAPPING \"" + name + "\"", response);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) SqlMappingDdlCodec(com.hazelcast.client.impl.protocol.codec.SqlMappingDdlCodec) Test(org.junit.Test)

Example 3 with SqlMappingDdlCodec

use of com.hazelcast.client.impl.protocol.codec.SqlMappingDdlCodec in project hazelcast by hazelcast.

the class MCMessageTasksTest method test_sqlMappingDdl_nonExistingMap.

@Test
public void test_sqlMappingDdl_nonExistingMap() throws Exception {
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), SqlMappingDdlCodec.encodeRequest(randomMapName()), null);
    ClientDelegatingFuture<String> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), SqlMappingDdlCodec::decodeResponse);
    String response = future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS);
    assertNull(response);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) SqlMappingDdlCodec(com.hazelcast.client.impl.protocol.codec.SqlMappingDdlCodec) Test(org.junit.Test)

Aggregations

ClientDelegatingFuture (com.hazelcast.client.impl.ClientDelegatingFuture)3 SqlMappingDdlCodec (com.hazelcast.client.impl.protocol.codec.SqlMappingDdlCodec)3 ClientInvocation (com.hazelcast.client.impl.spi.impl.ClientInvocation)3 Test (org.junit.Test)2 Nonnull (javax.annotation.Nonnull)1