View Javadoc

1   /**
2    * Licensed to jclouds, Inc. (jclouds) under one or more
3    * contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  jclouds licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.jclouds.rimuhosting.miro;
20  
21  import static org.jclouds.Constants.PROPERTY_API_VERSION;
22  import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT;
23  import static org.jclouds.Constants.PROPERTY_ENDPOINT;
24  import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
25  import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT;
26  import static org.jclouds.location.reference.LocationConstants.ISO3166_CODES;
27  import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONE;
28  import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES;
29  import static org.jclouds.rimuhosting.miro.reference.RimuHostingConstants.PROPERTY_RIMUHOSTING_DEFAULT_DC;
30  
31  import java.util.Properties;
32  
33  import org.jclouds.PropertiesBuilder;
34  import org.jclouds.compute.reference.ComputeServiceConstants;
35  import org.jclouds.concurrent.Timeout;
36  
37  /**
38   * Builds properties used in RimuHosting Clients
39   * 
40   * @author Adrian Cole
41   */
42  public class RimuHostingPropertiesBuilder extends PropertiesBuilder {
43     @Override
44     protected Properties defaultProperties() {
45        Properties properties = super.defaultProperties();
46        properties.setProperty(PROPERTY_ZONES, "DCAUCKLAND,DCLONDON,DCDALLAS,DCSYDNEY");
47        properties.setProperty(PROPERTY_ISO3166_CODES, "NZ-AUK,US-TX,AU-NSW,GB-LND");
48        properties.setProperty(PROPERTY_ZONE + ".DCAUCKLAND." + ISO3166_CODES, "NZ-AUK");
49        properties.setProperty(PROPERTY_ZONE + ".DCLONDON." + ISO3166_CODES, "GB-LND");
50        properties.setProperty(PROPERTY_ZONE + ".DCDALLAS." + ISO3166_CODES, "US-TX");
51        properties.setProperty(PROPERTY_ZONE + ".DCSYDNEY." + ISO3166_CODES, "AU-NSW");
52        properties.setProperty(PROPERTY_API_VERSION, "TODO");
53        properties.setProperty(PROPERTY_ENDPOINT, "https://api.rimuhosting.com/r");
54        properties.setProperty(PROPERTY_RIMUHOSTING_DEFAULT_DC, "DCDALLAS");
55        Timeout timeout = RimuHostingClient.class.getAnnotation(Timeout.class);
56        long timeoutMillis = timeout.timeUnit().toMillis(timeout.duration());
57        properties.setProperty(PROPERTY_SO_TIMEOUT, timeoutMillis + "");
58        properties.setProperty(PROPERTY_CONNECTION_TIMEOUT, timeoutMillis + "");
59        properties.setProperty(ComputeServiceConstants.PROPERTY_TIMEOUT_NODE_TERMINATED, 60 * 1000 + "");
60        return properties;
61     }
62  
63     public RimuHostingPropertiesBuilder(Properties properties) {
64        super(properties);
65     }
66  }