Repository: ambari Updated Branches: refs/heads/branch-feature-AMBARI-18901 1c5c7df31 -> 4278c4a4f
http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/ambari-web/test/utils/configs/config_initializer_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/configs/config_initializer_test.js b/ambari-web/test/utils/configs/config_initializer_test.js index e951b34..d348055 100644 --- a/ambari-web/test/utils/configs/config_initializer_test.js +++ b/ambari-web/test/utils/configs/config_initializer_test.js @@ -905,312 +905,6 @@ describe('App.ConfigInitializer', function () { }); - describe('config with mount points', function () { - - var localDB = { - masterComponentHosts: [ - { - component: 'NAMENODE', - hostName: 'h0' - }, - { - component: 'SECONDARY_NAMENODE', - hostName: 'h4' - }, - { - component: 'APP_TIMELINE_SERVER', - hostName: 'h0' - }, - { - component: 'ZOOKEEPER_SERVER', - hostName: 'h0' - }, - { - component: 'ZOOKEEPER_SERVER', - hostName: 'h1' - }, - { - component: 'OOZIE_SERVER', - hostName: 'h0' - }, - { - component: 'OOZIE_SERVER', - hostName: 'h1' - }, - { - component: 'NIMBUS', - hostName: 'h2' - }, - { - component: 'FALCON_SERVER', - hostName: 'h3' - }, - { - component: 'KAFKA_BROKER', - hostName: 'h0' - }, - { - component: 'KAFKA_BROKER', - hostName: 'h1' - } - ], - slaveComponentHosts: [ - { - componentName: 'DATANODE', - hosts: [ - { - hostName: 'h0' - }, - { - hostName: 'h1' - } - ] - }, - { - componentName: 'TASKTRACKER', - hosts: [ - { - hostName: 'h0' - }, - { - hostName: 'h1' - } - ] - }, - { - componentName: 'NODEMANAGER', - hosts: [ - { - hostName: 'h0' - }, - { - hostName: 'h1' - }, - { - hostName: 'h4' - } - ] - }, - { - componentName: 'HBASE_REGIONSERVER', - hosts: [ - { - hostName: 'h0' - }, - { - hostName: 'h1' - } - ] - }, - { - componentName: 'SUPERVISOR', - hosts: [ - { - hostName: 'h0' - }, - { - hostName: 'h1' - } - ] - } - ], - hosts: { - h0: { - disk_info: [ - { - mountpoint: '/' - }, - { - mountpoint: '/home' - }, - { - mountpoint: '/boot' - }, - { - mountpoint: '/boot/efi' - }, - { - mountpoint: '/mnt' - }, - { - mountpoint: '/mnt/efi' - }, - { - mountpoint: '/media/disk0', - available: '100000000' - }, - { - mountpoint: '/mount0', - available: '100000000' - } - ] - }, - h4: { - disk_info: [ - { - mountpoint: 'c:', - available: '100000000' - } - ] - } - } - }, - cases = [ - { - name: 'dfs.namenode.name.dir', - isOnlyFirstOneNeeded: false, - value: '/media/disk0/default\n/mount0/default\n' - }, - { - name: 'dfs.name.dir', - isOnlyFirstOneNeeded: false, - value: '/media/disk0/default\n/mount0/default\n' - }, - { - name: 'fs.checkpoint.dir', - isOnlyFirstOneNeeded: true, - value: 'file:///c:/default\n' - }, - { - name: 'dfs.namenode.checkpoint.dir', - isOnlyFirstOneNeeded: true, - value: 'file:///c:/default\n' - }, - { - name: 'dfs.data.dir', - isOnlyFirstOneNeeded: false, - value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n' - }, - { - name: 'dfs.datanode.data.dir', - isOnlyFirstOneNeeded: false, - value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n' - }, - { - name: 'mapred.local.dir', - isOnlyFirstOneNeeded: false, - value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n' - }, - { - name: 'yarn.nodemanager.log-dirs', - isOnlyFirstOneNeeded: false, - value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\nc:\\default\n' - }, - { - name: 'yarn.nodemanager.local-dirs', - isOnlyFirstOneNeeded: false, - value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\nc:\\default\n' - }, - { - name: 'yarn.timeline-service.leveldb-timeline-store.path', - isOnlyFirstOneNeeded: true, - value: '/media/disk0/default' - }, - { - name: 'yarn.timeline-service.leveldb-state-store.path', - isOnlyFirstOneNeeded: true, - value: '/media/disk0/default' - }, - { - name: 'dataDir', - isOnlyFirstOneNeeded: true, - value: '/media/disk0/default' - }, - { - name: 'oozie_data_dir', - isOnlyFirstOneNeeded: true, - value: '/media/disk0/default' - }, - { - name: 'storm.local.dir', - isOnlyFirstOneNeeded: true, - value: '/media/disk0/default' - }, - { - name: '*.falcon.graph.storage.directory', - isOnlyFirstOneNeeded: true, - value: '/default' - }, - { - name: '*.falcon.graph.serialize.path', - isOnlyFirstOneNeeded: true, - value: '/default' - }, - { - name: 'log.dirs', - isOnlyFirstOneNeeded: false, - value: '/media/disk0/default\n/mount0/default\n/media/disk1/default\n/mount1/default\n' - } - ]; - - beforeEach(function () { - sinon.stub(App.Host, 'find').returns([ - Em.Object.create({ - id: 'h1', - diskInfo: [ - { - mountpoint: '/media/disk1', - type: 'devtmpfs' - }, - { - mountpoint: '/media/disk1', - type: 'tmpfs' - }, - { - mountpoint: '/media/disk1', - type: 'vboxsf' - }, - { - mountpoint: '/media/disk1', - type: 'CDFS' - }, - { - mountpoint: '/media/disk1', - available: '0' - }, - { - mountpoint: '/media/disk1', - available: '100000000' - }, - { - mountpoint: '/mount1', - available: '100000000' - } - ] - }), - Em.Object.create({ - id: 'h2', - diskInfo: [ - { - mountpoint: '/' - } - ] - }), - Em.Object.create({ - id: 'h3', - diskInfo: [] - }) - ]); - }); - - afterEach(function () { - App.Host.find.restore(); - }); - - cases.forEach(function (item) { - it(item.name, function () { - serviceConfigProperty.setProperties({ - name: item.name, - recommendedValue: '/default' - }); - App.ConfigInitializer.initialValue(serviceConfigProperty, localDB, {}); - expect(serviceConfigProperty.get('value')).to.equal(item.value); - expect(serviceConfigProperty.get('recommendedValue')).to.equal(item.value); - }); - }); - - }); - describe('initializerTypes', function () { var types = App.ConfigInitializer.get('initializerTypes'); Em.keys(types).forEach(function(type) { @@ -1275,155 +969,4 @@ describe('App.ConfigInitializer', function () { }); }); - describe('#_filterMountPoint', function() { - [ - { - mPoint: { - mountpoint: '/' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/home' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/etc/resolv.conf' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/etc/hostname' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/etc/hosts' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/boot' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/mnt' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/tmp' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/some-dir', - type: 'devtmpfs' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/some-dir', - type: 'tmpfs' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/some-dir', - type: 'vboxsf' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/some-dir', - type: 'CDFS' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/usr/hdp' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/usr/hdp/1' - }, - localDB: {}, - e: false - }, - { - mPoint: { - mountpoint: '/usr/hdp/current' - }, - localDB: {}, - e: true - }, - { - mPoint: { - mountpoint: '/usr/hdp/2.5' - }, - localDB: { - selectedStack: { - repository_version: '2.5' - } - }, - e: true - }, - { - mPoint: { - mountpoint: '/usr/hdp/2.5.0' - }, - localDB: { - selectedStack: { - repository_version: '2.5' - } - }, - e: false - }, - { - mPoint: { - mountpoint: '/normal/directory' - }, - localDB: { - selectedStack: { - repository_version: '2.5' - } - }, - e: true - } - ].forEach(function(test) { - it('mount point "{0}" should be {1}'.format(test.mPoint.mountpoint, test.e ? 'valid' : 'invalid'), function() { - var fFn = App.ConfigInitializer._filterMountPoint(test.localDB); - expect(fFn(test.mPoint)).to.be.equal(test.e); - }); - }); - }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js index 5630a8c..075bcc8 100644 --- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js +++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js @@ -416,7 +416,7 @@ describe('App.upgradeWizardView', function () { }); }); - App.TestAliases.testAsComputedAnd(getView(), 'isDowngradeAvailable', ['!controller.isDowngrade', 'controller.downgradeAllowed']); + App.TestAliases.testAsComputedAnd(getView(), 'isDowngradeAvailable', ['!controller.isDowngrade', 'controller.downgradeAllowed', '!controller.cantBeStarted']); describe("#taskDetails", function () { it("runningItem present", function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/utils/perf/deploy-gce-perf-cluster.py ---------------------------------------------------------------------- diff --git a/contrib/utils/perf/deploy-gce-perf-cluster.py b/contrib/utils/perf/deploy-gce-perf-cluster.py index 4737c6f..fe5f22d 100644 --- a/contrib/utils/perf/deploy-gce-perf-cluster.py +++ b/contrib/utils/perf/deploy-gce-perf-cluster.py @@ -28,7 +28,7 @@ import re import socket cluster_prefix = "perf" -ambari_repo_file_url = "http://s3.amazonaws.com/dev.hortonworks.com/ambari/centos6/2.x/latest/trunk/ambaribn.repo" +ambari_repo_file_url = "http://s3.amazonaws.com/dev.hortonworks.com/ambari/centos6/2.x/updates/2.5.0.0/ambaribn.repo" public_hostname_script = "foo" hostname_script = "foo" @@ -280,13 +280,13 @@ def create_vms(args, number_of_nodes): :param number_of_nodes: Number of VMs to request. """ print "Creating server VM {0}-server-{1} with xxlarge nodes on centos6...".format(cluster_prefix, args.cluster_suffix) - execute_command(args, args.controller, "/usr/sbin/gce up {0}-server-{1} 1 --centos6 --xxlarge".format(cluster_prefix, args.cluster_suffix), + execute_command(args, args.controller, "/usr/sbin/gce up {0}-server-{1} 1 --centos6 --xxlarge --ex --disk-xxlarge".format(cluster_prefix, args.cluster_suffix), "Failed to create server, probably not enough resources!", "-tt") time.sleep(10) # trying to create cluster with needed params - print "Creating agent VMs {0}-agent-{1} with {2} large nodes on centos6...".format(cluster_prefix, args.cluster_suffix, str(number_of_nodes)) - execute_command(args, args.controller, "/usr/sbin/gce up {0}-agent-{1} {2} --centos6 --large".format(cluster_prefix, args.cluster_suffix, str(number_of_nodes)), + print "Creating agent VMs {0}-agent-{1} with {2} xlarge nodes on centos6...".format(cluster_prefix, args.cluster_suffix, str(number_of_nodes)) + execute_command(args, args.controller, "/usr/sbin/gce up {0}-agent-{1} {2} --centos6 --xlarge --ex --disk-large".format(cluster_prefix, args.cluster_suffix, str(number_of_nodes)), "Failed to create cluster VMs, probably not enough resources!", "-tt") # VMs are not accessible immediately @@ -331,7 +331,7 @@ def create_server_script(server_host_name): contents = "#!/bin/bash\n" + \ "wget -O /etc/yum.repos.d/ambari.repo {0}\n".format(ambari_repo_file_url) + \ "yum clean all; yum install git ambari-server -y\n" + \ - "mkdir /home ; cd /home ; git clone https://github.com/apache/ambari.git\n" + \ + "mkdir /home ; cd /home ; git clone https://github.com/apache/ambari.git ; cd ambari ; git checkout branch-2.5\n" + \ "cp -r /home/ambari/ambari-server/src/main/resources/stacks/PERF /var/lib/ambari-server/resources/stacks/PERF\n" + \ "cp -r /home/ambari/ambari-server/src/main/resources/stacks/PERF /var/lib/ambari-agent/cache/stacks/PERF\n" + \ "\n" + \ @@ -357,6 +357,7 @@ def create_server_script(server_host_name): "sed -i -e 's/local.database.user=postgres//g' /etc/ambari-server/conf/ambari.properties\n" + \ "sed -i -e 's/server.jdbc.postgres.schema=ambari//g' /etc/ambari-server/conf/ambari.properties\n" + \ "sed -i -e 's/false/true/g' /var/lib/ambari-server/resources/stacks/PERF/1.0/metainfo.xml\n" + \ + "sed -i -e 's/-Xmx2048m/-Xmx16384m/g' /var/lib/ambari-server/ambari-env.sh\n" + \ "\n" + \ "echo 'server.jdbc.driver=com.mysql.jdbc.Driver' >> /etc/ambari-server/conf/ambari.properties\n" + \ "echo 'server.jdbc.rca.url=jdbc:mysql://{0}:3306/ambari' >> /etc/ambari-server/conf/ambari.properties\n".format(server_host_name) + \ @@ -384,7 +385,7 @@ def create_agent_script(server_host_name): contents = "#!/bin/bash\n" + \ "wget -O /etc/yum.repos.d/ambari.repo {0}\n".format(ambari_repo_file_url) + \ "yum clean all; yum install git ambari-agent -y\n" + \ - "mkdir /home ; cd /home; git clone https://github.com/apache/ambari.git\n" + \ + "mkdir /home ; cd /home; git clone https://github.com/apache/ambari.git ; cd ambari ; git checkout branch-2.5\n" + \ "cp -r /home/ambari/ambari-server/src/main/resources/stacks/PERF /var/lib/ambari-agent/cache/stacks/PERF\n" + \ "sed -i -e 's/hostname=localhost/hostname={0}/g' /etc/ambari-agent/conf/ambari-agent.ini\n".format(server_host_name) + \ "sed -i -e 's/agent]/agent]\\nhostname_script={0}\\npublic_hostname_script={1}\\n/1' /etc/ambari-agent/conf/ambari-agent.ini\n".format(hostname_script, public_hostname_script) + \ http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/capacity-scheduler/src/main/resources/ui/app/app.js ---------------------------------------------------------------------- diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/app.js b/contrib/views/capacity-scheduler/src/main/resources/ui/app/app.js index fa1e05a..5854a09 100644 --- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/app.js +++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/app.js @@ -53,4 +53,16 @@ Ember.Application.initializer({ } }); -module.exports = Em.Application.create(); +module.exports = Em.Application.create({ + Resolver: Ember.DefaultResolver.extend({ + resolveTemplate: function(parsedName) { + var resolvedTemplate = this._super(parsedName); + var templateName = 'templates/' + parsedName.fullNameWithoutType.replace(/\./g, '/'); + if (resolvedTemplate) { + return resolvedTemplate; + } else { + return Ember.TEMPLATES[templateName]; + } + } + }) +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/capacity-scheduler/src/main/resources/view.xml ---------------------------------------------------------------------- diff --git a/contrib/views/capacity-scheduler/src/main/resources/view.xml b/contrib/views/capacity-scheduler/src/main/resources/view.xml index 84a9ee0..cba243c 100644 --- a/contrib/views/capacity-scheduler/src/main/resources/view.xml +++ b/contrib/views/capacity-scheduler/src/main/resources/view.xml @@ -23,19 +23,22 @@ <min-ambari-version>2.1.*</min-ambari-version> <cluster-config-options>AMBARI-ONLY</cluster-config-options> - <resource> - <name>scheduler</name> - <service-class>org.apache.ambari.view.capacityscheduler.CapacitySchedulerService</service-class> + <resource> + <name>scheduler</name> + <service-class>org.apache.ambari.view.capacityscheduler.CapacitySchedulerService</service-class> </resource> <auto-instance> - <name>AUTO_CS_INSTANCE</name> - <label>YARN Queue Manager</label> - <description>Manage YARN Capacity Scheduler Queues</description> - <stack-id>HDP-2.*</stack-id> - <services> - <service>YARN</service> - </services> + <name>AUTO_CS_INSTANCE</name> + <label>YARN Queue Manager</label> + <description>Manage YARN Capacity Scheduler Queues</description> + <stack-id>HDP-2.*</stack-id> + <services> + <service>YARN</service> + </services> + <roles> + <role>CLUSTER.ADMINISTRATOR</role> + </roles> </auto-instance> </view> http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/files/src/main/resources/view.xml ---------------------------------------------------------------------- diff --git a/contrib/views/files/src/main/resources/view.xml b/contrib/views/files/src/main/resources/view.xml index d6b2fde..640cee9 100644 --- a/contrib/views/files/src/main/resources/view.xml +++ b/contrib/views/files/src/main/resources/view.xml @@ -155,5 +155,12 @@ <services> <service>HDFS</service> </services> + <roles> + <role>CLUSTER.ADMINISTRATOR</role> + <role>CLUSTER.OPERATOR</role> + <role>SERVICE.ADMINISTRATOR</role> + <role>SERVICE.OPERATOR</role> + <role>CLUSTER.USER</role> + </roles> </auto-instance> </view> http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/hive-next/src/main/resources/view.xml ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/resources/view.xml b/contrib/views/hive-next/src/main/resources/view.xml index 02e632c..1107cd1 100644 --- a/contrib/views/hive-next/src/main/resources/view.xml +++ b/contrib/views/hive-next/src/main/resources/view.xml @@ -337,5 +337,12 @@ <services> <service>HIVE</service> </services> + <roles> + <role>CLUSTER.ADMINISTRATOR</role> + <role>CLUSTER.OPERATOR</role> + <role>SERVICE.ADMINISTRATOR</role> + <role>SERVICE.OPERATOR</role> + <role>CLUSTER.USER</role> + </roles> </auto-instance> </view> http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/pig/src/main/resources/ui/pig-web/app/app.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/app/app.js b/contrib/views/pig/src/main/resources/ui/pig-web/app/app.js index 866b8a7..c683f72 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/app/app.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/app/app.js @@ -35,5 +35,17 @@ module.exports = Em.Application.create({ } var namespaceUrl = 'api/v1/views' + view + version + '/instances' + instance; return namespaceUrl; - } + }, + + Resolver: Ember.DefaultResolver.extend({ + resolveTemplate: function(parsedName) { + var resolvedTemplate = this._super(parsedName); + var templateName = 'templates/' + parsedName.fullNameWithoutType.replace(/\./g, '/'); + if (resolvedTemplate) { + return resolvedTemplate; + } else { + return Ember.TEMPLATES[templateName]; + } + } + }) }); http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/pom.xml ---------------------------------------------------------------------- diff --git a/contrib/views/pom.xml b/contrib/views/pom.xml index ca5aef4..440274b 100644 --- a/contrib/views/pom.xml +++ b/contrib/views/pom.xml @@ -46,7 +46,6 @@ <module>tez</module> <module>hawq</module> <module>storm</module> - <module>zeppelin</module> <module>hueambarimigration</module> <module>hive-next</module> <module>hive</module> http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/tez/src/main/resources/view.xml ---------------------------------------------------------------------- diff --git a/contrib/views/tez/src/main/resources/view.xml b/contrib/views/tez/src/main/resources/view.xml index 2bb2bb0..41ffdbc 100644 --- a/contrib/views/tez/src/main/resources/view.xml +++ b/contrib/views/tez/src/main/resources/view.xml @@ -91,5 +91,12 @@ limitations under the License. Kerberos, LDAP, Custom. Binary/Htt <services> <service>TEZ</service> </services> + <roles> + <role>CLUSTER.ADMINISTRATOR</role> + <role>CLUSTER.OPERATOR</role> + <role>SERVICE.ADMINISTRATOR</role> + <role>SERVICE.OPERATOR</role> + <role>CLUSTER.USER</role> + </roles> </auto-instance> </view> http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/job-details.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/job-details.hbs b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/job-details.hbs index 0a04d25..f17f89e 100644 --- a/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/job-details.hbs +++ b/contrib/views/wfmanager/src/main/resources/ui/app/templates/components/job-details.hbs @@ -52,7 +52,7 @@ <li {{action 'getJobDag'}} role="presentation"><a href="#jobDag" aria-controls="jobDag" role="tab" data-toggle="tab">Flow Graph</a></li> <li role="presentation" class="pull-right"> {{#link-to 'design' (query-params appPath=model.appPath) class="backto-designer" }} - <button type="button" class="btn btn-success" title="Back" > + <button type="button" class="btn btn-success" title="Edit Workflow" > Edit Workflow </button> {{/link-to}} http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/zeppelin/pom.xml ---------------------------------------------------------------------- diff --git a/contrib/views/zeppelin/pom.xml b/contrib/views/zeppelin/pom.xml deleted file mode 100644 index 6a7f585..0000000 --- a/contrib/views/zeppelin/pom.xml +++ /dev/null @@ -1,190 +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. ---> -<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.ambari.contrib.views</groupId> - <artifactId>zeppelin-view</artifactId> - <version>1.0.0.0</version> - <name>Zeppelin</name> - - <parent> - <groupId>org.apache.ambari.contrib.views</groupId> - <artifactId>ambari-contrib-views</artifactId> - <version>2.5.0.0.0</version> - </parent> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.8.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.easymock</groupId> - <artifactId>easymock</artifactId> - <version>3.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.ambari</groupId> - <artifactId>ambari-views</artifactId> - <version>2.5.0.0.0</version> - </dependency> - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-server</artifactId> - <version>1.8</version> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>2.5</version> - <scope>provided</scope> - </dependency> - - - <dependency> - <groupId>commons-configuration</groupId> - <artifactId>commons-configuration</artifactId> - <version>1.6</version> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-csv</artifactId> - <version>1.0</version> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-collections4</artifactId> - <version>4.0</version> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>1.7.5</version> - </dependency> - - <dependency> - <groupId>org.apache.ambari.contrib.views</groupId> - <artifactId>ambari-views-utils</artifactId> - <version>2.5.0.0.0</version> - </dependency> - <dependency> - <groupId>org.json</groupId> - <artifactId>json</artifactId> - <version>20160212</version> - </dependency> - - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - <version>4.5.2</version> - </dependency> - - - </dependencies> - - <properties> - <ambari.dir>${project.parent.parent.parent.basedir}</ambari.dir> - <hive-version>1.0.0</hive-version> - <ambari.version>2.5.0.0.0</ambari.version> - </properties> - <build> - <plugins> - - <!-- Building frontend --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.1</version> - <configuration> - <source>1.7</source> - <target>1.7</target> - </configuration> - </plugin> - <plugin> - <artifactId>maven-dependency-plugin</artifactId> - <executions> - <execution> - <phase>generate-resources</phase> - <goals> - <goal>copy-dependencies</goal> - </goals> - <configuration> - <outputDirectory>${project.build.directory}/lib</outputDirectory> - <includeScope>runtime</includeScope> - </configuration> - </execution> - <execution> - <id>copy-artifact</id> - <phase>package</phase> - <goals> - <goal>copy</goal> - </goals> - <configuration> - <artifactItems> - <artifactItem> - <groupId>${project.groupId}</groupId> - <artifactId>${project.artifactId}</artifactId> - <version>${project.version}</version> - <type>${project.packaging}</type> - </artifactItem> - </artifactItems> - <outputDirectory>${views.jars.dir.rel}</outputDirectory> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.vafer</groupId> - <artifactId>jdeb</artifactId> - <version>1.0.1</version> - <executions> - <execution> - <phase>none</phase> - <goals> - <goal>jdeb</goal> - </goals> - </execution> - </executions> - <configuration> - <submodules>false</submodules> - </configuration> - </plugin> - </plugins> - <resources> - <resource> - <directory>src/main/resources</directory> - <filtering>true</filtering> - <includes> - <include>WEB-INF/web.xml</include> - <include>META-INF/**/*</include> - <include>view.xml</include> - <include>WEB-INF/index.jsp</include> - </includes> - </resource> - <resource> - <targetPath>WEB-INF/lib</targetPath> - <filtering>false</filtering> - <directory>target/lib</directory> - </resource> - </resources> - </build> -</project> http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServiceCheck.java ---------------------------------------------------------------------- diff --git a/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServiceCheck.java b/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServiceCheck.java deleted file mode 100644 index 8f94260..0000000 --- a/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServiceCheck.java +++ /dev/null @@ -1,55 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.view.zeppelin; - -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.HttpClientBuilder; -import org.json.JSONObject; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.PrintWriter; - - -public class ZeppelinServiceCheck { - static String check(String host, String port) { - String url = "http://" + host + ":" + port; - JSONObject json = new JSONObject(); - json.put("url", url); - try { - HttpClient httpclient = HttpClientBuilder.create().build(); - HttpGet httpget = new HttpGet(url); - HttpResponse httpresponse = httpclient.execute(httpget); - if (httpresponse.getStatusLine().getStatusCode() == 200) { - json.put("status", "SUCCESS"); - json.put("message", "Zeppelin is running"); - } - } catch (Exception e) { - json.put("status", "ERROR"); - json.put("message", "Zeppelin is not running"); - } - return json.toString(); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServlet.java ---------------------------------------------------------------------- diff --git a/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServlet.java b/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServlet.java deleted file mode 100644 index ab61a3d..0000000 --- a/contrib/views/zeppelin/src/main/java/org/apache/ambari/view/zeppelin/ZeppelinServlet.java +++ /dev/null @@ -1,113 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.view.zeppelin; - -import org.apache.ambari.view.ViewContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.List; - - -public class ZeppelinServlet extends HttpServlet { - private ViewContext viewContext; - private final static Logger LOG = LoggerFactory.getLogger(ZeppelinServlet.class); - - @Override - public void init(ServletConfig config) throws ServletException { - super.init(config); - - ServletContext context = config.getServletContext(); - viewContext = (ViewContext) context.getAttribute(ViewContext.CONTEXT_ATTRIBUTE); - } - - public void service(HttpServletRequest req, - HttpServletResponse res) throws IOException { - res.setContentType("text/html"); - PrintWriter out = res.getWriter(); - String publicName = ""; - String port = ""; - try { - port = viewContext.getProperties().get("zeppelin.server.port"); - if (viewContext.getCluster() != null) { - List<String> hostsForServiceComponents = viewContext.getCluster().getHostsForServiceComponent - ("ZEPPELIN", "ZEPPELIN_MASTER"); - publicName = hostsForServiceComponents.get(0); - } else { - publicName = viewContext.getProperties().get("zeppelin.host.publicname"); - } - } catch (Exception e) { - LOG.error("Zeppelin view servlet failed", e); - } - out.println("<html lang=\"en\">" + - "<head>" + - " <meta charset=\"utf-8\"/>" + - " <link rel=\"stylesheet\" href=\"/stylesheets/vendor.css\">" + - "</head>" + - "<body>" + - "" + - "<div class=\"container-fluid\" id=\"messageContainer\" style=\"display:none;\">" + - " <h1>Welcome to the Zeppelin View</h1>" + - " <h3>Service check failed</h3>" + - "" + - " <table class=\"table\">" + - " <tbody>" + - " <tr>" + - " <td>zeppelin service is not running</td>" + - " </tr>" + - " </tbody>" + - " </table>" + - "" + - "</div>" + - "" + - "<iframe id='zeppelinIFrame' width=\"100%\" seamless=\"seamless\" style=\"border: 0px;\"></iframe>" + - "<script>" + - "var $ = jQuery = parent.jQuery;" + - "var iframe = document.querySelector('#zeppelinIFrame');" + - "var messageContainer = document.querySelector('#messageContainer');" + - "" + - "var serviceCheckResponse = $.parseJSON(' " + ZeppelinServiceCheck.check(publicName, port) + "');" + - "" + - "if (serviceCheckResponse.status === \"SUCCESS\") {" + - " messageContainer.style.display = \"none\";" + - " iframe.style.display = \"block\";" + - " iframe.src = serviceCheckResponse.url;" + - " iframe.height = window.innerHeight;" + - "} else {" + - " messageContainer.style.display = \"block\";" + - " iframe.style.display = \"none\";" + - "}" + - "" + - "$(window).resize(function () {" + - " iframe.height = window.innerHeight;" + - "});" + - "</script>" + - "</body>" + - "</html>"); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/zeppelin/src/main/resources/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/contrib/views/zeppelin/src/main/resources/WEB-INF/web.xml b/contrib/views/zeppelin/src/main/resources/WEB-INF/web.xml deleted file mode 100644 index 6b2d156..0000000 --- a/contrib/views/zeppelin/src/main/resources/WEB-INF/web.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> - -<!-- -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. Kerberos, LDAP, Custom. Binary/Htt ---> - -<web-app xmlns="http://java.sun.com/xml/ns/j2ee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" - version="2.4"> - - <display-name>Zeppelin view servlet</display-name> - <description> - This is the Zeppelin view servlet application. - </description> - - <servlet> - <servlet-name>ZeppelinServlet</servlet-name> - <servlet-class>org.apache.ambari.view.zeppelin.ZeppelinServlet</servlet-class> - </servlet> - - <servlet-mapping> - <servlet-name>ZeppelinServlet</servlet-name> - <url-pattern>/</url-pattern> - </servlet-mapping> - -</web-app> http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/zeppelin/src/main/resources/view.log4j.properties ---------------------------------------------------------------------- diff --git a/contrib/views/zeppelin/src/main/resources/view.log4j.properties b/contrib/views/zeppelin/src/main/resources/view.log4j.properties deleted file mode 100644 index 15d264e..0000000 --- a/contrib/views/zeppelin/src/main/resources/view.log4j.properties +++ /dev/null @@ -1,27 +0,0 @@ -# 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. - -log4j.appender.zeppelinView=org.apache.log4j.RollingFileAppender -log4j.appender.zeppelinView.File=${ambari.log.dir}/zeppelin-view/zeppelin-view.log -log4j.appender.zeppelinView.MaxFileSize=80MB -log4j.appender.zeppelinView.MaxBackupIndex=60 -log4j.appender.zeppelinView.layout=org.apache.log4j.PatternLayout -log4j.appender.zeppelinView.layout.ConversionPattern=%d{DATE} %5p [%t] [%X{viewName} %X{viewVersion} %X{viewInstanceName}] %c{1}:%L - %m%n - -log4j.logger.org.apache.ambari.view.zeppelin=INFO,zeppelinView -log4j.additivity.org.apache.ambari.view.zeppelin=false \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/contrib/views/zeppelin/src/main/resources/view.xml ---------------------------------------------------------------------- diff --git a/contrib/views/zeppelin/src/main/resources/view.xml b/contrib/views/zeppelin/src/main/resources/view.xml deleted file mode 100644 index 323e09a..0000000 --- a/contrib/views/zeppelin/src/main/resources/view.xml +++ /dev/null @@ -1,48 +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. Kerberos, LDAP, Custom. Binary/Htt ---> -<view> - <name>ZEPPELIN</name> - <label>Zeppelin View!</label> - <version>1.0.0</version> - <build>${env.BUILD_NUMBER}</build> - <description>Ambari view for Apache Zeppelin</description> - - <parameter> - <name>zeppelin.server.port</name> - <description>Zeppelin Http port (example: 9995).</description> - <label>Zeppelin Http port</label> - <cluster-config>zeppelin-config/zeppelin.server.port</cluster-config> - <required>true</required> - </parameter> - <parameter> - <name>zeppelin.host.publicname</name> - <description>Zeppelin host name</description> - <label>Zeppelin host name</label> - <cluster-config>fake</cluster-config> - <required>true</required> - </parameter> - - <auto-instance> - <name>AUTO_ZEPPELIN_INSTANCE</name> - <label>Zeppelin View</label> - <description>This view instance is auto created when the Zeppelin service is added to a cluster.</description> - <stack-id>HDP-2.*</stack-id> - <services> - <service>ZEPPELIN</service> - </services> - </auto-instance> -</view> http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 95465d5..b400268 100644 --- a/pom.xml +++ b/pom.xml @@ -266,6 +266,7 @@ <exclude>contrib/agent-simulator/docker_image/package_list.txt</exclude> <exclude>contrib/agent-simulator/config/cluster.txt</exclude> <exclude>version</exclude> + <exclude>**/target/surefire-reports/</exclude> <!--IDE and GIT files--> <exclude>**/.idea/</exclude> <exclude>**/.classpath/</exclude> http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/utility/pom.xml ---------------------------------------------------------------------- diff --git a/utility/pom.xml b/utility/pom.xml index 2febb83..8380db9 100644 --- a/utility/pom.xml +++ b/utility/pom.xml @@ -20,6 +20,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.ambari</groupId> + <artifactId>ambari-project</artifactId> + <version>2.5.0.0.0</version> + <relativePath>../ambari-project</relativePath> + </parent> + <artifactId>utility</artifactId> <groupId>utility</groupId> <version>1.0.0.0-SNAPSHOT</version> @@ -28,9 +35,25 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.12</version> <scope>compile</scope> <!-- has to be compile-time dependency on junit --> </dependency> + <dependency> + <groupId>com.puppycrawl.tools</groupId> + <artifactId>checkstyle</artifactId> + </dependency> + <dependency> + <groupId>com.puppycrawl.tools</groupId> + <artifactId>checkstyle</artifactId> + <type>test-jar</type> + <version>${checkstyle.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>19.0</version> <!-- required for checkstyle --> + <scope>test</scope> + </dependency> </dependencies> <build> @@ -45,6 +68,14 @@ </configuration> </plugin> <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <descriptors> + <descriptor>${project.parent.basedir}/src/main/assemblies/empty.xml</descriptor> + </descriptors> + </configuration> + </plugin> + <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>rpm-maven-plugin</artifactId> <version>2.0.1</version> http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/utility/src/main/java/org/apache/ambari/checkstyle/AvoidTransactionalOnPrivateMethodsCheck.java ---------------------------------------------------------------------- diff --git a/utility/src/main/java/org/apache/ambari/checkstyle/AvoidTransactionalOnPrivateMethodsCheck.java b/utility/src/main/java/org/apache/ambari/checkstyle/AvoidTransactionalOnPrivateMethodsCheck.java new file mode 100644 index 0000000..80da103 --- /dev/null +++ b/utility/src/main/java/org/apache/ambari/checkstyle/AvoidTransactionalOnPrivateMethodsCheck.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.ambari.checkstyle; + +import com.puppycrawl.tools.checkstyle.api.AbstractCheck; +import com.puppycrawl.tools.checkstyle.api.DetailAST; +import com.puppycrawl.tools.checkstyle.api.TokenTypes; + +/** + * Detects private methods annotated as <code>Transactional</code>. + * See https://github.com/google/guice/wiki/Transactions for why this should be + * avoided. + */ +public class AvoidTransactionalOnPrivateMethodsCheck extends AbstractCheck { + + private static final String ANNOTATION_NAME = "Transactional"; + public static final String MSG_TRANSACTIONAL_ON_PRIVATE_METHOD = "@" + ANNOTATION_NAME + " should not be used on private methods"; + + @Override + public int[] getDefaultTokens() { + return new int[] { TokenTypes.METHOD_DEF }; + } + + @Override + public void visitToken(DetailAST ast) { + DetailAST modifiers = ast.findFirstToken(TokenTypes.MODIFIERS); + if (modifiers.findFirstToken(TokenTypes.LITERAL_PRIVATE) != null) { + DetailAST annotation = modifiers.findFirstToken(TokenTypes.ANNOTATION); + while (annotation != null) { + DetailAST name = annotation.findFirstToken(TokenTypes.IDENT); + if (name != null && ANNOTATION_NAME.equals(name.getText())) { + log(ast.getLineNo(), MSG_TRANSACTIONAL_ON_PRIVATE_METHOD); + break; + } + annotation = annotation.getNextSibling(); + } + } + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/utility/src/main/resources/checkstyle_packages.xml ---------------------------------------------------------------------- diff --git a/utility/src/main/resources/checkstyle_packages.xml b/utility/src/main/resources/checkstyle_packages.xml new file mode 100644 index 0000000..8cf4a44 --- /dev/null +++ b/utility/src/main/resources/checkstyle_packages.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Licensed 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. + See accompanying LICENSE file. --> +<!DOCTYPE checkstyle-packages PUBLIC + "-//Puppy Crawl//DTD Package Names 1.0//EN" + "http://www.puppycrawl.com/dtds/packages_1_0.dtd"> +<checkstyle-packages> + <package name="org.apache.ambari.checkstyle"/> +</checkstyle-packages> http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/utility/src/test/java/org/apache/ambari/checkstyle/AvoidTransactionalOnPrivateMethodsCheckTest.java ---------------------------------------------------------------------- diff --git a/utility/src/test/java/org/apache/ambari/checkstyle/AvoidTransactionalOnPrivateMethodsCheckTest.java b/utility/src/test/java/org/apache/ambari/checkstyle/AvoidTransactionalOnPrivateMethodsCheckTest.java new file mode 100644 index 0000000..14d7486 --- /dev/null +++ b/utility/src/test/java/org/apache/ambari/checkstyle/AvoidTransactionalOnPrivateMethodsCheckTest.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.ambari.checkstyle; + +import static org.apache.ambari.checkstyle.AvoidTransactionalOnPrivateMethodsCheck.MSG_TRANSACTIONAL_ON_PRIVATE_METHOD; + +import java.io.File; +import java.io.IOException; + +import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport; +import com.puppycrawl.tools.checkstyle.DefaultConfiguration; + +import org.junit.Test; + +public class AvoidTransactionalOnPrivateMethodsCheckTest extends BaseCheckTestSupport { + + @Override + protected String getPath(String filename) throws IOException { + return new File("src/test/resources/org/apache/ambari/checkstyle/" + filename) + .getCanonicalPath(); + } + + @Test + public void transactionalOnPrivateMethod() throws Exception { + final DefaultConfiguration config = createCheckConfig(AvoidTransactionalOnPrivateMethodsCheck.class); + final String[] expected = { + "32: " + MSG_TRANSACTIONAL_ON_PRIVATE_METHOD, + "41: " + MSG_TRANSACTIONAL_ON_PRIVATE_METHOD, + }; + + verify(config, getPath("InputTransactionalOnPrivateMethods.java"), expected); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/4278c4a4/utility/src/test/resources/org/apache/ambari/checkstyle/InputTransactionalOnPrivateMethods.java ---------------------------------------------------------------------- diff --git a/utility/src/test/resources/org/apache/ambari/checkstyle/InputTransactionalOnPrivateMethods.java b/utility/src/test/resources/org/apache/ambari/checkstyle/InputTransactionalOnPrivateMethods.java new file mode 100644 index 0000000..2ea5444 --- /dev/null +++ b/utility/src/test/resources/org/apache/ambari/checkstyle/InputTransactionalOnPrivateMethods.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.ambari.checkstyle; + +import com.google.inject.persist.Transactional; + +/** + * Input file for AvoidTransactionalOnPrivateMethodsCheckTest. + */ +public class InputTransactionalOnPrivateMethods { + + @Transactional + public void publicMethodWithTransactional() { + ; + } + + @Transactional + private void privateMethodWithTransactional() { + ; + } + + private void privateMethodWithoutTransactional() { + ; + } + + @Transactional + private void otherPrivateMethodWithTransactional() { + ; + } + +}