Repository: Netflix/SimianArmy
Branch: master
Commit: e8eb9f3bad23
Files: 289
Total size: 1.3 MB
Directory structure:
gitextract_54dtl7c9/
├── .gitignore
├── .netflixoss
├── .travis.yml
├── CHANGELOG.md
├── GNUmakefile
├── LICENSE
├── OSSMETADATA
├── README.md
├── build.gradle
├── buildViaTravis.sh
├── codequality/
│ ├── checkstyle.xml
│ └── org.eclipse.jdt.core.prefs
├── gradle/
│ └── wrapper/
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── installViaTravis.sh
├── settings.gradle
└── src/
├── main/
│ ├── java/
│ │ └── com/
│ │ └── netflix/
│ │ └── simianarmy/
│ │ ├── AbstractEmailBuilder.java
│ │ ├── CloudClient.java
│ │ ├── EmailBuilder.java
│ │ ├── EventType.java
│ │ ├── FeatureNotEnabledException.java
│ │ ├── GroupType.java
│ │ ├── InstanceGroupNotFoundException.java
│ │ ├── Monkey.java
│ │ ├── MonkeyCalendar.java
│ │ ├── MonkeyConfiguration.java
│ │ ├── MonkeyEmailNotifier.java
│ │ ├── MonkeyRecorder.java
│ │ ├── MonkeyRunner.java
│ │ ├── MonkeyScheduler.java
│ │ ├── MonkeyType.java
│ │ ├── NamedType.java
│ │ ├── NotFoundException.java
│ │ ├── Resource.java
│ │ ├── ResourceType.java
│ │ ├── aws/
│ │ │ ├── AWSEmailNotifier.java
│ │ │ ├── AWSResource.java
│ │ │ ├── AWSResourceType.java
│ │ │ ├── RDSRecorder.java
│ │ │ ├── STSAssumeRoleSessionCredentialsProvider.java
│ │ │ ├── SimpleDBRecorder.java
│ │ │ ├── conformity/
│ │ │ │ ├── RDSConformityClusterTracker.java
│ │ │ │ ├── SimpleDBConformityClusterTracker.java
│ │ │ │ ├── crawler/
│ │ │ │ │ └── AWSClusterCrawler.java
│ │ │ │ └── rule/
│ │ │ │ ├── BasicConformityEurekaClient.java
│ │ │ │ ├── ConformityEurekaClient.java
│ │ │ │ ├── CrossZoneLoadBalancing.java
│ │ │ │ ├── InstanceHasHealthCheckUrl.java
│ │ │ │ ├── InstanceHasStatusUrl.java
│ │ │ │ ├── InstanceInSecurityGroup.java
│ │ │ │ ├── InstanceInVPC.java
│ │ │ │ ├── InstanceIsHealthyInEureka.java
│ │ │ │ ├── InstanceTooOld.java
│ │ │ │ └── SameZonesInElbAndAsg.java
│ │ │ └── janitor/
│ │ │ ├── ASGJanitor.java
│ │ │ ├── EBSSnapshotJanitor.java
│ │ │ ├── EBSVolumeJanitor.java
│ │ │ ├── ELBJanitor.java
│ │ │ ├── ImageJanitor.java
│ │ │ ├── InstanceJanitor.java
│ │ │ ├── LaunchConfigJanitor.java
│ │ │ ├── RDSJanitorResourceTracker.java
│ │ │ ├── SimpleDBJanitorResourceTracker.java
│ │ │ ├── VolumeTaggingMonkey.java
│ │ │ ├── crawler/
│ │ │ │ ├── ASGJanitorCrawler.java
│ │ │ │ ├── AbstractAWSJanitorCrawler.java
│ │ │ │ ├── EBSSnapshotJanitorCrawler.java
│ │ │ │ ├── EBSVolumeJanitorCrawler.java
│ │ │ │ ├── ELBJanitorCrawler.java
│ │ │ │ ├── InstanceJanitorCrawler.java
│ │ │ │ ├── LaunchConfigJanitorCrawler.java
│ │ │ │ └── edda/
│ │ │ │ ├── EddaASGJanitorCrawler.java
│ │ │ │ ├── EddaEBSSnapshotJanitorCrawler.java
│ │ │ │ ├── EddaEBSVolumeJanitorCrawler.java
│ │ │ │ ├── EddaELBJanitorCrawler.java
│ │ │ │ ├── EddaImageJanitorCrawler.java
│ │ │ │ ├── EddaInstanceJanitorCrawler.java
│ │ │ │ ├── EddaLaunchConfigJanitorCrawler.java
│ │ │ │ └── EddaUtils.java
│ │ │ └── rule/
│ │ │ ├── ami/
│ │ │ │ └── UnusedImageRule.java
│ │ │ ├── asg/
│ │ │ │ ├── ASGInstanceValidator.java
│ │ │ │ ├── DiscoveryASGInstanceValidator.java
│ │ │ │ ├── DummyASGInstanceValidator.java
│ │ │ │ ├── OldEmptyASGRule.java
│ │ │ │ └── SuspendedASGRule.java
│ │ │ ├── elb/
│ │ │ │ └── OrphanedELBRule.java
│ │ │ ├── generic/
│ │ │ │ ├── TagValueExclusionRule.java
│ │ │ │ └── UntaggedRule.java
│ │ │ ├── instance/
│ │ │ │ └── OrphanedInstanceRule.java
│ │ │ ├── launchconfig/
│ │ │ │ └── OldUnusedLaunchConfigRule.java
│ │ │ ├── snapshot/
│ │ │ │ └── NoGeneratedAMIRule.java
│ │ │ └── volume/
│ │ │ ├── DeleteOnTerminationRule.java
│ │ │ └── OldDetachedVolumeRule.java
│ │ ├── basic/
│ │ │ ├── BasicCalendar.java
│ │ │ ├── BasicChaosMonkeyContext.java
│ │ │ ├── BasicConfiguration.java
│ │ │ ├── BasicMonkeyServer.java
│ │ │ ├── BasicRecorderEvent.java
│ │ │ ├── BasicScheduler.java
│ │ │ ├── BasicSimianArmyContext.java
│ │ │ ├── LocalDbRecorder.java
│ │ │ ├── calendars/
│ │ │ │ └── BavarianCalendar.java
│ │ │ ├── chaos/
│ │ │ │ ├── BasicChaosEmailNotifier.java
│ │ │ │ ├── BasicChaosInstanceSelector.java
│ │ │ │ ├── BasicChaosMonkey.java
│ │ │ │ ├── BasicInstanceGroup.java
│ │ │ │ └── CloudFormationChaosMonkey.java
│ │ │ ├── conformity/
│ │ │ │ ├── BasicConformityEmailBuilder.java
│ │ │ │ ├── BasicConformityMonkey.java
│ │ │ │ └── BasicConformityMonkeyContext.java
│ │ │ └── janitor/
│ │ │ ├── BasicJanitorEmailBuilder.java
│ │ │ ├── BasicJanitorMonkey.java
│ │ │ ├── BasicJanitorMonkeyContext.java
│ │ │ ├── BasicJanitorRuleEngine.java
│ │ │ └── BasicVolumeTaggingMonkeyContext.java
│ │ ├── chaos/
│ │ │ ├── BlockAllNetworkTrafficChaosType.java
│ │ │ ├── BurnCpuChaosType.java
│ │ │ ├── BurnIoChaosType.java
│ │ │ ├── ChaosCrawler.java
│ │ │ ├── ChaosEmailNotifier.java
│ │ │ ├── ChaosInstance.java
│ │ │ ├── ChaosInstanceSelector.java
│ │ │ ├── ChaosMonkey.java
│ │ │ ├── ChaosType.java
│ │ │ ├── DetachVolumesChaosType.java
│ │ │ ├── FailDnsChaosType.java
│ │ │ ├── FailDynamoDbChaosType.java
│ │ │ ├── FailEc2ChaosType.java
│ │ │ ├── FailS3ChaosType.java
│ │ │ ├── FillDiskChaosType.java
│ │ │ ├── KillProcessesChaosType.java
│ │ │ ├── NetworkCorruptionChaosType.java
│ │ │ ├── NetworkLatencyChaosType.java
│ │ │ ├── NetworkLossChaosType.java
│ │ │ ├── NullRouteChaosType.java
│ │ │ ├── ScriptChaosType.java
│ │ │ ├── ShutdownInstanceChaosType.java
│ │ │ └── SshConfig.java
│ │ ├── client/
│ │ │ ├── MonkeyRestClient.java
│ │ │ ├── aws/
│ │ │ │ ├── AWSClient.java
│ │ │ │ └── chaos/
│ │ │ │ ├── ASGChaosCrawler.java
│ │ │ │ ├── FilteringChaosCrawler.java
│ │ │ │ └── TagPredicate.java
│ │ │ ├── edda/
│ │ │ │ └── EddaClient.java
│ │ │ └── vsphere/
│ │ │ ├── PropertyBasedTerminationStrategy.java
│ │ │ ├── TerminationStrategy.java
│ │ │ ├── VSphereClient.java
│ │ │ ├── VSphereContext.java
│ │ │ ├── VSphereGroups.java
│ │ │ └── VSphereServiceConnection.java
│ │ ├── conformity/
│ │ │ ├── AutoScalingGroup.java
│ │ │ ├── Cluster.java
│ │ │ ├── ClusterCrawler.java
│ │ │ ├── Conformity.java
│ │ │ ├── ConformityClusterTracker.java
│ │ │ ├── ConformityEmailBuilder.java
│ │ │ ├── ConformityEmailNotifier.java
│ │ │ ├── ConformityMonkey.java
│ │ │ ├── ConformityRule.java
│ │ │ └── ConformityRuleEngine.java
│ │ ├── janitor/
│ │ │ ├── AbstractJanitor.java
│ │ │ ├── DryRunnableJanitor.java
│ │ │ ├── DryRunnableJanitorException.java
│ │ │ ├── Janitor.java
│ │ │ ├── JanitorCrawler.java
│ │ │ ├── JanitorEmailBuilder.java
│ │ │ ├── JanitorEmailNotifier.java
│ │ │ ├── JanitorMonkey.java
│ │ │ ├── JanitorResourceTracker.java
│ │ │ ├── JanitorRuleEngine.java
│ │ │ └── Rule.java
│ │ ├── resources/
│ │ │ ├── chaos/
│ │ │ │ └── ChaosMonkeyResource.java
│ │ │ └── janitor/
│ │ │ └── JanitorMonkeyResource.java
│ │ └── tunable/
│ │ ├── TunableInstanceGroup.java
│ │ └── TunablyAggressiveChaosMonkey.java
│ ├── resources/
│ │ ├── chaos.properties
│ │ ├── client.properties
│ │ ├── conformity.properties
│ │ ├── janitor.properties
│ │ ├── log4j.properties
│ │ ├── scripts/
│ │ │ ├── burncpu.sh
│ │ │ ├── burnio.sh
│ │ │ ├── faildns.sh
│ │ │ ├── faildynamodb.sh
│ │ │ ├── failec2.sh
│ │ │ ├── fails3.sh
│ │ │ ├── filldisk.sh
│ │ │ ├── killprocesses.sh
│ │ │ ├── networkcorruption.sh
│ │ │ ├── networklatency.sh
│ │ │ ├── networkloss.sh
│ │ │ └── nullroute.sh
│ │ ├── simianarmy.properties
│ │ └── volumeTagging.properties
│ └── webapp/
│ └── WEB-INF/
│ └── web.xml
└── test/
├── java/
│ └── com/
│ └── netflix/
│ └── simianarmy/
│ ├── TestMonkey.java
│ ├── TestMonkeyContext.java
│ ├── TestMonkeyRunner.java
│ ├── TestUtils.java
│ ├── aws/
│ │ ├── TestAWSEmailNotifier.java
│ │ ├── TestRDSRecorder.java
│ │ ├── TestSimpleDBRecorder.java
│ │ ├── conformity/
│ │ │ ├── TestASGOwnerEmailTag.java
│ │ │ ├── TestRDSConformityClusterTracker.java
│ │ │ └── rule/
│ │ │ └── TestInstanceInVPC.java
│ │ └── janitor/
│ │ ├── TestAWSResource.java
│ │ ├── TestRDSJanitorResourceTracker.java
│ │ ├── TestSimpleDBJanitorResourceTracker.java
│ │ ├── crawler/
│ │ │ ├── TestASGJanitorCrawler.java
│ │ │ ├── TestEBSSnapshotJanitorCrawler.java
│ │ │ ├── TestEBSVolumeJanitorCrawler.java
│ │ │ ├── TestELBJanitorCrawler.java
│ │ │ ├── TestInstanceJanitorCrawler.java
│ │ │ └── TestLaunchConfigJanitorCrawler.java
│ │ └── rule/
│ │ ├── TestMonkeyCalendar.java
│ │ ├── asg/
│ │ │ ├── TestOldEmptyASGRule.java
│ │ │ └── TestSuspendedASGRule.java
│ │ ├── elb/
│ │ │ └── TestOrphanedELBRule.java
│ │ ├── generic/
│ │ │ ├── TestTagValueExclusionRule.java
│ │ │ └── TestUntaggedRule.java
│ │ ├── instance/
│ │ │ └── TestOrphanedInstanceRule.java
│ │ ├── launchconfig/
│ │ │ └── TestOldUnusedLaunchConfigRule.java
│ │ ├── snapshot/
│ │ │ └── TestNoGeneratedAMIRule.java
│ │ └── volume/
│ │ └── TestOldDetachedVolumeRule.java
│ ├── basic/
│ │ ├── TestBasicCalendar.java
│ │ ├── TestBasicConfiguration.java
│ │ ├── TestBasicContext.java
│ │ ├── TestBasicMonkeyServer.java
│ │ ├── TestBasicRecorderEvent.java
│ │ ├── TestBasicScheduler.java
│ │ ├── calendar/
│ │ │ └── TestBavarianCalendar.java
│ │ ├── chaos/
│ │ │ ├── TestBasicChaosEmailNotifier.java
│ │ │ ├── TestBasicChaosInstanceSelector.java
│ │ │ ├── TestBasicChaosMonkey.java
│ │ │ └── TestCloudFormationChaosMonkey.java
│ │ └── janitor/
│ │ └── TestBasicJanitorRuleEngine.java
│ ├── chaos/
│ │ ├── TestChaosMonkeyArmy.java
│ │ └── TestChaosMonkeyContext.java
│ ├── client/
│ │ ├── aws/
│ │ │ ├── TestAWSClient.java
│ │ │ └── chaos/
│ │ │ ├── TestASGChaosCrawler.java
│ │ │ └── TestFilterASGChaosCrawler.java
│ │ └── vsphere/
│ │ ├── TestPropertyBasedTerminationStrategy.java
│ │ ├── TestVSpehereClient.java
│ │ ├── TestVSphereContext.java
│ │ ├── TestVSphereGroups.java
│ │ └── TestVSphereServiceConnection.java
│ ├── conformity/
│ │ ├── TestCrossZoneLoadBalancing.java
│ │ └── TestSameZonesInElbAndAsg.java
│ ├── janitor/
│ │ ├── TestAbstractJanitor.java
│ │ └── TestBasicJanitorMonkeyContext.java
│ ├── resources/
│ │ └── chaos/
│ │ └── TestChaosMonkeyResource.java
│ └── tunable/
│ └── TestTunablyAggressiveChaosMonkey.java
└── resources/
├── chaos.properties
├── client.properties
├── com/
│ └── netflix/
│ └── simianarmy/
│ ├── chaos/
│ │ ├── all.properties
│ │ ├── cloudformation.properties
│ │ ├── disabled.properties
│ │ ├── enabledA.properties
│ │ ├── enabledAwith0.properties
│ │ ├── enabledAwithout1.properties
│ │ ├── enabledB.properties
│ │ ├── fullProbability.properties
│ │ ├── globalNotificationEnabled.properties
│ │ ├── mandatoryTerminationDisabled.properties
│ │ ├── mandatoryTerminationInsideWindow.properties
│ │ ├── mandatoryTerminationNoOptInTime.properties
│ │ ├── mandatoryTerminationNotDefined.properties
│ │ ├── mandatoryTerminationOutsideWindow.properties
│ │ ├── noProbability.properties
│ │ ├── noProbabilityByName.properties
│ │ ├── notificationEnabled.properties
│ │ ├── ondemandTermination.properties
│ │ ├── ondemandTerminationDisabled.properties
│ │ ├── propertiesWithDefaults.properties
│ │ ├── terminationPerDayAsBiggerThanOne.properties
│ │ ├── terminationPerDayAsNegative.properties
│ │ ├── terminationPerDayAsOne.properties
│ │ ├── terminationPerDayAsSmallerThanOne.properties
│ │ ├── terminationPerDayAsVerySmall.properties
│ │ ├── terminationPerDayAsZero.properties
│ │ ├── terminationPerDayGroupLevel.properties
│ │ ├── unleashedEnabledA.properties
│ │ └── unleashedEnabledB.properties
│ └── resources/
│ └── chaos/
│ └── getChaosEventsResponse.json
├── log4j.properties
├── proxy.properties
└── simianarmy.properties
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
# Editor Files #
################
*~
*.swp
# Gradle Files #
################
.gradle
# Build output directies
/target
*/target
/build
*/build
/bin
*/bin
/test-output
*/test-output
# IntelliJ specific files/directories
out
.idea
*.ipr
*.iws
*.iml
atlassian-ide-plugin.xml
# Eclipse specific files/directories
.classpath
.project
.settings
.metadata
# NetBeans specific files/directories
.nbattrs
/bin
/test-output
================================================
FILE: .netflixoss
================================================
cloudbees_disabled=true
================================================
FILE: .travis.yml
================================================
language: java
jdk:
- oraclejdk8
sudo: required
dist: trusty
install: ./installViaTravis.sh
script: ./buildViaTravis.sh
cache:
directories:
- $HOME/.gradle/caches
env:
global:
- secure: WCRqvIKdPdIsoDhsJWZNBZhEH7Jdgz2fmkjzozVjs4dq36ySrH71udNtZcPIsTwjmHpRaGX0XCgmwLC5WorS2TBJJ87oghCP3WWQGMBLcCdXHS8quRdAHLHpNfao/BQrBEA/gmCYoJZdmXKFDc+XKXS5NBrHkkvVfLGCumcP0AI=
- secure: TKnGiZyCtWWI/ei2lNDvGIjyAI4W8xMNOlXT6tGiWJgexvFQpTl2NgkMqgwbxReyxj37vdUnn9Lb/883G6zL/uB+l5aCjeCG//6GAbJYdrSZQCE/UCo7iMlAxyqfuIlKcJABIhwpP8Fg4RwqxJG19Tbx5ddg8RP8yKAi1QNx06Y=
- secure: nUn8s+1fV60Hxb9V9DouFIOGHeBpeTD7l6Yadw4gthvi/tZndZ+L/Crh1Z9pAU69NqEHG/VcFLUMNER7dQ4rugVbcbfQueeCdnVpmStLS97tAl8kArhpWCk8dQi47IANuQw7U0nVlg3pA8w9HLZX6ee9PnhyG1oOnluPC/x2Or4=
- secure: KTtxnPJWfkwNwYkd2IxKAc4dUc6jF0Fd6uhrqK5q36z0RnY4b/gKlx8bjGPcZA5hutNmiN/gxyvpbL/bvVg9buQ2vkybaPZpzpLwhHTXiD5accjQUMuwF8DFYpzIb104hkgzHbrW18JRImK539ib5TTanF3I08F04LssSXG8NnY=
================================================
FILE: CHANGELOG.md
================================================
================================================
FILE: GNUmakefile
================================================
reformat:
eclipse -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter -verbose -config $(shell pwd)/codequality/org.eclipse.jdt.core.prefs $(shell pwd)/src
find $(shell pwd)/src -name \*.java | xargs perl -pi -e 's/{ /{/g; s/(\S) }/$$1}/g; s/\* $$/\*/; s/([.]<[^>]+>)\s+/$$1/g'
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2012 Netflix, Inc.
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.
================================================
FILE: OSSMETADATA
================================================
osslifecycle=archived
================================================
FILE: README.md
================================================
[](OSSMETADATA)
[](https://travis-ci.org/Netflix/SimianArmy)
[](https://opensource.org/licenses/Apache-2.0)
## PROJECT STATUS: RETIRED
**The Simian Army project is no longer actively maintained**. Some of the Simian
Army functionality has been moved to other Netflix projects:
* A [newer version of Chaos Monkey](https://github.com/netflix/chaosmonkey) is available as a standalone service.
* [Swabbie] is a new standalone service that will replace the functionality provided by Janitor Monkey.
* Conformity Monkey functionality will be rolled into other [Spinnaker] backend services.
[Swabbie]: https://github.com/spinnaker/swabbie
[Spinnaker]: https://www.spinnaker.io/
### DESCRIPTION
The Simian Army is a suite of tools for keeping your cloud operating in top
form. Chaos Monkey, the first member, is a resiliency tool that helps ensure
that your applications can tolerate random instance failures
### DETAILS
Please see the [wiki](https://github.com/Netflix/SimianArmy/wiki).
### SUPPORT
[Simian Army Google group](http://groups.google.com/group/simianarmy-users)
Because the project is no longer maintained, there is a good chance that nobody will be able to answer a support question.
### LICENSE
Copyright 2012-2016 Netflix, Inc.
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.
================================================
FILE: build.gradle
================================================
buildscript {
repositories {
jcenter()
}
}
plugins {
id 'nebula.netflixoss' version '3.2.3'
id 'net.saliman.cobertura' version '2.2.7'
id 'com.github.hierynomus.license' version '0.11.0'
}
// Establish version and status
ext.githubProjectName = 'SimianArmy'
group = "com.netflix.${project.name}"
apply plugin:'eclipse-wtp'
repositories {
mavenLocal()
mavenCentral()
}
apply plugin: 'war'
apply plugin: 'jetty'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
// for the VMWareClient
compile 'com.cloudbees.thirdparty:vijava:5.0.0'
// for DB support outside of AWS (SimpleDB not available)
compile 'org.mapdb:mapdb:0.9.5'
compile 'com.sun.jersey:jersey-servlet:1.19'
compile 'org.slf4j:slf4j-api:1.7.2'
compile 'org.codehaus.jackson:jackson-core-asl:1.9.2'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.2'
compile 'com.netflix.eureka:eureka-client:1.4.1'
compile 'com.amazonaws:aws-java-sdk:1.11.28'
compile 'commons-lang:commons-lang:2.6'
compile 'com.google.guava:guava:11.0.2'
compile 'org.apache.httpcomponents:httpclient:4.3'
compile 'com.google.auto.service:auto-service:1.0-rc2'
compile 'org.apache.jclouds.driver:jclouds-jsch:1.9.0'
compile 'org.apache.jclouds.driver:jclouds-slf4j:1.9.0'
compile 'org.apache.jclouds.api:ec2:1.9.0'
compile 'org.apache.jclouds.provider:aws-ec2:1.9.0'
compile 'com.netflix.servo:servo-core:0.12.11'
compile 'org.springframework:spring-jdbc:4.2.5.RELEASE'
compile 'com.zaxxer:HikariCP:2.4.7'
testCompile 'org.testng:testng:6.3.1'
testCompile 'org.mockito:mockito-core:1.8.5'
runtime 'org.slf4j:slf4j-log4j12:1.6.1'
providedCompile 'javax.servlet:servlet-api:2.5'
}
test {
useTestNG()
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint"
}
license {
exclude '**/*.properties'
exclude '**/*.json'
exclude '**/*.sh'
}
task coreJar(type: Jar) {
from sourceSets.main.output
include '**'
}
publishing {
publications {
mavenWar(MavenPublication) {
from components.web
artifact coreJar { classifier "core" }
}
}
}
artifactoryPublish {
publications('mavenWar')
}
================================================
FILE: buildViaTravis.sh
================================================
#!/bin/bash
# This script will build the project.
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo -e "Build Pull Request #$TRAVIS_PULL_REQUEST => Branch [$TRAVIS_BRANCH]"
./gradlew clean build
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" == "" ]; then
echo -e 'Build Branch with Snapshot => Branch ['$TRAVIS_BRANCH']'
./gradlew -Prelease.travisci=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" build snapshot
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" != "" ]; then
echo -e 'Build Branch for Release => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG']'
case "$TRAVIS_TAG" in
*-rc\.*)
./gradlew -Prelease.travisci=true -Prelease.useLastTag=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" candidate
;;
*)
./gradlew -Prelease.travisci=true -Prelease.useLastTag=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" final
;;
esac
else
echo -e 'WARN: Should not be here => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG'] Pull Request ['$TRAVIS_PULL_REQUEST']'
./gradlew build
fi
================================================
FILE: codequality/checkstyle.xml
================================================
================================================
FILE: codequality/org.eclipse.jdt.core.prefs
================================================
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
org.eclipse.jdt.core.formatter.comment.line_length=120
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=4
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.join_lines_in_comments=true
org.eclipse.jdt.core.formatter.join_wrapped_lines=true
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.jdt.core.formatter.lineSplit=120
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=4
org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Mon Feb 22 15:12:15 PST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-bin.zip
================================================
FILE: gradle.properties
================================================
================================================
FILE: gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: installViaTravis.sh
================================================
#!/bin/bash
# This script will build the project.
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo -e "Assemble Pull Request #$TRAVIS_PULL_REQUEST => Branch [$TRAVIS_BRANCH]"
./gradlew clean assemble --stacktrace
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" == "" ]; then
echo -e 'Assemble Branch with Snapshot => Branch ['$TRAVIS_BRANCH']'
./gradlew -Prelease.travisci=true assemble
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" != "" ]; then
echo -e 'Assemble Branch for Release => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG']'
./gradlew -Prelease.travisci=true -Prelease.useLastTag=true assemble
else
echo -e 'WARN: Should not be here => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG'] Pull Request ['$TRAVIS_PULL_REQUEST']'
./gradlew assemble
fi
================================================
FILE: settings.gradle
================================================
rootProject.name='simianarmy'
================================================
FILE: src/main/java/com/netflix/simianarmy/AbstractEmailBuilder.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
/** The abstract email builder. */
public abstract class AbstractEmailBuilder implements EmailBuilder {
@Override
public String buildEmailBody(String emailAddress) {
StringBuilder body = new StringBuilder();
String header = getHeader();
if (header != null) {
body.append(header);
}
String entryTable = getEntryTable(emailAddress);
if (entryTable != null) {
body.append(entryTable);
}
String footer = getFooter();
if (footer != null) {
body.append(footer);
}
return body.toString();
}
/**
* Gets the header to the email body.
*/
protected abstract String getHeader();
/**
* Gets the table of entries in the email body.
* @param emailAddress the email address to notify
* @return the HTML string representing the table for the resources to send to the
* email address
*/
protected abstract String getEntryTable(String emailAddress);
/**
* Gets the footer of the email body.
*/
protected abstract String getFooter();
/**
* Gets the HTML cell in the table of a string value.
* @param value the string to put in the table
* @return the HTML text
*/
protected String getHtmlCell(String value) {
return "
" + value + "
";
}
/**
* Gets the HTML string displaying the table header with the specified column names.
* @param columns the column names for the table
*/
protected String getHtmlTableHeader(String[] columns) {
StringBuilder tableHeader = new StringBuilder();
tableHeader.append(
"
");
tableHeader.append("
");
for (String col : columns) {
tableHeader.append(getHtmlCell(col));
}
tableHeader.append("
");
return tableHeader.toString();
}
}
================================================
FILE: src/main/java/com/netflix/simianarmy/CloudClient.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
import org.jclouds.compute.ComputeService;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.ssh.SshClient;
import java.util.List;
import java.util.Map;
/**
* The CloudClient interface. This abstractions provides the interface that the monkeys need to interact with
* "the cloud".
*/
public interface CloudClient {
/**
* Terminates instance.
*
* @param instanceId
* the instance id
*
* @throws NotFoundException
* if the instance no longer exists or was already terminated after the crawler discovered it then you
* should get a NotFoundException
*/
void terminateInstance(String instanceId);
/**
* Deletes an auto scaling group.
*
* @param asgName
* the auto scaling group name
*/
void deleteAutoScalingGroup(String asgName);
/**
* Deletes a launch configuration.
*
* @param launchConfigName
* the launch configuration name
*/
void deleteLaunchConfiguration(String launchConfigName);
/**
* Deletes a volume.
*
* @param volumeId
* the volume id
*/
void deleteVolume(String volumeId);
/**
* Deletes a snapshot.
*
* @param snapshotId
* the snapshot id.
*/
void deleteSnapshot(String snapshotId);
/** Deletes an image.
*
* @param imageId
* the image id.
*/
void deleteImage(String imageId);
/**
* Deletes an elastic load balancer.
*
* @param elbId
* the elastic load balancer id
*/
void deleteElasticLoadBalancer(String elbId);
/**
* Deletes a DNS record.
*
* @param dnsName
* the DNS record to delete
* @param dnsType
* the DNS type (CNAME, A, or AAAA)
* @param hostedZoneID
* the ID of the hosted zone (required for AWS Route53 records)
*/
public void deleteDNSRecord(String dnsName, String dnsType, String hostedZoneID);
/**
* Adds or overwrites tags for the specified resources.
*
* @param keyValueMap
* the new tags in the form of map from key to value
*
* @param resourceIds
* the list of resource ids
*/
void createTagsForResources(Map keyValueMap, String... resourceIds);
/**
* Lists all EBS volumes attached to the specified instance.
*
* @param instanceId
* the instance id
* @param includeRoot
* if the root volume is on EBS, should we include it?
*
* @throws NotFoundException
* if the instance no longer exists or was already terminated after the crawler discovered it then you
* should get a NotFoundException
*/
List listAttachedVolumes(String instanceId, boolean includeRoot);
/**
* Detaches an EBS volumes from the specified instance.
*
* @param instanceId
* the instance id
* @param volumeId
* the volume id
* @param force
* if we should force-detach the volume. Probably best not to use on high-value volumes.
*
* @throws NotFoundException
* if the instance no longer exists or was already terminated after the crawler discovered it then you
* should get a NotFoundException
*/
void detachVolume(String instanceId, String volumeId, boolean force);
/**
* Returns the jClouds compute service.
*/
ComputeService getJcloudsComputeService();
/**
* Returns the jClouds node id for an instance id on this CloudClient.
*/
String getJcloudsId(String instanceId);
/**
* Opens an SSH connection to an instance.
*
* @param instanceId
* instance id to connect to
* @param credentials
* SSH credentials to use
* @return {@link SshClient}, in connected state
*/
SshClient connectSsh(String instanceId, LoginCredentials credentials);
/**
* Finds a security group with the given name, that can be applied to the given instance.
*
* For example, if it is a VPC instance, it makes sure that it is in the same VPC group.
*
* @param instanceId
* the instance that the group must be applied to
* @param groupName
* the name of the group to find
*
* @return The group id, or null if not found
*/
String findSecurityGroup(String instanceId, String groupName);
/**
* Creates an (empty) security group, that can be applied to the given instance.
*
* @param instanceId
* instance that group should be applicable to
* @param groupName
* name for new group
* @param description
* description for new group
*
* @return the id of the security group
*/
String createSecurityGroup(String instanceId, String groupName, String description);
/**
* Checks if we can change the security groups of an instance.
*
* @param instanceId
* instance to check
*
* @return true iff we can change security groups.
*/
boolean canChangeInstanceSecurityGroups(String instanceId);
/**
* Sets the security groups for an instance.
*
* Note this is only valid for VPC instances.
*
* @param instanceId
* the instance id
* @param groupIds
* ids of desired new groups
*
* @throws NotFoundException
* if the instance no longer exists or was already terminated after the crawler discovered it then you
* should get a NotFoundException
*/
void setInstanceSecurityGroups(String instanceId, List groupIds);
}
================================================
FILE: src/main/java/com/netflix/simianarmy/EmailBuilder.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
/** Interface for build the email body. */
public interface EmailBuilder {
/**
* Builds an email body for an email address.
* @param emailAddress the email address to send notification to
* @return the email body
*/
String buildEmailBody(String emailAddress);
}
================================================
FILE: src/main/java/com/netflix/simianarmy/EventType.java
================================================
/*
*
* Copyright 2013 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
/**
* Marker interface for all event type enumerations.
*/
public interface EventType extends NamedType {
}
================================================
FILE: src/main/java/com/netflix/simianarmy/FeatureNotEnabledException.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
/**
* The Class FeatureNotEnabledException.
*
* These exceptions will be thrown when a feature is not enabled when being accessed.
*/
public class FeatureNotEnabledException extends Exception {
private static final long serialVersionUID = 8392434473284901306L;
/**
* Instantiates a FeatureNotEnabledException with a message.
* @param msg the error message
*/
public FeatureNotEnabledException(String msg) {
super(msg);
}
}
================================================
FILE: src/main/java/com/netflix/simianarmy/GroupType.java
================================================
/*
*
* Copyright 2013 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
/**
* Marker interface for all group type enumerations.
*/
public interface GroupType extends NamedType {
}
================================================
FILE: src/main/java/com/netflix/simianarmy/InstanceGroupNotFoundException.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
/**
* The Class InstanceGroupNotFoundException.
*
* These exceptions will be thrown when an instance group cannot be found with the
* given name and type.
*/
public class InstanceGroupNotFoundException extends Exception {
private static final long serialVersionUID = -5492120875166280476L;
private final String groupType;
private final String groupName;
/**
* Instantiates an InstanceGroupNotFoundException with the group type and name.
* @param groupType the group type
* @param groupName the gruop name
*/
public InstanceGroupNotFoundException(String groupType, String groupName) {
super(errorMessage(groupType, groupName));
this.groupType = groupType;
this.groupName = groupName;
}
@Override
public String toString() {
return errorMessage(groupType, groupName);
}
private static String errorMessage(String groupType, String groupName) {
return String.format("Instance group named '%s' [type %s] cannot be found.",
groupName, groupType);
}
}
================================================
FILE: src/main/java/com/netflix/simianarmy/Monkey.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.netflix.simianarmy.MonkeyRecorder.Event;
/**
* The abstract Monkey class, it provides a minimal interface from which all monkeys must be derived.
*/
public abstract class Monkey {
/** The Constant LOGGER. */
private static final Logger LOGGER = LoggerFactory.getLogger(Monkey.class);
/**
* The Interface Context.
*/
public interface Context {
/**
* Scheduler.
*
* @return the monkey scheduler
*/
MonkeyScheduler scheduler();
/**
* Calendar.
*
* @return the monkey calendar
*/
MonkeyCalendar calendar();
/**
* Cloud client.
*
* @return the cloud client
*/
CloudClient cloudClient();
/**
* Recorder.
*
* @return the monkey recorder
*/
MonkeyRecorder recorder();
/**
* Add a event to the summary report. The ChaosMonkey uses this to print a summary after the chaos run is
* complete.
*
* @param evt
* The Event to be reported
*/
void reportEvent(Event evt);
/**
* Used to clear the event summary on the start of a chaos run.
*/
void resetEventReport();
/**
* Returns a summary of what the chaos run did.
*/
String getEventReport();
/**
* Configuration.
*
* @return the monkey configuration
*/
MonkeyConfiguration configuration();
}
/** The context. */
private final Context ctx;
/**
* Instantiates a new monkey.
*
* @param ctx
* the context
*/
public Monkey(Context ctx) {
this.ctx = ctx;
}
/**
* Type.
*
* @return the monkey type enum
*/
public abstract MonkeyType type();
/**
* Do monkey business.
*/
public abstract void doMonkeyBusiness();
/**
* Context.
*
* @return the context
*/
public Context context() {
return ctx;
}
/**
* Run. This is run on the schedule set by the MonkeyScheduler
*/
public void run() {
if (ctx.calendar().isMonkeyTime(this)) {
LOGGER.info(this.type().name() + " Monkey Running ...");
try {
this.doMonkeyBusiness();
} finally {
String eventReport = context().getEventReport();
if (eventReport != null) {
LOGGER.info("Reporting what I did...\n" + eventReport);
}
}
} else {
LOGGER.info("Not Time for " + this.type().name() + " Monkey");
}
}
/**
* Start. Sets up the schedule for the monkey to run on.
*/
public void start() {
final Monkey me = this;
ctx.scheduler().start(this, new Runnable() {
@Override
public void run() {
try {
me.run();
} catch (Exception e) {
LOGGER.error(me.type().name() + " Monkey Error: ", e);
}
}
});
}
/**
* Stop. Removes the monkey from the schedule.
*/
public void stop() {
ctx.scheduler().stop(this);
}
}
================================================
FILE: src/main/java/com/netflix/simianarmy/MonkeyCalendar.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
import java.util.Calendar;
import java.util.Date;
/**
* The Interface MonkeyCalendar used to tell if a monkey should be running or now. We only want monkeys to run during
* business hours, so that engineers will be on-hand if something goes wrong.
*/
public interface MonkeyCalendar {
/**
* Checks if is monkey time.
*
* @param monkey
* the monkey
* @return true, if is monkey time
*/
boolean isMonkeyTime(Monkey monkey);
/**
* Open hour. This is the "open" hour for then the monkey should start working.
*
* @return the int
*/
int openHour();
/**
* Close hour. This is the "close" hour for when the monkey should stop working.
*
* @return the int
*/
int closeHour();
/**
* Get the current time using whatever timezone is used for monkey date calculations.
*
* @return the calendar
*/
Calendar now();
/** Gets the next business day from the start date after n business days.
*
* @param date the start date
* @param n the number of business days from now
* @return the business day after n business days
*/
Date getBusinessDay(Date date, int n);
}
================================================
FILE: src/main/java/com/netflix/simianarmy/MonkeyConfiguration.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
/**
* The Interface MonkeyConfiguration.
*/
public interface MonkeyConfiguration {
/**
* Gets the boolean associated with property string. If not found it will return false.
*
* @param property
* the property name
* @return the boolean value
*/
boolean getBool(String property);
/**
* Gets the boolean associated with property string. If not found it will return dflt.
*
* @param property
* the property name
* @param dflt
* the default value
* @return the bool property value, or dflt if none set
*/
boolean getBoolOrElse(String property, boolean dflt);
/**
* Gets the number (double) associated with property string. If not found it will return dflt.
*
* @param property
* the property name
* @param dflt
* the default value
* @return the numeric property value, or dflt if none set
*/
double getNumOrElse(String property, double dflt);
/**
* Gets the string associated with property string. If not found it will return null.
*
* @param property
* the property name
* @return the string property value
*/
String getStr(String property);
/**
* Gets the string associated with property string. If not found it will return dflt.
*
* @param property
* the property name
* @param dflt
* the default value
* @return the string property value, or dflt if none set
*/
String getStrOrElse(String property, String dflt);
/**
* If the configuration has dynamic elements then they should be reloaded with this.
*/
void reload();
/**
* Reloads the properties of specific group.
* @param groupName
* the instance group's name
*/
void reload(String groupName);
}
================================================
FILE: src/main/java/com/netflix/simianarmy/MonkeyEmailNotifier.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
/** The interface for the email notifier used by monkeys. */
public interface MonkeyEmailNotifier {
/**
* Determines if a email address is valid.
* @param email the email
* @return true if the email address is valid, false otherwise.
*/
boolean isValidEmail(String email);
/**
* Builds an email subject for an email address.
* @param to the destination email address
* @return the email subject
*/
String buildEmailSubject(String to);
/**
* Gets the cc email addresses for a to address.
* @param to the to address
* @return the cc email addresses
*/
String[] getCcAddresses(String to);
/**
* Gets the source email addresses for a to address.
* @param to the to address
* @return the source email addresses
*/
String getSourceAddress(String to);
/**
* Sends an email.
* @param to the address sent to
* @param subject the email subject
* @param body the email body
*/
void sendEmail(String to, String subject, String body);
}
================================================
FILE: src/main/java/com/netflix/simianarmy/MonkeyRecorder.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* The Interface MonkeyRecorder. This is use to store and find events in some datastore.
*/
public interface MonkeyRecorder {
/**
* The Interface Event.
*/
public interface Event {
/**
* Event Id.
*
* @return the string
*/
String id();
/**
* Event time.
*
* @return the date
*/
Date eventTime();
/**
* Monkey type.
*
* @return the monkey type enum
*/
MonkeyType monkeyType();
/**
* Event type.
*
* @return the event type enum
*/
EventType eventType();
/**
* Region.
*
* @return the region for the event
*/
String region();
/**
* Fields.
*
*
* @return the map of strings that may have been provided when the event was created
*/
Map fields();
/**
* Field.
*
* @param name
* the name
* @return the string associated with that field
*/
String field(String name);
/**
* Adds the field.
*
* @param name
* the name
* @param value
* the value
* @return this so you can chain multiple addField calls together
*/
Event addField(String name, String value);
}
/**
* New event.
*
* @param monkeyType
* the monkey type
* @param eventType
* the event type
* @param region
* the region the event occurred
* @param id
* the id
* @return the event
*/
Event newEvent(MonkeyType monkeyType, EventType eventType, String region, String id);
default Event newEvent(MonkeyType monkeyType, EventType eventType, Resource resource, String id) {
if (resource == null) throw new IllegalArgumentException("resource must not be null");
Event event = newEvent(monkeyType, eventType, resource.getRegion(), id);
if (resource.getAllTagKeys() != null) {
for(String key : resource.getAllTagKeys()) {
event.addField(key, resource.getTag(key));
}
}
event.addField("ResourceDescription", resource.getDescription());
event.addField("ResourceType", resource.getResourceType().toString());
event.addField("ResourceId", resource.getId());
return event;
}
/**
* Record event.
*
* @param evt
* the evt
*/
void recordEvent(Event evt);
/**
* Find events.
*
* @param query
* arbitrary map of strings to used to filter the results
* @param after
* the after
* @return the list of events
*/
List findEvents(Map query, Date after);
/**
* Find events.
*
* @param monkeyType
* the monkey type
* @param query
* arbitrary map of strings to used to filter the results
* @param after
* the after
* @return the list of events
*/
List findEvents(MonkeyType monkeyType, Map query, Date after);
/**
* Find events.
*
* @param monkeyType
* the monkey type
* @param eventType
* the event type
* @param query
* arbitrary map of strings to used to filter the results
* @param after
* the after
* @return the list
*/
List findEvents(MonkeyType monkeyType, EventType eventType, Map query, Date after);
}
================================================
FILE: src/main/java/com/netflix/simianarmy/MonkeyRunner.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
import java.lang.reflect.Constructor;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The MonkeyRunner Singleton.
*/
public enum MonkeyRunner {
/** The instance. */
INSTANCE;
/** The Constant LOGGER. */
private static final Logger LOGGER = LoggerFactory.getLogger(MonkeyRunner.class);
/**
* Gets the single instance of MonkeyRunner.
*
* @return single instance of MonkeyRunner
*/
public static MonkeyRunner getInstance() {
return INSTANCE;
}
/**
* Start all the monkeys registered with addMonkey or replaceMonkey.
*/
public void start() {
for (Monkey monkey : monkeys) {
LOGGER.info("Starting " + monkey.type().name() + " Monkey");
monkey.start();
}
}
/**
* Stop all of the registered monkeys.
*/
public void stop() {
for (Monkey monkey : monkeys) {
LOGGER.info("Stopping " + monkey.type().name() + " Monkey");
monkey.stop();
}
}
/**
* The monkey map. Maps the monkey class to the context class that is registered. This is so we can create new
* monkeys in factory() that have the same context types as the registered ones.
*/
private final Map, Class extends Monkey.Context>> monkeyMap =
new HashMap, Class extends Monkey.Context>>();
/** The monkeys. */
private final List monkeys = new LinkedList();
/**
* Gets the registered monkeys.
*
* @return the monkeys
*/
public List getMonkeys() {
return Collections.unmodifiableList(monkeys);
}
/**
* Adds a simple monkey void constructor.
*
* @param monkeyClass
* the monkey class
*/
public void addMonkey(Class extends Monkey> monkeyClass) {
addMonkey(monkeyClass, null);
}
/**
* Replace a simple monkey that has void constructor.
*
* @param monkeyClass
* the monkey class
*/
public void replaceMonkey(Class extends Monkey> monkeyClass) {
replaceMonkey(monkeyClass, null);
}
/**
* Adds the monkey.
*
* @param monkeyClass
* the monkey class
* @param ctxClass
* the context class that is passed to the monkey class constructor.
*/
public void addMonkey(Class extends Monkey> monkeyClass, Class extends Monkey.Context> ctxClass) {
if (monkeyMap.containsKey(monkeyClass)) {
throw new RuntimeException(monkeyClass.getName()
+ " already registered, use replaceMonkey instead of addMonkey");
}
monkeyMap.put(monkeyClass, ctxClass);
monkeys.add(factory(monkeyClass, ctxClass));
}
/**
* Replace monkey. If a monkey is already registered this will replace that registered monkey.
*
* @param monkeyClass
* the monkey class
* @param ctxClass
* the context class that is passed to the monkey class constructor.
*/
public void replaceMonkey(Class extends Monkey> monkeyClass, Class extends Monkey.Context> ctxClass) {
monkeyMap.put(monkeyClass, ctxClass);
ListIterator li = monkeys.listIterator();
while (li.hasNext()) {
Monkey monkey = li.next();
if (monkey.getClass() == monkeyClass) {
li.set(factory(monkeyClass, ctxClass));
return;
}
}
Monkey monkey = factory(monkeyClass, ctxClass);
monkeys.add(monkey);
}
/**
* Removes the monkey. factory() will no longer be able to construct monkeys of the specified monkey class.
*
* @param monkeyClass
* the monkey class
*/
public void removeMonkey(Class extends Monkey> monkeyClass) {
ListIterator li = monkeys.listIterator();
while (li.hasNext()) {
Monkey monkey = li.next();
if (monkey.getClass() == monkeyClass) {
monkey.stop();
li.remove();
break;
}
}
monkeyMap.remove(monkeyClass);
}
/**
* Monkey factory. This will generate a new monkey object of the monkeyClass type. If a monkey of monkeyClass has
* not been registered then this will attempt to find a registered subclass and create an object of that type.
* Example:
*
*
* {@code
* MonkeyRunner.getInstance().addMonkey(BasicChaosMonkey.class, BasicMonkeyContext.class);
* // This will actually return a BasicChaosMonkey since that is the only subclass that was registered
* ChaosMonkey monkey = MonkeyRunner.getInstance().factory(ChaosMonkey.class);
*}
*
*
* @param
* the generic type, must be a subclass of Monkey
* @param monkeyClass
* the monkey class
* @return the monkey
*/
public T factory(Class monkeyClass) {
Class extends Monkey.Context> ctxClass = getContextClass(monkeyClass);
if (ctxClass == null) {
// look for derived class already in our map
for (Map.Entry, Class extends Monkey.Context>> pair : monkeyMap.entrySet()) {
if (monkeyClass.isAssignableFrom(pair.getKey())) {
@SuppressWarnings("unchecked")
T monkey = (T) factory(pair.getKey(), pair.getValue());
return monkey;
}
}
}
return factory(monkeyClass, ctxClass);
}
/**
* Monkey Factory. Given a monkey class and a monkey context class it will generate a new monkey. If the
* contextClass is null it will try to generate a new monkeyClass with a void constructor;
*
* @param
* the generic type, must be a subclass of Monkey
* @param monkeyClass
* the monkey class
* @param contextClass
* the context class
* @return the monkey
*/
public T factory(Class monkeyClass, Class extends Monkey.Context> contextClass) {
try {
if (contextClass == null) {
// assume Monkey class has has void ctor
return monkeyClass.newInstance();
}
// then find corresponding ctor
for (Constructor> ctor : monkeyClass.getDeclaredConstructors()) {
Class>[] paramTypes = ctor.getParameterTypes();
if (paramTypes.length != 1) {
continue;
}
if (paramTypes[0].getName().endsWith("$Context")) {
@SuppressWarnings("unchecked")
T monkey = (T) ctor.newInstance(contextClass.newInstance());
return monkey;
}
}
} catch (Exception e) {
LOGGER.error("monkeyFactory error, cannot make monkey from " + monkeyClass.getName() + " with "
+ (contextClass == null ? null : contextClass.getName()), e);
}
return null;
}
/**
* Gets the context class. You should not need this.
*
* @param monkeyClass
* the monkey class
* @return the context class or null if a monkeyClass has not been registered
*/
public Class extends Monkey.Context> getContextClass(Class extends Monkey> monkeyClass) {
return monkeyMap.get(monkeyClass);
}
}
================================================
FILE: src/main/java/com/netflix/simianarmy/MonkeyScheduler.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
import java.util.concurrent.TimeUnit;
/**
* The Interface MonkeyScheduler.
*/
public interface MonkeyScheduler {
/**
* Frequency. How often the monkey should run, works in conjunction with frequencyUnit(). If frequency is 2 and
* frequencyUnit is TimeUnit.HOUR then the monkey will run once ever 2 hours.
*
* @return the frequency interval
*/
int frequency();
/**
* Frequency unit. This is the time unit that corresponds with frequency().
*
* @return time unit
*/
TimeUnit frequencyUnit();
/**
* Start the scheduler to cause the monkey run at a specified interval.
*
* @param monkey
* the monkey being scheduled
* @param run
* the Runnable to start, generally calls doMonkeyBusiness
*/
void start(Monkey monkey, Runnable run);
/**
* Stop the scheduler for a given monkey. After this the monkey will no longer run on the fixed schedule.
*
* @param monkey
* the monkey being scheduled
*/
void stop(Monkey monkey);
}
================================================
FILE: src/main/java/com/netflix/simianarmy/MonkeyType.java
================================================
/*
*
* Copyright 2013 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
/**
* Marker interface for all monkey type enumerations.
*/
public interface MonkeyType extends NamedType {
}
================================================
FILE: src/main/java/com/netflix/simianarmy/NamedType.java
================================================
/*
*
* Copyright 2013 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
/**
* Interface requiring a name() method.
*/
public interface NamedType {
/**
* Name of this instance.
*/
String name();
}
================================================
FILE: src/main/java/com/netflix/simianarmy/NotFoundException.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
/**
* The Class NotFoundException.
*
* These exceptions will be thrown when a Monkey is trying to interact with a remote resource but it no longer exists
* (or never existed). It is used as an adapter to translate a cloud provider exception into something common that the
* monkeys can easily handle.
*/
@SuppressWarnings("serial")
public class NotFoundException extends RuntimeException {
/**
* Instantiates a new NotFound exception.
*
* @param message
* the exception message
*/
public NotFoundException(String message) {
super(message);
}
/**
* Instantiates a new NotFound exception.
*
* @param message
* the exception message
* @param cause
* the exception cause. This should be the raw exception from the cloud provider.
*/
public NotFoundException(String message, Throwable cause) {
super(message, cause);
}
/**
* Instantiates a new NotFound exception.
*
* @param cause
* the exception cause. This should be the raw exception from the cloud provider.
*/
public NotFoundException(Throwable cause) {
super(cause);
}
}
================================================
FILE: src/main/java/com/netflix/simianarmy/Resource.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
/**
* The interface of Resource. It defines the interfaces for getting the common properties of a resource, as well as
* the methods to add and retrieve the additional properties of a resource. Instead of defining a new subclass of
* the Resource interface, new resources that have additional fields other than the common ones can be represented,
* by adding field-value pairs. This approach makes serialization and deserialization of resources much easier with
* the cost of type safety.
*/
public interface Resource {
/** The enum representing the cleanup state of a resource. **/
public enum CleanupState {
/** The resource is marked as a cleanup candidate but has not been cleaned up yet. **/
MARKED,
/** The resource is terminated by janitor monkey. **/
JANITOR_TERMINATED,
/** The resource is terminated by user before janitor monkey performs the termination. **/
USER_TERMINATED,
/** The resource is unmarked and not for cleanup anymore due to some change of situations. **/
UNMARKED
}
/**
* Gets the resource id.
*
* @return the resource id
*/
String getId();
/**
* Sets the resource id.
*
* @param id the resource id
*/
void setId(String id);
/**
* Sets the resource id and returns the resource.
*
* @param id the resource id
* @return the resource object
*/
Resource withId(String id);
/**
* Gets the resource type.
*
* @return the resource type enum
*/
ResourceType getResourceType();
/**
* Sets the resource type.
*
* @param type the resource type enum
*/
void setResourceType(ResourceType type);
/**
* Sets the resource type and returns the resource.
*
* @param type resource type enum
* @return the resource object
*/
Resource withResourceType(ResourceType type);
/**
* Gets the region the resource is in.
*
* @return the region of the resource
*/
String getRegion();
/**
* Sets the region the resource is in.
*
* @param region the region the resource is in
*/
void setRegion(String region);
/**
* Sets the resource region and returns the resource.
*
* @param region the region the resource is in
* @return the resource object
*/
Resource withRegion(String region);
/**
* Gets the owner email of the resource.
*
* @return the owner email of the resource
*/
String getOwnerEmail();
/**
* Sets the owner email of the resource.
*
* @param ownerEmail the owner email of the resource
*/
void setOwnerEmail(String ownerEmail);
/**
* Sets the resource owner email and returns the resource.
*
* @param ownerEmail the owner email of the resource
* @return the resource object
*/
Resource withOwnerEmail(String ownerEmail);
/**
* Gets the description of the resource.
*
* @return the description of the resource
*/
String getDescription();
/**
* Sets the description of the resource.
*
* @param description the description of the resource
*/
void setDescription(String description);
/**
* Sets the resource description and returns the resource.
*
* @param description the description of the resource
* @return the resource object
*/
Resource withDescription(String description);
/**
* Gets the launch time of the resource.
*
* @return the launch time of the resource
*/
Date getLaunchTime();
/**
* Sets the launch time of the resource.
*
* @param launchTime the launch time of the resource
*/
void setLaunchTime(Date launchTime);
/**
* Sets the resource launch time and returns the resource.
*
* @param launchTime the launch time of the resource
* @return the resource object
*/
Resource withLaunchTime(Date launchTime);
/**
* Gets the time that when the resource is marked as a cleanup candidate.
*
* @return the time that when the resource is marked as a cleanup candidate
*/
Date getMarkTime();
/**
* Sets the time that when the resource is marked as a cleanup candidate.
*
* @param markTime the time that when the resource is marked as a cleanup candidate
*/
void setMarkTime(Date markTime);
/**
* Sets the resource mark time and returns the resource.
*
* @param markTime the time that when the resource is marked as a cleanup candidate
* @return the resource object
*/
Resource withMarkTime(Date markTime);
/**
* Gets the the time that when the resource is expected to be terminated.
*
* @return the time that when the resource is expected to be terminated
*/
Date getExpectedTerminationTime();
/**
* Sets the time that when the resource is expected to be terminated.
*
* @param expectedTerminationTime the time that when the resource is expected to be terminated
*/
void setExpectedTerminationTime(Date expectedTerminationTime);
/**
* Sets the time that when the resource is expected to be terminated and returns the resource.
*
* @param expectedTerminationTime the time that when the resource is expected to be terminated
* @return the resource object
*/
Resource withExpectedTerminationTime(Date expectedTerminationTime);
/**
* Gets the time that when the resource is actually terminated.
*
* @return the time that when the resource is actually terminated
*/
Date getActualTerminationTime();
/**
* Sets the time that when the resource is actually terminated.
*
* @param actualTerminationTime the time that when the resource is actually terminated
*/
void setActualTerminationTime(Date actualTerminationTime);
/**
* Sets the resource actual termination time and returns the resource.
*
* @param actualTerminationTime the time that when the resource is actually terminated
* @return the resource object
*/
Resource withActualTerminationTime(Date actualTerminationTime);
/**
* Gets the time that when the owner is notified about the cleanup of the resource.
*
* @return the time that when the owner is notified about the cleanup of the resource
*/
Date getNotificationTime();
/**
* Sets the time that when the owner is notified about the cleanup of the resource.
*
* @param notificationTime the time that when the owner is notified about the cleanup of the resource
*/
void setNotificationTime(Date notificationTime);
/**
* Sets the time that when the owner is notified about the cleanup of the resource and returns the resource.
*
* @param notificationTime the time that when the owner is notified about the cleanup of the resource
* @return the resource object
*/
Resource withNnotificationTime(Date notificationTime);
/**
* Gets the resource state.
*
* @return the resource state enum
*/
CleanupState getState();
/**
* Sets the resource state.
*
* @param state the resource state
*/
void setState(CleanupState state);
/**
* Sets the resource state and returns the resource.
*
* @param state resource state enum
* @return the resource object
*/
Resource withState(CleanupState state);
/**
* Gets the termination reason of the resource.
*
* @return the termination reason of the resource
*/
String getTerminationReason();
/**
* Sets the termination reason of the resource.
*
* @param terminationReason the termination reason of the resource
*/
void setTerminationReason(String terminationReason);
/**
* Sets the resource termination reason and returns the resource.
*
* @param terminationReason the termination reason of the resource
* @return the resource object
*/
Resource withTerminationReason(String terminationReason);
/**
* Gets the boolean to indicate whether or not the resource is opted out of Janitor monkey
* so it will not be cleaned.
* @return true if the resource is opted out of Janitor monkey, otherwise false
*/
boolean isOptOutOfJanitor();
/**
* Sets the flag to indicate whether or not the resource is opted out of Janitor monkey
* so it will not be cleaned.
* @param optOutOfJanitor true if the resource is opted out of Janitor monkey, otherwise false
*/
void setOptOutOfJanitor(boolean optOutOfJanitor);
/**
* Sets the flag to indicate whether or not the resource is opted out of Janitor monkey
* so it will not be cleaned and returns the resource object.
* @param optOutOfJanitor true if the resource is opted out of Janitor monkey, otherwise false
* @return the resource object
*/
Resource withOptOutOfJanitor(boolean optOutOfJanitor);
/**
* Gets a map from fields of resources to corresponding values. Values are represented
* as Strings so they can be displayed or stored in databases like SimpleDB.
* @return a map from field name to field value
*/
Map getFieldToValueMap();
/** Adds or sets an additional field with the specified name and value to the resource.
*
* @param fieldName the field name
* @param fieldValue the field value
* @return the resource itself for chaining
*/
Resource setAdditionalField(String fieldName, String fieldValue);
/** Gets the value of an additional field with the specified name of the resource.
*
* @param fieldName the field name
* @return the field value
*/
String getAdditionalField(String fieldName);
/**
* Gets all additional field names in the resource.
* @return a collection of names of all additional fields
*/
Collection getAdditionalFieldNames();
/**
* Adds a tag with the specified key and value to the resource.
* @param key the key of the tag
* @param value the value of the tag
*/
void setTag(String key, String value);
/**
* Gets the tag value for a specific key of the resource.
* @param key the key of the tag
* @return the value of the tag
*/
String getTag(String key);
/**
* Gets all the keys of tags.
* @return collection of keys of all tags
*/
Collection getAllTagKeys();
/** Clone a resource with the exact field values of the current object.
*
* @return the clone of the resource
*/
Resource cloneResource();
}
================================================
FILE: src/main/java/com/netflix/simianarmy/ResourceType.java
================================================
/*
*
* Copyright 2013 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy;
/**
* Marker interface for all resource type enumerations.
*/
public interface ResourceType extends NamedType {
}
================================================
FILE: src/main/java/com/netflix/simianarmy/aws/AWSEmailNotifier.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy.aws;
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient;
import com.amazonaws.services.simpleemail.model.Body;
import com.amazonaws.services.simpleemail.model.Content;
import com.amazonaws.services.simpleemail.model.Destination;
import com.amazonaws.services.simpleemail.model.Message;
import com.amazonaws.services.simpleemail.model.SendEmailRequest;
import com.amazonaws.services.simpleemail.model.SendEmailResult;
import com.netflix.simianarmy.MonkeyEmailNotifier;
/**
* The class implements the monkey email notifier using AWS simple email service
* for sending email.
*/
public abstract class AWSEmailNotifier implements MonkeyEmailNotifier {
/** The Constant LOGGER. */
private static final Logger LOGGER = LoggerFactory.getLogger(AWSEmailNotifier.class);
private static final String EMAIL_PATTERN =
"^[_A-Za-z0-9-\\+\\.#]+(.[_A-Za-z0-9-#]+)*@"
+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
private final Pattern emailPattern;
private final AmazonSimpleEmailServiceClient sesClient;
/**
* The constructor.
*/
public AWSEmailNotifier(AmazonSimpleEmailServiceClient sesClient) {
super();
this.sesClient = sesClient;
this.emailPattern = Pattern.compile(EMAIL_PATTERN);
}
@Override
public void sendEmail(String to, String subject, String body) {
if (!isValidEmail(to)) {
LOGGER.error(String.format("The destination email address %s is not valid, no email is sent.", to));
return;
}
if (sesClient == null) {
String msg = "The email client is not set.";
LOGGER.error(msg);
throw new RuntimeException(msg);
}
Destination destination = new Destination().withToAddresses(to)
.withCcAddresses(getCcAddresses(to));
Content subjectContent = new Content(subject);
Content bodyContent = new Content();
Body msgBody = new Body(bodyContent);
msgBody.setHtml(new Content(body));
Message msg = new Message(subjectContent, msgBody);
String sourceAddress = getSourceAddress(to);
SendEmailRequest request = new SendEmailRequest(sourceAddress, destination, msg);
request.setReturnPath(sourceAddress);
LOGGER.debug(String.format("Sending email with subject '%s' to %s",
subject, to));
SendEmailResult result = null;
try {
result = sesClient.sendEmail(request);
} catch (Exception e) {
throw new RuntimeException(String.format("Failed to send email to %s", to), e);
}
LOGGER.info(String.format("Email to %s, result id is %s, subject is %s",
to, result.getMessageId(), subject));
}
@Override
public boolean isValidEmail(String email) {
if (email == null) {
return false;
}
if (!emailPattern.matcher(email).matches()) {
LOGGER.error(String.format("Invalid email address: %s", email));
return false;
}
if (email.equals("foo@bar.com")) {
LOGGER.error(String.format("Email address not changed from default; treating as invalid: %s", email));
return false;
}
return true;
}
}
================================================
FILE: src/main/java/com/netflix/simianarmy/aws/AWSResource.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy.aws;
import java.util.*;
import org.apache.commons.lang.Validate;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import com.netflix.simianarmy.NamedType;
import com.netflix.simianarmy.Resource;
import com.netflix.simianarmy.ResourceType;
/**
* The class represents general AWS resources that are managed by janitor monkey.
*/
public class AWSResource implements Resource {
private String id;
private ResourceType resourceType;
private String region;
private String ownerEmail;
private String description;
private String terminationReason;
private CleanupState state;
private Date expectedTerminationTime;
private Date actualTerminationTime;
private Date notificationTime;
private Date launchTime;
private Date markTime;
private boolean optOutOfJanitor;
private String awsResourceState;
/** The field name for resourceId. **/
public static final String FIELD_RESOURCE_ID = "resourceId";
/** The field name for resourceType. **/
public static final String FIELD_RESOURCE_TYPE = "resourceType";
/** The field name for region. **/
public static final String FIELD_REGION = "region";
/** The field name for owner email. **/
public static final String FIELD_OWNER_EMAIL = "ownerEmail";
/** The field name for description. **/
public static final String FIELD_DESCRIPTION = "description";
/** The field name for state. **/
public static final String FIELD_STATE = "state";
/** The field name for terminationReason. **/
public static final String FIELD_TERMINATION_REASON = "terminationReason";
/** The field name for expectedTerminationTime. **/
public static final String FIELD_EXPECTED_TERMINATION_TIME = "expectedTerminationTime";
/** The field name for actualTerminationTime. **/
public static final String FIELD_ACTUAL_TERMINATION_TIME = "actualTerminationTime";
/** The field name for notificationTime. **/
public static final String FIELD_NOTIFICATION_TIME = "notificationTime";
/** The field name for launchTime. **/
public static final String FIELD_LAUNCH_TIME = "launchTime";
/** The field name for markTime. **/
public static final String FIELD_MARK_TIME = "markTime";
/** The field name for isOptOutOfJanitor. **/
public static final String FIELD_OPT_OUT_OF_JANITOR = "optOutOfJanitor";
/** The field name for awsResourceState. **/
public static final String FIELD_AWS_RESOURCE_STATE = "awsResourceState";
/** The date format used to print or parse a Date value. **/
public static final DateTimeFormatter DATE_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss");
/** The map from name to value for additional fields used by the resource. **/
private final Map additionalFields = new HashMap();
/** The map from AWS tag key to value for the resource. **/
private final Map tags = new HashMap();
/** {@inheritDoc} */
@Override
public Map getFieldToValueMap() {
Map fieldToValue = new HashMap();
putToMapIfNotNull(fieldToValue, FIELD_RESOURCE_ID, getId());
putToMapIfNotNull(fieldToValue, FIELD_RESOURCE_TYPE, getResourceType());
putToMapIfNotNull(fieldToValue, FIELD_REGION, getRegion());
putToMapIfNotNull(fieldToValue, FIELD_OWNER_EMAIL, getOwnerEmail());
putToMapIfNotNull(fieldToValue, FIELD_DESCRIPTION, getDescription());
putToMapIfNotNull(fieldToValue, FIELD_STATE, getState());
putToMapIfNotNull(fieldToValue, FIELD_TERMINATION_REASON, getTerminationReason());
putToMapIfNotNull(fieldToValue, FIELD_EXPECTED_TERMINATION_TIME, printDate(getExpectedTerminationTime()));
putToMapIfNotNull(fieldToValue, FIELD_ACTUAL_TERMINATION_TIME, printDate(getActualTerminationTime()));
putToMapIfNotNull(fieldToValue, FIELD_NOTIFICATION_TIME, printDate(getNotificationTime()));
putToMapIfNotNull(fieldToValue, FIELD_LAUNCH_TIME, printDate(getLaunchTime()));
putToMapIfNotNull(fieldToValue, FIELD_MARK_TIME, printDate(getMarkTime()));
putToMapIfNotNull(fieldToValue, FIELD_AWS_RESOURCE_STATE, getAWSResourceState());
// Additional fields are serialized while tags are not. So if any tags need to be
// serialized as well, put them to additional fields.
fieldToValue.put(FIELD_OPT_OUT_OF_JANITOR, String.valueOf(isOptOutOfJanitor()));
fieldToValue.putAll(additionalFields);
return fieldToValue;
}
/**
* Parse a map from field name to value to a resource.
* @param fieldToValue the map from field name to value
* @return the resource that is de-serialized from the map
*/
public static AWSResource parseFieldtoValueMap(Map fieldToValue) {
AWSResource resource = new AWSResource();
for (Map.Entry field : fieldToValue.entrySet()) {
String name = field.getKey();
String value = field.getValue();
if (name.equals(FIELD_RESOURCE_ID)) {
resource.setId(value);
} else if (name.equals(FIELD_RESOURCE_TYPE)) {
resource.setResourceType(AWSResourceType.valueOf(value));
} else if (name.equals(FIELD_REGION)) {
resource.setRegion(value);
} else if (name.equals(FIELD_OWNER_EMAIL)) {
resource.setOwnerEmail(value);
} else if (name.equals(FIELD_DESCRIPTION)) {
resource.setDescription(value);
} else if (name.equals(FIELD_STATE)) {
resource.setState(CleanupState.valueOf(value));
} else if (name.equals(FIELD_TERMINATION_REASON)) {
resource.setTerminationReason(value);
} else if (name.equals(FIELD_EXPECTED_TERMINATION_TIME)) {
resource.setExpectedTerminationTime(new Date(DATE_FORMATTER.parseDateTime(value).getMillis()));
} else if (name.equals(FIELD_ACTUAL_TERMINATION_TIME)) {
resource.setActualTerminationTime(new Date(DATE_FORMATTER.parseDateTime(value).getMillis()));
} else if (name.equals(FIELD_NOTIFICATION_TIME)) {
resource.setNotificationTime(new Date(DATE_FORMATTER.parseDateTime(value).getMillis()));
} else if (name.equals(FIELD_LAUNCH_TIME)) {
resource.setLaunchTime(new Date(DATE_FORMATTER.parseDateTime(value).getMillis()));
} else if (name.equals(FIELD_MARK_TIME)) {
resource.setMarkTime(new Date(DATE_FORMATTER.parseDateTime(value).getMillis()));
} else if (name.equals(FIELD_AWS_RESOURCE_STATE)) {
resource.setAWSResourceState(value);
} else if (name.equals(FIELD_OPT_OUT_OF_JANITOR)) {
resource.setOptOutOfJanitor("true".equals(value));
} else {
// put all other fields into additional fields
resource.setAdditionalField(name, value);
}
}
return resource;
}
public String getAWSResourceState() {
return awsResourceState;
}
public void setAWSResourceState(String awsState) {
this.awsResourceState = awsState;
}
/** {@inheritDoc} */
@Override
public String getId() {
return id;
}
/** {@inheritDoc} */
@Override
public void setId(String id) {
this.id = id;
}
/** {@inheritDoc} */
@Override
public Resource withId(String resourceId) {
setId(resourceId);
return this;
}
/** {@inheritDoc} */
@Override
public ResourceType getResourceType() {
return resourceType;
}
/** {@inheritDoc} */
@Override
public void setResourceType(ResourceType resourceType) {
this.resourceType = resourceType;
}
/** {@inheritDoc} */
@Override
public Resource withResourceType(ResourceType type) {
setResourceType(type);
return this;
}
/** {@inheritDoc} */
@Override
public String getRegion() {
return region;
}
/** {@inheritDoc} */
@Override
public void setRegion(String region) {
this.region = region;
}
/** {@inheritDoc} */
@Override
public Resource withRegion(String resourceRegion) {
setRegion(resourceRegion);
return this;
}
/** {@inheritDoc} */
@Override
public String getOwnerEmail() {
return ownerEmail;
}
/** {@inheritDoc} */
@Override
public void setOwnerEmail(String ownerEmail) {
this.ownerEmail = ownerEmail;
}
/** {@inheritDoc} */
@Override
public Resource withOwnerEmail(String resourceOwner) {
setOwnerEmail(resourceOwner);
return this;
}
/** {@inheritDoc} */
@Override
public String getDescription() {
return description;
}
/** {@inheritDoc} */
@Override
public void setDescription(String description) {
this.description = description;
}
/** {@inheritDoc} */
@Override
public Resource withDescription(String resourceDescription) {
setDescription(resourceDescription);
return this;
}
/** {@inheritDoc} */
@Override
public Date getLaunchTime() {
return getCopyOfDate(launchTime);
}
/** {@inheritDoc} */
@Override
public void setLaunchTime(Date launchTime) {
this.launchTime = getCopyOfDate(launchTime);
}
/** {@inheritDoc} */
@Override
public Resource withLaunchTime(Date resourceLaunchTime) {
setLaunchTime(resourceLaunchTime);
return this;
}
/** {@inheritDoc} */
@Override
public Date getMarkTime() {
return getCopyOfDate(markTime);
}
/** {@inheritDoc} */
@Override
public void setMarkTime(Date markTime) {
this.markTime = getCopyOfDate(markTime);
}
/** {@inheritDoc} */
@Override
public Resource withMarkTime(Date resourceMarkTime) {
setMarkTime(resourceMarkTime);
return this;
}
/** {@inheritDoc} */
@Override
public Date getExpectedTerminationTime() {
return getCopyOfDate(expectedTerminationTime);
}
/** {@inheritDoc} */
@Override
public void setExpectedTerminationTime(Date expectedTerminationTime) {
this.expectedTerminationTime = getCopyOfDate(expectedTerminationTime);
}
/** {@inheritDoc} */
@Override
public Resource withExpectedTerminationTime(Date resourceExpectedTerminationTime) {
setExpectedTerminationTime(resourceExpectedTerminationTime);
return this;
}
/** {@inheritDoc} */
@Override
public Date getActualTerminationTime() {
return getCopyOfDate(actualTerminationTime);
}
/** {@inheritDoc} */
@Override
public void setActualTerminationTime(Date actualTerminationTime) {
this.actualTerminationTime = getCopyOfDate(actualTerminationTime);
}
/** {@inheritDoc} */
@Override
public Resource withActualTerminationTime(Date resourceActualTerminationTime) {
setActualTerminationTime(resourceActualTerminationTime);
return this;
}
/** {@inheritDoc} */
@Override
public Date getNotificationTime() {
return getCopyOfDate(notificationTime);
}
/** {@inheritDoc} */
@Override
public void setNotificationTime(Date notificationTime) {
this.notificationTime = getCopyOfDate(notificationTime);
}
/** {@inheritDoc} */
@Override
public Resource withNnotificationTime(Date resourceNotificationTime) {
setNotificationTime(resourceNotificationTime);
return this;
}
/** {@inheritDoc} */
@Override
public CleanupState getState() {
return state;
}
/** {@inheritDoc} */
@Override
public void setState(CleanupState state) {
this.state = state;
}
/** {@inheritDoc} */
@Override
public Resource withState(CleanupState resourceState) {
setState(resourceState);
return this;
}
/** {@inheritDoc} */
@Override
public String getTerminationReason() {
return terminationReason;
}
/** {@inheritDoc} */
@Override
public void setTerminationReason(String terminationReason) {
this.terminationReason = terminationReason;
}
/** {@inheritDoc} */
@Override
public Resource withTerminationReason(String resourceTerminationReason) {
setTerminationReason(resourceTerminationReason);
return this;
}
/** {@inheritDoc} */
@Override
public boolean isOptOutOfJanitor() {
return optOutOfJanitor;
}
/** {@inheritDoc} */
@Override
public void setOptOutOfJanitor(boolean optOutOfJanitor) {
this.optOutOfJanitor = optOutOfJanitor;
}
/** {@inheritDoc} */
@Override
public Resource withOptOutOfJanitor(boolean optOut) {
setOptOutOfJanitor(optOut);
return this;
}
private static Date getCopyOfDate(Date date) {
if (date == null) {
return null;
}
return new Date(date.getTime());
}
private static void putToMapIfNotNull(Map map, String key, String value) {
Validate.notNull(map);
Validate.notNull(key);
if (value != null) {
map.put(key, value);
}
}
private static void putToMapIfNotNull(Map map, String key, Enum> value) {
Validate.notNull(map);
Validate.notNull(key);
if (value != null) {
map.put(key, value.name());
}
}
private static void putToMapIfNotNull(Map map, String key, NamedType value) {
Validate.notNull(map);
Validate.notNull(key);
if (value != null) {
map.put(key, value.name());
}
}
private static String printDate(Date date) {
if (date == null) {
return null;
}
return DATE_FORMATTER.print(date.getTime());
}
@Override
public Resource setAdditionalField(String fieldName, String fieldValue) {
Validate.notNull(fieldName);
Validate.notNull(fieldValue);
putToMapIfNotNull(additionalFields, fieldName, fieldValue);
return this;
}
@Override
public String getAdditionalField(String fieldName) {
return additionalFields.get(fieldName);
}
@Override
public Collection getAdditionalFieldNames() {
return additionalFields.keySet();
}
@Override
public Resource cloneResource() {
Resource clone = new AWSResource()
.withActualTerminationTime(getActualTerminationTime())
.withDescription(getDescription())
.withExpectedTerminationTime(getExpectedTerminationTime())
.withId(getId())
.withLaunchTime(getLaunchTime())
.withMarkTime(getMarkTime())
.withNnotificationTime(getNotificationTime())
.withOwnerEmail(getOwnerEmail())
.withRegion(getRegion())
.withResourceType(getResourceType())
.withState(getState())
.withTerminationReason(getTerminationReason())
.withOptOutOfJanitor(isOptOutOfJanitor());
((AWSResource) clone).setAWSResourceState(awsResourceState);
((AWSResource) clone).additionalFields.putAll(additionalFields);
for (String key : this.getAllTagKeys()) {
clone.setTag(key, this.getTag(key));
}
return clone;
}
/** {@inheritDoc} */
@Override
public void setTag(String key, String value) {
tags.put(key, value);
}
/** {@inheritDoc} */
@Override
public String getTag(String key) {
return tags.get(key);
}
/** {@inheritDoc} */
@Override
public Collection getAllTagKeys() {
return tags.keySet();
}
@Override
public String toString() {
return "AWSResource{" +
"id='" + id + '\'' +
", resourceType=" + resourceType +
", region='" + region + '\'' +
", ownerEmail='" + ownerEmail + '\'' +
", description='" + description + '\'' +
", terminationReason='" + terminationReason + '\'' +
", state=" + state +
", expectedTerminationTime=" + expectedTerminationTime +
", actualTerminationTime=" + actualTerminationTime +
", notificationTime=" + notificationTime +
", launchTime=" + launchTime +
", markTime=" + markTime +
", optOutOfJanitor=" + optOutOfJanitor +
", awsResourceState='" + awsResourceState + '\'' +
", additionalFields=" + additionalFields +
", tags=" + tags +
'}';
}
@Override
public boolean equals(Object o) {
// consider two resources to be equivalent if id, resourceType and region match
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AWSResource that = (AWSResource) o;
return Objects.equals(id, that.id) &&
Objects.equals(resourceType, that.resourceType) &&
Objects.equals(region, that.region);
}
@Override
public int hashCode() {
// consider two resources to be equivalent if id, resourceType and region match
return Objects.hash(id, resourceType, region);
}
}
================================================
FILE: src/main/java/com/netflix/simianarmy/aws/AWSResourceType.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy.aws;
import com.netflix.simianarmy.ResourceType;
/**
* The enum of resource types of AWS.
*/
public enum AWSResourceType implements ResourceType {
/** AWS instance. */
INSTANCE,
/** AWS EBS volume. */
EBS_VOLUME,
/** AWS EBS snapshot. */
EBS_SNAPSHOT,
/** AWS auto scaling group. */
ASG,
/** AWS launch configuration. */
LAUNCH_CONFIG,
/** AWS S3 bucket. */
S3_BUCKET,
/** AWS security group. */
SECURITY_GROUP,
/** AWS Amazon Machine Image. **/
IMAGE,
/** AWS Elastic Load Balancer. **/
ELB
}
================================================
FILE: src/main/java/com/netflix/simianarmy/aws/RDSRecorder.java
================================================
/*
*
* Copyright 2012 Netflix, Inc.
*
* 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.
*
*/
package com.netflix.simianarmy.aws;
import com.amazonaws.AmazonClientException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.simianarmy.EventType;
import com.netflix.simianarmy.MonkeyRecorder;
import com.netflix.simianarmy.MonkeyType;
import com.netflix.simianarmy.basic.BasicRecorderEvent;
import com.zaxxer.hikari.HikariDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* The Class RDSRecorder. Records events to and fetched events from a RDS table (default SIMIAN_ARMY)
*/
@SuppressWarnings("serial")
public class RDSRecorder implements MonkeyRecorder {
/** The Constant LOGGER. */
private static final Logger LOGGER = LoggerFactory.getLogger(RDSRecorder.class);
private final String region;
/** The table. */
private final String table;
/** the jdbcTemplate */
JdbcTemplate jdbcTemplate = null;
public static final String FIELD_ID = "eventId";
public static final String FIELD_EVENT_TIME = "eventTime";
public static final String FIELD_MONKEY_TYPE = "monkeyType";
public static final String FIELD_EVENT_TYPE = "eventType";
public static final String FIELD_REGION = "region";
public static final String FIELD_DATA_JSON = "dataJson";
/**
* Instantiates a new RDS recorder.
*
*/
public RDSRecorder(String dbDriver, String dbUser,
String dbPass, String dbUrl, String dbTable, String region) {
HikariDataSource dataSource = new HikariDataSource();
dataSource.setDriverClassName(dbDriver);
dataSource.setJdbcUrl(dbUrl);
dataSource.setUsername(dbUser);
dataSource.setPassword(dbPass);
dataSource.setMaximumPoolSize(2);
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.table = dbTable;
this.region = region;
}
/**
* Instantiates a new RDS recorder. This constructor is intended
* for unit testing.
*
*/
public RDSRecorder(JdbcTemplate jdbcTemplate, String table, String region) {
this.jdbcTemplate = jdbcTemplate;
this.table = table;
this.region = region;
}
public JdbcTemplate getJdbcTemplate() {
return jdbcTemplate;
}
/** {@inheritDoc} */
@Override
public Event newEvent(MonkeyType monkeyType, EventType eventType, String reg, String id) {
return new BasicRecorderEvent(monkeyType, eventType, reg, id);
}
/** {@inheritDoc} */
@Override
public void recordEvent(Event evt) {
String evtTime = String.valueOf(evt.eventTime().getTime());
String name = String.format("%s-%s-%s-%s", evt.monkeyType().name(), evt.id(), region, evtTime);
String json;
try {
json = new ObjectMapper().writeValueAsString(evt.fields());
} catch (JsonProcessingException e) {
LOGGER.error("ERROR generating JSON when saving resource " + name, e);
return;
}
LOGGER.debug(String.format("Saving event %s to RDS table %s", name, table));
StringBuilder sb = new StringBuilder();
sb.append("insert into ").append(table);
sb.append(" (");
sb.append(FIELD_ID).append(",");
sb.append(FIELD_EVENT_TIME).append(",");
sb.append(FIELD_MONKEY_TYPE).append(",");
sb.append(FIELD_EVENT_TYPE).append(",");
sb.append(FIELD_REGION).append(",");
sb.append(FIELD_DATA_JSON).append(") values (?,?,?,?,?,?)");
LOGGER.debug(String.format("Insert statement is '%s'", sb));
int updated = this.jdbcTemplate.update(sb.toString(),
evt.id(),
evt.eventTime().getTime(),
SimpleDBRecorder.enumToValue(evt.monkeyType()),
SimpleDBRecorder.enumToValue(evt.eventType()),
evt.region(),
json);
LOGGER.debug(String.format("%d rows inserted", updated));
}
/** {@inheritDoc} */
@Override
public List findEvents(Map query, Date after) {
return findEvents(null, null, query, after);
}
/** {@inheritDoc} */
@Override
public List findEvents(MonkeyType monkeyType, Map query, Date after) {
return findEvents(monkeyType, null, query, after);
}
/** {@inheritDoc} */
@Override
public List findEvents(MonkeyType monkeyType, EventType eventType, Map query, Date after) {
ArrayList