Hello Marc, Yes, but I execute this in infinite loop which will continuously request to dump execution data.
Thanks & Regards Vijay On Mon 13 May, 2019, 4:18 PM Marc Hoffmann, <[email protected]> wrote: > Hi Vijay, > > ok, I see, you added "writer.visitDumpCommand(true, false);” This means > when the JVM starts and the agent connects to the ExecutionDataServer the > dump request is immediately triggered. At this point in time no application > code has been executed. You probably need a smarter version of > ExecutionDataServer > which requests dumps once your tests are finished. > > Regards, > -marc > > > On 13. May 2019, at 12:40, Vijay Nanekar <[email protected]> wrote: > > Thank you Marc. > > Yes, destfile parameter is not required here as we are using > output=tcpclient. > > In the case of output=tcpclient, I think we don't need to shutdown JVM to > collect data. We request execution data from ExecutionDataServer class > using statement "writer.visitDumpCommand(true, false);". Please correct me > if I am wrong. > > Please find link to shared .exec file. > https://drive.google.com/open?id=1f8W-Jt18qRlN1yw8sh0GymqqnDv6WBC8 > > > > Thanks, > Vijay > > On Monday, 13 May 2019 15:49:03 UTC+5:30, Marc R. Hoffmann wrote: >> >> Hi, >> >> technical it should be possible to use the same server socket for >> multiple clients at the same time. Our example code should also be robust >> for concurrent access. But I personally never tested this aspect. Can you >> please send the broken exec file? The position of the broken bytes might >> give a hint. >> >> By default JaCoCo only dumps execution data when you properly shut down a >> JVM. It has not notion about “micro service” or “hit”. Therefore I’m >> surprised that you get the the log entry when starting your services. >> >> BTW, the destfile parameter is not used when you configure the agent with >> output=tcpclient >> >> Regards, >> -marc >> >> >> On 13. May 2019, at 12:02, Vijay Nanekar <[email protected]> wrote: >> >> Hello, >> >> All our micro-services are sending execution data to the same socket >> server and on the same port. These are the Jacoco agent parameters we are >> setting. >> >> java -javaagent:$PWD/coverage/jacocoagent.jar=output=tcpclient,destfile= >> $PWD/jacoco-server.exec,includes=*,address=1XX.XX.XX.XX,port=6300 >> >> >> We are running given ExecutionDataServer.java class from address=1XX.XX. >> XX.XX machine which listens for incoming execution data. >> >> First, Could you please tell me, is it a good practice to collect >> execution data from multiple services to the same server socket? >> >> If yes, Then are we missed anything in below ExecutionDataServer class? >> as we are missing coverage from some of the services. >> >> When we start services, we get "Retrieving execution Data for session: >> <SERVICE_NAME>" log in ExecutionDataServer's class output for all >> services. But then we are not getting this log statement again even though >> we hit the code of that service. >> >> Please help. >> >> public final class ExecutionDataServer { >> >> private static String DESTFILE = "jacoco-server.exec"; >> >> private static String ADDRESS = "localhost"; >> >> private static int PORT = 6300; >> >> /** >> * Start the server as a standalone program. >> * >> * @param args >> * @throws IOException >> */ >> public static void main(final String[] args) throws IOException { >> final ExecutionDataWriter fileWriter = new >> ExecutionDataWriter(new FileOutputStream(DESTFILE)); >> final ServerSocket server = new ServerSocket(PORT, 0, >> InetAddress.getByName(ADDRESS)); >> while (true) { >> try { >> final Handler handler = new Handler(server.accept(), >> fileWriter); >> new Thread(handler).start(); >> } catch (Exception e) { >> e.printStackTrace(); >> System.out.println(e.getMessage()); >> } >> } >> } >> >> private static class Handler implements Runnable, >> ISessionInfoVisitor, IExecutionDataVisitor { >> >> private final Socket socket; >> >> private final RemoteControlReader reader; >> >> private final RemoteControlWriter writer; >> >> private final ExecutionDataWriter fileWriter; >> >> Handler(final Socket socket, final ExecutionDataWriter >> fileWriter) throws IOException { >> this.socket = socket; >> this.fileWriter = fileWriter; >> >> // Just send a valid header: >> writer = new RemoteControlWriter(socket.getOutputStream()); >> >> reader = new RemoteControlReader(socket.getInputStream()); >> reader.setSessionInfoVisitor(this); >> reader.setExecutionDataVisitor(this); >> } >> >> public void run() { >> try { >> writer.visitDumpCommand(true, false); >> while (reader.read()) { >> } >> socket.close(); >> synchronized (fileWriter) { >> fileWriter.flush(); >> } >> } catch (final IOException e) { >> e.printStackTrace(); >> } >> } >> >> public void visitSessionInfo(final SessionInfo info) { >> System.out.printf("Retrieving execution Data for session: >> %s%n", info.getId()); >> synchronized (fileWriter) { >> fileWriter.visitSessionInfo(info); >> } >> } >> >> public void visitClassExecution(final ExecutionData data) { >> synchronized (fileWriter) { >> fileWriter.visitClassExecution(data); >> } >> } >> } >> >> private ExecutionDataServer() { >> } >> } >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "JaCoCo and EclEmma Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jacoco/34854dc9-1a80-4019-bfd2-8b0571d9a993%40googlegroups.com >> <https://groups.google.com/d/msgid/jacoco/34854dc9-1a80-4019-bfd2-8b0571d9a993%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> >> >> > -- > You received this message because you are subscribed to the Google Groups > "JaCoCo and EclEmma Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jacoco/3b09bd80-951b-4d11-a3e6-8cdf9b171d35%40googlegroups.com > <https://groups.google.com/d/msgid/jacoco/3b09bd80-951b-4d11-a3e6-8cdf9b171d35%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > > -- > You received this message because you are subscribed to the Google Groups > "JaCoCo and EclEmma Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jacoco/ECA78200-CD4F-4C5F-AB10-A2EA9C7C6ED9%40mountainminds.com > <https://groups.google.com/d/msgid/jacoco/ECA78200-CD4F-4C5F-AB10-A2EA9C7C6ED9%40mountainminds.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/CAAheh30NO%2Bi%2BX%3DJWc5nH-v%3DK8jvzPZbeSKk2m5AQXK1yF%2Bre9A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
