Changeset 1991 for trunk


Ignore:
Timestamp:
07/08/15 09:03:46 (9 years ago)
Author:
pharms
Message:
  • added ordering id for requests and responses
Location:
trunk
Files:
4 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/AbstractTC.java

    r1614 r1991  
    280280            System.err.println(exchange.getResponse().getContent().getData()); 
    281281        } 
     282         
     283        assertNotNull(exchange.getRequest().getOrderingId()); 
     284        assertNotNull(exchange.getResponse().getOrderingId()); 
     285        assertTrue(exchange.getRequest().getOrderingId() < exchange.getResponse().getOrderingId()); 
    282286    } 
    283287 
  • trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitorTest.java

    r1614 r1991  
    3232 
    3333import org.apache.http.HttpEntity; 
     34import org.apache.http.HttpResponse; 
     35import org.apache.http.client.methods.HttpGet; 
    3436import org.apache.http.client.methods.HttpPost; 
    3537import org.apache.http.entity.ContentType; 
     
    102104     */ 
    103105    @Test 
     106    public void test_RetrievalOfId_MonitorOnly() throws Exception { 
     107        monitor = new HttpMonitor(new String[] { LOG_FILE_DIR, MONITOR_PORT + "" }); 
     108 
     109        monitor.init(); 
     110        monitor.start(); 
     111         
     112        long id = getId(); 
     113        assertTrue(id > 0); 
     114         
     115        for (int i = 0; i < 300; i++) { 
     116            long prevId = id; 
     117            id = getId(); 
     118            assertTrue(id > prevId); 
     119        } 
     120         
     121        monitor.stop(); 
     122        monitor = null; 
     123    } 
     124     
     125    /** 
     126     * 
     127     */ 
     128    @Test 
    104129    public void test_SimulatedSession_MonitorOnly() throws Exception { 
    105130        monitor = new HttpMonitor(new String[] { LOG_FILE_DIR, MONITOR_PORT + "" }); 
     
    138163        System.out.println("{"); 
    139164        System.out.println("  {"); 
     165        long prevId = 0; 
     166         
    140167        for (int j = 0; j < sequence.size(); j++) { 
    141168            System.out.print("    "); 
     
    150177            assertTrue(sequence.get(j).getTarget() instanceof HTTPTarget); 
    151178 
     179            HTTPEventType eventType = (HTTPEventType) sequence.get(j).getType(); 
     180             
    152181            HTTPTestUtils.assertExchangeEquals 
    153                 (simulatedSession.getHttpExchange().get(j), 
    154                  ((HTTPEventType) sequence.get(j).getType()).getExchange()); 
     182                (simulatedSession.getHttpExchange().get(j), eventType.getExchange()); 
    155183 
    156184            assertEquals(HTTPUtils.toString(simulatedSession.getHttpExchange().get(j).getReceiver()), 
    157185                         ((HTTPTarget) sequence.get(j).getTarget()).getStringIdentifier()); 
     186             
     187            assertNotNull(eventType.getExchange().getRequest().getOrderingId()); 
     188            assertTrue(prevId < eventType.getExchange().getRequest().getOrderingId()); 
     189            prevId = eventType.getExchange().getRequest().getOrderingId(); 
     190             
     191            assertNotNull(eventType.getExchange().getResponse().getOrderingId()); 
     192            assertTrue(prevId < eventType.getExchange().getResponse().getOrderingId()); 
     193            prevId = eventType.getExchange().getResponse().getOrderingId(); 
    158194        } 
    159195        System.out.println("  }"); 
     
    510546    } 
    511547 
     548    /** 
     549     * 
     550     */ 
     551    private long getId() throws Exception { 
     552        DefaultHttpClient httpclient = new DefaultHttpClient(); 
     553         
     554        HttpGet httpRequest = new HttpGet("http://localhost:" + MONITOR_PORT + "/"); 
     555             
     556        try { 
     557            HttpResponse response = httpclient.execute(httpRequest); 
     558            return Long.parseLong(response.getFirstHeader("X-AutoQUEST-OrderingId").getValue()); 
     559        } 
     560        finally { 
     561            httpRequest.releaseConnection(); 
     562        } 
     563    } 
     564 
    512565} 
  • trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitoringProxyTest.java

    r1614 r1991  
    6565     */ 
    6666    private Server dummyMonitor; 
     67 
     68    /** 
     69     * the id generator used by the dummy 
     70     */ 
     71    private IdGenerator idGenerator; 
    6772     
    6873    /** 
     
    7782        // setup a simple HTTP server 
    7883        messages = new LinkedList<String>(); 
     84         
     85        idGenerator = new SimpleIdGenerator(); 
     86        idGenerator.init(); 
     87        idGenerator.start(); 
    7988         
    8089        dummyMonitor = new Server(MONITOR_PORT); 
     
    99108            } 
    100109        } 
     110         
    101111        if (dummyMonitor != null) { 
    102112            try { 
     
    105115            finally { 
    106116                dummyMonitor = null; 
     117            } 
     118        } 
     119         
     120        if (idGenerator != null) { 
     121            try { 
     122                idGenerator.stop(); 
     123            } 
     124            finally { 
     125                idGenerator = null; 
    107126            } 
    108127        } 
     
    642661         
    643662        /* (non-Javadoc) 
    644          * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) 
     663         * @see HttpServlet#service(HttpServletRequest, HttpServletResponse) 
    645664         */ 
    646665        @Override 
     
    653672            System.out.println("send ok response"); 
    654673        } 
     674 
     675        /* (non-Javadoc) 
     676         * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) 
     677         */ 
     678        @Override 
     679        protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
     680            throws ServletException, IOException 
     681        { 
     682            resp.setHeader("X-AutoQUEST-OrderingId", Long.toString(idGenerator.getNextId())); 
     683        } 
    655684         
    656685         
  • trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitor.java

    r1384 r1991  
    2222 * <p> 
    2323 * The HTTP monitor starts a web server ({@link HttpMonitorServer}) that receives exchanges 
    24  * of the HTTP proxy. These exchanges are logged using the {@link HttpMonitorLogManager}. The 
    25  * class assures that on shutdown e.g. caused by CTRL-C the server and the log manager are 
    26  * stopped correctly. 
     24 * of the HTTP proxy. In addition, it provides via get a unique ordering id for requests and 
     25 * responses that can be used by the proxies when creating the exchanges. The exchanges are 
     26 * logged using the {@link HttpMonitorLogManager}. The class assures that on shutdown e.g. caused 
     27 * by CTRL-C the server and the log manager are stopped correctly. 
    2728 * </p> 
    2829 *  
     
    5051     */ 
    5152    private HttpMonitorLogManager logManager; 
     53 
     54    /** 
     55     * the id generator used for getting new unique ids 
     56     */ 
     57    private IdGenerator idGenerator; 
    5258 
    5359    /** 
     
    9298         
    9399        try { 
     100            idGenerator = new SimpleIdGenerator(); 
     101            idGenerator.init(); 
     102 
    94103            logManager = new HttpMonitorLogManager(logFileBaseDir); 
    95104            logManager.init(); 
    96105         
    97             Servlet servlet = new HttpMonitorServlet(logManager); 
     106            Servlet servlet = new HttpMonitorServlet(logManager, idGenerator); 
    98107            server = new HttpMonitorServer(port, servlet); 
    99108            server.init(); 
     
    118127        try { 
    119128            Runtime.getRuntime().addShutdownHook(shutdownHook); 
     129            idGenerator.start(); 
    120130            logManager.start(); 
    121131            server.start(); 
     
    139149        server.stop(); 
    140150        logManager.stop(); 
     151        idGenerator.stop(); 
    141152         
    142153        server = null; 
    143154        logManager = null; 
     155        idGenerator = null; 
    144156    } 
    145157 
  • trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitorServer.java

    r1384 r1991  
    5555     * 
    5656     * @param port    the port to listen on 
    57      * @param servlet teh servlet to be deployed 
     57     * @param servlet the servlet to be deployed 
    5858     */ 
    5959    public HttpMonitorServer(int port, Servlet servlet) { 
  • trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/HttpMonitorServlet.java

    r1561 r1991  
    3333 * the servlet deployed in the web server that receives all recorded exchanges from the proxy. The 
    3434 * exchanges are parsed and forwarded to the provided exchange handler. If an exchange can not 
    35  * be parsed it is discarded. Exchanges are only received via the POST HTTP method. 
     35 * be parsed it is discarded. Exchanges are only received via the POST HTTP method. Via the GET 
     36 * method, the servlet provides unique ordering ids as a header parameter in the response. The 
     37 * header parameter is named "X-AutoQUEST-OrderingId". For creating the ids it uses a provided id 
     38 * generator. 
    3639 * </p> 
    3740 *  
     
    4750     */ 
    4851    private transient HttpMonitorExchangeHandler exchangeHandler; 
     52     
     53    /** 
     54     * the id generator used to return new unique ids. 
     55     */ 
     56    private transient IdGenerator idGenerator; 
    4957 
    5058    /** 
    5159     * <p> 
    5260     * initializes the servlet with the exchange handler to which all exchanges shall be forwarded 
     61     * and the id generator to be used for returning new ids 
    5362     * </p> 
    5463     * 
    5564     * @param exchangeHandler the exchange handler that shall receive all exchanges 
     65     * @param idGenerator     the id generator used to generate new ids 
    5666     */ 
    57     HttpMonitorServlet(HttpMonitorExchangeHandler exchangeHandler) { 
     67    HttpMonitorServlet(HttpMonitorExchangeHandler exchangeHandler, IdGenerator idGenerator) { 
    5868        this.exchangeHandler = exchangeHandler; 
     69        this.idGenerator = idGenerator; 
    5970    } 
    6071 
     
    8798        } 
    8899    } 
     100 
     101    /** 
     102     * this implements handling of doGet. For this servlet this means that we return a unique 
     103     * ordering id which can be used by proxies as ordering ids for requests and responses. 
     104     *  
     105     * (non-Javadoc) (non-Javadoc) 
     106     * @see HttpServlet#doGet(HttpServletRequest, HttpServletResponse) 
     107     */ 
     108    @Override 
     109    protected void doGet(HttpServletRequest request, HttpServletResponse response) 
     110        throws ServletException, IOException 
     111    { 
     112        response.setHeader("X-AutoQUEST-OrderingId", Long.toString(idGenerator.getNextId())); 
     113    } 
    89114     
    90115} 
  • trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/ExchangeListener.java

    r1561 r1991  
    2727 
    2828import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorExchangeHandler; 
     29import de.ugoe.cs.autoquest.httpmonitor.IdGenerator; 
    2930import de.ugoe.cs.autoquest.plugin.http.logdata.Address; 
    3031import de.ugoe.cs.autoquest.plugin.http.logdata.Content; 
     
    4647 * recording an exchange can not be done in one step. This is due to the fact, that the proxy 
    4748 * servlet notifies different processing states for requests and response. An exchange listener 
    48  * records all these event. On the occurrence of the final event, it compiles an 
    49  * {@link HttpExchange} and forwards it to the exchange handler. 
     49 * records all these events. On the occurrence of the final event, it compiles an 
     50 * {@link HttpExchange} and forwards it to the exchange handler. When receiving the first event 
     51 * of the request, it also determines a respective ordering id. The same applies for the response. 
     52 * The ordering ids are retrieved from a provided id generator. 
    5053 * </p> 
    5154 *  
     
    6366    /** 
    6467     * <p> 
     68     * the id generator used to generate ordering ids for requests and responses 
     69     * </p> 
     70     */ 
     71    private IdGenerator idGenerator; 
     72     
     73    /** 
     74     * <p> 
    6575     * the request of compiled exchange 
    6676     * </p> 
    6777     */ 
    6878    private HttpServletRequest request; 
     79     
     80    /** 
     81     * <p> 
     82     * the ordering id for the request 
     83     * </p> 
     84     */ 
     85    private long requestOrderingId; 
    6986 
    7087    /** 
     
    8198     */ 
    8299    private HttpServletResponse response; 
     100     
     101    /** 
     102     * <p> 
     103     * the ordering id for the response 
     104     * </p> 
     105     */ 
     106    private long responseOrderingId; 
    83107 
    84108    /** 
     
    99123     * <p> 
    100124     * initialized the exchange listener with the exchange handler to forward compiled exchanges to 
     125     * and the id generator to be used for generating ordering ids for requests and responses 
    101126     * </p> 
    102127     *  
    103128     * @param exchangeHandler the exchange handler to forward compiled exchanges to 
    104      */ 
    105     ExchangeListener(HttpMonitorExchangeHandler exchangeHandler) { 
     129     * @param idGenerator     the id generator to used for generating ordering ids 
     130     */ 
     131    ExchangeListener(HttpMonitorExchangeHandler exchangeHandler, IdGenerator idGenerator) { 
    106132        this.exchangeHandler = exchangeHandler; 
     133        this.idGenerator = idGenerator; 
    107134    } 
    108135 
     
    123150        lastUpdate = System.currentTimeMillis(); 
    124151        this.request = request; 
     152        this.requestOrderingId = idGenerator.getNextId(); 
    125153    } 
    126154 
     
    159187        lastUpdate = System.currentTimeMillis(); 
    160188        this.response = response; 
     189        this.responseOrderingId = idGenerator.getNextId(); 
    161190    } 
    162191     
     
    239268        exchange.setReceiver(address); 
    240269         
    241         exchange.setRequest(map(request, eventObjectFactory)); 
    242         exchange.setResponse(map(response, eventObjectFactory)); 
     270        exchange.setRequest(map(request, requestOrderingId, eventObjectFactory)); 
     271        exchange.setResponse(map(response, responseOrderingId, eventObjectFactory)); 
    243272         
    244273        exchangeHandler.handleHttpExchange(exchange); 
     
    250279     * </p> 
    251280     */ 
    252     private HttpRequest map(HttpServletRequest request, ObjectFactory eventObjectFactory) { 
     281    private HttpRequest map(HttpServletRequest request, 
     282                            long               requestOrderingId, 
     283                            ObjectFactory      eventObjectFactory) 
     284    { 
    253285        HttpRequest eventRequest = eventObjectFactory.createHttpRequest(); 
     286        eventRequest.setOrderingId(requestOrderingId); 
    254287        eventRequest.setMethod(Method.fromValue(request.getMethod())); 
    255288        eventRequest.setProtocol(Protocol.fromValue(request.getProtocol())); 
     
    311344     * </p> 
    312345     */ 
    313     private HttpResponse map(HttpServletResponse response, ObjectFactory eventObjectFactory) { 
     346    private HttpResponse map(HttpServletResponse response, 
     347                             long                responseOrderingId, 
     348                             ObjectFactory       eventObjectFactory) 
     349    { 
    314350        HttpResponse eventResponse = eventObjectFactory.createHttpResponse(); 
    315351         
    316352        eventResponse.setStatus(BigInteger.valueOf(response.getStatus())); 
     353        eventResponse.setOrderingId(responseOrderingId); 
    317354 
    318355        Headers headers = eventObjectFactory.createHeaders(); 
  • trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/ExchangeListenerManager.java

    r1561 r1991  
    3030import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorException; 
    3131import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorExchangeHandler; 
     32import de.ugoe.cs.autoquest.httpmonitor.IdGenerator; 
    3233import de.ugoe.cs.autoquest.plugin.http.logdata.Status; 
    3334import de.ugoe.cs.util.console.Console; 
     
    6061    /** 
    6162     * <p> 
     63     * the id generator used to generate ordering ids for requests and responses 
     64     * </p> 
     65     */ 
     66    private IdGenerator idGenerator; 
     67     
     68    /** 
     69     * <p> 
    6270     * the mapping of requests handled by the proxy to the respective exchange listeners 
    6371     * </p> 
     
    7987     *  
    8088     * @param exchangeHandler the exchange handler to be forwarded to the exchange listeners 
    81      */ 
    82     ExchangeListenerManager(HttpMonitorExchangeHandler exchangeHandler) { 
     89     * @param idGenerator     the id generator to used for generating ordering ids 
     90     */ 
     91    ExchangeListenerManager(HttpMonitorExchangeHandler exchangeHandler, IdGenerator idGenerator) { 
    8392        this.exchangeHandler = exchangeHandler; 
     93        this.idGenerator = idGenerator; 
    8494    } 
    8595 
     
    219229                if (listener == null) { 
    220230                    Console.traceln(Level.FINEST, "creating exchange listener for " + request); 
    221                     listener = new ExchangeListener(exchangeHandler);  
     231                    listener = new ExchangeListener(exchangeHandler, idGenerator);  
    222232                    listeners.put(request, listener); 
    223233                } 
  • trunk/autoquest-httpmonitor/src/main/java/de/ugoe/cs/autoquest/httpmonitor/proxy/HttpMonitorRemoteExchangeHandler.java

    r1614 r1991  
    1717import java.io.IOException; 
    1818import java.io.OutputStreamWriter; 
    19 import java.util.HashSet; 
    20 import java.util.Set; 
    2119import java.util.logging.Level; 
    2220 
     
    2523import javax.xml.bind.Marshaller; 
    2624 
    27 import org.eclipse.jetty.client.HttpClient; 
    2825import org.eclipse.jetty.client.api.Request; 
    29 import org.eclipse.jetty.client.api.Response.CompleteListener; 
    3026import org.eclipse.jetty.client.api.Result; 
    3127import org.eclipse.jetty.client.util.OutputStreamContentProvider; 
    3228import org.eclipse.jetty.http.HttpMethod; 
    3329import org.eclipse.jetty.http.HttpVersion; 
    34 import org.eclipse.jetty.util.thread.QueuedThreadPool; 
    3530 
    3631import de.ugoe.cs.autoquest.httpmonitor.HttpMonitor; 
    37 import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorComponent; 
    38 import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorException; 
    3932import de.ugoe.cs.autoquest.httpmonitor.HttpMonitorExchangeHandler; 
    4033import de.ugoe.cs.autoquest.plugin.http.logdata.HttpExchange; 
     
    4841 * request/response. It then creates an HTTP request to the central monitor and sends it there. 
    4942 * It is initialized with the name of the server and the port on which the central monitor runs. 
    50  * If the exchanges can not be forwarded to the central server, they are discarded. 
     43 * If the exchanges cannot be forwarded to the central server, they are discarded. 
    5144 * </p> 
    5245 *  
     
    5447 */ 
    5548public class HttpMonitorRemoteExchangeHandler 
    56     implements CompleteListener, HttpMonitorExchangeHandler, HttpMonitorComponent 
     49    extends HttpMonitorRemoteConnection 
     50    implements HttpMonitorExchangeHandler 
    5751{ 
    58  
    59     /** 
    60      * <p> 
    61      * the HTTP client used internally to send data to the central server 
    62      * </p> 
    63      */ 
    64     private HttpClient httpClient; 
    65      
    66     /** 
    67      * <p> 
    68      * the host name of the central server 
    69      * </p> 
    70      */ 
    71     private String httpMonitorServer; 
    72      
    73     /** 
    74      * <p> 
    75      * the port of the central server 
    76      * </p> 
    77      */ 
    78     private int httpMonitorPort; 
    79  
    80     /** 
    81      * <p> 
    82      * a set of requests send to the central server for which the response was not received yet 
    83      * </p> 
    84      */ 
    85     private Set<Request> openRequests = new HashSet<Request>(); 
    8652     
    8753    /** 
     
    9460     */ 
    9561    public HttpMonitorRemoteExchangeHandler(String httpMonitorServer, int httpMonitorPort) { 
    96         this.httpMonitorServer = httpMonitorServer; 
    97         this.httpMonitorPort = httpMonitorPort; 
    98     } 
    99  
    100     /* (non-Javadoc) 
    101      * @see de.ugoe.cs.autoquest.httpmonitor.HttpMonitorComponent#init() 
    102      */ 
    103     @Override 
    104     public void init() throws IllegalStateException, HttpMonitorException { 
    105         httpClient = createHttpClient(); 
    106     } 
    107  
    108     /* (non-Javadoc) 
    109      * @see de.ugoe.cs.autoquest.httpmonitor.HttpMonitorComponent#start() 
    110      */ 
    111     @Override 
    112     public void start() throws IllegalStateException, HttpMonitorException { 
    113         try { 
    114             httpClient.start(); 
    115             httpClient.getContentDecoderFactories().clear(); 
    116         } 
    117         catch (Exception e) { 
    118             throw new HttpMonitorException("could not start client for HTTP-Monitor", e); 
    119         } 
    120     } 
    121  
    122     /* (non-Javadoc) 
    123      * @see de.ugoe.cs.autoquest.httpmonitor.HttpMonitorComponent#stop() 
    124      */ 
    125     @Override 
    126     public void stop() { 
    127         if (httpClient != null) { 
    128             try { 
    129                 httpClient.stop(); 
    130             } 
    131             catch (Exception e) { 
    132                 Console.traceln(Level.WARNING, "could not stop client for HTTP-Monitor"); 
    133                 Console.logException(e); 
    134             } 
    135         } 
    136          
    137         httpClient = null; 
     62        super(httpMonitorServer, httpMonitorPort); 
    13863    } 
    13964 
     
    14469    public synchronized void handleHttpExchange(HttpExchange httpExchange) { 
    14570        // send the exchange to the server and wait for completion 
    146         Request httpMonitorRequest = httpClient.newRequest(httpMonitorServer, httpMonitorPort); 
     71        Request httpMonitorRequest = super.newRequest(); 
    14772        httpMonitorRequest.method(HttpMethod.POST); 
    14873        httpMonitorRequest.version(HttpVersion.HTTP_1_1); 
     
    15176        httpMonitorRequest.content(out); 
    15277         
    153         openRequests.add(httpMonitorRequest); 
    154         httpMonitorRequest.send(this); 
     78        super.sendRequest(httpMonitorRequest); 
    15579 
    15680        try { 
     
    17397            Console.logException(e); 
    17498        } 
    175  
    176         try { 
    177             // wait for the request to be removed from the list asynchronously 
    178             int count = 30; 
    179             while (openRequests.contains(httpMonitorRequest)) { 
    180                 this.wait(1000); 
    181                  
    182                 if (--count == 0) { 
    183                     // after 30 seconds, cancel the sending of the loggin request 
    184                     openRequests.remove(httpMonitorRequest); 
    185                     break; 
    186                 } 
    187             } 
    188         } 
    189         catch (InterruptedException e) { 
    190             // ignore, as this may only happen on system shutdown 
    191         } 
    192     } 
    193  
    194     /* (non-Javadoc) 
    195      * @see org.eclipse.jetty.client.api.Response.CompleteListener#onComplete(Result) 
    196      */ 
    197     @Override 
    198     public synchronized void onComplete(Result result) { 
     99         
     100        // wait to ensure that the request was received 
     101        Result result = super.getResult(httpMonitorRequest); 
     102         
    199103        if (result.isFailed()) { 
    200104            Console.traceln 
     
    202106            Console.logException((Exception) result.getFailure()); 
    203107        } 
    204          
    205         openRequests.remove(result.getRequest()); 
    206         this.notify(); 
    207     } 
    208  
    209     /** 
    210      * <p> 
    211      * convenience method to create an initialize the utilized HTTP client 
    212      * </p> 
    213      */ 
    214     private HttpClient createHttpClient() { 
    215         HttpClient client = new HttpClient(); 
    216          
    217         QueuedThreadPool executor = new QueuedThreadPool(10); 
    218         executor.setName("HttpMonitorClients"); 
    219         client.setExecutor(executor); 
    220  
    221         client.setMaxConnectionsPerDestination(10000); 
    222         client.setIdleTimeout(30000); 
    223         client.setConnectTimeout(30000); 
    224         client.setStopTimeout(30000); 
    225         client.setRequestBufferSize(1024*1024); 
    226         client.setResponseBufferSize(1024*1024); 
    227          
    228         return client; 
    229108    } 
    230109} 
  • 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.