You call visitDumpCommand only once immediately after incoming connect, 
which means that following happens

client JVM starts and JaCoCo agent immediately connects to your server
server receives incoming connection and immediately requests coverage, 
whereas your code wasn't yet executed in client JVM
after that client JVM executes your code


On Monday, May 13, 2019 at 12:40:51 PM UTC+2, Vijay Nanekar 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/e96b7d8b-8efa-4af8-abd5-3c40d6a27323%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to