Java Code Examples for org.apache.calcite.avatica.remote.Driver#Serialization

The following examples show how to use org.apache.calcite.avatica.remote.Driver#Serialization . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HandlerFactory.java    From calcite-avatica with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs the desired implementation for the given serialization method and server
 * configuration with metrics.
 *
 * @param service The underlying {@link Service}
 * @param serialization The serializatio mechanism to use
 * @param metricsConfig Configuration for the {@link MetricsSystem}.
 * @param serverConfig Avatica server configuration or null
 * @return An {@link AvaticaHandler}
 */
public AvaticaHandler getHandler(Service service, Driver.Serialization serialization,
    MetricsSystemConfiguration<?> metricsConfig, AvaticaServerConfiguration serverConfig) {
  if (null == metricsConfig) {
    metricsConfig = NoopMetricsSystemConfiguration.getInstance();
  }
  MetricsSystem metrics = MetricsSystemLoader.load(metricsConfig);

  switch (serialization) {
  case JSON:
    return new AvaticaJsonHandler(service, metrics, serverConfig);
  case PROTOBUF:
    return new AvaticaProtobufHandler(service, metrics, serverConfig);
  default:
    throw new IllegalArgumentException("Unknown Avatica handler for " + serialization.name());
  }
}
 
Example 2
Source File: Main.java    From quark with Apache License 2.0 6 votes vote down vote up
/**
 * Instantiates the Handler for use by the Avatica (Jetty) server.
 *
 * @param service The Avatica Service implementation
 * @param handlerFactory Factory used for creating a Handler
 * @return The Handler to use.
 */
Handler getHandler(Service service, HandlerFactory handlerFactory) {
  String serializationName = "PROTOBUF";
  Driver.Serialization serialization;
  try {
    serialization = Driver.Serialization.valueOf(serializationName);
  } catch (Exception e) {
    LOG.error("Unknown message serialization type for " + serializationName);
    throw e;
  }

  Handler handler = handlerFactory.getHandler(service, serialization);
  LOG.info("Instantiated " + handler.getClass() + " for Quark Server");

  return handler;
}
 
Example 3
Source File: HandlerFactory.java    From calcite-avatica with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs the desired implementation for the given serialization method with metrics.
 *
 * @param service The underlying {@link Service}.
 * @param serialization The desired message serialization.
 * @return The {@link AvaticaHandler}.
 */
public AvaticaHandler getHandler(Service service, Driver.Serialization serialization) {
  return getHandler(service, serialization, NoopMetricsSystemConfiguration.getInstance());
}
 
Example 4
Source File: HandlerFactory.java    From calcite-avatica with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs the desired implementation for the given serialization method and server
 * configuration with metrics.
 *
 * @param service The underlying {@link Service}.
 * @param serialization The desired message serialization.
 * @param serverConfig Avatica server configuration or null.
 * @return The {@link AvaticaHandler}.
 */
public AvaticaHandler getHandler(Service service, Driver.Serialization serialization,
    AvaticaServerConfiguration serverConfig) {
  return getHandler(service, serialization, NoopMetricsSystemConfiguration.getInstance(),
      serverConfig);
}
 
Example 5
Source File: HandlerFactory.java    From calcite-avatica with Apache License 2.0 2 votes vote down vote up
/**
 * Constructs the desired implementation for the given serialization method with metrics.
 *
 * @param service The underlying {@link Service}.
 * @param serialization The desired message serialization.
 * @param metricsConfig Configuration for the {@link MetricsSystem}.
 * @return The {@link AvaticaHandler}.
 */
public AvaticaHandler getHandler(Service service, Driver.Serialization serialization,
    MetricsSystemConfiguration<?> metricsConfig) {
  return getHandler(service, serialization, metricsConfig, null);
}