You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Clinton Davidson (JIRA)" <ax...@ws.apache.org> on 2005/01/26 18:32:18 UTC

[jira] Created: (AXIS-1782) Delete orphaned temp files on startup

Delete orphaned temp files on startup
-------------------------------------

         Key: AXIS-1782
         URL: http://issues.apache.org/jira/browse/AXIS-1782
     Project: Axis
        Type: Improvement
  Components: Basic Architecture  
    Versions: 1.1rc2    
 Environment: Windows 2000, Java
    Reporter: Clinton Davidson
    Priority: Minor


The use case is to delete orphaned temp files, e.g. those that may have been left over from abnormal VM termination. 

 

The proposed changes would be in  org.apache.axis.AxisEngine.java, with a minor change in org.apache.axis.attachments.ManagedMemoryDataSource.java

 

In AxisEngine:

 

Changes to imports:

 

import java.io.FilenameFilter;

import java.io.File;

 

in member variables:

 

 /** Temp file prefix used when the data is flushed to disk */

 public static final String TEMP_FILE_PREFIX = "Axis";

 /** Temp file suffix used when the data is flushed to disk */

 public static final String TEMP_FILE_SUFFIX = "axis";

 

 /** <code>true</code> if the orphaned disk cache files have been deleted **/

 private static boolean orphanedDiskCacheFilesDeleted = false;

 

 

in init, directly before the log message to exit:

 

//only do it once

if (!orphanedDiskCacheFilesDeleted) {

    deleteOrphanedDiskCacheFiles();

    orphanedDiskCacheFilesDeleted = true;

}

 

Additional method to remove temp files:

 

     private void deleteOrphanedDiskCacheFiles()

     {

         if (log.isDebugEnabled()) {

             log.debug("Enter: AxisEngine::deleteOrphanedDiskCacheFiles");

         }

 

         String tempDirName = (String) getOption(PROP_ATTACHMENT_DIR);

         if (tempDirName == null) {

             tempDirName = System.getProperty("java.io.tmpdir");

         }

 

         if (log.isTraceEnabled()) {

             log.trace("tempDirName: " + tempDirName);

         }

 

         File tempDir = new File(tempDirName);

         if (!tempDir.exists() || !tempDir.isDirectory())

             return;

 

         //matches our temp files

         FilenameFilter tempFileFilter = new FilenameFilter() {

             public boolean accept(File dir, String name) {

                 boolean isTempFile = name.startsWith(TEMP_FILE_PREFIX) && name.endsWith(TEMP_FILE_SUFFIX);

                 return isTempFile;

             }

         };

 

         File[] tempFiles = tempDir.listFiles(tempFileFilter);

         if (log.isTraceEnabled()) {

             log.trace("number of our temp files in the temp dir: " + tempFiles.length);

         }

         for (int i = 0; i < tempFiles.length; i++) {

             File tempFile = tempFiles[i];

             if (log.isTraceEnabled()) {

                 log.trace("deleting our temp file: " + tempFile.getName());

             }

             tempFile.delete();

         }

 

         if (log.isDebugEnabled()) {

             log.debug("Exit: AxisEngine::deleteOrphanedDiskCacheFiles");

         }

     }

 

In ManagedMemoryDataSource:

 

Add an import for axis engine:

 

import org.apache.axis.AxisEngine;

 

 

in flushToDisk(), replace the hard coded name with the constant from AxisEngine

 

//diskCacheFile = java.io.File.createTempFile("Axis", "axis",

diskCacheFile = java.io.File.createTempFile(AxisEngine.TEMP_FILE_PREFIX, AxisEngine.TEMP_FILE_SUFFIX,

 

 

I was not clear if this should be a bug, feature request, or improvement. I posted to the dev mailing list, but got no response. Let me know if you have any feedback about the proposed patch.

 

Thanks

 

Clinton

   

 

 

 

 

 

 


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXIS-1782) Delete orphaned temp files on startup

Posted by "Clinton Davidson (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXIS-1782?page=comments#action_58096 ]
     
Clinton Davidson commented on AXIS-1782:
----------------------------------------

Sorry, I meant this for 1.2 rc2, although the issue is present in 1.1 as well. 

> Delete orphaned temp files on startup
> -------------------------------------
>
>          Key: AXIS-1782
>          URL: http://issues.apache.org/jira/browse/AXIS-1782
>      Project: Axis
>         Type: Improvement
>   Components: Basic Architecture
>     Versions: 1.1rc2
>  Environment: Windows 2000, Java
>     Reporter: Clinton Davidson
>     Priority: Minor

>
> The use case is to delete orphaned temp files, e.g. those that may have been left over from abnormal VM termination. 
>  
> The proposed changes would be in  org.apache.axis.AxisEngine.java, with a minor change in org.apache.axis.attachments.ManagedMemoryDataSource.java
>  
> In AxisEngine:
>  
> Changes to imports:
>  
> import java.io.FilenameFilter;
> import java.io.File;
>  
> in member variables:
>  
>  /** Temp file prefix used when the data is flushed to disk */
>  public static final String TEMP_FILE_PREFIX = "Axis";
>  /** Temp file suffix used when the data is flushed to disk */
>  public static final String TEMP_FILE_SUFFIX = "axis";
>  
>  /** <code>true</code> if the orphaned disk cache files have been deleted **/
>  private static boolean orphanedDiskCacheFilesDeleted = false;
>  
>  
> in init, directly before the log message to exit:
>  
> //only do it once
> if (!orphanedDiskCacheFilesDeleted) {
>     deleteOrphanedDiskCacheFiles();
>     orphanedDiskCacheFilesDeleted = true;
> }
>  
> Additional method to remove temp files:
>  
>      private void deleteOrphanedDiskCacheFiles()
>      {
>          if (log.isDebugEnabled()) {
>              log.debug("Enter: AxisEngine::deleteOrphanedDiskCacheFiles");
>          }
>  
>          String tempDirName = (String) getOption(PROP_ATTACHMENT_DIR);
>          if (tempDirName == null) {
>              tempDirName = System.getProperty("java.io.tmpdir");
>          }
>  
>          if (log.isTraceEnabled()) {
>              log.trace("tempDirName: " + tempDirName);
>          }
>  
>          File tempDir = new File(tempDirName);
>          if (!tempDir.exists() || !tempDir.isDirectory())
>              return;
>  
>          //matches our temp files
>          FilenameFilter tempFileFilter = new FilenameFilter() {
>              public boolean accept(File dir, String name) {
>                  boolean isTempFile = name.startsWith(TEMP_FILE_PREFIX) && name.endsWith(TEMP_FILE_SUFFIX);
>                  return isTempFile;
>              }
>          };
>  
>          File[] tempFiles = tempDir.listFiles(tempFileFilter);
>          if (log.isTraceEnabled()) {
>              log.trace("number of our temp files in the temp dir: " + tempFiles.length);
>          }
>          for (int i = 0; i < tempFiles.length; i++) {
>              File tempFile = tempFiles[i];
>              if (log.isTraceEnabled()) {
>                  log.trace("deleting our temp file: " + tempFile.getName());
>              }
>              tempFile.delete();
>          }
>  
>          if (log.isDebugEnabled()) {
>              log.debug("Exit: AxisEngine::deleteOrphanedDiskCacheFiles");
>          }
>      }
>  
> In ManagedMemoryDataSource:
>  
> Add an import for axis engine:
>  
> import org.apache.axis.AxisEngine;
>  
>  
> in flushToDisk(), replace the hard coded name with the constant from AxisEngine
>  
> //diskCacheFile = java.io.File.createTempFile("Axis", "axis",
> diskCacheFile = java.io.File.createTempFile(AxisEngine.TEMP_FILE_PREFIX, AxisEngine.TEMP_FILE_SUFFIX,
>  
>  
> I was not clear if this should be a bug, feature request, or improvement. I posted to the dev mailing list, but got no response. Let me know if you have any feedback about the proposed patch.
>  
> Thanks
>  
> Clinton
>    
>  
>  
>  
>  
>  
>  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira