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

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

Best Java code snippets using org.apache.flink.queryablestate.network.messages.MessageSerializer.deserializeServerFailure (Showing top 6 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 server failure serialization.
 */
@Test
public void testServerFailureSerialization() throws Exception {
  IllegalStateException cause = new IllegalStateException("Expected test");
  ByteBuf buf = MessageSerializer.serializeServerFailure(alloc, cause);
  int frameLength = buf.readInt();
  assertEquals(MessageType.SERVER_FAILURE, MessageSerializer.deserializeHeader(buf));
  Throwable request = MessageSerializer.deserializeServerFailure(buf);
  assertEquals(buf.readerIndex(), frameLength + 4);
  assertEquals(cause.getClass(), request.getClass());
  assertEquals(cause.getMessage(), request.getMessage());
}
origin: apache/flink

/**
 * Tests that the channel is closed if an Exception reaches the channel handler.
 */
@Test
public void testCloseChannelOnExceptionCaught() 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(handler);
  channel.pipeline().fireExceptionCaught(new RuntimeException("Expected test Exception"));
  ByteBuf buf = (ByteBuf) readInboundBlocking(channel);
  buf.skipBytes(4); // skip frame length
  // Verify the response
  assertEquals(MessageType.SERVER_FAILURE, MessageSerializer.deserializeHeader(buf));
  Throwable response = MessageSerializer.deserializeServerFailure(buf);
  assertTrue(response.getMessage().contains("Expected test Exception"));
  channel.closeFuture().await(READ_TIMEOUT_MILLIS);
  assertFalse(channel.isActive());
}
origin: apache/flink

Throwable response = MessageSerializer.deserializeServerFailure(buf);
response = MessageSerializer.deserializeServerFailure(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.messagesMessageSerializerdeserializeServerFailure

Javadoc

De-serializes the failure message sent to the org.apache.flink.queryablestate.network.Client in case of server 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
  • deserializeRequestFailure
    De-serializes the RequestFailure sent to the org.apache.flink.queryablestate.network.Client in case
  • deserializeResponse
    De-serializes the response sent to the org.apache.flink.queryablestate.network.Client. The buffer i
  • 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

  • Finding current android device location
  • runOnUiThread (Activity)
  • startActivity (Activity)
  • addToBackStack (FragmentTransaction)
  • String (java.lang)
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Github Copilot alternatives
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