Remove project etcd. Project is now being hosted at https://github.com/cdancy/etcd-rest.
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/1f215379 Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/1f215379 Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/1f215379 Branch: refs/heads/master Commit: 1f2153799190d06b64295f65607e2b0bb3600903 Parents: 247e9fd Author: Christopher Dancy <[email protected]> Authored: Fri May 6 11:21:27 2016 -0400 Committer: Ignasi Barrera <[email protected]> Committed: Mon May 9 11:24:00 2016 +0200 ---------------------------------------------------------------------- etcd/pom.xml | 123 -------------- .../src/main/java/org/jclouds/etcd/EtcdApi.java | 41 ----- .../java/org/jclouds/etcd/EtcdApiMetadata.java | 82 --------- .../jclouds/etcd/config/EtcdHttpApiModule.java | 43 ----- .../java/org/jclouds/etcd/domain/keys/Key.java | 42 ----- .../java/org/jclouds/etcd/domain/keys/Node.java | 60 ------- .../etcd/domain/members/CreateMember.java | 47 ------ .../org/jclouds/etcd/domain/members/Member.java | 49 ------ .../etcd/domain/miscellaneous/Version.java | 38 ----- .../jclouds/etcd/domain/statistics/Counts.java | 38 ----- .../etcd/domain/statistics/Follower.java | 38 ----- .../jclouds/etcd/domain/statistics/Latency.java | 45 ----- .../jclouds/etcd/domain/statistics/Leader.java | 41 ----- .../etcd/domain/statistics/LeaderInfo.java | 40 ----- .../jclouds/etcd/domain/statistics/Self.java | 55 ------ .../jclouds/etcd/domain/statistics/Store.java | 68 -------- .../jclouds/etcd/fallbacks/EtcdFallbacks.java | 48 ------ .../java/org/jclouds/etcd/features/KeysApi.java | 59 ------- .../org/jclouds/etcd/features/MembersApi.java | 74 -------- .../jclouds/etcd/features/MiscellaneousApi.java | 52 ------ .../jclouds/etcd/features/StatisticsApi.java | 58 ------- .../jclouds/etcd/handlers/EtcdErrorHandler.java | 83 --------- .../org/jclouds/etcd/BaseEtcdApiLiveTest.java | 51 ------ .../org/jclouds/etcd/EtcdApiMetadataTest.java | 50 ------ .../jclouds/etcd/features/KeysApiLiveTest.java | 100 ----------- .../jclouds/etcd/features/KeysApiMockTest.java | 144 ---------------- .../etcd/features/MembersApiLiveTest.java | 103 ------------ .../etcd/features/MembersApiMockTest.java | 168 ------------------- .../etcd/features/MiscellaneousApiLiveTest.java | 53 ------ .../etcd/features/MiscellaneousApiMockTest.java | 105 ------------ .../etcd/features/StatisticsApiLiveTest.java | 77 --------- .../etcd/features/StatisticsApiMockTest.java | 91 ---------- .../jclouds/etcd/internal/BaseEtcdMockTest.java | 114 ------------- etcd/src/test/resources/health-bad.json | 1 - etcd/src/test/resources/health.json | 1 - etcd/src/test/resources/keys-create-ttl.json | 11 -- etcd/src/test/resources/keys-create.json | 9 - etcd/src/test/resources/keys-delete.json | 14 -- .../resources/keys-get-delete-nonexistent.json | 6 - etcd/src/test/resources/keys-get.json | 9 - etcd/src/test/resources/leader.json | 31 ---- .../test/resources/members-add-existent.json | 1 - .../resources/members-add-illegal-format.json | 1 - .../resources/members-add-malformed-url.json | 1 - etcd/src/test/resources/members-added.json | 9 - .../resources/members-delete-nonexistent.json | 1 - etcd/src/test/resources/members.json | 24 --- etcd/src/test/resources/metrics.txt | 160 ------------------ etcd/src/test/resources/self.json | 15 -- etcd/src/test/resources/store.json | 16 -- etcd/src/test/resources/version.json | 4 - pom.xml | 1 - 52 files changed, 2595 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/pom.xml ---------------------------------------------------------------------- diff --git a/etcd/pom.xml b/etcd/pom.xml deleted file mode 100644 index f83e72c..0000000 --- a/etcd/pom.xml +++ /dev/null @@ -1,123 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<project xmlns="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/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.jclouds.labs</groupId> - <artifactId>jclouds-labs</artifactId> - <version>2.0.0-SNAPSHOT</version> - </parent> - - <!-- TODO: when out of labs, switch to org.jclouds.api --> - <artifactId>etcd</artifactId> - <name>jclouds etcd api</name> - <description>jclouds components to access an implementation of etcd</description> - <packaging>bundle</packaging> - - <properties> - <test.etcd.endpoint>http://127.0.0.1:2379</test.etcd.endpoint> - <test.etcd.identity>FIXME</test.etcd.identity> - <test.etcd.credential>FIXME</test.etcd.credential> - <test.etcd.api-version>v2</test.etcd.api-version> - <jclouds.osgi.export>org.jclouds.etcd*;version="${project.version}"</jclouds.osgi.export> - <jclouds.osgi.import> - org.jclouds*;version="${jclouds.version}", - * - </jclouds.osgi.import> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-core</artifactId> - <version>${jclouds.version}</version> - </dependency> - <dependency> - <groupId>com.google.auto.service</groupId> - <artifactId>auto-service</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.google.auto.value</groupId> - <artifactId>auto-value</artifactId> - <scope>provided</scope> - </dependency> - <!-- Test dependencies --> - <dependency> - <groupId>org.apache.jclouds</groupId> - <artifactId>jclouds-core</artifactId> - <version>${jclouds.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.squareup.okhttp</groupId> - <artifactId>mockwebserver</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.jclouds.driver</groupId> - <artifactId>jclouds-slf4j</artifactId> - <version>${jclouds.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <profiles> - <profile> - <id>live</id> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <executions> - <execution> - <id>integration</id> - <phase>integration-test</phase> - <goals> - <goal>test</goal> - </goals> - <configuration> - <systemPropertyVariables> - <test.etcd.endpoint>${test.etcd.endpoint}</test.etcd.endpoint> - <test.etcd.identity>${test.etcd.identity}</test.etcd.identity> - <test.etcd.credential>${test.etcd.credential}</test.etcd.credential> - <test.etcd.api-version>${test.etcd.api-version}</test.etcd.api-version> - </systemPropertyVariables> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project> http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/EtcdApi.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/EtcdApi.java b/etcd/src/main/java/org/jclouds/etcd/EtcdApi.java deleted file mode 100644 index fb5f811..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/EtcdApi.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd; - -import java.io.Closeable; - -import org.jclouds.etcd.features.KeysApi; -import org.jclouds.etcd.features.MembersApi; -import org.jclouds.etcd.features.MiscellaneousApi; -import org.jclouds.etcd.features.StatisticsApi; -import org.jclouds.rest.annotations.Delegate; - -public interface EtcdApi extends Closeable { - - @Delegate - KeysApi keysApi(); - - @Delegate - MembersApi membersApi(); - - @Delegate - MiscellaneousApi miscellaneousApi(); - - @Delegate - StatisticsApi statisticsApi(); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/EtcdApiMetadata.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/EtcdApiMetadata.java b/etcd/src/main/java/org/jclouds/etcd/EtcdApiMetadata.java deleted file mode 100644 index c44490f..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/EtcdApiMetadata.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.etcd.config.EtcdHttpApiModule; -import org.jclouds.rest.internal.BaseHttpApiMetadata; - -import com.google.auto.service.AutoService; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -@AutoService(ApiMetadata.class) -public class EtcdApiMetadata extends BaseHttpApiMetadata<EtcdApi> { - - public static final String API_VERSION = "v2"; - public static final String BUILD_VERSION = "2.2.5"; - - @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata(this); - } - - public EtcdApiMetadata() { - this(new Builder()); - } - - protected EtcdApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseHttpApiMetadata.defaultProperties(); - return properties; - } - - public static class Builder extends BaseHttpApiMetadata.Builder<EtcdApi, Builder> { - - protected Builder() { - super(EtcdApi.class); - id("etcd").name("Etcd API").identityName("Optional Username").credentialName("Optional Password") - .defaultIdentity("N/A").defaultCredential("N/A") - .documentation(URI.create("https://github.com/coreos/etcd/blob/master/Documentation/api.md")) - .version(API_VERSION).buildVersion(BUILD_VERSION).defaultEndpoint("http://127.0.0.1:2379") - .defaultProperties(EtcdApiMetadata.defaultProperties()) - .defaultModules(ImmutableSet.<Class<? extends Module>> of(EtcdHttpApiModule.class)); - } - - @Override - public EtcdApiMetadata build() { - return new EtcdApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - - @Override - public Builder fromApiMetadata(ApiMetadata in) { - return this; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/config/EtcdHttpApiModule.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/config/EtcdHttpApiModule.java b/etcd/src/main/java/org/jclouds/etcd/config/EtcdHttpApiModule.java deleted file mode 100644 index f635387..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/config/EtcdHttpApiModule.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.config; - -import org.jclouds.etcd.EtcdApi; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.rest.ConfiguresHttpApi; -import org.jclouds.rest.config.HttpApiModule; - -import org.jclouds.etcd.handlers.EtcdErrorHandler; - -@ConfiguresHttpApi -public class EtcdHttpApiModule extends HttpApiModule<EtcdApi> { - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(EtcdErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(EtcdErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(EtcdErrorHandler.class); - } - - protected void configure() { - super.configure(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/domain/keys/Key.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/domain/keys/Key.java b/etcd/src/main/java/org/jclouds/etcd/domain/keys/Key.java deleted file mode 100644 index 5c9b378..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/domain/keys/Key.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.domain.keys; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Key { - - public abstract String action(); - - public abstract Node node(); - - @Nullable - public abstract Node prevNode(); - - Key() { - } - - @SerializedNames({ "action", "node", "prevNode" }) - public static Key create(String action, Node node, Node prevNode) { - return new AutoValue_Key(action, node, prevNode); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/domain/keys/Node.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/domain/keys/Node.java b/etcd/src/main/java/org/jclouds/etcd/domain/keys/Node.java deleted file mode 100644 index 6ccdac9..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/domain/keys/Node.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.domain.keys; - -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; - -@AutoValue -public abstract class Node { - - public abstract int createdIndex(); - - public abstract boolean dir(); - - public abstract List<Node> nodes(); - - @Nullable - public abstract String expiration(); - - @Nullable - public abstract String key(); - - public abstract int modifiedIndex(); - - public abstract int ttl(); - - @Nullable - public abstract String value(); - - Node() { - } - - @SerializedNames({ "createdIndex", "dir", "nodes", "expiration", "key", "modifiedIndex", "ttl", "value" }) - public static Node create(int createdIndex, boolean dir, List<Node> nodes, String expiration, String key, - int modifiedIndex, int ttl, String value) { - return new AutoValue_Node(createdIndex, dir, - nodes != null ? ImmutableList.copyOf(nodes) : ImmutableList.<Node> of(), expiration, key, modifiedIndex, - ttl, value); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/domain/members/CreateMember.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/domain/members/CreateMember.java b/etcd/src/main/java/org/jclouds/etcd/domain/members/CreateMember.java deleted file mode 100644 index 025e8bd..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/domain/members/CreateMember.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.domain.members; - -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; - -@AutoValue -public abstract class CreateMember { - - @Nullable - public abstract String name(); - - public abstract List<String> peerURLs(); - - public abstract List<String> clientURLs(); - - CreateMember() { - } - - @SerializedNames({ "name", "peerURLs", "clientURLs" }) - public static CreateMember create(String name, List<String> peerURLs, List<String> clientURLs) { - if (clientURLs == null) - clientURLs = ImmutableList.of(); - return new AutoValue_CreateMember(name, ImmutableList.copyOf(peerURLs), ImmutableList.copyOf(clientURLs)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/domain/members/Member.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/domain/members/Member.java b/etcd/src/main/java/org/jclouds/etcd/domain/members/Member.java deleted file mode 100644 index cfeae6c..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/domain/members/Member.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.domain.members; - -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; - -@AutoValue -public abstract class Member { - - public abstract String id(); - - @Nullable - public abstract String name(); - - public abstract List<String> peerURLs(); - - public abstract List<String> clientURLs(); - - Member() { - } - - @SerializedNames({ "id", "name", "peerURLs", "clientURLs" }) - private static Member create(String id, String name, List<String> peerURLs, List<String> clientURLs) { - if (clientURLs == null) - clientURLs = ImmutableList.of(); - return new AutoValue_Member(id, name, ImmutableList.copyOf(peerURLs), ImmutableList.copyOf(clientURLs)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/domain/miscellaneous/Version.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/domain/miscellaneous/Version.java b/etcd/src/main/java/org/jclouds/etcd/domain/miscellaneous/Version.java deleted file mode 100644 index 60d05ed..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/domain/miscellaneous/Version.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.domain.miscellaneous; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Version { - - public abstract String etcdServer(); - - public abstract String etcdCluster(); - - Version() { - } - - @SerializedNames({ "etcdserver", "etcdcluster" }) - public static Version create(String etcdserver, String etcdcluster) { - return new AutoValue_Version(etcdserver, etcdcluster); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Counts.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Counts.java b/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Counts.java deleted file mode 100644 index eabc6a9..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Counts.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.domain.statistics; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Counts { - - public abstract int fail(); - - public abstract int success(); - - Counts() { - } - - @SerializedNames({ "fail", "success" }) - private static Counts create(int fail, int success) { - return new AutoValue_Counts(fail, success); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Follower.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Follower.java b/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Follower.java deleted file mode 100644 index 05c333e..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Follower.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.domain.statistics; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Follower { - - public abstract Counts counts(); - - public abstract Latency latency(); - - Follower() { - } - - @SerializedNames({ "counts", "latency" }) - private static Follower create(Counts counts, Latency latency) { - return new AutoValue_Follower(counts, latency); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Latency.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Latency.java b/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Latency.java deleted file mode 100644 index 1002170..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Latency.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.domain.statistics; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Latency { - - public abstract double average(); - - public abstract double current(); - - public abstract double maximum(); - - public abstract double minimum(); - - public abstract double standardDeviation(); - - Latency() { - } - - @SerializedNames({ "average", "current", "maximum", "minimum", "standardDeviation" }) - private static Latency create(double average, double current, double maximum, double minimum, - double standardDeviation) { - return new AutoValue_Latency(average, current, maximum, minimum, standardDeviation); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Leader.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Leader.java b/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Leader.java deleted file mode 100644 index e3af2b0..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Leader.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.domain.statistics; - -import java.util.Map; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableMap; - -@AutoValue -public abstract class Leader { - - public abstract String leader(); - - public abstract Map<String, Follower> followers(); - - Leader() { - } - - @SerializedNames({ "leader", "followers" }) - private static Leader create(String leader, Map<String, Follower> followers) { - return new AutoValue_Leader(leader, ImmutableMap.copyOf(followers)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/domain/statistics/LeaderInfo.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/LeaderInfo.java b/etcd/src/main/java/org/jclouds/etcd/domain/statistics/LeaderInfo.java deleted file mode 100644 index ec0aa67..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/LeaderInfo.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.domain.statistics; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class LeaderInfo { - - public abstract String leader(); - - public abstract String startTime(); - - public abstract String uptime(); - - LeaderInfo() { - } - - @SerializedNames({ "leader", "startTime", "uptime" }) - private static LeaderInfo create(String leader, String startTime, String uptime) { - return new AutoValue_LeaderInfo(leader, startTime, uptime); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Self.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Self.java b/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Self.java deleted file mode 100644 index a9d7e22..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Self.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.domain.statistics; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Self { - - public abstract String id(); - - public abstract LeaderInfo leaderInfo(); - - public abstract String name(); - - public abstract double recvAppendRequestCnt(); - - public abstract double sendAppendRequestCnt(); - - public abstract double sendBandwidthRate(); - - public abstract double sendPkgRate(); - - public abstract String startTime(); - - public abstract String state(); - - Self() { - } - - @SerializedNames({ "id", "leaderInfo", "name", "recvAppendRequestCnt", "sendAppendRequestCnt", "sendBandwidthRate", - "sendPkgRate", "startTime", "state" }) - private static Self create(String id, LeaderInfo leaderInfo, String name, double recvAppendRequestCnt, - double sendAppendRequestCnt, double sendBandwidthRate, double sendPkgRate, String startTime, String state) { - return new AutoValue_Self(id, leaderInfo, name, recvAppendRequestCnt, sendAppendRequestCnt, sendBandwidthRate, - sendPkgRate, startTime, state); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Store.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Store.java b/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Store.java deleted file mode 100644 index 7c468d1..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/domain/statistics/Store.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.domain.statistics; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Store { - - public abstract int compareAndSwapFail(); - - public abstract int compareAndSwapSuccess(); - - public abstract int createFail(); - - public abstract int createSuccess(); - - public abstract int deleteFail(); - - public abstract int deleteSuccess(); - - public abstract int expireCount(); - - public abstract int getsFail(); - - public abstract int getsSuccess(); - - public abstract int setsFail(); - - public abstract int setsSuccess(); - - public abstract int updateFail(); - - public abstract int updateSuccess(); - - public abstract int watchers(); - - Store() { - } - - @SerializedNames({ "compareAndSwapFail", "compareAndSwapSuccess", "createFail", "createSuccess", "deleteFail", - "deleteSuccess", "expireCount", "getsFail", "getsSuccess", "setsFail", "setsSuccess", "updateFail", - "updateSuccess", "watchers" }) - private static Store create(int compareAndSwapFail, int compareAndSwapSuccess, int createFail, int createSuccess, - int deleteFail, int deleteSuccess, int expireCount, int getsFail, int getsSuccess, int setsFail, - int setsSuccess, int updateFail, int updateSuccess, int watchers) { - return new AutoValue_Store(compareAndSwapFail, compareAndSwapSuccess, createFail, createSuccess, deleteFail, - deleteSuccess, expireCount, getsFail, getsSuccess, setsFail, setsSuccess, updateFail, updateSuccess, - watchers); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/fallbacks/EtcdFallbacks.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/fallbacks/EtcdFallbacks.java b/etcd/src/main/java/org/jclouds/etcd/fallbacks/EtcdFallbacks.java deleted file mode 100644 index de8cec9..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/fallbacks/EtcdFallbacks.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.etcd.fallbacks; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Throwables.propagate; -import static org.jclouds.http.HttpUtils.returnValueOnCodeOrNull; - -import org.jclouds.Fallback; -import org.jclouds.http.HttpUtils; - -public final class EtcdFallbacks { - - public static final class FalseOn503 implements Fallback<Boolean> { - public Boolean createOrPropagate(Throwable t) throws Exception { - if (checkNotNull(t, "throwable") != null && t.getMessage().contains("{\"health\": \"false\"}") - && returnValueOnCodeOrNull(t, true, equalTo(503)) != null) { - return Boolean.FALSE; - } - throw propagate(t); - } - } - - public static final class NullOnKeyNonFoundAnd404 implements Fallback<Object> { - public Object createOrPropagate(Throwable t) throws Exception { - if (checkNotNull(t, "throwable") != null && t.getMessage().contains("Key not found") - && HttpUtils.contains404(t)) { - return null; - } - throw propagate(t); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/features/KeysApi.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/features/KeysApi.java b/etcd/src/main/java/org/jclouds/etcd/features/KeysApi.java deleted file mode 100644 index f2ef5d6..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/features/KeysApi.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.FormParam; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.etcd.domain.keys.Key; -import org.jclouds.etcd.fallbacks.EtcdFallbacks.NullOnKeyNonFoundAnd404; -import org.jclouds.rest.annotations.Fallback; - -@Consumes(MediaType.APPLICATION_JSON) -@Path("/{jclouds.api-version}/keys") -public interface KeysApi { - - @Named("keys:create") - @PUT - @Path("/{key}") - Key createKey(@PathParam("key") String key, @FormParam("value") String value); - - @Named("keys:create") - @PUT - @Path("/{key}") - Key createKey(@PathParam("key") String key, @FormParam("value") String value, @FormParam("ttl") int seconds); - - @Named("keys:get") - @GET - @Path("/{key}") - @Fallback(NullOnKeyNonFoundAnd404.class) - Key getKey(@PathParam("key") String key); - - @Named("keys:delete") - @DELETE - @Path("/{key}") - @Fallback(NullOnKeyNonFoundAnd404.class) - Key deleteKey(@PathParam("key") String key); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/features/MembersApi.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/features/MembersApi.java b/etcd/src/main/java/org/jclouds/etcd/features/MembersApi.java deleted file mode 100644 index 655b748..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/features/MembersApi.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.features; - -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.FalseOnNotFoundOr404; -import org.jclouds.etcd.domain.members.CreateMember; -import org.jclouds.etcd.domain.members.Member; -import org.jclouds.rest.ResourceAlreadyExistsException; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.binders.BindToJsonPayload; - -@Consumes(MediaType.APPLICATION_JSON) -@Path("/{jclouds.api-version}/members") -public interface MembersApi { - - /** - * @return list of members within cluster - */ - @Named("members:list") - @SelectJson("members") - @GET - List<Member> list(); - - /** - * @param member - * non-existing member to add to cluster - * @return newly created member - * @throws ResourceAlreadyExistsException - * if member with peerURLs was already present - */ - @Named("members:add") - @POST - Member add(@BinderParam(BindToJsonPayload.class) CreateMember memberToCreate); - - /** - * @param memberID - * id of previously existing member - * @return true if member was deleted or false if id did not match an - * existing member - */ - @Named("members:delete") - @Path("/{id}") - @Fallback(FalseOnNotFoundOr404.class) - @DELETE - boolean delete(@PathParam("id") String memberID); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/features/MiscellaneousApi.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/features/MiscellaneousApi.java b/etcd/src/main/java/org/jclouds/etcd/features/MiscellaneousApi.java deleted file mode 100644 index 73d61ea..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/features/MiscellaneousApi.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.etcd.domain.miscellaneous.Version; -import org.jclouds.etcd.fallbacks.EtcdFallbacks.FalseOn503; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.SelectJson; - -public interface MiscellaneousApi { - - @Named("miscellaneous:version") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/version") - @GET - Version version(); - - @Named("miscellaneous:health") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/health") - @SelectJson("health") - @Fallback(FalseOn503.class) - @GET - boolean health(); - - @Named("miscellaneous:metrics") - @Consumes(MediaType.TEXT_PLAIN) - @Path("/metrics") - @GET - String metrics(); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/features/StatisticsApi.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/features/StatisticsApi.java b/etcd/src/main/java/org/jclouds/etcd/features/StatisticsApi.java deleted file mode 100644 index d469cf6..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/features/StatisticsApi.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.etcd.domain.statistics.Leader; -import org.jclouds.etcd.domain.statistics.Self; -import org.jclouds.etcd.domain.statistics.Store; - -@Consumes(MediaType.APPLICATION_JSON) -@Path("/{jclouds.api-version}/stats") -public interface StatisticsApi { - - /** - * @return information on leader and entire cluster but only if WE are the - * leader - */ - @Named("statistics:leader") - @Path("/leader") - @GET - Leader leader(); - - /** - * @return information on node we are currently pointing at - */ - @Named("statistics:self") - @Path("/self") - @GET - Self self(); - - /** - * @return information about operations this node has handled - */ - @Named("statistics:store") - @Path("/store") - @GET - Store store(); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/main/java/org/jclouds/etcd/handlers/EtcdErrorHandler.java ---------------------------------------------------------------------- diff --git a/etcd/src/main/java/org/jclouds/etcd/handlers/EtcdErrorHandler.java b/etcd/src/main/java/org/jclouds/etcd/handlers/EtcdErrorHandler.java deleted file mode 100644 index e3e2261..0000000 --- a/etcd/src/main/java/org/jclouds/etcd/handlers/EtcdErrorHandler.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.etcd.handlers; - -import static org.jclouds.util.Closeables2.closeQuietly; - -import java.io.IOException; - -import javax.annotation.Resource; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.logging.Logger; -import org.jclouds.rest.ResourceAlreadyExistsException; -import org.jclouds.util.Strings2; - -import com.google.common.base.Throwables; - -/** - * Handle errors and propagate exception - */ -public class EtcdErrorHandler implements HttpErrorHandler { - @Resource - protected Logger logger = Logger.NULL; - - public void handleError(HttpCommand command, HttpResponse response) { - - String message = parseMessage(response); - Exception exception = null; - try { - - message = message != null ? message - : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()); - - switch (response.getStatusCode()) { - case 400: - exception = new IllegalArgumentException(message); - break; - case 409: - exception = new ResourceAlreadyExistsException(message); - break; - default: - exception = new HttpResponseException(message, command, response); - break; - } - } catch (Exception e) { - exception = new HttpResponseException(command, response, e); - } finally { - if (exception == null) { - exception = message != null ? new HttpResponseException(command, response, message) - : new HttpResponseException(command, response); - } - closeQuietly(response.getPayload()); - command.setException(exception); - } - } - - private String parseMessage(HttpResponse response) { - if (response.getPayload() == null) - return null; - try { - return Strings2.toStringAndClose(response.getPayload().openStream()); - } catch (IOException e) { - throw Throwables.propagate(e); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/test/java/org/jclouds/etcd/BaseEtcdApiLiveTest.java ---------------------------------------------------------------------- diff --git a/etcd/src/test/java/org/jclouds/etcd/BaseEtcdApiLiveTest.java b/etcd/src/test/java/org/jclouds/etcd/BaseEtcdApiLiveTest.java deleted file mode 100644 index 88cfb61..0000000 --- a/etcd/src/test/java/org/jclouds/etcd/BaseEtcdApiLiveTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.etcd; - -import java.util.Properties; -import java.util.UUID; - -import org.jclouds.Constants; -import org.jclouds.apis.BaseApiLiveTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -@Test(groups = "live") -public class BaseEtcdApiLiveTest extends BaseApiLiveTest<EtcdApi> { - - public BaseEtcdApiLiveTest() { - provider = "etcd"; - } - - @Override - protected Iterable<Module> setupModules() { - return ImmutableSet.<Module> of(getLoggingModule()); - } - - @Override - protected Properties setupProperties() { - Properties overrides = super.setupProperties(); - overrides.setProperty(Constants.PROPERTY_MAX_RETRIES, "0"); - return overrides; - } - - protected String randomString() { - return UUID.randomUUID().toString().replaceAll("-", ""); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/test/java/org/jclouds/etcd/EtcdApiMetadataTest.java ---------------------------------------------------------------------- diff --git a/etcd/src/test/java/org/jclouds/etcd/EtcdApiMetadataTest.java b/etcd/src/test/java/org/jclouds/etcd/EtcdApiMetadataTest.java deleted file mode 100644 index 475a5b5..0000000 --- a/etcd/src/test/java/org/jclouds/etcd/EtcdApiMetadataTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.etcd; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.HashSet; -import org.jclouds.View; -import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.Apis; -import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.testng.annotations.Test; - -import com.google.common.reflect.TypeToken; - -/** - * Unit tests for the {@link EtcdApiMetadata} class. - */ -@Test(groups = "unit", testName = "EtcdApiMetadataTest") -public class EtcdApiMetadataTest extends BaseApiMetadataTest { - - public EtcdApiMetadataTest() { - super(new EtcdApiMetadata(), new HashSet<TypeToken<? extends View>>()); - } - - public void testEtcdApiRegistered() { - ApiMetadata api = Apis.withId("etcd"); - - assertNotNull(api); - assertTrue(api instanceof EtcdApiMetadata); - assertEquals(api.getId(), "etcd"); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/test/java/org/jclouds/etcd/features/KeysApiLiveTest.java ---------------------------------------------------------------------- diff --git a/etcd/src/test/java/org/jclouds/etcd/features/KeysApiLiveTest.java b/etcd/src/test/java/org/jclouds/etcd/features/KeysApiLiveTest.java deleted file mode 100644 index 2b31917..0000000 --- a/etcd/src/test/java/org/jclouds/etcd/features/KeysApiLiveTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.etcd.features; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.etcd.BaseEtcdApiLiveTest; -import org.jclouds.etcd.domain.keys.Key; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Throwables; - -@Test(groups = "live", testName = "KeysApiLiveTest") -public class KeysApiLiveTest extends BaseEtcdApiLiveTest { - - private String key; - private String value; - - @BeforeClass - protected void init() { - key = randomString(); - value = randomString(); - } - - @Test - public void testCreateKeyWithTTL() { - String localKey = randomString(); - String localValue = randomString(); - Key createdKey = api().createKey(localKey, localValue, 1); - assertNotNull(createdKey); - assertNotNull(createdKey.node().expiration()); - assertTrue(createdKey.node().ttl() == 1); - - try { - Thread.sleep(3000); - } catch (InterruptedException e) { - Throwables.propagate(e); - } - - createdKey = api().getKey(localKey); - assertNull(createdKey); - } - - @Test - public void testCreateKey() { - Key createdKey = api().createKey(key, value); - assertNotNull(createdKey); - assertTrue(createdKey.action().equals("set")); - assertTrue(createdKey.node().value().equals(value)); - } - - @Test(dependsOnMethods = "testCreateKey") - public void testGetKey() { - Key getKey = api().getKey(key); - assertNotNull(getKey); - assertTrue(getKey.action().equals("get")); - assertTrue(getKey.node().value().equals(value)); - } - - @Test(dependsOnMethods = "testGetKey", alwaysRun = true) - public void testDeleteKey() { - Key deletedKey = api().deleteKey(key); - assertNotNull(deletedKey); - assertTrue(deletedKey.action().equals("delete")); - assertTrue(deletedKey.prevNode().value().equals(value)); - } - - @Test - public void testGetNonExistentKey() { - Key deletedKey = api().getKey(randomString()); - assertNull(deletedKey); - } - - @Test - public void testDeleteNonExistentKey() { - Key deletedKey = api().deleteKey(randomString()); - assertNull(deletedKey); - } - - private KeysApi api() { - return api.keysApi(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/test/java/org/jclouds/etcd/features/KeysApiMockTest.java ---------------------------------------------------------------------- diff --git a/etcd/src/test/java/org/jclouds/etcd/features/KeysApiMockTest.java b/etcd/src/test/java/org/jclouds/etcd/features/KeysApiMockTest.java deleted file mode 100644 index 7f650a0..0000000 --- a/etcd/src/test/java/org/jclouds/etcd/features/KeysApiMockTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.etcd.features; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.etcd.EtcdApi; -import org.jclouds.etcd.EtcdApiMetadata; -import org.jclouds.etcd.domain.keys.Key; -import org.jclouds.etcd.internal.BaseEtcdMockTest; -import org.testng.annotations.Test; - -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; - -/** - * Mock tests for the {@link org.jclouds.etcd.features.KeysApi} class. - */ -@Test(groups = "unit", testName = "KeysApiMockTest") -public class KeysApiMockTest extends BaseEtcdMockTest { - - public void testCreateKey() throws Exception { - MockWebServer server = mockEtcdJavaWebServer(); - - server.enqueue(new MockResponse().setBody(payloadFromResource("/keys-create.json")).setResponseCode(201)); - EtcdApi etcdApi = api(server.getUrl("/")); - KeysApi api = etcdApi.keysApi(); - try { - Key createdKey = api.createKey("hello", "world"); - assertNotNull(createdKey); - assertTrue(createdKey.node().key().equals("/hello")); - assertTrue(createdKey.node().value().equals("world")); - assertSentWithFormData(server, "PUT", "/" + EtcdApiMetadata.API_VERSION + "/keys/hello", "value=world"); - } finally { - etcdApi.close(); - server.shutdown(); - } - } - - public void testCreateKeyWithTTL() throws Exception { - MockWebServer server = mockEtcdJavaWebServer(); - - server.enqueue(new MockResponse().setBody(payloadFromResource("/keys-create-ttl.json")).setResponseCode(201)); - EtcdApi etcdApi = api(server.getUrl("/")); - KeysApi api = etcdApi.keysApi(); - try { - Key createdKey = api.createKey("hello", "world", 5); - assertNotNull(createdKey); - assertNotNull(createdKey.node().expiration()); - assertTrue(createdKey.node().ttl() == 5); - assertTrue(createdKey.node().key().equals("/hello")); - assertTrue(createdKey.node().value().equals("world")); - assertSentWithFormData(server, "PUT", "/" + EtcdApiMetadata.API_VERSION + "/keys/hello", "value=world&ttl=5"); - } finally { - etcdApi.close(); - server.shutdown(); - } - } - - public void testGetKey() throws Exception { - MockWebServer server = mockEtcdJavaWebServer(); - - server.enqueue(new MockResponse().setBody(payloadFromResource("/keys-get.json")).setResponseCode(200)); - EtcdApi etcdApi = api(server.getUrl("/")); - KeysApi api = etcdApi.keysApi(); - try { - Key foundKey = api.getKey("hello"); - assertNotNull(foundKey); - assertTrue(foundKey.node().key().equals("/hello")); - assertTrue(foundKey.node().value().equals("world")); - assertSent(server, "GET", "/" + EtcdApiMetadata.API_VERSION + "/keys/hello"); - } finally { - etcdApi.close(); - server.shutdown(); - } - } - - public void testGetNonExistentKey() throws Exception { - MockWebServer server = mockEtcdJavaWebServer(); - - server.enqueue( - new MockResponse().setBody(payloadFromResource("/keys-get-delete-nonexistent.json")).setResponseCode(404)); - EtcdApi etcdApi = api(server.getUrl("/")); - KeysApi api = etcdApi.keysApi(); - try { - Key nonExistentKey = api.getKey("NonExistentKeyToGet"); - assertNull(nonExistentKey); - assertSent(server, "GET", "/" + EtcdApiMetadata.API_VERSION + "/keys/NonExistentKeyToGet"); - } finally { - etcdApi.close(); - server.shutdown(); - } - } - - public void testDeleteKey() throws Exception { - MockWebServer server = mockEtcdJavaWebServer(); - - server.enqueue(new MockResponse().setBody(payloadFromResource("/keys-delete.json")).setResponseCode(200)); - EtcdApi etcdApi = api(server.getUrl("/")); - KeysApi api = etcdApi.keysApi(); - try { - Key deletedKey = api.deleteKey("hello"); - assertTrue(deletedKey.prevNode().key().equals("/hello")); - assertTrue(deletedKey.prevNode().value().equals("world")); - assertSent(server, "DELETE", "/" + EtcdApiMetadata.API_VERSION + "/keys/hello"); - } finally { - etcdApi.close(); - server.shutdown(); - } - } - - public void testDeleteNonExistentKey() throws Exception { - MockWebServer server = mockEtcdJavaWebServer(); - - server.enqueue( - new MockResponse().setBody(payloadFromResource("/keys-get-delete-nonexistent.json")).setResponseCode(404)); - EtcdApi etcdApi = api(server.getUrl("/")); - KeysApi api = etcdApi.keysApi(); - try { - Key nonExistentKey = api.deleteKey("NonExistentKeyToDelete"); - assertNull(nonExistentKey); - assertSent(server, "DELETE", "/" + EtcdApiMetadata.API_VERSION + "/keys/NonExistentKeyToDelete"); - } finally { - etcdApi.close(); - server.shutdown(); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/test/java/org/jclouds/etcd/features/MembersApiLiveTest.java ---------------------------------------------------------------------- diff --git a/etcd/src/test/java/org/jclouds/etcd/features/MembersApiLiveTest.java b/etcd/src/test/java/org/jclouds/etcd/features/MembersApiLiveTest.java deleted file mode 100644 index df8d58e..0000000 --- a/etcd/src/test/java/org/jclouds/etcd/features/MembersApiLiveTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.etcd.features; - -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.util.List; - -import org.jclouds.etcd.BaseEtcdApiLiveTest; -import org.jclouds.etcd.domain.members.CreateMember; -import org.jclouds.etcd.domain.members.Member; -import org.jclouds.rest.ResourceAlreadyExistsException; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; - -@Test(groups = "live", testName = "MembersApiLiveTest", singleThreaded = true) -public class MembersApiLiveTest extends BaseEtcdApiLiveTest { - - private String selfID; - private Member nonSelfMember; - private Member addedMember; - - @BeforeClass - protected void init() { - selfID = api.statisticsApi().self().id(); - assertNotNull(selfID); - } - - public void testListMembers() { - List<Member> members = api().list(); - assertNotNull(members); - assertTrue(members.size() > 0); - for (Member member : members) { - if (!member.id().equals(selfID)) { - this.nonSelfMember = member; - return; - } - } - throw new RuntimeException("Could not find another member in cluster with different id"); - } - - @Test(dependsOnMethods = "testListMembers") - public void testDeleteMember() { - boolean successful = api().delete(nonSelfMember.id()); - assertTrue(successful); - } - - @Test(dependsOnMethods = "testDeleteMember") - public void testAddMember() { - assertNotNull(nonSelfMember); - - addedMember = api().add(CreateMember.create(null, nonSelfMember.peerURLs(), null)); - assertNotNull(addedMember); - assertTrue(addedMember.peerURLs().containsAll(nonSelfMember.peerURLs())); - } - - @Test(dependsOnMethods = "testAddMember", expectedExceptions = ResourceAlreadyExistsException.class) - public void testAddExistingMember() { - assertNotNull(addedMember); - - Member existingMember = api().add(CreateMember.create(null, addedMember.peerURLs(), addedMember.clientURLs())); - assertNull(existingMember); - } - - @Test(dependsOnMethods = "testAddExistingMember", expectedExceptions = IllegalArgumentException.class) - public void testAddMemberWithMalformedURL() { - api().add(CreateMember.create(null, ImmutableList.of("htp:/hello/world:11bye"), null)); - } - - @Test(dependsOnMethods = "testAddMemberWithMalformedURL", expectedExceptions = IllegalArgumentException.class) - public void testAddMemberWithIllegalFormat() { - api().add(CreateMember.create(null, ImmutableList.of("http://www.google.com"), null)); - } - - @Test(dependsOnMethods = "testAddMemberWithIllegalFormat") - public void testDeleteMemberNonExistentMember() { - boolean successful = api().delete(randomString()); - assertFalse(successful); - } - - private MembersApi api() { - return api.membersApi(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/test/java/org/jclouds/etcd/features/MembersApiMockTest.java ---------------------------------------------------------------------- diff --git a/etcd/src/test/java/org/jclouds/etcd/features/MembersApiMockTest.java b/etcd/src/test/java/org/jclouds/etcd/features/MembersApiMockTest.java deleted file mode 100644 index 863e131..0000000 --- a/etcd/src/test/java/org/jclouds/etcd/features/MembersApiMockTest.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.etcd.features; - -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertFalse; - -import java.util.List; - -import org.jclouds.etcd.EtcdApi; -import org.jclouds.etcd.EtcdApiMetadata; -import org.jclouds.etcd.domain.members.CreateMember; -import org.jclouds.etcd.domain.members.Member; -import org.jclouds.etcd.internal.BaseEtcdMockTest; -import org.jclouds.rest.ResourceAlreadyExistsException; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; - -/** - * Mock tests for the {@link org.jclouds.etcd.features.MembersApi} class. - */ -@Test(groups = "unit", testName = "MembersApiMockTest") -public class MembersApiMockTest extends BaseEtcdMockTest { - - public void testListMembers() throws Exception { - MockWebServer server = mockEtcdJavaWebServer(); - - server.enqueue(new MockResponse().setBody(payloadFromResource("/members.json")).setResponseCode(200)); - EtcdApi etcdApi = api(server.getUrl("/")); - MembersApi api = etcdApi.membersApi(); - try { - List<Member> members = api.list(); - assertNotNull(members); - assertTrue(members.size() == 2); - assertSent(server, "GET", "/" + EtcdApiMetadata.API_VERSION + "/members"); - } finally { - etcdApi.close(); - server.shutdown(); - } - } - - public void testAddMember() throws Exception { - MockWebServer server = mockEtcdJavaWebServer(); - - server.enqueue(new MockResponse().setBody(payloadFromResource("/members-added.json")).setResponseCode(201)); - EtcdApi etcdApi = api(server.getUrl("/")); - MembersApi api = etcdApi.membersApi(); - try { - String peerURL = "http://10.0.0.10:2380"; - String clientURL = "http://10.0.0.10:2381"; - Member member = api.add(CreateMember.create(null, ImmutableList.of(peerURL), ImmutableList.of(clientURL))); - assertNotNull(member); - assertTrue(member.peerURLs().contains(peerURL)); - assertTrue(member.clientURLs().contains(clientURL)); - assertSent(server, "POST", "/" + EtcdApiMetadata.API_VERSION + "/members"); - } finally { - etcdApi.close(); - server.shutdown(); - } - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testAddMemberWithMalformedURL() throws Exception { - MockWebServer server = mockEtcdJavaWebServer(); - - server.enqueue( - new MockResponse().setBody(payloadFromResource("/members-add-malformed-url.json")).setResponseCode(400)); - EtcdApi etcdApi = api(server.getUrl("/")); - MembersApi api = etcdApi.membersApi(); - try { - String peerURL = "htp:/hello/world:11bye"; - api.add(CreateMember.create(null, ImmutableList.of(peerURL), null)); - } finally { - etcdApi.close(); - server.shutdown(); - } - } - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testAddMemberWithIllegalFormat() throws Exception { - MockWebServer server = mockEtcdJavaWebServer(); - - server.enqueue( - new MockResponse().setBody(payloadFromResource("/members-add-illegal-format.json")).setResponseCode(400)); - EtcdApi etcdApi = api(server.getUrl("/")); - MembersApi api = etcdApi.membersApi(); - try { - String peerURL = "http://www.google.com"; - api.add(CreateMember.create(null, ImmutableList.of(peerURL), null)); - } finally { - etcdApi.close(); - server.shutdown(); - } - } - - @Test(expectedExceptions = ResourceAlreadyExistsException.class) - public void testAddExistingMember() throws Exception { - MockWebServer server = mockEtcdJavaWebServer(); - - server.enqueue( - new MockResponse().setBody(payloadFromResource("/members-add-existent.json")).setResponseCode(409)); - EtcdApi etcdApi = api(server.getUrl("/")); - MembersApi api = etcdApi.membersApi(); - try { - String peerURL = "http://10.0.0.10:2380"; - Member member = api.add(CreateMember.create(null, ImmutableList.of(peerURL), null)); - assertNull(member); - assertSent(server, "POST", "/" + EtcdApiMetadata.API_VERSION + "/members"); - } finally { - etcdApi.close(); - server.shutdown(); - } - } - - public void testDeleteMember() throws Exception { - MockWebServer server = mockEtcdJavaWebServer(); - - server.enqueue(new MockResponse().setBody("").setResponseCode(204)); - EtcdApi etcdApi = api(server.getUrl("/")); - MembersApi api = etcdApi.membersApi(); - try { - String memberID = "123456789"; - boolean deleted = api.delete(memberID); - assertTrue(deleted); - assertSent(server, "DELETE", "/" + EtcdApiMetadata.API_VERSION + "/members/" + memberID); - } finally { - etcdApi.close(); - server.shutdown(); - } - } - - public void testDeleteNonExistentMember() throws Exception { - MockWebServer server = mockEtcdJavaWebServer(); - - server.enqueue( - new MockResponse().setBody(payloadFromResource("/members-delete-nonexistent.json")).setResponseCode(404)); - EtcdApi etcdApi = api(server.getUrl("/")); - MembersApi api = etcdApi.membersApi(); - try { - String memberID = "1234567890"; - boolean deleted = api.delete(memberID); - assertFalse(deleted); - assertSent(server, "DELETE", "/" + EtcdApiMetadata.API_VERSION + "/members/" + memberID); - } finally { - etcdApi.close(); - server.shutdown(); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1f215379/etcd/src/test/java/org/jclouds/etcd/features/MiscellaneousApiLiveTest.java ---------------------------------------------------------------------- diff --git a/etcd/src/test/java/org/jclouds/etcd/features/MiscellaneousApiLiveTest.java b/etcd/src/test/java/org/jclouds/etcd/features/MiscellaneousApiLiveTest.java deleted file mode 100644 index ec955c3..0000000 --- a/etcd/src/test/java/org/jclouds/etcd/features/MiscellaneousApiLiveTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.etcd.features; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import org.jclouds.etcd.BaseEtcdApiLiveTest; -import org.jclouds.etcd.domain.miscellaneous.Version; -import org.testng.annotations.Test; - -@Test(groups = "live", testName = "MiscellaneousApiLiveTest") -public class MiscellaneousApiLiveTest extends BaseEtcdApiLiveTest { - - private final String versionRegex = "^\\d+\\.\\d+\\.\\d+$"; - - @Test - public void testGetVersion() { - Version version = api().version(); - assertNotNull(version); - assertTrue(version.etcdServer().matches(versionRegex)); - assertTrue(version.etcdCluster().matches(versionRegex)); - } - - @Test - public void testGetHealth() { - boolean health = api().health(); - assertTrue(health); - } - - @Test - public void testGetMetrics() { - String metrics = api().metrics(); - assertNotNull(metrics); - } - - private MiscellaneousApi api() { - return api.miscellaneousApi(); - } -}
