Ignore:
Timestamp:
2015-06-05T20:58:20+12:00 (9 years ago)
Author:
ak19
Message:

First of two commits to fix rebuilding a collection using the online editor on Windows. Resolves the file lock problem. The java code works with changes in activate.pl. activate.pl is passed a flag so that it no longer de-activates and re-activates the collection itself, but just concerns itself with moving building to index. The GS2Construct java code now de-activates the collection prior to calling activate.pl and then re-activates it afterward. In the way it was done before, activate.pl used to handle de- and re-activating the collection. But when it was launched from the server java code, the java VM would exit having left a copy of the file handles to the perl process when forking the process for activate.pl. The perl code could not move building to index since the file handles had locks (6 of them) on the index/text/collection.gdb. Changes have been made to GS2PerlConstructor too, so that it more cleanly closes all the pipes of a process, that the process itself may thereby exit cleanly. Not yet able to move this properly into its own classes since the StreamGobbler classes in GLI are not quite suited but were customised for FormatConverter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java

    r29869 r29947  
    330330        String lang = request.getAttribute(GSXML.LANG_ATT);
    331331
    332         Element response = runCommand(request, GS2PerlConstructor.ACTIVATE);
     332        UserContext userContext = new UserContext(request);
     333        String request_type = request.getAttribute(GSXML.TYPE_ATT);
     334       
     335        // now we de-activate the collection before running activate.pl, and then re-activate at end
     336        // So activate.pl only does the moving, no activation. This way will prevent java from launching
     337        // perl, exiting and then leaving dangling file handles (on index/text/col.gdb) in perl.
     338        if (!request_type.equals(GSXML.REQUEST_TYPE_STATUS)) {         
     339            systemRequest("delete", coll_name, null, userContext); // deactivate collection
     340        }   
     341
     342        Element response = runCommand(request, GS2PerlConstructor.ACTIVATE); // if request is for STATUS, then this won't run activate.pl
     343
    333344        Element status = (Element) GSXML.getChildByTagName(response, GSXML.STATUS_ELEM);
    334 
    335         String request_type = request.getAttribute(GSXML.TYPE_ATT);
    336         if (request_type.equals(GSXML.REQUEST_TYPE_STATUS))
    337         {
    338             return response;
    339         }
    340 
    341         UserContext userContext = new UserContext(request);
    342         systemRequest("delete", coll_name, null, userContext);
    343345
    344346        // check for finished
     
    384386        status.appendChild(t);
    385387        // once have got here, we assume
    386         // the first bit proceeded successfully, now reload the collection
     388        // the first bit proceeded successfully, now reload the collection (sends a collection reactivation request)
    387389        systemRequest("reload", coll_name, status, userContext); // this will append more messages to the status, and overwrite the error code att
    388390        return response;
Note: See TracChangeset for help on using the changeset viewer.