You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/02/22 17:48:21 UTC
[01/21] ambari git commit: AMBARI-15091 Metrics collector running out
of file descriptors (dsen)
Repository: ambari
Updated Branches:
refs/heads/branch-dev-patch-upgrade 4d3839c7f -> 2eea1bfa9
AMBARI-15091 Metrics collector running out of file descriptors (dsen)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/739ed206
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/739ed206
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/739ed206
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 739ed206ef5e1152f7080b463a32127716d96711
Parents: d48fb9b
Author: Dmytro Sen <ds...@apache.org>
Authored: Fri Feb 19 15:57:40 2016 +0200
Committer: Dmytro Sen <ds...@apache.org>
Committed: Fri Feb 19 15:57:40 2016 +0200
----------------------------------------------------------------------
.../timeline/AbstractTimelineMetricsSink.java | 53 ++++++++++++++++++--
.../ApplicationHistoryServer.java | 6 ++-
.../loadsimulator/net/RestMetricsSender.java | 4 +-
.../ApplicationHistoryStoreTestUtils.java | 2 +-
.../TestApplicationHistoryClientService.java | 6 +--
.../TestFileSystemApplicationHistoryStore.java | 12 ++---
.../TestMemoryApplicationHistoryStore.java | 12 ++---
.../webapp/TestAHSWebServices.java | 2 +-
.../stacks/HDP/2.0.6/services/stack_advisor.py | 5 +-
.../stacks/2.0.6/common/test_stack_advisor.py | 12 ++---
.../stacks/2.2/common/test_stack_advisor.py | 1 +
11 files changed, 83 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/739ed206/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/AbstractTimelineMetricsSink.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/AbstractTimelineMetricsSink.java b/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/AbstractTimelineMetricsSink.java
index 2854898..b2810b7 100644
--- a/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/AbstractTimelineMetricsSink.java
+++ b/ambari-metrics/ambari-metrics-common/src/main/java/org/apache/hadoop/metrics2/sink/timeline/AbstractTimelineMetricsSink.java
@@ -28,9 +28,12 @@ import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManagerFactory;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
@@ -72,17 +75,19 @@ public abstract class AbstractTimelineMetricsSink {
protected void emitMetrics(TimelineMetrics metrics) {
String connectUrl = getCollectorUri();
int timeout = getTimeoutSeconds() * 1000;
+ HttpURLConnection connection = null;
try {
if (connectUrl == null) {
throw new IOException("Unknown URL. " +
"Unable to connect to metrics collector.");
}
String jsonData = mapper.writeValueAsString(metrics);
- HttpURLConnection connection = connectUrl.startsWith("https") ?
+ connection = connectUrl.startsWith("https") ?
getSSLConnection(connectUrl) : getConnection(connectUrl);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
+ connection.setRequestProperty("Connection", "Keep-Alive");
connection.setConnectTimeout(timeout);
connection.setReadTimeout(timeout);
connection.setDoOutput(true);
@@ -103,14 +108,52 @@ public abstract class AbstractTimelineMetricsSink {
LOG.debug("Metrics posted to Collector " + connectUrl);
}
}
- } catch (IOException e) {
+ cleanupInputStream(connection.getInputStream());
+ } catch (IOException ioe) {
+ StringBuilder errorMessage =
+ new StringBuilder("Unable to connect to collector, " + connectUrl + "\n");
+ try {
+ if ((connection != null)) {
+ errorMessage.append(cleanupInputStream(connection.getErrorStream()));
+ }
+ } catch (IOException e) {
+ //NOP
+ }
if (LOG.isDebugEnabled()) {
- LOG.debug("Unable to connect to collector, " + connectUrl, e);
+ LOG.debug(errorMessage, ioe);
} else {
- LOG.info("Unable to connect to collector, " + connectUrl);
+ LOG.info(errorMessage);
+ }
+ throw new UnableToConnectException(ioe).setConnectUrl(connectUrl);
+ }
+ }
+
+ /**
+ * Cleans up and closes an input stream
+ * see http://docs.oracle.com/javase/6/docs/technotes/guides/net/http-keepalive.html
+ * @param is the InputStream to clean up
+ * @return string read from the InputStream
+ * @throws IOException
+ */
+ private String cleanupInputStream(InputStream is) throws IOException {
+ StringBuilder sb = new StringBuilder();
+ if (is != null) {
+ try (
+ InputStreamReader isr = new InputStreamReader(is);
+ BufferedReader br = new BufferedReader(isr)
+ ) {
+ // read the response body
+ String line;
+ while ((line = br.readLine()) != null) {
+ if (LOG.isDebugEnabled()) {
+ sb.append(line);
+ }
+ }
+ } finally {
+ is.close();
}
- throw new UnableToConnectException(e).setConnectUrl(connectUrl);
}
+ return sb.toString();
}
// Get a connection
http://git-wip-us.apache.org/repos/asf/ambari/blob/739ed206/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java
index 62a8cc3..1ca9c33 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java
@@ -55,8 +55,8 @@ import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.ti
public class ApplicationHistoryServer extends CompositeService {
public static final int SHUTDOWN_HOOK_PRIORITY = 30;
- private static final Log LOG = LogFactory
- .getLog(ApplicationHistoryServer.class);
+ private static final Log LOG =
+ LogFactory.getLog(ApplicationHistoryServer.class);
ApplicationHistoryClientService ahsClientService;
ApplicationHistoryManager historyManager;
@@ -172,6 +172,8 @@ public class ApplicationHistoryServer extends CompositeService {
LOG.info("Instantiating AHSWebApp at " + bindAddress);
try {
Configuration conf = metricConfiguration.getMetricsConf();
+ conf.set("hadoop.http.max.threads", String.valueOf(metricConfiguration
+ .getTimelineMetricsServiceHandlerThreadCount()));
HttpConfig.Policy policy = HttpConfig.Policy.valueOf(
conf.get(TimelineMetricConfiguration.TIMELINE_SERVICE_HTTP_POLICY,
HttpConfig.Policy.HTTP_ONLY.name()));
http://git-wip-us.apache.org/repos/asf/ambari/blob/739ed206/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/net/RestMetricsSender.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/net/RestMetricsSender.java b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/net/RestMetricsSender.java
index 0a9a513..32af851 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/net/RestMetricsSender.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/loadsimulator/net/RestMetricsSender.java
@@ -24,6 +24,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.ProtocolException;
+import java.util.concurrent.TimeUnit;
/**
* Implements MetricsSender and provides a way of pushing metrics to application metrics history service using REST
@@ -65,7 +66,8 @@ public class RestMetricsSender implements MetricsSender {
responseString = svc.send(payload);
timer.stop();
- LOG.info("http response time: " + timer.elapsedMillis() + " ms");
+ LOG.info("http response time: " + timer.elapsed(TimeUnit.MILLISECONDS)
+ + " ms");
if (responseString.length() > 0) {
LOG.debug("POST response from server: " + responseString);
http://git-wip-us.apache.org/repos/asf/ambari/blob/739ed206/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryStoreTestUtils.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryStoreTestUtils.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryStoreTestUtils.java
index c41b8a7..ec9b49d 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryStoreTestUtils.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryStoreTestUtils.java
@@ -58,7 +58,7 @@ public class ApplicationHistoryStoreTestUtils {
ApplicationAttemptId appAttemptId) throws IOException {
store.applicationAttemptStarted(ApplicationAttemptStartData.newInstance(
appAttemptId, appAttemptId.toString(), 0,
- ContainerId.newInstance(appAttemptId, 1)));
+ ContainerId.newContainerId(appAttemptId, 1)));
}
protected void writeApplicationAttemptFinishData(
http://git-wip-us.apache.org/repos/asf/ambari/blob/739ed206/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryClientService.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryClientService.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryClientService.java
index 2fdedb2..f93ac5e 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryClientService.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryClientService.java
@@ -168,7 +168,7 @@ public class TestApplicationHistoryClientService extends
writeApplicationStartData(appId);
ApplicationAttemptId appAttemptId =
ApplicationAttemptId.newInstance(appId, 1);
- ContainerId containerId = ContainerId.newInstance(appAttemptId, 1);
+ ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
writeContainerStartData(containerId);
writeContainerFinishData(containerId);
writeApplicationFinishData(appId);
@@ -189,8 +189,8 @@ public class TestApplicationHistoryClientService extends
writeApplicationStartData(appId);
ApplicationAttemptId appAttemptId =
ApplicationAttemptId.newInstance(appId, 1);
- ContainerId containerId = ContainerId.newInstance(appAttemptId, 1);
- ContainerId containerId1 = ContainerId.newInstance(appAttemptId, 2);
+ ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
+ ContainerId containerId1 = ContainerId.newContainerId(appAttemptId, 2);
writeContainerStartData(containerId);
writeContainerFinishData(containerId);
writeContainerStartData(containerId1);
http://git-wip-us.apache.org/repos/asf/ambari/blob/739ed206/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestFileSystemApplicationHistoryStore.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestFileSystemApplicationHistoryStore.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestFileSystemApplicationHistoryStore.java
index bc16d36..543c25b 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestFileSystemApplicationHistoryStore.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestFileSystemApplicationHistoryStore.java
@@ -94,7 +94,7 @@ public class TestFileSystemApplicationHistoryStore extends
}
// write container history data
for (int k = 1; k <= num; ++k) {
- ContainerId containerId = ContainerId.newInstance(appAttemptId, k);
+ ContainerId containerId = ContainerId.newContainerId(appAttemptId, k);
writeContainerStartData(containerId);
if (missingContainer && k == num) {
continue;
@@ -144,7 +144,7 @@ public class TestFileSystemApplicationHistoryStore extends
// read container history data
Assert.assertEquals(num, store.getContainers(appAttemptId).size());
for (int k = 1; k <= num; ++k) {
- ContainerId containerId = ContainerId.newInstance(appAttemptId, k);
+ ContainerId containerId = ContainerId.newContainerId(appAttemptId, k);
ContainerHistoryData containerData = store.getContainer(containerId);
Assert.assertNotNull(containerData);
Assert.assertEquals(Priority.newInstance(containerId.getId()),
@@ -159,7 +159,7 @@ public class TestFileSystemApplicationHistoryStore extends
ContainerHistoryData masterContainer =
store.getAMContainer(appAttemptId);
Assert.assertNotNull(masterContainer);
- Assert.assertEquals(ContainerId.newInstance(appAttemptId, 1),
+ Assert.assertEquals(ContainerId.newContainerId(appAttemptId, 1),
masterContainer.getContainerId());
}
}
@@ -186,7 +186,7 @@ public class TestFileSystemApplicationHistoryStore extends
Assert.assertTrue(e.getMessage().contains("is not opened"));
}
// write container history data
- ContainerId containerId = ContainerId.newInstance(appAttemptId, 1);
+ ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
try {
writeContainerStartData(containerId);
Assert.fail();
@@ -209,8 +209,8 @@ public class TestFileSystemApplicationHistoryStore extends
writeApplicationStartData(appId);
ApplicationAttemptId appAttemptId =
ApplicationAttemptId.newInstance(appId, 1);
- for (int i = 1; i <= 100000; ++i) {
- ContainerId containerId = ContainerId.newInstance(appAttemptId, i);
+ for (int i = 1; i <= 1000; ++i) {
+ ContainerId containerId = ContainerId.newContainerId(appAttemptId, i);
writeContainerStartData(containerId);
writeContainerFinishData(containerId);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/739ed206/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java
index fc5c096..b4da01a 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java
@@ -137,7 +137,7 @@ public class TestMemoryApplicationHistoryStore extends
ApplicationId appId = ApplicationId.newInstance(0, 1);
ApplicationAttemptId appAttemptId =
ApplicationAttemptId.newInstance(appId, 1);
- ContainerId containerId = ContainerId.newInstance(appAttemptId, 1);
+ ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
try {
writeContainerFinishData(containerId);
Assert.fail();
@@ -149,14 +149,14 @@ public class TestMemoryApplicationHistoryStore extends
writeApplicationAttemptStartData(appAttemptId);
int numContainers = 5;
for (int i = 1; i <= numContainers; ++i) {
- containerId = ContainerId.newInstance(appAttemptId, i);
+ containerId = ContainerId.newContainerId(appAttemptId, i);
writeContainerStartData(containerId);
writeContainerFinishData(containerId);
}
Assert
.assertEquals(numContainers, store.getContainers(appAttemptId).size());
for (int i = 1; i <= numContainers; ++i) {
- containerId = ContainerId.newInstance(appAttemptId, i);
+ containerId = ContainerId.newContainerId(appAttemptId, i);
ContainerHistoryData data = store.getContainer(containerId);
Assert.assertNotNull(data);
Assert.assertEquals(Priority.newInstance(containerId.getId()),
@@ -165,11 +165,11 @@ public class TestMemoryApplicationHistoryStore extends
}
ContainerHistoryData masterContainer = store.getAMContainer(appAttemptId);
Assert.assertNotNull(masterContainer);
- Assert.assertEquals(ContainerId.newInstance(appAttemptId, 1),
+ Assert.assertEquals(ContainerId.newContainerId(appAttemptId, 1),
masterContainer.getContainerId());
writeApplicationAttemptFinishData(appAttemptId);
// Write again
- containerId = ContainerId.newInstance(appAttemptId, 1);
+ containerId = ContainerId.newContainerId(appAttemptId, 1);
try {
writeContainerStartData(containerId);
Assert.fail();
@@ -195,7 +195,7 @@ public class TestMemoryApplicationHistoryStore extends
ApplicationAttemptId appAttemptId =
ApplicationAttemptId.newInstance(appId, 1);
for (int i = 1; i <= numContainers; ++i) {
- ContainerId containerId = ContainerId.newInstance(appAttemptId, i);
+ ContainerId containerId = ContainerId.newContainerId(appAttemptId, i);
writeContainerStartData(containerId);
writeContainerFinishData(containerId);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/739ed206/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java
----------------------------------------------------------------------
diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java
index e78dfcc..44b3f65 100644
--- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java
+++ b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java
@@ -269,7 +269,7 @@ public class TestAHSWebServices extends JerseyTest {
ApplicationId appId = ApplicationId.newInstance(0, 1);
ApplicationAttemptId appAttemptId =
ApplicationAttemptId.newInstance(appId, 1);
- ContainerId containerId = ContainerId.newInstance(appAttemptId, 1);
+ ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
WebResource r = resource();
ClientResponse response =
r.path("ws").path("v1").path("applicationhistory").path("apps")
http://git-wip-us.apache.org/repos/asf/ambari/blob/739ed206/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
index 7c69ac9..f6f8cde 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
@@ -581,8 +581,8 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
putAmsHbaseSiteProperty("hbase.regionserver.global.memstore.upperLimit", 0.3)
putAmsHbaseSiteProperty("hbase.regionserver.global.memstore.lowerLimit", 0.25)
putAmsHbaseSiteProperty("phoenix.query.maxGlobalMemoryPercentage", 20)
- putAmsSiteProperty("phoenix.query.maxGlobalMemoryPercentage", 30)
putAmsHbaseSiteProperty("phoenix.coprocessor.maxMetaDataCacheSize", 81920000)
+ putAmsSiteProperty("phoenix.query.maxGlobalMemoryPercentage", 30)
elif total_sinks_count >= 500:
putAmsHbaseSiteProperty("hbase.regionserver.handler.count", 60)
putAmsHbaseSiteProperty("hbase.regionserver.hlog.blocksize", 134217728)
@@ -593,6 +593,9 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
putAmsHbaseSiteProperty("phoenix.coprocessor.maxMetaDataCacheSize", 20480000)
pass
+ metrics_api_handlers = min(50, max(20, int(total_sinks_count / 100)))
+ putAmsSiteProperty("timeline.metrics.service.handler.thread.count", metrics_api_handlers)
+
# Distributed mode heap size
if operatingMode == "distributed":
hbase_heapsize = max(hbase_heapsize, 756)
http://git-wip-us.apache.org/repos/asf/ambari/blob/739ed206/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py
index 7c578f2..e15582e 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py
@@ -1820,7 +1820,7 @@ class TestHDP206StackAdvisor(TestCase):
)
recommendedDefaults = {"property1": "file:///grid/0/var/dir"}
warn = self.stackAdvisor.validatorNotRootFs(properties, recommendedDefaults, 'property1', hostInfo)
- self.assertIsNotNone(warn)
+ self.assertTrue(warn != None)
self.assertEquals({'message': 'It is not recommended to use root partition for property1', 'level': 'WARN'}, warn)
# Set by user /var mountpoint, which is non-root , but not preferable - no warning
@@ -1831,7 +1831,7 @@ class TestHDP206StackAdvisor(TestCase):
"mountpoint" : "/var"
}
)
- self.assertIsNone(self.stackAdvisor.validatorNotRootFs(properties, recommendedDefaults, 'property1', hostInfo))
+ self.assertTrue(self.stackAdvisor.validatorNotRootFs(properties, recommendedDefaults, 'property1', hostInfo) == None)
def test_validatorEnoughDiskSpace(self):
reqiuredDiskSpace = 1048576
@@ -1847,7 +1847,7 @@ class TestHDP206StackAdvisor(TestCase):
}
]}
properties = {"property1": "file:///var/dir"}
- self.assertIsNone(self.stackAdvisor.validatorEnoughDiskSpace(properties, 'property1', hostInfo, reqiuredDiskSpace))
+ self.assertTrue(self.stackAdvisor.validatorEnoughDiskSpace(properties, 'property1', hostInfo, reqiuredDiskSpace) == None)
# local FS, no enough space
hostInfo = {"disk_info": [
@@ -1858,16 +1858,16 @@ class TestHDP206StackAdvisor(TestCase):
}
]}
warn = self.stackAdvisor.validatorEnoughDiskSpace(properties, 'property1', hostInfo, reqiuredDiskSpace)
- self.assertIsNotNone(warn)
+ self.assertTrue(warn != None)
self.assertEquals({'message': errorMsg, 'level': 'WARN'}, warn)
# non-local FS, HDFS
properties = {"property1": "hdfs://h1"}
- self.assertIsNone(self.stackAdvisor.validatorEnoughDiskSpace(properties, 'property1', hostInfo, reqiuredDiskSpace))
+ self.assertTrue(self.stackAdvisor.validatorEnoughDiskSpace(properties, 'property1', hostInfo, reqiuredDiskSpace) == None)
# non-local FS, WASB
properties = {"property1": "wasb://h1"}
- self.assertIsNone(self.stackAdvisor.validatorEnoughDiskSpace(properties, 'property1', hostInfo, reqiuredDiskSpace))
+ self.assertTrue(self.stackAdvisor.validatorEnoughDiskSpace(properties, 'property1', hostInfo, reqiuredDiskSpace) == None)
def test_round_to_n(self):
self.assertEquals(self.stack_advisor_impl.round_to_n(0), 0)
http://git-wip-us.apache.org/repos/asf/ambari/blob/739ed206/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py
index 14a28d3..d48b78d 100644
--- a/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py
+++ b/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py
@@ -2052,6 +2052,7 @@ class TestHDP22StackAdvisor(TestCase):
"timeline.metrics.cluster.aggregate.splitpoints": " ",
"timeline.metrics.host.aggregate.splitpoints": " ",
"timeline.metrics.host.aggregator.ttl": "1",
+ "timeline.metrics.service.handler.thread.count": "20",
'timeline.metrics.service.watcher.disabled': 'false'
}
}
[11/21] ambari git commit: AMBARI-15011. Decrease the load on ambari
database after cluster creation (Sebastian Toader via smohanty)
Posted by nc...@apache.org.
AMBARI-15011. Decrease the load on ambari database after cluster creation (Sebastian Toader via smohanty)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/20056273
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/20056273
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/20056273
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 20056273ec9279f4823e495cdecfe514537f1223
Parents: 32173ff
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Fri Feb 19 13:33:00 2016 -0800
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Fri Feb 19 13:37:50 2016 -0800
----------------------------------------------------------------------
.../server/configuration/Configuration.java | 77 +++++++++
.../server/controller/ControllerModule.java | 16 ++
.../server/orm/dao/HostRoleCommandDAO.java | 166 +++++++++++++++----
.../orm/entities/HostRoleCommandEntity.java | 7 +-
.../serveraction/ServerActionExecutor.java | 13 +-
.../server/state/cluster/ClusterImpl.java | 36 ++--
.../server/upgrade/UpgradeCatalog222.java | 5 +
.../main/resources/Ambari-DDL-MySQL-CREATE.sql | 1 +
.../main/resources/Ambari-DDL-Oracle-CREATE.sql | 1 +
.../resources/Ambari-DDL-Postgres-CREATE.sql | 3 +
.../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql | 1 +
.../resources/Ambari-DDL-SQLAnywhere-CREATE.sql | 1 +
.../resources/Ambari-DDL-SQLServer-CREATE.sql | 1 +
.../actionmanager/TestActionScheduler.java | 24 +--
.../ambari/server/agent/AgentResourceTest.java | 2 +
.../server/configuration/ConfigurationTest.java | 95 +++++++++++
.../server/controller/KerberosHelperTest.java | 2 +
.../ambari/server/state/ConfigHelperTest.java | 2 +
.../server/upgrade/UpgradeCatalog222Test.java | 55 ++++--
.../ambari/server/utils/StageUtilsTest.java | 2 +
20 files changed, 435 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/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 aec83a7..4a980ee 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
@@ -184,6 +184,9 @@ public class Configuration {
public static final String LDAP_REFERRAL_KEY = "authentication.ldap.referral";
public static final String LDAP_PAGINATION_ENABLED_KEY = "authentication.ldap.pagination.enabled";
public static final String SERVER_EC_CACHE_SIZE = "server.ecCacheSize";
+ public static final String SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED = "server.hrcStatusSummary.cache.enabled";
+ public static final String SERVER_HRC_STATUS_SUMMARY_CACHE_SIZE = "server.hrcStatusSummary.cache.size";
+ public static final String SERVER_HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION = "server.hrcStatusSummary.cache.expiryDuration";
public static final String SERVER_STALE_CONFIG_CACHE_ENABLED_KEY = "server.cache.isStale.enabled";
public static final String SERVER_PERSISTENCE_TYPE_KEY = "server.persistence.type";
public static final String SERVER_JDBC_USER_NAME_KEY = "server.jdbc.user.name";
@@ -367,6 +370,11 @@ public class Configuration {
public static final String CUSTOM_ACTION_DEFINITION_KEY = "custom.action.definitions";
public static final String SHARED_RESOURCES_DIR_KEY = "shared.resources.dir";
+
+ protected static final boolean SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED_DEFAULT = true;
+ protected static final long SERVER_HRC_STATUS_SUMMARY_CACHE_SIZE_DEFAULT = 10000L;
+ protected static final long SERVER_HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION_DEFAULT = 30; //minutes
+
private static final String CUSTOM_ACTION_DEFINITION_DEF_VALUE = "/var/lib/ambari-server/resources/custom_action_definitions";
private static final long SERVER_EC_CACHE_SIZE_DEFAULT = 10000L;
@@ -1757,6 +1765,75 @@ public class Configuration {
}
/**
+ * Caching of host role command status summary can be enabled/disabled
+ * through the {@link #SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED} config property.
+ * This method returns the value of {@link #SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED}
+ * config property. If this config property is not defined than returns the default defined by {@link #SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED_DEFAULT}.
+ * @return true if caching is to be enabled otherwise false.
+ */
+ public boolean getHostRoleCommandStatusSummaryCacheEnabled() {
+ String stringValue = properties.getProperty(SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED);
+ boolean value = SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED_DEFAULT;
+ if (stringValue != null) {
+ try {
+ value = Boolean.valueOf(stringValue);
+ }
+ catch (NumberFormatException ignored) {
+ }
+
+ }
+
+ return value;
+ }
+
+ /**
+ * In order to avoid the cache storing host role command status summary objects exhaust
+ * memory we set a max record number allowed for the cache. This limit can be configured
+ * through {@link #SERVER_HRC_STATUS_SUMMARY_CACHE_SIZE} config property. The method returns
+ * the value of this config property. If this config property is not defined than
+ * the default value specified by {@link #SERVER_HRC_STATUS_SUMMARY_CACHE_SIZE_DEFAULT} is returned.
+ * @return the upper limit for the number of cached host role command summaries.
+ */
+ public long getHostRoleCommandStatusSummaryCacheSize() {
+ String stringValue = properties.getProperty(SERVER_HRC_STATUS_SUMMARY_CACHE_SIZE);
+ long value = SERVER_HRC_STATUS_SUMMARY_CACHE_SIZE_DEFAULT;
+ if (stringValue != null) {
+ try {
+ value = Long.valueOf(stringValue);
+ }
+ catch (NumberFormatException ignored) {
+ }
+
+ }
+
+ return value;
+ }
+
+ /**
+ * As a safety measure the cache storing host role command status summaries should auto expire after a while.
+ * The expiry duration is specified through the {@link #SERVER_HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION} config property
+ * expressed in minutes. The method returns the value of this config property. If this config property is not defined than
+ * the default value specified by {@link #SERVER_HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION_DEFAULT}
+ * @return the cache expiry duration in minutes
+ */
+ public long getHostRoleCommandStatusSummaryCacheExpiryDuration() {
+ String stringValue = properties.getProperty(SERVER_HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION);
+ long value = SERVER_HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION_DEFAULT;
+ if (stringValue != null) {
+ try {
+ value = Long.valueOf(stringValue);
+ }
+ catch (NumberFormatException ignored) {
+ }
+
+ }
+
+ return value;
+ }
+
+
+
+ /**
* @return whether staleConfig's flag is cached.
*/
public boolean isStaleConfigCacheEnabled() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
index 76ff6db..daca64d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
@@ -65,6 +65,7 @@ import org.apache.ambari.server.notifications.NotificationDispatcher;
import org.apache.ambari.server.orm.DBAccessor;
import org.apache.ambari.server.orm.DBAccessorImpl;
import org.apache.ambari.server.orm.PersistenceType;
+import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
import org.apache.ambari.server.scheduler.ExecutionScheduler;
import org.apache.ambari.server.scheduler.ExecutionSchedulerImpl;
import org.apache.ambari.server.security.AmbariEntryPoint;
@@ -338,6 +339,21 @@ public class ControllerModule extends AbstractModule {
bindConstant().annotatedWith(Names.named("executionCommandCacheSize")).
to(configuration.getExecutionCommandsCacheSize());
+
+ // Host role commands status summary max cache enable/disable
+ bindConstant().annotatedWith(Names.named(HostRoleCommandDAO.HRC_STATUS_SUMMARY_CACHE_ENABLED)).
+ to(configuration.getHostRoleCommandStatusSummaryCacheEnabled());
+
+ // Host role commands status summary max cache size
+ bindConstant().annotatedWith(Names.named(HostRoleCommandDAO.HRC_STATUS_SUMMARY_CACHE_SIZE)).
+ to(configuration.getHostRoleCommandStatusSummaryCacheSize());
+ // Host role command status summary cache expiry duration in minutes
+ bindConstant().annotatedWith(Names.named(HostRoleCommandDAO.HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION_MINUTES)).
+ to(configuration.getHostRoleCommandStatusSummaryCacheExpiryDuration());
+
+
+
+
bind(AmbariManagementController.class).to(
AmbariManagementControllerImpl.class);
bind(AbstractRootServiceResponseFactory.class).to(RootServiceResponseFactory.class);
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
index 4fd03e5..deca9b1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
@@ -18,9 +18,6 @@
package org.apache.ambari.server.orm.dao;
-import static org.apache.ambari.server.orm.DBAccessor.DbType.ORACLE;
-import static org.apache.ambari.server.orm.dao.DaoUtils.ORACLE_LIST_LIMIT;
-
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
@@ -28,6 +25,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
@@ -49,16 +47,27 @@ import org.apache.ambari.server.orm.entities.HostEntity;
import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
import org.apache.ambari.server.orm.entities.HostRoleCommandEntity_;
import org.apache.ambari.server.orm.entities.StageEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
import com.google.common.collect.Lists;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
+import com.google.inject.name.Named;
import com.google.inject.persist.Transactional;
+import static org.apache.ambari.server.orm.DBAccessor.DbType.ORACLE;
+import static org.apache.ambari.server.orm.dao.DaoUtils.ORACLE_LIST_LIMIT;
+
@Singleton
public class HostRoleCommandDAO {
+ private static final Logger LOG = LoggerFactory.getLogger(HostRoleCommandDAO.class);
+
private static final String SUMMARY_DTO = String.format(
"SELECT NEW %s(" +
"MAX(hrc.stage.skippable), " +
@@ -92,12 +101,122 @@ public class HostRoleCommandDAO {
*/
private static final String COMPLETED_REQUESTS_SQL = "SELECT DISTINCT task.requestId FROM HostRoleCommandEntity task WHERE task.requestId NOT IN (SELECT task.requestId FROM HostRoleCommandEntity task WHERE task.status IN :notCompletedStatuses) ORDER BY task.requestId {0}";
+ /**
+ * A cache that holds {@link HostRoleCommandStatusSummaryDTO} grouped by stage id for requests by request id.
+ * The JPQL computing the host role command status summary for a request is rather expensive
+ * thus this cache helps reducing the load on the database
+ */
+ private final LoadingCache<Long, Map<Long, HostRoleCommandStatusSummaryDTO>> hrcStatusSummaryCache;
+
+ /**
+ * Specifies whether caching for {@link HostRoleCommandStatusSummaryDTO} grouped by stage id for requests
+ * is enabled.
+ */
+ private final boolean hostRoleCommandStatusSummaryCacheEnabled;
+
+
@Inject
Provider<EntityManager> entityManagerProvider;
@Inject
DaoUtils daoUtils;
+ public final static String HRC_STATUS_SUMMARY_CACHE_SIZE = "hostRoleCommandStatusSummaryCacheSize";
+ public final static String HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION_MINUTES = "hostRoleCommandStatusCacheExpiryDurationMins";
+ public final static String HRC_STATUS_SUMMARY_CACHE_ENABLED = "hostRoleCommandStatusSummaryCacheEnabled";
+
+ /**
+ * Invalidates the host role command status summary cache entry that corresponds to the given request.
+ * @param requestId the key of the cache entry to be invalidated.
+ */
+ protected void invalidateHostRoleCommandStatusSummaryCache(Long requestId) {
+ if (!hostRoleCommandStatusSummaryCacheEnabled )
+ return;
+
+ LOG.debug("Invalidating host role command status summary cache for request {} !", requestId);
+ hrcStatusSummaryCache.invalidate(requestId);
+
+ }
+
+ /**
+ * Invalidates those entries in host role command status cache which are dependent on the passed {@link org.apache.ambari.server.orm.entities.HostRoleCommandEntity}
+ * entity.
+ * @param hostRoleCommandEntity
+ */
+ protected void invalidateHostRoleCommandStatusCache(HostRoleCommandEntity hostRoleCommandEntity) {
+ if ( !hostRoleCommandStatusSummaryCacheEnabled )
+ return;
+
+ if (hostRoleCommandEntity != null) {
+ Long requestId = hostRoleCommandEntity.getRequestId();
+ if (requestId == null) {
+ StageEntity stageEntity = hostRoleCommandEntity.getStage();
+ if (stageEntity != null)
+ requestId = stageEntity.getRequestId();
+ }
+
+ if (requestId != null)
+ invalidateHostRoleCommandStatusSummaryCache(requestId.longValue());
+ }
+
+ }
+
+ /**
+ * Loads the counts of tasks for a request and groups them by stage id.
+ * This allows for very efficient loading when there are a huge number of stages
+ * and tasks to iterate (for example, during a Stack Upgrade).
+ * @param requestId the request id
+ * @return the map of stage-to-summary objects
+ */
+ @RequiresSession
+ protected Map<Long, HostRoleCommandStatusSummaryDTO> loadAggregateCounts(Long requestId) {
+
+ TypedQuery<HostRoleCommandStatusSummaryDTO> query = entityManagerProvider.get().createQuery(
+ SUMMARY_DTO, HostRoleCommandStatusSummaryDTO.class);
+
+ query.setParameter("requestId", requestId);
+ query.setParameter("aborted", HostRoleStatus.ABORTED);
+ query.setParameter("completed", HostRoleStatus.COMPLETED);
+ query.setParameter("failed", HostRoleStatus.FAILED);
+ query.setParameter("holding", HostRoleStatus.HOLDING);
+ query.setParameter("holding_failed", HostRoleStatus.HOLDING_FAILED);
+ query.setParameter("holding_timedout", HostRoleStatus.HOLDING_TIMEDOUT);
+ query.setParameter("in_progress", HostRoleStatus.IN_PROGRESS);
+ query.setParameter("pending", HostRoleStatus.PENDING);
+ query.setParameter("queued", HostRoleStatus.QUEUED);
+ query.setParameter("timedout", HostRoleStatus.TIMEDOUT);
+ query.setParameter("skipped_failed", HostRoleStatus.SKIPPED_FAILED);
+
+ Map<Long, HostRoleCommandStatusSummaryDTO> map = new HashMap<Long, HostRoleCommandStatusSummaryDTO>();
+
+ for (HostRoleCommandStatusSummaryDTO dto : daoUtils.selectList(query)) {
+ map.put(dto.getStageId(), dto);
+ }
+
+ return map;
+ }
+
+ @Inject
+ public HostRoleCommandDAO(@Named(HRC_STATUS_SUMMARY_CACHE_ENABLED) boolean hostRoleCommandStatusSummaryCacheEnabled, @Named(HRC_STATUS_SUMMARY_CACHE_SIZE) long hostRoleCommandStatusSummaryCacheLimit, @Named(HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION_MINUTES) long hostRoleCommandStatusSummaryCacheExpiryDurationMins) {
+ this.hostRoleCommandStatusSummaryCacheEnabled = hostRoleCommandStatusSummaryCacheEnabled;
+
+ LOG.info("Host role command status summary cache {} !", hostRoleCommandStatusSummaryCacheEnabled ? "enabled" : "disabled");
+
+
+ hrcStatusSummaryCache = CacheBuilder.newBuilder()
+ .maximumSize(hostRoleCommandStatusSummaryCacheLimit)
+ .expireAfterAccess(hostRoleCommandStatusSummaryCacheExpiryDurationMins, TimeUnit.MINUTES)
+ .build(new CacheLoader<Long, Map<Long, HostRoleCommandStatusSummaryDTO>>() {
+ @Override
+ public Map<Long, HostRoleCommandStatusSummaryDTO> load(Long requestId) throws Exception {
+ LOG.debug("Cache miss for host role command status summary object for request {}, fetching from JPA", requestId);
+ Map<Long, HostRoleCommandStatusSummaryDTO> hrcCommandStatusByStageId = loadAggregateCounts(requestId);
+
+ return hrcCommandStatusByStageId;
+ }
+ });
+ }
+
@RequiresSession
public HostRoleCommandEntity findByPK(long taskId) {
return entityManagerProvider.get().find(HostRoleCommandEntity.class, taskId);
@@ -425,11 +544,16 @@ public class HostRoleCommandDAO {
@Transactional
public void create(HostRoleCommandEntity stageEntity) {
entityManagerProvider.get().persist(stageEntity);
+
+ invalidateHostRoleCommandStatusCache(stageEntity);
}
@Transactional
public HostRoleCommandEntity merge(HostRoleCommandEntity stageEntity) {
HostRoleCommandEntity entity = entityManagerProvider.get().merge(stageEntity);
+
+ invalidateHostRoleCommandStatusCache(entity);
+
return entity;
}
@@ -446,6 +570,8 @@ public class HostRoleCommandDAO {
List<HostRoleCommandEntity> managedList = new ArrayList<HostRoleCommandEntity>(entities.size());
for (HostRoleCommandEntity entity : entities) {
managedList.add(entityManagerProvider.get().merge(entity));
+
+ invalidateHostRoleCommandStatusCache(entity);
}
return managedList;
}
@@ -453,6 +579,8 @@ public class HostRoleCommandDAO {
@Transactional
public void remove(HostRoleCommandEntity stageEntity) {
entityManagerProvider.get().remove(merge(stageEntity));
+
+ invalidateHostRoleCommandStatusCache(stageEntity);
}
@Transactional
@@ -463,39 +591,17 @@ public class HostRoleCommandDAO {
/**
* Finds the counts of tasks for a request and groups them by stage id.
- * This allows for very efficient loading when there are a huge number of stages
- * and tasks to iterate (for example, during a Stack Upgrade).
* @param requestId the request id
* @return the map of stage-to-summary objects
*/
- @RequiresSession
public Map<Long, HostRoleCommandStatusSummaryDTO> findAggregateCounts(Long requestId) {
-
- TypedQuery<HostRoleCommandStatusSummaryDTO> query = entityManagerProvider.get().createQuery(
- SUMMARY_DTO, HostRoleCommandStatusSummaryDTO.class);
-
- query.setParameter("requestId", requestId);
- query.setParameter("aborted", HostRoleStatus.ABORTED);
- query.setParameter("completed", HostRoleStatus.COMPLETED);
- query.setParameter("failed", HostRoleStatus.FAILED);
- query.setParameter("holding", HostRoleStatus.HOLDING);
- query.setParameter("holding_failed", HostRoleStatus.HOLDING_FAILED);
- query.setParameter("holding_timedout", HostRoleStatus.HOLDING_TIMEDOUT);
- query.setParameter("in_progress", HostRoleStatus.IN_PROGRESS);
- query.setParameter("pending", HostRoleStatus.PENDING);
- query.setParameter("queued", HostRoleStatus.QUEUED);
- query.setParameter("timedout", HostRoleStatus.TIMEDOUT);
- query.setParameter("skipped_failed", HostRoleStatus.SKIPPED_FAILED);
-
- Map<Long, HostRoleCommandStatusSummaryDTO> map = new HashMap<Long, HostRoleCommandStatusSummaryDTO>();
-
- for (HostRoleCommandStatusSummaryDTO dto : daoUtils.selectList(query)) {
- map.put(dto.getStageId(), dto);
- }
-
- return map;
+ if (hostRoleCommandStatusSummaryCacheEnabled)
+ return hrcStatusSummaryCache.getUnchecked(requestId);
+ else
+ return loadAggregateCounts(requestId); // if caching not enabled fall back to fetching through JPA
}
+
/**
* Updates the {@link HostRoleCommandEntity#isFailureAutoSkipped()} flag for
* all commands for the given request.
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
index af71c40..1674175 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
@@ -32,6 +32,7 @@ import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
+import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob;
@@ -48,7 +49,11 @@ import org.apache.ambari.server.actionmanager.HostRoleStatus;
import org.apache.commons.lang.ArrayUtils;
@Entity
-@Table(name = "host_role_command")
+@Table(name = "host_role_command"
+ , indexes = {
+ @Index(name = "idx_hrc_request_id", columnList = "request_id")
+ , @Index(name = "idx_hrc_status_role", columnList = "status, role")
+ })
@TableGenerator(name = "host_role_command_id_generator",
table = "ambari_sequences", pkColumnName = "sequence_name", valueColumnName = "sequence_value"
, pkColumnValue = "host_role_command_id_seq"
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java
index 20cf5bb..f93cf43 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java
@@ -392,17 +392,8 @@ public class ServerActionExecutor {
* @throws InterruptedException
*/
public void doWork() throws InterruptedException {
- List<HostRoleCommand> tasks = db.getTasksByHostRoleAndStatus(serverHostName,
- Role.AMBARI_SERVER_ACTION.toString(), HostRoleStatus.QUEUED);
-
- if (null == tasks || tasks.isEmpty()) {
- // !!! if the server is not a part of the cluster,
- // !!! just look for anything designated AMBARI_SERVER_ACTION.
- // !!! do we even need to worry about servername in the first place? We're
- // !!! _on_ the ambari server!
- tasks = db.getTasksByRoleAndStatus(Role.AMBARI_SERVER_ACTION.name(),
- HostRoleStatus.QUEUED);
- }
+ List<HostRoleCommand> tasks = db.getTasksByRoleAndStatus(Role.AMBARI_SERVER_ACTION.name(),
+ HostRoleStatus.QUEUED);
if ((tasks != null) && !tasks.isEmpty()) {
for (HostRoleCommand task : tasks) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 57941d0..4212975 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -2462,13 +2462,31 @@ public class ClusterImpl implements Cluster {
clusterGlobalLock.readLock().lock();
try {
List<ServiceConfigVersionResponse> serviceConfigVersionResponses = new ArrayList<ServiceConfigVersionResponse>();
- Set<Long> activeIds = getActiveServiceConfigVersionIds();
- for (ServiceConfigEntity serviceConfigEntity : serviceConfigDAO.getServiceConfigs(getClusterId())) {
+ List<ServiceConfigEntity> serviceConfigs = serviceConfigDAO.getServiceConfigs(getClusterId());
+ Map<String, ServiceConfigVersionResponse> activeServiceConfigResponses = new HashMap<>();
+
+ for (ServiceConfigEntity serviceConfigEntity : serviceConfigs) {
ServiceConfigVersionResponse serviceConfigVersionResponse = convertToServiceConfigVersionResponse(serviceConfigEntity);
+ ServiceConfigVersionResponse activeServiceConfigResponse = activeServiceConfigResponses.get(serviceConfigVersionResponse.getServiceName());
+ if (activeServiceConfigResponse == null) {
+ activeServiceConfigResponse = serviceConfigVersionResponse;
+ activeServiceConfigResponses.put(serviceConfigVersionResponse.getServiceName(), serviceConfigVersionResponse);
+ }
+
serviceConfigVersionResponse.setConfigurations(new ArrayList<ConfigurationResponse>());
- serviceConfigVersionResponse.setIsCurrent(activeIds.contains(serviceConfigEntity.getServiceConfigId()));
+
+ if (serviceConfigEntity.getGroupId() == null) {
+ if (serviceConfigVersionResponse.getCreateTime() > activeServiceConfigResponse.getCreateTime())
+ activeServiceConfigResponses.put(serviceConfigVersionResponse.getServiceName(), serviceConfigVersionResponse);
+ }
+ else if (clusterConfigGroups != null && clusterConfigGroups.containsKey(serviceConfigEntity.getGroupId())){
+ if (serviceConfigVersionResponse.getVersion() > activeServiceConfigResponse.getVersion())
+ activeServiceConfigResponses.put(serviceConfigVersionResponse.getServiceName(), serviceConfigVersionResponse);
+ }
+
+ serviceConfigVersionResponse.setIsCurrent(false);
List<ClusterConfigEntity> clusterConfigEntities = serviceConfigEntity.getClusterConfigEntities();
for (ClusterConfigEntity clusterConfigEntity : clusterConfigEntities) {
@@ -2484,6 +2502,10 @@ public class ClusterImpl implements Cluster {
serviceConfigVersionResponses.add(serviceConfigVersionResponse);
}
+ for (ServiceConfigVersionResponse serviceConfigVersionResponse: activeServiceConfigResponses.values()) {
+ serviceConfigVersionResponse.setIsCurrent(true);
+ }
+
return serviceConfigVersionResponses;
} finally {
clusterGlobalLock.readLock().unlock();
@@ -2502,14 +2524,6 @@ public class ClusterImpl implements Cluster {
return responses;
}
- private Set<Long> getActiveServiceConfigVersionIds() {
- Set<Long> idSet = new HashSet<Long>();
- for (ServiceConfigEntity entity : getActiveServiceConfigVersionEntities()) {
- idSet.add(entity.getServiceConfigId());
- }
- return idSet;
- }
-
private List<ServiceConfigEntity> getActiveServiceConfigVersionEntities() {
List<ServiceConfigEntity> activeServiceConfigVersions = new ArrayList<ServiceConfigEntity>();
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
index 88b3151..0aa1e7a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
@@ -115,6 +115,7 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
updateAlerts();
updateStormConfigs();
updateAMSConfigs();
+ updateHostRoleCommands();
}
protected void updateStormConfigs() throws AmbariException {
@@ -153,6 +154,10 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
}
+ protected void updateHostRoleCommands() throws SQLException{
+ dbAccessor.createIndex("idx_hrc_status", "host_role_command", "status", "role");
+ }
+
protected void updateAMSConfigs() throws AmbariException {
AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
Clusters clusters = ambariManagementController.getClusters();
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index e395902..1ea1646 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -677,6 +677,7 @@ CREATE TABLE setting (
-- tasks indices --
CREATE INDEX idx_stage_request_id ON stage (request_id);
CREATE INDEX idx_hrc_request_id ON host_role_command (request_id);
+CREATE INDEX idx_hrc_status_role ON host_role_command (status, role);
CREATE INDEX idx_rsc_request_id ON role_success_criteria (request_id);
-- altering tables by creating unique constraints----------
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index 0f957e6..e5fa3e1 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -666,6 +666,7 @@ CREATE TABLE setting (
-- tasks indices --
CREATE INDEX idx_stage_request_id ON stage (request_id);
CREATE INDEX idx_hrc_request_id ON host_role_command (request_id);
+CREATE INDEX idx_hrc_status_role ON host_role_command (status, role);
CREATE INDEX idx_rsc_request_id ON role_success_criteria (request_id);
--------altering tables by creating unique constraints----------
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index 7daf4ae..150ea9b 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -670,8 +670,11 @@ CREATE TABLE setting (
-- tasks indices --
CREATE INDEX idx_stage_request_id ON stage (request_id);
CREATE INDEX idx_hrc_request_id ON host_role_command (request_id);
+CREATE INDEX idx_hrc_status_role ON host_role_command (status, role);
CREATE INDEX idx_rsc_request_id ON role_success_criteria (request_id);
+
+
--------altering tables by creating unique constraints----------
ALTER TABLE users ADD CONSTRAINT UNQ_users_0 UNIQUE (user_name, user_type);
ALTER TABLE clusterconfig ADD CONSTRAINT UQ_config_type_tag UNIQUE (cluster_id, type_name, version_tag);
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
index 28c025f..0443336 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
@@ -752,6 +752,7 @@ GRANT ALL PRIVILEGES ON TABLE ambari.setting TO :username;
-- tasks indices --
CREATE INDEX idx_stage_request_id ON ambari.stage (request_id);
CREATE INDEX idx_hrc_request_id ON ambari.host_role_command (request_id);
+CREATE INDEX idx_hrc_status_role ON ambari.host_role_command (status, role);
CREATE INDEX idx_rsc_request_id ON ambari.role_success_criteria (request_id);
--------altering tables by creating unique constraints----------
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index c9d6ac2..1f45bc7 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -666,6 +666,7 @@ CREATE TABLE setting (
-- tasks indices --
CREATE INDEX idx_stage_request_id ON stage (request_id);
CREATE INDEX idx_hrc_request_id ON host_role_command (request_id);
+CREATE INDEX idx_hrc_status_role ON host_role_command (status, role);
CREATE INDEX idx_rsc_request_id ON role_success_criteria (request_id);
-- altering tables by creating unique constraints----------
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index 4d6f0e8..b1edbbd 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -775,6 +775,7 @@ CREATE TABLE setting (
-- tasks indices --
CREATE INDEX idx_stage_request_id ON stage (request_id);
CREATE INDEX idx_hrc_request_id ON host_role_command (request_id);
+CREATE INDEX idx_hrc_status_role ON host_role_command (status, role);
CREATE INDEX idx_rsc_request_id ON role_success_criteria (request_id);
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
index bc4d397..af6fb9b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
@@ -607,8 +607,8 @@ public class TestActionScheduler {
doAnswer(new Answer<List<HostRoleCommand>>() {
@Override
public List<HostRoleCommand> answer(InvocationOnMock invocation) throws Throwable {
- String role = (String) invocation.getArguments()[1];
- HostRoleStatus status = (HostRoleStatus) invocation.getArguments()[2];
+ String role = (String) invocation.getArguments()[0];
+ HostRoleStatus status = (HostRoleStatus) invocation.getArguments()[1];
HostRoleCommand task = s.getHostRoleCommand(null, role);
@@ -618,7 +618,7 @@ public class TestActionScheduler {
return Collections.emptyList();
}
}
- }).when(db).getTasksByHostRoleAndStatus(anyString(), anyString(), any(HostRoleStatus.class));
+ }).when(db).getTasksByRoleAndStatus(anyString(), any(HostRoleStatus.class));
ServerActionExecutor.init(injector);
ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
@@ -762,8 +762,8 @@ public class TestActionScheduler {
doAnswer(new Answer<List<HostRoleCommand>>() {
@Override
public List<HostRoleCommand> answer(InvocationOnMock invocation) throws Throwable {
- String role = (String) invocation.getArguments()[1];
- HostRoleStatus status = (HostRoleStatus) invocation.getArguments()[2];
+ String role = (String) invocation.getArguments()[0];
+ HostRoleStatus status = (HostRoleStatus) invocation.getArguments()[1];
HostRoleCommand task = s.getHostRoleCommand(null, role);
@@ -774,7 +774,7 @@ public class TestActionScheduler {
}
}
- }).when(db).getTasksByHostRoleAndStatus(anyString(), anyString(), any(HostRoleStatus.class));
+ }).when(db).getTasksByRoleAndStatus(anyString(), any(HostRoleStatus.class));
ServerActionExecutor.init(injector);
ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
@@ -843,8 +843,8 @@ public class TestActionScheduler {
doAnswer(new Answer<List<HostRoleCommand>>() {
@Override
public List<HostRoleCommand> answer(InvocationOnMock invocation) throws Throwable {
- String role = (String) invocation.getArguments()[1];
- HostRoleStatus status = (HostRoleStatus) invocation.getArguments()[2];
+ String role = (String) invocation.getArguments()[0];
+ HostRoleStatus status = (HostRoleStatus) invocation.getArguments()[1];
HostRoleCommand task = s.getHostRoleCommand(null, role);
@@ -854,7 +854,7 @@ public class TestActionScheduler {
return Collections.emptyList();
}
}
- }).when(db).getTasksByHostRoleAndStatus(anyString(), anyString(), any(HostRoleStatus.class));
+ }).when(db).getTasksByRoleAndStatus(anyString(), any(HostRoleStatus.class));
ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
new HostsMap((String) null), unitOfWork, null, conf);
@@ -1951,8 +1951,8 @@ public class TestActionScheduler {
doAnswer(new Answer<List<HostRoleCommand>>() {
@Override
public List<HostRoleCommand> answer(InvocationOnMock invocation) throws Throwable {
- String role = (String) invocation.getArguments()[1];
- HostRoleStatus status = (HostRoleStatus) invocation.getArguments()[2];
+ String role = (String) invocation.getArguments()[0];
+ HostRoleStatus status = (HostRoleStatus) invocation.getArguments()[1];
HostRoleCommand task = s.getHostRoleCommand(null, role);
@@ -1962,7 +1962,7 @@ public class TestActionScheduler {
return Collections.emptyList();
}
}
- }).when(db).getTasksByHostRoleAndStatus(anyString(), anyString(), any(HostRoleStatus.class));
+ }).when(db).getTasksByRoleAndStatus(anyString(), any(HostRoleStatus.class));
doAnswer(new Answer<HostRoleCommand>() {
@Override
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
index 510e1fb..6cb9e6f 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java
@@ -36,6 +36,7 @@ import org.apache.ambari.server.agent.rest.AgentResource;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
import org.apache.ambari.server.orm.DBAccessor;
+import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
import org.apache.ambari.server.security.SecurityHelper;
import org.apache.ambari.server.security.SecurityHelperImpl;
import org.apache.ambari.server.stack.StackManagerFactory;
@@ -308,6 +309,7 @@ public class AgentResourceTest extends RandomPortJerseyTest {
bind(HeartBeatHandler.class).toInstance(handler);
bind(AmbariMetaInfo.class).toInstance(ambariMetaInfo);
bind(DBAccessor.class).toInstance(mock(DBAccessor.class));
+ bind(HostRoleCommandDAO.class).toInstance(mock(HostRoleCommandDAO.class));
}
private void installDependencies() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
index 4e236f3..3ecb5aa 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
@@ -563,4 +563,99 @@ public class ConfigurationTest {
Assert.assertEquals(44, configuration.getPropertyProvidersThreadPoolMaxSize());
}
+
+ public void testGetHostRoleCommandStatusSummaryCacheSize() throws Exception {
+ // Given
+ final Properties ambariProperties = new Properties();
+ final Configuration configuration = new Configuration(ambariProperties);
+ ambariProperties.setProperty(Configuration.SERVER_HRC_STATUS_SUMMARY_CACHE_SIZE, "3000");
+
+ // When
+ long actualCacheSize = configuration.getHostRoleCommandStatusSummaryCacheSize();
+
+ // Then
+ Assert.assertEquals(actualCacheSize, 3000L);
+ }
+
+ @Test
+ public void testGetHostRoleCommandStatusSummaryCacheSizeDefault() throws Exception {
+ // Given
+ final Properties ambariProperties = new Properties();
+ final Configuration configuration = new Configuration(ambariProperties);
+
+ // When
+ long actualCacheSize = configuration.getHostRoleCommandStatusSummaryCacheSize();
+
+ // Then
+ Assert.assertEquals(actualCacheSize, Configuration.SERVER_HRC_STATUS_SUMMARY_CACHE_SIZE_DEFAULT);
+ }
+
+ @Test
+ public void testGetHostRoleCommandStatusSummaryCacheExpiryDuration() throws Exception {
+ // Given
+ final Properties ambariProperties = new Properties();
+ final Configuration configuration = new Configuration(ambariProperties);
+ ambariProperties.setProperty(Configuration.SERVER_HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION, "60");
+
+ // When
+ long actualCacheExpiryDuration = configuration.getHostRoleCommandStatusSummaryCacheExpiryDuration();
+
+ // Then
+ Assert.assertEquals(actualCacheExpiryDuration, 60L);
+ }
+
+ @Test
+ public void testGetHostRoleCommandStatusSummaryCacheExpiryDurationDefault() throws Exception {
+ // Given
+ final Properties ambariProperties = new Properties();
+ final Configuration configuration = new Configuration(ambariProperties);
+
+ // When
+ long actualCacheExpiryDuration = configuration.getHostRoleCommandStatusSummaryCacheExpiryDuration();
+
+ // Then
+ Assert.assertEquals(actualCacheExpiryDuration, Configuration.SERVER_HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION_DEFAULT);
+ }
+
+ @Test
+ public void testGetHostRoleCommandStatusSummaryCacheEnabled() throws Exception {
+ // Given
+ final Properties ambariProperties = new Properties();
+ final Configuration configuration = new Configuration(ambariProperties);
+ ambariProperties.setProperty(Configuration.SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED, "true");
+
+ // When
+ boolean actualCacheEnabledConfig = configuration.getHostRoleCommandStatusSummaryCacheEnabled();
+
+ // Then
+ Assert.assertEquals(actualCacheEnabledConfig, true);
+ }
+
+ @Test
+ public void testGetHostRoleCommandStatusSummaryCacheDisabled() throws Exception {
+ // Given
+ final Properties ambariProperties = new Properties();
+ final Configuration configuration = new Configuration(ambariProperties);
+ ambariProperties.setProperty(Configuration.SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED, "false");
+
+ // When
+ boolean actualCacheEnabledConfig = configuration.getHostRoleCommandStatusSummaryCacheEnabled();
+
+ // Then
+ Assert.assertEquals(actualCacheEnabledConfig, false);
+ }
+
+ @Test
+ public void testGetHostRoleCommandStatusSummaryCacheEnabledDefault() throws Exception {
+ // Given
+ final Properties ambariProperties = new Properties();
+ final Configuration configuration = new Configuration(ambariProperties);
+
+ // When
+ boolean actualCacheEnabledConfig = configuration.getHostRoleCommandStatusSummaryCacheEnabled();
+
+ // Then
+ Assert.assertEquals(actualCacheEnabledConfig, Configuration.SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED_DEFAULT);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
index 2dcde00..f6027f3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java
@@ -42,6 +42,7 @@ import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.spi.ResourceProvider;
import org.apache.ambari.server.metadata.RoleCommandOrder;
import org.apache.ambari.server.orm.DBAccessor;
+import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
import org.apache.ambari.server.security.SecurityHelper;
import org.apache.ambari.server.security.credential.PrincipalKeyCredential;
import org.apache.ambari.server.security.encryption.CredentialStoreService;
@@ -215,6 +216,7 @@ public class KerberosHelperTest extends EasyMockSupport {
bind(CreatePrincipalsServerAction.class).toInstance(createMock(CreatePrincipalsServerAction.class));
bind(CreateKeytabFilesServerAction.class).toInstance(createMock(CreateKeytabFilesServerAction.class));
bind(StackAdvisorHelper.class).toInstance(createMock(StackAdvisorHelper.class));
+ bind(HostRoleCommandDAO.class).toInstance(createNiceMock(HostRoleCommandDAO.class));
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
index 98424b7..9fe0fc3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
@@ -48,6 +48,7 @@ import org.apache.ambari.server.controller.spi.ClusterController;
import org.apache.ambari.server.orm.DBAccessor;
import org.apache.ambari.server.orm.GuiceJpaInitializer;
import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
import org.apache.ambari.server.security.SecurityHelper;
import org.apache.ambari.server.security.TestAuthenticationFactory;
import org.apache.ambari.server.stack.StackManagerFactory;
@@ -754,6 +755,7 @@ public class ConfigHelperTest {
bind(Clusters.class).toInstance(createNiceMock(ClustersImpl.class));
bind(ClusterController.class).toInstance(clusterController);
bind(StackManagerFactory.class).toInstance(createNiceMock(StackManagerFactory.class));
+ bind(HostRoleCommandDAO.class).toInstance(createNiceMock(HostRoleCommandDAO.class));
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
index 6061e06..077df33 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
@@ -19,12 +19,12 @@
package org.apache.ambari.server.upgrade;
-import com.google.common.collect.Maps;
-import com.google.gson.Gson;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Provider;
-import com.google.inject.persist.PersistService;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+
import org.apache.ambari.server.actionmanager.ActionManager;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.controller.AmbariManagementController;
@@ -33,6 +33,7 @@ import org.apache.ambari.server.controller.ConfigurationRequest;
import org.apache.ambari.server.controller.ConfigurationResponse;
import org.apache.ambari.server.controller.KerberosHelper;
import org.apache.ambari.server.controller.MaintenanceStateHelper;
+import org.apache.ambari.server.orm.DBAccessor;
import org.apache.ambari.server.orm.GuiceJpaInitializer;
import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
import org.apache.ambari.server.orm.dao.StackDAO;
@@ -40,6 +41,7 @@ import org.apache.ambari.server.orm.entities.StackEntity;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.stack.OsFamily;
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.easymock.EasyMockSupport;
@@ -47,10 +49,14 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import javax.persistence.EntityManager;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
+import com.google.common.collect.Maps;
+import com.google.gson.Gson;
+import com.google.inject.Binder;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.Provider;
+import com.google.inject.persist.PersistService;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.anyString;
@@ -58,6 +64,7 @@ import static org.easymock.EasyMock.capture;
import static org.easymock.EasyMock.createMockBuilder;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
@@ -101,6 +108,7 @@ public class UpgradeCatalog222Test {
Method updateAlerts = UpgradeCatalog222.class.getDeclaredMethod("updateAlerts");
Method updateStormConfigs = UpgradeCatalog222.class.getDeclaredMethod("updateStormConfigs");
Method updateAMSConfigs = UpgradeCatalog222.class.getDeclaredMethod("updateAMSConfigs");
+ Method updateHostRoleCommands = UpgradeCatalog222.class.getDeclaredMethod("updateHostRoleCommands");
UpgradeCatalog222 upgradeCatalog222 = createMockBuilder(UpgradeCatalog222.class)
@@ -108,6 +116,7 @@ public class UpgradeCatalog222Test {
.addMockedMethod(updateAlerts)
.addMockedMethod(updateStormConfigs)
.addMockedMethod(updateAMSConfigs)
+ .addMockedMethod(updateHostRoleCommands)
.createMock();
upgradeCatalog222.addNewConfigurationsFromXml();
@@ -118,6 +127,8 @@ public class UpgradeCatalog222Test {
expectLastCall().once();
upgradeCatalog222.updateAMSConfigs();
expectLastCall().once();
+ upgradeCatalog222.updateHostRoleCommands();
+ expectLastCall().once();
replay(upgradeCatalog222);
@@ -203,4 +214,28 @@ public class UpgradeCatalog222Test {
}
+ @Test
+ public void testUpdateHostRoleCommands() throws Exception {
+ final DBAccessor dbAccessor = createNiceMock(DBAccessor.class);
+ dbAccessor.createIndex(eq("idx_hrc_status"), eq("host_role_command"), eq("status"), eq("role"));
+ expectLastCall().once();
+
+ replay(dbAccessor);
+
+ Module module = new Module() {
+ @Override
+ public void configure(Binder binder) {
+ binder.bind(DBAccessor.class).toInstance(dbAccessor);
+ binder.bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+ }
+ };
+
+ Injector injector = Guice.createInjector(module);
+ UpgradeCatalog222 upgradeCatalog222 = injector.getInstance(UpgradeCatalog222.class);
+ upgradeCatalog222.updateHostRoleCommands();
+
+
+ verify(dbAccessor);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/20056273/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java b/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
index 854263c..215d137 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
@@ -37,6 +37,7 @@ import org.apache.ambari.server.agent.ExecutionCommand;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.orm.DBAccessor;
import org.apache.ambari.server.orm.dao.HostDAO;
+import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
import org.apache.ambari.server.security.SecurityHelper;
import org.apache.ambari.server.security.encryption.CredentialStoreService;
import org.apache.ambari.server.stack.StackManagerFactory;
@@ -118,6 +119,7 @@ public class StageUtilsTest extends EasyMockSupport {
bind(HostRoleCommandFactory.class).to(HostRoleCommandFactoryImpl.class);
bind(HostDAO.class).toInstance(createNiceMock(HostDAO.class));
bind(PersistedState.class).toInstance(createNiceMock(PersistedState.class));
+ bind(HostRoleCommandDAO.class).toInstance(createNiceMock(HostRoleCommandDAO.class));
}
});
[15/21] ambari git commit: AMBARI-15115. Agent bootstrap/registration
fails in multi-byte language environments.(vbrodetskyi)
Posted by nc...@apache.org.
AMBARI-15115. Agent bootstrap/registration fails in multi-byte language environments.(vbrodetskyi)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a8e337ca
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a8e337ca
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a8e337ca
Branch: refs/heads/branch-dev-patch-upgrade
Commit: a8e337caf432008a5d935648c852cb3ab4aed67f
Parents: 6044f0c
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Mon Feb 22 11:37:56 2016 +0200
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Mon Feb 22 11:37:56 2016 +0200
----------------------------------------------------------------------
ambari-common/src/main/python/resource_management/core/logger.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/a8e337ca/ambari-common/src/main/python/resource_management/core/logger.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/logger.py b/ambari-common/src/main/python/resource_management/core/logger.py
index fd05b02..5bbd35b 100644
--- a/ambari-common/src/main/python/resource_management/core/logger.py
+++ b/ambari-common/src/main/python/resource_management/core/logger.py
@@ -173,4 +173,4 @@ class Logger:
if arguments_str:
arguments_str = arguments_str[:-2]
- return unicode("{0} {{{1}}}").format(name, arguments_str)
\ No newline at end of file
+ return unicode("{0} {{{1}}}", 'UTF-8').format(name, arguments_str)
\ No newline at end of file
[13/21] ambari git commit: AMBARI-15125. Preupload.py should use
hdfs_path_prefix (aonishuk)
Posted by nc...@apache.org.
AMBARI-15125. Preupload.py should use hdfs_path_prefix (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4bdd8dd9
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4bdd8dd9
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4bdd8dd9
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 4bdd8dd9c6a391e7caa1bbf817989edadd4e8e10
Parents: 1ba6722
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Sat Feb 20 22:01:25 2016 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Sat Feb 20 22:01:25 2016 +0200
----------------------------------------------------------------------
.../main/resources/scripts/Ambaripreupload.py | 41 +++++++++++---------
1 file changed, 22 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bdd8dd9/ambari-server/src/main/resources/scripts/Ambaripreupload.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/scripts/Ambaripreupload.py b/ambari-server/src/main/resources/scripts/Ambaripreupload.py
index cc6213e..fb0c3e1 100644
--- a/ambari-server/src/main/resources/scripts/Ambaripreupload.py
+++ b/ambari-server/src/main/resources/scripts/Ambaripreupload.py
@@ -132,6 +132,7 @@ with Environment() as env:
TAR_DESTINATION_FOLDER_SUFFIX = "_tar_destination_folder"
class params:
+ hdfs_path_prefix = hdfs_path_prefix
hdfs_user = "hdfs"
mapred_user ="mapred"
hadoop_bin_dir="/usr/hdp/" + hdp_version + "/hadoop/bin"
@@ -236,23 +237,23 @@ with Environment() as env:
return _copy_files(source_and_dest_pairs, file_owner, group_owner, kinit_if_needed)
def createHdfsResources():
- params.HdfsResource('/atshistory', user='hdfs', change_permissions_for_parents=True, owner='yarn', group='hadoop', type='directory', action= ['create_on_execute'], mode=0755)
- params.HdfsResource('/user/hcat', owner='hcat', type='directory', action=['create_on_execute'], mode=0755)
- params.HdfsResource('/hive/warehouse', owner='hive', type='directory', action=['create_on_execute'], mode=0777)
- params.HdfsResource('/user/hive', owner='hive', type='directory', action=['create_on_execute'], mode=0755)
- params.HdfsResource('/tmp', mode=0777, action=['create_on_execute'], type='directory', owner='hdfs')
- params.HdfsResource('/user/ambari-qa', type='directory', action=['create_on_execute'], mode=0770)
- params.HdfsResource('/user/oozie', owner='oozie', type='directory', action=['create_on_execute'], mode=0775)
- params.HdfsResource('/app-logs', recursive_chmod=True, owner='yarn', group='hadoop', type='directory', action=['create_on_execute'], mode=0777)
- params.HdfsResource('/tmp/entity-file-history/active', owner='yarn', group='hadoop', type='directory', action=['create_on_execute'])
- params.HdfsResource('/mapred', owner='mapred', type='directory', action=['create_on_execute'])
- params.HdfsResource('/mapred/system', owner='hdfs', type='directory', action=['create_on_execute'])
- params.HdfsResource('/mr-history/done', change_permissions_for_parents=True, owner='mapred', group='hadoop', type='directory', action=['create_on_execute'], mode=0777)
- params.HdfsResource('/atshistory/done', owner='yarn', group='hadoop', type='directory', action=['create_on_execute'], mode=0700)
- params.HdfsResource('/atshistory/active', owner='yarn', group='hadoop', type='directory', action=['create_on_execute'], mode=01777)
- params.HdfsResource('/ams/hbase', owner='ams', type='directory', action=['create_on_execute'], mode=0775)
- params.HdfsResource('/amshbase/staging', owner='ams', type='directory', action=['create_on_execute'], mode=0711)
- params.HdfsResource('/user/ams/hbase', owner='ams', type='directory', action=['create_on_execute'], mode=0775)
+ params.HdfsResource(format('{hdfs_path_prefix}/atshistory'), user='hdfs', change_permissions_for_parents=True, owner='yarn', group='hadoop', type='directory', action= ['create_on_execute'], mode=0755)
+ params.HdfsResource(format('{hdfs_path_prefix}/user/hcat'), owner='hcat', type='directory', action=['create_on_execute'], mode=0755)
+ params.HdfsResource(format('{hdfs_path_prefix}/hive/warehouse'), owner='hive', type='directory', action=['create_on_execute'], mode=0777)
+ params.HdfsResource(format('{hdfs_path_prefix}/user/hive'), owner='hive', type='directory', action=['create_on_execute'], mode=0755)
+ params.HdfsResource(format('{hdfs_path_prefix}/tmp'), mode=0777, action=['create_on_execute'], type='directory', owner='hdfs')
+ params.HdfsResource(format('{hdfs_path_prefix}/user/ambari-qa'), type='directory', action=['create_on_execute'], mode=0770)
+ params.HdfsResource(format('{hdfs_path_prefix}/user/oozie'), owner='oozie', type='directory', action=['create_on_execute'], mode=0775)
+ params.HdfsResource(format('{hdfs_path_prefix}/app-logs'), recursive_chmod=True, owner='yarn', group='hadoop', type='directory', action=['create_on_execute'], mode=0777)
+ params.HdfsResource(format('{hdfs_path_prefix}/tmp/entity-file-history/active'), owner='yarn', group='hadoop', type='directory', action=['create_on_execute'])
+ params.HdfsResource(format('{hdfs_path_prefix}/mapred'), owner='mapred', type='directory', action=['create_on_execute'])
+ params.HdfsResource(format('{hdfs_path_prefix}/mapred/system'), owner='hdfs', type='directory', action=['create_on_execute'])
+ params.HdfsResource(format('{hdfs_path_prefix}/mr-history/done'), change_permissions_for_parents=True, owner='mapred', group='hadoop', type='directory', action=['create_on_execute'], mode=0777)
+ params.HdfsResource(format('{hdfs_path_prefix}/atshistory/done'), owner='yarn', group='hadoop', type='directory', action=['create_on_execute'], mode=0700)
+ params.HdfsResource(format('{hdfs_path_prefix}/atshistory/active'), owner='yarn', group='hadoop', type='directory', action=['create_on_execute'], mode=01777)
+ params.HdfsResource(format('{hdfs_path_prefix}/ams/hbase'), owner='ams', type='directory', action=['create_on_execute'], mode=0775)
+ params.HdfsResource(format('{hdfs_path_prefix}/amshbase/staging'), owner='ams', type='directory', action=['create_on_execute'], mode=0711)
+ params.HdfsResource(format('{hdfs_path_prefix}/user/ams/hbase'), owner='ams', type='directory', action=['create_on_execute'], mode=0775)
def putCreatedHdfsResourcesToIgnore(env):
@@ -262,14 +263,16 @@ with Environment() as env:
file_content = ""
for file in env.config['hdfs_files']:
- file_content += file['target']
+ if not file['target'].startswith(hdfs_path_prefix):
+ raise Exception("Something created outside hdfs_path_prefix!")
+ file_content += file['target'][len(hdfs_path_prefix):]
file_content += "\n"
with open("/var/lib/ambari-agent/data/.hdfs_resource_ignore", "a+") as fp:
fp.write(file_content)
def putSQLDriverToOozieShared():
- params.HdfsResource('/user/oozie/share/lib/sqoop/{0}'.format(os.path.basename(SQL_DRIVER_PATH)),
+ params.HdfsResource(hdfs_path_prefix + '/user/oozie/share/lib/sqoop/{0}'.format(os.path.basename(SQL_DRIVER_PATH)),
owner='hdfs', type='file', action=['create_on_execute'], mode=0644, source=SQL_DRIVER_PATH)
env.set_params(params)
[06/21] ambari git commit: AMBARI-15065. Add Service/component
dependency for 'HiveServer Interactive' component. (swapan shridhar via
jaimin)
Posted by nc...@apache.org.
AMBARI-15065. Add Service/component dependency for 'HiveServer Interactive' component. (swapan shridhar via jaimin)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d207bef2
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d207bef2
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d207bef2
Branch: refs/heads/branch-dev-patch-upgrade
Commit: d207bef2513f31d6fc2501e28aacbd70ed930028
Parents: bd5fcae
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Sat Feb 20 00:51:48 2016 +0530
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Sat Feb 20 00:51:48 2016 +0530
----------------------------------------------------------------------
.../stacks/HDP/2.4/services/HIVE/metainfo.xml | 41 ++++++++++++++++++--
1 file changed, 38 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/d207bef2/ambari-server/src/main/resources/stacks/HDP/2.4/services/HIVE/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/services/HIVE/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/services/HIVE/metainfo.xml
index ee973ed..93728fd 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/services/HIVE/metainfo.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/services/HIVE/metainfo.xml
@@ -26,7 +26,7 @@
<name>HIVE_SERVER_INTERACTIVE</name>
<displayName>HiveServer2 Interactive</displayName>
<category>MASTER</category>
- <cardinality>1</cardinality>
+ <cardinality>0+</cardinality>
<versionAdvertised>true</versionAdvertised>
<clientsToUpdateConfigs></clientsToUpdateConfigs>
<dependencies>
@@ -35,7 +35,7 @@
<scope>cluster</scope>
<auto-deploy>
<enabled>true</enabled>
- <co-locate>HIVE/HIVE_SERVER</co-locate>
+ <co-locate>HIVE/HIVE_SERVER_INTERACTIVE</co-locate>
</auto-deploy>
</dependency>
<dependency>
@@ -43,6 +43,15 @@
<scope>host</scope>
<auto-deploy>
<enabled>true</enabled>
+ <co-locate>HIVE/HIVE_SERVER_INTERACTIVE</co-locate>
+ </auto-deploy>
+ </dependency>
+ <dependency>
+ <name>HDFS/HDFS_CLIENT</name>
+ <scope>host</scope>
+ <auto-deploy>
+ <enabled>true</enabled>
+ <co-locate>HIVE/HIVE_SERVER_INTERACTIVE</co-locate>
</auto-deploy>
</dependency>
<dependency>
@@ -50,6 +59,7 @@
<scope>host</scope>
<auto-deploy>
<enabled>true</enabled>
+ <co-locate>HIVE/HIVE_SERVER_INTERACTIVE</co-locate>
</auto-deploy>
</dependency>
<dependency>
@@ -57,9 +67,26 @@
<scope>host</scope>
<auto-deploy>
<enabled>true</enabled>
+ <co-locate>HIVE/HIVE_SERVER_INTERACTIVE</co-locate>
+ </auto-deploy>
+ </dependency>
+ <dependency>
+ <name>PIG/PIG</name>
+ <scope>host</scope>
+ <auto-deploy>
+ <enabled>true</enabled>
+ <co-locate>HIVE/HIVE_SERVER_INTERACTIVE</co-locate>
+ </auto-deploy>
+ </dependency>
+ <dependency>
+ <name>SLIDER/SLIDER</name>
+ <scope>host</scope>
+ <auto-deploy>
+ <enabled>true</enabled>
+ <co-locate>HIVE/HIVE_SERVER_INTERACTIVE</co-locate>
</auto-deploy>
</dependency>
- </dependencies>
+ </dependencies>
<commandScript>
<script>scripts/hive_server_interactive.py</script>
<scriptType>PYTHON</scriptType>
@@ -70,6 +97,14 @@
</configuration-dependencies>
</component>
</components>
+ <requiredServices>
+ <service>ZOOKEEPER</service>
+ <service>HDFS</service>
+ <service>YARN</service>
+ <service>TEZ</service>
+ <service>PIG</service>
+ <service>SLIDER</service>
+ </requiredServices>
</service>
</services>
</metainfo>
[14/21] ambari git commit: AMBARI-15122: Auto-start services - Add
upgrade support for changes to servicecomponentdesiredstate table
Posted by nc...@apache.org.
AMBARI-15122: Auto-start services - Add upgrade support for changes to servicecomponentdesiredstate table
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6044f0c8
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6044f0c8
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6044f0c8
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 6044f0c829c0879f3195d7fd445da413d8176222
Parents: 4bdd8dd
Author: Nahappan Somasundaram <ns...@hortonworks.com>
Authored: Fri Feb 19 16:07:15 2016 -0800
Committer: Nahappan Somasundaram <ns...@hortonworks.com>
Committed: Sat Feb 20 17:10:06 2016 -0800
----------------------------------------------------------------------
.../ambari/server/upgrade/UpgradeCatalog240.java | 13 +++++++++++++
.../src/main/resources/Ambari-DDL-MySQL-CREATE.sql | 2 +-
.../src/main/resources/Ambari-DDL-Oracle-CREATE.sql | 2 +-
.../main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql | 2 +-
.../src/main/resources/Ambari-DDL-SQLServer-CREATE.sql | 2 +-
.../ambari/server/upgrade/UpgradeCatalog240Test.java | 12 ++++++++++++
6 files changed, 29 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/6044f0c8/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
index d97962f..6a8ead1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
@@ -77,6 +77,8 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
private static final String ID = "id";
private static final String SETTING_TABLE = "setting";
+ protected static final String SERVICE_COMPONENT_DESIRED_STATE_TABLE = "servicecomponentdesiredstate";
+ protected static final String RECOVERY_ENABLED_COL = "recovery_enabled";
// ----- Constructors ------------------------------------------------------
@@ -115,6 +117,7 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
@Override
protected void executeDDLUpdates() throws AmbariException, SQLException {
updateAdminPermissionTable();
+ updateServiceComponentDesiredStateTable();
createSettingTable();
}
@@ -391,4 +394,14 @@ public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
7, PermissionEntity.VIEW_USER_PERMISSION_NAME));
}
+ /**
+ * Alter servicecomponentdesiredstate table to add recovery_enabled column.
+ * @throws SQLException
+ */
+ private void updateServiceComponentDesiredStateTable() throws SQLException {
+ // ALTER TABLE servicecomponentdesiredstate ADD COLUMN
+ // recovery_enabled SMALLINT DEFAULT 0 NOT NULL
+ dbAccessor.addColumn(SERVICE_COMPONENT_DESIRED_STATE_TABLE,
+ new DBAccessor.DBColumnInfo(RECOVERY_ENABLED_COL, Short.class, null, 0, false));
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6044f0c8/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index 1ea1646..2898ab7 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -177,7 +177,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(100) NOT NULL,
- recovery_enabled TINYINT(1) NOT NULL DEFAULT 0,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
PRIMARY KEY (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/6044f0c8/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index e5fa3e1..092f8c2 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -167,7 +167,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id NUMBER(19) NOT NULL,
desired_state VARCHAR2(255) NOT NULL,
service_name VARCHAR2(255) NOT NULL,
- recovery_enabled NUMBER(1) DEFAULT 0 NOT NULL,
+ recovery_enabled SMALLINT DEFAULT 0 NOT NULL,
PRIMARY KEY (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/6044f0c8/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index 1f45bc7..20a7634 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -166,7 +166,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id NUMERIC(19) NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
- recovery_enabled BIT NOT NULL DEFAULT 0,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
PRIMARY KEY (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/6044f0c8/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index b1edbbd..2c9adf3 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -186,7 +186,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
- recovery_enabled BIT NOT NULL DEFAULT 0,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
PRIMARY KEY CLUSTERED (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/6044f0c8/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
index a145253..ca1b907 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
@@ -100,6 +100,7 @@ public class UpgradeCatalog240Test {
@Test
public void testExecuteDDLUpdates() throws SQLException, AmbariException {
Capture<DBAccessor.DBColumnInfo> capturedColumnInfo = newCapture();
+ Capture<DBAccessor.DBColumnInfo> capturedScColumnInfo = newCapture();
final DBAccessor dbAccessor = createStrictMock(DBAccessor.class);
Configuration configuration = createNiceMock(Configuration.class);
Connection connection = createNiceMock(Connection.class);
@@ -108,6 +109,8 @@ public class UpgradeCatalog240Test {
Capture<List<DBAccessor.DBColumnInfo>> capturedSettingColumns = EasyMock.newCapture();
dbAccessor.addColumn(eq("adminpermission"), capture(capturedColumnInfo));
+ dbAccessor.addColumn(eq(UpgradeCatalog240.SERVICE_COMPONENT_DESIRED_STATE_TABLE), capture(capturedScColumnInfo));
+
dbAccessor.createTable(eq("setting"), capture(capturedSettingColumns), eq("id"));
expect(configuration.getDatabaseUrl()).andReturn(Configuration.JDBC_IN_MEMORY_URL).anyTimes();
expect(dbAccessor.getConnection()).andReturn(connection);
@@ -136,6 +139,15 @@ public class UpgradeCatalog240Test {
Assert.assertEquals(1, columnInfo.getDefaultValue());
Assert.assertEquals(false, columnInfo.isNullable());
+ // Verify if recovery_enabled column was added to servicecomponentdesiredstate table
+ DBAccessor.DBColumnInfo columnScInfo = capturedScColumnInfo.getValue();
+ Assert.assertNotNull(columnScInfo);
+ Assert.assertEquals(UpgradeCatalog240.RECOVERY_ENABLED_COL, columnScInfo.getName());
+ Assert.assertEquals(null, columnScInfo.getLength());
+ Assert.assertEquals(Short.class, columnScInfo.getType());
+ Assert.assertEquals(0, columnScInfo.getDefaultValue());
+ Assert.assertEquals(false, columnScInfo.isNullable());
+
Map<String, Class> expectedCaptures = new HashMap<>();
expectedCaptures.put("id", Long.class);
expectedCaptures.put("name", String.class);
[16/21] ambari git commit: AMBARI-15095. Take into account "config
group" logic in check database queries.(vbrodetskyi)
Posted by nc...@apache.org.
AMBARI-15095. Take into account "config group" logic in check database queries.(vbrodetskyi)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/29d3f6cc
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/29d3f6cc
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/29d3f6cc
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 29d3f6cc7fdb03619de8e6819832927315b303b7
Parents: a8e337c
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Mon Feb 22 15:07:17 2016 +0200
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Mon Feb 22 15:07:17 2016 +0200
----------------------------------------------------------------------
.../server/checks/CheckDatabaseHelper.java | 137 ++++++++++++-------
.../server/checks/CheckDatabaseHelperTest.java | 20 +--
2 files changed, 97 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/29d3f6cc/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
index 0396767..766e2c0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
@@ -59,6 +59,7 @@ public class CheckDatabaseHelper {
private AmbariMetaInfo ambariMetaInfo;
private Injector injector;
private boolean errorAvailable = false;
+ private boolean warningAvailable = false;
@Inject
public CheckDatabaseHelper(DBAccessor dbAccessor,
@@ -119,11 +120,19 @@ public class CheckDatabaseHelper {
this.errorAvailable = errorAvailable;
}
+ public boolean isWarningAvailable() {
+ return warningAvailable;
+ }
+
+ public void setWarningAvailable(boolean warningAvailable) {
+ this.warningAvailable = warningAvailable;
+ }
+
/*
- * This method checks if all configurations that we have in clusterconfig table
- * have at least one mapping in clusterconfigmapping table. If we found not mapped config
- * then we are showing warning message for user.
- * */
+ * This method checks if all configurations that we have in clusterconfig table
+ * have at least one mapping in clusterconfigmapping table. If we found not mapped config
+ * then we are showing warning message for user.
+ * */
protected void checkForNotMappedConfigsToCluster() {
String GET_NOT_MAPPED_CONFIGS_QUERY = "select type_name from clusterconfig where type_name not in (select type_name from clusterconfigmapping)";
Set<String> nonSelectedConfigs = new HashSet<>();
@@ -137,7 +146,8 @@ public class CheckDatabaseHelper {
}
}
if (!nonSelectedConfigs.isEmpty()) {
- LOG.warn("You have config(s) that is(are) not mapped to any cluster: " + StringUtils.join(nonSelectedConfigs, ","));
+ LOG.warn("You have config(s): {} that is(are) not mapped (in clusterconfigmapping table) to any cluster!", StringUtils.join(nonSelectedConfigs, ","));
+ warningAvailable = true;
}
} catch (SQLException e) {
LOG.error("Exception occurred during check for not mapped configs to cluster procedure: ", e);
@@ -159,25 +169,27 @@ public class CheckDatabaseHelper {
* than one selected version it's a bug and we are showing error message for user.
* */
protected void checkForConfigsSelectedMoreThanOnce() {
- String GET_CONFIGS_SELECTED_MORE_THAN_ONCE_QUERY = "select c.cluster_name,type_name from clusterconfigmapping ccm " +
+ String GET_CONFIGS_SELECTED_MORE_THAN_ONCE_QUERY = "select c.cluster_name, ccm.type_name from clusterconfigmapping ccm " +
"join clusters c on ccm.cluster_id=c.cluster_id " +
- "group by c.cluster_name,type_name " +
+ "group by c.cluster_name, ccm.type_name " +
"having sum(selected) > 1";
- Multimap<String, String> configsSelectedMoreThanOnce = HashMultimap.create();
+ Multimap<String, String> clusterConfigTypeMap = HashMultimap.create();
ResultSet rs = null;
try {
Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = statement.executeQuery(GET_CONFIGS_SELECTED_MORE_THAN_ONCE_QUERY);
if (rs != null) {
while (rs.next()) {
- configsSelectedMoreThanOnce.put(rs.getString("cluster_name"), rs.getString("type_name"));
+ clusterConfigTypeMap.put(rs.getString("cluster_name"), rs.getString("type_name"));
+ }
+
+ for (String clusterName : clusterConfigTypeMap.keySet()) {
+ LOG.error("You have config(s), in cluster {}, that is(are) selected more than once in clusterconfigmapping table: {}",
+ clusterName ,StringUtils.join(clusterConfigTypeMap.get(clusterName), ","));
+ errorAvailable = true;
}
}
- for (String clusterName : configsSelectedMoreThanOnce.keySet()) {
- LOG.error(String.format("You have config(s), in cluster %s, that is(are) selected more than once in clusterconfigmapping: %s",
- clusterName ,StringUtils.join(configsSelectedMoreThanOnce.get(clusterName), ",")));
- errorAvailable = true;
- }
+
} catch (SQLException e) {
LOG.error("Exception occurred during check for config selected more than ones procedure: ", e);
} finally {
@@ -207,12 +219,13 @@ public class CheckDatabaseHelper {
while (rs.next()) {
hostsWithoutStatus.add(rs.getString("host_name"));
}
- }
- if (!hostsWithoutStatus.isEmpty()) {
- LOG.error("You have host(s) without status: " + StringUtils.join(hostsWithoutStatus, ","));
- errorAvailable = true;
+ if (!hostsWithoutStatus.isEmpty()) {
+ LOG.error("You have host(s) without state (in hoststate table): " + StringUtils.join(hostsWithoutStatus, ","));
+ errorAvailable = true;
+ }
}
+
} catch (SQLException e) {
LOG.error("Exception occurred during check for host without state procedure: ", e);
} finally {
@@ -236,7 +249,7 @@ public class CheckDatabaseHelper {
String GET_HOST_COMPONENT_STATE_COUNT_QUERY = "select count(*) from hostcomponentstate";
String GET_HOST_COMPONENT_DESIRED_STATE_COUNT_QUERY = "select count(*) from hostcomponentdesiredstate";
String GET_MERGED_TABLE_ROW_COUNT_QUERY = "select count(*) FROM hostcomponentstate hcs " +
- "JOIN hostcomponentdesiredstate hcds ON hcs.service_name = hcds.service_name AND hcs.component_name = hcds.component_name AND hcs.host_id = hcds.host_id";
+ "JOIN hostcomponentdesiredstate hcds ON hcs.service_name=hcds.service_name AND hcs.component_name=hcds.component_name AND hcs.host_id=hcds.host_id";
int hostComponentStateCount = 0;
int hostComponentDesiredStateCount = 0;
int mergedCount = 0;
@@ -266,7 +279,7 @@ public class CheckDatabaseHelper {
}
if (hostComponentStateCount != hostComponentDesiredStateCount || hostComponentStateCount != mergedCount) {
- LOG.error("Your host component states(hostcomponentstate table) count not equals host component desired states(hostcomponentdesiredstate table) count!");
+ LOG.error("Your host component states (hostcomponentstate table) count not equals host component desired states (hostcomponentdesiredstate table) count!");
errorAvailable = true;
}
@@ -297,29 +310,31 @@ public class CheckDatabaseHelper {
String GET_SERVICES_WITHOUT_CONFIGS_QUERY = "select c.cluster_name, service_name from clusterservices cs " +
"join clusters c on cs.cluster_id=c.cluster_id " +
"where service_name not in (select service_name from serviceconfig sc where sc.cluster_id=cs.cluster_id and sc.service_name=cs.service_name and sc.group_id is null)";
- String GET_SERVICE_CONFIG_WITHOUT_MAPPING_QUERY = "select service_name from serviceconfig where service_config_id not in (select service_config_id from serviceconfigmapping) and group_id is null";
+ String GET_SERVICE_CONFIG_WITHOUT_MAPPING_QUERY = "select c.cluster_name, sc.service_name, sc.version from serviceconfig sc " +
+ "join clusters c on sc.cluster_id=c.cluster_id " +
+ "where service_config_id not in (select service_config_id from serviceconfigmapping) and group_id is null";
String GET_STACK_NAME_VERSION_QUERY = "select c.cluster_name, s.stack_name, s.stack_version from clusters c " +
"join stack s on c.desired_stack_id = s.stack_id";
- String GET_SERVICES_WITH_CONFIGS_QUERY = "select c.cluster_name, cs.service_name, type_name, sc.version from clusterservices cs " +
+ String GET_SERVICES_WITH_CONFIGS_QUERY = "select c.cluster_name, cs.service_name, cc.type_name, sc.version from clusterservices cs " +
"join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id " +
"join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id " +
"join clusterconfig cc on scm.config_id=cc.config_id and sc.cluster_id=cc.cluster_id " +
"join clusters c on cc.cluster_id=c.cluster_id " +
"where sc.group_id is null " +
- "group by c.cluster_name, cs.service_name, type_name, sc.version";
- String GET_NOT_SELECTED_SERVICE_CONFIGS_QUERY = "select c.cluster_name, cs.service_name,cc.type_name from clusterservices cs " +
+ "group by c.cluster_name, cs.service_name, cc.type_name, sc.version";
+ String GET_NOT_SELECTED_SERVICE_CONFIGS_QUERY = "select c.cluster_name, cs.service_name, cc.type_name from clusterservices cs " +
"join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id " +
"join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id " +
"join clusterconfig cc on scm.config_id=cc.config_id and cc.cluster_id=sc.cluster_id " +
"join clusterconfigmapping ccm on cc.type_name=ccm.type_name and cc.version_tag=ccm.version_tag and cc.cluster_id=ccm.cluster_id " +
"join clusters c on ccm.cluster_id=c.cluster_id " +
"where sc.group_id is null and sc.service_config_id = (select max(service_config_id) from serviceconfig sc2 where sc2.service_name=sc.service_name and sc2.cluster_id=sc.cluster_id) " +
- "group by c.cluster_name,cs.service_name,cc.type_name " +
+ "group by c.cluster_name, cs.service_name, cc.type_name " +
"having sum(ccm.selected) < 1";
- Multimap<String, String> servicesWithoutConfigs = HashMultimap.create();
+ Multimap<String, String> clusterServiceMap = HashMultimap.create();
Map<String, Map<String, String>> clusterStackInfo = new HashMap<>();
- Set<String> servicesWithoutMappedConfigs = new HashSet<>();
- Map<String, Multimap<String, String>> notSelectedServiceConfigs = new HashMap<>();
+ Map<String, Multimap<String, String>> clusterServiceVersionMap = new HashMap<>();
+ Map<String, Multimap<String, String>> clusterServiceConfigType = new HashMap<>();
ResultSet rs = null;
try {
@@ -328,27 +343,45 @@ public class CheckDatabaseHelper {
rs = statement.executeQuery(GET_SERVICES_WITHOUT_CONFIGS_QUERY);
if (rs != null) {
while (rs.next()) {
- servicesWithoutConfigs.put(rs.getString("cluster_name"), rs.getString("service_name"));
+ clusterServiceMap.put(rs.getString("cluster_name"), rs.getString("service_name"));
+ }
+
+ for (String clusterName : clusterServiceMap.keySet()) {
+ LOG.error("Service(s): {}, from cluster {} has no config(s) in serviceconfig table!", StringUtils.join(clusterServiceMap.get(clusterName), ","), clusterName);
+ errorAvailable = true;
}
- }
- for (String clusterName : servicesWithoutConfigs.keySet()) {
- LOG.error(String.format("Service(s): %s, from cluster %s has no config(s) in serviceconfig table!", StringUtils.join(servicesWithoutConfigs.get(clusterName), ","), clusterName));
- errorAvailable = true;
}
rs = statement.executeQuery(GET_SERVICE_CONFIG_WITHOUT_MAPPING_QUERY);
if (rs != null) {
+ String serviceName = null, version = null, clusterName = null;
while (rs.next()) {
- servicesWithoutMappedConfigs.add(rs.getString("service_name"));
+ serviceName = rs.getString("service_name");
+ clusterName = rs.getString("cluster_name");
+ version = rs.getString("version");
+
+ if (clusterServiceVersionMap.get(clusterName) != null) {
+ Multimap<String, String> serviceVersion = clusterServiceVersionMap.get(clusterName);
+ serviceVersion.put(serviceName, version);
+ } else {
+ Multimap<String, String> serviceVersion = HashMultimap.create();;
+ serviceVersion.put(serviceName, version);
+ clusterServiceVersionMap.put(clusterName, serviceVersion);
+ }
+ }
+
+ for (String clName : clusterServiceVersionMap.keySet()) {
+ Multimap<String, String> serviceVersion = clusterServiceVersionMap.get(clName);
+ for (String servName : serviceVersion.keySet()) {
+ LOG.error("In cluster {}, service config mapping is unavailable (in table serviceconfigmapping) for service {} with version(s) {}! ", clName, servName, StringUtils.join(serviceVersion.get(servName), ","));
+ errorAvailable = true;
+ }
}
- }
- if (!servicesWithoutMappedConfigs.isEmpty()) {
- LOG.error("You have service(s) without mapped configs in serviceconfigmapping: " + StringUtils.join(servicesWithoutMappedConfigs, ","));
- errorAvailable = true;
}
+ //get stack info from db
rs = statement.executeQuery(GET_STACK_NAME_VERSION_QUERY);
if (rs != null) {
while (rs.next()) {
@@ -375,6 +408,7 @@ public class CheckDatabaseHelper {
serviceNames.add(serviceName);
+ //collect data about mapped configs to services from db
if (dbClusterServiceVersionConfigs.get(clusterName) != null) {
Map<Integer, Multimap<String, String>> dbServiceVersionConfigs = dbClusterServiceVersionConfigs.get(clusterName);
@@ -386,18 +420,18 @@ public class CheckDatabaseHelper {
dbServiceVersionConfigs.put(serviceVersion, dbServiceConfigs);
}
} else {
-
Map<Integer, Multimap<String, String>> dbServiceVersionConfigs = new HashMap<>();
Multimap<String, String> dbServiceConfigs = HashMultimap.create();
dbServiceConfigs.put(serviceName, configType);
dbServiceVersionConfigs.put(serviceVersion, dbServiceConfigs);
dbClusterServiceVersionConfigs.put(clusterName, dbServiceVersionConfigs);
-
}
}
}
+ //compare service configs from stack with configs that we got from db
for (Map.Entry<String, Map<String, String>> clusterStackInfoEntry : clusterStackInfo.entrySet()) {
+ //collect required configs for all services from stack
String clusterName = clusterStackInfoEntry.getKey();
Map<String, String> stackInfo = clusterStackInfoEntry.getValue();
String stackName = stackInfo.keySet().iterator().next();
@@ -411,6 +445,7 @@ public class CheckDatabaseHelper {
}
}
+ //compare required service configs from stack with mapped service configs from db
Map<Integer, Multimap<String, String>> dbServiceVersionConfigs = dbClusterServiceVersionConfigs.get(clusterName);
for (Integer serviceVersion : dbServiceVersionConfigs.keySet()) {
Multimap<String, String> dbServiceConfigs = dbServiceVersionConfigs.get(serviceVersion);
@@ -420,8 +455,8 @@ public class CheckDatabaseHelper {
if (serviceConfigsFromDB != null && serviceConfigsFromStack != null) {
serviceConfigsFromStack.removeAll(serviceConfigsFromDB);
if (!serviceConfigsFromStack.isEmpty()) {
- LOG.error(String.format("Required config(s): %s is(are) not available for service %s with service config version %s for cluster %s",
- StringUtils.join(serviceConfigsFromStack, ","), serviceName, Integer.toString(serviceVersion), clusterName));
+ LOG.error("Required config(s): {} is(are) not available for service {} with service config version {} in cluster {}",
+ StringUtils.join(serviceConfigsFromStack, ","), serviceName, Integer.toString(serviceVersion), clusterName);
errorAvailable = true;
}
}
@@ -429,7 +464,7 @@ public class CheckDatabaseHelper {
}
}
-
+ //getting services which has mapped configs which are not selected in clusterconfigmapping
rs = statement.executeQuery(GET_NOT_SELECTED_SERVICE_CONFIGS_QUERY);
if (rs != null) {
String serviceName = null, configType = null, clusterName = null;
@@ -439,24 +474,24 @@ public class CheckDatabaseHelper {
configType = rs.getString("type_name");
- if (notSelectedServiceConfigs.get(clusterName) != null) {
- Multimap<String, String> serviceConfigs = notSelectedServiceConfigs.get(clusterName);
+ if (clusterServiceConfigType.get(clusterName) != null) {
+ Multimap<String, String> serviceConfigs = clusterServiceConfigType.get(clusterName);
serviceConfigs.put(serviceName, configType);
} else {
Multimap<String, String> serviceConfigs = HashMultimap.create();
serviceConfigs.put(serviceName, configType);
- notSelectedServiceConfigs.put(clusterName, serviceConfigs);
+ clusterServiceConfigType.put(clusterName, serviceConfigs);
}
}
}
- for (String clusterName : notSelectedServiceConfigs.keySet()) {
- Multimap<String, String> serviceConfig = notSelectedServiceConfigs.get(clusterName);
+ for (String clusterName : clusterServiceConfigType.keySet()) {
+ Multimap<String, String> serviceConfig = clusterServiceConfigType.get(clusterName);
for (String serviceName : serviceConfig.keySet()) {
- LOG.error(String.format("You have non selected configs: %s for service %s from cluster %s!", StringUtils.join(serviceConfig.get(serviceName), ","), serviceName, clusterName));
+ LOG.error("You have non selected configs: {} for service {} from cluster {}!", StringUtils.join(serviceConfig.get(serviceName), ","), serviceName, clusterName);
errorAvailable = true;
}
}
@@ -515,8 +550,8 @@ public class CheckDatabaseHelper {
} finally {
if (checkDatabaseHelper != null) {
checkDatabaseHelper.closeConnection();
- if (checkDatabaseHelper.isErrorAvailable()) {
- System.out.print("Some error(s) was(were) found. Please check ambari-server-check-database.log for problem(s).");
+ if (checkDatabaseHelper.isErrorAvailable() || checkDatabaseHelper.isWarningAvailable()) {
+ System.out.print("Some error(s) or/and warning(s) was(were) found. Please check ambari-server-check-database.log for problem(s).");
} else {
System.out.print("No erros were found.");
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/29d3f6cc/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
index 67594b7..51ed42b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
@@ -111,9 +111,9 @@ public class CheckDatabaseHelperTest {
expect(mockDBDbAccessor.getConnection()).andReturn(mockConnection);
expect(mockConnection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE)).andReturn(mockStatement);
- expect(mockStatement.executeQuery("select c.cluster_name,type_name from clusterconfigmapping ccm " +
+ expect(mockStatement.executeQuery("select c.cluster_name, ccm.type_name from clusterconfigmapping ccm " +
"join clusters c on ccm.cluster_id=c.cluster_id " +
- "group by c.cluster_name,type_name " +
+ "group by c.cluster_name, ccm.type_name " +
"having sum(selected) > 1")).andReturn(mockResultSet);
CheckDatabaseHelper checkDatabaseHelper = new CheckDatabaseHelper(mockDBDbAccessor, mockInjector, null);
@@ -201,8 +201,8 @@ public class CheckDatabaseHelperTest {
expect(mockStatement.executeQuery("select count(*) from hostcomponentstate")).andReturn(mockResultSet);
expect(mockStatement.executeQuery("select count(*) from hostcomponentdesiredstate")).andReturn(mockResultSet);
expect(mockStatement.executeQuery("select count(*) FROM hostcomponentstate hcs " +
- "JOIN hostcomponentdesiredstate hcds ON hcs.service_name = hcds.service_name AND " +
- "hcs.component_name = hcds.component_name AND hcs.host_id = hcds.host_id")).andReturn(mockResultSet);
+ "JOIN hostcomponentdesiredstate hcds ON hcs.service_name=hcds.service_name AND " +
+ "hcs.component_name=hcds.component_name AND hcs.host_id=hcds.host_id")).andReturn(mockResultSet);
CheckDatabaseHelper checkDatabaseHelper = new CheckDatabaseHelper(mockDBDbAccessor, mockInjector, null);
@@ -263,24 +263,26 @@ public class CheckDatabaseHelperTest {
expect(mockStatement.executeQuery("select c.cluster_name, service_name from clusterservices cs " +
"join clusters c on cs.cluster_id=c.cluster_id " +
"where service_name not in (select service_name from serviceconfig sc where sc.cluster_id=cs.cluster_id and sc.service_name=cs.service_name and sc.group_id is null)")).andReturn(mockResultSet);
- expect(mockStatement.executeQuery("select service_name from serviceconfig where service_config_id not in (select service_config_id from serviceconfigmapping) and group_id is null")).andReturn(mockResultSet);
+ expect(mockStatement.executeQuery("select c.cluster_name, sc.service_name, sc.version from serviceconfig sc " +
+ "join clusters c on sc.cluster_id=c.cluster_id " +
+ "where service_config_id not in (select service_config_id from serviceconfigmapping) and group_id is null")).andReturn(mockResultSet);
expect(mockStatement.executeQuery("select c.cluster_name, s.stack_name, s.stack_version from clusters c " +
"join stack s on c.desired_stack_id = s.stack_id")).andReturn(stackResultSet);
- expect(mockStatement.executeQuery("select c.cluster_name, cs.service_name, type_name, sc.version from clusterservices cs " +
+ expect(mockStatement.executeQuery("select c.cluster_name, cs.service_name, cc.type_name, sc.version from clusterservices cs " +
"join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id " +
"join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id " +
"join clusterconfig cc on scm.config_id=cc.config_id and sc.cluster_id=cc.cluster_id " +
"join clusters c on cc.cluster_id=c.cluster_id " +
"where sc.group_id is null " +
- "group by c.cluster_name, cs.service_name, type_name, sc.version")).andReturn(serviceConfigResultSet);
- expect(mockStatement.executeQuery("select c.cluster_name, cs.service_name,cc.type_name from clusterservices cs " +
+ "group by c.cluster_name, cs.service_name, cc.type_name, sc.version")).andReturn(serviceConfigResultSet);
+ expect(mockStatement.executeQuery("select c.cluster_name, cs.service_name, cc.type_name from clusterservices cs " +
"join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id " +
"join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id " +
"join clusterconfig cc on scm.config_id=cc.config_id and cc.cluster_id=sc.cluster_id " +
"join clusterconfigmapping ccm on cc.type_name=ccm.type_name and cc.version_tag=ccm.version_tag and cc.cluster_id=ccm.cluster_id " +
"join clusters c on ccm.cluster_id=c.cluster_id " +
"where sc.group_id is null and sc.service_config_id = (select max(service_config_id) from serviceconfig sc2 where sc2.service_name=sc.service_name and sc2.cluster_id=sc.cluster_id) " +
- "group by c.cluster_name,cs.service_name,cc.type_name " +
+ "group by c.cluster_name, cs.service_name, cc.type_name " +
"having sum(ccm.selected) < 1")).andReturn(mockResultSet);
CheckDatabaseHelper checkDatabaseHelper = new CheckDatabaseHelper(mockDBDbAccessor, mockInjector, null);
[12/21] ambari git commit: AMBARI-15076: HAWQ standby host name not
getting populated in warning msg (nalex via jaoki)
Posted by nc...@apache.org.
AMBARI-15076: HAWQ standby host name not getting populated in warning msg (nalex via jaoki)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1ba6722d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1ba6722d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1ba6722d
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 1ba6722d14f54910d73f4b4d8decbb9a3cb1c5d6
Parents: 2005627
Author: Jun Aoki <ja...@apache.org>
Authored: Fri Feb 19 14:16:20 2016 -0800
Committer: Jun Aoki <ja...@apache.org>
Committed: Fri Feb 19 14:16:20 2016 -0800
----------------------------------------------------------------------
.../admin/highAvailability/hawq/addStandby/step3_controller.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/1ba6722d/ambari-web/app/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller.js
index 513a519..fd28ad5 100644
--- a/ambari-web/app/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller.js
+++ b/ambari-web/app/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller.js
@@ -141,7 +141,7 @@ App.AddHawqStandbyWizardStep3Controller = Em.Controller.extend({
submit: function () {
if (!this.get('isSubmitDisabled')) {
dataDir = this.get('hawqProps').items[0].properties['hawq_master_directory'];
- hawqStandby = this.get('hawqProps').items[0].properties['hawq_standby_address_host']
+ hawqStandby = this.get('content.hawqHosts.newHawqStandby');
App.showConfirmationPopup(
function() {
App.get('router.mainAdminKerberosController').getKDCSessionState(function() {
[10/21] ambari git commit: AMBARI-15083: Add Stack Advisor
validations for hawq_global_rm_type property in HAWQ (bhuvnesh2703 via jaoki)
Posted by nc...@apache.org.
AMBARI-15083: Add Stack Advisor validations for hawq_global_rm_type property in HAWQ (bhuvnesh2703 via jaoki)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/32173ff1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/32173ff1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/32173ff1
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 32173ff17642b8cdca6f0fdd5318683b633bb681
Parents: dccacb9
Author: Jun Aoki <ja...@apache.org>
Authored: Fri Feb 19 13:37:08 2016 -0800
Committer: Jun Aoki <ja...@apache.org>
Committed: Fri Feb 19 13:37:08 2016 -0800
----------------------------------------------------------------------
.../stacks/HDP/2.3/services/stack_advisor.py | 32 +++++++-------
.../stacks/2.3/common/test_stack_advisor.py | 46 ++++++++++++++++++++
2 files changed, 62 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/32173ff1/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
index b354378..34e4cfa 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
@@ -943,31 +943,31 @@ class HDP23StackAdvisor(HDP22StackAdvisor):
"HAWQ Master or Standby Master cannot use the port 5432 when installed on the same host as the Ambari Server. Ambari Postgres DB uses the same port. Please choose a different value (e.g. 10432)")})
# 2. Check if any data directories are pointing to root dir '/'
- prop_name = 'hawq_master_directory'
- display_name = 'HAWQ Master directory'
- self.validateIfRootDir (properties, validationItems, prop_name, display_name)
-
- prop_name = 'hawq_master_temp_directory'
- display_name = 'HAWQ Master temp directory'
- self.validateIfRootDir (properties, validationItems, prop_name, display_name)
-
- prop_name = 'hawq_segment_directory'
- display_name = 'HAWQ Segment directory'
- self.validateIfRootDir (properties, validationItems, prop_name, display_name)
-
- prop_name = 'hawq_segment_temp_directory'
- display_name = 'HAWQ Segment temp directory'
- self.validateIfRootDir (properties, validationItems, prop_name, display_name)
+ directories = {
+ 'hawq_master_directory': 'HAWQ Master directory',
+ 'hawq_master_temp_directory': 'HAWQ Master temp directory',
+ 'hawq_segment_directory': 'HAWQ Segment directory',
+ 'hawq_segment_temp_directory': 'HAWQ Segment temp directory'
+ }
+ for property_name, display_name in directories.iteritems():
+ self.validateIfRootDir(properties, validationItems, property_name, display_name)
# 3. Check YARN RM address properties
+ YARN = "YARN"
servicesList = [service["StackServices"]["service_name"] for service in services["services"]]
- if "YARN" in servicesList and "yarn-site" in configurations:
+ if YARN in servicesList and "yarn-site" in configurations:
yarn_site = getSiteProperties(configurations, "yarn-site")
for hs_prop, ys_prop in self.getHAWQYARNPropertyMapping().items():
if hs_prop in hawq_site and ys_prop in yarn_site and hawq_site[hs_prop] != yarn_site[ys_prop]:
message = "Expected value: {0} (this property should have the same value as the property {1} in yarn-site)".format(yarn_site[ys_prop], ys_prop)
validationItems.append({"config-name": hs_prop, "item": self.getWarnItem(message)})
+ # 4. Check HAWQ Resource Manager type
+ HAWQ_GLOBAL_RM_TYPE = "hawq_global_rm_type"
+ if YARN not in servicesList and HAWQ_GLOBAL_RM_TYPE in hawq_site and hawq_site[HAWQ_GLOBAL_RM_TYPE].upper() == YARN:
+ message = "{0} must be set to none if YARN service is not installed".format(HAWQ_GLOBAL_RM_TYPE)
+ validationItems.append({"config-name": HAWQ_GLOBAL_RM_TYPE, "item": self.getErrorItem(message)})
+
return self.toConfigurationValidationProblems(validationItems, "hawq-site")
http://git-wip-us.apache.org/repos/asf/ambari/blob/32173ff1/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
index 545a2b5..03ae6cc 100644
--- a/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
+++ b/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
@@ -1630,6 +1630,7 @@ class TestHDP23StackAdvisor(TestCase):
def test_validateHAWQConfigurations(self):
services = self.load_json("services-hawq-3-hosts.json")
# setup default configuration values
+ # Test hawq_rm_yarn_address and hawq_rm_scheduler_address are set correctly
configurations = services["configurations"]
configurations["hawq-site"] = {"properties": {"hawq_rm_yarn_address": "localhost:8032",
"hawq_rm_yarn_scheduler_address": "localhost:8030"}}
@@ -1664,3 +1665,48 @@ class TestHDP23StackAdvisor(TestCase):
self.assertEqual(len(problems), 2)
self.assertEqual(problems_dict, expected_warnings)
+ # Test hawq_global_rm_type validation
+ services = {
+ "services" : [
+ {
+ "StackServices" : {
+ "service_name" : "HAWQ"
+ },
+ "components": []
+ } ],
+ "configurations":
+ {
+ "hawq-site": {
+ "properties": {
+ "hawq_global_rm_type": "yarn"
+ }
+ }
+ }
+ }
+ properties = services["configurations"]["hawq-site"]["properties"]
+
+ # case 1: hawq_global_rm_type is set as yarn, but YARN service is not installed. Validation error expected.
+ """
+ Validation error expected is as below:
+ [ {
+ "config-type": "hawq-site",
+ "message": "hawq_global_rm_type must be set to none if YARN service is not installed",
+ "type": "configuration",
+ "config-name": "hawq_global_rm_type",
+ "level": "ERROR"
+ } ]
+ """
+ problems = self.stackAdvisor.validateHAWQConfigurations(properties, defaults, services["configurations"], services, hosts)
+ self.assertEqual(len(problems), 1)
+ self.assertEqual(problems[0]["config-type"], "hawq-site")
+ self.assertEqual(problems[0]["message"], "hawq_global_rm_type must be set to none if YARN service is not installed")
+ self.assertEqual(problems[0]["type"], "configuration")
+ self.assertEqual(problems[0]["config-name"], "hawq_global_rm_type")
+ self.assertEqual(problems[0]["level"], "ERROR")
+
+
+ # case 2: hawq_global_rm_type is set as yarn, and YARN service is installed. No validation errors expected.
+ services["services"].append({"StackServices" : {"service_name" : "YARN"}, "components":[]})
+
+ problems = self.stackAdvisor.validateHAWQConfigurations(properties, defaults, services["configurations"], services, hosts)
+ self.assertEqual(len(problems), 0)
[08/21] ambari git commit: AMBARI-15060: Ambari should show no. of
HAWQ segments live on main dashboard (mithmatt via jaoki)
Posted by nc...@apache.org.
AMBARI-15060: Ambari should show no. of HAWQ segments live on main dashboard (mithmatt via jaoki)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/82d94401
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/82d94401
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/82d94401
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 82d944017eb90c380e374e6f7aeddab6004c6a84
Parents: 997749f
Author: Jun Aoki <ja...@apache.org>
Authored: Fri Feb 19 12:05:40 2016 -0800
Committer: Jun Aoki <ja...@apache.org>
Committed: Fri Feb 19 12:05:40 2016 -0800
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 1 +
.../app/mappers/components_state_mapper.js | 5 +
ambari-web/app/messages.js | 5 +
ambari-web/app/views.js | 1 +
ambari-web/app/views/main/dashboard/widgets.js | 19 +-
.../main/dashboard/widgets/hawqsegment_live.js | 190 +++++++++++++++++++
.../dashboard/widgets/hawqsegment_live_test.js | 69 +++++++
7 files changed, 286 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/82d94401/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 06c4c31..4edcc5e 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -239,6 +239,7 @@ var files = [
'test/views/main/dashboard/widgets/uptime_text_widget_test',
'test/views/main/dashboard/widgets/node_managers_live_test',
'test/views/main/dashboard/widgets/datanode_live_test',
+ 'test/views/main/dashboard/widgets/hawqsegment_live_test',
'test/views/main/dashboard/widgets/hbase_average_load_test',
'test/views/main/dashboard/widgets/hbase_regions_in_transition_test',
'test/views/main/dashboard/widgets/namenode_rpc_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/82d94401/ambari-web/app/mappers/components_state_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/components_state_mapper.js b/ambari-web/app/mappers/components_state_mapper.js
index 0f2b627..ac3e1b5 100644
--- a/ambari-web/app/mappers/components_state_mapper.js
+++ b/ambari-web/app/mappers/components_state_mapper.js
@@ -59,6 +59,11 @@ App.componentsStateMapper = App.QuickDataMapper.create({
node_managers_installed: 'INSTALLED_PATH',
node_managers_total: 'TOTAL_PATH'
},
+ 'HAWQSEGMENT': {
+ hawq_segments_started: 'STARTED_PATH',
+ hawq_segments_installed: 'INSTALLED_PATH',
+ hawq_segments_total: 'TOTAL_PATH'
+ },
'HBASE_REGIONSERVER': {
region_servers_started: 'STARTED_PATH',
region_servers_installed: 'INSTALLED_PATH',
http://git-wip-us.apache.org/repos/asf/ambari/blob/82d94401/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 1b08248..2622043 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2527,6 +2527,7 @@ Em.I18n.translations = {
'dashboard.widgets.YARNLinks': 'YARN Links',
'dashboard.widgets.error.invalid': 'Invalid! Enter a number between 0 - {0}',
'dashboard.widgets.error.smaller': 'Threshold 1 should be smaller than threshold 2!',
+ 'dashboard.widgets.HawqSegmentUp': 'HAWQ Segments Live',
'dashboard': {
'widgets': {
@@ -2631,6 +2632,10 @@ Em.I18n.translations = {
'dashboard.services.hbase.masterStarted':'Master Started',
'dashboard.services.hbase.masterActivated':'Master Activated',
+ 'dashboard.services.hawq.segments.started':'started',
+ 'dashboard.services.hawq.segments.stopped':'stopped',
+ 'dashboard.services.hawq.segments.total':'in total',
+
'dashboard.services.hive.clients':'Hive Clients',
'dashboard.services.hive.client':'Hive Client',
'dashboard.services.hive.metastore':'Hive Metastore',
http://git-wip-us.apache.org/repos/asf/ambari/blob/82d94401/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index 2440086..0d3e49b 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -219,6 +219,7 @@ require('views/main/dashboard/widgets/namenode_heap');
require('views/main/dashboard/widgets/namenode_cpu');
require('views/main/dashboard/widgets/hdfs_capacity');
require('views/main/dashboard/widgets/datanode_live');
+require('views/main/dashboard/widgets/hawqsegment_live');
require('views/main/dashboard/widgets/namenode_rpc');
require('views/main/dashboard/widgets/metrics_memory');
require('views/main/dashboard/widgets/metrics_network');
http://git-wip-us.apache.org/repos/asf/ambari/blob/82d94401/ambari-web/app/views/main/dashboard/widgets.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets.js b/ambari-web/app/views/main/dashboard/widgets.js
index a2fb281..8a86af6 100644
--- a/ambari-web/app/views/main/dashboard/widgets.js
+++ b/ambari-web/app/views/main/dashboard/widgets.js
@@ -128,7 +128,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
'13', '12', '14', '16', //hbase
'17', '18', '19', '20', '23', // all yarn
'21', // storm
- '22' // flume
+ '22', // flume
+ '24' // hawq
]; // all in order
var hiddenFull = [
['15', 'Region In Transition']
@@ -173,6 +174,12 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
visibleFull = visibleFull.without(item);
}, this);
}
+ if (this.get('hawq_model') == null) {
+ var hawq = ['24'];
+ hawq.forEach(function (item) {
+ visibleFull = visibleFull.without(item);
+ }, this);
+ }
var obj = this.get('initPrefObject');
obj.set('visible', visibleFull);
obj.set('hidden', hiddenFull);
@@ -192,6 +199,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
flume_model: null,
+ hawq_model: null,
+
/**
* List of visible widgets
* @type {Ember.Enumerable}
@@ -383,7 +392,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
hbase_model: ['12', '13', '14', '15', '16'],
yarn_model: ['17', '18', '19', '20', '23'],
storm_model: ['21'],
- flume_model: ['22']
+ flume_model: ['22'],
+ hawq_model: ['24']
};
// check each service, find out the newly added service and already deleted service
@@ -450,7 +460,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
'20': App.YARNMemoryPieChartView,
'21': App.SuperVisorUpView,
'22': App.FlumeAgentUpView,
- '23': App.YARNLinksView
+ '23': App.YARNLinksView,
+ '24': App.HawqSegmentUpView
}, id);
},
@@ -467,7 +478,7 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
visible: [],
hidden: [],
threshold: {1: [80, 90], 2: [85, 95], 3: [90, 95], 4: [80, 90], 5: [1000, 3000], 6: [], 7: [], 8: [], 9: [], 10: [], 11: [], 12: [], 13: [70, 90], 14: [150, 250], 15: [3, 10], 16: [],
- 17: [70, 90], 18: [], 19: [50, 75], 20: [50, 75], 21: [85, 95], 22: [85, 95], 23: []} // id:[thresh1, thresh2]
+ 17: [70, 90], 18: [], 19: [50, 75], 20: [50, 75], 21: [85, 95], 22: [85, 95], 23: [], 24: [80, 90]} // id:[thresh1, thresh2]
}),
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/82d94401/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js b/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js
new file mode 100644
index 0000000..e8d0656
--- /dev/null
+++ b/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js
@@ -0,0 +1,190 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+
+App.HawqSegmentUpView = App.TextDashboardWidgetView.extend({
+
+ title: Em.I18n.t('dashboard.widgets.HawqSegmentUp'),
+ id: '24',
+
+ isPieChart: false,
+ isText: true,
+ isProgressBar: false,
+ model_type: 'hawq',
+
+ hiddenInfo: function () {
+ var result = [];
+ result.pushObject(this.get('hawqSegmentsStarted') + ' ' + Em.I18n.t('dashboard.services.hawq.segments.started'));
+ result.pushObject(this.get('hawqSegmentsInstalled') + ' ' + Em.I18n.t('dashboard.services.hawq.segments.stopped'));
+ result.pushObject(this.get('hawqSegmentsTotal')+ ' ' + Em.I18n.t('dashboard.services.hawq.segments.total'));
+ return result;
+ }.property('hawqSegmentsStarted', 'hawqSegmentsInstalled', 'hawqSegmentsTotal'),
+ hiddenInfoClass: "hidden-info-three-line",
+
+ thresh1: 40,
+ thresh2: 70,
+ maxValue: 100,
+
+ hawqSegmentsStarted: function () {
+ if (Em.isNone(this.get('model.hawqSegmentsStarted'))) {
+ return Em.I18n.t('services.service.summary.notAvailable');
+ }
+ return this.get('model.hawqSegmentsStarted');
+ }.property('model.hawqSegmentsStarted'),
+
+ hawqSegmentsInstalled: function () {
+ if (Em.isNone(this.get('model.hawqSegmentsInstalled'))) {
+ return Em.I18n.t('services.service.summary.notAvailable');
+ }
+ return this.get('model.hawqSegmentsInstalled');
+ }.property('model.hawqSegmentsInstalled'),
+
+ hawqSegmentsTotal: function () {
+ if (Em.isNone(this.get('model.hawqSegmentsTotal'))) {
+ return Em.I18n.t('services.service.summary.notAvailable');
+ }
+ return this.get('model.hawqSegmentsTotal');
+ }.property('model.hawqSegmentsTotal'),
+
+ data: function () {
+ if (Em.isNone(this.get('model.hawqSegmentsStarted')) || Em.isNone(this.get('model.hawqSegmentsTotal'))) {
+ return null;
+ } else {
+ return ((this.get('hawqSegmentsStarted') / this.get('model.hawqSegmentsTotal')).toFixed(2)) * 100;
+ }
+ }.property('model.hawqSegmentsTotal', 'hawqSegmentsStarted'),
+
+ content: function () {
+ if (Em.isNone(this.get('model.hawqSegmentsStarted')) || Em.isNone(this.get('model.hawqSegmentsTotal'))) {
+ return Em.I18n.t('services.service.summary.notAvailable');
+ } else {
+ return this.get('hawqSegmentsStarted') + "/" + this.get('model.hawqSegmentsTotal');
+ }
+ }.property('model.hawqSegmentsTotal', 'hawqSegmentsStarted'),
+
+ editWidget: function (event) {
+ var parent = this;
+ var max_tmp = parseFloat(parent.get('maxValue'));
+ var configObj = Ember.Object.create({
+ thresh1: parent.get('thresh1') + '',
+ thresh2: parent.get('thresh2') + '',
+ hintInfo: Em.I18n.t('dashboard.widgets.hintInfo.hint1').format(max_tmp),
+ isThresh1Error: false,
+ isThresh2Error: false,
+ errorMessage1: "",
+ errorMessage2: "",
+ maxValue: max_tmp,
+ observeNewThresholdValue: function () {
+ var thresh1 = this.get('thresh1');
+ var thresh2 = this.get('thresh2');
+ if (thresh1.trim() != "") {
+ if (isNaN(thresh1) || thresh1 > max_tmp || thresh1 < 0){
+ this.set('isThresh1Error', true);
+ this.set('errorMessage1', 'Invalid! Enter a number between 0 - ' + max_tmp);
+ } else if ( this.get('isThresh2Error') === false && parseFloat(thresh2)<= parseFloat(thresh1)) {
+ this.set('isThresh1Error', true);
+ this.set('errorMessage1', 'Threshold 1 should be smaller than threshold 2 !');
+ } else {
+ this.set('isThresh1Error', false);
+ this.set('errorMessage1', '');
+ }
+ } else {
+ this.set('isThresh1Error', true);
+ this.set('errorMessage1', 'This is required');
+ }
+
+ if (thresh2.trim() != "") {
+ if (isNaN(thresh2) || thresh2 > max_tmp || thresh2 < 0) {
+ this.set('isThresh2Error', true);
+ this.set('errorMessage2', 'Invalid! Enter a number between 0 - ' + max_tmp);
+ } else {
+ this.set('isThresh2Error', false);
+ this.set('errorMessage2', '');
+ }
+ } else {
+ this.set('isThresh2Error', true);
+ this.set('errorMessage2', 'This is required');
+ }
+
+ // update the slider handles and color
+ if (this.get('isThresh1Error') === false && this.get('isThresh2Error') === false) {
+ $("#slider-range").slider('values', 0 , parseFloat(thresh1));
+ $("#slider-range").slider('values', 1 , parseFloat(thresh2));
+ }
+ }.observes('thresh1', 'thresh2')
+
+ });
+
+ var browserVerion = this.getInternetExplorerVersion();
+ App.ModalPopup.show({
+ header: Em.I18n.t('dashboard.widgets.popupHeader'),
+ classNames: [ 'sixty-percent-width-modal-edit-widget'],
+ bodyClass: Ember.View.extend({
+ templateName: require('templates/main/dashboard/edit_widget_popup'),
+ configPropertyObj: configObj
+ }),
+ primary: Em.I18n.t('common.apply'),
+ onPrimary: function () {
+ configObj.observeNewThresholdValue();
+ if (!configObj.isThresh1Error && !configObj.isThresh2Error) {
+ parent.set('thresh1', parseFloat(configObj.get('thresh1')) );
+ parent.set('thresh2', parseFloat(configObj.get('thresh2')) );
+ if (!App.get('testMode')) {
+ var big_parent = parent.get('parentView');
+ big_parent.getUserPref(big_parent.get('persistKey'));
+ var oldValue = big_parent.get('currentPrefObject');
+ oldValue.threshold[parseInt(parent.id)] = [configObj.get('thresh1'), configObj.get('thresh2')];
+ big_parent.postUserPref(big_parent.get('persistKey'),oldValue);
+ }
+ this.hide();
+ }
+ },
+
+ didInsertElement: function () {
+ var handlers = [configObj.get('thresh1'), configObj.get('thresh2')];
+ var colors = [App.healthStatusRed, App.healthStatusOrange, App.healthStatusGreen]; //color red, orange, green
+
+ if (browserVerion == -1 || browserVerion > 9) {
+ configObj.set('isIE9', false);
+ configObj.set('isGreenOrangeRed', false);
+ $("#slider-range").slider({
+ range: true,
+ min: 0,
+ max: max_tmp,
+ values: handlers,
+ create: function (event, ui) {
+ parent.updateColors(handlers, colors);
+ },
+ slide: function (event, ui) {
+ parent.updateColors(ui.values, colors);
+ configObj.set('thresh1', ui.values[0] + '');
+ configObj.set('thresh2', ui.values[1] + '');
+ },
+ change: function (event, ui) {
+ parent.updateColors(ui.values, colors);
+ }
+ });
+ } else {
+ configObj.set('isIE9', true);
+ configObj.set('isGreenOrangeRed', false);
+ }
+ }
+ });
+ }
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/82d94401/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js b/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js
new file mode 100644
index 0000000..eb8a505
--- /dev/null
+++ b/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js
@@ -0,0 +1,69 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+
+require('views/main/dashboard/widget');
+require('views/main/dashboard/widgets/text_widget');
+require('views/main/dashboard/widgets/hawqsegment_live');
+
+describe('App.HawqSegmentUpView', function() {
+
+ var tests = [
+ {
+ data: 100,
+ e: {
+ isRed: false,
+ isOrange: false,
+ isGreen: true
+ }
+ },
+ {
+ data: 0,
+ e: {
+ isRed: true,
+ isOrange: false,
+ isGreen: false
+ }
+ },
+ {
+ data: 50,
+ e: {
+ isRed: false,
+ isOrange: true,
+ isGreen: false
+ }
+ }
+ ];
+
+ tests.forEach(function(test) {
+ describe('', function() {
+ var hawqSegmentUpView = App.HawqSegmentUpView.create({model_type:null, data: test.data, content: test.data.toString()});
+ it('shows red', function() {
+ expect(hawqSegmentUpView.get('isRed')).to.equal(test.e.isRed);
+ });
+ it('shows orange', function() {
+ expect(hawqSegmentUpView.get('isOrange')).to.equal(test.e.isOrange);
+ });
+ it('shows green', function() {
+ expect(hawqSegmentUpView.get('isGreen')).to.equal(test.e.isGreen);
+ });
+ });
+ });
+
+});
[03/21] ambari git commit: AMBARI-15077: Auto-start services -
Backend API and DB changes for component auto start.
Posted by nc...@apache.org.
AMBARI-15077: Auto-start services - Backend API and DB changes for component auto start.
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fca04c30
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fca04c30
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fca04c30
Branch: refs/heads/branch-dev-patch-upgrade
Commit: fca04c305c472db7a11d9b121b3de38a4f176f84
Parents: a0c4dcc
Author: Nahappan Somasundaram <ns...@hortonworks.com>
Authored: Thu Feb 18 14:22:21 2016 -0800
Committer: Nahappan Somasundaram <ns...@hortonworks.com>
Committed: Fri Feb 19 07:55:33 2016 -0800
----------------------------------------------------------------------
.../controller/ServiceComponentRequest.java | 35 +++++++--
.../controller/ServiceComponentResponse.java | 22 +++++-
.../internal/ComponentResourceProvider.java | 38 ++++++++++
.../ServiceComponentDesiredStateEntity.java | 11 +++
.../ambari/server/state/ServiceComponent.java | 14 ++++
.../server/state/ServiceComponentImpl.java | 80 +++++++++++++++++---
.../main/resources/Ambari-DDL-Derby-CREATE.sql | 1 +
.../main/resources/Ambari-DDL-MySQL-CREATE.sql | 1 +
.../main/resources/Ambari-DDL-Oracle-CREATE.sql | 1 +
.../resources/Ambari-DDL-Postgres-CREATE.sql | 1 +
.../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql | 1 +
.../resources/Ambari-DDL-SQLAnywhere-CREATE.sql | 1 +
.../resources/Ambari-DDL-SQLServer-CREATE.sql | 1 +
.../src/main/resources/properties.json | 1 +
.../AmbariManagementControllerTest.java | 3 +
.../internal/ComponentResourceProviderTest.java | 37 +++++----
16 files changed, 218 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java
index 78b9897..ba0b84f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentRequest.java
@@ -31,21 +31,28 @@ public class ServiceComponentRequest {
private String componentCategory;
+ private String recoveryEnabled; // CREATE/UPDATE
+
public ServiceComponentRequest(String clusterName, String serviceName,
String componentName, String desiredState) {
- this.clusterName = clusterName;
- this.serviceName = serviceName;
- this.componentName = componentName;
- this.desiredState = desiredState;
+ this(clusterName, serviceName, componentName, desiredState, null, null);
+ }
+
+ public ServiceComponentRequest(String clusterName, String serviceName,
+ String componentName, String desiredState,
+ String recoveryEnabled) {
+ this(clusterName, serviceName, componentName, desiredState, recoveryEnabled, null);
}
public ServiceComponentRequest(String clusterName,
String serviceName, String componentName,
- String desiredState, String componentCategory) {
+ String desiredState, String recoveryEnabled,
+ String componentCategory) {
this.clusterName = clusterName;
this.serviceName = serviceName;
this.componentName = componentName;
this.desiredState = desiredState;
+ this.recoveryEnabled = recoveryEnabled;
this.componentCategory = componentCategory;
}
@@ -105,6 +112,20 @@ public class ServiceComponentRequest {
this.clusterName = clusterName;
}
+ /**
+ * @return recoveryEnabled
+ */
+ public String getRecoveryEnabled() {
+ return recoveryEnabled;
+ }
+
+ /**
+ * @param recoveryEnabled the recoveryEnabled value to set.
+ */
+ public void setRecoveryEnabled(String recoveryEnabled) {
+ this.recoveryEnabled = recoveryEnabled;
+ }
+
public String getComponentCategory() {
return componentCategory;
}
@@ -115,7 +136,7 @@ public class ServiceComponentRequest {
@Override
public String toString() {
- return String.format("[clusterName=%s, serviceName=%s, componentName=%s, desiredState=%s, componentCategory=%s]",
- clusterName, serviceName, clusterName, desiredState, componentCategory);
+ return String.format("[clusterName=%s, serviceName=%s, componentName=%s, desiredState=%s, recoveryEnabled=%s, componentCategory=%s]",
+ clusterName, serviceName, clusterName, desiredState, recoveryEnabled, componentCategory);
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
index f7dd301..381b114 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
@@ -41,6 +41,8 @@ public class ServiceComponentResponse {
private int installedCount;
+ private boolean recoveryEnabled;
+
public ServiceComponentResponse(Long clusterId, String clusterName,
String serviceName,
String componentName,
@@ -48,7 +50,8 @@ public class ServiceComponentResponse {
String desiredState,
int totalCount,
int startedCount,
- int installedCount) {
+ int installedCount,
+ boolean recoveryEnabled) {
super();
this.clusterId = clusterId;
this.clusterName = clusterName;
@@ -59,6 +62,7 @@ public class ServiceComponentResponse {
this.totalCount = totalCount;
this.startedCount = startedCount;
this.installedCount = installedCount;
+ this.recoveryEnabled = recoveryEnabled;
}
/**
@@ -211,6 +215,22 @@ public class ServiceComponentResponse {
this.totalCount = totalCount;
}
+ /**
+ * Get a true or false value indicating if the service component is auto start enabled
+ * @return true or false
+ */
+ public boolean isRecoveryEnabled() {
+ return recoveryEnabled;
+ }
+
+ /**
+ * Set a true or false value indicating whether the service component is auto start enabled
+ * @param recoveryEnabled
+ */
+ public void setRecoveryEnabled(boolean recoveryEnabled) {
+ this.recoveryEnabled = recoveryEnabled;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
index 3ad6e64..b339adf 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
@@ -84,6 +84,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
protected static final String COMPONENT_TOTAL_COUNT_PROPERTY_ID = "ServiceComponentInfo/total_count";
protected static final String COMPONENT_STARTED_COUNT_PROPERTY_ID = "ServiceComponentInfo/started_count";
protected static final String COMPONENT_INSTALLED_COUNT_PROPERTY_ID = "ServiceComponentInfo/installed_count";
+ protected static final String COMPONENT_RECOVERY_ENABLED_ID = "ServiceComponentInfo/recovery_enabled";
private static final String TRUE = "true";
@@ -178,6 +179,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
setResourceProperty(resource, COMPONENT_TOTAL_COUNT_PROPERTY_ID, response.getTotalCount(), requestedIds);
setResourceProperty(resource, COMPONENT_STARTED_COUNT_PROPERTY_ID, response.getStartedCount(), requestedIds);
setResourceProperty(resource, COMPONENT_INSTALLED_COUNT_PROPERTY_ID, response.getInstalledCount(), requestedIds);
+ setResourceProperty(resource, COMPONENT_RECOVERY_ENABLED_ID, String.valueOf(response.isRecoveryEnabled()), requestedIds);
resources.add(resource);
}
@@ -251,6 +253,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
(String) properties.get(COMPONENT_SERVICE_NAME_PROPERTY_ID),
(String) properties.get(COMPONENT_COMPONENT_NAME_PROPERTY_ID),
(String) properties.get(COMPONENT_STATE_PROPERTY_ID),
+ (String) properties.get(COMPONENT_RECOVERY_ENABLED_ID),
(String) properties.get(COMPONENT_CATEGORY_PROPERTY_ID));
}
@@ -463,6 +466,9 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
Map<String, Map<String, Set<String>>> componentNames = new HashMap<>();
Set<State> seenNewStates = new HashSet<>();
+ Collection<ServiceComponent> recoveryEnabledComponents = new ArrayList<>();
+ Collection<ServiceComponent> recoveryDisabledComponents = new ArrayList<>();
+
// Determine operation level
Resource.Type reqOpLvl;
if (requestProperties.containsKey(RequestOperationLevel.OPERATION_LEVEL_ID)) {
@@ -513,6 +519,20 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
continue;
}
+ // Gather the components affected by the change in
+ // auto start state
+ if (!StringUtils.isEmpty(request.getRecoveryEnabled())) {
+ boolean newRecoveryEnabled = Boolean.parseBoolean(request.getRecoveryEnabled());
+ boolean oldRecoveryEnabled = sc.isRecoveryEnabled();
+ if (newRecoveryEnabled != oldRecoveryEnabled) {
+ if (newRecoveryEnabled) {
+ recoveryEnabledComponents.add(sc);
+ } else {
+ recoveryDisabledComponents.add(sc);
+ }
+ }
+ }
+
if (newState == null) {
debug("Nothing to do for new updateServiceComponent request, request ={}, newDesiredState=null" + request);
continue;
@@ -539,9 +559,11 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterId=" + cluster.getClusterId()
+ ", serviceName=" + sc.getServiceName()
+ ", componentName=" + sc.getName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", currentDesiredState=" + oldScState
+ ", newDesiredState=" + newState);
}
+
if (!changedComps.containsKey(newState)) {
changedComps.put(newState, new ArrayList<ServiceComponent>());
}
@@ -549,6 +571,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterName=" + clusterName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", currentDesiredState=" + oldScState
+ ", newDesiredState=" + newState);
@@ -562,6 +585,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterName=" + clusterName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", hostname=" + sch.getHostName()
+ ", currentState=" + oldSchState
+ ", newDesiredState=" + newState);
@@ -574,6 +598,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterName=" + clusterName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", hostname=" + sch.getHostName()
+ ", currentState=" + oldSchState
+ ", newDesiredState=" + newState);
@@ -587,6 +612,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterName=" + clusterName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", hostname=" + sch.getHostName());
continue;
@@ -600,6 +626,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterId=" + cluster.getClusterId()
+ ", serviceName=" + sch.getServiceName()
+ ", componentName=" + sch.getServiceComponentName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", hostname=" + sch.getHostName()
+ ", currentState=" + oldSchState
+ ", newDesiredState=" + newState);
@@ -615,6 +642,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
+ ", clusterName=" + clusterName
+ ", serviceName=" + serviceName
+ ", componentName=" + sc.getName()
+ + ", recoveryEnabled=" + sc.isRecoveryEnabled()
+ ", hostname=" + sch.getHostName()
+ ", currentState=" + oldSchState
+ ", newDesiredState=" + newState);
@@ -628,6 +656,16 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
// TODO additional validation?
+ // Validations completed. Update the affected service components now.
+
+ for (ServiceComponent sc : recoveryEnabledComponents) {
+ sc.setRecoveryEnabled(true);
+ }
+
+ for (ServiceComponent sc : recoveryDisabledComponents) {
+ sc.setRecoveryEnabled(false);
+ }
+
Cluster cluster = clusters.getCluster(clusterNames.iterator().next());
return getManagementController().createAndPersistStages(cluster, requestProperties, null, null, changedComps, changedScHosts,
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
index bda2543..630eef2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
@@ -55,6 +55,9 @@ public class ServiceComponentDesiredStateEntity {
@Enumerated(EnumType.STRING)
private State desiredState = State.INIT;
+ @Column(name = "recovery_enabled", nullable = false, insertable = true, updatable = true)
+ private Integer recoveryEnabled = 0;
+
/**
* Unidirectional one-to-one association to {@link StackEntity}
*/
@@ -112,6 +115,14 @@ public class ServiceComponentDesiredStateEntity {
this.desiredStack = desiredStack;
}
+ public boolean isRecoveryEnabled() {
+ return recoveryEnabled != 0;
+ }
+
+ public void setRecoveryEnabled(boolean recoveryEnabled) {
+ this.recoveryEnabled = (recoveryEnabled == false) ? 0 : 1;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
index 7803045..dcb7cf6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
@@ -28,6 +28,20 @@ public interface ServiceComponent {
String getName();
+ /**
+ * Get a true or false value specifying
+ * if auto start was enabled for this component.
+ * @return true or false
+ */
+ boolean isRecoveryEnabled();
+
+ /**
+ * Set a true or false value specifying if this
+ * component is to be enabled for auto start or not.
+ * @param recoveryEnabled - true or false
+ */
+ void setRecoveryEnabled(boolean recoveryEnabled);
+
String getServiceName();
long getClusterId();
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
index 7e1dd1d..7b866a9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
@@ -95,6 +95,7 @@ public class ServiceComponentImpl implements ServiceComponent {
desiredStateEntity.setDesiredState(State.INIT);
desiredStateEntity.setServiceName(service.getName());
desiredStateEntity.setClusterId(service.getClusterId());
+ desiredStateEntity.setRecoveryEnabled(false);
desiredStateEntityPK = getDesiredStateEntityPK(desiredStateEntity);
setDesiredStackVersion(service.getDesiredStackVersion());
@@ -190,6 +191,55 @@ public class ServiceComponentImpl implements ServiceComponent {
return null;
}
+ /**
+ * Get the recoveryEnabled value.
+ *
+ * @return true or false
+ */
+ @Override
+ public boolean isRecoveryEnabled() {
+ ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+ if (desiredStateEntity != null) {
+ return desiredStateEntity.isRecoveryEnabled();
+ } else {
+ LOG.warn("Trying to fetch a member from an entity object that may " +
+ "have been previously deleted, serviceName = " + service.getName() + ", " +
+ "componentName = " + componentName);
+ }
+ return false;
+ }
+
+ /**
+ * Set the recoveryEnabled field in the entity object.
+ *
+ * @param recoveryEnabled - true or false
+ */
+ @Override
+ public void setRecoveryEnabled(boolean recoveryEnabled) {
+ readWriteLock.writeLock().lock();
+ try {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Setting RecoveryEnabled of Component" + ", clusterName="
+ + service.getCluster().getClusterName() + ", clusterId="
+ + service.getCluster().getClusterId() + ", serviceName="
+ + service.getName() + ", componentName=" + getName()
+ + ", oldRecoveryEnabled=" + isRecoveryEnabled() + ", newRecoveryEnabled="
+ + recoveryEnabled);
+ }
+ ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+ if (desiredStateEntity != null) {
+ desiredStateEntity.setRecoveryEnabled(recoveryEnabled);
+ saveIfPersisted();
+ } else {
+ LOG.warn("Setting a member on an entity object that may have been " +
+ "previously deleted, serviceName = " + service.getName());
+ }
+
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ }
+
@Override
public String getServiceName() {
return service.getName();
@@ -256,7 +306,8 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterId=" + service.getCluster().getClusterId()
+ ", serviceName=" + service.getName()
+ ", serviceComponentName=" + getName()
- + ", hostname=" + hostComponent.getHostName());
+ + ", hostname=" + hostComponent.getHostName()
+ + ", recoveryEnabled=" + isRecoveryEnabled());
}
if (hostComponents.containsKey(hostComponent.getHostName())) {
throw new AmbariException("Cannot add duplicate ServiceComponentHost"
@@ -264,7 +315,8 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterId=" + service.getCluster().getClusterId()
+ ", serviceName=" + service.getName()
+ ", serviceComponentName=" + getName()
- + ", hostname=" + hostComponent.getHostName());
+ + ", hostname=" + hostComponent.getHostName()
+ + ", recoveryEnabled=" + isRecoveryEnabled());
}
// FIXME need a better approach of caching components by host
ClusterImpl clusterImpl = (ClusterImpl) service.getCluster();
@@ -292,6 +344,7 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterId=" + service.getCluster().getClusterId()
+ ", serviceName=" + service.getName()
+ ", serviceComponentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", hostname=" + hostName);
}
if (hostComponents.containsKey(hostName)) {
@@ -300,6 +353,7 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterId=" + service.getCluster().getClusterId()
+ ", serviceName=" + service.getName()
+ ", serviceComponentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", hostname=" + hostName);
}
ServiceComponentHost hostComponent = serviceComponentHostFactory.createNew(this, hostName);
@@ -363,11 +417,11 @@ public class ServiceComponentImpl implements ServiceComponent {
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Setting DesiredState of Service" + ", clusterName="
- + service.getCluster().getClusterName() + ", clusterId="
- + service.getCluster().getClusterId() + ", serviceName="
- + service.getName() + ", serviceComponentName=" + getName()
- + ", oldDesiredState=" + getDesiredState() + ", newDesiredState="
- + state);
+ + service.getCluster().getClusterName() + ", clusterId="
+ + service.getCluster().getClusterId() + ", serviceName="
+ + service.getName() + ", serviceComponentName=" + getName()
+ + ", oldDesiredState=" + getDesiredState() + ", newDesiredState="
+ + state);
}
ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
if (desiredStateEntity != null) {
@@ -437,7 +491,8 @@ public class ServiceComponentImpl implements ServiceComponent {
ServiceComponentResponse r = new ServiceComponentResponse(getClusterId(),
cluster.getClusterName(), service.getName(), getName(),
getDesiredStackVersion().getStackId(), getDesiredState().toString(),
- getTotalCount(), getStartedCount(), getInstalledCount());
+ getTotalCount(), getStartedCount(), getInstalledCount(),
+ isRecoveryEnabled());
return r;
} finally {
readWriteLock.readLock().unlock();
@@ -449,11 +504,13 @@ public class ServiceComponentImpl implements ServiceComponent {
return service.getCluster().getClusterName();
}
+
@Override
public void debugDump(StringBuilder sb) {
readWriteLock.readLock().lock();
try {
sb.append("ServiceComponent={ serviceComponentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", clusterName=" + service.getCluster().getClusterName()
+ ", clusterId=" + service.getCluster().getClusterId()
+ ", serviceName=" + service.getName() + ", desiredStackVersion="
@@ -603,6 +660,7 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterName=" + getClusterName()
+ ", serviceName=" + getServiceName()
+ ", componentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", hostname=" + sch.getHostName());
return false;
}
@@ -626,7 +684,8 @@ public class ServiceComponentImpl implements ServiceComponent {
LOG.info("Deleting all servicecomponenthosts for component"
+ ", clusterName=" + getClusterName()
+ ", serviceName=" + getServiceName()
- + ", componentName=" + getName());
+ + ", componentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled());
for (ServiceComponentHost sch : hostComponents.values()) {
if (!sch.canBeRemoved()) {
throw new AmbariException("Found non removable hostcomponent "
@@ -635,6 +694,7 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterName=" + getClusterName()
+ ", serviceName=" + getServiceName()
+ ", componentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", hostname=" + sch.getHostName());
}
}
@@ -663,12 +723,14 @@ public class ServiceComponentImpl implements ServiceComponent {
+ ", clusterName=" + getClusterName()
+ ", serviceName=" + getServiceName()
+ ", componentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", hostname=" + sch.getHostName());
if (!sch.canBeRemoved()) {
throw new AmbariException("Could not delete hostcomponent from cluster"
+ ", clusterName=" + getClusterName()
+ ", serviceName=" + getServiceName()
+ ", componentName=" + getName()
+ + ", recoveryEnabled=" + isRecoveryEnabled()
+ ", hostname=" + sch.getHostName());
}
sch.delete();
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
index 8aee031..6d63a90 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@ -176,6 +176,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
PRIMARY KEY (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index 4940e9d..e395902 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -177,6 +177,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(100) NOT NULL,
+ recovery_enabled TINYINT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index e43a7fc..0f957e6 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -167,6 +167,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id NUMBER(19) NOT NULL,
desired_state VARCHAR2(255) NOT NULL,
service_name VARCHAR2(255) NOT NULL,
+ recovery_enabled NUMBER(1) DEFAULT 0 NOT NULL,
PRIMARY KEY (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index 848d9e0..7daf4ae 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -176,6 +176,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
PRIMARY KEY (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
index a379575..28c025f 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
@@ -201,6 +201,7 @@ CREATE TABLE ambari.servicecomponentdesiredstate (
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
PRIMARY KEY (component_name, cluster_id, service_name)
);
GRANT ALL PRIVILEGES ON TABLE ambari.servicecomponentdesiredstate TO :username;
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index b57d377..c9d6ac2 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -166,6 +166,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id NUMERIC(19) NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled BIT NOT NULL DEFAULT 0,
PRIMARY KEY (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index b2fd5e2..4d6f0e8 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -186,6 +186,7 @@ CREATE TABLE servicecomponentdesiredstate (
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled BIT NOT NULL DEFAULT 0,
PRIMARY KEY CLUSTERED (component_name, cluster_id, service_name)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index 4052ad2..8ccae05 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -62,6 +62,7 @@
"ServiceComponentInfo/total_count",
"ServiceComponentInfo/started_count",
"ServiceComponentInfo/installed_count",
+ "ServiceComponentInfo/recovery_enabled",
"params/run_smoke_test",
"_"
],
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index ffee3fa..1a223e1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -5683,6 +5683,7 @@ public class AmbariManagementControllerTest {
clusters.getCluster(clusterName).getService(serviceName)
.getServiceComponents().values()) {
Assert.assertEquals(State.INSTALLED, sc.getDesiredState());
+ Assert.assertFalse(sc.isRecoveryEnabled()); // default value of recoveryEnabled
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
Assert.assertEquals(State.INSTALLED, sch.getDesiredState());
Assert.assertEquals(State.INIT, sch.getState());
@@ -5699,6 +5700,7 @@ public class AmbariManagementControllerTest {
for (ServiceComponent sc :
clusters.getCluster(clusterName).getService(serviceName)
.getServiceComponents().values()) {
+ sc.setRecoveryEnabled(true);
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
sch.setState(State.INSTALLED);
}
@@ -5718,6 +5720,7 @@ public class AmbariManagementControllerTest {
clusters.getCluster(clusterName).getService(serviceName)
.getServiceComponents().values()) {
Assert.assertEquals(State.INSTALLED, sc.getDesiredState());
+ Assert.assertTrue(sc.isRecoveryEnabled());
for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
Assert.assertEquals(State.INSTALLED, sch.getDesiredState());
Assert.assertEquals(State.INSTALLED, sch.getState());
http://git-wip-us.apache.org/repos/asf/ambari/blob/fca04c30/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
index f38fab1..d24ca09 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
@@ -225,11 +225,14 @@ public class ComponentResourceProviderTest {
expect(service.getServiceComponents()).andReturn(serviceComponentMap).anyTimes();
expect(serviceComponent1.convertToResponse()).andReturn(
- new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component100", null, "", 1, 1, 0));
+ new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component100", null, "", 1, 1, 0,
+ true /* recovery enabled */));
expect(serviceComponent2.convertToResponse()).andReturn(
- new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, "", 1, 1, 0));
+ new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, "", 1, 1, 0,
+ false /* recovery not enabled */));
expect(serviceComponent3.convertToResponse()).andReturn(
- new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null, "", 1, 1, 0));
+ new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null, "", 1, 1, 0,
+ true /* recovery enabled */));
expect(ambariMetaInfo.getComponent((String) anyObject(),
(String) anyObject(), (String) anyObject(), (String) anyObject()))
@@ -258,6 +261,7 @@ public class ComponentResourceProviderTest {
propertyIds.add(ComponentResourceProvider.COMPONENT_TOTAL_COUNT_PROPERTY_ID);
propertyIds.add(ComponentResourceProvider.COMPONENT_STARTED_COUNT_PROPERTY_ID);
propertyIds.add(ComponentResourceProvider.COMPONENT_INSTALLED_COUNT_PROPERTY_ID);
+ propertyIds.add(ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID);
Predicate predicate = new PredicateBuilder()
.property(ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID)
@@ -282,6 +286,8 @@ public class ComponentResourceProviderTest {
ComponentResourceProvider.COMPONENT_STARTED_COUNT_PROPERTY_ID));
Assert.assertEquals(0, resource.getPropertyValue(
ComponentResourceProvider.COMPONENT_INSTALLED_COUNT_PROPERTY_ID));
+ Assert.assertEquals(String.valueOf(true), resource.getPropertyValue(
+ ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID));
}
// verify
@@ -364,11 +370,14 @@ public class ComponentResourceProviderTest {
expect(component3Info.getCategory()).andReturn(null);
expect(serviceComponent1.convertToResponse()).andReturn(
- new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, "", 1, 0, 1));
+ new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, "", 1, 0, 1,
+ false /* recovery not enabled */));
expect(serviceComponent2.convertToResponse()).andReturn(
- new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null, "", 1, 0, 1));
+ new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null, "", 1, 0, 1,
+ false /* recovery not enabled */));
expect(serviceComponent3.convertToResponse()).andReturn(
- new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component103", null, "", 1, 0, 1));
+ new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component103", null, "", 1, 0, 1,
+ false /* recovery not enabled */));
expect(serviceComponent1.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
expect(serviceComponent2.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
expect(serviceComponent3.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
@@ -412,6 +421,7 @@ public class ComponentResourceProviderTest {
Map<String, Object> properties = new LinkedHashMap<String, Object>();
+ properties.put(ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID, String.valueOf(true) /* recovery enabled */);
properties.put(ComponentResourceProvider.COMPONENT_STATE_PROPERTY_ID, "STARTED");
properties.put(ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -607,7 +617,7 @@ public class ComponentResourceProviderTest {
// requests
ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
- null);
+ null, String.valueOf(true /* recovery enabled */));
Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
setRequests.add(request1);
@@ -667,14 +677,15 @@ public class ComponentResourceProviderTest {
// requests
ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
- null);
+ null, String.valueOf(true /* recovery enabled */));
ServiceComponentRequest request2 = new ServiceComponentRequest("cluster1", "service1", "component2",
- null);
+ null, String.valueOf(true /* recovery enabled */));
ServiceComponentRequest request3 = new ServiceComponentRequest("cluster1", "service1", "component3",
- null);
+ null, String.valueOf(true /* recovery enabled */));
ServiceComponentRequest request4 = new ServiceComponentRequest("cluster1", "service1", "component4",
- null);
- ServiceComponentRequest request5 = new ServiceComponentRequest("cluster1", "service2", null, null);
+ null, String.valueOf(true /* recovery enabled */));
+ ServiceComponentRequest request5 = new ServiceComponentRequest("cluster1", "service2", null, null,
+ String.valueOf(true /* recovery enabled */));
Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
setRequests.add(request1);
@@ -758,7 +769,7 @@ public class ComponentResourceProviderTest {
// requests
ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
- null);
+ null, String.valueOf(true /* recovery enabled */));
Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
setRequests.add(request1);
[21/21] ambari git commit: Merge branch 'trunk' into
branch-dev-patch-upgrade
Posted by nc...@apache.org.
Merge branch 'trunk' into branch-dev-patch-upgrade
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2eea1bfa
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2eea1bfa
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2eea1bfa
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 2eea1bfa9008b0e17dcca8c196ea911fdce041fd
Parents: 4d3839c 4fcca62
Author: Nate Cole <nc...@hortonworks.com>
Authored: Mon Feb 22 11:48:00 2016 -0500
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Mon Feb 22 11:48:00 2016 -0500
----------------------------------------------------------------------
.../python/resource_management/core/logger.py | 2 +-
.../timeline/AbstractTimelineMetricsSink.java | 53 +++++-
.../ApplicationHistoryServer.java | 6 +-
.../loadsimulator/net/RestMetricsSender.java | 4 +-
.../ApplicationHistoryStoreTestUtils.java | 2 +-
.../TestApplicationHistoryClientService.java | 6 +-
.../TestFileSystemApplicationHistoryStore.java | 12 +-
.../TestMemoryApplicationHistoryStore.java | 12 +-
.../webapp/TestAHSWebServices.java | 2 +-
.../server/checks/CheckDatabaseHelper.java | 137 ++++++++-----
.../server/configuration/Configuration.java | 89 +++++++++
.../server/controller/ControllerModule.java | 16 ++
.../controller/ServiceComponentRequest.java | 35 +++-
.../controller/ServiceComponentResponse.java | 22 ++-
.../internal/ComponentResourceProvider.java | 38 ++++
.../server/orm/dao/HostRoleCommandDAO.java | 166 +++++++++++++---
.../orm/entities/HostRoleCommandEntity.java | 7 +-
.../ServiceComponentDesiredStateEntity.java | 11 ++
.../serveraction/ServerActionExecutor.java | 13 +-
.../ambari/server/state/ServiceComponent.java | 14 ++
.../server/state/ServiceComponentImpl.java | 81 +++++++-
.../server/state/cluster/ClusterImpl.java | 36 ++--
.../services/AlertNoticeDispatchService.java | 17 +-
.../server/upgrade/UpgradeCatalog222.java | 55 ++++++
.../server/upgrade/UpgradeCatalog240.java | 14 ++
.../main/resources/Ambari-DDL-Derby-CREATE.sql | 1 +
.../main/resources/Ambari-DDL-MySQL-CREATE.sql | 2 +
.../main/resources/Ambari-DDL-Oracle-CREATE.sql | 2 +
.../resources/Ambari-DDL-Postgres-CREATE.sql | 4 +
.../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql | 2 +
.../resources/Ambari-DDL-SQLAnywhere-CREATE.sql | 2 +
.../resources/Ambari-DDL-SQLServer-CREATE.sql | 2 +-
.../src/main/resources/alert-templates.xml | 20 +-
.../1.6.1.2.2.0/configuration/accumulo-env.xml | 1 -
.../0.5.0.2.1/configuration/falcon-env.xml | 1 -
.../FLUME/1.4.0.2.0/configuration/flume-env.xml | 1 -
.../0.96.0.2.0/configuration/hbase-env.xml | 1 -
.../HDFS/2.1.0.2.0/configuration/hadoop-env.xml | 1 -
.../HIVE/0.12.0.2.0/configuration/hive-env.xml | 1 -
.../HIVE/0.12.0.2.0/configuration/hive-site.xml | 1 +
.../0.8.1.2.2/configuration/kafka-broker.xml | 1 -
.../OOZIE/4.0.0.2.0/configuration/oozie-env.xml | 1 -
.../configuration-mapred/mapred-env.xml | 1 -
.../YARN/2.1.0.2.0/configuration/yarn-env.xml | 1 -
.../3.4.5.2.0/configuration/zookeeper-env.xml | 1 -
.../src/main/resources/properties.json | 1 +
.../main/resources/scripts/Ambaripreupload.py | 46 +++--
.../stacks/HDP/2.0.6/services/stack_advisor.py | 5 +-
.../services/HBASE/configuration/hbase-env.xml | 1 -
.../stacks/HDP/2.2/services/stack_advisor.py | 17 +-
.../services/HIVE/configuration/hive-site.xml | 2 +
.../stacks/HDP/2.3/services/stack_advisor.py | 32 ++--
.../stacks/HDP/2.4/services/HIVE/metainfo.xml | 41 +++-
.../actionmanager/TestActionScheduler.java | 24 +--
.../ambari/server/agent/AgentResourceTest.java | 2 +
.../server/checks/CheckDatabaseHelperTest.java | 20 +-
.../server/configuration/ConfigurationTest.java | 95 ++++++++++
.../AmbariManagementControllerTest.java | 3 +
.../server/controller/KerberosHelperTest.java | 2 +
.../internal/ComponentResourceProviderTest.java | 37 ++--
.../ambari/server/stack/StackManagerTest.java | 35 ++--
.../ambari/server/state/ConfigHelperTest.java | 2 +
.../server/upgrade/UpgradeCatalog222Test.java | 134 ++++++++++++-
.../server/upgrade/UpgradeCatalog240Test.java | 12 ++
.../ambari/server/utils/StageUtilsTest.java | 2 +
.../stacks/2.0.6/common/test_stack_advisor.py | 12 +-
.../stacks/2.2/common/test_stack_advisor.py | 14 +-
.../stacks/2.3/common/test_stack_advisor.py | 46 +++++
ambari-web/app/assets/test/tests.js | 1 +
.../hawq/addStandby/step3_controller.js | 2 +-
.../app/mappers/components_state_mapper.js | 5 +
ambari-web/app/messages.js | 5 +
.../app/models/alerts/alert_definition.js | 4 +-
ambari-web/app/views.js | 1 +
.../configs/widgets/list_config_widget_view.js | 11 +-
ambari-web/app/views/main/dashboard/widgets.js | 19 +-
.../main/dashboard/widgets/hawqsegment_live.js | 190 +++++++++++++++++++
ambari-web/test/controllers/installer_test.js | 2 +-
.../progress_popup_controller_test.js | 4 +-
...anage_alert_notifications_controller_test.js | 8 +-
.../main/service/info/config_test.js | 2 +-
.../widgets/create/step2_controller_test.js | 2 +-
.../test/controllers/main/service_test.js | 12 --
.../test/controllers/wizard/step3_test.js | 18 --
.../test/controllers/wizard/step7_test.js | 2 +-
.../test/controllers/wizard/step9_test.js | 7 +-
.../test/mappers/server_data_mapper_test.js | 8 +-
.../mixins/common/configs/configs_saver_test.js | 10 +-
.../host_components/install_component_test.js | 2 +-
.../test/models/alerts/alert_instance_test.js | 3 +-
ambari-web/test/utils/form_field_test.js | 2 +-
.../widgets/slider_config_widget_view_test.js | 4 +-
ambari-web/test/views/common/table_view_test.js | 2 +-
.../admin/stack_upgrade/services_view_test.js | 6 +-
.../views/main/alert_definitions_view_test.js | 4 +-
.../test/views/main/dashboard/widget_test.js | 18 +-
.../dashboard/widgets/hawqsegment_live_test.js | 69 +++++++
.../ambari_metrics/regionserver_base_test.js | 2 +-
ambari-web/test/views/wizard/step5_view_test.js | 4 +-
ambari-web/test/views/wizard/step9_view_test.js | 31 ++-
100 files changed, 1564 insertions(+), 378 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
----------------------------------------------------------------------
diff --cc ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
index 65cc107,630eef2..519e4e6
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
@@@ -151,35 -115,14 +154,43 @@@ public class ServiceComponentDesiredSta
this.desiredStack = desiredStack;
}
+ /**
+ * Adds a historical entry for the version of this service component. New
+ * entries are automatically created when this entities is merged via a
+ * {@link CascadeType#MERGE}.
+ *
+ * @param historicalEntry
+ * the entry to add.
+ */
+ public void addHistory(ServiceComponentHistoryEntity historicalEntry) {
+ if (null == serviceComponentHistory) {
+ serviceComponentHistory = new ArrayList<>();
+ }
+
+ serviceComponentHistory.add(historicalEntry);
+
+ if (!equals(historicalEntry.getServiceComponentDesiredState())) {
+ historicalEntry.setServiceComponentDesiredState(this);
+ }
+ }
+
+ /**
+ * Gets the history of this component's upgrades and downgrades.
+ *
+ * @return the component history, or {@code null} if none.
+ */
+ public Collection<ServiceComponentHistoryEntity> getHistory() {
+ return serviceComponentHistory;
+ }
+
+ public boolean isRecoveryEnabled() {
+ return recoveryEnabled != 0;
+ }
+
+ public void setRecoveryEnabled(boolean recoveryEnabled) {
+ this.recoveryEnabled = (recoveryEnabled == false) ? 0 : 1;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
----------------------------------------------------------------------
diff --cc ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
index 4afc857,7b866a9..eca911d
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
@@@ -95,7 -95,8 +95,7 @@@ public class ServiceComponentImpl imple
desiredStateEntity.setDesiredState(State.INIT);
desiredStateEntity.setServiceName(service.getName());
desiredStateEntity.setClusterId(service.getClusterId());
-
+ desiredStateEntity.setRecoveryEnabled(false);
- desiredStateEntityPK = getDesiredStateEntityPK(desiredStateEntity);
setDesiredStackVersion(service.getDesiredStackVersion());
hostComponents = new HashMap<String, ServiceComponentHost>();
@@@ -178,9 -180,66 +178,58 @@@
@Override
public String getName() {
- ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
- if (desiredStateEntity != null) {
- return desiredStateEntity.getComponentName();
- } else {
- LOG.warn("Trying to fetch a member from an entity object that may " +
- "have been previously deleted, serviceName = " + getServiceName() + ", " +
- "componentName = " + componentName);
- }
- return null;
+ return componentName;
}
+ /**
+ * Get the recoveryEnabled value.
+ *
+ * @return true or false
+ */
+ @Override
+ public boolean isRecoveryEnabled() {
+ ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+ if (desiredStateEntity != null) {
+ return desiredStateEntity.isRecoveryEnabled();
+ } else {
+ LOG.warn("Trying to fetch a member from an entity object that may " +
+ "have been previously deleted, serviceName = " + service.getName() + ", " +
+ "componentName = " + componentName);
+ }
+ return false;
+ }
+
+ /**
+ * Set the recoveryEnabled field in the entity object.
+ *
+ * @param recoveryEnabled - true or false
+ */
+ @Override
+ public void setRecoveryEnabled(boolean recoveryEnabled) {
+ readWriteLock.writeLock().lock();
+ try {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Setting RecoveryEnabled of Component" + ", clusterName="
+ + service.getCluster().getClusterName() + ", clusterId="
+ + service.getCluster().getClusterId() + ", serviceName="
+ + service.getName() + ", componentName=" + getName()
+ + ", oldRecoveryEnabled=" + isRecoveryEnabled() + ", newRecoveryEnabled="
+ + recoveryEnabled);
+ }
+ ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+ if (desiredStateEntity != null) {
+ desiredStateEntity.setRecoveryEnabled(recoveryEnabled);
- saveIfPersisted();
++ saveIfPersisted(desiredStateEntity);
+ } else {
+ LOG.warn("Setting a member on an entity object that may have been " +
+ "previously deleted, serviceName = " + service.getName());
+ }
+
+ } finally {
+ readWriteLock.writeLock().unlock();
+ }
+ }
+
@Override
public String getServiceName() {
return service.getName();
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
----------------------------------------------------------------------
diff --cc ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
index 09f31e4,6a8ead1..f2055a6
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
@@@ -127,10 -117,8 +129,11 @@@ public class UpgradeCatalog240 extends
@Override
protected void executeDDLUpdates() throws AmbariException, SQLException {
updateAdminPermissionTable();
+ updateServiceComponentDesiredStateTable();
createSettingTable();
+ updateRepoVersionTableDDL();
+ updateServiceComponentDesiredStateTableDDL();
+ createServiceComponentHistoryTable();
}
@Override
@@@ -408,158 -395,13 +411,169 @@@
}
/**
+ * Makes the following changes to the {@value #REPO_VERSION_TABLE} table:
+ * <ul>
+ * <li>repo_type VARCHAR(255) DEFAULT 'STANDARD' NOT NULL</li>
+ * <li>version_url VARCHAR(1024)</li>
+ * <li>version_xml MEDIUMTEXT</li>
+ * <li>version_xsd VARCHAR(512)</li>
+ * <li>parent_id BIGINT</li>
+ * </ul>
+ *
+ * @throws SQLException
+ */
+ private void updateRepoVersionTableDDL() throws SQLException {
+ DBColumnInfo repoTypeColumn = new DBColumnInfo("repo_type", String.class, 255, RepositoryType.STANDARD.name(), false);
+ DBColumnInfo versionUrlColumn = new DBColumnInfo("version_url", String.class, 1024, null, true);
+ DBColumnInfo versionXmlColumn = new DBColumnInfo("version_xml", Clob.class, null, null, true);
+ DBColumnInfo versionXsdColumn = new DBColumnInfo("version_xsd", String.class, 512, null, true);
+ DBColumnInfo parentIdColumn = new DBColumnInfo("parent_id", Long.class, null, null, true);
+
+ dbAccessor.addColumn(REPO_VERSION_TABLE, repoTypeColumn);
+ dbAccessor.addColumn(REPO_VERSION_TABLE, versionUrlColumn);
+ dbAccessor.addColumn(REPO_VERSION_TABLE, versionXmlColumn);
+ dbAccessor.addColumn(REPO_VERSION_TABLE, versionXsdColumn);
+ dbAccessor.addColumn(REPO_VERSION_TABLE, parentIdColumn);
+ }
+
+ /**
+ * Makes the following changes to the {@value #SERVICE_COMPONENT_DS_TABLE} table,
+ * but only if the table doesn't have it's new PK set.
+ * <ul>
+ * <li>id BIGINT NOT NULL</li>
+ * <li>Drops FKs on {@value #HOST_COMPONENT_DS_TABLE} and {@value #HOST_COMPONENT_STATE_TABLE}</li>
+ * <li>Populates {@value #SQLException#ID} in {@value #SERVICE_COMPONENT_DS_TABLE}</li>
+ * <li>Creates {@code UNIQUE} constraint on {@value #HOST_COMPONENT_DS_TABLE}</li>
+ * <li>Adds FKs on {@value #HOST_COMPONENT_DS_TABLE} and {@value #HOST_COMPONENT_STATE_TABLE}</li>
+ * <li>Adds new sequence value of {@code servicecomponentdesiredstate_id_seq}</li>
+ * </ul>
+ *
+ * @throws SQLException
+ */
+ @Transactional
+ private void updateServiceComponentDesiredStateTableDDL() throws SQLException {
+ if (dbAccessor.tableHasPrimaryKey(SERVICE_COMPONENT_DS_TABLE, ID)) {
+ LOG.info("Skipping {} table Primary Key modifications since the new {} column already exists",
+ SERVICE_COMPONENT_DS_TABLE, ID);
+
+ return;
+ }
+
+ // drop FKs to SCDS in both HCDS and HCS tables
+ dbAccessor.dropFKConstraint(HOST_COMPONENT_DS_TABLE, "hstcmpnntdesiredstatecmpnntnme");
+ dbAccessor.dropFKConstraint(HOST_COMPONENT_STATE_TABLE, "hstcomponentstatecomponentname");
+
+ // remove existing compound PK
+ dbAccessor.dropPKConstraint(SERVICE_COMPONENT_DS_TABLE, "servicecomponentdesiredstate_pkey");
+
+ // add new PK column to SCDS, making it nullable for now
+ DBColumnInfo idColumn = new DBColumnInfo(ID, Long.class, null, null, true);
+ dbAccessor.addColumn(SERVICE_COMPONENT_DS_TABLE, idColumn);
+
+ // populate SCDS id column
+ AtomicLong scdsIdCounter = new AtomicLong(1);
+ Statement statement = null;
+ ResultSet resultSet = null;
+ try {
+ statement = dbAccessor.getConnection().createStatement();
+ if (statement != null) {
+ String selectSQL = String.format("SELECT cluster_id, service_name, component_name FROM %s",
+ SERVICE_COMPONENT_DS_TABLE);
+
+ resultSet = statement.executeQuery(selectSQL);
+ while (null != resultSet && resultSet.next()) {
+ final Long clusterId = resultSet.getLong("cluster_id");
+ final String serviceName = resultSet.getString("service_name");
+ final String componentName = resultSet.getString("component_name");
+
+ String updateSQL = String.format(
+ "UPDATE %s SET %s = %d WHERE cluster_id = %d AND service_name = '%s' AND component_name = '%s'",
+ SERVICE_COMPONENT_DS_TABLE, ID, scdsIdCounter.getAndIncrement(), clusterId,
+ serviceName, componentName);
+
+ dbAccessor.executeQuery(updateSQL);
+ }
+ }
+ } finally {
+ JdbcUtils.closeResultSet(resultSet);
+ JdbcUtils.closeStatement(statement);
+ }
+
+ // make the column NON NULL now
+ dbAccessor.alterColumn(SERVICE_COMPONENT_DS_TABLE,
+ new DBColumnInfo(ID, Long.class, null, null, false));
+
+ // create a new PK, matching the name of the constraint found in SQL
+ dbAccessor.addPKConstraint(SERVICE_COMPONENT_DS_TABLE, "pk_sc_desiredstate", ID);
+
+ // create UNIQUE constraint, ensuring column order matches SQL files
+ String[] uniqueColumns = new String[] { "component_name", "service_name", "cluster_id" };
+ dbAccessor.addUniqueConstraint(SERVICE_COMPONENT_DS_TABLE, "unq_scdesiredstate_name",
+ uniqueColumns);
+
+ // add FKs back to SCDS in both HCDS and HCS tables
+ dbAccessor.addFKConstraint(HOST_COMPONENT_DS_TABLE, "hstcmpnntdesiredstatecmpnntnme",
+ uniqueColumns, SERVICE_COMPONENT_DS_TABLE, uniqueColumns, false);
+
+ dbAccessor.addFKConstraint(HOST_COMPONENT_STATE_TABLE, "hstcomponentstatecomponentname",
+ uniqueColumns, SERVICE_COMPONENT_DS_TABLE, uniqueColumns, false);
+
+ // Add sequence for SCDS id
+ addSequence("servicecomponentdesiredstate_id_seq", scdsIdCounter.get(), false);
+ }
+
+ /**
+ * Makes the following changes to the {@value #SERVICE_COMPONENT_HISTORY_TABLE} table:
+ * <ul>
+ * <li>id BIGINT NOT NULL</li>
+ * <li>component_id BIGINT NOT NULL</li>
+ * <li>upgrade_id BIGINT NOT NULL</li>
+ * <li>from_stack_id BIGINT NOT NULL</li>
+ * <li>to_stack_id BIGINT NOT NULL</li>
+ * <li>CONSTRAINT PK_sc_history PRIMARY KEY (id)</li>
+ * <li>CONSTRAINT FK_sc_history_component_id FOREIGN KEY (component_id) REFERENCES servicecomponentdesiredstate (id)</li>
+ * <li>CONSTRAINT FK_sc_history_upgrade_id FOREIGN KEY (upgrade_id) REFERENCES upgrade (upgrade_id)</li>
+ * <li>CONSTRAINT FK_sc_history_from_stack_id FOREIGN KEY (from_stack_id) REFERENCES stack (stack_id)</li>
+ * <li>CONSTRAINT FK_sc_history_to_stack_id FOREIGN KEY (to_stack_id) REFERENCES stack (stack_id)</li>
+ * <li>Creates the {@code servicecomponent_history_id_seq}</li>
+ * </ul>
+ *
+ * @throws SQLException
+ */
+ private void createServiceComponentHistoryTable() throws SQLException {
+ List<DBColumnInfo> columns = new ArrayList<>();
+ columns.add(new DBColumnInfo(ID, Long.class, null, null, false));
+ columns.add(new DBColumnInfo("component_id", Long.class, null, null, false));
+ columns.add(new DBColumnInfo("upgrade_id", Long.class, null, null, false));
+ columns.add(new DBColumnInfo("from_stack_id", Long.class, null, null, false));
+ columns.add(new DBColumnInfo("to_stack_id", Long.class, null, null, false));
+ dbAccessor.createTable(SERVICE_COMPONENT_HISTORY_TABLE, columns, (String[]) null);
+
+ dbAccessor.addPKConstraint(SERVICE_COMPONENT_HISTORY_TABLE, "PK_sc_history", ID);
+
+ dbAccessor.addFKConstraint(SERVICE_COMPONENT_HISTORY_TABLE, "FK_sc_history_component_id",
+ "component_id", SERVICE_COMPONENT_DS_TABLE, "id", false);
+
+ dbAccessor.addFKConstraint(SERVICE_COMPONENT_HISTORY_TABLE, "FK_sc_history_upgrade_id",
+ "upgrade_id", UPGRADE_TABLE, "upgrade_id", false);
+
+ dbAccessor.addFKConstraint(SERVICE_COMPONENT_HISTORY_TABLE, "FK_sc_history_from_stack_id",
+ "from_stack_id", STACK_TABLE, "stack_id", false);
+
+ dbAccessor.addFKConstraint(SERVICE_COMPONENT_HISTORY_TABLE, "FK_sc_history_to_stack_id",
+ "to_stack_id", STACK_TABLE, "stack_id", false);
+
+ addSequence("servicecomponent_history_id_seq", 0L, false);
+ }
++
++ /**
+ * Alter servicecomponentdesiredstate table to add recovery_enabled column.
+ * @throws SQLException
+ */
+ private void updateServiceComponentDesiredStateTable() throws SQLException {
+ // ALTER TABLE servicecomponentdesiredstate ADD COLUMN
+ // recovery_enabled SMALLINT DEFAULT 0 NOT NULL
+ dbAccessor.addColumn(SERVICE_COMPONENT_DESIRED_STATE_TABLE,
- new DBAccessor.DBColumnInfo(RECOVERY_ENABLED_COL, Short.class, null, 0, false));
++ new DBColumnInfo(RECOVERY_ENABLED_COL, Short.class, null, 0, false));
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
----------------------------------------------------------------------
diff --cc ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
index 2db745b,6d63a90..bd7755c
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@@ -177,8 -176,8 +177,9 @@@ CREATE TABLE servicecomponentdesiredsta
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
- PRIMARY KEY (component_name, cluster_id, service_name)
+ CONSTRAINT pk_sc_desiredstate PRIMARY KEY (id),
+ CONSTRAINT unq_scdesiredstate_name UNIQUE(component_name, service_name, cluster_id)
);
CREATE TABLE servicedesiredstate (
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --cc ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index b892bc8,2898ab7..ac1c5d7
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@@ -178,8 -177,8 +178,9 @@@ CREATE TABLE servicecomponentdesiredsta
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(100) NOT NULL,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
- PRIMARY KEY (component_name, cluster_id, service_name)
+ CONSTRAINT pk_sc_desiredstate PRIMARY KEY (id),
+ CONSTRAINT unq_scdesiredstate_name UNIQUE(component_name, service_name, cluster_id)
);
CREATE TABLE servicedesiredstate (
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --cc ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index 026efea,092f8c2..4ed3a19
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@@ -168,8 -167,8 +168,9 @@@ CREATE TABLE servicecomponentdesiredsta
desired_stack_id NUMBER(19) NOT NULL,
desired_state VARCHAR2(255) NOT NULL,
service_name VARCHAR2(255) NOT NULL,
+ recovery_enabled SMALLINT DEFAULT 0 NOT NULL,
- PRIMARY KEY (component_name, cluster_id, service_name)
+ CONSTRAINT pk_sc_desiredstate PRIMARY KEY (id),
+ CONSTRAINT unq_scdesiredstate_name UNIQUE(component_name, service_name, cluster_id)
);
CREATE TABLE servicedesiredstate (
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --cc ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index fb9889d,150ea9b..5d7be25
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@@ -177,8 -176,8 +177,9 @@@ CREATE TABLE servicecomponentdesiredsta
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
- PRIMARY KEY (component_name, cluster_id, service_name)
+ CONSTRAINT pk_sc_desiredstate PRIMARY KEY (id),
+ CONSTRAINT unq_scdesiredstate_name UNIQUE(component_name, service_name, cluster_id)
);
CREATE TABLE servicedesiredstate (
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------
diff --cc ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
index 3cc7516,0443336..c032b8f
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
@@@ -202,8 -201,8 +202,9 @@@ CREATE TABLE ambari.servicecomponentdes
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
- PRIMARY KEY (component_name, cluster_id, service_name)
+ CONSTRAINT pk_sc_desiredstate PRIMARY KEY (id),
+ CONSTRAINT unq_scdesiredstate_name UNIQUE(component_name, service_name, cluster_id)
);
GRANT ALL PRIVILEGES ON TABLE ambari.servicecomponentdesiredstate TO :username;
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --cc ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index a5bfdc2,20a7634..6a6b77b
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@@ -167,8 -166,8 +167,9 @@@ CREATE TABLE servicecomponentdesiredsta
desired_stack_id NUMERIC(19) NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
+ recovery_enabled SMALLINT NOT NULL DEFAULT 0,
- PRIMARY KEY (component_name, cluster_id, service_name)
+ CONSTRAINT pk_sc_desiredstate PRIMARY KEY (id),
+ CONSTRAINT unq_scdesiredstate_name UNIQUE(component_name, service_name, cluster_id)
);
CREATE TABLE servicedesiredstate (
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --cc ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index 8e5b2f8,2c9adf3..43419c1
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@@ -187,10 -186,9 +187,9 @@@ CREATE TABLE servicecomponentdesiredsta
desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
- PRIMARY KEY CLUSTERED (id),
- recovery_enabled SMALLINT NOT NULL DEFAULT 0,
- PRIMARY KEY CLUSTERED (component_name, cluster_id, service_name)
- );
+ CONSTRAINT pk_sc_desiredstate PRIMARY KEY (id),
+ CONSTRAINT unq_scdesiredstate_name UNIQUE(component_name, service_name, cluster_id)
+);
CREATE TABLE servicedesiredstate (
cluster_id BIGINT NOT NULL,
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-web/app/messages.js
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/2eea1bfa/ambari-web/app/views.js
----------------------------------------------------------------------
[20/21] ambari git commit: AMBARI-15128. Fix UI UT (onechiporenko)
Posted by nc...@apache.org.
AMBARI-15128. Fix UI UT (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4fcca627
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4fcca627
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4fcca627
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 4fcca627e1094e87ee471a3f21e6d57cadf09b79
Parents: 2a7196d
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Mon Feb 22 16:57:28 2016 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Mon Feb 22 18:12:11 2016 +0200
----------------------------------------------------------------------
ambari-web/test/controllers/installer_test.js | 2 +-
.../progress_popup_controller_test.js | 4 +--
...anage_alert_notifications_controller_test.js | 8 ++---
.../main/service/info/config_test.js | 2 +-
.../widgets/create/step2_controller_test.js | 2 +-
.../test/controllers/main/service_test.js | 12 --------
.../test/controllers/wizard/step3_test.js | 18 ------------
.../test/controllers/wizard/step7_test.js | 2 +-
.../test/controllers/wizard/step9_test.js | 7 ++++-
.../test/mappers/server_data_mapper_test.js | 8 ++---
.../mixins/common/configs/configs_saver_test.js | 10 +++----
.../host_components/install_component_test.js | 2 +-
.../test/models/alerts/alert_instance_test.js | 3 +-
ambari-web/test/utils/form_field_test.js | 2 +-
.../widgets/slider_config_widget_view_test.js | 4 +--
ambari-web/test/views/common/table_view_test.js | 2 +-
.../admin/stack_upgrade/services_view_test.js | 6 ++--
.../views/main/alert_definitions_view_test.js | 4 +--
.../test/views/main/dashboard/widget_test.js | 18 +++++++-----
.../dashboard/widgets/hawqsegment_live_test.js | 2 +-
.../ambari_metrics/regionserver_base_test.js | 2 +-
ambari-web/test/views/wizard/step5_view_test.js | 4 +--
ambari-web/test/views/wizard/step9_view_test.js | 31 +++++++++++++++-----
23 files changed, 72 insertions(+), 83 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/controllers/installer_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/installer_test.js b/ambari-web/test/controllers/installer_test.js
index df4ab0e..353129b 100644
--- a/ambari-web/test/controllers/installer_test.js
+++ b/ambari-web/test/controllers/installer_test.js
@@ -36,7 +36,7 @@ describe('App.InstallerController', function () {
c = App.InstallerController.create({});
});
it('all steps are disabled by default', function () {
- expect(c.get('isStepDisabled.length') > 0 ).to.be.ok;
+ expect(c.get('isStepDisabled.length')).to.be.above(0);
expect(c.get('isStepDisabled').everyProperty('value', true)).to.be.ok;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js
index 8648181..f4a0e99 100644
--- a/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js
@@ -46,11 +46,11 @@ describe('App.HighAvailabilityProgressPopupController', function () {
});
it('taskInfo.id = 2', function () {
- expect(controller.get('taskInfo.id'), 2);
+ expect(controller.get('taskInfo.id')).to.be.equal(2);
});
it('taskInfo.requestId = 1', function () {
- expect(controller.get('taskInfo.requestId'), 1);
+ expect(controller.get('taskInfo.requestId')).to.be.equal(1);
});
it('App.updater.run is called once', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
index 19d0c1b..f16bf4d 100644
--- a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
@@ -1020,23 +1020,19 @@ describe('App.ManageAlertNotificationsController', function () {
describe('#errorHandler', function () {
it('should fire invalid name', function () {
-
view.set('controller.newCustomProperty.name', '!!');
view.errorsHandler();
expect(view.get('isError')).to.be.true;
expect(view.get('parentView.disablePrimary')).to.be.true;
- expect(view.get('errorMessage.length') > 0).to.be.true;
-
+ expect(view.get('errorMessage.length')).to.be.above(0);
});
it('should fire existing property name', function () {
-
view.set('controller.newCustomProperty.name', 'n1');
view.errorsHandler();
expect(view.get('isError')).to.be.true;
expect(view.get('parentView.disablePrimary')).to.be.true;
- expect(view.get('errorMessage.length') > 0).to.be.true;
-
+ expect(view.get('errorMessage.length')).to.be.above(0);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js
index fd7b23a..9adfd28 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -478,7 +478,7 @@ describe("App.MainServiceInfoConfigsController", function () {
});
it("ajax request to put cluster cfg", function () {
mainServiceInfoConfigsController.set('stepConfigs', sc);
- expect(mainServiceInfoConfigsController.putChangedConfigurations([]));
+ mainServiceInfoConfigsController.putChangedConfigurations([]);
var args = testHelpers.findAjaxRequest('name', 'common.across.services.configurations');
expect(args[0]).exists;
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js b/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js
index 70a160b..e717f02 100644
--- a/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js
+++ b/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js
@@ -731,7 +731,7 @@ describe('App.WidgetWizardStep2Controller', function () {
});
it("user is moved to the next step", function () {
controller.next();
- expect(App.router.send.calledWith('next'));
+ expect(App.router.send.calledWith('next')).to.be.true;
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/controllers/main/service_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service_test.js b/ambari-web/test/controllers/main/service_test.js
index 60e0e4d..ee90a0f 100644
--- a/ambari-web/test/controllers/main/service_test.js
+++ b/ambari-web/test/controllers/main/service_test.js
@@ -178,12 +178,6 @@ describe('App.MainServiceController', function () {
expect(r).to.be.null;
});
- it('nothing disabled', function() {
- var event = {target: {}}, query = 'query';
- mainServiceController.startAllService(event).onPrimary(query);
- expect(mainServiceController.allServicesCall.calledWith('STARTED', query));
- });
-
});
describe('#stopAllService', function() {
@@ -208,12 +202,6 @@ describe('App.MainServiceController', function () {
expect(r).to.be.null;
});
- it('nothing disabled', function() {
- var event = {target: {}}, query = 'query';
- mainServiceController.stopAllService(event).onPrimary(query);
- expect(mainServiceController.allServicesCall.calledWith('STARTED', query));
- });
-
});
describe('#startStopAllService', function() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/controllers/wizard/step3_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step3_test.js b/ambari-web/test/controllers/wizard/step3_test.js
index 438554b..dbfb868 100644
--- a/ambari-web/test/controllers/wizard/step3_test.js
+++ b/ambari-web/test/controllers/wizard/step3_test.js
@@ -380,24 +380,6 @@ describe('App.WizardStep3Controller', function () {
});
- describe('#removeHost', function () {
-
- beforeEach(function () {
- sinon.stub(c, 'removeHosts', Em.K);
- });
-
- afterEach(function () {
- c.removeHosts.restore();
- });
-
- it('should call removeHosts with array as arg', function () {
- var host = {a: ''};
- c.removeHost(host);
- expect(c.removeHosts.calledWith([host]));
- });
-
- });
-
describe('#removeSelectedHosts', function () {
beforeEach(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index a089150..0ceec97 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -1733,7 +1733,7 @@ describe('App.InstallerStep7Controller', function () {
it('should copy properties from hdfs-site to hdfs-client for HAWQ', function() {
installerStep7Controller.addHawqConfigsOnNnHa(configs);
// ensure 6 new configs were added
- expect(configs.length - oldConfigs.length).to.be.equal(6);
+ expect(configs.length).to.be.equal(oldConfigs.length + 6);
});
describe('find the same property in hdfs-client for HAWQ and see if attribute value matches with the corresponding property\'s attribute value in hdfs-site', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/controllers/wizard/step9_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step9_test.js b/ambari-web/test/controllers/wizard/step9_test.js
index dd4f6cd..dfc1d65 100644
--- a/ambari-web/test/controllers/wizard/step9_test.js
+++ b/ambari-web/test/controllers/wizard/step9_test.js
@@ -974,7 +974,12 @@ describe('App.InstallerStep9Controller', function () {
tests.forEach(function (test) {
it(test.m, function () {
c.onInProgressPerHost(test.actions, test.host);
- expect(test.host.message === test.e.message).to.equal(test.e.b);
+ if (test.e.b) {
+ expect(test.host.message).to.be.equal(test.e.message);
+ }
+ else {
+ expect(test.host.message).to.be.not.equal(test.e.message);
+ }
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/mappers/server_data_mapper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mappers/server_data_mapper_test.js b/ambari-web/test/mappers/server_data_mapper_test.js
index d144afa..077cd20 100644
--- a/ambari-web/test/mappers/server_data_mapper_test.js
+++ b/ambari-web/test/mappers/server_data_mapper_test.js
@@ -113,11 +113,11 @@ describe('App.QuickDataMapper', function () {
});
it('numeric array. element doesn\'t exists', function () {
- expect(mapper.binaryIndexOf(array1, 0) < 0).to.be.true;
+ expect(mapper.binaryIndexOf(array1, 0)).to.be.below(0);
});
it('numeric array. element doesn\'t exists 2', function () {
- expect(mapper.binaryIndexOf(array1, 10) < 0).to.be.true;
+ expect(mapper.binaryIndexOf(array1, 10)).to.be.below(0);
});
array2.forEach(function(item, index) {
@@ -127,11 +127,11 @@ describe('App.QuickDataMapper', function () {
});
it('string array. element doesn\'t exists', function () {
- expect(mapper.binaryIndexOf(array2, 'a') < 0).to.be.true;
+ expect(mapper.binaryIndexOf(array2, 'a')).to.be.below(0);
});
it('string array. element doesn\'t exists 2', function () {
- expect(mapper.binaryIndexOf(array2, 'q') < 0).to.be.true;
+ expect(mapper.binaryIndexOf(array2, 'q')).to.be.below(0);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/mixins/common/configs/configs_saver_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/configs_saver_test.js b/ambari-web/test/mixins/common/configs/configs_saver_test.js
index f7be831..4baf303 100644
--- a/ambari-web/test/mixins/common/configs/configs_saver_test.js
+++ b/ambari-web/test/mixins/common/configs/configs_saver_test.js
@@ -59,14 +59,14 @@ describe('App.ConfigsSaverMixin', function() {
currentServices: stackServices[2],
res: false,
m: 'not ok'
- }].forEach(function (c) {
+ }].forEach(function (c, index) {
describe(c.m, function () {
beforeEach(function () {
instanceObject.reopen({
currentServices: c.currentServices
});
- it('', function () {
- expect(instanceObject.allowSaveCoreSite()).to.equal(c.res);
+ it('test #' + index, function () {
+ expect(instanceObject.allowSaveCoreSite()).to.be.equal(c.res);
});
});
});
@@ -79,7 +79,7 @@ describe('App.ConfigsSaverMixin', function() {
{ fName: 'core-site', res: true, allowSaveCoreSite: true, m: 'core site is allowed to be saved' },
{ fName: 'core-site', res: false, allowSaveCoreSite: false, m: 'core site is not allowed to be saved' },
{ fName: 'other-file-name', res: true, m: 'file name has not restriction rule, so can be saved' }
- ].forEach(function (c) {
+ ].forEach(function (c, index) {
describe(c.m, function () {
beforeEach(function() {
sinon.stub(instanceObject, 'allowSaveCoreSite').returns(c.allowSaveCoreSite);
@@ -87,7 +87,7 @@ describe('App.ConfigsSaverMixin', function() {
afterEach(function() {
instanceObject.allowSaveCoreSite.restore();
});
- it('', function () {
+ it('test #' + index, function () {
expect(instanceObject.allowSaveSite(c.fName)).to.equal(c.res);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/mixins/main/host/details/host_components/install_component_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/main/host/details/host_components/install_component_test.js b/ambari-web/test/mixins/main/host/details/host_components/install_component_test.js
index 56d582c..c039107 100644
--- a/ambari-web/test/mixins/main/host/details/host_components/install_component_test.js
+++ b/ambari-web/test/mixins/main/host/details/host_components/install_component_test.js
@@ -109,7 +109,7 @@ describe('App.InstallComponent', function () {
it("App.ajax.defaultErrorHandler should be called", function() {
installComponent.ajaxErrorCallback({}, {}, 'error', {method: 'method1', url: 'url1'}, {});
- expect(App.ajax.defaultErrorHandler.calledWith({}, 'url1', 'method1'));
+ expect(App.ajax.defaultErrorHandler.calledWith({}, 'url1', 'method1')).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/models/alerts/alert_instance_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/alerts/alert_instance_test.js b/ambari-web/test/models/alerts/alert_instance_test.js
index 19838a4..f3abd79 100644
--- a/ambari-web/test/models/alerts/alert_instance_test.js
+++ b/ambari-web/test/models/alerts/alert_instance_test.js
@@ -51,8 +51,7 @@ describe('App.AlertInstance', function () {
lastTriggeredFormatted: lastTriggeredFormatted
});
var status = model.get('statusChangedAndLastCheckedFormatted');
- expect(status.indexOf(lastCheckedFormatted) > status.indexOf(lastTriggeredFormatted)).to.be.true;
-
+ expect(status.indexOf(lastCheckedFormatted)).to.be.above(status.indexOf(lastTriggeredFormatted));
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/utils/form_field_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/form_field_test.js b/ambari-web/test/utils/form_field_test.js
index 9359e72..f0bf190 100644
--- a/ambari-web/test/utils/form_field_test.js
+++ b/ambari-web/test/utils/form_field_test.js
@@ -34,7 +34,7 @@ describe('App.FormField', function () {
formField.set('value', '');
formField.set('isRequired', true);
formField.validate();
- expect(formField.get('errorMessage') === '').to.equal(false);
+ expect(formField.get('errorMessage')).to.be.not.equal('');
});
/*REQUIRE END*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js b/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
index a996e69..f038d3d 100644
--- a/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
+++ b/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
@@ -127,8 +127,8 @@ describe('App.SliderConfigWidgetView', function () {
describe('#mirrorValue', function () {
it('should be equal to config.value after init', function () {
- expect('' + viewInt.get('mirrorValue')).to.equal(viewInt.get('config.value'));
- expect('' + viewFloat.get('mirrorValue')).to.equal(viewFloat.get('config.value'));
+ expect(viewInt.get('mirrorValue').toString()).to.be.equal(viewInt.get('config.value'));
+ expect(viewFloat.get('mirrorValue').toString()).to.be.equal(viewFloat.get('config.value'));
});
it('should be converted according to widget format', function() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/views/common/table_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/table_view_test.js b/ambari-web/test/views/common/table_view_test.js
index 50a5ee3..37dd911 100644
--- a/ambari-web/test/views/common/table_view_test.js
+++ b/ambari-web/test/views/common/table_view_test.js
@@ -50,7 +50,7 @@ describe('App.TableView', function () {
it('should set filterConditions on instance', function() {
var tableView = App.TableView.create();
- expect(tableView.get('filterConditions') === App.TableView.prototype.filterConditions).to.be.false;
+ expect(tableView.get('filterConditions')).to.be.not.equal(App.TableView.prototype.filterConditions);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
index 64afed3..9a42c42 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
@@ -73,14 +73,16 @@ describe('App.MainAdminStackServicesView', function () {
it("routes to Add Service Wizard and set redirect path on wizard close", function() {
isAccessibleMock.returns(true);
view.goToAddService({context: "serviceName"});
- expect(App.router.get.calledWith('addServiceController') && mock.setDBProperty.calledWith('onClosePath', 'main.admin.stackAndUpgrade.services')).to.be.true;
+ expect(App.router.get.calledWith('addServiceController')).to.be.true;
+ expect(mock.setDBProperty.calledWith('onClosePath', 'main.admin.stackAndUpgrade.services')).to.be.true;
expect(App.get('router').transitionTo.calledWith('main.serviceAdd')).to.be.true;
expect(mock.get('serviceToInstall')).to.be.equal("serviceName");
});
it("routes to Security Wizard", function() {
isAccessibleMock.returns(true);
view.goToAddService({context: "KERBEROS"});
- expect(App.router.get.calledWith('kerberosWizardController') && mock.setDBProperty.calledWith('onClosePath', 'main.admin.stackAndUpgrade.services')).to.be.true;
+ expect(App.router.get.calledWith('kerberosWizardController')).to.be.true;
+ expect(mock.setDBProperty.calledWith('onClosePath', 'main.admin.stackAndUpgrade.services')).to.be.true;
expect(mock.checkAndStartKerberosWizard.calledOnce).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/views/main/alert_definitions_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/alert_definitions_view_test.js b/ambari-web/test/views/main/alert_definitions_view_test.js
index 224cb7e..0c3e5cc 100644
--- a/ambari-web/test/views/main/alert_definitions_view_test.js
+++ b/ambari-web/test/views/main/alert_definitions_view_test.js
@@ -51,8 +51,8 @@ describe('App.MainAlertDefinitionsView', function () {
it('Add Ambari service to filters', function () {
var serviceFilterClass = view.serviceFilterView;
var content = serviceFilterClass.create({}).get('content');
- expect(content[0].label === Em.I18n.t('common.all'));
- expect(content[content.length - 1].label === Em.I18n.t('app.name'));
+ expect(content[0].label).to.be.equal(Em.I18n.t('common.all'));
+ expect(content[content.length - 1].label).to.be.equal(Em.I18n.t('app.name'));
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/views/main/dashboard/widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widget_test.js b/ambari-web/test/views/main/dashboard/widget_test.js
index 6450d1c..1a77efe 100644
--- a/ambari-web/test/views/main/dashboard/widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widget_test.js
@@ -103,20 +103,22 @@ describe('App.DashboardWidgetView', function () {
dashboardWidgetView.get('parentView').translateToReal.restore();
});
it("postUserPref is called with correct data", function () {
- expect(dashboardWidgetView.get('parentView').postUserPref.calledWith('key', {
+ var arg = JSON.parse(JSON.stringify(dashboardWidgetView.get('parentView').postUserPref.args[0][1]));
+ expect(arg).to.be.eql({
dashboardVersion: 'new',
- visible: ['2'],
- hidden: ['1'],
+ visible: ['1', '2'],
+ hidden: [[5, null]],
threshold: 'threshold'
- }));
+ });
});
it("translateToReal is called with valid data", function () {
- expect(dashboardWidgetView.get('parentView').translateToReal.calledWith({
+ var arg = JSON.parse(JSON.stringify(dashboardWidgetView.get('parentView').translateToReal.args[0][0]));
+ expect(arg).to.be.eql({
dashboardVersion: 'new',
- visible: ['2'],
- hidden: ['1'],
+ visible: ['1', '2'],
+ hidden: [[5, null]],
threshold: 'threshold'
- }));
+ });
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js b/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js
index eb8a505..c4a1687 100644
--- a/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js
@@ -52,7 +52,7 @@ describe('App.HawqSegmentUpView', function() {
];
tests.forEach(function(test) {
- describe('', function() {
+ describe('data -' + test.data, function() {
var hawqSegmentUpView = App.HawqSegmentUpView.create({model_type:null, data: test.data, content: test.data.toString()});
it('shows red', function() {
expect(hawqSegmentUpView.get('isRed')).to.equal(test.e.isRed);
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test.js b/ambari-web/test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test.js
index 3b0ee44..dcec6fe 100644
--- a/ambari-web/test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test.js
+++ b/ambari-web/test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test.js
@@ -50,7 +50,7 @@ describe('App.ChartServiceMetricsAMS_RegionServerBaseView', function () {
});
it('displayName', function () {
- expect(this.result[0].name === regionServerView.displayName).to.be.true;
+ expect(this.result[0].name).to.be.equal(regionServerView.displayName);
});
it('data.length', function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/views/wizard/step5_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step5_view_test.js b/ambari-web/test/views/wizard/step5_view_test.js
index 5f3cd0d..bf45a51 100644
--- a/ambari-web/test/views/wizard/step5_view_test.js
+++ b/ambari-web/test/views/wizard/step5_view_test.js
@@ -191,7 +191,7 @@ describe('App.SelectHostView', function() {
it('should call assignHostToMaster', function() {
view.changeHandler();
- expect(view.get('controller').assignHostToMaster.calledWith('ZOOKEEPER_SERVER', 'h1', 1));
+ expect(view.get('controller').assignHostToMaster.args[0]).to.be.eql(['ZOOKEEPER_SERVER', 'h1 info', 1]);
});
it('should increment rebalanceComponentHostsCounter if component it is multiple', function() {
@@ -271,7 +271,7 @@ describe('App.InputHostView', function() {
it('should call assignHostToMaster', function() {
view.changeHandler();
- expect(view.get('controller').assignHostToMaster.calledWith('ZOOKEEPER_SERVER', 'h1', 1));
+ expect(view.get('controller').assignHostToMaster.args[0]).to.be.eql(['ZOOKEEPER_SERVER', 'h1', 1]);
});
it('should increment rebalanceComponentHostsCounter if component it is multiple', function() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/4fcca627/ambari-web/test/views/wizard/step9_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step9_view_test.js b/ambari-web/test/views/wizard/step9_view_test.js
index 646e945..47bae16 100644
--- a/ambari-web/test/views/wizard/step9_view_test.js
+++ b/ambari-web/test/views/wizard/step9_view_test.js
@@ -701,14 +701,29 @@ describe('App.HostStatusView', function () {
e: false
}
]).forEach(function (test) {
- it(JSON.stringify(test.obj) + ' ' + test.progress, function() {
- hv.set('barColor', '');
- hv.set('obj', test.obj);
- hv.set('obj.message', '');
- hv.set('controller', {progress: test.progress});
- hv.onStatus();
- expect(hv.get('obj.message') === Em.I18n.t('installer.step9.host.status.success')).to.equal(test.e);
- expect(hv.get('barColor') === 'progress-success').to.equal(test.e);
+ describe(JSON.stringify(test.obj) + ' ' + test.progress, function() {
+ beforeEach(function () {
+ hv.setProperties({
+ barColor: '',
+ obj: test.obj
+ });
+ hv.set('obj.message', '');
+ hv.set('controller', {progress: test.progress});
+ hv.onStatus();
+ });
+
+ if (test.e) {
+ it('completed successful', function () {
+ expect(hv.get('obj.message')).to.be.equal(Em.I18n.t('installer.step9.host.status.success'));
+ expect(hv.get('barColor')).to.be.equal('progress-success');
+ });
+ }
+ else {
+ it('completed not successful', function () {
+ expect(hv.get('obj.message')).to.be.not.equal(Em.I18n.t('installer.step9.host.status.success'));
+ expect(hv.get('barColor')).to.be.not.equal('progress-success');
+ });
+ }
});
});
});
[09/21] ambari git commit: AMBARI-15118. Fix and enable UTs
testMetricsLoaded and testServicesWithRangerPluginRoleCommandOrder (smohanty)
Posted by nc...@apache.org.
AMBARI-15118. Fix and enable UTs testMetricsLoaded and testServicesWithRangerPluginRoleCommandOrder (smohanty)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/dccacb95
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/dccacb95
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/dccacb95
Branch: refs/heads/branch-dev-patch-upgrade
Commit: dccacb9528f81c06d8e9bef85f4a0dbce6b0e507
Parents: 82d9440
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Fri Feb 19 12:28:11 2016 -0800
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Fri Feb 19 12:28:11 2016 -0800
----------------------------------------------------------------------
.../ambari/server/stack/StackManagerTest.java | 35 ++++++++++----------
1 file changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/dccacb95/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerTest.java
index 455652b..d7a15e2 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerTest.java
@@ -31,6 +31,7 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileReader;
import java.lang.reflect.Type;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -62,6 +63,7 @@ import org.apache.commons.lang.StringUtils;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
+import org.springframework.util.Assert;
/**
* StackManager unit tests.
@@ -641,12 +643,16 @@ public class StackManagerTest {
stack.getKerberosDescriptorFileLocation());
}
- @Ignore
@Test
public void testMetricsLoaded() throws Exception {
- String stackRoot = ClassLoader.getSystemClassLoader().getResource("stacks").getPath().replace("test-classes","classes");
- String commonServices = ClassLoader.getSystemClassLoader().getResource("common-services").getPath().replace("test-classes","classes");
+ URL rootDirectoryURL = StackManagerTest.class.getResource("/");
+ Assert.notNull(rootDirectoryURL);
+
+ File resourcesDirectory = new File(new File(rootDirectoryURL.getFile()).getParentFile().getParentFile(), "src/main/resources");
+
+ File stackRoot = new File(resourcesDirectory, "stacks");
+ File commonServices = new File(resourcesDirectory, "common-services");
MetainfoDAO metaInfoDao = createNiceMock(MetainfoDAO.class);
StackDAO stackDao = createNiceMock(StackDAO.class);
@@ -660,7 +666,7 @@ public class StackManagerTest {
OsFamily osFamily = new OsFamily(config);
- StackManager stackManager = new StackManager(new File(stackRoot), new File(commonServices),
+ StackManager stackManager = new StackManager(stackRoot, commonServices,
osFamily, metaInfoDao, actionMetadata, stackDao);
for (StackInfo stackInfo : stackManager.getStacks()) {
@@ -682,12 +688,15 @@ public class StackManagerTest {
}
}
- @Ignore
@Test
public void testServicesWithRangerPluginRoleCommandOrder() throws AmbariException {
- // Given
- String stackRoot = ClassLoader.getSystemClassLoader().getResource("stacks").getPath().replace("test-classes","classes");
- String commonServices = ClassLoader.getSystemClassLoader().getResource("common-services").getPath().replace("test-classes","classes");
+ URL rootDirectoryURL = StackManagerTest.class.getResource("/");
+ Assert.notNull(rootDirectoryURL);
+
+ File resourcesDirectory = new File(new File(rootDirectoryURL.getFile()).getParentFile().getParentFile(), "src/main/resources");
+
+ File stackRoot = new File(resourcesDirectory, "stacks");
+ File commonServices = new File(resourcesDirectory, "common-services");
MetainfoDAO metaInfoDao = createNiceMock(MetainfoDAO.class);
StackDAO stackDao = createNiceMock(StackDAO.class);
@@ -701,7 +710,7 @@ public class StackManagerTest {
OsFamily osFamily = new OsFamily(config);
- StackManager stackManager = new StackManager(new File(stackRoot), new File(commonServices), osFamily, metaInfoDao, actionMetadata, stackDao);
+ StackManager stackManager = new StackManager(stackRoot, commonServices, osFamily, metaInfoDao, actionMetadata, stackDao);
String rangerUserSyncRoleCommand = Role.RANGER_USERSYNC + "-" + RoleCommand.START;
String rangerAdminRoleCommand = Role.RANGER_ADMIN + "-" + RoleCommand.START;
@@ -783,14 +792,6 @@ public class StackManagerTest {
assertTrue(rangerUserSyncRoleCommand + " should be dependent of " + rangerAdminRoleCommand, rangerUserSyncBlockers.contains(rangerAdminRoleCommand));
assertTrue(rangerUserSyncRoleCommand + " should be dependent of " + kmsRoleCommand, rangerUserSyncBlockers.contains(kmsRoleCommand));
-
- // Zookeeper Server
- ArrayList<String> zookeeperBlockers = (ArrayList<String>)generalDeps.get(zookeeperServerRoleCommand);
-
- assertTrue(zookeeperServerRoleCommand + " should be dependent of " + rangerUserSyncRoleCommand, zookeeperBlockers.contains(rangerUserSyncRoleCommand));
-
}
-
-
//todo: component override assertions
}
[04/21] ambari git commit: AMBARI-15112 KAFKA display name and
components are missing in 2.4 (dsen)
Posted by nc...@apache.org.
AMBARI-15112 KAFKA display name and components are missing in 2.4 (dsen)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f000a5c4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f000a5c4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f000a5c4
Branch: refs/heads/branch-dev-patch-upgrade
Commit: f000a5c44342095fa9664518649cbf60d684783e
Parents: fca04c3
Author: Dmytro Sen <ds...@apache.org>
Authored: Fri Feb 19 20:52:36 2016 +0200
Committer: Dmytro Sen <ds...@apache.org>
Committed: Fri Feb 19 20:52:36 2016 +0200
----------------------------------------------------------------------
.../common-services/KAFKA/0.8.1.2.2/configuration/kafka-broker.xml | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/f000a5c4/ambari-server/src/main/resources/common-services/KAFKA/0.8.1.2.2/configuration/kafka-broker.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KAFKA/0.8.1.2.2/configuration/kafka-broker.xml b/ambari-server/src/main/resources/common-services/KAFKA/0.8.1.2.2/configuration/kafka-broker.xml
index 704d73f..857f40e 100644
--- a/ambari-server/src/main/resources/common-services/KAFKA/0.8.1.2.2/configuration/kafka-broker.xml
+++ b/ambari-server/src/main/resources/common-services/KAFKA/0.8.1.2.2/configuration/kafka-broker.xml
@@ -325,7 +325,6 @@
<description>Timeline port</description>
</property>
<property>
- <property>
<name>kafka.timeline.metrics.protocol</name>
<value>{{metric_collector_protocol}}</value>
<description>Timeline protocol(http or https)</description>
[05/21] ambari git commit: AMBARI-15117. After Ambari-upgrade,
Hive configurations are not showing up in Ambari UI. (jaimin)
Posted by nc...@apache.org.
AMBARI-15117. After Ambari-upgrade, Hive configurations are not showing up in Ambari UI. (jaimin)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/bd5fcae4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/bd5fcae4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/bd5fcae4
Branch: refs/heads/branch-dev-patch-upgrade
Commit: bd5fcae473fe6ad0815b3958024542a5204feefa
Parents: f000a5c
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Sat Feb 20 00:45:34 2016 +0530
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Sat Feb 20 00:46:31 2016 +0530
----------------------------------------------------------------------
.../stacks/HDP/2.2/services/stack_advisor.py | 17 ++++++++++-------
.../python/stacks/2.2/common/test_stack_advisor.py | 13 +++++++++++--
.../configs/widgets/list_config_widget_view.js | 11 +++++------
3 files changed, 26 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/bd5fcae4/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py
index dc968cc..cd25d77 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py
@@ -367,13 +367,16 @@ class HDP22StackAdvisor(HDP21StackAdvisor):
yarn_queues = "default"
capacitySchedulerProperties = {}
- if "capacity-scheduler" in services['configurations'] and "capacity-scheduler" in services['configurations']["capacity-scheduler"]["properties"]:
- properties = str(services['configurations']["capacity-scheduler"]["properties"]["capacity-scheduler"]).split('\n')
- for property in properties:
- key,sep,value = property.partition("=")
- capacitySchedulerProperties[key] = value
- if "yarn.scheduler.capacity.root.queues" in capacitySchedulerProperties:
- yarn_queues = str(capacitySchedulerProperties["yarn.scheduler.capacity.root.queues"])
+ if "capacity-scheduler" in services['configurations']:
+ if "capacity-scheduler" in services['configurations']["capacity-scheduler"]["properties"]:
+ properties = str(services['configurations']["capacity-scheduler"]["properties"]["capacity-scheduler"]).split('\n')
+ for property in properties:
+ key,sep,value = property.partition("=")
+ capacitySchedulerProperties[key] = value
+ if "yarn.scheduler.capacity.root.queues" in capacitySchedulerProperties:
+ yarn_queues = str(capacitySchedulerProperties["yarn.scheduler.capacity.root.queues"])
+ elif "yarn.scheduler.capacity.root.queues" in services['configurations']["capacity-scheduler"]["properties"]:
+ yarn_queues = services['configurations']["capacity-scheduler"]["properties"]["yarn.scheduler.capacity.root.queues"]
# Interactive Queues property attributes
putHiveServerPropertyAttribute = self.putPropertyAttribute(configurations, "hiveserver2-site")
toProcessQueues = yarn_queues.split(",")
http://git-wip-us.apache.org/repos/asf/ambari/blob/bd5fcae4/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py
index d48b78d..d230030 100644
--- a/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py
+++ b/ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py
@@ -1028,7 +1028,7 @@ class TestHDP22StackAdvisor(TestCase):
'hive-site': {
'properties': {
'hive.server2.enable.doAs': 'true',
- 'hive.server2.tez.default.queues': "default",
+ 'hive.server2.tez.default.queues': "queue1,queue2",
'hive.server2.tez.initialize.default.sessions': 'false',
'hive.server2.tez.sessions.per.default.queue': '1',
'hive.auto.convert.join.noconditionaltask.size': '268435456',
@@ -1073,7 +1073,16 @@ class TestHDP22StackAdvisor(TestCase):
'hive.server2.authentication.kerberos.keytab': {'delete': 'true'},
'hive.server2.authentication.ldap.url': {'delete': 'true'},
'hive.server2.tez.default.queues': {
- 'entries': [{'value': 'default', 'label': 'default queue'}]
+ "entries": [
+ {
+ "value": "queue1",
+ "label": "queue1 queue"
+ },
+ {
+ "value": "queue2",
+ "label": "queue2 queue"
+ }
+ ]
}
}
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/bd5fcae4/ambari-web/app/views/common/configs/widgets/list_config_widget_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/widgets/list_config_widget_view.js b/ambari-web/app/views/common/configs/widgets/list_config_widget_view.js
index fcf2aac..568c405 100644
--- a/ambari-web/app/views/common/configs/widgets/list_config_widget_view.js
+++ b/ambari-web/app/views/common/configs/widgets/list_config_widget_view.js
@@ -288,16 +288,15 @@ App.ListConfigWidgetView = App.ConfigWidgetView.extend({
},
isOptionExist: function(value) {
- var isExist = false;
- if (value !== null && value !== undefined) {
+ var isExist = true;
+ if (Em.isNone(value)) {
+ return !isExist;
+ } else {
value = Em.typeOf(value) == 'string' ? value.split(',') : value;
value.forEach(function(item) {
- isExist = this.get('options').mapProperty('value').contains(item);
+ isExist = isExist && this.get('options').mapProperty('value').contains(item);
}, this);
return isExist;
- } else {
- return false;
}
}
-
});
[17/21] ambari git commit: AMBARI-15119. Allow changing log
directories for all services (alexantonenko)
Posted by nc...@apache.org.
AMBARI-15119. Allow changing log directories for all services (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1536e42a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1536e42a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1536e42a
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 1536e42a481a2f2672b98e8278230cc24392ba83
Parents: 29d3f6c
Author: Alex Antonenko <hi...@gmail.com>
Authored: Sat Feb 20 00:09:06 2016 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Mon Feb 22 15:30:29 2016 +0200
----------------------------------------------------------------------
.../ACCUMULO/1.6.1.2.2.0/configuration/accumulo-env.xml | 1 -
.../common-services/FALCON/0.5.0.2.1/configuration/falcon-env.xml | 1 -
.../common-services/FLUME/1.4.0.2.0/configuration/flume-env.xml | 1 -
.../common-services/HBASE/0.96.0.2.0/configuration/hbase-env.xml | 1 -
.../common-services/HDFS/2.1.0.2.0/configuration/hadoop-env.xml | 1 -
.../common-services/HIVE/0.12.0.2.0/configuration/hive-env.xml | 1 -
.../common-services/OOZIE/4.0.0.2.0/configuration/oozie-env.xml | 1 -
.../YARN/2.1.0.2.0/configuration-mapred/mapred-env.xml | 1 -
.../common-services/YARN/2.1.0.2.0/configuration/yarn-env.xml | 1 -
.../ZOOKEEPER/3.4.5.2.0/configuration/zookeeper-env.xml | 1 -
.../stacks/HDP/2.2/services/HBASE/configuration/hbase-env.xml | 1 -
11 files changed, 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/1536e42a/ambari-server/src/main/resources/common-services/ACCUMULO/1.6.1.2.2.0/configuration/accumulo-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/ACCUMULO/1.6.1.2.2.0/configuration/accumulo-env.xml b/ambari-server/src/main/resources/common-services/ACCUMULO/1.6.1.2.2.0/configuration/accumulo-env.xml
index 2debf40..4f9d7bf 100644
--- a/ambari-server/src/main/resources/common-services/ACCUMULO/1.6.1.2.2.0/configuration/accumulo-env.xml
+++ b/ambari-server/src/main/resources/common-services/ACCUMULO/1.6.1.2.2.0/configuration/accumulo-env.xml
@@ -68,7 +68,6 @@
<description>Log Directories for Accumulo.</description>
<value-attributes>
<type>directory</type>
- <editable-only-at-install>true</editable-only-at-install>
<overridable>false</overridable>
</value-attributes>
</property>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1536e42a/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/configuration/falcon-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/configuration/falcon-env.xml b/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/configuration/falcon-env.xml
index 1462e6d..28fcceb 100644
--- a/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/configuration/falcon-env.xml
+++ b/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/configuration/falcon-env.xml
@@ -45,7 +45,6 @@
<description>Falcon log directory.</description>
<value-attributes>
<type>directory</type>
- <editable-only-at-install>true</editable-only-at-install>
<overridable>false</overridable>
</value-attributes>
</property>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1536e42a/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/configuration/flume-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/configuration/flume-env.xml b/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/configuration/flume-env.xml
index 440e2b6..12c0eae 100644
--- a/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/configuration/flume-env.xml
+++ b/ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/configuration/flume-env.xml
@@ -40,7 +40,6 @@
<value-attributes>
<type>directory</type>
<overridable>false</overridable>
- <editable-only-at-install>true</editable-only-at-install>
</value-attributes>
</property>
<property>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1536e42a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-env.xml b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-env.xml
index cabd4fd..fb2d876 100644
--- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-env.xml
+++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-env.xml
@@ -29,7 +29,6 @@
<value-attributes>
<type>directory</type>
<overridable>false</overridable>
- <editable-only-at-install>true</editable-only-at-install>
</value-attributes>
</property>
<property>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1536e42a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/configuration/hadoop-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/configuration/hadoop-env.xml b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/configuration/hadoop-env.xml
index 5e43b71..2feca17 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/configuration/hadoop-env.xml
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/configuration/hadoop-env.xml
@@ -29,7 +29,6 @@
<value-attributes>
<type>directory</type>
<overridable>false</overridable>
- <editable-only-at-install>true</editable-only-at-install>
</value-attributes>
</property>
<property>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1536e42a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-env.xml b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-env.xml
index 7aa4a35..14607e7 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-env.xml
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-env.xml
@@ -100,7 +100,6 @@
<value-attributes>
<type>directory</type>
<overridable>false</overridable>
- <editable-only-at-install>true</editable-only-at-install>
</value-attributes>
</property>
<property>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1536e42a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/configuration/oozie-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/configuration/oozie-env.xml b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/configuration/oozie-env.xml
index b39578f..84d8ab7 100644
--- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/configuration/oozie-env.xml
+++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/configuration/oozie-env.xml
@@ -63,7 +63,6 @@
<description>Directory for oozie logs</description>
<value-attributes>
<type>directory</type>
- <editable-only-at-install>true</editable-only-at-install>
<overridable>false</overridable>
</value-attributes>
</property>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1536e42a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/configuration-mapred/mapred-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/configuration-mapred/mapred-env.xml b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/configuration-mapred/mapred-env.xml
index 8fff1d6..27e2c0a 100644
--- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/configuration-mapred/mapred-env.xml
+++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/configuration-mapred/mapred-env.xml
@@ -29,7 +29,6 @@
<value-attributes>
<type>directory</type>
<overridable>false</overridable>
- <editable-only-at-install>true</editable-only-at-install>
</value-attributes>
</property>
<property>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1536e42a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/configuration/yarn-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/configuration/yarn-env.xml b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/configuration/yarn-env.xml
index 526af3f..3586890 100644
--- a/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/configuration/yarn-env.xml
+++ b/ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/configuration/yarn-env.xml
@@ -29,7 +29,6 @@
<value-attributes>
<type>directory</type>
<overridable>false</overridable>
- <editable-only-at-install>true</editable-only-at-install>
</value-attributes>
</property>
<property>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1536e42a/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/configuration/zookeeper-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/configuration/zookeeper-env.xml b/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/configuration/zookeeper-env.xml
index 01aeb94..9171974 100644
--- a/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/configuration/zookeeper-env.xml
+++ b/ambari-server/src/main/resources/common-services/ZOOKEEPER/3.4.5.2.0/configuration/zookeeper-env.xml
@@ -49,7 +49,6 @@
<description>ZooKeeper Pid Dir</description>
<value-attributes>
<type>directory</type>
- <editable-only-at-install>true</editable-only-at-install>
<overridable>false</overridable>
</value-attributes>
</property>
http://git-wip-us.apache.org/repos/asf/ambari/blob/1536e42a/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-env.xml b/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-env.xml
index 7aafa86..35268cd 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-env.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.2/services/HBASE/configuration/hbase-env.xml
@@ -29,7 +29,6 @@
<value-attributes>
<type>directory</type>
<overridable>false</overridable>
- <editable-only-at-install>true</editable-only-at-install>
</value-attributes>
</property>
<property>
[02/21] ambari git commit: AMBARI-15111 Alerts: email notification
should also contain server info (dsen)
Posted by nc...@apache.org.
AMBARI-15111 Alerts: email notification should also contain server info (dsen)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a0c4dcc5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a0c4dcc5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a0c4dcc5
Branch: refs/heads/branch-dev-patch-upgrade
Commit: a0c4dcc5db21903391e6bd5e819fefb921f4e3ca
Parents: 739ed20
Author: Dmytro Sen <ds...@apache.org>
Authored: Fri Feb 19 16:18:03 2016 +0200
Committer: Dmytro Sen <ds...@apache.org>
Committed: Fri Feb 19 16:18:03 2016 +0200
----------------------------------------------------------------------
.../server/configuration/Configuration.java | 12 ++++++++++++
.../services/AlertNoticeDispatchService.java | 17 +++++++++++++----
.../src/main/resources/alert-templates.xml | 20 +++++++++++++++++++-
3 files changed, 44 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/a0c4dcc5/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 cfc2f51..aec83a7 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
@@ -278,6 +278,9 @@ public class Configuration {
public static final String TEMPORARY_KEYSTORE_ACTIVELY_PURGE = "security.temporary.keystore.actibely.purge";
public static final boolean TEMPORARY_KEYSTORE_ACTIVELY_PURGE_DEFAULT = true;
+ // Alerts notifications properties
+ public static final String AMBARI_DISPLAY_URL = "ambari.display.url";
+
/**
* Key for repo validation suffixes.
*/
@@ -2481,6 +2484,15 @@ public class Configuration {
}
/**
+ * Get the ambari display URL
+ * @return
+ */
+ public String getAmbariDisplayUrl() {
+ return properties.getProperty(AMBARI_DISPLAY_URL, null);
+ }
+
+
+ /**
* @return number of retry attempts for api and blueprint operations
*/
public int getOperationsRetryAttempts() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/a0c4dcc5/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java b/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
index a27bc1d..0b84568 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/services/AlertNoticeDispatchService.java
@@ -451,7 +451,7 @@ public class AlertNoticeDispatchService extends AbstractScheduledService {
String targetType = target.getNotificationType();
// build the velocity objects for template rendering
- AmbariInfo ambari = new AmbariInfo(m_metaInfo.get());
+ AmbariInfo ambari = new AmbariInfo(m_metaInfo.get(), m_configuration);
AlertSummaryInfo summary = new AlertSummaryInfo(histories);
DispatchInfo dispatch = new DispatchInfo(target);
@@ -516,7 +516,7 @@ public class AlertNoticeDispatchService extends AbstractScheduledService {
String targetType = target.getNotificationType();
// build the velocity objects for template rendering
- AmbariInfo ambari = new AmbariInfo(m_metaInfo.get());
+ AmbariInfo ambari = new AmbariInfo(m_metaInfo.get(), m_configuration);
AlertInfo alert = new AlertInfo(history);
DispatchInfo dispatch = new DispatchInfo(target);
@@ -558,6 +558,10 @@ public class AlertNoticeDispatchService extends AbstractScheduledService {
bodyWriter.write(alert.getAlertName());
bodyWriter.write(" ");
bodyWriter.write(alert.getAlertText());
+ if (alert.hasHostName()) {
+ bodyWriter.write(" ");
+ bodyWriter.append(alert.getHostName());
+ }
bodyWriter.write("\n");
}
}
@@ -1042,7 +1046,8 @@ public class AlertNoticeDispatchService extends AbstractScheduledService {
*
* @param metaInfo
*/
- protected AmbariInfo(AmbariMetaInfo metaInfo) {
+ protected AmbariInfo(AmbariMetaInfo metaInfo, Configuration m_configuration) {
+ m_url = m_configuration.getAmbariDisplayUrl();
m_version = metaInfo.getServerVersion();
}
@@ -1053,6 +1058,10 @@ public class AlertNoticeDispatchService extends AbstractScheduledService {
return m_hostName;
}
+ public boolean hasUrl() {
+ return m_url != null;
+ }
+
/**
* @return the url
*/
@@ -1193,4 +1202,4 @@ public class AlertNoticeDispatchService extends AbstractScheduledService {
return m_body;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/a0c4dcc5/ambari-server/src/main/resources/alert-templates.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/alert-templates.xml b/ambari-server/src/main/resources/alert-templates.xml
index d7fe320..2e8fc71 100644
--- a/ambari-server/src/main/resources/alert-templates.xml
+++ b/ambari-server/src/main/resources/alert-templates.xml
@@ -158,6 +158,20 @@
<div class="label-small">
$alert.getAlertText()
</div>
+ <div class="label-small">
+ Cluster: $alert.getAlertDefinition().getCluster().getClusterName()
+ </div>
+ #if( $alert.getHostName() )
+ #if( $ambari.hasUrl() )
+ <div class="label-small">
+ Host: <a href=$ambari.getUrl()/#/main/hosts/$alert.getHostName()/summary>$ambari.getUrl()/#/main/hosts/$alert.getHostName()/summary</a>
+ </div>
+ #else
+ <div class="label-small">
+ Host: $alert.getHostName()
+ </div>
+ #end
+ #end
</td>
</tr>
#end
@@ -170,6 +184,10 @@
This notification was sent to $dispatch.getTargetName()
<br/>
Apache Ambari $ambari.getServerVersion()
+ #if( $ambari.hasUrl() )
+ <br/>
+ Ambari Server link: <a href=$ambari.getUrl()>$ambari.getUrl()</a>
+ #end
</div>
</html>
]]>
@@ -193,4 +211,4 @@
$alert.getAlertText()]]>
</body>
</alert-template>
-</alert-templates>
\ No newline at end of file
+</alert-templates>
[19/21] ambari git commit: AMBARI-15129. Oozie server unable to load
JDBC driver (aonishuk)
Posted by nc...@apache.org.
AMBARI-15129. Oozie server unable to load JDBC driver (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2a7196d7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2a7196d7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2a7196d7
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 2a7196d77bca67203e73209cf5c5f9cbdcab28ec
Parents: c8f65e3
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Mon Feb 22 18:03:01 2016 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Mon Feb 22 18:03:01 2016 +0200
----------------------------------------------------------------------
ambari-server/src/main/resources/scripts/Ambaripreupload.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/2a7196d7/ambari-server/src/main/resources/scripts/Ambaripreupload.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/scripts/Ambaripreupload.py b/ambari-server/src/main/resources/scripts/Ambaripreupload.py
index fb0c3e1..5ce75dd 100644
--- a/ambari-server/src/main/resources/scripts/Ambaripreupload.py
+++ b/ambari-server/src/main/resources/scripts/Ambaripreupload.py
@@ -279,14 +279,15 @@ with Environment() as env:
hadoop_conf_dir = params.hadoop_conf_dir
oozie_libext_dir = format("/usr/hdp/{hdp_version}/oozie/libext")
+ sql_driver_filename = os.path.basename(SQL_DRIVER_PATH)
oozie_home=format("/usr/hdp/{hdp_version}/oozie")
oozie_setup_sh=format("/usr/hdp/{hdp_version}/oozie/bin/oozie-setup.sh")
oozie_setup_sh_current="/usr/hdp/current/oozie-server/bin/oozie-setup.sh"
oozie_tmp_dir = "/var/tmp/oozie"
configure_cmds = []
configure_cmds.append(('tar','-xvf', oozie_home + '/oozie-sharelib.tar.gz','-C', oozie_home))
- configure_cmds.append(('cp', "/usr/share/HDP-oozie/ext-2.2.zip", format("/usr/hdp/{hdp_version}/oozie/libext")))
- configure_cmds.append(('chown', 'oozie:hadoop', oozie_libext_dir + "/ext-2.2.zip"))
+ configure_cmds.append(('cp', "/usr/share/HDP-oozie/ext-2.2.zip", SQL_DRIVER_PATH, oozie_libext_dir))
+ configure_cmds.append(('chown', 'oozie:hadoop', oozie_libext_dir + "/ext-2.2.zip", oozie_libext_dir + "/" + sql_driver_filename))
no_op_test = "ls /var/run/oozie/oozie.pid >/dev/null 2>&1 && ps -p `cat /var/run/oozie/oozie.pid` >/dev/null 2>&1"
[07/21] ambari git commit: AMBARI-15113. UI does not update alert
state (alexantonenko)
Posted by nc...@apache.org.
AMBARI-15113. UI does not update alert state (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/997749f7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/997749f7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/997749f7
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 997749f73d2403a634c7543e1a6d16eb3d6950e4
Parents: d207bef
Author: Alex Antonenko <hi...@gmail.com>
Authored: Fri Feb 19 19:00:25 2016 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Fri Feb 19 22:01:24 2016 +0200
----------------------------------------------------------------------
ambari-web/app/models/alerts/alert_definition.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/997749f7/ambari-web/app/models/alerts/alert_definition.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/alerts/alert_definition.js b/ambari-web/app/models/alerts/alert_definition.js
index e91bd4f..6c25f7e 100644
--- a/ambari-web/app/models/alerts/alert_definition.js
+++ b/ambari-web/app/models/alerts/alert_definition.js
@@ -41,8 +41,8 @@ App.AlertDefinition = DS.Model.extend({
groups: DS.hasMany('App.AlertGroup'),
reporting: DS.hasMany('App.AlertReportDefinition'),
parameters: DS.hasMany('App.AlertDefinitionParameter'),
- lastTriggered: DS.attr('number'),
- lastTriggeredRaw: DS.attr('number'),
+ lastTriggered: 0,
+ lastTriggeredRaw: 0,
//relates only to SCRIPT-type alert definition
location: DS.attr('string'),
[18/21] ambari git commit: AMBARI-15006. Ambari Server Upgrade adds
unneeded Atlas properties even though Atlas is not needed,
causing forced Hive restart (aonishuk)
Posted by nc...@apache.org.
AMBARI-15006. Ambari Server Upgrade adds unneeded Atlas properties even though Atlas is not needed, causing forced Hive restart (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c8f65e35
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c8f65e35
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c8f65e35
Branch: refs/heads/branch-dev-patch-upgrade
Commit: c8f65e3512c6f4095aff651936e655f013a8243e
Parents: 1536e42
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Mon Feb 22 16:27:23 2016 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Mon Feb 22 16:27:23 2016 +0200
----------------------------------------------------------------------
.../server/upgrade/UpgradeCatalog222.java | 50 +++++++++++++
.../HIVE/0.12.0.2.0/configuration/hive-site.xml | 1 +
.../services/HIVE/configuration/hive-site.xml | 2 +
.../server/upgrade/UpgradeCatalog222Test.java | 79 ++++++++++++++++++++
4 files changed, 132 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/c8f65e35/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
index 0aa1e7a..2d0b556 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
@@ -28,11 +28,15 @@ import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.utils.VersionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.SQLException;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@@ -49,6 +53,16 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
*/
private static final Logger LOG = LoggerFactory.getLogger(UpgradeCatalog222.class);
private static final String AMS_SITE = "ams-site";
+ private static final String HIVE_SITE_CONFIG = "hive-site";
+ private static final String ATLAS_APPLICATION_PROPERTIES_CONFIG = "application-properties";
+ private static final String ATLAS_HOOK_HIVE_MINTHREADS_PROPERTY = "atlas.hook.hive.minThreads";
+ private static final String ATLAS_HOOK_HIVE_MAXTHREADS_PROPERTY = "atlas.hook.hive.maxThreads";
+ private static final String ATLAS_CLUSTER_NAME_PROPERTY = "atlas.cluster.name";
+ private static final String ATLAS_ENABLETLS_PROPERTY = "atlas.enableTLS";
+ private static final String ATLAS_SERVER_HTTP_PORT_PROPERTY = "atlas.server.http.port";
+ private static final String ATLAS_SERVER_HTTPS_PORT_PROPERTY = "atlas.server.https.port";
+ private static final String ATLAS_REST_ADDRESS_PROPERTY = "atlas.rest.address";
+
private static final String HOST_AGGREGATOR_DAILY_CHECKPOINTCUTOFFMULTIPIER =
"timeline.metrics.host.aggregator.daily.checkpointCutOffMultiplier";
private static final String CLUSTER_AGGREGATOR_DAILY_CHECKPOINTCUTOFFMULTIPIER =
@@ -115,6 +129,7 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
updateAlerts();
updateStormConfigs();
updateAMSConfigs();
+ updateHiveConfig();
updateHostRoleCommands();
}
@@ -285,6 +300,41 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
}
}
+ protected void updateHiveConfig() throws AmbariException {
+ AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
+ for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values()) {
+ Config hiveSiteConfig = cluster.getDesiredConfigByType(HIVE_SITE_CONFIG);
+ Config atlasConfig = cluster.getDesiredConfigByType(ATLAS_APPLICATION_PROPERTIES_CONFIG);
+
+ StackId stackId = cluster.getCurrentStackVersion();
+ boolean isStackNotLess23 = (stackId != null && stackId.getStackName().equals("HDP") &&
+ VersionUtils.compareVersions(stackId.getStackVersion(), "2.3") >= 0);
+
+ List<ServiceComponentHost> atlasHost = cluster.getServiceComponentHosts("ATLAS", "ATLAS_SERVER");
+ Map<String, String> updates = new HashMap<String, String>();
+
+ if (isStackNotLess23 && atlasHost.size() != 0 && hiveSiteConfig != null) {
+
+ updates.put(ATLAS_HOOK_HIVE_MINTHREADS_PROPERTY, "1");
+ updates.put(ATLAS_HOOK_HIVE_MAXTHREADS_PROPERTY, "1");
+ updates.put(ATLAS_CLUSTER_NAME_PROPERTY, "primary");
+
+ if (atlasConfig != null && atlasConfig.getProperties().containsKey(ATLAS_ENABLETLS_PROPERTY)) {
+ String atlasEnableTLSProperty = atlasConfig.getProperties().get(ATLAS_ENABLETLS_PROPERTY);
+ String atlasScheme = "http";
+ String atlasServerHttpPortProperty = atlasConfig.getProperties().get(ATLAS_SERVER_HTTP_PORT_PROPERTY);
+ if (atlasEnableTLSProperty.toLowerCase().equals("true")) {
+ atlasServerHttpPortProperty = atlasConfig.getProperties().get(ATLAS_SERVER_HTTPS_PORT_PROPERTY);
+ atlasScheme = "https";
+ }
+ updates.put(ATLAS_REST_ADDRESS_PROPERTY, String.format("%s://%s:%s", atlasScheme, atlasHost.get(0).getHostName(), atlasServerHttpPortProperty));
+ }
+ updateConfigurationPropertiesForCluster(cluster, HIVE_SITE_CONFIG, updates, false, false);
+ }
+ }
+ }
+
+
private String convertToDaysIfInSeconds(String secondsString) {
int seconds = Integer.valueOf(secondsString);
http://git-wip-us.apache.org/repos/asf/ambari/blob/c8f65e35/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-site.xml b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-site.xml
index 4087c72..c63c289 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-site.xml
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/configuration/hive-site.xml
@@ -434,6 +434,7 @@ limitations under the License.
<property>
<name>atlas.cluster.name</name>
+ <property-type>DONT_ADD_ON_UPGRADE</property-type>
<value>primary</value>
<depends-on>
<property>
http://git-wip-us.apache.org/repos/asf/ambari/blob/c8f65e35/ambari-server/src/main/resources/stacks/HDP/2.3/services/HIVE/configuration/hive-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/services/HIVE/configuration/hive-site.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/services/HIVE/configuration/hive-site.xml
index a611386..de2813c 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/services/HIVE/configuration/hive-site.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/services/HIVE/configuration/hive-site.xml
@@ -42,6 +42,7 @@ limitations under the License.
<property>
<name>atlas.hook.hive.minThreads</name>
+ <property-type>DONT_ADD_ON_UPGRADE</property-type>
<value>1</value>
<description>
Minimum number of threads maintained by Atlas hook.
@@ -49,6 +50,7 @@ limitations under the License.
</property>
<property>
+ <property-type>DONT_ADD_ON_UPGRADE</property-type>
<name>atlas.hook.hive.maxThreads</name>
<value>1</value>
<description>
http://git-wip-us.apache.org/repos/asf/ambari/blob/c8f65e35/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
index 077df33..2b95cd9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
@@ -20,7 +20,9 @@ package org.apache.ambari.server.upgrade;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.persistence.EntityManager;
@@ -41,6 +43,8 @@ import org.apache.ambari.server.orm.entities.StackEntity;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.StackId;
import org.apache.ambari.server.state.stack.OsFamily;
import org.easymock.Capture;
import org.easymock.EasyMock;
@@ -51,12 +55,14 @@ import org.junit.Test;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
+import com.google.inject.AbstractModule;
import com.google.inject.Binder;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.Provider;
import com.google.inject.persist.PersistService;
+import org.apache.ambari.server.AmbariException;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.anyString;
@@ -108,6 +114,7 @@ public class UpgradeCatalog222Test {
Method updateAlerts = UpgradeCatalog222.class.getDeclaredMethod("updateAlerts");
Method updateStormConfigs = UpgradeCatalog222.class.getDeclaredMethod("updateStormConfigs");
Method updateAMSConfigs = UpgradeCatalog222.class.getDeclaredMethod("updateAMSConfigs");
+ Method updateHiveConfigs = UpgradeCatalog222.class.getDeclaredMethod("updateHiveConfig");
Method updateHostRoleCommands = UpgradeCatalog222.class.getDeclaredMethod("updateHostRoleCommands");
@@ -116,6 +123,7 @@ public class UpgradeCatalog222Test {
.addMockedMethod(updateAlerts)
.addMockedMethod(updateStormConfigs)
.addMockedMethod(updateAMSConfigs)
+ .addMockedMethod(updateHiveConfigs)
.addMockedMethod(updateHostRoleCommands)
.createMock();
@@ -129,6 +137,8 @@ public class UpgradeCatalog222Test {
expectLastCall().once();
upgradeCatalog222.updateHostRoleCommands();
expectLastCall().once();
+ upgradeCatalog222.updateHiveConfig();
+ expectLastCall().once();
replay(upgradeCatalog222);
@@ -138,6 +148,75 @@ public class UpgradeCatalog222Test {
}
@Test
+ public void testHiveSiteUpdateConfigs() throws AmbariException {
+ EasyMockSupport easyMockSupport = new EasyMockSupport();
+ final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
+ final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
+ final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
+
+ final Config hiveSiteConfigs = easyMockSupport.createNiceMock(Config.class);
+ final Config AtlasSiteConfigs = easyMockSupport.createNiceMock(Config.class);
+
+ final ServiceComponentHost atlasHost = easyMockSupport.createNiceMock(ServiceComponentHost.class);
+ final List<ServiceComponentHost> atlasHosts = new ArrayList<>();
+ atlasHosts.add(atlasHost);
+
+ StackId stackId = new StackId("HDP","2.3");
+
+ final Map<String, String> propertiesAtlasSiteConfigs = new HashMap<String, String>() {{
+ put("atlas.enableTLS", "true");
+ put("atlas.server.https.port", "21443");
+ }};
+
+ final Injector mockInjector = Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
+ bind(Clusters.class).toInstance(mockClusters);
+ bind(EntityManager.class).toInstance(entityManager);
+ bind(ServiceComponentHost.class).toInstance(atlasHost);
+
+ bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
+ bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+ }
+ });
+
+ expect(mockClusterExpected.getCurrentStackVersion()).andReturn(stackId).once();
+ expect(mockClusterExpected.getServiceComponentHosts("ATLAS", "ATLAS_SERVER")).andReturn(atlasHosts).once();
+ expect(atlasHost.getHostName()).andReturn("c6401").once();
+ expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
+ expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
+ put("normal", mockClusterExpected);
+ }}).atLeastOnce();
+ expect(mockClusterExpected.getDesiredConfigByType("hive-site")).andReturn(hiveSiteConfigs).atLeastOnce();
+ expect(mockClusterExpected.getDesiredConfigByType("application-properties")).andReturn(AtlasSiteConfigs).anyTimes();
+ expect(AtlasSiteConfigs.getProperties()).andReturn(propertiesAtlasSiteConfigs).anyTimes();
+
+ UpgradeCatalog222 upgradeCatalog222 = createMockBuilder(UpgradeCatalog222.class)
+ .withConstructor(Injector.class)
+ .withArgs(mockInjector)
+ .addMockedMethod("updateConfigurationPropertiesForCluster", Cluster.class, String.class,
+ Map.class, boolean.class, boolean.class)
+ .createMock();
+
+ Map<String, String> expectedUpdates = new HashMap<>();
+ expectedUpdates.put("atlas.hook.hive.minThreads", "1");
+ expectedUpdates.put("atlas.hook.hive.maxThreads", "1");
+ expectedUpdates.put("atlas.cluster.name", "primary");
+ expectedUpdates.put("atlas.rest.address", "https://c6401:21443");
+
+ upgradeCatalog222.updateConfigurationPropertiesForCluster(mockClusterExpected, "hive-site", expectedUpdates,
+ false, false);
+ expectLastCall().once();
+
+ easyMockSupport.replayAll();
+ replay(upgradeCatalog222);
+ upgradeCatalog222.updateHiveConfig();
+ easyMockSupport.verifyAll();
+ }
+
+
+ @Test
public void testAmsSiteUpdateConfigs() throws Exception{
Map<String, String> oldPropertiesAmsSite = new HashMap<String, String>() {