Ignore:
Timestamp:
07/08/15 09:03:46 (9 years ago)
Author:
pharms
Message:
  • added ordering id for requests and responses
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitoringProxy.java

    r1384 r1991  
    2222import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorLogManager; 
    2323import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorServer; 
     24import de.ugoe.cs.autoquest.httpmonitor.IdGenerator; 
    2425import de.ugoe.cs.autoquest.httpmonitor.Runner; 
    2526import de.ugoe.cs.autoquest.httpmonitor.ShutdownHook; 
     27import de.ugoe.cs.autoquest.httpmonitor.SimpleIdGenerator; 
    2628import de.ugoe.cs.util.console.Console; 
    2729 
     
    2931 * <p> 
    3032 * The HTTP monitory proxy monitor starts a web server ({@link HttpMonitorServer}) that receives 
    31  * proxies HTTP messages and response. Each exchange of a request and a response is forwarded to 
     33 * proxied HTTP messages and response. Each exchange of a request and a response is forwarded to 
    3234 * an exchange handler. The exchange handler is either a local log manager 
    3335 * ({@link HttpMonitorLogManager}) or a connection to an external and central HTTP monitor via 
    34  * an {@link HttpMonitorRemoteExchangeHandler}. The class ensures that on shutdown e.g. caused 
     36 * an {@link HttpMonitorRemoteExchangeHandler}. It also holds a reference to an id generator. If 
     37 * the exchanges are handled locally, then also a local {@link SimpleIdGenerator} is used. If 
     38 * the exchanges are send to a central HTTP monitor, then this monitor is used as id generator via 
     39 * an {@link HttpMonitorRemoteIdGenerator}. The class ensures that on shutdown e.g. caused 
    3540 * by CTRL-C the server and all other requied components are stopped correctly. 
    3641 * </p> 
     
    5964     */ 
    6065    private HttpMonitorExchangeHandler exchangeHandler; 
     66     
     67    /** 
     68     *  the id generator used to generate order ids for the requests and responses 
     69     */ 
     70    private IdGenerator idGenerator; 
    6171     
    6272    /** 
     
    170180            exchangeHandler = 
    171181                new HttpMonitorRemoteExchangeHandler(httpMonitorServer, httpMonitorPort); 
     182             
     183            idGenerator = new HttpMonitorRemoteIdGenerator(httpMonitorServer, httpMonitorPort); 
    172184        } 
    173185        else { 
    174186            Console.println("storing logs locally into directory " + logFileBaseDir); 
    175187            exchangeHandler = new HttpMonitorLogManager(logFileBaseDir); 
     188            idGenerator = new SimpleIdGenerator(); 
    176189        } 
    177190    } 
     
    187200         
    188201        exchangeHandler.init(); 
    189          
    190         exchangeListenerManager = new ExchangeListenerManager(exchangeHandler); 
     202        idGenerator.init(); 
     203         
     204        exchangeListenerManager = new ExchangeListenerManager(exchangeHandler, idGenerator); 
    191205        exchangeListenerManager.init(); 
    192206         
     
    205219    @Override 
    206220    public synchronized void start() { 
    207         if ((exchangeHandler == null) || (exchangeListenerManager == null) || (server == null)) { 
     221        if ((exchangeHandler == null) || (idGenerator == null) || 
     222            (exchangeListenerManager == null) || (server == null)) 
     223        { 
    208224            throw new IllegalStateException("not initialized."); 
    209225        } 
     
    212228            Runtime.getRuntime().addShutdownHook(shutdownHook); 
    213229            exchangeHandler.start(); 
     230            idGenerator.start(); 
    214231            exchangeListenerManager.start(); 
    215232            server.start(); 
     
    226243    @Override 
    227244    public synchronized void stop() { 
    228         if ((exchangeHandler == null) || (exchangeListenerManager == null) || (server == null)) { 
     245        if ((exchangeHandler == null) || (idGenerator == null) || 
     246            (exchangeListenerManager == null) || (server == null)) 
     247        { 
    229248            throw new IllegalStateException("not initialized."); 
    230249        } 
     
    233252        server.stop(); 
    234253        exchangeListenerManager.stop(); 
     254        idGenerator.stop(); 
    235255        exchangeHandler.stop(); 
    236256         
    237257        server = null; 
    238258        exchangeListenerManager = null; 
     259        idGenerator = null; 
    239260        exchangeHandler = null; 
    240261    } 
Note: See TracChangeset for help on using the changeset viewer.