karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject karaf git commit: [KARAF-3693]only update the instances.properties when the read operation detect instance pid changes (cherry picked from commit 6aa141a74029d60495d166b6c1c0c804909b9caa)
Date Thu, 23 Apr 2015 09:56:11 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-3.0.x 3431c8258 -> 9899e43a1


[KARAF-3693]only update the instances.properties when the read operation detect instance pid
changes
(cherry picked from commit 6aa141a74029d60495d166b6c1c0c804909b9caa)


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/9899e43a
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/9899e43a
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/9899e43a

Branch: refs/heads/karaf-3.0.x
Commit: 9899e43a117c95d79cec605f5358ee3e22f6b63a
Parents: 3431c82
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Thu Apr 23 17:53:10 2015 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Thu Apr 23 17:55:03 2015 +0800

----------------------------------------------------------------------
 .../core/internal/InstanceServiceImpl.java      | 26 ++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/9899e43a/instance/core/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
----------------------------------------------------------------------
diff --git a/instance/core/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
b/instance/core/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
index c889ffc..724a625 100644
--- a/instance/core/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
+++ b/instance/core/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
@@ -834,6 +834,7 @@ public class InstanceServiceImpl implements InstanceService {
     }
 
     int getInstancePid(final String name) {
+        boolean updateInstanceProperties = isInstancePidNeedUpdate(name);
         return execute(new Task<Integer>() {
             public Integer call(State state) throws IOException {
                 InstanceState instance = state.instances.get(name);
@@ -843,7 +844,7 @@ public class InstanceServiceImpl implements InstanceService {
                 checkPid(instance);
                 return instance.pid;
             }
-        }, false);
+        }, updateInstanceProperties);
     }
 
     String getInstanceJavaOpts(final String name) {
@@ -872,6 +873,7 @@ public class InstanceServiceImpl implements InstanceService {
     }
 
     String getInstanceState(final String name) {
+        boolean updateInstanceProperties = isInstancePidNeedUpdate(name);
         return execute(new Task<String>() {
             public String call(State state) throws IOException {
                 InstanceState instance = state.instances.get(name);
@@ -900,7 +902,7 @@ public class InstanceServiceImpl implements InstanceService {
                     return Instance.STARTING;
                 }
             }
-        }, true);
+        }, updateInstanceProperties);
     }
 
     private boolean deleteFile(File fileToDelete) {
@@ -1240,5 +1242,25 @@ public class InstanceServiceImpl implements InstanceService {
             }
         }, true);
     }
+    
+    private Boolean isInstancePidNeedUpdate(final String name) {
+        return execute(new Task<Boolean>() {
+            public Boolean call(State state) throws IOException {
+                InstanceState instance = state.instances.get(name);
+                if (instance == null) {
+                    throw new IllegalArgumentException("Instance " + name + " not found");
+                }
+                int origialPid = instance.pid;
+                checkPid(instance);
+                int newPid = instance.pid;
+                if (origialPid == newPid) {
+                    return false;
+                } else {
+                    return true;
+                }
+                
+            }
+        }, false);
+    }
 
 }


Mime
View raw message