You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by up...@apache.org on 2018/03/13 22:56:21 UTC

[geode] branch develop updated: GEODE-4669: Fall back on file controller if mbean controller fails

This is an automated email from the ASF dual-hosted git repository.

upthewaterspout pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 736742d  GEODE-4669: Fall back on file controller if mbean controller fails
736742d is described below

commit 736742de8ae157035b7435d9fc4344754498efb0
Author: Dan Smith <up...@apache.org>
AuthorDate: Fri Mar 9 14:14:41 2018 -0800

    GEODE-4669: Fall back on file controller if mbean controller fails
    
    The MBeanProcessController has some logic to attach to a started locator
    or server process and look for the location of JDK jars. Under JDK 9,
    this logic does work.
    
    This fix allows us to fall back on the FileProcessController if the
    mbean one fails, rather than silently hanging forever.
---
 .../process/MBeanOrFileProcessController.java      | 64 ++++++++++++++++++++++
 .../internal/process/ProcessControllerFactory.java | 10 ++--
 .../ProcessControllerFactoryIntegrationTest.java   |  2 +-
 .../process/ProcessControllerFactoryTest.java      |  2 +-
 4 files changed, 70 insertions(+), 8 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/process/MBeanOrFileProcessController.java b/geode-core/src/main/java/org/apache/geode/internal/process/MBeanOrFileProcessController.java
new file mode 100644
index 0000000..da87faf
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/internal/process/MBeanOrFileProcessController.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.process;
+
+import java.io.IOException;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * Process controller that attempts to use the MBeanProcessController but
+ * falls back on FileProcessController if that fails
+ */
+public class MBeanOrFileProcessController implements ProcessController {
+  private final ProcessController mbeanController;
+  private final ProcessController fileController;
+
+  public MBeanOrFileProcessController(ProcessControllerParameters parameters, int pid) {
+    mbeanController = new MBeanProcessController(parameters, pid);
+    fileController = new FileProcessController(parameters, pid);
+  }
+
+  @Override
+  public String status() throws UnableToControlProcessException, ConnectionFailedException,
+      IOException, MBeanInvocationFailedException, InterruptedException, TimeoutException {
+    try {
+      return mbeanController.status();
+    } catch (IOException | MBeanInvocationFailedException | ConnectionFailedException
+        | UnableToControlProcessException e) {
+      return fileController.status();
+    }
+  }
+
+  @Override
+  public void stop() throws UnableToControlProcessException, ConnectionFailedException, IOException,
+      MBeanInvocationFailedException {
+
+    try {
+      mbeanController.stop();
+    } catch (IOException | MBeanInvocationFailedException | ConnectionFailedException
+        | UnableToControlProcessException e) {
+      fileController.stop();
+    }
+
+  }
+
+  @Override
+  public int getProcessId() {
+    return mbeanController.getProcessId();
+  }
+
+  @Override
+  public void checkPidSupport() {}
+}
diff --git a/geode-core/src/main/java/org/apache/geode/internal/process/ProcessControllerFactory.java b/geode-core/src/main/java/org/apache/geode/internal/process/ProcessControllerFactory.java
index be662df..1a06a95 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/process/ProcessControllerFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/process/ProcessControllerFactory.java
@@ -49,13 +49,11 @@ public class ProcessControllerFactory {
     notNull(parameters, "Invalid parameters '" + parameters + "' specified");
     isTrue(pid > 0, "Invalid pid '" + pid + "' specified");
 
-    if (isAttachAPIFound()) {
-      try {
-        return new MBeanProcessController(parameters, pid);
-      } catch (ExceptionInInitializerError ignore) {
-      }
+    if (!isAttachAPIFound()) {
+      return new FileProcessController(parameters, pid);
     }
-    return new FileProcessController(parameters, pid);
+
+    return new MBeanOrFileProcessController(parameters, pid);
   }
 
   public ProcessController createProcessController(final ProcessControllerParameters parameters,
diff --git a/geode-core/src/test/java/org/apache/geode/internal/process/ProcessControllerFactoryIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/internal/process/ProcessControllerFactoryIntegrationTest.java
index aafa260..a52c266 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/process/ProcessControllerFactoryIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/process/ProcessControllerFactoryIntegrationTest.java
@@ -83,7 +83,7 @@ public class ProcessControllerFactoryIntegrationTest {
         factory.createProcessController(parameters, directory, pidFileName);
 
     // assert
-    assertThat(controller).isInstanceOf(MBeanProcessController.class);
+    assertThat(controller).isInstanceOf(MBeanOrFileProcessController.class);
   }
 
   @Test
diff --git a/geode-core/src/test/java/org/apache/geode/internal/process/ProcessControllerFactoryTest.java b/geode-core/src/test/java/org/apache/geode/internal/process/ProcessControllerFactoryTest.java
index 55f5d58..92e9f99 100755
--- a/geode-core/src/test/java/org/apache/geode/internal/process/ProcessControllerFactoryTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/process/ProcessControllerFactoryTest.java
@@ -73,7 +73,7 @@ public class ProcessControllerFactoryTest {
     ProcessController controller = factory.createProcessController(parameters, pid);
 
     // assert
-    assertThat(controller).isInstanceOf(MBeanProcessController.class);
+    assertThat(controller).isInstanceOf(MBeanOrFileProcessController.class);
   }
 
   @Test

-- 
To stop receiving notification emails like this one, please contact
upthewaterspout@apache.org.