Skip to main content

[glassfish~svn:62356] FPP-1887: start-domain --drop-interrupted-commands command option and fun

  • From: andriy.zhdanov@...
  • To: commits@...
  • Subject: [glassfish~svn:62356] FPP-1887: start-domain --drop-interrupted-commands command option and fun
  • Date: Tue, 16 Jul 2013 15:51:01 +0000

Project:    glassfish
Repository: svn
Revision:   62356
Author:     andriy.zhdanov
Date:       2013-07-16 15:51:00 UTC
Link:       

Log Message:
------------
FPP-1887: start-domain --drop-interrupted-commands command option and 
functionality


Revisions:
----------
62356


Modified Paths:
---------------
trunk/main/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java
trunk/main/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java
trunk/main/nucleus/admin/launcher/src/test/java/com/sun/enterprise/admin/launcher/GFLauncherTest.java
trunk/main/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/SystemPropertyConstants.java
trunk/main/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/AdminCommandInstanceImpl.java
trunk/main/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java
trunk/main/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/JobManagerService.java


Diffs:
------
Index: 
trunk/main/nucleus/admin/launcher/src/test/java/com/sun/enterprise/admin/launcher/GFLauncherTest.java
===================================================================
--- 
trunk/main/nucleus/admin/launcher/src/test/java/com/sun/enterprise/admin/launcher/GFLauncherTest.java
       (revision 62355)
+++ 
trunk/main/nucleus/admin/launcher/src/test/java/com/sun/enterprise/admin/launcher/GFLauncherTest.java
       (revision 62356)
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 2008-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008-2013 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -193,6 +193,13 @@
         assertTrue(launcher.getLogFilename().endsWith("server.log"));
     }
 
+    @Test
+    public void testDropInterruptedCommands() throws GFLauncherException {
+        info.setDomainName("domainNoLog");
+        info.setDropInterruptedCommands(true);
+        launcher.launch();
+        
assertTrue(launcher.getJvmOptions().contains("-Dorg.glassfish.job-manager.drop-interrupted-commands=true"));
+    }
 
     //private static File domain1, domain2, domain3, domain4, domain5;
     private static File installDir;
Index: 
trunk/main/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java
===================================================================
--- 
trunk/main/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java
   (revision 62355)
+++ 
trunk/main/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java
   (revision 62356)
@@ -1,7 +1,7 @@
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * Copyright (c) 2008-2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008-2013 Oracle and/or its affiliates. All rights reserved.
  *
  * The contents of this file are subject to the terms of either the GNU
  * General Public License Version 2 only ("GPL") or the Common Development
@@ -50,6 +50,7 @@
 import com.sun.enterprise.universal.process.ProcessStreamDrainer;
 import com.sun.enterprise.universal.xml.MiniXmlParserException;
 import com.sun.enterprise.util.OS;
+import com.sun.enterprise.util.SystemPropertyConstants;
 import com.sun.enterprise.util.io.FileUtils;
 import com.sun.enterprise.universal.glassfish.ASenvPropertyReader;
 import com.sun.enterprise.universal.xml.MiniXmlParser;
@@ -766,6 +767,9 @@
             rawJvmOptions.addAll(profiler.getJvmOptions());
         }
         jvmOptions = new JvmOptions(rawJvmOptions);
+        if (info.isDropInterruptedCommands()) {
+            
jvmOptions.sysProps.put(SystemPropertyConstants.DROP_INTERRUPTED_COMMANDS, 
Boolean.TRUE.toString());
+        }
     }
 
     private void setupUpgradeSecurity() throws GFLauncherException {
Index: 
trunk/main/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java
===================================================================
--- 
trunk/main/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java
       (revision 62355)
+++ 
trunk/main/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java
       (revision 62356)
@@ -100,7 +100,6 @@
         watchdog = b;
     }
 
-
     /**
      * Starts the server in debug mode
      * @param b 
@@ -128,6 +127,11 @@
     public void setInstanceRootDir(File f) {
         instanceRootDir = f;
     }
+
+    public void setDropInterruptedCommands(boolean dropInterruptedCommands) {
+        this.dropInterruptedCommands = dropInterruptedCommands;
+    }
+
     public final boolean isDomain() {
         return type == RuntimeType.DAS;
     }
@@ -222,6 +226,9 @@
         return domainParentDir;
     }
 
+    public boolean isDropInterruptedCommands() {
+        return dropInterruptedCommands;
+    }
 
     /**
      *  TEMPORARY.  The guts of HK2 and V3 bootstrapping wants String[]
@@ -560,6 +567,7 @@
     private File configFile; // domain.xml
     private String domainName;
     private String instanceName;
+    private boolean dropInterruptedCommands = false;
     private boolean valid = false;
     private Map<String, String> argsMap;
     private ArrayList<String> argsRaw = new ArrayList<String>();
Index: 
trunk/main/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java
===================================================================
--- 
trunk/main/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java
  (revision 62355)
+++ 
trunk/main/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java
  (revision 62356)
@@ -45,8 +45,9 @@
 import java.util.*;
 import java.util.logging.*;
 
+import javax.inject.Inject;
+
 import org.jvnet.hk2.annotations.*;
-import org.jvnet.hk2.component.*;
 import org.glassfish.api.Param;
 import org.glassfish.api.admin.*;
 import org.glassfish.hk2.api.PerLookup;
@@ -87,6 +88,12 @@
     @Param(name = "dry-run", shortName = "n", optional = true,
             defaultValue = "false")
     private boolean dry_run;
+    @Param(name = "drop-interrupted-commands", optional = true, defaultValue 
= "false")
+    private boolean drop_interrupted_commands;
+
+    @Inject
+    ServerEnvironment senv;
+    
     private static final LocalStringsImpl strings =
             new LocalStringsImpl(StartDomainCommand.class);
     // the name of the master password option
@@ -212,6 +219,7 @@
         info.setDebug(debug);
         info.setUpgrade(upgrade);
         info.setWatchdog(watchdog);
+        info.setDropInterruptedCommands(drop_interrupted_commands);
 
         info.setRespawnInfo(programOpts.getClassName(),
                 programOpts.getClassPath(),
Index: 
trunk/main/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/SystemPropertyConstants.java
===================================================================
--- 
trunk/main/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/SystemPropertyConstants.java
    (revision 62355)
+++ 
trunk/main/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/SystemPropertyConstants.java
    (revision 62356)
@@ -234,6 +234,7 @@
     public static final String DEFAULT_SERVER_SOCKET_ADDRESS="0.0.0.0";
     public static final String CLUSTER_AWARE_FEATURE_FACTORY_CLASS 
         = "com.sun.enterprise.ee.server.pluggable.EEPluggableFeatureImpl";
+    public static final String DROP_INTERRUPTED_COMMANDS = 
"org.glassfish.job-manager.drop-interrupted-commands";
     
     /** Name of the default config that determines the configuration for the 
instances */
     public static final String TEMPLATE_CONFIG_NAME = "default-config";
Index: 
trunk/main/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/JobManagerService.java
===================================================================
--- 
trunk/main/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/JobManagerService.java
     (revision 62355)
+++ 
trunk/main/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/JobManagerService.java
     (revision 62356)
@@ -45,6 +45,7 @@
 import com.sun.enterprise.config.serverbeans.ManagedJobConfig;
 import com.sun.enterprise.util.LocalStringManagerImpl;
 import com.sun.enterprise.util.StringUtils;
+import com.sun.enterprise.util.SystemPropertyConstants;
 import com.sun.enterprise.v3.admin.CheckpointHelper.CheckpointFilename;
 import com.sun.enterprise.v3.server.ExecutorServiceFactory;
 import java.io.File;
@@ -58,7 +59,6 @@
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import java.util.zip.ZipOutputStream;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import javax.xml.bind.JAXBContext;
@@ -77,7 +77,6 @@
 import org.glassfish.kernel.KernelLoggerInfo;
 import org.jvnet.hk2.annotations.Service;
 import javax.xml.bind.Marshaller;
-import org.glassfish.admin.payload.PayloadImpl;
 import org.glassfish.api.ActionReport;
 import org.glassfish.api.admin.AdminCommandState.State;
 
@@ -129,9 +128,6 @@
     protected File jobsFile;
 
     @Inject
-    private JobLocatorService jobLocatorService;
-
-    @Inject
     private ServiceLocator serviceLocator;
 
     @Inject
@@ -304,16 +300,12 @@
         
logger.fine(adminStrings.getLocalString("removed.expired.job","Removed 
expired job ",  job));
     }
     
-    public void deleteCheckpoint(final Job job) {
-        File jobFile = job.getJobsFile();
-        if (jobFile == null) {
-            jobFile = getJobsFile();
-        }
+    public void deleteCheckpoint(final File parentDir, final String jobId) {
         //list all related files
-        File[] toDelete = jobFile.getParentFile().listFiles(new 
FilenameFilter() {
+        File[] toDelete = parentDir.listFiles(new FilenameFilter() {
                                    @Override
                                    public boolean accept(File dir, String 
name) {
-                                       return name.startsWith(job.getId() + 
".") || name.startsWith(job.getId() + "-");
+                                       return name.startsWith(jobId + ".") 
|| name.startsWith(jobId + "-");
                                    }
                                });
         for (File td : toDelete) {
@@ -412,10 +404,15 @@
         for  (File jobfile : persistedJobFiles)   {
             if (jobfile != null) {
                 reapCompletedJobs(jobfile);
-                // FIXME: if enabled
+                boolean dropInterruptedCommands = 
Boolean.valueOf(System.getProperty(SystemPropertyConstants.DROP_INTERRUPTED_COMMANDS));
 
                 Collection<CheckpointFilename> listed = 
checkpointHelper.listCheckpoints(jobfile.getParentFile());
                 for (CheckpointFilename cf : listed) {
-                    this.retryableJobsInfo.put(cf.getJobId(), cf);
+                    if (dropInterruptedCommands) {
+                        logger.info("Dropping checkpoint: " + cf.getFile());
+                        deleteCheckpoint(cf.getParentDir(), cf.getJobId());
+                    } else {
+                        this.retryableJobsInfo.put(cf.getJobId(), cf);
+                    }
                 }
             }
         }
Index: 
trunk/main/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/AdminCommandInstanceImpl.java
===================================================================
--- 
trunk/main/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/AdminCommandInstanceImpl.java
      (revision 62355)
+++ 
trunk/main/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/AdminCommandInstanceImpl.java
      (revision 62356)
@@ -188,7 +188,11 @@
                 jobPersistenceService.persist(new 
JobInfo(id,commandName,executionDate,report.getActionExitCode().name(),subjectUsernames.get(0),report.getMessage(),getJobsFile(),finalState.name(),completionDate));
                 if (getState().equals(State.RUNNING_RETRYABLE) || 
getState().equals(State.REVERTING)) {
                     JobManagerService jobManager = 
Globals.getDefaultHabitat().getService(JobManagerService.class);
-                    jobManager.deleteCheckpoint(this);
+                    File jobFile = getJobsFile();
+                    if (jobFile == null) {
+                        jobFile = jobManager.getJobsFile();
+                    }
+                    jobManager.deleteCheckpoint(jobFile.getParentFile(), 
getId());
                 }
                 setState(finalState);
             }





[glassfish~svn:62356] FPP-1887: start-domain --drop-interrupted-commands command option and fun

andriy . zhdanov 07/16/2013
 
 
Close
loading
Please Confirm
Close