Search in sources :

Example 1 with UnknownOperationKeyException

use of org.apache.flink.runtime.dispatcher.UnknownOperationKeyException in project flink by apache.

the class SavepointHandlersTest method testQueryStatusOfUnknownOperationReturnsError.

@Test
public void testQueryStatusOfUnknownOperationReturnsError() throws HandlerRequestException, RestHandlerException {
    final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder().setGetSavepointStatusFunction(key -> FutureUtils.completedExceptionally(new UnknownOperationKeyException(key))).build();
    final CompletableFuture<AsynchronousOperationResult<SavepointInfo>> statusFuture = savepointStatusHandler.handleRequest(savepointStatusRequest(new TriggerId()), testingRestfulGateway);
    assertThat(statusFuture, RestMatchers.respondsWithError(HttpResponseStatus.NOT_FOUND));
}
Also used : AsynchronousOperationResult(org.apache.flink.runtime.rest.handler.async.AsynchronousOperationResult) TriggerId(org.apache.flink.runtime.rest.messages.TriggerId) SavepointFormatType(org.apache.flink.core.execution.SavepointFormatType) SavepointTestUtilities.setReferenceToOperationKey(org.apache.flink.runtime.rest.handler.job.savepoints.SavepointTestUtilities.setReferenceToOperationKey) QueueStatus(org.apache.flink.runtime.rest.messages.queue.QueueStatus) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) TestingRestfulGateway(org.apache.flink.runtime.webmonitor.TestingRestfulGateway) AtomicReference(java.util.concurrent.atomic.AtomicReference) AsynchronousJobOperationKey(org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey) HttpResponseStatus(org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) TriggerIdPathParameter(org.apache.flink.runtime.rest.messages.TriggerIdPathParameter) Assert.assertThat(org.junit.Assert.assertThat) SavepointTestUtilities.getResultIfKeyMatches(org.apache.flink.runtime.rest.handler.job.savepoints.SavepointTestUtilities.getResultIfKeyMatches) FutureUtils(org.apache.flink.util.concurrent.FutureUtils) Map(java.util.Map) SavepointTriggerRequestBody(org.apache.flink.runtime.rest.messages.job.savepoints.SavepointTriggerRequestBody) TestLogger(org.apache.flink.util.TestLogger) HandlerRequest(org.apache.flink.runtime.rest.handler.HandlerRequest) Assert.fail(org.junit.Assert.fail) SavepointStatusMessageParameters(org.apache.flink.runtime.rest.messages.job.savepoints.SavepointStatusMessageParameters) UnknownOperationKeyException(org.apache.flink.runtime.dispatcher.UnknownOperationKeyException) HandlerRequestException(org.apache.flink.runtime.rest.handler.HandlerRequestException) RestMatchers(org.apache.flink.runtime.rest.RestMatchers) JobIDPathParameter(org.apache.flink.runtime.rest.messages.JobIDPathParameter) Nullable(javax.annotation.Nullable) Before(org.junit.Before) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) OperationResult(org.apache.flink.runtime.rest.handler.async.OperationResult) GatewayRetriever(org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever) SavepointInfo(org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo) RestfulGateway(org.apache.flink.runtime.webmonitor.RestfulGateway) Test(org.junit.Test) Acknowledge(org.apache.flink.runtime.messages.Acknowledge) RestHandlerException(org.apache.flink.runtime.rest.handler.RestHandlerException) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) SavepointTriggerMessageParameters(org.apache.flink.runtime.rest.messages.job.savepoints.SavepointTriggerMessageParameters) JobID(org.apache.flink.api.common.JobID) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Collections(java.util.Collections) Time(org.apache.flink.api.common.time.Time) Assert.assertEquals(org.junit.Assert.assertEquals) UnknownOperationKeyException(org.apache.flink.runtime.dispatcher.UnknownOperationKeyException) AsynchronousOperationResult(org.apache.flink.runtime.rest.handler.async.AsynchronousOperationResult) TriggerId(org.apache.flink.runtime.rest.messages.TriggerId) TestingRestfulGateway(org.apache.flink.runtime.webmonitor.TestingRestfulGateway) Test(org.junit.Test)

Aggregations

Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Nullable (javax.annotation.Nullable)1 JobID (org.apache.flink.api.common.JobID)1 Time (org.apache.flink.api.common.time.Time)1 SavepointFormatType (org.apache.flink.core.execution.SavepointFormatType)1 UnknownOperationKeyException (org.apache.flink.runtime.dispatcher.UnknownOperationKeyException)1 Acknowledge (org.apache.flink.runtime.messages.Acknowledge)1 RestMatchers (org.apache.flink.runtime.rest.RestMatchers)1 HandlerRequest (org.apache.flink.runtime.rest.handler.HandlerRequest)1 HandlerRequestException (org.apache.flink.runtime.rest.handler.HandlerRequestException)1 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)1 AsynchronousOperationResult (org.apache.flink.runtime.rest.handler.async.AsynchronousOperationResult)1 OperationResult (org.apache.flink.runtime.rest.handler.async.OperationResult)1 AsynchronousJobOperationKey (org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey)1 SavepointTestUtilities.getResultIfKeyMatches (org.apache.flink.runtime.rest.handler.job.savepoints.SavepointTestUtilities.getResultIfKeyMatches)1 SavepointTestUtilities.setReferenceToOperationKey (org.apache.flink.runtime.rest.handler.job.savepoints.SavepointTestUtilities.setReferenceToOperationKey)1