@Test public void getFragmentMetadata() { RequestContext context = parser.parseRequest(mockRequestHeaders, RequestType.FRAGMENTER); byte[] location = context.getFragmentMetadata(); assertEquals("Something in the way", new String(location)); }
@Override public RequestContext parseRequest(HttpHeaders request, RequestContext.RequestType requestType) { RequestMap params = new RequestMap(request.getRequestHeaders()); if (LOG.isDebugEnabled()) { LOG.debug("Parsing request parameters: " + params.keySet()); } RequestContext context = new RequestContext(); context.setRequestType(requestType); String profile = params.removeUserProperty("PROFILE"); context.setProfile(profile); addProfilePlugins(profile, params); String wireFormat = params.removeProperty("FORMAT"); context.setOutputFormat(OutputFormat.valueOf(wireFormat)); String format = params.removeUserProperty("FORMAT"); format = StringUtils.isNotBlank(format) ? format : context.inferFormatName(); context.setFormat(format); context.setAccessor(params.removeUserProperty("ACCESSOR")); context.setAggType(EnumAggregationType.getAggregationType(params.removeOptionalProperty("AGG-TYPE"))); String fragmentStr = params.removeOptionalProperty("DATA-FRAGMENT"); if (StringUtils.isNotBlank(fragmentStr)) { context.setDataFragment(Integer.parseInt(fragmentStr)); } context.setDataSource(params.removeProperty("DATA-DIR")); String filterString = params.removeOptionalProperty("FILTER"); String hasFilter = params.removeProperty("HAS-FILTER"); if (filterString != null) { context.setFilterString(filterString); } else if ("1".equals(hasFilter)) { LOG.info("Original query has filter, but it was not propagated to PXF"); } context.setFragmenter(params.removeUserProperty("FRAGMENTER")); String fragmentIndexStr = params.removeOptionalProperty("FRAGMENT-INDEX"); if (StringUtils.isNotBlank(fragmentIndexStr)) { context.setFragmentIndex(Integer.parseInt(fragmentIndexStr)); } String encodedFragmentMetadata = params.removeOptionalProperty("FRAGMENT-METADATA"); context.setFragmentMetadata(Utilities.parseBase64(encodedFragmentMetadata, "Fragment metadata information")); context.setHost(params.removeProperty("URL-HOST")); context.setMetadata(params.removeUserProperty("METADATA")); context.setPort(params.removeIntProperty("URL-PORT")); context.setProfileScheme(params.removeUserProperty(PROFILE_SCHEME)); context.setProtocol(params.removeUserProperty("PROTOCOL")); context.setRemoteLogin(params.removeOptionalProperty("REMOTE-USER")); context.setRemoteSecret(params.removeOptionalProperty("REMOTE-PASS")); context.setResolver(params.removeUserProperty("RESOLVER")); context.setSegmentId(params.removeIntProperty("SEGMENT-ID")); context.setServerName(params.removeUserProperty("SERVER")); String config = params.removeUserProperty("CONFIG"); context.setConfig(StringUtils.isNotBlank(config) ? config : context.getServerName()); String maxFrags = params.removeUserProperty("STATS-MAX-FRAGMENTS"); if (!StringUtils.isBlank(maxFrags)) { context.setStatsMaxFragments(Integer.parseInt(maxFrags)); } String sampleRatioStr = params.removeUserProperty("STATS-SAMPLE-RATIO"); if (!StringUtils.isBlank(sampleRatioStr)) { context.setStatsSampleRatio(Float.parseFloat(sampleRatioStr)); } context.setTotalSegments(params.removeIntProperty("SEGMENT-COUNT")); context.setTransactionId(params.removeProperty("XID")); parseTupleDescription(params, context); if (context.getOutputFormat() == OutputFormat.TEXT) { parseGreenplumCSV(params, context); if (context.getTupleDescription().size() != 1 && context.getGreenplumCSV().getDelimiter() == null) { throw new IllegalArgumentException(String.format("using no delimiter is only possible for a single column table. %d columns found", context.getTupleDescription().size())); } } context.setUser(params.removeProperty("USER")); String encodedFragmentUserData = params.removeOptionalProperty("FRAGMENT-USER-DATA"); context.setUserData(Utilities.parseBase64(encodedFragmentUserData, "Fragment user data")); System.setProperty("greenplum.alignment", params.removeProperty("ALIGNMENT")); Map<String, String> optionMappings = null; if (StringUtils.isNotBlank(profile)) { optionMappings = pluginConf.getOptionMappings(profile); } if (optionMappings == null) { optionMappings = Collections.emptyMap(); } Map<String, String> additionalConfigProps = new HashMap<>(); List<String> paramNames = new ArrayList<>(params.keySet()); for (String param : paramNames) { if (StringUtils.startsWithIgnoreCase(param, RequestMap.USER_PROP_PREFIX)) { String optionName = param.toLowerCase().replace(RequestMap.USER_PROP_PREFIX_LOWERCASE, ""); String optionValue = params.removeUserProperty(optionName); context.addOption(optionName, optionValue); LOG.debug("Added option {} to request context", optionName); String propertyName = optionMappings.get(optionName); if (StringUtils.isNotBlank(propertyName)) { if (optionValue != null) { additionalConfigProps.put(propertyName, optionValue); LOG.debug("Added extra config property {} from option {}", propertyName, optionName); } } } else if (StringUtils.startsWithIgnoreCase(param, RequestMap.PROP_PREFIX)) { LOG.debug("Unused property {}", param); } } context.setAdditionalConfigProps(additionalConfigProps); context.setPluginConf(pluginConf); if (StringUtils.isNotBlank(profile)) { String handlerClassName = pluginConf.getHandler(profile); if (StringUtils.isNotBlank(handlerClassName)) { Class<?> clazz; try { clazz = Class.forName(handlerClassName); ProtocolHandler handler = (ProtocolHandler) clazz.getDeclaredConstructor().newInstance(); context.setFragmenter(handler.getFragmenterClassName(context)); context.setAccessor(handler.getAccessorClassName(context)); context.setResolver(handler.getResolverClassName(context)); } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(String.format("Error when invoking handlerClass '%s' : %s", handlerClassName, e), e); } } } context.validate(); return context; }
HttpRequestParser implements RequestParser<HttpHeaders> { @Override public RequestContext parseRequest(HttpHeaders request, RequestContext.RequestType requestType) { RequestMap params = new RequestMap(request.getRequestHeaders()); if (LOG.isDebugEnabled()) { LOG.debug("Parsing request parameters: " + params.keySet()); } RequestContext context = new RequestContext(); context.setRequestType(requestType); String profile = params.removeUserProperty("PROFILE"); context.setProfile(profile); addProfilePlugins(profile, params); String wireFormat = params.removeProperty("FORMAT"); context.setOutputFormat(OutputFormat.valueOf(wireFormat)); String format = params.removeUserProperty("FORMAT"); format = StringUtils.isNotBlank(format) ? format : context.inferFormatName(); context.setFormat(format); context.setAccessor(params.removeUserProperty("ACCESSOR")); context.setAggType(EnumAggregationType.getAggregationType(params.removeOptionalProperty("AGG-TYPE"))); String fragmentStr = params.removeOptionalProperty("DATA-FRAGMENT"); if (StringUtils.isNotBlank(fragmentStr)) { context.setDataFragment(Integer.parseInt(fragmentStr)); } context.setDataSource(params.removeProperty("DATA-DIR")); String filterString = params.removeOptionalProperty("FILTER"); String hasFilter = params.removeProperty("HAS-FILTER"); if (filterString != null) { context.setFilterString(filterString); } else if ("1".equals(hasFilter)) { LOG.info("Original query has filter, but it was not propagated to PXF"); } context.setFragmenter(params.removeUserProperty("FRAGMENTER")); String fragmentIndexStr = params.removeOptionalProperty("FRAGMENT-INDEX"); if (StringUtils.isNotBlank(fragmentIndexStr)) { context.setFragmentIndex(Integer.parseInt(fragmentIndexStr)); } String encodedFragmentMetadata = params.removeOptionalProperty("FRAGMENT-METADATA"); context.setFragmentMetadata(Utilities.parseBase64(encodedFragmentMetadata, "Fragment metadata information")); context.setHost(params.removeProperty("URL-HOST")); context.setMetadata(params.removeUserProperty("METADATA")); context.setPort(params.removeIntProperty("URL-PORT")); context.setProfileScheme(params.removeUserProperty(PROFILE_SCHEME)); context.setProtocol(params.removeUserProperty("PROTOCOL")); context.setRemoteLogin(params.removeOptionalProperty("REMOTE-USER")); context.setRemoteSecret(params.removeOptionalProperty("REMOTE-PASS")); context.setResolver(params.removeUserProperty("RESOLVER")); context.setSegmentId(params.removeIntProperty("SEGMENT-ID")); context.setServerName(params.removeUserProperty("SERVER")); String config = params.removeUserProperty("CONFIG"); context.setConfig(StringUtils.isNotBlank(config) ? config : context.getServerName()); String maxFrags = params.removeUserProperty("STATS-MAX-FRAGMENTS"); if (!StringUtils.isBlank(maxFrags)) { context.setStatsMaxFragments(Integer.parseInt(maxFrags)); } String sampleRatioStr = params.removeUserProperty("STATS-SAMPLE-RATIO"); if (!StringUtils.isBlank(sampleRatioStr)) { context.setStatsSampleRatio(Float.parseFloat(sampleRatioStr)); } context.setTotalSegments(params.removeIntProperty("SEGMENT-COUNT")); context.setTransactionId(params.removeProperty("XID")); parseTupleDescription(params, context); if (context.getOutputFormat() == OutputFormat.TEXT) { parseGreenplumCSV(params, context); if (context.getTupleDescription().size() != 1 && context.getGreenplumCSV().getDelimiter() == null) { throw new IllegalArgumentException(String.format("using no delimiter is only possible for a single column table. %d columns found", context.getTupleDescription().size())); } } context.setUser(params.removeProperty("USER")); String encodedFragmentUserData = params.removeOptionalProperty("FRAGMENT-USER-DATA"); context.setUserData(Utilities.parseBase64(encodedFragmentUserData, "Fragment user data")); System.setProperty("greenplum.alignment", params.removeProperty("ALIGNMENT")); Map<String, String> optionMappings = null; if (StringUtils.isNotBlank(profile)) { optionMappings = pluginConf.getOptionMappings(profile); } if (optionMappings == null) { optionMappings = Collections.emptyMap(); } Map<String, String> additionalConfigProps = new HashMap<>(); List<String> paramNames = new ArrayList<>(params.keySet()); for (String param : paramNames) { if (StringUtils.startsWithIgnoreCase(param, RequestMap.USER_PROP_PREFIX)) { String optionName = param.toLowerCase().replace(RequestMap.USER_PROP_PREFIX_LOWERCASE, ""); String optionValue = params.removeUserProperty(optionName); context.addOption(optionName, optionValue); LOG.debug("Added option {} to request context", optionName); String propertyName = optionMappings.get(optionName); if (StringUtils.isNotBlank(propertyName)) { if (optionValue != null) { additionalConfigProps.put(propertyName, optionValue); LOG.debug("Added extra config property {} from option {}", propertyName, optionName); } } } else if (StringUtils.startsWithIgnoreCase(param, RequestMap.PROP_PREFIX)) { LOG.debug("Unused property {}", param); } } context.setAdditionalConfigProps(additionalConfigProps); context.setPluginConf(pluginConf); if (StringUtils.isNotBlank(profile)) { String handlerClassName = pluginConf.getHandler(profile); if (StringUtils.isNotBlank(handlerClassName)) { Class<?> clazz; try { clazz = Class.forName(handlerClassName); ProtocolHandler handler = (ProtocolHandler) clazz.getDeclaredConstructor().newInstance(); context.setFragmenter(handler.getFragmenterClassName(context)); context.setAccessor(handler.getAccessorClassName(context)); context.setResolver(handler.getResolverClassName(context)); } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(String.format("Error when invoking handlerClass '%s' : %s", handlerClassName, e), e); } } } context.validate(); return context; } }
HttpRequestParser implements RequestParser<HttpHeaders> { @Override public RequestContext parseRequest(HttpHeaders request, RequestContext.RequestType requestType) { RequestMap params = new RequestMap(request.getRequestHeaders()); if (LOG.isDebugEnabled()) { LOG.debug("Parsing request parameters: " + params.keySet()); } RequestContext context = new RequestContext(); context.setRequestType(requestType); String profile = params.removeUserProperty("PROFILE"); context.setProfile(profile); addProfilePlugins(profile, params); String wireFormat = params.removeProperty("FORMAT"); context.setOutputFormat(OutputFormat.valueOf(wireFormat)); String format = params.removeUserProperty("FORMAT"); format = StringUtils.isNotBlank(format) ? format : context.inferFormatName(); context.setFormat(format); context.setAccessor(params.removeUserProperty("ACCESSOR")); context.setAggType(EnumAggregationType.getAggregationType(params.removeOptionalProperty("AGG-TYPE"))); String fragmentStr = params.removeOptionalProperty("DATA-FRAGMENT"); if (StringUtils.isNotBlank(fragmentStr)) { context.setDataFragment(Integer.parseInt(fragmentStr)); } context.setDataSource(params.removeProperty("DATA-DIR")); String filterString = params.removeOptionalProperty("FILTER"); String hasFilter = params.removeProperty("HAS-FILTER"); if (filterString != null) { context.setFilterString(filterString); } else if ("1".equals(hasFilter)) { LOG.info("Original query has filter, but it was not propagated to PXF"); } context.setFragmenter(params.removeUserProperty("FRAGMENTER")); String fragmentIndexStr = params.removeOptionalProperty("FRAGMENT-INDEX"); if (StringUtils.isNotBlank(fragmentIndexStr)) { context.setFragmentIndex(Integer.parseInt(fragmentIndexStr)); } String encodedFragmentMetadata = params.removeOptionalProperty("FRAGMENT-METADATA"); context.setFragmentMetadata(Utilities.parseBase64(encodedFragmentMetadata, "Fragment metadata information")); context.setHost(params.removeProperty("URL-HOST")); context.setMetadata(params.removeUserProperty("METADATA")); context.setPort(params.removeIntProperty("URL-PORT")); context.setProfileScheme(params.removeUserProperty(PROFILE_SCHEME)); context.setProtocol(params.removeUserProperty("PROTOCOL")); context.setRemoteLogin(params.removeOptionalProperty("REMOTE-USER")); context.setRemoteSecret(params.removeOptionalProperty("REMOTE-PASS")); context.setResolver(params.removeUserProperty("RESOLVER")); context.setSegmentId(params.removeIntProperty("SEGMENT-ID")); context.setServerName(params.removeUserProperty("SERVER")); String config = params.removeUserProperty("CONFIG"); context.setConfig(StringUtils.isNotBlank(config) ? config : context.getServerName()); String maxFrags = params.removeUserProperty("STATS-MAX-FRAGMENTS"); if (!StringUtils.isBlank(maxFrags)) { context.setStatsMaxFragments(Integer.parseInt(maxFrags)); } String sampleRatioStr = params.removeUserProperty("STATS-SAMPLE-RATIO"); if (!StringUtils.isBlank(sampleRatioStr)) { context.setStatsSampleRatio(Float.parseFloat(sampleRatioStr)); } context.setTotalSegments(params.removeIntProperty("SEGMENT-COUNT")); context.setTransactionId(params.removeProperty("XID")); parseTupleDescription(params, context); if (context.getOutputFormat() == OutputFormat.TEXT) { parseGreenplumCSV(params, context); if (context.getTupleDescription().size() != 1 && context.getGreenplumCSV().getDelimiter() == null) { throw new IllegalArgumentException(String.format("using no delimiter is only possible for a single column table. %d columns found", context.getTupleDescription().size())); } } context.setUser(params.removeProperty("USER")); String encodedFragmentUserData = params.removeOptionalProperty("FRAGMENT-USER-DATA"); context.setUserData(Utilities.parseBase64(encodedFragmentUserData, "Fragment user data")); System.setProperty("greenplum.alignment", params.removeProperty("ALIGNMENT")); Map<String, String> optionMappings = null; if (StringUtils.isNotBlank(profile)) { optionMappings = pluginConf.getOptionMappings(profile); } if (optionMappings == null) { optionMappings = Collections.emptyMap(); } Map<String, String> additionalConfigProps = new HashMap<>(); List<String> paramNames = new ArrayList<>(params.keySet()); for (String param : paramNames) { if (StringUtils.startsWithIgnoreCase(param, RequestMap.USER_PROP_PREFIX)) { String optionName = param.toLowerCase().replace(RequestMap.USER_PROP_PREFIX_LOWERCASE, ""); String optionValue = params.removeUserProperty(optionName); context.addOption(optionName, optionValue); LOG.debug("Added option {} to request context", optionName); String propertyName = optionMappings.get(optionName); if (StringUtils.isNotBlank(propertyName)) { if (optionValue != null) { additionalConfigProps.put(propertyName, optionValue); LOG.debug("Added extra config property {} from option {}", propertyName, optionName); } } } else if (StringUtils.startsWithIgnoreCase(param, RequestMap.PROP_PREFIX)) { LOG.debug("Unused property {}", param); } } context.setAdditionalConfigProps(additionalConfigProps); context.setPluginConf(pluginConf); if (StringUtils.isNotBlank(profile)) { String handlerClassName = pluginConf.getHandler(profile); if (StringUtils.isNotBlank(handlerClassName)) { Class<?> clazz; try { clazz = Class.forName(handlerClassName); ProtocolHandler handler = (ProtocolHandler) clazz.getDeclaredConstructor().newInstance(); context.setFragmenter(handler.getFragmenterClassName(context)); context.setAccessor(handler.getAccessorClassName(context)); context.setResolver(handler.getResolverClassName(context)); } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(String.format("Error when invoking handlerClass '%s' : %s", handlerClassName, e), e); } } } context.validate(); return context; } HttpRequestParser();   HttpRequestParser(PluginConf pluginConf); }
HttpRequestParser implements RequestParser<HttpHeaders> { @Override public RequestContext parseRequest(HttpHeaders request, RequestContext.RequestType requestType) { RequestMap params = new RequestMap(request.getRequestHeaders()); if (LOG.isDebugEnabled()) { LOG.debug("Parsing request parameters: " + params.keySet()); } RequestContext context = new RequestContext(); context.setRequestType(requestType); String profile = params.removeUserProperty("PROFILE"); context.setProfile(profile); addProfilePlugins(profile, params); String wireFormat = params.removeProperty("FORMAT"); context.setOutputFormat(OutputFormat.valueOf(wireFormat)); String format = params.removeUserProperty("FORMAT"); format = StringUtils.isNotBlank(format) ? format : context.inferFormatName(); context.setFormat(format); context.setAccessor(params.removeUserProperty("ACCESSOR")); context.setAggType(EnumAggregationType.getAggregationType(params.removeOptionalProperty("AGG-TYPE"))); String fragmentStr = params.removeOptionalProperty("DATA-FRAGMENT"); if (StringUtils.isNotBlank(fragmentStr)) { context.setDataFragment(Integer.parseInt(fragmentStr)); } context.setDataSource(params.removeProperty("DATA-DIR")); String filterString = params.removeOptionalProperty("FILTER"); String hasFilter = params.removeProperty("HAS-FILTER"); if (filterString != null) { context.setFilterString(filterString); } else if ("1".equals(hasFilter)) { LOG.info("Original query has filter, but it was not propagated to PXF"); } context.setFragmenter(params.removeUserProperty("FRAGMENTER")); String fragmentIndexStr = params.removeOptionalProperty("FRAGMENT-INDEX"); if (StringUtils.isNotBlank(fragmentIndexStr)) { context.setFragmentIndex(Integer.parseInt(fragmentIndexStr)); } String encodedFragmentMetadata = params.removeOptionalProperty("FRAGMENT-METADATA"); context.setFragmentMetadata(Utilities.parseBase64(encodedFragmentMetadata, "Fragment metadata information")); context.setHost(params.removeProperty("URL-HOST")); context.setMetadata(params.removeUserProperty("METADATA")); context.setPort(params.removeIntProperty("URL-PORT")); context.setProfileScheme(params.removeUserProperty(PROFILE_SCHEME)); context.setProtocol(params.removeUserProperty("PROTOCOL")); context.setRemoteLogin(params.removeOptionalProperty("REMOTE-USER")); context.setRemoteSecret(params.removeOptionalProperty("REMOTE-PASS")); context.setResolver(params.removeUserProperty("RESOLVER")); context.setSegmentId(params.removeIntProperty("SEGMENT-ID")); context.setServerName(params.removeUserProperty("SERVER")); String config = params.removeUserProperty("CONFIG"); context.setConfig(StringUtils.isNotBlank(config) ? config : context.getServerName()); String maxFrags = params.removeUserProperty("STATS-MAX-FRAGMENTS"); if (!StringUtils.isBlank(maxFrags)) { context.setStatsMaxFragments(Integer.parseInt(maxFrags)); } String sampleRatioStr = params.removeUserProperty("STATS-SAMPLE-RATIO"); if (!StringUtils.isBlank(sampleRatioStr)) { context.setStatsSampleRatio(Float.parseFloat(sampleRatioStr)); } context.setTotalSegments(params.removeIntProperty("SEGMENT-COUNT")); context.setTransactionId(params.removeProperty("XID")); parseTupleDescription(params, context); if (context.getOutputFormat() == OutputFormat.TEXT) { parseGreenplumCSV(params, context); if (context.getTupleDescription().size() != 1 && context.getGreenplumCSV().getDelimiter() == null) { throw new IllegalArgumentException(String.format("using no delimiter is only possible for a single column table. %d columns found", context.getTupleDescription().size())); } } context.setUser(params.removeProperty("USER")); String encodedFragmentUserData = params.removeOptionalProperty("FRAGMENT-USER-DATA"); context.setUserData(Utilities.parseBase64(encodedFragmentUserData, "Fragment user data")); System.setProperty("greenplum.alignment", params.removeProperty("ALIGNMENT")); Map<String, String> optionMappings = null; if (StringUtils.isNotBlank(profile)) { optionMappings = pluginConf.getOptionMappings(profile); } if (optionMappings == null) { optionMappings = Collections.emptyMap(); } Map<String, String> additionalConfigProps = new HashMap<>(); List<String> paramNames = new ArrayList<>(params.keySet()); for (String param : paramNames) { if (StringUtils.startsWithIgnoreCase(param, RequestMap.USER_PROP_PREFIX)) { String optionName = param.toLowerCase().replace(RequestMap.USER_PROP_PREFIX_LOWERCASE, ""); String optionValue = params.removeUserProperty(optionName); context.addOption(optionName, optionValue); LOG.debug("Added option {} to request context", optionName); String propertyName = optionMappings.get(optionName); if (StringUtils.isNotBlank(propertyName)) { if (optionValue != null) { additionalConfigProps.put(propertyName, optionValue); LOG.debug("Added extra config property {} from option {}", propertyName, optionName); } } } else if (StringUtils.startsWithIgnoreCase(param, RequestMap.PROP_PREFIX)) { LOG.debug("Unused property {}", param); } } context.setAdditionalConfigProps(additionalConfigProps); context.setPluginConf(pluginConf); if (StringUtils.isNotBlank(profile)) { String handlerClassName = pluginConf.getHandler(profile); if (StringUtils.isNotBlank(handlerClassName)) { Class<?> clazz; try { clazz = Class.forName(handlerClassName); ProtocolHandler handler = (ProtocolHandler) clazz.getDeclaredConstructor().newInstance(); context.setFragmenter(handler.getFragmenterClassName(context)); context.setAccessor(handler.getAccessorClassName(context)); context.setResolver(handler.getResolverClassName(context)); } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(String.format("Error when invoking handlerClass '%s' : %s", handlerClassName, e), e); } } } context.validate(); return context; } HttpRequestParser();   HttpRequestParser(PluginConf pluginConf); static HttpRequestParser getInstance(); @Override RequestContext parseRequest(HttpHeaders request, RequestContext.RequestType requestType); }
HttpRequestParser implements RequestParser<HttpHeaders> { @Override public RequestContext parseRequest(HttpHeaders request, RequestContext.RequestType requestType) { RequestMap params = new RequestMap(request.getRequestHeaders()); if (LOG.isDebugEnabled()) { LOG.debug("Parsing request parameters: " + params.keySet()); } RequestContext context = new RequestContext(); context.setRequestType(requestType); String profile = params.removeUserProperty("PROFILE"); context.setProfile(profile); addProfilePlugins(profile, params); String wireFormat = params.removeProperty("FORMAT"); context.setOutputFormat(OutputFormat.valueOf(wireFormat)); String format = params.removeUserProperty("FORMAT"); format = StringUtils.isNotBlank(format) ? format : context.inferFormatName(); context.setFormat(format); context.setAccessor(params.removeUserProperty("ACCESSOR")); context.setAggType(EnumAggregationType.getAggregationType(params.removeOptionalProperty("AGG-TYPE"))); String fragmentStr = params.removeOptionalProperty("DATA-FRAGMENT"); if (StringUtils.isNotBlank(fragmentStr)) { context.setDataFragment(Integer.parseInt(fragmentStr)); } context.setDataSource(params.removeProperty("DATA-DIR")); String filterString = params.removeOptionalProperty("FILTER"); String hasFilter = params.removeProperty("HAS-FILTER"); if (filterString != null) { context.setFilterString(filterString); } else if ("1".equals(hasFilter)) { LOG.info("Original query has filter, but it was not propagated to PXF"); } context.setFragmenter(params.removeUserProperty("FRAGMENTER")); String fragmentIndexStr = params.removeOptionalProperty("FRAGMENT-INDEX"); if (StringUtils.isNotBlank(fragmentIndexStr)) { context.setFragmentIndex(Integer.parseInt(fragmentIndexStr)); } String encodedFragmentMetadata = params.removeOptionalProperty("FRAGMENT-METADATA"); context.setFragmentMetadata(Utilities.parseBase64(encodedFragmentMetadata, "Fragment metadata information")); context.setHost(params.removeProperty("URL-HOST")); context.setMetadata(params.removeUserProperty("METADATA")); context.setPort(params.removeIntProperty("URL-PORT")); context.setProfileScheme(params.removeUserProperty(PROFILE_SCHEME)); context.setProtocol(params.removeUserProperty("PROTOCOL")); context.setRemoteLogin(params.removeOptionalProperty("REMOTE-USER")); context.setRemoteSecret(params.removeOptionalProperty("REMOTE-PASS")); context.setResolver(params.removeUserProperty("RESOLVER")); context.setSegmentId(params.removeIntProperty("SEGMENT-ID")); context.setServerName(params.removeUserProperty("SERVER")); String config = params.removeUserProperty("CONFIG"); context.setConfig(StringUtils.isNotBlank(config) ? config : context.getServerName()); String maxFrags = params.removeUserProperty("STATS-MAX-FRAGMENTS"); if (!StringUtils.isBlank(maxFrags)) { context.setStatsMaxFragments(Integer.parseInt(maxFrags)); } String sampleRatioStr = params.removeUserProperty("STATS-SAMPLE-RATIO"); if (!StringUtils.isBlank(sampleRatioStr)) { context.setStatsSampleRatio(Float.parseFloat(sampleRatioStr)); } context.setTotalSegments(params.removeIntProperty("SEGMENT-COUNT")); context.setTransactionId(params.removeProperty("XID")); parseTupleDescription(params, context); if (context.getOutputFormat() == OutputFormat.TEXT) { parseGreenplumCSV(params, context); if (context.getTupleDescription().size() != 1 && context.getGreenplumCSV().getDelimiter() == null) { throw new IllegalArgumentException(String.format("using no delimiter is only possible for a single column table. %d columns found", context.getTupleDescription().size())); } } context.setUser(params.removeProperty("USER")); String encodedFragmentUserData = params.removeOptionalProperty("FRAGMENT-USER-DATA"); context.setUserData(Utilities.parseBase64(encodedFragmentUserData, "Fragment user data")); System.setProperty("greenplum.alignment", params.removeProperty("ALIGNMENT")); Map<String, String> optionMappings = null; if (StringUtils.isNotBlank(profile)) { optionMappings = pluginConf.getOptionMappings(profile); } if (optionMappings == null) { optionMappings = Collections.emptyMap(); } Map<String, String> additionalConfigProps = new HashMap<>(); List<String> paramNames = new ArrayList<>(params.keySet()); for (String param : paramNames) { if (StringUtils.startsWithIgnoreCase(param, RequestMap.USER_PROP_PREFIX)) { String optionName = param.toLowerCase().replace(RequestMap.USER_PROP_PREFIX_LOWERCASE, ""); String optionValue = params.removeUserProperty(optionName); context.addOption(optionName, optionValue); LOG.debug("Added option {} to request context", optionName); String propertyName = optionMappings.get(optionName); if (StringUtils.isNotBlank(propertyName)) { if (optionValue != null) { additionalConfigProps.put(propertyName, optionValue); LOG.debug("Added extra config property {} from option {}", propertyName, optionName); } } } else if (StringUtils.startsWithIgnoreCase(param, RequestMap.PROP_PREFIX)) { LOG.debug("Unused property {}", param); } } context.setAdditionalConfigProps(additionalConfigProps); context.setPluginConf(pluginConf); if (StringUtils.isNotBlank(profile)) { String handlerClassName = pluginConf.getHandler(profile); if (StringUtils.isNotBlank(handlerClassName)) { Class<?> clazz; try { clazz = Class.forName(handlerClassName); ProtocolHandler handler = (ProtocolHandler) clazz.getDeclaredConstructor().newInstance(); context.setFragmenter(handler.getFragmenterClassName(context)); context.setAccessor(handler.getAccessorClassName(context)); context.setResolver(handler.getResolverClassName(context)); } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { throw new RuntimeException(String.format("Error when invoking handlerClass '%s' : %s", handlerClassName, e), e); } } } context.validate(); return context; } HttpRequestParser();   HttpRequestParser(PluginConf pluginConf); static HttpRequestParser getInstance(); @Override RequestContext parseRequest(HttpHeaders request, RequestContext.RequestType requestType);  }