Search in sources :

Example 1 with DefaultServerMetaData

use of com.navercorp.pinpoint.profiler.context.DefaultServerMetaData in project pinpoint by naver.

the class AgentInfoSenderTest method serverMetaDataShouldBeSentOnPublish.

@Test
public void serverMetaDataShouldBeSentOnPublish() throws InterruptedException {
    // Given
    final AtomicInteger requestCount = new AtomicInteger();
    final AtomicInteger successCount = new AtomicInteger();
    final long agentInfoSendRetryIntervalMs = 1000L;
    ResponseServerMessageListener serverListener = new ResponseServerMessageListener(requestCount, successCount);
    PinpointServerAcceptor serverAcceptor = createServerAcceptor(serverListener);
    PinpointClientFactory clientFactory = createPinpointClientFactory();
    PinpointClient pinpointClient = ClientFactoryUtils.createPinpointClient(HOST, PORT, clientFactory);
    TcpDataSender dataSender = new TcpDataSender(pinpointClient);
    AgentInfoSender agentInfoSender = new AgentInfoSender.Builder(dataSender, getAgentInfo()).sendInterval(agentInfoSendRetryIntervalMs).build();
    final List<ServerMetaData> serverMetaDataObjects = new ArrayList<ServerMetaData>();
    serverMetaDataObjects.add(new DefaultServerMetaData("server1", Collections.<String>emptyList(), Collections.<Integer, String>emptyMap(), Collections.<ServiceInfo>emptyList()));
    serverMetaDataObjects.add(new DefaultServerMetaData("server2", Collections.<String>emptyList(), Collections.<Integer, String>emptyMap(), Collections.<ServiceInfo>emptyList()));
    serverMetaDataObjects.add(new DefaultServerMetaData("server3", Collections.<String>emptyList(), Collections.<Integer, String>emptyMap(), Collections.<ServiceInfo>emptyList()));
    serverMetaDataObjects.add(new DefaultServerMetaData("server4", Collections.<String>emptyList(), Collections.<Integer, String>emptyMap(), Collections.<ServiceInfo>emptyList()));
    serverMetaDataObjects.add(new DefaultServerMetaData("server5", Collections.<String>emptyList(), Collections.<Integer, String>emptyMap(), Collections.<ServiceInfo>emptyList()));
    // When
    try {
        for (ServerMetaData serverMetaData : serverMetaDataObjects) {
            agentInfoSender.publishServerMetaData(serverMetaData);
        }
        waitExpectedRequestCount(requestCount, 5);
    } finally {
        closeAll(serverAcceptor, agentInfoSender, pinpointClient, clientFactory);
    }
    // Then
    assertEquals(5, requestCount.get());
    assertEquals(5, successCount.get());
}
Also used : PinpointClient(com.navercorp.pinpoint.rpc.client.PinpointClient) ArrayList(java.util.ArrayList) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ServiceInfo(com.navercorp.pinpoint.bootstrap.context.ServiceInfo) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PinpointServerAcceptor(com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor) TcpDataSender(com.navercorp.pinpoint.profiler.sender.TcpDataSender) DefaultServerMetaData(com.navercorp.pinpoint.profiler.context.DefaultServerMetaData) ServerMetaData(com.navercorp.pinpoint.bootstrap.context.ServerMetaData) DefaultServerMetaData(com.navercorp.pinpoint.profiler.context.DefaultServerMetaData) Test(org.junit.Test)

Example 2 with DefaultServerMetaData

use of com.navercorp.pinpoint.profiler.context.DefaultServerMetaData in project pinpoint by naver.

the class AgentGrpcDataSenderTestMain method newAgentInfo.

private AgentInfo newAgentInfo() {
    AgentInformation agentInformation = new DefaultAgentInformation(AGENT_ID, AGENT_NAME, APPLICATION_NAME, true, START_TIME, 99, "", "", ServiceType.TEST_STAND_ALONE, "1.0", "1.0");
    JvmInformation jvmInformation = new JvmInformation("1.0", JvmGcType.G1);
    ServerMetaData serverInfo = new DefaultServerMetaData("serverInfo", Collections.<String>emptyList(), Collections.<Integer, String>emptyMap(), Collections.<ServiceInfo>emptyList());
    return new AgentInfo(agentInformation, serverInfo, jvmInformation);
}
Also used : AgentInformation(com.navercorp.pinpoint.profiler.AgentInformation) DefaultAgentInformation(com.navercorp.pinpoint.profiler.DefaultAgentInformation) AgentInfo(com.navercorp.pinpoint.profiler.metadata.AgentInfo) DefaultAgentInformation(com.navercorp.pinpoint.profiler.DefaultAgentInformation) DefaultServerMetaData(com.navercorp.pinpoint.profiler.context.DefaultServerMetaData) ServerMetaData(com.navercorp.pinpoint.bootstrap.context.ServerMetaData) DefaultServerMetaData(com.navercorp.pinpoint.profiler.context.DefaultServerMetaData) JvmInformation(com.navercorp.pinpoint.profiler.JvmInformation)

Aggregations

ServerMetaData (com.navercorp.pinpoint.bootstrap.context.ServerMetaData)2 DefaultServerMetaData (com.navercorp.pinpoint.profiler.context.DefaultServerMetaData)2 ServiceInfo (com.navercorp.pinpoint.bootstrap.context.ServiceInfo)1 AgentInformation (com.navercorp.pinpoint.profiler.AgentInformation)1 DefaultAgentInformation (com.navercorp.pinpoint.profiler.DefaultAgentInformation)1 JvmInformation (com.navercorp.pinpoint.profiler.JvmInformation)1 AgentInfo (com.navercorp.pinpoint.profiler.metadata.AgentInfo)1 TcpDataSender (com.navercorp.pinpoint.profiler.sender.TcpDataSender)1 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)1 PinpointClient (com.navercorp.pinpoint.rpc.client.PinpointClient)1 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)1 PinpointServerAcceptor (com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Test (org.junit.Test)1