Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 16ff8f30a -> 0734caf1d
  refs/heads/trunk 4fbf172c3 -> ed3ca611b


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/0734caf1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0734caf1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0734caf1

Branch: refs/heads/branch-2.2
Commit: 0734caf1de23a0a8f5c54a77141d32b2631f52cb
Parents: 16ff8f3
Author: Myroslav Papirkovskyy <mpapyrkovs...@hortonworks.com>
Authored: Thu Feb 4 13:05:05 2016 +0200
Committer: Myroslav Papirkovskyy <mpapyrkovs...@hortonworks.com>
Committed: Thu Feb 4 13:05:05 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/0734caf1/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 f74073f..edcfa28 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
@@ -2327,6 +2327,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/0734caf1/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 433853b..373b7fc 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
@@ -248,6 +248,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;
   }
@@ -260,6 +268,8 @@ public class AmbariServer {
     server.setSessionIdManager(sessionIdManager);
     Server serverForAgent = new Server();
 
+    setSystemProperties(configs);
+
     DatabaseChecker.checkDBVersion();
     DatabaseChecker.checkDBConsistency();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/0734caf1/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(

Reply via email to