Search in sources :

Example 1 with InstancePingPkg

use of org.apache.skywalking.apm.network.management.v3.InstancePingPkg in project skywalking-java by apache.

the class KafkaServiceManagementServiceClient method run.

@Override
public void run() {
    if (producer == null) {
        return;
    }
    if (Math.abs(sendPropertiesCounter.getAndAdd(1)) % Config.Collector.PROPERTIES_REPORT_PERIOD_FACTOR == 0) {
        InstanceProperties instance = InstanceProperties.newBuilder().setService(Config.Agent.SERVICE_NAME).setServiceInstance(Config.Agent.INSTANCE_NAME).addAllProperties(OSUtil.buildOSInfo(Config.OsInfo.IPV4_LIST_SIZE)).addAllProperties(SERVICE_INSTANCE_PROPERTIES).addAllProperties(LoadedLibraryCollector.buildJVMInfo()).build();
        producer.send(new ProducerRecord<>(topic, TOPIC_KEY_REGISTER + instance.getServiceInstance(), Bytes.wrap(instance.toByteArray())));
        producer.flush();
    } else {
        InstancePingPkg ping = InstancePingPkg.newBuilder().setService(Config.Agent.SERVICE_NAME).setServiceInstance(Config.Agent.INSTANCE_NAME).build();
        if (LOGGER.isDebugEnable()) {
            LOGGER.debug("Heartbeat reporting, instance: {}", ping.getServiceInstance());
        }
        producer.send(new ProducerRecord<>(topic, ping.getServiceInstance(), Bytes.wrap(ping.toByteArray())));
    }
}
Also used : InstanceProperties(org.apache.skywalking.apm.network.management.v3.InstanceProperties) InstancePingPkg(org.apache.skywalking.apm.network.management.v3.InstancePingPkg)

Example 2 with InstancePingPkg

use of org.apache.skywalking.apm.network.management.v3.InstancePingPkg in project skywalking by apache.

the class ServiceManagementHandlerTest method testHandler.

@Test
public void testHandler() {
    InstanceProperties properties = InstanceProperties.newBuilder().setService(SERVICE).setServiceInstance(SERVICE_INSTANCE).build();
    InstancePingPkg ping = InstancePingPkg.newBuilder().setService(SERVICE).setServiceInstance(SERVICE_INSTANCE).build();
    handler.handle(new ConsumerRecord<>(TOPIC_NAME, 0, 0, "register", Bytes.wrap(properties.toByteArray())));
    handler.handle(new ConsumerRecord<>(TOPIC_NAME, 0, 0, ping.getServiceInstance(), Bytes.wrap(ping.toByteArray())));
}
Also used : InstanceProperties(org.apache.skywalking.apm.network.management.v3.InstanceProperties) InstancePingPkg(org.apache.skywalking.apm.network.management.v3.InstancePingPkg) Test(org.junit.Test)

Example 3 with InstancePingPkg

use of org.apache.skywalking.apm.network.management.v3.InstancePingPkg in project incubator-skywalking by apache.

the class ServiceManagementHandlerTest method testHandler.

@Test
public void testHandler() {
    InstanceProperties properties = InstanceProperties.newBuilder().setService(SERVICE).setServiceInstance(SERVICE_INSTANCE).build();
    InstancePingPkg ping = InstancePingPkg.newBuilder().setService(SERVICE).setServiceInstance(SERVICE_INSTANCE).build();
    handler.handle(new ConsumerRecord<>(TOPIC_NAME, 0, 0, "register", Bytes.wrap(properties.toByteArray())));
    handler.handle(new ConsumerRecord<>(TOPIC_NAME, 0, 0, ping.getServiceInstance(), Bytes.wrap(ping.toByteArray())));
}
Also used : InstanceProperties(org.apache.skywalking.apm.network.management.v3.InstanceProperties) InstancePingPkg(org.apache.skywalking.apm.network.management.v3.InstancePingPkg) Test(org.junit.Test)

Aggregations

InstancePingPkg (org.apache.skywalking.apm.network.management.v3.InstancePingPkg)3 InstanceProperties (org.apache.skywalking.apm.network.management.v3.InstanceProperties)3 Test (org.junit.Test)2