Tabnine Logo
MessageSerializer.deserializeRequestFailure
Code IndexAdd Tabnine to your IDE (free)

How to use
deserializeRequestFailure
method
in
org.apache.flink.queryablestate.network.messages.MessageSerializer

Best Java code snippets using org.apache.flink.queryablestate.network.messages.MessageSerializer.deserializeRequestFailure (Showing top 9 results out of 315)

origin: apache/flink

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
  try {
    ByteBuf buf = (ByteBuf) msg;
    MessageType msgType = MessageSerializer.deserializeHeader(buf);
    if (msgType == MessageType.REQUEST_RESULT) {
      long requestId = MessageSerializer.getRequestId(buf);
      RESP result = serializer.deserializeResponse(buf);
      callback.onRequestResult(requestId, result);
    } else if (msgType == MessageType.REQUEST_FAILURE) {
      RequestFailure failure = MessageSerializer.deserializeRequestFailure(buf);
      callback.onRequestFailure(failure.getRequestId(), failure.getCause());
    } else if (msgType == MessageType.SERVER_FAILURE) {
      throw MessageSerializer.deserializeServerFailure(buf);
    } else {
      throw new IllegalStateException("Unexpected response type '" + msgType + "'");
    }
  } catch (Throwable t1) {
    try {
      callback.onFailure(t1);
    } catch (Throwable t2) {
      LOG.error("Failed to notify callback about failure", t2);
    }
  } finally {
    ReferenceCountUtil.release(msg);
  }
}
origin: apache/flink

/**
 * Tests request failure serialization.
 */
@Test
public void testKvStateRequestFailureSerialization() throws Exception {
  long requestId = Integer.MAX_VALUE + 1111222L;
  IllegalStateException cause = new IllegalStateException("Expected test");
  ByteBuf buf = MessageSerializer.serializeRequestFailure(alloc, requestId, cause);
  int frameLength = buf.readInt();
  assertEquals(MessageType.REQUEST_FAILURE, MessageSerializer.deserializeHeader(buf));
  RequestFailure requestFailure = MessageSerializer.deserializeRequestFailure(buf);
  assertEquals(buf.readerIndex(), frameLength + 4);
  assertEquals(requestId, requestFailure.getRequestId());
  assertEquals(cause.getClass(), requestFailure.getCause().getClass());
  assertEquals(cause.getMessage(), requestFailure.getCause().getMessage());
}
origin: apache/flink

RequestFailure response = MessageSerializer.deserializeRequestFailure(buf);
origin: apache/flink

RequestFailure response = MessageSerializer.deserializeRequestFailure(buf);
origin: apache/flink

RequestFailure response = MessageSerializer.deserializeRequestFailure(buf);
assertEquals(182828L, response.getRequestId());
assertTrue(response.getCause().getMessage().contains("IOException"));
response = MessageSerializer.deserializeRequestFailure(buf);
assertEquals(182829L, response.getRequestId());
assertTrue(response.getCause().getMessage().contains("IOException"));
origin: apache/flink

/**
 * Tests the failure response with {@link UnknownKvStateIdException} as cause on
 * queries for unregistered KvStateIDs.
 */
@Test
public void testQueryUnknownKvStateID() throws Exception {
  KvStateRegistry registry = new KvStateRegistry();
  AtomicKvStateRequestStats stats = new AtomicKvStateRequestStats();
  MessageSerializer<KvStateInternalRequest, KvStateResponse> serializer =
      new MessageSerializer<>(new KvStateInternalRequest.KvStateInternalRequestDeserializer(), new KvStateResponse.KvStateResponseDeserializer());
  KvStateServerHandler handler = new KvStateServerHandler(testServer, registry, serializer, stats);
  EmbeddedChannel channel = new EmbeddedChannel(getFrameDecoder(), handler);
  long requestId = Integer.MAX_VALUE + 182828L;
  KvStateInternalRequest request = new KvStateInternalRequest(new KvStateID(), new byte[0]);
  ByteBuf serRequest = MessageSerializer.serializeRequest(channel.alloc(), requestId, request);
  // Write the request and wait for the response
  channel.writeInbound(serRequest);
  ByteBuf buf = (ByteBuf) readInboundBlocking(channel);
  buf.skipBytes(4); // skip frame length
  // Verify the response
  assertEquals(MessageType.REQUEST_FAILURE, MessageSerializer.deserializeHeader(buf));
  RequestFailure response = MessageSerializer.deserializeRequestFailure(buf);
  assertEquals(requestId, response.getRequestId());
  assertTrue("Did not respond with expected failure cause", response.getCause() instanceof UnknownKvStateIdException);
  assertEquals(1L, stats.getNumRequests());
  assertEquals(1L, stats.getNumFailed());
}
origin: apache/flink

RequestFailure response = MessageSerializer.deserializeRequestFailure(buf);
origin: org.apache.flink/flink-queryable-state-client-java_2.11

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
  try {
    ByteBuf buf = (ByteBuf) msg;
    MessageType msgType = MessageSerializer.deserializeHeader(buf);
    if (msgType == MessageType.REQUEST_RESULT) {
      long requestId = MessageSerializer.getRequestId(buf);
      RESP result = serializer.deserializeResponse(buf);
      callback.onRequestResult(requestId, result);
    } else if (msgType == MessageType.REQUEST_FAILURE) {
      RequestFailure failure = MessageSerializer.deserializeRequestFailure(buf);
      callback.onRequestFailure(failure.getRequestId(), failure.getCause());
    } else if (msgType == MessageType.SERVER_FAILURE) {
      throw MessageSerializer.deserializeServerFailure(buf);
    } else {
      throw new IllegalStateException("Unexpected response type '" + msgType + "'");
    }
  } catch (Throwable t1) {
    try {
      callback.onFailure(t1);
    } catch (Throwable t2) {
      LOG.error("Failed to notify callback about failure", t2);
    }
  } finally {
    ReferenceCountUtil.release(msg);
  }
}
origin: com.alibaba.blink/flink-queryable-state-client-java

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
  try {
    ByteBuf buf = (ByteBuf) msg;
    MessageType msgType = MessageSerializer.deserializeHeader(buf);
    if (msgType == MessageType.REQUEST_RESULT) {
      long requestId = MessageSerializer.getRequestId(buf);
      RESP result = serializer.deserializeResponse(buf);
      callback.onRequestResult(requestId, result);
    } else if (msgType == MessageType.REQUEST_FAILURE) {
      RequestFailure failure = MessageSerializer.deserializeRequestFailure(buf);
      callback.onRequestFailure(failure.getRequestId(), failure.getCause());
    } else if (msgType == MessageType.SERVER_FAILURE) {
      throw MessageSerializer.deserializeServerFailure(buf);
    } else {
      throw new IllegalStateException("Unexpected response type '" + msgType + "'");
    }
  } catch (Throwable t1) {
    try {
      callback.onFailure(t1);
    } catch (Throwable t2) {
      LOG.error("Failed to notify callback about failure", t2);
    }
  } finally {
    ReferenceCountUtil.release(msg);
  }
}
org.apache.flink.queryablestate.network.messagesMessageSerializerdeserializeRequestFailure

Javadoc

De-serializes the RequestFailure sent to the org.apache.flink.queryablestate.network.Client in case of protocol related errors.
 
The buffer is expected to be at the correct position. 

Popular methods of MessageSerializer

  • <init>
  • deserializeHeader
    De-serializes the header and returns the MessageType. The buffer is expected to be at the header po
  • deserializeRequest
    De-serializes the request sent to the org.apache.flink.queryablestate.network.AbstractServerBase. T
  • deserializeResponse
    De-serializes the response sent to the org.apache.flink.queryablestate.network.Client. The buffer i
  • deserializeServerFailure
    De-serializes the failure message sent to the org.apache.flink.queryablestate.network.Client in case
  • getRequestId
    De-serializes the header and returns the MessageType. The buffer is expected to be at the request i
  • serializeRequestFailure
    Serializes the exception containing the failure message sent to the org.apache.flink.queryablestate.
  • serializeResponse
    Serializes the response sent to the org.apache.flink.queryablestate.network.Client.
  • serializeServerFailure
    Serializes the failure message sent to the org.apache.flink.queryablestate.network.Client in case of
  • writeHeader
    Helper for serializing the header.
  • writePayload
    Helper for serializing the messages.
  • serializeRequest
    Serializes the request sent to the org.apache.flink.queryablestate.network.AbstractServerBase.
  • writePayload,
  • serializeRequest

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSharedPreferences (Context)
  • getResourceAsStream (ClassLoader)
  • getSupportFragmentManager (FragmentActivity)
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Runner (org.openjdk.jmh.runner)
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now