Logging Client-Server Commands

over 7 years ago

StarTeam is a multi-tier client-server system. In general, SDK calls result in commands issued to the server over a proprietary Tcp/Ip based command streaming protocol.

When developing SDK based custom applications, a valuable principle to adhere to is - a few commands with large bursts of data transmitted is far superior to large sets of commands each transmitting small packets of data. This approach is called bulkification. 

Chatty applications typically consume significant amounts of network bandwidth, in the process, bogging the client down in Tcp/Ip traffic. But, bulkification is as important to the StarTeam server as it is to the client. Every time the server receives a command from a client, it allocates a thread to handle that command. The thread has to receive the data driving the request, process the request, possibly issue a database query, return the results to the client, then return the thread to the thread pool ready to service the next request. Each thread allocated to a client application is potential starvation of another client application waiting for a server thread.

Well behaved SDK applications minimize the number of commands issued, while maximizing client side memory retention and processing.

The best way to track exactly what commands are issued by the custom application, and to use this information to bulkify the application and minimize the commands, is to log all commands using the NetMonitor class. Each command issued fires an event to registered callers, through the ServerCommandListener event interface. NetMinitor is used to turn on the registration.

Here is a simple example...

public class ServerCommandAdapter implements ServerCommandListener {

               public void start(ServerCommandEvent e) {

System.out.print(e.getCommandName() " " e.isPropertyFetchTriggered());


               public void end(ServerCommandEvent e) {

System.out.println(e.getCommandTime() " " e.getBytesSent() " " e.getBytesReceived());


               public void error(ServerCommandEvent e) {

System.out.println("Error:" e.getCommandName());




private static ServerCommandListener listener = new ServerCommandAdapter();


  Application.setDefaultName("My Custom Application 1.0");


 myServer = new Server("host", port);

 myServer.logon("user", "password");

//... open projects, views, folders, check out files, edit change requests, close views, etc...



One can as easily log the commands to a file, and use that to analyze the command patterns.


How To-Best Practice
Comment List
Related Discussions