use of org.apache.skywalking.oap.server.telemetry.api.CounterMetrics in project incubator-skywalking by apache.
the class RemoteServiceHandlerTestCase method callTest.
@Test
public void callTest() throws DuplicateProviderException, ProviderNotFoundException, IOException {
final String testWorkerId = "mock-worker";
ModuleManagerTesting moduleManager = new ModuleManagerTesting();
ModuleDefineTesting moduleDefine = new ModuleDefineTesting();
moduleManager.put(CoreModule.NAME, moduleDefine);
WorkerInstancesService workerInstancesService = new WorkerInstancesService();
moduleDefine.provider().registerServiceImplementation(IWorkerInstanceGetter.class, workerInstancesService);
moduleDefine.provider().registerServiceImplementation(IWorkerInstanceSetter.class, workerInstancesService);
TestWorker worker = new TestWorker(moduleManager);
workerInstancesService.put(testWorkerId, worker, TestRemoteData.class);
String serverName = InProcessServerBuilder.generateName();
MetricsCreator metricsCreator = mock(MetricsCreator.class);
when(metricsCreator.createCounter(any(), any(), any(), any())).thenReturn(new CounterMetrics() {
@Override
public void inc() {
}
@Override
public void inc(double value) {
}
});
when(metricsCreator.createHistogramMetric(any(), any(), any(), any())).thenReturn(new HistogramMetrics() {
@Override
public Timer createTimer() {
return super.createTimer();
}
@Override
public void observe(double value) {
}
});
ModuleDefineTesting telemetryModuleDefine = new ModuleDefineTesting();
moduleManager.put(TelemetryModule.NAME, telemetryModuleDefine);
telemetryModuleDefine.provider().registerServiceImplementation(MetricsCreator.class, metricsCreator);
gRPCCleanup.register(InProcessServerBuilder.forName(serverName).directExecutor().addService(new RemoteServiceHandler(moduleManager)).build().start());
RemoteServiceGrpc.RemoteServiceStub remoteServiceStub = RemoteServiceGrpc.newStub(gRPCCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build()));
StreamObserver<RemoteMessage> streamObserver = remoteServiceStub.call(new StreamObserver<Empty>() {
@Override
public void onNext(Empty empty) {
}
@Override
public void onError(Throwable throwable) {
}
@Override
public void onCompleted() {
}
});
RemoteMessage.Builder remoteMessage = RemoteMessage.newBuilder();
remoteMessage.setNextWorkerName(testWorkerId);
RemoteData.Builder remoteData = RemoteData.newBuilder();
remoteData.addDataStrings("test1");
remoteData.addDataStrings("test2");
remoteData.addDataLongs(10);
remoteData.addDataLongs(20);
remoteMessage.setRemoteData(remoteData);
streamObserver.onNext(remoteMessage.build());
streamObserver.onCompleted();
}
use of org.apache.skywalking.oap.server.telemetry.api.CounterMetrics in project incubator-skywalking by apache.
the class GRPCRemoteClientTestCase method testPush.
@Test
public void testPush() throws InterruptedException {
MetricsCreator metricsCreator = mock(MetricsCreator.class);
when(metricsCreator.createCounter(any(), any(), any(), any())).thenReturn(new CounterMetrics() {
@Override
public void inc() {
}
@Override
public void inc(double value) {
}
});
when(metricsCreator.createHistogramMetric(any(), any(), any(), any())).thenReturn(new HistogramMetrics() {
@Override
public Timer createTimer() {
return super.createTimer();
}
@Override
public void observe(double value) {
}
});
ModuleDefineTesting telemetryModuleDefine = new ModuleDefineTesting();
moduleManager.put(TelemetryModule.NAME, telemetryModuleDefine);
telemetryModuleDefine.provider().registerServiceImplementation(MetricsCreator.class, metricsCreator);
grpcServerRule.getServiceRegistry().addService(new RemoteServiceHandler(moduleManager));
Address address = new Address("not-important", 11, false);
GRPCRemoteClient remoteClient = spy(new GRPCRemoteClient(moduleManager, address, 1, 10, 10, null));
remoteClient.connect();
doReturn(grpcServerRule.getChannel()).when(remoteClient).getChannel();
for (int i = 0; i < 12; i++) {
remoteClient.push(nextWorkerName, new TestStreamData());
}
TimeUnit.SECONDS.sleep(2);
}
use of org.apache.skywalking.oap.server.telemetry.api.CounterMetrics in project skywalking by apache.
the class RemoteServiceHandlerTestCase method callTest.
@Test
public void callTest() throws DuplicateProviderException, ProviderNotFoundException, IOException {
final String testWorkerId = "mock-worker";
ModuleManagerTesting moduleManager = new ModuleManagerTesting();
ModuleDefineTesting moduleDefine = new ModuleDefineTesting();
moduleManager.put(CoreModule.NAME, moduleDefine);
WorkerInstancesService workerInstancesService = new WorkerInstancesService();
moduleDefine.provider().registerServiceImplementation(IWorkerInstanceGetter.class, workerInstancesService);
moduleDefine.provider().registerServiceImplementation(IWorkerInstanceSetter.class, workerInstancesService);
TestWorker worker = new TestWorker(moduleManager);
workerInstancesService.put(testWorkerId, worker, TestRemoteData.class);
String serverName = InProcessServerBuilder.generateName();
MetricsCreator metricsCreator = mock(MetricsCreator.class);
when(metricsCreator.createCounter(any(), any(), any(), any())).thenReturn(new CounterMetrics() {
@Override
public void inc() {
}
@Override
public void inc(double value) {
}
});
when(metricsCreator.createHistogramMetric(any(), any(), any(), any())).thenReturn(new HistogramMetrics() {
@Override
public Timer createTimer() {
return super.createTimer();
}
@Override
public void observe(double value) {
}
});
ModuleDefineTesting telemetryModuleDefine = new ModuleDefineTesting();
moduleManager.put(TelemetryModule.NAME, telemetryModuleDefine);
telemetryModuleDefine.provider().registerServiceImplementation(MetricsCreator.class, metricsCreator);
gRPCCleanup.register(InProcessServerBuilder.forName(serverName).directExecutor().addService(new RemoteServiceHandler(moduleManager)).build().start());
RemoteServiceGrpc.RemoteServiceStub remoteServiceStub = RemoteServiceGrpc.newStub(gRPCCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build()));
StreamObserver<RemoteMessage> streamObserver = remoteServiceStub.call(new StreamObserver<Empty>() {
@Override
public void onNext(Empty empty) {
}
@Override
public void onError(Throwable throwable) {
}
@Override
public void onCompleted() {
}
});
RemoteMessage.Builder remoteMessage = RemoteMessage.newBuilder();
remoteMessage.setNextWorkerName(testWorkerId);
RemoteData.Builder remoteData = RemoteData.newBuilder();
remoteData.addDataStrings("test1");
remoteData.addDataStrings("test2");
remoteData.addDataLongs(10);
remoteData.addDataLongs(20);
remoteMessage.setRemoteData(remoteData);
streamObserver.onNext(remoteMessage.build());
streamObserver.onCompleted();
}
use of org.apache.skywalking.oap.server.telemetry.api.CounterMetrics in project skywalking by apache.
the class GRPCRemoteClientTestCase method testPush.
@Test
public void testPush() throws InterruptedException {
MetricsCreator metricsCreator = mock(MetricsCreator.class);
when(metricsCreator.createCounter(any(), any(), any(), any())).thenReturn(new CounterMetrics() {
@Override
public void inc() {
}
@Override
public void inc(double value) {
}
});
when(metricsCreator.createHistogramMetric(any(), any(), any(), any())).thenReturn(new HistogramMetrics() {
@Override
public Timer createTimer() {
return super.createTimer();
}
@Override
public void observe(double value) {
}
});
ModuleDefineTesting telemetryModuleDefine = new ModuleDefineTesting();
moduleManager.put(TelemetryModule.NAME, telemetryModuleDefine);
telemetryModuleDefine.provider().registerServiceImplementation(MetricsCreator.class, metricsCreator);
grpcServerRule.getServiceRegistry().addService(new RemoteServiceHandler(moduleManager));
Address address = new Address("not-important", 11, false);
GRPCRemoteClient remoteClient = spy(new GRPCRemoteClient(moduleManager, address, 1, 10, 10, null));
remoteClient.connect();
doReturn(grpcServerRule.getChannel()).when(remoteClient).getChannel();
for (int i = 0; i < 12; i++) {
remoteClient.push(nextWorkerName, new TestStreamData());
}
TimeUnit.SECONDS.sleep(2);
}
use of org.apache.skywalking.oap.server.telemetry.api.CounterMetrics in project skywalking by apache.
the class GRPCRemoteClientRealClient method main.
public static void main(String[] args) throws InterruptedException {
Address address = new Address("localhost", 10000, false);
ModuleManagerTesting moduleManager = new ModuleManagerTesting();
MetricsCreator metricsCreator = mock(MetricsCreator.class);
when(metricsCreator.createCounter(any(), any(), any(), any())).thenReturn(new CounterMetrics() {
@Override
public void inc() {
}
@Override
public void inc(double value) {
}
});
ModuleDefineTesting telemetryModuleDefine = new ModuleDefineTesting();
moduleManager.put(TelemetryModule.NAME, telemetryModuleDefine);
telemetryModuleDefine.provider().registerServiceImplementation(MetricsCreator.class, metricsCreator);
GRPCRemoteClient remoteClient = spy(new GRPCRemoteClient(moduleManager, address, 1, 10, 10, null));
remoteClient.connect();
for (int i = 0; i < 10000; i++) {
remoteClient.push("mock_remote", new TestStreamData());
TimeUnit.SECONDS.sleep(1);
}
TimeUnit.MINUTES.sleep(10);
}
Aggregations