Search in sources :

Example 1 with DisabledKvStateRequestStats

use of org.apache.flink.queryablestate.network.stats.DisabledKvStateRequestStats in project flink by apache.

the class KvStateService method fromConfiguration.

// --------------------------------------------------------------------------------------------
// Static factory methods for kvState service
// --------------------------------------------------------------------------------------------
/**
 * Creates and returns the KvState service.
 *
 * @param taskManagerServicesConfiguration task manager configuration
 * @return service for kvState related components
 */
public static KvStateService fromConfiguration(TaskManagerServicesConfiguration taskManagerServicesConfiguration) {
    KvStateRegistry kvStateRegistry = new KvStateRegistry();
    QueryableStateConfiguration qsConfig = taskManagerServicesConfiguration.getQueryableStateConfig();
    KvStateClientProxy kvClientProxy = null;
    KvStateServer kvStateServer = null;
    if (qsConfig != null) {
        int numProxyServerNetworkThreads = qsConfig.numProxyServerThreads() == 0 ? taskManagerServicesConfiguration.getNumberOfSlots() : qsConfig.numProxyServerThreads();
        int numProxyServerQueryThreads = qsConfig.numProxyQueryThreads() == 0 ? taskManagerServicesConfiguration.getNumberOfSlots() : qsConfig.numProxyQueryThreads();
        kvClientProxy = QueryableStateUtils.createKvStateClientProxy(taskManagerServicesConfiguration.getExternalAddress(), qsConfig.getProxyPortRange(), numProxyServerNetworkThreads, numProxyServerQueryThreads, new DisabledKvStateRequestStats());
        int numStateServerNetworkThreads = qsConfig.numStateServerThreads() == 0 ? taskManagerServicesConfiguration.getNumberOfSlots() : qsConfig.numStateServerThreads();
        int numStateServerQueryThreads = qsConfig.numStateQueryThreads() == 0 ? taskManagerServicesConfiguration.getNumberOfSlots() : qsConfig.numStateQueryThreads();
        kvStateServer = QueryableStateUtils.createKvStateServer(taskManagerServicesConfiguration.getExternalAddress(), qsConfig.getStateServerPortRange(), numStateServerNetworkThreads, numStateServerQueryThreads, kvStateRegistry, new DisabledKvStateRequestStats());
    }
    return new KvStateService(kvStateRegistry, kvStateServer, kvClientProxy);
}
Also used : TaskKvStateRegistry(org.apache.flink.runtime.query.TaskKvStateRegistry) KvStateRegistry(org.apache.flink.runtime.query.KvStateRegistry) KvStateClientProxy(org.apache.flink.runtime.query.KvStateClientProxy) KvStateServer(org.apache.flink.runtime.query.KvStateServer) DisabledKvStateRequestStats(org.apache.flink.queryablestate.network.stats.DisabledKvStateRequestStats)

Example 2 with DisabledKvStateRequestStats

use of org.apache.flink.queryablestate.network.stats.DisabledKvStateRequestStats in project flink by apache.

the class KvStateServerHandlerTest method testQueryExecutorShutDown.

/**
 * Tests the failure response on a rejected execution, because the query executor has been
 * closed.
 */
@Test
public void testQueryExecutorShutDown() throws Throwable {
    KvStateRegistry registry = new KvStateRegistry();
    AtomicKvStateRequestStats stats = new AtomicKvStateRequestStats();
    KvStateServerImpl localTestServer = new KvStateServerImpl(InetAddress.getLocalHost().getHostName(), Collections.singletonList(0).iterator(), 1, 1, new KvStateRegistry(), new DisabledKvStateRequestStats());
    localTestServer.start();
    localTestServer.shutdown();
    assertTrue(localTestServer.getQueryExecutor().isTerminated());
    MessageSerializer<KvStateInternalRequest, KvStateResponse> serializer = new MessageSerializer<>(new KvStateInternalRequest.KvStateInternalRequestDeserializer(), new KvStateResponse.KvStateResponseDeserializer());
    KvStateServerHandler handler = new KvStateServerHandler(localTestServer, registry, serializer, stats);
    EmbeddedChannel channel = new EmbeddedChannel(getFrameDecoder(), handler);
    int numKeyGroups = 1;
    AbstractStateBackend abstractBackend = new MemoryStateBackend();
    DummyEnvironment dummyEnv = new DummyEnvironment("test", 1, 0);
    dummyEnv.setKvStateRegistry(registry);
    KeyedStateBackend<Integer> backend = createKeyedStateBackend(registry, numKeyGroups, abstractBackend, dummyEnv);
    final TestRegistryListener registryListener = new TestRegistryListener();
    registry.registerListener(dummyEnv.getJobID(), registryListener);
    // Register state
    ValueStateDescriptor<Integer> desc = new ValueStateDescriptor<>("any", IntSerializer.INSTANCE);
    desc.setQueryable("vanilla");
    backend.getPartitionedState(VoidNamespace.INSTANCE, VoidNamespaceSerializer.INSTANCE, desc);
    assertTrue(registryListener.registrationName.equals("vanilla"));
    KvStateInternalRequest request = new KvStateInternalRequest(registryListener.kvStateId, new byte[0]);
    ByteBuf serRequest = MessageSerializer.serializeRequest(channel.alloc(), 282872L, request);
    // Write the request and wait for the response
    channel.writeInbound(serRequest);
    ByteBuf buf = (ByteBuf) readInboundBlocking(channel);
    // skip frame length
    buf.skipBytes(4);
    // Verify the response
    assertEquals(MessageType.REQUEST_FAILURE, MessageSerializer.deserializeHeader(buf));
    RequestFailure response = MessageSerializer.deserializeRequestFailure(buf);
    buf.release();
    assertTrue(response.getCause().getMessage().contains("RejectedExecutionException"));
    assertEquals(1L, stats.getNumRequests());
    assertEquals(1L, stats.getNumFailed());
    localTestServer.shutdown();
}
Also used : KvStateRegistry(org.apache.flink.runtime.query.KvStateRegistry) MessageSerializer(org.apache.flink.queryablestate.network.messages.MessageSerializer) MemoryStateBackend(org.apache.flink.runtime.state.memory.MemoryStateBackend) EmbeddedChannel(org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel) DummyEnvironment(org.apache.flink.runtime.operators.testutils.DummyEnvironment) ByteBuf(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf) KvStateServerImpl(org.apache.flink.queryablestate.server.KvStateServerImpl) ValueStateDescriptor(org.apache.flink.api.common.state.ValueStateDescriptor) KvStateServerHandler(org.apache.flink.queryablestate.server.KvStateServerHandler) KvStateInternalRequest(org.apache.flink.queryablestate.messages.KvStateInternalRequest) KvStateResponse(org.apache.flink.queryablestate.messages.KvStateResponse) RequestFailure(org.apache.flink.queryablestate.network.messages.RequestFailure) DisabledKvStateRequestStats(org.apache.flink.queryablestate.network.stats.DisabledKvStateRequestStats) AtomicKvStateRequestStats(org.apache.flink.queryablestate.network.stats.AtomicKvStateRequestStats) AbstractStateBackend(org.apache.flink.runtime.state.AbstractStateBackend) Test(org.junit.Test)

Example 3 with DisabledKvStateRequestStats

use of org.apache.flink.queryablestate.network.stats.DisabledKvStateRequestStats in project flink by apache.

the class AbstractServerTest method testServerInitializationFailure.

/**
 * Tests that in case of port collision, a FlinkRuntimeException is thrown with a specific
 * message.
 */
@Test
public void testServerInitializationFailure() throws Throwable {
    // the expected exception along with the adequate message
    expectedEx.expect(FlinkRuntimeException.class);
    expectedEx.expectMessage("Unable to start Test Server 2. All ports in provided range are occupied.");
    List<Integer> portList = Collections.singletonList(0);
    try (TestServer server1 = new TestServer("Test Server 1", new DisabledKvStateRequestStats(), portList.iterator())) {
        server1.start();
        try (TestServer server2 = new TestServer("Test Server 2", new DisabledKvStateRequestStats(), Collections.singletonList(server1.getServerAddress().getPort()).iterator())) {
            server2.start();
        }
    }
}
Also used : DisabledKvStateRequestStats(org.apache.flink.queryablestate.network.stats.DisabledKvStateRequestStats) Test(org.junit.Test)

Example 4 with DisabledKvStateRequestStats

use of org.apache.flink.queryablestate.network.stats.DisabledKvStateRequestStats in project flink by apache.

the class KvStateServerHandlerTest method setup.

@BeforeClass
public static void setup() {
    try {
        testServer = new KvStateServerImpl(InetAddress.getLocalHost().getHostName(), Collections.singletonList(0).iterator(), 1, 1, new KvStateRegistry(), new DisabledKvStateRequestStats());
        testServer.start();
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : KvStateServerImpl(org.apache.flink.queryablestate.server.KvStateServerImpl) KvStateRegistry(org.apache.flink.runtime.query.KvStateRegistry) DisabledKvStateRequestStats(org.apache.flink.queryablestate.network.stats.DisabledKvStateRequestStats) BeforeClass(org.junit.BeforeClass)

Aggregations

DisabledKvStateRequestStats (org.apache.flink.queryablestate.network.stats.DisabledKvStateRequestStats)4 KvStateRegistry (org.apache.flink.runtime.query.KvStateRegistry)3 KvStateServerImpl (org.apache.flink.queryablestate.server.KvStateServerImpl)2 Test (org.junit.Test)2 ValueStateDescriptor (org.apache.flink.api.common.state.ValueStateDescriptor)1 KvStateInternalRequest (org.apache.flink.queryablestate.messages.KvStateInternalRequest)1 KvStateResponse (org.apache.flink.queryablestate.messages.KvStateResponse)1 MessageSerializer (org.apache.flink.queryablestate.network.messages.MessageSerializer)1 RequestFailure (org.apache.flink.queryablestate.network.messages.RequestFailure)1 AtomicKvStateRequestStats (org.apache.flink.queryablestate.network.stats.AtomicKvStateRequestStats)1 KvStateServerHandler (org.apache.flink.queryablestate.server.KvStateServerHandler)1 DummyEnvironment (org.apache.flink.runtime.operators.testutils.DummyEnvironment)1 KvStateClientProxy (org.apache.flink.runtime.query.KvStateClientProxy)1 KvStateServer (org.apache.flink.runtime.query.KvStateServer)1 TaskKvStateRegistry (org.apache.flink.runtime.query.TaskKvStateRegistry)1 AbstractStateBackend (org.apache.flink.runtime.state.AbstractStateBackend)1 MemoryStateBackend (org.apache.flink.runtime.state.memory.MemoryStateBackend)1 ByteBuf (org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf)1 EmbeddedChannel (org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel)1 BeforeClass (org.junit.BeforeClass)1