@Test public void testSecureAll() throws Exception { int securePort1 = findAvailablePort(2888); int securePort2 = findAvailablePort(2889); proxy.proxyConfig.privateCertPath = getClass().getClassLoader().getResource("demo.cert").getPath(); proxy.proxyConfig.privateKeyPath = getClass().getClassLoader().getResource("demo.key").getPath(); proxy.proxyConfig.tlsPorts = "*"; proxy.initSslContext(); proxy.proxyConfig.pushListenerPorts = securePort1 + "," + securePort2; SpanSampler sampler = new SpanSampler(new RateSampler(1.0D), proxy.proxyConfig.isTraceAlwaysSampleErrors()); proxy.startGraphiteListener(String.valueOf(securePort1), mockHandlerFactory, null, sampler); proxy.startGraphiteListener(String.valueOf(securePort2), mockHandlerFactory, null, sampler); waitUntilListenerIsOnline(securePort1); waitUntilListenerIsOnline(securePort2); reset(mockPointHandler); mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy"). setMetric("metric.test").setHost("test1").setTimestamp(startTime * 1000).setValue(0.0d).build()); expectLastCall(); mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy"). setMetric("metric.test").setHost("test2").setTimestamp((startTime + 1) * 1000).setValue(1.0d).build()); expectLastCall(); replay(mockPointHandler); Socket socket = sslSocketFactory.createSocket("localhost", securePort1); BufferedOutputStream stream = new BufferedOutputStream(socket.getOutputStream()); String payloadStr = "metric.test 0 " + startTime + " source=test1\n" + "metric.test 1 " + (startTime + 1) + " source=test2\n"; stream.write(payloadStr.getBytes()); stream.flush(); socket.close(); verifyWithTimeout(500, mockPointHandler); reset(mockPointHandler); mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy"). setMetric("metric.test").setHost("test3").setTimestamp(startTime * 1000).setValue(0.0d).build()); expectLastCall(); mockPointHandler.report(ReportPoint.newBuilder().setTable("dummy"). setMetric("metric.test").setHost("test4").setTimestamp((startTime + 1) * 1000).setValue(1.0d).build()); expectLastCall(); replay(mockPointHandler); socket = sslSocketFactory.createSocket("localhost", securePort2); stream = new BufferedOutputStream(socket.getOutputStream()); payloadStr = "metric.test 0 " + startTime + " source=test3\n" + "metric.test 1 " + (startTime + 1) + " source=test4\n"; stream.write(payloadStr.getBytes()); stream.flush(); socket.close(); verifyWithTimeout(500, mockPointHandler); }
@VisibleForTesting protected void startGraphiteListener(String strPort, ReportableEntityHandlerFactory handlerFactory, SharedGraphiteHostAnnotator hostAnnotator, SpanSampler sampler) { final int port = Integer.parseInt(strPort); registerPrefixFilter(strPort); registerTimestampFilter(strPort); if (proxyConfig.isHttpHealthCheckAllPorts()) healthCheckManager.enableHealthcheck(port); WavefrontPortUnificationHandler wavefrontPortUnificationHandler = new WavefrontPortUnificationHandler(strPort, tokenAuthenticator, healthCheckManager, decoderSupplier.get(), handlerFactory, hostAnnotator, preprocessors.get(strPort), () -> entityProps.get(ReportableEntityType.HISTOGRAM).isFeatureDisabled(), () -> entityProps.get(ReportableEntityType.TRACE).isFeatureDisabled(), () -> entityProps.get(ReportableEntityType.TRACE_SPAN_LOGS).isFeatureDisabled(), sampler); startAsManagedThread(port, new TcpIngester(createInitializer(wavefrontPortUnificationHandler, port, proxyConfig.getPushListenerMaxReceivedLength(), proxyConfig.getPushListenerHttpBufferSize(), proxyConfig.getListenerIdleConnectionTimeout(), getSslContext(strPort), getCorsConfig(strPort)), port). withChildChannelOptions(childChannelOptions), "listener-graphite-" + port); }
PushAgent extends AbstractAgent { @VisibleForTesting protected void startGraphiteListener(String strPort, ReportableEntityHandlerFactory handlerFactory, SharedGraphiteHostAnnotator hostAnnotator, SpanSampler sampler) { final int port = Integer.parseInt(strPort); registerPrefixFilter(strPort); registerTimestampFilter(strPort); if (proxyConfig.isHttpHealthCheckAllPorts()) healthCheckManager.enableHealthcheck(port); WavefrontPortUnificationHandler wavefrontPortUnificationHandler = new WavefrontPortUnificationHandler(strPort, tokenAuthenticator, healthCheckManager, decoderSupplier.get(), handlerFactory, hostAnnotator, preprocessors.get(strPort), () -> entityProps.get(ReportableEntityType.HISTOGRAM).isFeatureDisabled(), () -> entityProps.get(ReportableEntityType.TRACE).isFeatureDisabled(), () -> entityProps.get(ReportableEntityType.TRACE_SPAN_LOGS).isFeatureDisabled(), sampler); startAsManagedThread(port, new TcpIngester(createInitializer(wavefrontPortUnificationHandler, port, proxyConfig.getPushListenerMaxReceivedLength(), proxyConfig.getPushListenerHttpBufferSize(), proxyConfig.getListenerIdleConnectionTimeout(), getSslContext(strPort), getCorsConfig(strPort)), port). withChildChannelOptions(childChannelOptions), "listener-graphite-" + port); } }
PushAgent extends AbstractAgent { @VisibleForTesting protected void startGraphiteListener(String strPort, ReportableEntityHandlerFactory handlerFactory, SharedGraphiteHostAnnotator hostAnnotator, SpanSampler sampler) { final int port = Integer.parseInt(strPort); registerPrefixFilter(strPort); registerTimestampFilter(strPort); if (proxyConfig.isHttpHealthCheckAllPorts()) healthCheckManager.enableHealthcheck(port); WavefrontPortUnificationHandler wavefrontPortUnificationHandler = new WavefrontPortUnificationHandler(strPort, tokenAuthenticator, healthCheckManager, decoderSupplier.get(), handlerFactory, hostAnnotator, preprocessors.get(strPort), () -> entityProps.get(ReportableEntityType.HISTOGRAM).isFeatureDisabled(), () -> entityProps.get(ReportableEntityType.TRACE).isFeatureDisabled(), () -> entityProps.get(ReportableEntityType.TRACE_SPAN_LOGS).isFeatureDisabled(), sampler); startAsManagedThread(port, new TcpIngester(createInitializer(wavefrontPortUnificationHandler, port, proxyConfig.getPushListenerMaxReceivedLength(), proxyConfig.getPushListenerHttpBufferSize(), proxyConfig.getListenerIdleConnectionTimeout(), getSslContext(strPort), getCorsConfig(strPort)), port). withChildChannelOptions(childChannelOptions), "listener-graphite-" + port); }  }
PushAgent extends AbstractAgent { @VisibleForTesting protected void startGraphiteListener(String strPort, ReportableEntityHandlerFactory handlerFactory, SharedGraphiteHostAnnotator hostAnnotator, SpanSampler sampler) { final int port = Integer.parseInt(strPort); registerPrefixFilter(strPort); registerTimestampFilter(strPort); if (proxyConfig.isHttpHealthCheckAllPorts()) healthCheckManager.enableHealthcheck(port); WavefrontPortUnificationHandler wavefrontPortUnificationHandler = new WavefrontPortUnificationHandler(strPort, tokenAuthenticator, healthCheckManager, decoderSupplier.get(), handlerFactory, hostAnnotator, preprocessors.get(strPort), () -> entityProps.get(ReportableEntityType.HISTOGRAM).isFeatureDisabled(), () -> entityProps.get(ReportableEntityType.TRACE).isFeatureDisabled(), () -> entityProps.get(ReportableEntityType.TRACE_SPAN_LOGS).isFeatureDisabled(), sampler); startAsManagedThread(port, new TcpIngester(createInitializer(wavefrontPortUnificationHandler, port, proxyConfig.getPushListenerMaxReceivedLength(), proxyConfig.getPushListenerHttpBufferSize(), proxyConfig.getListenerIdleConnectionTimeout(), getSslContext(strPort), getCorsConfig(strPort)), port). withChildChannelOptions(childChannelOptions), "listener-graphite-" + port); }  static void main(String[] args); @Override void stopListeners(); }
PushAgent extends AbstractAgent { @VisibleForTesting protected void startGraphiteListener(String strPort, ReportableEntityHandlerFactory handlerFactory, SharedGraphiteHostAnnotator hostAnnotator, SpanSampler sampler) { final int port = Integer.parseInt(strPort); registerPrefixFilter(strPort); registerTimestampFilter(strPort); if (proxyConfig.isHttpHealthCheckAllPorts()) healthCheckManager.enableHealthcheck(port); WavefrontPortUnificationHandler wavefrontPortUnificationHandler = new WavefrontPortUnificationHandler(strPort, tokenAuthenticator, healthCheckManager, decoderSupplier.get(), handlerFactory, hostAnnotator, preprocessors.get(strPort), () -> entityProps.get(ReportableEntityType.HISTOGRAM).isFeatureDisabled(), () -> entityProps.get(ReportableEntityType.TRACE).isFeatureDisabled(), () -> entityProps.get(ReportableEntityType.TRACE_SPAN_LOGS).isFeatureDisabled(), sampler); startAsManagedThread(port, new TcpIngester(createInitializer(wavefrontPortUnificationHandler, port, proxyConfig.getPushListenerMaxReceivedLength(), proxyConfig.getPushListenerHttpBufferSize(), proxyConfig.getListenerIdleConnectionTimeout(), getSslContext(strPort), getCorsConfig(strPort)), port). withChildChannelOptions(childChannelOptions), "listener-graphite-" + port); }  static void main(String[] args); @Override void stopListeners();  }