You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by mp...@apache.org on 2016/02/04 12:15:39 UTC

[2/2] ambari git commit: AMBARI-14915. Ambari Server should not use /tmp for extraction. (mpapirkovskyy)

AMBARI-14915. Ambari Server should not use /tmp for extraction. (mpapirkovskyy)


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

Branch: refs/heads/trunk
Commit: ed3ca611b98a6a68c12a735ca934a83755913b39
Parents: 4fbf172
Author: Myroslav Papirkovskyy <mp...@hortonworks.com>
Authored: Thu Feb 4 13:14:06 2016 +0200
Committer: Myroslav Papirkovskyy <mp...@hortonworks.com>
Committed: Thu Feb 4 13:14:06 2016 +0200

----------------------------------------------------------------------
 .../apache/ambari/server/configuration/Configuration.java |  8 ++++++++
 .../org/apache/ambari/server/controller/AmbariServer.java | 10 ++++++++++
 .../apache/ambari/server/controller/AmbariServerTest.java |  9 +++++++++
 3 files changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ed3ca611/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index 4a4ae43..35e9b6f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -2419,6 +2419,14 @@ public class Configuration {
   }
 
   /**
+   * Ambari server temp dir
+   * @return server temp dir
+   */
+  public String getServerTempDir() {
+    return properties.getProperty(SERVER_TMP_DIR_KEY, SERVER_TMP_DIR_DEFAULT);
+  }
+
+  /**
    * Gets whether to use experiemental concurrent processing to convert
    * {@link StageEntity} instances into {@link Stage} instances. The default is
    * {@code false}.

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed3ca611/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index 9c05bf8..c7e7880 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -253,6 +253,14 @@ public class AmbariServer {
 
   private static AmbariManagementController clusterController = null;
 
+  /**
+   * Alters system variables on base of Ambari configuration
+   */
+  static void setSystemProperties(Configuration configs) {
+    // modify location of temporary dir to avoid using default /tmp dir
+    System.setProperty("java.io.tmpdir", configs.getServerTempDir());
+  }
+
   public static AmbariManagementController getController() {
     return clusterController;
   }
@@ -265,6 +273,8 @@ public class AmbariServer {
     server.setSessionIdManager(sessionIdManager);
     Server serverForAgent = new Server();
 
+    setSystemProperties(configs);
+
     if (System.getProperty("skipDatabaseConsistencyValidation") == null) {
       DatabaseChecker.checkDBVersion();
       DatabaseChecker.checkDBConsistency();

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed3ca611/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
index 02941b5..54f6147 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariServerTest.java
@@ -105,6 +105,15 @@ public class AmbariServerTest {
   }
 
   @Test
+  public void testSystemProperties() throws Exception {
+    Configuration configuration = EasyMock.createNiceMock(Configuration.class);
+    expect(configuration.getServerTempDir()).andReturn("/ambari/server/temp/dir").anyTimes();
+    replay(configuration);
+    AmbariServer.setSystemProperties(configuration);
+    Assert.assertEquals(System.getProperty("java.io.tmpdir"), "/ambari/server/temp/dir");
+  }
+
+  @Test
   public void testProxyUser() throws Exception {
 
     PasswordAuthentication pa = Authenticator.requestPasswordAuthentication(