Correcting resolution of index location under hudson (adjusting to changes done in indexers)
authorJan Lahoda <jlahoda@netbeans.org>
Fri, 21 Jan 2011 18:30:16 +0100
changeset 5243b13a4ec61b0
parent 523 9263091c58de
child 525 5aa5da27a106
Correcting resolution of index location under hudson (adjusting to changes done in indexers)
server/hudson/src/main/java/org/netbeans/modules/jackpot30/hudson/Cache.java
server/hudson/src/main/java/org/netbeans/modules/jackpot30/hudson/ClearIndexProperty.java
server/hudson/src/main/java/org/netbeans/modules/jackpot30/hudson/IndexingBuilder.java
     1.1 --- a/server/hudson/src/main/java/org/netbeans/modules/jackpot30/hudson/Cache.java	Thu Jan 20 23:30:03 2011 +0100
     1.2 +++ b/server/hudson/src/main/java/org/netbeans/modules/jackpot30/hudson/Cache.java	Fri Jan 21 18:30:16 2011 +0100
     1.3 @@ -67,20 +67,22 @@
     1.4      private static File standaloneCacheRoot;
     1.5      private static Map<String, Cache> name2Cache = new HashMap<String, Cache>();
     1.6  
     1.7 -    public static Cache findCache(String indexName) {
     1.8 +    public static Cache findCache(String indexName, int version) {
     1.9          Cache cache = name2Cache.get(indexName);
    1.10  
    1.11          if (cache == null) {
    1.12 -            name2Cache.put(indexName, cache = new Cache(indexName));
    1.13 +            name2Cache.put(indexName, cache = new Cache(indexName, version));
    1.14          }
    1.15  
    1.16          return cache;
    1.17      }
    1.18  
    1.19      private final String name;
    1.20 +    private final int version;
    1.21  
    1.22 -    private Cache(String name) {
    1.23 +    private Cache(String name, int version) {
    1.24          this.name = name;
    1.25 +        this.version = version;
    1.26      }
    1.27      
    1.28      public File findCacheRoot(URL sourceRoot) throws IOException {
    1.29 @@ -90,7 +92,7 @@
    1.30              Logger.getLogger(Cache.class.getName()).log(Level.SEVERE, null, ex);
    1.31          }
    1.32          if (standaloneCacheRoot != null) {
    1.33 -            return getDataFolder(sourceRoot, name);
    1.34 +            return getDataFolder(sourceRoot, name, version);
    1.35          } else {
    1.36              throw new IllegalStateException();
    1.37          }
    1.38 @@ -179,7 +181,7 @@
    1.39          }
    1.40      }
    1.41  
    1.42 -    private static synchronized File getDataFolder (final URL root, String name) throws IOException {
    1.43 +    private static synchronized File getDataFolder (final URL root, String name, int version) throws IOException {
    1.44          loadSegments ();
    1.45          final String rootName = root.toExternalForm();
    1.46          String slice = invertedSegments.get (rootName);
    1.47 @@ -193,7 +195,7 @@
    1.48              storeSegments ();
    1.49          }
    1.50          final File folder = standaloneCacheRoot;
    1.51 -        return new File(new File(folder, slice), name);
    1.52 +        return new File(new File(new File(folder, slice), name), Integer.toString(version));
    1.53      }
    1.54  
    1.55      private static synchronized File getCacheFolder () {
     2.1 --- a/server/hudson/src/main/java/org/netbeans/modules/jackpot30/hudson/ClearIndexProperty.java	Thu Jan 20 23:30:03 2011 +0100
     2.2 +++ b/server/hudson/src/main/java/org/netbeans/modules/jackpot30/hudson/ClearIndexProperty.java	Fri Jan 21 18:30:16 2011 +0100
     2.3 @@ -89,7 +89,7 @@
     2.4          public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, InterruptedException {
     2.5              String jobName = job.getName();
     2.6              Project<?, ?> prj = Hudson.getInstance().getItemByFullName(jobName, Project.class);
     2.7 -            File cacheRoot = Cache.findCache("clear-workspace").findCacheRoot(prj.getSomeWorkspace().toURI().toURL()).getParentFile();
     2.8 +            File cacheRoot = Cache.findCache("clear-workspace", 0).findCacheRoot(prj.getSomeWorkspace().toURI().toURL()).getParentFile().getParentFile();
     2.9  
    2.10              deleteRecursivelly(cacheRoot);
    2.11              
     3.1 --- a/server/hudson/src/main/java/org/netbeans/modules/jackpot30/hudson/IndexingBuilder.java	Thu Jan 20 23:30:03 2011 +0100
     3.2 +++ b/server/hudson/src/main/java/org/netbeans/modules/jackpot30/hudson/IndexingBuilder.java	Fri Jan 21 18:30:16 2011 +0100
     3.3 @@ -142,7 +142,7 @@
     3.4              success &= indexer.index(new IndexingContext(getDescriptor().getCacheDir(), build, launcher, listener, addedFiles, removedFiles));
     3.5          }
     3.6          //XXX:
     3.7 -        File info = new File(Cache.findCache("jackpot30").findCacheRoot(build.getWorkspace().toURI().toURL()), "info");
     3.8 +        File info = new File(Cache.findCache("jackpot30", 1002).findCacheRoot(build.getWorkspace().toURI().toURL()), "info");
     3.9          String jsonContent = readFully(info);
    3.10          JSONObject json = JSONObject.fromObject(jsonContent);
    3.11