Browse Source

Revert "AMBARI-8770 [WinGA] Add windows server assembly for AMS. Unit test failure on CentOS."

This reverts commit 19e972cf98423200bf30518803f066669f2dcd2a.
Siddharth Wagle 10 years ago
parent
commit
ab8c0e350f
35 changed files with 105 additions and 2210 deletions
  1. 1 1
      ambari-agent/conf/windows/service_wrapper.py
  2. 8 9
      ambari-common/src/main/python/ambari_commons/os_utils.py
  3. 9 12
      ambari-common/src/main/python/ambari_commons/os_windows.py
  4. 0 33
      ambari-common/src/main/python/ambari_commons/xml_utils.py
  5. 4 73
      ambari-metrics/ambari-metrics-assembly/pom.xml
  6. 0 101
      ambari-metrics/ambari-metrics-assembly/src/main/assembly/collector-windows.xml
  7. 0 84
      ambari-metrics/ambari-metrics-assembly/src/main/assembly/monitor-windows.xml
  8. 1 1
      ambari-metrics/ambari-metrics-assembly/src/main/assembly/monitor.xml
  9. 0 60
      ambari-metrics/ambari-metrics-assembly/src/main/assembly/sink-windows.xml
  10. 0 17
      ambari-metrics/ambari-metrics-host-monitoring/conf/windows/ambari-metrics-monitor.cmd
  11. 0 19
      ambari-metrics/ambari-metrics-host-monitoring/conf/windows/metric_groups.conf
  12. 0 30
      ambari-metrics/ambari-metrics-host-monitoring/conf/windows/metric_monitor.ini
  13. 44 102
      ambari-metrics/ambari-metrics-host-monitoring/pom.xml
  14. 0 231
      ambari-metrics/ambari-metrics-host-monitoring/src/main/python/amhm_service.py
  15. 1 2
      ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/__init__.py
  16. 2 64
      ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/config_reader.py
  17. 6 21
      ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/controller.py
  18. 4 13
      ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/emitter.py
  19. 0 138
      ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/stop_handler.py
  20. 9 49
      ambari-metrics/ambari-metrics-host-monitoring/src/main/python/main.py
  21. 0 17
      ambari-metrics/ambari-metrics-timelineservice/conf/windows/ambari-metrics-collector.cmd
  22. 0 16
      ambari-metrics/ambari-metrics-timelineservice/conf/windows/ams-env.cmd
  23. 0 25
      ambari-metrics/ambari-metrics-timelineservice/conf/windows/ams-site.xml
  24. 0 17
      ambari-metrics/ambari-metrics-timelineservice/conf/windows/ams.properties
  25. 0 29
      ambari-metrics/ambari-metrics-timelineservice/conf/windows/log4j.properties
  26. 0 31
      ambari-metrics/ambari-metrics-timelineservice/pom.xml
  27. 0 21
      ambari-metrics/ambari-metrics-timelineservice/src/main/python/ambari_metrics_collector/__init__.py
  28. 0 223
      ambari-metrics/ambari-metrics-timelineservice/src/main/python/ambari_metrics_collector/properties.py
  29. 0 152
      ambari-metrics/ambari-metrics-timelineservice/src/main/python/ambari_metrics_collector/serviceConfiguration.py
  30. 0 174
      ambari-metrics/ambari-metrics-timelineservice/src/main/python/amc_service.py
  31. 0 201
      ambari-metrics/ambari-metrics-timelineservice/src/main/python/embedded_hbase_service.py
  32. 0 214
      ambari-metrics/ambari-metrics-timelineservice/src/main/python/main.py
  33. 0 27
      ambari-metrics/pom.xml
  34. 16 1
      ambari-server/src/main/python/ambari-server-state/Entities.py
  35. 0 2
      pom.xml

+ 1 - 1
ambari-agent/conf/windows/service_wrapper.py

@@ -92,7 +92,7 @@ class AmbariAgentService(AmbariService):
     # Soft dependency on the Windows Time service
     ensure_time_service_is_started()
 
-    self.heartbeat_stop_handler = HeartbeatStopHandlers(AmbariAgentService._heventSvcStop)
+    self.heartbeat_stop_handler = HeartbeatStopHandlers(self._heventSvcStop)
 
     self.ReportServiceStatus(win32service.SERVICE_RUNNING)
 

+ 8 - 9
ambari-common/src/main/python/ambari_commons/os_utils.py

@@ -48,17 +48,14 @@ def quote_path(filepath):
     filepath_ret = filepath
   return filepath_ret
 
-def _search_file(filename, search_path, pathsep):
+def search_file(filename, search_path, pathsep=os.pathsep):
+  """ Given a search path, find file with requested name """
   for path in string.split(search_path, pathsep):
     candidate = os.path.join(path, filename)
     if os.path.exists(candidate):
       return os.path.abspath(candidate)
   return None
 
-def search_file(filename, search_path, pathsep=os.pathsep):
-  """ Given a search path, find file with requested name """
-  return _search_file(filename, search_path, pathsep)
-
 def copy_file(src, dest_file):
   try:
     shutil.copyfile(src, dest_file)
@@ -106,7 +103,9 @@ def get_password(prompt):
   return os_getpass(prompt)
 
 def find_in_path(file):
-  full_path = _search_file(file, os.environ["PATH"], os.pathsep)
-  if full_path is None:
-    raise Exception("File {0} not found in PATH".format(file))
-  return full_path
+  dirs = os.environ["PATH"].split(os.pathsep)
+  for dir in dirs:
+    full_path = os.path.join(dir, file)
+    if os.path.exists(full_path):
+      return full_path
+  raise Exception("File {} not found in PATH".format(file))

+ 9 - 12
ambari-common/src/main/python/ambari_commons/os_windows.py

@@ -402,7 +402,7 @@ class WinService(win32serviceutil.ServiceFramework):
   # _svc_display_name_ = The service display name
   # _svc_description_ = The service description
 
-  _heventSvcStop = win32event.CreateEvent(None, 1, 0, None)
+  _heventSvcStop = win32event.CreateEvent(None, 0, 0, None)
   _hmtxOut = win32event.CreateMutex(None, False, None)  #[fbarca] Python doesn't support critical sections
 
   def __init__(self, *args):
@@ -418,18 +418,17 @@ class WinService(win32serviceutil.ServiceFramework):
 
   def SvcStop(self):
     self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
-    win32event.SetEvent(WinService._heventSvcStop)
+    win32event.SetEvent(self._heventSvcStop)
 
   # Service code entry point. Override it to implement the intended functionality.
   def ServiceMain(self):
     #Default implementation, does nothing.
-    win32event.WaitForSingleObject(WinService._heventSvcStop, win32event.INFINITE)
+    win32event.WaitForSingleObject(self._heventSvcStop, win32event.INFINITE)
     pass
 
-  @staticmethod
-  def DefCtrlCHandler():
+  def DefCtrlCHandler(self):
     print_info_msg("Ctrl+C handler invoked. Stopping.")
-    win32event.SetEvent(WinService._heventSvcStop)
+    win32event.SetEvent(self._heventSvcStop)
     pass
 
   #username domain\\username : The Username the service is to run under
@@ -439,7 +438,7 @@ class WinService(win32serviceutil.ServiceFramework):
   #perfmonini file: .ini file to use for registering performance monitor data
   #perfmondll file: .dll file to use when querying the service for performance data, default = perfmondata.dll
   @classmethod
-  def Install(cls, classPath = None, startupMode = "auto", username = None, password = None, interactive = False,
+  def Install(cls, startupMode = "auto", username = None, password = None, interactive = False,
               perfMonIni = None, perfMonDll = None):
     installArgs = [sys.argv[0], "--startup=" + startupMode]
     if username is not None and username:
@@ -453,8 +452,7 @@ class WinService(win32serviceutil.ServiceFramework):
     if perfMonDll is not None and perfMonDll:
       installArgs.append("--perfmondll=" + perfMonDll)
     installArgs.append("install")
-
-    win32serviceutil.HandleCommandLine(cls, classPath, installArgs)
+    win32serviceutil.HandleCommandLine(cls, None, installArgs)
 
   @classmethod
   def Start(cls, waitSecs = 30):
@@ -485,12 +483,11 @@ class WinService(win32serviceutil.ServiceFramework):
 
   def CheckForStop(self):
     #Check for stop event to be signaled
-    return win32event.WAIT_OBJECT_0 == win32event.WaitForSingleObject(WinService._heventSvcStop, 1)
+    return win32event.WAIT_OBJECT_0 == win32event.WaitForSingleObject(self._heventSvcStop, 1)
 
   def _StopOrWaitForChildProcessToFinish(self, childProcess):
     #Wait for the child process to finish or for the stop event to be signaled
-    if(win32event.WAIT_OBJECT_0 == win32event.WaitForMultipleObjects([WinService._heventSvcStop, childProcess._handle],
-                                                                     False, win32event.INFINITE)):
+    if(win32event.WAIT_OBJECT_0 == win32event.WaitForMultipleObjects([self._heventSvcStop, childProcess._handle], False, win32event.INFINITE)):
       # The OS only detaches the child process when the master process exits.
       # We must kill it manually.
       try:

+ 0 - 33
ambari-common/src/main/python/ambari_commons/xml_utils.py

@@ -1,33 +0,0 @@
-# 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.
-
-import inspect
-import os
-
-class ConvertToXml:
-  "Template class, allow to output fields in xml format"
-  def getField(self):
-    return [name for name, obj in inspect.getmembers(self)
-            if not name.startswith("__") and not inspect.isroutine(obj)]
-
-  def attributesToXml(self):
-    result = ""
-    listOfAttr = self.getField()
-    for attrName in listOfAttr:
-      result += "<" + attrName + ">"
-      result += str(getattr(self, attrName))
-      result += "</" + attrName + ">\n"
-    return result

+ 4 - 73
ambari-metrics/ambari-metrics-assembly/pom.xml

@@ -26,9 +26,9 @@
     <version>0.1.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
+
   <artifactId>ambari-metrics-assembly</artifactId>
   <packaging>pom</packaging>
-  <version>0.1.0-SNAPSHOT</version>
 
   <properties>
     <collector.dir>${project.basedir}/../ambari-metrics-timelineservice</collector.dir>
@@ -47,33 +47,6 @@
 
   <build>
     <plugins>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <version>1.8</version>
-        <executions>
-          <execution>
-            <id>parse-version</id>
-            <phase>validate</phase>
-            <goals>
-              <goal>parse-version</goal>
-            </goals>
-          </execution>
-          <execution>
-            <id>regex-property</id>
-            <goals>
-              <goal>regex-property</goal>
-            </goals>
-            <configuration>
-              <name>ambariVersion</name>
-              <value>${project.version}</value>
-              <regex>^([0-9]+)\.([0-9]+)\.([0-9]+)(\.|-).*</regex>
-              <replacement>$1.$2.$3</replacement>
-              <failIfNoMatch>false</failIfNoMatch>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
       <plugin>
         <artifactId>maven-resources-plugin</artifactId>
         <version>2.7</version>
@@ -121,7 +94,7 @@
               <finalName>ambari-metrics-collector-${project.version}</finalName>
               <appendAssemblyId>false</appendAssemblyId>
               <descriptors>
-                <descriptor>${assemblydescriptor.collector}</descriptor>
+                <descriptor>src/main/assembly/collector.xml</descriptor>
               </descriptors>
               <tarLongFileMode>gnu</tarLongFileMode>
             </configuration>
@@ -137,7 +110,7 @@
               <finalName>ambari-metrics-monitor-${project.version}</finalName>
               <appendAssemblyId>false</appendAssemblyId>
               <descriptors>
-                <descriptor>${assemblydescriptor.monitor}</descriptor>
+                <descriptor>src/main/assembly/monitor.xml</descriptor>
               </descriptors>
               <tarLongFileMode>gnu</tarLongFileMode>
             </configuration>
@@ -153,7 +126,7 @@
               <finalName>ambari-metrics-hadoop-sink-${project.version}</finalName>
               <appendAssemblyId>false</appendAssemblyId>
               <descriptors>
-                <descriptor>${assemblydescriptor.sink}</descriptor>
+                <descriptor>src/main/assembly/sink.xml</descriptor>
               </descriptors>
               <tarLongFileMode>gnu</tarLongFileMode>
             </configuration>
@@ -737,48 +710,6 @@
         </plugins>
       </build>
     </profile>
-    <profile>
-      <id>windows</id>
-      <activation>
-        <os>
-          <family>win</family>
-        </os>
-      </activation>
-      <properties>
-        <envClassifier>win</envClassifier>
-        <dirsep>\</dirsep>
-        <pathsep>;</pathsep>
-        <executable.python>python</executable.python>
-        <executable.shell>cmd</executable.shell>
-        <fileextension.shell>cmd</fileextension.shell>
-        <fileextension.dot.shell-default>.cmd</fileextension.dot.shell-default>
-        <assemblydescriptor.collector>src/main/assembly/collector-windows.xml</assemblydescriptor.collector>
-        <assemblydescriptor.monitor>src/main/assembly/monitor-windows.xml</assemblydescriptor.monitor>
-        <assemblydescriptor.sink>src/main/assembly/sink-windows.xml</assemblydescriptor.sink>
-        <packagingFormat>jar</packagingFormat>
-      </properties>
-    </profile>
-    <profile>
-      <id>linux</id>
-      <activation>
-        <os>
-          <family>unix</family>
-        </os>
-      </activation>
-      <properties>
-        <envClassifier>linux</envClassifier>
-        <dirsep>/</dirsep>
-        <pathsep>:</pathsep>
-        <executable.python>${project.basedir}/../ambari-common/src/main/unix/ambari-python-wrap</executable.python>
-        <executable.shell>sh</executable.shell>
-        <fileextension.shell>sh</fileextension.shell>
-        <fileextension.dot.shell-default></fileextension.dot.shell-default>
-        <assemblydescriptor.collector>src/main/assembly/collector.xml</assemblydescriptor.collector>
-        <assemblydescriptor.monitor>src/main/assembly/monitor.xml</assemblydescriptor.monitor>
-        <assemblydescriptor.sink>src/main/assembly/sink.xml</assemblydescriptor.sink>
-        <packagingFormat>jar</packagingFormat>
-      </properties>
-    </profile>
   </profiles>
 
 

+ 0 - 101
ambari-metrics/ambari-metrics-assembly/src/main/assembly/collector-windows.xml

@@ -1,101 +0,0 @@
-<?xml version="1.0"?>
-
-<!--
-  ~ 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.
-  -->
-
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd">
-  <id>collector</id>
-  <formats>
-    <format>dir</format>
-  </formats>
-  <includeBaseDirectory>false</includeBaseDirectory>
-  <fileSets>
-    <fileSet>
-      <directory>${collector.dir}/target/embedded/${hbase.folder}</directory>
-      <outputDirectory>hbase</outputDirectory>
-    </fileSet>
-    <fileSet>
-      <directory>${collector.dir}/conf/windows</directory>
-      <outputDirectory>/</outputDirectory>
-      <includes>
-        <include>ambari-metrics-collector.cmd</include>
-      </includes>
-    </fileSet>
-    <fileSet>
-      <directory>${collector.dir}/conf/windows</directory>
-      <outputDirectory>conf</outputDirectory>
-      <includes>
-        <include>ams.properties</include>
-        <include>ams-env.cmd</include>
-        <include>ams-site.xml</include>
-        <include>log4j.properties</include>
-      </includes>
-    </fileSet>
-    <fileSet>
-      <directory>${collector.dir}/target/lib</directory>
-      <outputDirectory>lib</outputDirectory>
-    </fileSet>
-    <fileSet>
-      <directory>${collector.dir}/src/main/python</directory>
-      <outputDirectory>/sbin</outputDirectory>
-      <includes>
-        <include>*.py</include>
-      </includes>
-    </fileSet>
-    <fileSet>
-      <directory>${collector.dir}/src/main/python/ambari_metrics_collector</directory>
-      <outputDirectory>/sbin/ambari_metrics_collector</outputDirectory>
-      <includes>
-        <include>*.py</include>
-      </includes>
-    </fileSet>
-    <fileSet>
-      <directory>${project.basedir}/../../ambari-common/src/main/python/ambari_commons</directory>
-      <outputDirectory>/sbin/ambari_commons</outputDirectory>
-      <includes>
-        <include>*.py</include>
-      </includes>
-    </fileSet>
-    <fileSet>
-      <directory>${project.basedir}/../../ambari-common/src/main/python/ambari_commons/resources</directory>
-      <outputDirectory>/sbin/ambari_commons/resources</outputDirectory>
-      <includes>
-        <include>*.json</include>
-      </includes>
-    </fileSet>
-  </fileSets>
-  <dependencySets>
-    <dependencySet>
-      <unpack>false</unpack>
-      <outputDirectory>hbase/lib</outputDirectory>
-      <useProjectArtifact>false</useProjectArtifact>
-      <includes>
-        <include>org.antlr:antlr*</include>
-        <include>org.apache.phoenix:phoenix-core</include>
-      </includes>
-    </dependencySet>
-    <dependencySet>
-      <unpack>false</unpack>
-      <outputDirectory>lib</outputDirectory>
-      <useProjectArtifact>false</useProjectArtifact>
-      <includes>
-        <include>org.apache.ambari:ambari-metrics-timelineservice</include>
-      </includes>
-    </dependencySet>
-  </dependencySets>
-</assembly>

+ 0 - 84
ambari-metrics/ambari-metrics-assembly/src/main/assembly/monitor-windows.xml

@@ -1,84 +0,0 @@
-<!--
-  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.
--->
-<assembly>
-    <id>windows-dist</id>
-  <formats>
-    <format>dir</format>
-  </formats>
-  <includeBaseDirectory>false</includeBaseDirectory>
-  <fileSets>
-    <fileSet>
-      <directory>${monitor.dir}/src/main/python</directory>
-      <outputDirectory>/sbin</outputDirectory>
-      <includes>
-        <include>*.py</include>
-      </includes>
-    </fileSet>
-    <fileSet>
-      <directory>${project.basedir}/../../ambari-common/src/main/python/ambari_commons</directory>
-      <outputDirectory>/sbin/ambari_commons</outputDirectory>
-      <includes>
-        <include>*.py</include>
-      </includes>
-    </fileSet>
-    <fileSet>
-      <directory>${project.basedir}/../../ambari-common/src/main/python/ambari_commons/resources</directory>
-      <outputDirectory>/sbin/ambari_commons/resources</outputDirectory>
-      <includes>
-        <include>*.json</include>
-      </includes>
-    </fileSet>
-    <fileSet>
-      <directory>${monitor.dir}/src/main/python/core</directory>
-      <outputDirectory>/sbin/core</outputDirectory>
-      <includes>
-        <include>*.py</include>
-      </includes>
-    </fileSet>
-    <fileSet>
-      <directory>${monitor.dir}/target/psutil_build</directory>
-      <outputDirectory>/sbin/psutil/build</outputDirectory>
-      <includes>
-        <include>*.egg</include>
-      </includes>
-    </fileSet>
-    <fileSet>
-      <directory>${monitor.dir}/conf/windows</directory>
-      <outputDirectory>conf</outputDirectory>
-      <includes>
-        <include>metric_groups.conf</include>
-        <include>metric_monitor.ini</include>
-      </includes>
-    </fileSet>
-    <fileSet>
-      <directory>${monitor.dir}/conf/windows</directory>
-      <outputDirectory>/</outputDirectory>
-      <includes>
-        <include>ambari-metrics-monitor.cmd</include>
-      </includes>
-    </fileSet>
-  </fileSets>
-  <dependencySets>
-    <dependencySet>
-      <useProjectArtifact>false</useProjectArtifact>
-      <excludes>
-        <exclude>*</exclude>
-      </excludes>
-    </dependencySet>
-  </dependencySets>
-</assembly>

+ 1 - 1
ambari-metrics/ambari-metrics-assembly/src/main/assembly/monitor.xml

@@ -31,8 +31,8 @@
       <outputDirectory>site-packages/resource_monitoring</outputDirectory>
     </fileSet>
     <fileSet>
-      <directory>${monitor.dir}/conf/unix</directory>
       <outputDirectory>conf</outputDirectory>
+      <directory>${monitor.dir}/conf/unix</directory>
       <includes>
         <include>metric_groups.conf</include>
         <include>metric_monitor.ini</include>

+ 0 - 60
ambari-metrics/ambari-metrics-assembly/src/main/assembly/sink-windows.xml

@@ -1,60 +0,0 @@
-<?xml version="1.0"?>
-
-<!--
-  ~ 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.
-  -->
-
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd">
-  <id>hadoop-sink</id>
-  <formats>
-    <format>dir</format>
-  </formats>
-  <includeBaseDirectory>false</includeBaseDirectory>
-  <fileSets>
-    <fileSet>
-      <directory>${hadoop-sink.dir}/src/main/conf</directory>
-      <outputDirectory>hadoop-sink/conf</outputDirectory>
-    </fileSet>
-    <fileSet>
-      <directory>${flume-sink.dir}/src/main/conf</directory>
-      <outputDirectory>hadoop-sink/conf</outputDirectory>
-    </fileSet>
-    <fileSet>
-      <directory>${storm-sink.dir}/src/main/conf</directory>
-      <outputDirectory>hadoop-sink/conf</outputDirectory>
-    </fileSet>
-  </fileSets>
-
-  <files>
-    <file>
-      <source>${hadoop-sink.dir}/target/ambari-metrics-hadoop-sink-with-common-${project.version}.jar</source>
-      <outputDirectory>hadoop-sink</outputDirectory>
-    </file>
-    <file>
-      <source>${flume-sink.dir}/target/ambari-metrics-flume-sink-with-common-${project.version}.jar</source>
-      <outputDirectory>hadoop-sink</outputDirectory>
-    </file>
-    <file>
-      <source>${storm-sink.dir}/target/ambari-metrics-storm-sink-with-common-${project.version}.jar</source>
-      <outputDirectory>hadoop-sink</outputDirectory>
-    </file>
-  </files>
-
-
-
-
-</assembly>

+ 0 - 17
ambari-metrics/ambari-metrics-host-monitoring/conf/windows/ambari-metrics-monitor.cmd

@@ -1,17 +0,0 @@
-@rem Licensed to the Apache Software Foundation (ASF) under one or more
-@rem contributor license agreements.  See the NOTICE file distributed with
-@rem this work for additional information regarding copyright ownership.
-@rem The ASF licenses this file to You under the Apache License, Version 2.0
-@rem (the "License"); you may not use this file except in compliance with
-@rem the License.  You may obtain a copy of the License at
-@rem
-@rem     http://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-
-@echo off
-python.exe -u %~dp0\sbin\amhm_service.py %* 2>&1

+ 0 - 19
ambari-metrics/ambari-metrics-host-monitoring/conf/windows/metric_groups.conf

@@ -1,19 +0,0 @@
-{
-   "host_metric_groups": {
-      "all": {
-         "collect_every": "10",
-         "metrics": [
-            {
-               "name": "bytes_out",
-               "value_threshold": "128"
-            }
-         ]
-      }
-   },
-   "process_metric_groups": {
-      "": {
-         "collect_every": "15",
-         "metrics": []
-      }
-   }
-}

+ 0 - 30
ambari-metrics/ambari-metrics-host-monitoring/conf/windows/metric_monitor.ini

@@ -1,30 +0,0 @@
-;
-; 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.
-;
-
-[default]
-debug_level = INFO
-metrics_server = {{ams_collector_host_single}}:{{ams_collector_port}}
-enable_time_threshold = false
-enable_value_threshold = false
-
-[emitter]
-send_interval = 60
-
-[collector]
-collector_sleep_interval = 5
-max_queue_size = 5000

+ 44 - 102
ambari-metrics/ambari-metrics-host-monitoring/pom.xml

@@ -32,7 +32,6 @@
     <resmonitor.install.dir>
       /usr/lib/python2.6/site-packages/resource_monitoring
     </resmonitor.install.dir>
-    <final.name>${project.artifactId}-${project.version}</final.name>
   </properties>
   <build>
     <plugins>
@@ -82,13 +81,56 @@
         <artifactId>maven-compiler-plugin</artifactId>
         <version>3.0</version>
       </plugin>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <tarLongFileMode>gnu</tarLongFileMode>
+          <descriptors>
+            <descriptor>${project.basedir}/../../ambari-project/src/main/assemblies/empty.xml</descriptor>
+          </descriptors>
+        </configuration>
+        <executions>
+          <execution>
+            <id>build-tarball</id>
+            <phase>none</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <version>1.7</version>
+        <executions>
+          <execution>
+            <id>psutils-compile</id>
+            <phase>process-test-classes</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <target name="psutils-compile">
+                <exec dir="${basedir}/src/main/python/psutil" executable="${project.basedir}/../../ambari-common/src/main/unix/ambari-python-wrap" failonerror="true">
+                  <arg value="setup.py" />
+                  <arg value="build" />
+                  <arg value="--build-platlib" />
+                  <arg value="${basedir}/target/psutil_build" />
+                </exec>
+              </target>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>exec-maven-plugin</artifactId>
         <executions>
           <execution>
             <configuration>
-              <executable>${executable.python}</executable>
+              <executable>${project.basedir}/../../ambari-common/src/main/unix/ambari-python-wrap</executable>
               <workingDirectory>src/test/python</workingDirectory>
               <arguments>
                 <argument>unitTests.py</argument>
@@ -111,8 +153,6 @@
         <artifactId>apache-rat-plugin</artifactId>
         <configuration>
           <excludes>
-            <exclude>conf/unix/metric_groups.conf</exclude>
-            <exclude>conf/windows/metric_groups.conf</exclude>
             <exclude>src/main/python/psutil/**</exclude>
             <exclude>.pydevproject</exclude>
           </excludes>
@@ -128,102 +168,4 @@
       </plugin>
     </plugins>
   </build>
-  <profiles>
-    <profile>
-      <id>windows</id>
-      <activation>
-        <os>
-          <family>win</family>
-        </os>
-      </activation>
-      <properties>
-        <envClassifier>win</envClassifier>
-        <dirsep>\</dirsep>
-        <pathsep>;</pathsep>
-        <executable.python>python</executable.python>
-        <executable.shell>cmd</executable.shell>
-        <fileextension.shell>cmd</fileextension.shell>
-        <fileextension.dot.shell-default>.cmd</fileextension.dot.shell-default>
-        <assemblydescriptor>src/main/assemblies/amhm-windows.xml</assemblydescriptor>
-        <packagingFormat>jar</packagingFormat>
-      </properties>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-antrun-plugin</artifactId>
-            <version>1.7</version>
-            <executions>
-              <execution>
-                <id>psutils-compile</id>
-                <phase>process-test-classes</phase>
-                <goals>
-                  <goal>run</goal>
-                </goals>
-                <configuration>
-                  <target name="psutils-compile">
-                    <exec dir="${basedir}/src/main/python/psutil" executable="python" failonerror="true">
-                      <arg value="setup.py" />
-                      <arg value="bdist_egg" />
-                      <arg value="--bdist-dir" />
-                      <arg value="${basedir}/target/psutil_build_temp" />
-                      <arg value="--dist-dir" />
-                      <arg value="${basedir}/target/psutil_build" />
-                    </exec>
-                  </target>
-                </configuration>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-    <profile>
-      <id>linux</id>
-      <activation>
-        <os>
-          <family>unix</family>
-        </os>
-      </activation>
-      <properties>
-        <envClassifier>linux</envClassifier>
-        <dirsep>/</dirsep>
-        <pathsep>:</pathsep>
-        <executable.python>${project.basedir}/../../ambari-common/src/main/unix/ambari-python-wrap</executable.python>
-        <executable.shell>sh</executable.shell>
-        <fileextension.shell>sh</fileextension.shell>
-        <fileextension.dot.shell-default></fileextension.dot.shell-default>
-        <assemblydescriptor>src/main/assemblies/empty.xml</assemblydescriptor>
-        <packagingFormat>jar</packagingFormat>
-      </properties>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-antrun-plugin</artifactId>
-            <version>1.7</version>
-            <executions>
-              <execution>
-                <id>psutils-compile</id>
-                <phase>process-test-classes</phase>
-                <goals>
-                  <goal>run</goal>
-                </goals>
-                <configuration>
-                  <target name="psutils-compile">
-                    <exec dir="${basedir}/src/main/python/psutil" executable="python" failonerror="true">
-                      <arg value="setup.py" />
-                      <arg value="build" />
-                      <arg value="--build-platlib" />
-                      <arg value="${basedir}/target/psutil_build" />
-                    </exec>
-                  </target>
-                </configuration>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-  </profiles>
 </project>

+ 0 - 231
ambari-metrics/ambari-metrics-host-monitoring/src/main/python/amhm_service.py

@@ -1,231 +0,0 @@
-#!/usr/bin/env python
-
-'''
-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.
-'''
-import glob
-
-import optparse
-import os
-import sys
-
-from ambari_commons.ambari_service import AmbariService
-from ambari_commons.exceptions import FatalException, NonFatalException
-from ambari_commons.logging_utils import print_warning_msg, print_error_msg, print_info_msg
-from ambari_commons.os_utils import search_file, run_os_command
-from ambari_commons.os_windows import SvcStatusCallback
-from core.config_reader import SERVER_OUT_FILE, SERVICE_USERNAME_KEY, SERVICE_PASSWORD_KEY, \
-  SETUP_ACTION, START_ACTION, STOP_ACTION, RESTART_ACTION, STATUS_ACTION
-from core.stop_handler import bind_signal_handlers, StopHandler
-from main import server_process_main
-
-
-#
-# Windows-specific service implementation. This class will be instantiated directly by pythonservice.exe.
-#
-class AMHostMonitoringService(AmbariService):
-  AmbariService._svc_name_ = "AmbariMetricsHostMonitoring"
-  AmbariService._svc_display_name_ = "Ambari Metrics Host Monitoring"
-  AmbariService._svc_description_ = "Ambari Metrics Host Monitoring Service"
-
-  AmbariService._AdjustServiceVersion()
-
-  # Adds the necessary script dir to the Python's modules path.
-  # Modify this as the deployed product's dir structure changes.
-  def _adjustPythonPath(self, current_dir):
-    python_path = os.path.join(current_dir, "sbin")
-    sys.path.insert(0, python_path)
-    pass
-
-  def SvcDoRun(self):
-    scmStatus = SvcStatusCallback(self)
-
-    self.redirect_output_streams()
-
-    stopHandler = StopHandler(AMHostMonitoringService._heventSvcStop)
-    bind_signal_handlers(stopHandler)
-
-    AMHostMonitoringService.set_ctrl_c_handler(ctrlHandler)
-
-    server_process_main(stopHandler, scmStatus)
-    pass
-
-  def _InitOptionsParser(self):
-    return init_options_parser()
-
-  def redirect_output_streams(self):
-    self._RedirectOutputStreamsToFile(SERVER_OUT_FILE)
-    pass
-
-
-def ctrlHandler(ctrlType):
-  AMHostMonitoringService.DefCtrlCHandler()
-  return True
-
-
-def svcsetup():
-  AMHostMonitoringService.set_ctrl_c_handler(ctrlHandler)
-  # we don't save password between 'setup' runs, so we can't run Install every time. We run 'setup' only if user and
-  # password provided or if service not installed
-  if (SERVICE_USERNAME_KEY in os.environ and SERVICE_PASSWORD_KEY in os.environ):
-    AMHostMonitoringService.Install(username=os.environ[SERVICE_USERNAME_KEY], password=os.environ[SERVICE_PASSWORD_KEY])
-  elif AMHostMonitoringService.QueryStatus() == "not installed":
-    AMHostMonitoringService.Install()
-  pass
-
-
-#
-# Starts the Ambari Metrics Collector. The server can start as a service or standalone process.
-# args:
-#  options.is_process = True - start the server as a process. For now, there is no restrictions for the number of
-#     server instances that can run like this.
-#  options.is_process = False - start the server in normal mode, as a Windows service. If the Ambari Metrics Collector
-#     is not registered as a service, the function fails. By default, only one instance of the service can
-#     possibly run.
-#
-def start(options):
-  AMHostMonitoringService.set_ctrl_c_handler(ctrlHandler)
-
-  if options.is_process:
-    #Run as a normal process. Invoke the ServiceMain directly.
-    stopHandler = StopHandler(AMHostMonitoringService._heventSvcStop)
-    bind_signal_handlers(stopHandler)
-    server_process_main(stopHandler)
-  else:
-    AMHostMonitoringService.Start()
-
-#
-# Stops the Ambari Metrics Collector. Ineffective when the server is started as a standalone process.
-#
-def stop():
-  AMHostMonitoringService.Stop()
-
-#
-# Prints the Ambari Metrics Collector service status.
-#
-def svcstatus(options):
-  options.exit_message = None
-
-  statusStr = AMHostMonitoringService.QueryStatus()
-  print "Ambari Metrics Collector is " + statusStr
-
-
-def init_options_parser():
-  parser = optparse.OptionParser(usage="usage: %prog action [options]", )
-  parser.add_option('-d', '--debug', action="store_true", dest='debug', default=False,
-                    help="Start Ambari Metrics Host Monitoring in debug mode")
-  parser.add_option('-p', '--process', action="store_true", dest='is_process', default=False,
-                    help="Start Ambari Metrics Host Monitoring as a normal process, not as a service")
-
-  # --help reserved for help
-  return parser
-
-def find_python_exe_path():
-  paths = "." + os.pathsep + os.environ["PATH"]
-
-  # Find python.exe by attempting to load it as a resource dll
-  python_path = search_file("python.exe", paths)
-  return os.path.dirname(python_path)
-
-
-def find_psutil_egg():
-  abs_subdir = os.path.join(os.getcwd(), "sbin", "psutil", "build")
-  egg_files = glob.glob(os.path.join(abs_subdir, "psutil*-win-amd64.egg"))
-  if egg_files is None or len(egg_files) == 0:
-    err = "Unable to find the expected psutil egg file in {0}. " \
-          "Verify that the installation carried out correctly.".format(abs_subdir)
-    raise FatalException(1, err)
-  if len(egg_files) > 1:
-    err = "Multiple psutil egg files found in {0}".format(abs_subdir)
-    print_warning_msg(err)
-  #Return the latest
-  return egg_files[len(egg_files) - 1]
-
-
-def setup_psutil():
-  python_exe_path = find_python_exe_path()
-  egg_file = find_psutil_egg()
-  cmd = [os.path.join(python_exe_path, "Scripts", "easy_install"), "--upgrade", egg_file]
-
-  retval, std_out, std_err = run_os_command(cmd)
-  if std_err is not None and std_err != '':
-    print_warning_msg(std_err)
-    print_info_msg(std_out)
-  if 0 != retval:
-    err = "Psutil egg installation failed. Exit code={0}, err output={1}".format(retval, std_err)
-    raise FatalException(1, err)
-
-  # Now the egg should be installed in the site_packages dir
-
-def win_main():
-  parser = init_options_parser()
-  (options, args) = parser.parse_args()
-
-  options.warnings = []
-  options.exit_message = None
-
-  if options.debug:
-    sys.frozen = 'windows_exe' # Fake py2exe so we can debug
-
-  if len(args) == 0:
-    print parser.print_help()
-    parser.error("No action entered")
-
-  action = args[0]
-
-  try:
-    if action == SETUP_ACTION:
-      setup_psutil()
-      svcsetup()
-    elif action == START_ACTION:
-      start(options)
-    elif action == STOP_ACTION:
-      stop()
-    elif action == RESTART_ACTION:
-      stop()
-      start(options)
-    elif action == STATUS_ACTION:
-      svcstatus(options)
-    else:
-      parser.error("Invalid action")
-
-    if options.warnings:
-      for warning in options.warnings:
-        print_warning_msg(warning)
-        pass
-      options.exit_message = "Ambari Metrics Host Monitoring '%s' completed with warnings." % action
-      pass
-  except FatalException as e:
-    if e.reason is not None:
-      print_error_msg("Exiting with exit code {0}. \nREASON: {1}".format(e.code, e.reason))
-    sys.exit(e.code)
-  except NonFatalException as e:
-    options.exit_message = "Ambari Metrics Host Monitoring '%s' completed with warnings." % action
-    if e.reason is not None:
-      print_warning_msg(e.reason)
-
-  if options.exit_message is not None:
-    print options.exit_message
-
-  sys.exit(0)
-
-if __name__ == "__main__":
-  try:
-    win_main()
-  except (KeyboardInterrupt, EOFError):
-    print("\nAborting ... Keyboard Interrupt.")
-    sys.exit(1)

+ 1 - 2
ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/__init__.py

@@ -19,9 +19,8 @@ limitations under the License.
 """
 
 import os, sys
-
 path = os.path.abspath(__file__)
-path = os.path.normpath(os.path.join(os.path.dirname(path), "..", "psutil", "build"))
+path = os.path.join(os.path.dirname(os.path.dirname(path)), "psutil/build/")
 
 for dir in os.walk(path).next()[1]:
   if 'lib' in dir:

+ 2 - 64
ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/config_reader.py

@@ -22,67 +22,10 @@ import ConfigParser
 import StringIO
 import json
 import os
-from ambari_commons import OSConst
-from ambari_commons.os_family_impl import OsFamilyImpl
-
-
-#
-# Abstraction for OS-dependent configuration defaults
-#
-class ConfigDefaults(object):
-  def get_config_file_path(self):
-    pass
-  def get_metric_file_path(self):
-    pass
-
-@OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY)
-class ConfigDefaultsWindows(ConfigDefaults):
-  def __init__(self):
-    self._CONFIG_FILE_PATH = "conf\\metric_monitor.ini"
-    self._METRIC_FILE_PATH = "conf\\metric_groups.conf"
-    pass
-
-  def get_config_file_path(self):
-    return self._CONFIG_FILE_PATH
-  def get_metric_file_path(self):
-    return self._METRIC_FILE_PATH
-
-@OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
-class ConfigDefaultsLinux(ConfigDefaults):
-  def __init__(self):
-    self._CONFIG_FILE_PATH = "/etc/ambari-metrics-monitor/conf/metric_monitor.ini"
-    self._METRIC_FILE_PATH = "/etc/ambari-metrics-monitor/conf/metric_groups.conf"
-    pass
-
-  def get_config_file_path(self):
-    return self._CONFIG_FILE_PATH
-  def get_metric_file_path(self):
-    return self._METRIC_FILE_PATH
-
-configDefaults = ConfigDefaults()
-
 
 config = ConfigParser.RawConfigParser()
-
-CONFIG_FILE_PATH = configDefaults.get_config_file_path()
-METRIC_FILE_PATH = configDefaults.get_metric_file_path()
-
-OUT_DIR = os.path.join(os.sep, "var", "log", "ambari-metrics-host-monitoring")
-SERVER_OUT_FILE = OUT_DIR + os.sep + "ambari-metrics-host-monitoring.out"
-SERVER_LOG_FILE = OUT_DIR + os.sep + "ambari-metrics-host-monitoring.log"
-
-PID_DIR = os.path.join(os.sep, "var", "run", "ambari-metrics-host-monitoring")
-PID_OUT_FILE = PID_DIR + os.sep + "ambari-metrics-host-monitoring.pid"
-EXITCODE_OUT_FILE = PID_DIR + os.sep + "ambari-metrics-host-monitoring.exitcode"
-
-SERVICE_USERNAME_KEY = "TMP_AMHM_USERNAME"
-SERVICE_PASSWORD_KEY = "TMP_AMHM_PASSWORD"
-
-SETUP_ACTION = "setup"
-START_ACTION = "start"
-STOP_ACTION = "stop"
-RESTART_ACTION = "restart"
-STATUS_ACTION = "status"
+CONFIG_FILE_PATH = "/etc/ambari-metrics-monitor/conf/metric_monitor.ini"
+METRIC_FILE_PATH = "/etc/ambari-metrics-monitor/conf/metric_groups.conf"
 
 config_content = """
 [default]
@@ -153,11 +96,6 @@ class Configuration:
       self.metric_groups = json.load(open(METRIC_FILE_PATH))
     else:
       print 'No metric configs found at {0}'.format(METRIC_FILE_PATH)
-      self.metric_groups = \
-      {
-        'host_metric_groups': [],
-        'process_metric_groups': []
-      }
     pass
 
   def getConfig(self):

+ 6 - 21
ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/controller.py

@@ -33,7 +33,7 @@ logger = logging.getLogger()
 
 class Controller(threading.Thread):
 
-  def __init__(self, config, stop_handler):
+  def __init__(self, config):
     # Process initialization code
     threading.Thread.__init__(self)
     logger.debug('Initializing Controller thread.')
@@ -48,42 +48,27 @@ class Controller(threading.Thread):
     self.metric_collector = MetricsCollector(self.event_queue, self.application_metric_map)
     self.server_url = config.get_server_address()
     self.sleep_interval = config.get_collector_sleep_interval()
-    self._stop_handler = stop_handler
     self.initialize_events_cache()
-    self.emitter = Emitter(self.config, self.application_metric_map, stop_handler)
-    self._t = None
+    self.emitter = Emitter(self.config, self.application_metric_map)
 
   def run(self):
     logger.info('Running Controller thread: %s' % threading.currentThread().getName())
-
-    self.start_emitter()
-
-  # Wake every 5 seconds to push events to the queue
+    # Wake every 5 seconds to push events to the queue
     while True:
       if (self.event_queue.full()):
         logger.warn('Event Queue full!! Suspending further collections.')
       else:
         self.enqueque_events()
       pass
-      #Wait for the service stop event instead of sleeping blindly
-      if 0 == self._stop_handler.wait(self.sleep_interval):
-        logger.info('Shutting down Controller thread')
-        break
-
-    if not self._t is None:
-      self._t.cancel()
-      self._t.join(5)
-
-    #The emitter thread should have stopped by now, just ensure it has shut down properly
-    self.emitter.join(5)
+      time.sleep(self.sleep_interval)
     pass
 
   # TODO: Optimize to not use Timer class and use the Queue instead
   def enqueque_events(self):
     # Queue events for up to a minute
     for event in self.events_cache:
-      self._t = Timer(event.get_collect_interval(), self.metric_collector.process_event, args=(event,))
-      self._t.start()
+      t = Timer(event.get_collect_interval(), self.metric_collector.process_event, args=(event,))
+      t.start()
     pass
 
   def initialize_events_cache(self):

+ 4 - 13
ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/emitter.py

@@ -32,13 +32,12 @@ class Emitter(threading.Thread):
   """
   Wake up every send interval seconds and empty the application metric map.
   """
-  def __init__(self, config, application_metric_map, stop_handler):
+  def __init__(self, config, application_metric_map):
     threading.Thread.__init__(self)
     logger.debug('Initializing Emitter thread.')
     self.lock = threading.Lock()
     self.collector_address = config.get_server_address()
     self.send_interval = config.get_send_interval()
-    self._stop_handler = stop_handler
     self.application_metric_map = application_metric_map
 
   def run(self):
@@ -46,16 +45,10 @@ class Emitter(threading.Thread):
     while True:
       try:
         self.submit_metrics()
-        #Wait for the service stop event instead of sleeping blindly
-        if 0 == self._stop_handler.wait(self.send_interval):
-          logger.info('Shutting down Emitter thread')
-          return
+        time.sleep(self.send_interval)
       except Exception, e:
         logger.warn('Unable to emit events. %s' % str(e))
-        #Wait for the service stop event instead of sleeping blindly
-        if 0 == self._stop_handler.wait(self.RETRY_SLEEP_INTERVAL):
-          logger.info('Shutting down Emitter thread - abort retry')
-          return
+        time.sleep(self.RETRY_SLEEP_INTERVAL)
         logger.info('Retrying emit after %s seconds.' % self.RETRY_SLEEP_INTERVAL)
     pass
   
@@ -76,9 +69,7 @@ class Emitter(threading.Thread):
         logger.warn("Error sending metrics to server. Retrying after {0} "
                     "...".format(self.RETRY_SLEEP_INTERVAL))
         retry_count += 1
-        #Wait for the service stop event instead of sleeping blindly
-        if 0 == self._stop_handler.wait(self.RETRY_SLEEP_INTERVAL):
-          return
+        time.sleep(self.RETRY_SLEEP_INTERVAL)
       pass
     pass
   

+ 0 - 138
ambari-metrics/ambari-metrics-host-monitoring/src/main/python/core/stop_handler.py

@@ -1,138 +0,0 @@
-#!/usr/bin/env python
-
-'''
-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.
-'''
-
-import logging
-import os
-import signal
-import threading
-import traceback
-
-from ambari_commons import OSConst, OSCheck
-from ambari_commons.exceptions import FatalException
-from ambari_commons.os_family_impl import OsFamilyImpl
-
-
-logger = logging.getLogger()
-
-_handler = None
-
-
-class StopHandler(object):
-  def set_stop(self):
-    pass
-
-  def wait(self, timeout=None):
-    return -1
-
-
-#
-# Windows implementation
-#
-@OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY)
-class StopHandlerWindows(StopHandler):
-  def __init__(self, stopEvent=None):
-    import win32event
-    # Event used to gracefully stop the process
-    if stopEvent is None:
-      # Allow standalone testing
-      self._heventStop = win32event.CreateEvent(None, 0, 0, None)
-    else:
-      # Allow one unique event per process
-      self._heventStop = stopEvent
-
-  def set_stop(self):
-    import win32event
-    win32event.SetEvent(self._heventStop)
-
-  def wait(self, timeout=None):
-    '''
-    :param timeout: Time to wait, in seconds.
-    :return: 0 == stop event signaled, -1 = timeout
-    '''
-    import win32event
-
-    if timeout is None:
-      timeout = win32event.INFINITE
-    else:
-      timeout = timeout * 1000
-
-    result = win32event.WaitForSingleObject(self._heventStop, timeout)
-    if(win32event.WAIT_OBJECT_0 != result and win32event.WAIT_TIMEOUT != result):
-      raise FatalException(-1, "Error waiting for stop event: " + str(result))
-    if (win32event.WAIT_TIMEOUT == result):
-      return -1
-      logger.info("Stop event received")
-    return result # 0 -> stop
-
-
-#
-# Linux implementation
-#
-def signal_handler(signum, frame):
-  global _handler
-  _handler.set_stop()
-
-def debug(sig, frame):
-  """Interrupt running process, and provide a python prompt for
-  interactive debugging."""
-  d = {'_frame': frame}  # Allow access to frame object.
-  d.update(frame.f_globals)  # Unless shadowed by global
-  d.update(frame.f_locals)
-
-  message = "Signal received : entering python shell.\nTraceback:\n"
-  message += ''.join(traceback.format_stack(frame))
-  logger.info(message)
-
-
-@OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
-class StopHandlerLinux(StopHandler):
-  def __init__(self, stopEvent=None):
-    # Event used to gracefully stop the process
-    if stopEvent is None:
-      # Allow standalone testing
-      self.stop_event = threading.Event()
-    else:
-      # Allow one unique event per process
-      self.stop_event = stopEvent
-
-  def set_stop(self):
-    self.stop_event.set()
-
-  def wait(self, timeout=None):
-    # Stop process when stop event received
-    if self.stop_event.wait(timeout):
-      logger.info("Stop event received")
-      return 0
-    # Timeout
-    return -1
-
-
-def bind_signal_handlers(new_handler=None):
-  if OSCheck.get_os_family() != OSConst.WINSRV_FAMILY:
-      signal.signal(signal.SIGINT, signal_handler)
-      signal.signal(signal.SIGTERM, signal_handler)
-      signal.signal(signal.SIGUSR1, debug)
-
-  if new_handler is None:
-    global _handler
-    _handler = StopHandler()
-  else:
-    _handler = new_handler
-  return _handler

+ 9 - 49
ambari-metrics/ambari-metrics-host-monitoring/src/main/python/main.py

@@ -18,67 +18,27 @@ See the License for the specific language governing permissions and
 limitations under the License.
 '''
 
+import core
+from core.controller import Controller
+from core.config_reader import Configuration
 import logging
-import os
+import signal
 import sys
 
-from ambari_commons.os_utils import remove_file
-
-from core.controller import Controller
-from core.config_reader import Configuration, PID_OUT_FILE, SERVER_LOG_FILE, SERVER_OUT_FILE
-from core.stop_handler import bind_signal_handlers
-
-
 logger = logging.getLogger()
 
-
-def save_pid(pid, pidfile):
-  """
-    Save pid to pidfile.
-  """
-  try:
-    pfile = open(pidfile, "w")
-    pfile.write("%s\n" % pid)
-  except IOError:
-    pass
-  finally:
-    try:
-      pfile.close()
-    except:
-      pass
-
-
 def main(argv=None):
   # Allow Ctrl-C
-  stop_handler = bind_signal_handlers()
-
-  server_process_main(stop_handler)
-
-def server_process_main(stop_handler, scmStatus=None):
-  if scmStatus is not None:
-    scmStatus.reportStartPending()
-
-  save_pid(os.getpid(), PID_OUT_FILE)
+  signal.signal(signal.SIGINT, signal.SIG_DFL)
 
   config = Configuration()
-  controller = Controller(config, stop_handler)
-
+  controller = Controller(config)
+  
   _init_logging(config)
-
+  
   logger.info('Starting Server RPC Thread: %s' % ' '.join(sys.argv))
   controller.start()
-
-  print "Server out at: " + SERVER_OUT_FILE
-  print "Server log at: " + SERVER_LOG_FILE
-
-  if scmStatus is not None:
-    scmStatus.reportStarted()
-
-  #The controller thread finishes when the stop event is signaled
-  controller.join()
-
-  remove_file(PID_OUT_FILE)
-  pass
+  controller.start_emitter()
 
 def _init_logging(config):
   _levels = {

+ 0 - 17
ambari-metrics/ambari-metrics-timelineservice/conf/windows/ambari-metrics-collector.cmd

@@ -1,17 +0,0 @@
-@rem Licensed to the Apache Software Foundation (ASF) under one or more
-@rem contributor license agreements.  See the NOTICE file distributed with
-@rem this work for additional information regarding copyright ownership.
-@rem The ASF licenses this file to You under the Apache License, Version 2.0
-@rem (the "License"); you may not use this file except in compliance with
-@rem the License.  You may obtain a copy of the License at
-@rem
-@rem     http://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-
-@echo off
-python.exe -u %~dp0\sbin\main.py %* 2>&1

+ 0 - 16
ambari-metrics/ambari-metrics-timelineservice/conf/windows/ams-env.cmd

@@ -1,16 +0,0 @@
-@rem Licensed to the Apache Software Foundation (ASF) under one or more
-@rem contributor license agreements.  See the NOTICE file distributed with
-@rem this work for additional information regarding copyright ownership.
-@rem The ASF licenses this file to You under the Apache License, Version 2.0
-@rem (the "License"); you may not use this file except in compliance with
-@rem the License.  You may obtain a copy of the License at
-@rem
-@rem     http://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-
-@rem Set environment variables here.

+ 0 - 25
ambari-metrics/ambari-metrics-timelineservice/conf/windows/ams-site.xml

@@ -1,25 +0,0 @@
-<?xml version="1.0"?>
-
-<!--
-  ~ 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.
-  -->
-
-<configuration>
-
-  <!-- Site specific AMS configuration properties -->
-
-</configuration>

+ 0 - 17
ambari-metrics/ambari-metrics-timelineservice/conf/windows/ams.properties

@@ -1,17 +0,0 @@
-#
-# 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.
-#

+ 0 - 29
ambari-metrics/ambari-metrics-timelineservice/conf/windows/log4j.properties

@@ -1,29 +0,0 @@
-#
-# 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.
-#
-
-# Define some default values that can be overridden by system properties
-# Root logger option
-log4j.rootLogger=INFO,file
-
-# Direct log messages to a log file
-log4j.appender.file=org.apache.log4j.RollingFileAppender
-log4j.appender.file.File=\\var\\log\\ambari-metrics-collector\\ambari-metrics-collector.log
-log4j.appender.file.MaxFileSize=80MB
-log4j.appender.file.MaxBackupIndex=60
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p [%t] %c{1}:%L - %m%n

+ 0 - 31
ambari-metrics/ambari-metrics-timelineservice/pom.xml

@@ -41,33 +41,6 @@
 
   <build>
     <plugins>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <version>1.8</version>
-        <executions>
-          <execution>
-            <id>parse-version</id>
-            <phase>validate</phase>
-            <goals>
-              <goal>parse-version</goal>
-            </goals>
-          </execution>
-          <execution>
-            <id>regex-property</id>
-            <goals>
-              <goal>regex-property</goal>
-            </goals>
-            <configuration>
-              <name>ambariVersion</name>
-              <value>${project.version}</value>
-              <regex>^([0-9]+)\.([0-9]+)\.([0-9]+)(\.|-).*</regex>
-              <replacement>$1.$2.$3</replacement>
-              <failIfNoMatch>false</failIfNoMatch>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
       <plugin>
         <artifactId>maven-dependency-plugin</artifactId>
         <executions>
@@ -85,10 +58,6 @@
           </execution>
         </executions>
       </plugin>
-      <plugin>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>3.0</version>
-      </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-antrun-plugin</artifactId>

+ 0 - 21
ambari-metrics/ambari-metrics-timelineservice/src/main/python/ambari_metrics_collector/__init__.py

@@ -1,21 +0,0 @@
-#!/usr/bin/env python
-"""
-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.
-
-Ambari Agent
-
-"""

+ 0 - 223
ambari-metrics/ambari-metrics-timelineservice/src/main/python/ambari_metrics_collector/properties.py

@@ -1,223 +0,0 @@
-#!/usr/bin/env python
-
-'''
-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.
-'''
-
-import os
-import re
-import time
-
-#Apache License Header
-ASF_LICENSE_HEADER = '''
-# Copyright 2011 The Apache Software Foundation
-#
-# 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.
-'''
-
-# A Python replacement for java.util.Properties
-# Based on http://code.activestate.com/recipes
-# /496795-a-python-replacement-for-javautilproperties/
-class Properties(object):
-  def __init__(self, props=None):
-    self._props = {}
-    self._origprops = {}
-    self._keymap = {}
-
-    self.othercharre = re.compile(r'(?<!\\)(\s*\=)|(?<!\\)(\s*\:)')
-    self.othercharre2 = re.compile(r'(\s*\=)|(\s*\:)')
-    self.bspacere = re.compile(r'\\(?!\s$)')
-
-  def __parse(self, lines):
-    lineno = 0
-    i = iter(lines)
-    for line in i:
-      lineno += 1
-      line = line.strip()
-      if not line:
-        continue
-      if line[0] == '#':
-        continue
-      escaped = False
-      sepidx = -1
-      flag = 0
-      m = self.othercharre.search(line)
-      if m:
-        first, last = m.span()
-        start, end = 0, first
-        flag = 1
-        wspacere = re.compile(r'(?<![\\\=\:])(\s)')
-      else:
-        if self.othercharre2.search(line):
-          wspacere = re.compile(r'(?<![\\])(\s)')
-        start, end = 0, len(line)
-      m2 = wspacere.search(line, start, end)
-      if m2:
-        first, last = m2.span()
-        sepidx = first
-      elif m:
-        first, last = m.span()
-        sepidx = last - 1
-      while line[-1] == '\\':
-        nextline = i.next()
-        nextline = nextline.strip()
-        lineno += 1
-        line = line[:-1] + nextline
-      if sepidx != -1:
-        key, value = line[:sepidx], line[sepidx + 1:]
-      else:
-        key, value = line, ''
-      self.process_pair(key, value)
-
-  def process_pair(self, key, value):
-    oldkey = key
-    oldvalue = value
-    keyparts = self.bspacere.split(key)
-    strippable = False
-    lastpart = keyparts[-1]
-    if lastpart.find('\\ ') != -1:
-      keyparts[-1] = lastpart.replace('\\', '')
-    elif lastpart and lastpart[-1] == ' ':
-      strippable = True
-    key = ''.join(keyparts)
-    if strippable:
-      key = key.strip()
-      oldkey = oldkey.strip()
-    oldvalue = self.unescape(oldvalue)
-    value = self.unescape(value)
-    self._props[key] = None if value is None else value.strip()
-    if self._keymap.has_key(key):
-      oldkey = self._keymap.get(key)
-      self._origprops[oldkey] = None if oldvalue is None else oldvalue.strip()
-    else:
-      self._origprops[oldkey] = None if oldvalue is None else oldvalue.strip()
-      self._keymap[key] = oldkey
-
-  def unescape(self, value):
-    newvalue = value
-    if not value is None:
-     newvalue = value.replace('\:', ':')
-     newvalue = newvalue.replace('\=', '=')
-    return newvalue
-
-  def removeOldProp(self, key):
-    if self._origprops.has_key(key):
-      del self._origprops[key]
-    pass
-
-  def removeProp(self, key):
-    if self._props.has_key(key):
-      del self._props[key]
-    pass
-
-  def load(self, stream):
-    if type(stream) is not file:
-      raise TypeError, 'Argument should be a file object!'
-    if stream.mode != 'r':
-      raise ValueError, 'Stream should be opened in read-only mode!'
-    try:
-      self.fileName = os.path.abspath(stream.name)
-      lines = stream.readlines()
-      self.__parse(lines)
-    except IOError:
-      raise
-
-  def get_property(self, key):
-    return self._props.get(key, '')
-
-  def propertyNames(self):
-    return self._props.keys()
-
-  def getPropertyDict(self):
-    return self._props
-
-  def __getitem__(self, name):
-    return self.get_property(name)
-
-  def __getattr__(self, name):
-    try:
-      return self.__dict__[name]
-    except KeyError:
-      if hasattr(self._props, name):
-        return getattr(self._props, name)
-
-  def sort_props(self):
-    tmp_props = {}
-    for key in sorted(self._props.iterkeys()):
-      tmp_props[key] = self._props[key]
-    self._props = tmp_props
-    pass
-
-  def sort_origprops(self):
-    tmp_props = self._origprops.copy()
-    self._origprops.clear()
-    for key in sorted(tmp_props.iterkeys()):
-      self._origprops[key] = tmp_props[key]
-    pass
-
-  def store(self, out, header=""):
-    """ Write the properties list to the stream 'out' along
-    with the optional 'header' """
-    if out.mode[0] != 'w':
-      raise ValueError, 'Steam should be opened in write mode!'
-    try:
-      out.write(''.join(('#', ASF_LICENSE_HEADER, '\n')))
-      out.write(''.join(('#', header, '\n')))
-      # Write timestamp
-      tstamp = time.strftime('%a %b %d %H:%M:%S %Z %Y', time.localtime())
-      out.write(''.join(('#', tstamp, '\n')))
-      # Write properties from the pristine dictionary
-      for prop, val in self._origprops.items():
-        if val is not None:
-          out.write(''.join((prop, '=', val, '\n')))
-      out.close()
-    except IOError:
-      raise
-
-  def store_ordered(self, out, header=""):
-    """ Write the properties list to the stream 'out' along
-    with the optional 'header' """
-    if out.mode[0] != 'w':
-      raise ValueError, 'Steam should be opened in write mode!'
-    try:
-      out.write(''.join(('#', ASF_LICENSE_HEADER, '\n')))
-      out.write(''.join(('#', header, '\n')))
-      # Write timestamp
-      tstamp = time.strftime('%a %b %d %H:%M:%S %Z %Y', time.localtime())
-      out.write(''.join(('#', tstamp, '\n')))
-      # Write properties from the pristine dictionary
-      for key in sorted(self._origprops.iterkeys()):
-        val = self._origprops[key]
-        if val is not None:
-          out.write(''.join((key, '=', val, '\n')))
-      out.close()
-    except IOError:
-      raise

+ 0 - 152
ambari-metrics/ambari-metrics-timelineservice/src/main/python/ambari_metrics_collector/serviceConfiguration.py

@@ -1,152 +0,0 @@
-#!/usr/bin/env python
-
-'''
-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.
-'''
-
-import os
-
-from ambari_commons.exceptions import FatalException
-from ambari_commons.logging_utils import print_info_msg
-from ambari_commons.os_utils import search_file
-from ambari_metrics_collector.properties import Properties
-
-
-AMS_CONF_VAR = "AMS_CONF"
-DEFAULT_CONF_DIR = "conf"
-AMS_PROPERTIES_FILE = "ams.properties"
-
-JAVA_HOME = "JAVA_HOME"
-
-DEBUG_MODE_KEY = "ams.server.debug"
-SUSPEND_START_MODE_KEY = "ams.server.debug.suspend.start"
-
-SERVER_OUT_FILE_KEY = "ams.output.file.path"
-
-DEFAULT_LIBS_DIR = "lib"
-
-EMBEDDED_HBASE_MASTER_SERVICE = "ams_hbase_master"
-
-EMBEDDED_HBASE_SUBDIR = "hbase"
-
-JAVA_EXE_SUBPATH = "bin\\java.exe"
-
-JAVA_HEAP_MAX_DEFAULT = "-Xmx1g"
-
-HADOOP_HEAPSIZE = "HADOOP_HEAPSIZE"
-HADOOP_HEAPSIZE_DEFAULT = "1024"
-
-DEBUG_MODE = False
-SUSPEND_START_MODE = False
-
-OUT_DIR = "\\var\\log\\ambari-metrics-collector"
-SERVER_OUT_FILE = OUT_DIR + "\\ambari-metrics-collector.out"
-SERVER_LOG_FILE = OUT_DIR + "\\ambari-metrics-collector.log"
-
-PID_DIR = "\\var\\run\\ambari-metrics-collector"
-PID_OUT_FILE = PID_DIR + "\\ambari-metrics-collector.pid"
-EXITCODE_OUT_FILE = PID_DIR + "\\ambari-metrics-collector.exitcode"
-
-SERVICE_USERNAME_KEY = "TMP_AMC_USERNAME"
-SERVICE_PASSWORD_KEY = "TMP_AMC_PASSWORD"
-
-SETUP_ACTION = "setup"
-START_ACTION = "start"
-STOP_ACTION = "stop"
-RESTART_ACTION = "restart"
-STATUS_ACTION = "status"
-
-def get_conf_dir():
-  try:
-    conf_dir = os.environ[AMS_CONF_VAR]
-  except KeyError:
-    conf_dir = DEFAULT_CONF_DIR
-  return conf_dir
-
-def find_properties_file():
-  conf_file = search_file(AMS_PROPERTIES_FILE, get_conf_dir())
-  if conf_file is None:
-    err = 'File %s not found in search path $%s: %s' % (AMS_PROPERTIES_FILE,
-                                                        AMS_CONF_VAR, get_conf_dir())
-    print err
-    raise FatalException(1, err)
-  else:
-    print_info_msg('Loading properties from ' + conf_file)
-  return conf_file
-
-# Load AMC properties and return dict with values
-def get_properties():
-  conf_file = find_properties_file()
-
-  properties = None
-  try:
-    properties = Properties()
-    properties.load(open(conf_file))
-  except (Exception), e:
-    print 'Could not read "%s": %s' % (conf_file, e)
-    return -1
-  return properties
-
-def get_value_from_properties(properties, key, default=""):
-  try:
-    value = properties.get_property(key)
-    if not value:
-      value = default
-  except:
-    return default
-  return value
-
-def get_java_cp():
-  conf_dir = get_conf_dir()
-  conf_dir = os.path.abspath(conf_dir) + os.pathsep + os.path.join(os.path.abspath(DEFAULT_LIBS_DIR), "*")
-  if conf_dir.find(' ') != -1:
-    conf_dir = '"' + conf_dir + '"'
-  return conf_dir
-
-def find_jdk():
-  try:
-    java_home = os.environ[JAVA_HOME]
-  except Exception:
-    # No JAVA_HOME set
-    err = "ERROR: JAVA_HOME is not set and could not be found."
-    raise FatalException(1, err)
-
-  if not os.path.isdir(java_home):
-    err = "ERROR: JAVA_HOME {0} does not exist.".format(java_home)
-    raise FatalException(1, err)
-
-  java_exe = os.path.join(java_home, JAVA_EXE_SUBPATH)
-  if not os.path.isfile(java_exe):
-    err = "ERROR: {0} is not executable.".format(java_exe)
-    raise FatalException(1, err)
-
-  return java_home
-
-def get_java_exe_path():
-  jdk_path = find_jdk()
-  java_exe = os.path.join(jdk_path, JAVA_EXE_SUBPATH)
-  return java_exe
-
-def build_jvm_args():
-  try:
-    # check envvars which might override default args
-    hadoop_heapsize = os.environ[HADOOP_HEAPSIZE]
-    java_heap_max = "-Xms{0}m".format(hadoop_heapsize)
-  except Exception:
-    java_heap_max = JAVA_HEAP_MAX_DEFAULT
-
-  return java_heap_max

+ 0 - 174
ambari-metrics/ambari-metrics-timelineservice/src/main/python/amc_service.py

@@ -1,174 +0,0 @@
-#!/usr/bin/env python
-
-'''
-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.
-'''
-
-import optparse
-import os
-import sys
-
-from ambari_commons.ambari_service import AmbariService
-from ambari_commons.exceptions import FatalException
-from ambari_commons.os_utils import remove_file
-from ambari_commons.os_windows import SvcStatusCallback, WinServiceController
-from ambari_metrics_collector.serviceConfiguration import get_properties, get_value_from_properties, DEBUG_MODE_KEY, \
-  SUSPEND_START_MODE_KEY, PID_OUT_FILE, SERVER_OUT_FILE_KEY, SERVER_OUT_FILE, SERVICE_USERNAME_KEY, SERVICE_PASSWORD_KEY, \
-  DEFAULT_CONF_DIR, EMBEDDED_HBASE_MASTER_SERVICE
-from embedded_hbase_service import EmbeddedHBaseService
-from main import server_process_main
-
-
-class AMCollectorService(AmbariService):
-  AmbariService._svc_name_ = "AmbariMetricsCollector"
-  AmbariService._svc_display_name_ = "Ambari Metrics Collector"
-  AmbariService._svc_description_ = "Ambari Metrics Collector Service"
-
-  AmbariService._AdjustServiceVersion()
-
-  # Adds the necessary script dir(s) to the Python's modules path.
-  # Modify this as the deployed product's dir structure changes.
-  def _adjustPythonPath(self, current_dir):
-    python_path = os.path.join(current_dir, "sbin")
-    sys.path.insert(0, python_path)
-    pass
-
-  @classmethod
-  def Install(cls, startupMode = "auto", username = None, password = None, interactive = False,
-              perfMonIni = None, perfMonDll = None):
-    script_path = os.path.dirname(__file__.replace('/', os.sep))
-    classPath = os.path.join(script_path, cls.__module__) + "." + cls.__name__
-
-    return AmbariService.Install(classPath, startupMode, username, password, interactive,
-                                                    perfMonIni, perfMonDll)
-
-  def SvcDoRun(self):
-    scmStatus = SvcStatusCallback(self)
-
-    properties = get_properties()
-    self.options.debug = get_value_from_properties(properties, DEBUG_MODE_KEY, self.options.debug)
-    self.options.suspend_start = get_value_from_properties(properties, SUSPEND_START_MODE_KEY, self.options.suspend_start)
-
-    self.redirect_output_streams()
-
-    childProc = server_process_main(self.options, scmStatus)
-
-    if not self._StopOrWaitForChildProcessToFinish(childProc):
-      return
-
-    remove_file(PID_OUT_FILE)
-    pass
-
-  def _InitOptionsParser(self):
-    return init_options_parser()
-
-  def redirect_output_streams(self):
-    properties = get_properties()
-
-    outFilePath = properties[SERVER_OUT_FILE_KEY]
-    if (outFilePath is None or outFilePath == ""):
-      outFilePath = SERVER_OUT_FILE
-
-    self._RedirectOutputStreamsToFile(outFilePath)
-    pass
-
-def ctrlHandler(ctrlType):
-  AMCollectorService.DefCtrlCHandler()
-  return True
-
-def svcsetup():
-  AMCollectorService.set_ctrl_c_handler(ctrlHandler)
-
-  # we don't save password between 'setup' runs, so we can't run Install every time. We run 'setup' only if user and
-  # password provided or if service not installed
-  if (SERVICE_USERNAME_KEY in os.environ and SERVICE_PASSWORD_KEY in os.environ):
-    EmbeddedHBaseService.Install(username=os.environ[SERVICE_USERNAME_KEY], password=os.environ[SERVICE_PASSWORD_KEY])
-    AMCollectorService.Install(username=os.environ[SERVICE_USERNAME_KEY], password=os.environ[SERVICE_PASSWORD_KEY])
-  else:
-    EmbeddedHBaseService.Install()
-    AMCollectorService.Install()
-  pass
-
-#
-# Starts the Ambari Metrics Collector. The server can start as a service or standalone process.
-# args:
-#  options.is_process = True - start the server as a process. For now, there is no restrictions for the number of
-#     server instances that can run like this.
-#  options.is_process = False - start the server in normal mode, as a Windows service. If the Ambari Metrics Collector
-#     is not registered as a service, the function fails. By default, only one instance of the service can
-#     possibly run.
-#
-def start(options):
-  AMCollectorService.set_ctrl_c_handler(ctrlHandler)
-
-  if options.is_process:
-    #Run as a normal process. Invoke the ServiceMain directly.
-    childProc = server_process_main(options)
-
-    childProc.wait()
-
-    remove_file(PID_OUT_FILE)
-  else:
-    AMCollectorService.Start()
-
-#
-# Stops the Ambari Metrics Collector. Ineffective when the server is started as a standalone process.
-#
-def stop():
-  AMCollectorService.Stop()
-
-#
-# Prints the Ambari Metrics Collector service status.
-#
-def svcstatus(options):
-  options.exit_message = None
-
-  statusStr = AMCollectorService.QueryStatus()
-  print "Ambari Metrics Collector is " + statusStr
-
-
-def setup(options):
-  svcsetup()
-
-def init_options_parser():
-  parser = optparse.OptionParser(usage="usage: %prog action [options]", )
-  parser.add_option('--config', dest="conf_dir",
-                    default=DEFAULT_CONF_DIR,
-                    help="Configuration files directory")
-  parser.add_option('--debug', action="store_true", dest='debug', default=False,
-                    help="Start ambari-metrics-collector in debug mode")
-  parser.add_option('--suspend-start', action="store_true", dest='suspend_start', default=False,
-                    help="Freeze ambari-metrics-collector Java process at startup in debug mode")
-  parser.add_option('--process', action="store_true", dest='is_process', default=False,
-                    help="Start ambari-metrics-collector as a process, not as a service")
-  parser.add_option('--noembedded', action="store_true", dest='no_embedded_hbase', default=False,
-                    help="Don't attempt to start the HBASE services. Expect them to be already installed and running.")
-
-  # --help reserved for help
-  return parser
-
-
-def init_service_debug(options):
-  if options.debug:
-    sys.frozen = 'windows_exe'  # Fake py2exe so we can debug
-
-
-def ensure_hdp_service_soft_dependencies():
-  ret = WinServiceController.EnsureServiceIsStarted(EMBEDDED_HBASE_MASTER_SERVICE)
-  if ret != 0:
-    err = 'ERROR: Cannot start service "{0}". Error = {1}'.format(EMBEDDED_HBASE_MASTER_SERVICE, ret)
-    raise FatalException(1, err)

+ 0 - 201
ambari-metrics/ambari-metrics-timelineservice/src/main/python/embedded_hbase_service.py

@@ -1,201 +0,0 @@
-#!/usr/bin/env python
-
-'''
-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.
-'''
-
-import os
-import win32service
-import win32api
-from win32serviceutil import RemoveService, SmartOpenService
-import winerror
-
-from ambari_commons.xml_utils import ConvertToXml
-from ambari_metrics_collector.serviceConfiguration import EMBEDDED_HBASE_MASTER_SERVICE, EMBEDDED_HBASE_SUBDIR, \
-  find_jdk, get_java_exe_path, build_jvm_args
-
-MASTER_JVM_ARGS = '{0} ' \
-  '"-XX:+UseConcMarkSweepGC" "-Djava.net.preferIPv4Stack=true" ' \
-  '-Dhadoop.home.dir="{1}" -Dhbase.log.dir="{2}" -Dhbase.log.file={3} -Dhbase.home.dir="{1}" -Dhbase.id.str="{4}" ' \
-  '-Dhbase.root.logger="INFO,DRFA" -Dhbase.security.logger="INFO,RFAS" ' \
-  '-classpath "{5}" org.apache.hadoop.hbase.master.HMaster start'
-
-#-Xmx1000m "-XX:+UseConcMarkSweepGC" "-Djava.net.preferIPv4Stack=true"
-# -Dhbase.log.dir="C:\test\ambari-metrics-timelineservice-0.1.0-SNAPSHOT\hbase\logs" -Dhbase.log.file="hbase.log" -Dhbase.home.dir="C:\test\ambari-metrics-timelineservice-0.1.0-SNAPSHOT\hbase" -Dhbase.id.str="Administrator"
-# -XX:OnOutOfMemoryError="taskkill /F /PID p" -Dhbase.root.logger="INFO,console" -Dhbase.security.logger="INFO,DRFAS"
-# -classpath "C:\test\ambari-metrics-timelineservice-0.1.0-SNAPSHOT\hbase\conf;C:\jdk1.7.0_67\lib\tools.jar;C:\test\ambari-metrics-timelineservice-0.1.0-SNAPSHOT\hbase;C:\test\ambari-metrics-timelineservice-0.1.0-SNAPSHOT\hbase\lib\*"
-# org.apache.hadoop.hbase.master.HMaster start
-def _build_master_java_args(username = None):
-  hbase_home_dir = os.path.abspath(EMBEDDED_HBASE_SUBDIR)
-  hbase_log_dir = os.path.join(os.sep, "var", "log", EMBEDDED_HBASE_MASTER_SERVICE)
-  hbase_log_file = "hbase.log"
-  hbase_user_id = username if username else "SYSTEM"
-
-  if not os.path.exists(hbase_log_dir):
-    os.makedirs(hbase_log_dir)
-
-  java_class_path = os.path.join(hbase_home_dir, "conf")
-  java_class_path += os.pathsep + os.path.join(find_jdk(), "lib", "tools.jar")
-  java_class_path += os.pathsep + hbase_home_dir
-  java_class_path += os.pathsep + os.path.join(hbase_home_dir, "lib", "*")
-
-  args = MASTER_JVM_ARGS.format(build_jvm_args(), hbase_home_dir, hbase_log_dir, hbase_log_file, hbase_user_id, java_class_path)
-
-  return args
-
-
-def _get_config_file_path():
-  config_file_path = os.path.join(os.getcwd(), EMBEDDED_HBASE_SUBDIR, "bin", EMBEDDED_HBASE_MASTER_SERVICE + ".xml")
-  return config_file_path
-
-class EmbeddedHBaseService:
-  _svc_name_ = EMBEDDED_HBASE_MASTER_SERVICE
-  _svc_display_name_ = "Apache Ambari Metrics " + EMBEDDED_HBASE_MASTER_SERVICE
-  _exe_name_ = os.path.join(EMBEDDED_HBASE_SUBDIR, "bin", EMBEDDED_HBASE_MASTER_SERVICE + ".exe")
-
-  @classmethod
-  def _get_start_type(cls, startupMode):
-    if startupMode == "auto":
-      startType = win32service.SERVICE_AUTO_START
-    elif startupMode == "disabled":
-      startType = win32service.SERVICE_DISABLED
-    else:
-      startType = win32service.SERVICE_DEMAND_START
-    return startType
-
-  @classmethod
-  def Install(cls, startupMode = "auto", username = None, password = None):
-    print "Installing service %s" % (cls._svc_name_)
-
-    # Configure master.xml, which drives the java subprocess
-    java_path = get_java_exe_path()
-    java_args = _build_master_java_args(username)
-
-    config_file_path = _get_config_file_path()
-
-    xmlFileContents = _MasterXml()
-    xmlFileContents.service.id = EMBEDDED_HBASE_MASTER_SERVICE
-    xmlFileContents.service.name = EMBEDDED_HBASE_MASTER_SERVICE
-    xmlFileContents.service.description = "This service runs " + EMBEDDED_HBASE_MASTER_SERVICE
-    xmlFileContents.service.executable = java_path
-    xmlFileContents.service.arguments = java_args
-
-    xmlFile = open(config_file_path, "w")
-    xmlFile.write( str(xmlFileContents) )
-    xmlFile.close()
-
-    startType = cls._get_start_type(startupMode)
-    serviceType = win32service.SERVICE_WIN32_OWN_PROCESS
-    errorControl = win32service.SERVICE_ERROR_NORMAL
-
-    commandLine = os.path.abspath(cls._exe_name_)
-    hscm = win32service.OpenSCManager(None,None,win32service.SC_MANAGER_ALL_ACCESS)
-    try:
-      try:
-        hs = win32service.CreateService(hscm,
-                                        cls._svc_name_,
-                                        cls._svc_display_name_,
-                                        win32service.SERVICE_ALL_ACCESS,         # desired access
-                                        serviceType,        # service type
-                                        startType,
-                                        errorControl,       # error control type
-                                        commandLine,
-                                        None,
-                                        0,
-                                        None,
-                                        username,
-                                        password)
-        print "Service installed"
-        win32service.CloseServiceHandle(hs)
-      finally:
-        win32service.CloseServiceHandle(hscm)
-    except win32service.error, exc:
-      if exc.winerror==winerror.ERROR_SERVICE_EXISTS:
-        cls.Update(username, password)
-      else:
-        print "Error installing service: %s (%d)" % (exc.strerror, exc.winerror)
-        err = exc.winerror
-    except ValueError, msg: # Can be raised by custom option handler.
-      print "Error installing service: %s" % str(msg)
-      err = -1
-      # xxx - maybe I should remove after _any_ failed install - however,
-      # xxx - it may be useful to help debug to leave the service as it failed.
-      # xxx - We really _must_ remove as per the comments above...
-      # As we failed here, remove the service, so the next installation
-      # attempt works.
-      try:
-        RemoveService(cls._svc_name_)
-      except win32api.error:
-        print "Warning - could not remove the partially installed service."
-
-  @classmethod
-  def Update(cls, startupMode = "auto", username = None, password = None):
-    # Handle the default arguments.
-    if startupMode is None:
-      startType = win32service.SERVICE_NO_CHANGE
-    else:
-      startType = cls._get_start_type(startupMode)
-
-    hscm = win32service.OpenSCManager(None,None,win32service.SC_MANAGER_ALL_ACCESS)
-    serviceType = win32service.SERVICE_WIN32_OWN_PROCESS
-
-    commandLine = os.path.abspath(cls._exe_name_)
-
-    try:
-      hs = SmartOpenService(hscm, cls._svc_name_, win32service.SERVICE_ALL_ACCESS)
-      try:
-        win32service.ChangeServiceConfig(hs,
-                                         serviceType,  # service type
-                                         startType,
-                                         win32service.SERVICE_NO_CHANGE,       # error control type
-                                         commandLine,
-                                         None,
-                                         0,
-                                         None,
-                                         username,
-                                         password,
-                                         cls._svc_display_name_)
-        print "Service updated"
-      finally:
-        win32service.CloseServiceHandle(hs)
-    finally:
-      win32service.CloseServiceHandle(hscm)
-
-class _MasterXml(ConvertToXml):
-  service = ""  #Service entity
-
-  def __init__(self):
-    self.service = _ServiceXml()
-
-  def __str__(self):
-    result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-    result += str(self.service)
-    return result
-
-class _ServiceXml(ConvertToXml):
-  def __init__(self):
-    self.id = ""
-    self.name = ""
-    self.description = ""
-    self.executable = ""
-    self.arguments = ""
-
-  def __str__(self):
-    result = "<service>\n"
-    result += self.attributesToXml()
-    result += "</service>"
-    return result

+ 0 - 214
ambari-metrics/ambari-metrics-timelineservice/src/main/python/main.py

@@ -1,214 +0,0 @@
-#!/usr/bin/env python
-
-'''
-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.
-'''
-
-import os
-import subprocess
-import sys
-
-from ambari_commons.exceptions import FatalException, NonFatalException
-from ambari_commons.logging_utils import print_info_msg, print_warning_msg, print_error_msg
-from ambari_metrics_collector.serviceConfiguration import get_java_exe_path, get_java_cp, build_jvm_args, \
-  SETUP_ACTION, START_ACTION, STOP_ACTION, RESTART_ACTION, STATUS_ACTION, PID_DIR, EXITCODE_OUT_FILE, \
-  SERVER_OUT_FILE, PID_OUT_FILE, SERVER_LOG_FILE
-
-
-# debug settings
-SERVER_START_DEBUG = False
-SUSPEND_START_MODE = False
-
-AMS_ENV_CMD = "ams-env.cmd"
-
-SERVER_START_CMD = \
-  "-cp {0} {1} " + \
-  "-Djava.net.preferIPv4Stack=true " \
-  "-Dproc_timelineserver " + \
-  "org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryServer"
-SERVER_START_CMD_DEBUG = \
-  "-cp {0} {1} " + \
-  "-Djava.net.preferIPv4Stack=true " \
-  "-Dproc_timelineserver " + \
-  " -Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend={2} " + \
-  "org.apache.hadoop.yarn.server.applicationhistoryservice.ApplicationHistoryServer"
-
-AMC_DIE_MSG = "Ambari Metrics Collector java process died with exitcode {0}. Check {1} for more information."
-
-
-def save_pid(pid, pidfile):
-  """
-    Save pid to pidfile.
-  """
-  try:
-    pfile = open(pidfile, "w")
-    pfile.write("%s\n" % pid)
-  except IOError:
-    pass
-  finally:
-    try:
-      pfile.close()
-    except:
-      pass
-
-
-def exec_ams_env_cmd(options):
-  ams_env_cmd = os.path.join(options.conf_dir, AMS_ENV_CMD)
-  if os.path.exists(ams_env_cmd):
-    cmds = ["cmd.exe", "/C", ams_env_cmd]
-    procAms = subprocess.Popen(cmds, env=os.environ)
-    out, err = procAms.communicate()
-    if err is not None and err is not "":
-      print_warning_msg(AMS_ENV_CMD + " error output: " + err)
-    if out is not None and out is not "":
-      print_info_msg(AMS_ENV_CMD + " output: " + out)
-  else:
-    err = 'ERROR: Cannot execute "{0}"'.format(ams_env_cmd)
-    raise FatalException(1, err)
-
-
-def server_process_main(options, scmStatus=None):
-  if scmStatus is not None:
-    scmStatus.reportStartPending()
-
-  # debug mode
-  try:
-    global DEBUG_MODE
-    DEBUG_MODE = options.debug
-  except AttributeError:
-    pass
-
-  # stop Java process at startup?
-  try:
-    global SUSPEND_START_MODE
-    SUSPEND_START_MODE = options.suspend_start
-  except AttributeError:
-    pass
-
-  #options.conf_dir <= --config
-  if not os.path.isdir(options.conf_dir):
-    err = 'ERROR: Cannot find configuration directory "{0}"'.format(options.conf_dir)
-    raise FatalException(1, err)
-
-  #execute ams-env.cmd
-  exec_ams_env_cmd(options)
-
-  #Ensure the 3 Hadoop services required are started on the local machine
-  if not options.no_embedded_hbase:
-    from amc_service import ensure_hdp_service_soft_dependencies
-    ensure_hdp_service_soft_dependencies()
-
-  if scmStatus is not None:
-    scmStatus.reportStartPending()
-
-  java_exe = get_java_exe_path()
-  java_class_path = get_java_cp()
-  java_heap_max = build_jvm_args()
-  command_base = SERVER_START_CMD_DEBUG if (DEBUG_MODE or SERVER_START_DEBUG) else SERVER_START_CMD
-  suspend_mode = 'y' if SUSPEND_START_MODE else 'n'
-  command = command_base.format(java_class_path, java_heap_max, suspend_mode)
-  if not os.path.exists(PID_DIR):
-    os.makedirs(PID_DIR, 0755)
-
-  #Ignore the requirement to run as root. In Windows, by default the child process inherits the security context
-  # and the environment from the parent process.
-  param_list = java_exe + " " + command
-
-  print_info_msg("Running server: " + str(param_list))
-  procJava = subprocess.Popen(param_list, env=os.environ)
-
-  #wait for server process for SERVER_START_TIMEOUT seconds
-  print "Waiting for server start..."
-
-  pidJava = procJava.pid
-  if pidJava <= 0:
-    procJava.terminate()
-    exitcode = procJava.returncode
-    save_pid(exitcode, EXITCODE_OUT_FILE)
-
-    if scmStatus is not None:
-      scmStatus.reportStopPending()
-
-    raise FatalException(-1, AMC_DIE_MSG.format(exitcode, SERVER_OUT_FILE))
-  else:
-    save_pid(pidJava, PID_OUT_FILE)
-    print "Server PID at: " + PID_OUT_FILE
-    print "Server out at: " + SERVER_OUT_FILE
-    print "Server log at: " + SERVER_LOG_FILE
-
-  if scmStatus is not None:
-    scmStatus.reportStarted()
-
-  return procJava
-
-def main():
-  from amc_service import init_options_parser, init_service_debug, setup, start, stop, svcstatus
-
-  parser = init_options_parser()
-  (options, args) = parser.parse_args()
-
-  options.warnings = []
-  options.exit_message = None
-
-  init_service_debug(options)
-
-  if len(args) == 0:
-    print parser.print_help()
-    parser.error("No action entered")
-
-  action = args[0]
-
-  try:
-    if action == SETUP_ACTION:
-      setup(options)
-    elif action == START_ACTION:
-      start(options)
-    elif action == STOP_ACTION:
-      stop()
-    elif action == RESTART_ACTION:
-      stop()
-      start(options)
-    elif action == STATUS_ACTION:
-      svcstatus(options)
-    else:
-      parser.error("Invalid action")
-
-    if options.warnings:
-      for warning in options.warnings:
-        print_warning_msg(warning)
-        pass
-      options.exit_message = "Ambari Metrics Collector '%s' completed with warnings." % action
-      pass
-  except FatalException as e:
-    if e.reason is not None:
-      print_error_msg("Exiting with exit code {0}. \nREASON: {1}".format(e.code, e.reason))
-    sys.exit(e.code)
-  except NonFatalException as e:
-    options.exit_message = "Ambari Metrics Collector '%s' completed with warnings." % action
-    if e.reason is not None:
-      print_warning_msg(e.reason)
-
-  if options.exit_message is not None:
-    print options.exit_message
-
-
-if __name__ == "__main__":
-  try:
-    main()
-  except (KeyboardInterrupt, EOFError):
-    print("\nAborting ... Keyboard Interrupt.")
-    sys.exit(1)

+ 0 - 27
ambari-metrics/pom.xml

@@ -56,33 +56,6 @@
   </repositories>
   <build>
     <plugins>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <version>1.8</version>
-        <executions>
-          <execution>
-            <id>parse-version</id>
-            <phase>validate</phase>
-            <goals>
-              <goal>parse-version</goal>
-            </goals>
-          </execution>
-          <execution>
-            <id>regex-property</id>
-            <goals>
-              <goal>regex-property</goal>
-            </goals>
-            <configuration>
-              <name>ambariVersion</name>
-              <value>${project.version}</value>
-              <regex>^([0-9]+)\.([0-9]+)\.([0-9]+)(\.|-).*</regex>
-              <replacement>$1.$2.$3</replacement>
-              <failIfNoMatch>false</failIfNoMatch>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
       <plugin>
         <artifactId>maven-assembly-plugin</artifactId>
         <configuration>

+ 16 - 1
ambari-server/src/main/python/ambari-server-state/Entities.py

@@ -1,3 +1,5 @@
+import inspect
+
 # 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
@@ -14,7 +16,20 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from ambari_commons.xml_utils import ConvertToXml
+class ConvertToXml:
+  "Template class, allow to output fields in xml format"
+  def getField(self):
+    return [name for name, obj in inspect.getmembers(self)
+            if not name.startswith("__") and not inspect.isroutine(obj)]
+
+  def attributesToXml(self):
+    result = ""
+    listOfAttr = self.getField()
+    for attrName in listOfAttr:
+      result += "<" + attrName + ">"
+      result += str(getattr(self, attrName))
+      result += "</" + attrName + ">"
+    return result
 
 
 class Configurations(ConvertToXml):

+ 0 - 2
pom.xml

@@ -179,8 +179,6 @@
             <exclude>derby.log</exclude>
             <exclude>CHANGES.txt</exclude>
             <exclude>pass.txt</exclude>
-            <exclude>ambari-metrics/ambari-metrics-host-monitoring/conf/unix/metric_groups.conf</exclude>
-            <exclude>ambari-metrics/ambari-metrics-host-monitoring/conf/windows/metric_groups.conf</exclude>
             <exclude>contrib/addons/test/dataServices/jmx/data/cluster_configuration.json.nohbase</exclude>
             <exclude>contrib/ambari-scom/msi/src/GUI_Ambari.sln</exclude>
             <exclude>version</exclude>