Permalink
Browse files

Initial version

  • Loading branch information...
0 parents commit 7324ed426d437e77647f78b683b9305f1d55e799 @electrum committed Sep 29, 2011
@@ -0,0 +1,17 @@
+*.iml
+*.ipr
+*.iws
+target/
+/var
+pom.xml.versionsBackup
+test-output/
+/atlassian-ide-plugin.xml
+.idea
+.DS_Store
+.classpath
+.settings
+.project
+temp-testng-customsuite.xml
+test-output
+.externalToolBuilders
+*~
@@ -0,0 +1 @@
+Automatically update AWS Elastic Load Balancers (ELB) from Discovery
@@ -0,0 +1,2 @@
+node.environment=testing
+discovery.uri=http://localhost:8411
@@ -0,0 +1,2 @@
+com.proofpoint=DEBUG
+com.amazonaws.request=WARN
@@ -0,0 +1,13 @@
+Copyright 2011 Proofpoint, 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.
165 pom.xml
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.proofpoint.platform</groupId>
+ <artifactId>rest-server-base</artifactId>
+ <version>0.46</version>
+ </parent>
+
+ <properties>
+ <main-class>com.proofpoint.discovery.elb.Main</main-class>
+ </properties>
+
+ <groupId>com.proofpoint.discovery</groupId>
+ <artifactId>elb</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.amazonaws</groupId>
+ <artifactId>aws-java-sdk</artifactId>
+ <version>1.2.7</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ <version>1.3.9</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.weakref</groupId>
+ <artifactId>jmxutils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.proofpoint.platform</groupId>
+ <artifactId>bootstrap</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.proofpoint.platform</groupId>
+ <artifactId>configuration</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.proofpoint.platform</groupId>
+ <artifactId>discovery-experimental</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.proofpoint.platform</groupId>
+ <artifactId>log</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.proofpoint.platform</groupId>
+ <artifactId>http-server</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.proofpoint.platform</groupId>
+ <artifactId>jaxrs</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.proofpoint.platform</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.proofpoint.platform</groupId>
+ <artifactId>jmx</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.proofpoint.platform</groupId>
+ <artifactId>node</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.proofpoint.platform</groupId>
+ <artifactId>units</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.proofpoint.platform</groupId>
+ <artifactId>experimental</artifactId>
+ </dependency>
+
+ <!-- for packaging -->
+ <dependency>
+ <groupId>com.proofpoint.platform</groupId>
+ <artifactId>launcher</artifactId>
+ <classifier>bin</classifier>
+ <type>tar.gz</type>
+ </dependency>
+
+ <!-- for testing -->
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!--
+ Do a license check by running: mvn license:check
+ Update the license by running: mvn license:format
+ -->
+ <plugin>
+ <groupId>com.mycila.maven-license-plugin</groupId>
+ <artifactId>maven-license-plugin</artifactId>
+ <configuration>
+ <header>license-header.txt</header>
+ <strictCheck>true</strictCheck>
+ <mapping>
+ <java>SLASHSTAR_STYLE</java>
+ </mapping>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ <excludes>
+ <exclude>**/README.txt</exclude>
+ <exclude>**/config.properties</exclude>
+ <exclude>**/log.properties</exclude>
+ <exclude>**/logback-test.xml</exclude>
+ <exclude>**/.gitignore</exclude>
+ <exclude>var/**</exclude>
+ </excludes>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>test</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2011 Proofpoint, 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.proofpoint.discovery.elb;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Objects;
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableList;
+
+import javax.annotation.concurrent.Immutable;
+import java.util.List;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * EC2 Galaxy location: {@code ec2/region/zone/instance/slot}
+ */
+@Immutable
+@SuppressWarnings("UnusedDeclaration")
+public class Ec2Location
+{
+ private final String region;
+ private final String availabilityZone;
+ private final String instanceId;
+ private final String slot;
+
+ public Ec2Location(String region, String availabilityZone, String instanceId, String slot)
+ {
+ this.region = checkNotNull(region, "region is null");
+ this.availabilityZone = checkNotNull(availabilityZone, "availabilityZone is null");
+ this.instanceId = checkNotNull(instanceId, "instanceId is null");
+ this.slot = checkNotNull(slot, "slot is null");
+ }
+
+ public String getRegion()
+ {
+ return region;
+ }
+
+ public String getAvailabilityZone()
+ {
+ return availabilityZone;
+ }
+
+ public String getInstanceId()
+ {
+ return instanceId;
+ }
+
+ public String getSlot()
+ {
+ return slot;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof Ec2Location)) {
+ return false;
+ }
+ Ec2Location x = (Ec2Location) o;
+ return equal(region, x.region) &&
+ equal(availabilityZone, x.availabilityZone) &&
+ equal(instanceId, x.instanceId) &&
+ equal(slot, x.slot);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hashCode(region, availabilityZone, instanceId, slot);
+ }
+
+ @Override
+ public String toString()
+ {
+ return Joiner.on('/').join("ec2", region, availabilityZone, instanceId, slot);
+ }
+
+ /**
+ * Parse an EC2 location string into an {@link Ec2Location}.
+ *
+ * @param location the location string
+ * @return the parsed location
+ * @throws IllegalArgumentException if the location string is invalid
+ */
+ public static Ec2Location valueOf(String location)
+ throws IllegalArgumentException
+ {
+ List<String> parts = ImmutableList.copyOf(Splitter.on('/').split(location).iterator());
+ if (parts.size() != 5) {
+ throw new IllegalArgumentException("wrong number of parts");
+ }
+ if (!parts.get(0).equals("ec2")) {
+ throw new IllegalArgumentException("not an EC2 location");
+ }
+ return new Ec2Location(parts.get(1), parts.get(2), parts.get(3), parts.get(4));
+ }
+}
Oops, something went wrong.

0 comments on commit 7324ed4

Please sign in to comment.