Changeset 1227 for trunk


Ignore:
Timestamp:
06/26/13 15:30:58 (11 years ago)
Author:
pharms
Message:
  • changed log file directory structure for better distinguishing the monitored applications
  • extended session timeout to potentially reduce log file sizes
  • increased log file maximum sizes to reduce storage consumption due do GUI model duplication
Location:
trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlClientInfos.java

    r1019 r1227  
    9292    } 
    9393 
     94    /** 
     95     * @return the id of the monitored web application which is the host and port 
     96     */ 
     97    String getWebAppId() { 
     98        String id = url.getHost(); 
     99        if ("".equals(id)) { 
     100            id = "unknown"; 
     101        } 
     102         
     103        if (url.getPort() > 0) { 
     104            id += "_" + url.getPort(); 
     105        } 
     106         
     107        return id; 
     108    } 
     109 
    94110} 
  • trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlMonitorLogManager.java

    r1069 r1227  
    4141     * the timeout after which a writer of an inactive client is closed 
    4242     */ 
    43     private static final int SESSION_TIMEOUT = 100000; 
     43    private static final int SESSION_TIMEOUT = 10 * 60 * 1000; 
    4444     
    4545    /** 
     
    126126                    writer = writers.get(clientInfos.getClientId()); 
    127127                    if (writer == null) { 
    128                         writer = 
    129                             new HtmlMonitorOutputWriter(logFileBaseDir, clientInfos.getClientId()); 
     128                        writer = new HtmlMonitorOutputWriter 
     129                            (logFileBaseDir, clientInfos.getWebAppId(), clientInfos.getClientId()); 
     130 
    130131                        writer.init(); 
    131132                        writer.start(); 
  • trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlMonitorOutputWriter.java

    r1089 r1227  
    5151     * the maximum size of an individual log file 
    5252     */ 
    53     private static final int MAXIMUM_LOG_FILE_SIZE = 10000000; 
     53    private static final int MAXIMUM_LOG_FILE_SIZE = 50000000; 
    5454 
    5555    /** 
     
    6262     */ 
    6363    private File logFileBaseDir; 
     64 
     65    /** 
     66     * the id of the web application used by the client 
     67     */ 
     68    private String webAppId; 
    6469 
    6570    /** 
     
    97102     * @param logFileBaseDir the log file base directory, or null if the default directory shall 
    98103     *                       be taken 
     104     * @param webAppId       the ID of the web application used by the client 
    99105     * @param clientId       the ID of the client, for which this writer logs 
    100106     */ 
    101     public HtmlMonitorOutputWriter(String logFileBaseDir, String clientId) { 
     107    public HtmlMonitorOutputWriter(String logFileBaseDir, String webAppId, String clientId) { 
    102108        if (logFileBaseDir == null) { 
    103109            this.logFileBaseDir = new File(DEFAULT_LOG_FILE_BASE_DIR); 
     
    107113        } 
    108114         
     115        this.webAppId = webAppId; 
    109116        this.clientId = clientId; 
    110117         
     
    123130        synchronized (HtmlMonitorOutputWriter.class) { 
    124131            try { 
    125                 File clientLogDir = new File(logFileBaseDir, clientId); 
    126              
     132                File clientLogDir = new File(logFileBaseDir, webAppId); 
     133                clientLogDir = new File(clientLogDir, clientId); 
     134                 
    127135                if (!clientLogDir.exists()) { 
    128136                    if (!clientLogDir.mkdirs()) { 
     
    136144                } 
    137145                 
     146                handleOldLogFiles(new File(logFileBaseDir, clientId), clientLogDir); 
     147                 
    138148                logFile = new File(clientLogDir, getLogFileName(-1)); 
    139149                 
     
    318328        } 
    319329        else { 
    320             val = value.toString(); 
     330            val = String.valueOf(value); 
    321331        } 
    322332         
     
    399409    } 
    400410 
     411    /** 
     412     * <p> 
     413     * this method moves old logfiles of the same client resisting in the wrong old directory 
     414     * structure to the new one. 
     415     * </p> 
     416     * 
     417     * @param file 
     418     * @param clientLogDir 
     419     */ 
     420    private void handleOldLogFiles(File oldLogDir, File newLogDir) { 
     421        if (oldLogDir.exists() && oldLogDir.isDirectory()) { 
     422            for (File oldLogFile : oldLogDir.listFiles()) { 
     423                oldLogFile.renameTo(new File(newLogDir, oldLogFile.getName())); 
     424            } 
     425             
     426            oldLogDir.delete(); 
     427        } 
     428    } 
     429 
    401430    /* (non-Javadoc) 
    402431     * @see de.ugoe.cs.autoquest.htmlmonitor.HtmlMonitorComponent#stop() 
Note: See TracChangeset for help on using the changeset viewer.