/** * Constructor. */ @SuppressWarnings("nls") public HawkularMetricsAccessor(Map<String, String> config) { String endpoint = config.get("hawkular.endpoint"); Map<String, String> httpOptions = new HashMap<>(); httpOptions.put("http.timeouts.read", config.get("http.timeouts.read")); httpOptions.put("http.timeouts.write", config.get("http.timeouts.write")); httpOptions.put("http.timeouts.connect", config.get("http.timeouts.connect")); httpOptions.put("http.followRedirects", config.get("http.followRedirects")); client = new HawkularMetricsClient(endpoint, new HttpConnectorOptions(httpOptions)); }
/** * Constructor. * @param metricsServer * @param options */ public HawkularMetricsClient(URL metricsServer, HttpConnectorOptions options) { this(metricsServer); httpClient.setReadTimeout(options.getReadTimeout(), TimeUnit.SECONDS); httpClient.setWriteTimeout(options.getWriteTimeout(), TimeUnit.SECONDS); httpClient.setConnectTimeout(options.getConnectTimeout(), TimeUnit.SECONDS); httpClient.setFollowRedirects(options.isFollowRedirects()); httpClient.setFollowSslRedirects(options.isFollowRedirects()); }
/** * @see io.apiman.common.config.options.AbstractOptions#parse(java.util.Map) */ @Override protected void parse(Map<String, String> options) { String read = options.get("http.timeouts.read"); //$NON-NLS-1$ String write = options.get("http.timeouts.write"); //$NON-NLS-1$ String connect = options.get("http.timeouts.connect"); //$NON-NLS-1$ String redirects = options.get("http.followRedirects"); //$NON-NLS-1$ if (read != null) { setReadTimeout(Integer.parseInt(read)); } else { setReadTimeout(DEFAULT_READ_TIMEOUT); } if (write != null) { setWriteTimeout(Integer.parseInt(write)); } else { setWriteTimeout(DEFAULT_WRITE_TIMEOUT); } if (connect != null) { setConnectTimeout(Integer.parseInt(connect)); } else { setConnectTimeout(DEFAULT_CONNECT_TIMEOUT); } if (redirects != null) { setFollowRedirects(Boolean.parseBoolean(redirects)); } else { setFollowRedirects(DEFAULT_FOLLOW_REDIRECTS); } }
/** * Constructor. * @param metricsServer * @param options */ public HawkularMetricsClient(URL metricsServer, HttpConnectorOptions options) { this(metricsServer); httpClient.setReadTimeout(options.getReadTimeout(), TimeUnit.SECONDS); httpClient.setWriteTimeout(options.getWriteTimeout(), TimeUnit.SECONDS); httpClient.setConnectTimeout(options.getConnectTimeout(), TimeUnit.SECONDS); httpClient.setFollowRedirects(options.isFollowRedirects()); httpClient.setFollowSslRedirects(options.isFollowRedirects()); }
/** * Constructor. * @param config */ @SuppressWarnings("nls") public HawkularMetrics(Map<String, String> config) { String endpoint = config.get("hawkular.endpoint"); if (endpoint == null) { throw new RuntimeException("Missing configuration property: apiman-gateway.metrics.hawkular.endpoint"); } Map<String, String> httpOptions = new HashMap<>(); httpOptions.put("http.timeouts.read", config.get("http.timeouts.read")); httpOptions.put("http.timeouts.write", config.get("http.timeouts.write")); httpOptions.put("http.timeouts.connect", config.get("http.timeouts.connect")); httpOptions.put("http.followRedirects", config.get("http.followRedirects")); client = new HawkularMetricsClient(endpoint, new HttpConnectorOptions(httpOptions)); int queueSize = DEFAULT_QUEUE_SIZE; String queueSizeConfig = config.get("hawkular.queueSize"); if (queueSizeConfig != null) { queueSize = new Integer(queueSizeConfig); } queue = new LinkedBlockingDeque<>(queueSize); startConsumerThread(); }
/** * @return a new http client */ private OkHttpClient createHttpClient() { OkHttpClient client = new OkHttpClient(); client.setReadTimeout(connectorOptions.getReadTimeout(), TimeUnit.SECONDS); client.setWriteTimeout(connectorOptions.getWriteTimeout(), TimeUnit.SECONDS); client.setConnectTimeout(connectorOptions.getConnectTimeout(), TimeUnit.SECONDS); client.setFollowRedirects(connectorOptions.isFollowRedirects()); client.setFollowSslRedirects(connectorOptions.isFollowRedirects()); client.setProxySelector(ProxySelector.getDefault()); client.setCookieHandler(CookieHandler.getDefault()); client.setCertificatePinner(CertificatePinner.DEFAULT); client.setAuthenticator(AuthenticatorAdapter.INSTANCE); client.setConnectionPool(ConnectionPool.getDefault()); client.setProtocols(Util.immutableList(Protocol.HTTP_1_1)); client.setConnectionSpecs(DEFAULT_CONNECTION_SPECS); client.setSocketFactory(SocketFactory.getDefault()); Internal.instance.setNetwork(client, Network.DEFAULT); return client; }
/** * Constructor. * @param config */ @SuppressWarnings("nls") public HawkularMetrics(Map<String, String> config) { String endpoint = config.get("hawkular.endpoint"); if (endpoint == null) { throw new RuntimeException("Missing configuration property: apiman-gateway.metrics.hawkular.endpoint"); } Map<String, String> httpOptions = new HashMap<>(); httpOptions.put("http.timeouts.read", config.get("http.timeouts.read")); httpOptions.put("http.timeouts.write", config.get("http.timeouts.write")); httpOptions.put("http.timeouts.connect", config.get("http.timeouts.connect")); httpOptions.put("http.followRedirects", config.get("http.followRedirects")); client = new HawkularMetricsClient(endpoint, new HttpConnectorOptions(httpOptions)); int queueSize = DEFAULT_QUEUE_SIZE; String queueSizeConfig = config.get("hawkular.queueSize"); if (queueSizeConfig != null) { queueSize = new Integer(queueSizeConfig); } queue = new LinkedBlockingDeque<>(queueSize); startConsumerThread(); }
/** * @return a new http client */ private OkHttpClient createHttpClient() { OkHttpClient client = new OkHttpClient(); client.setReadTimeout(connectorOptions.getReadTimeout(), TimeUnit.SECONDS); client.setWriteTimeout(connectorOptions.getWriteTimeout(), TimeUnit.SECONDS); client.setConnectTimeout(connectorOptions.getConnectTimeout(), TimeUnit.SECONDS); client.setFollowRedirects(connectorOptions.isFollowRedirects()); client.setFollowSslRedirects(connectorOptions.isFollowRedirects()); client.setProxySelector(ProxySelector.getDefault()); client.setCookieHandler(CookieHandler.getDefault()); client.setCertificatePinner(CertificatePinner.DEFAULT); client.setAuthenticator(AuthenticatorAdapter.INSTANCE); client.setConnectionPool(ConnectionPool.getDefault()); client.setProtocols(Util.immutableList(Protocol.HTTP_1_1)); client.setConnectionSpecs(DEFAULT_CONNECTION_SPECS); client.setSocketFactory(SocketFactory.getDefault()); Internal.instance.setNetwork(client, Network.DEFAULT); return client; }
/** * Constructor. * @param config map of configuration options */ public HttpConnectorFactory(Map<String, String> config) { this.tlsOptions = new TLSOptions(config); this.connectorOptions = new HttpConnectorOptions(config); this.okClient = createHttpClient(); }
/** * Constructor. * @param config map of configuration options */ public HttpConnectorFactory(Map<String, String> config) { this.tlsOptions = new TLSOptions(config); this.connectorOptions = new HttpConnectorOptions(config); this.okClient = createHttpClient(); }