@Override public Object valueFromString(String param) { if (param == null) return null; return Protocol.valueOf(param.toUpperCase()); }
@Override public PingResponse pingNode(Protocol protocol, String host, int port) { String portStr = (port > 0) ? ":" + port : ""; WebResource resource = client.resource(String.format("%s://%s%s/?ping", protocol.name().toLowerCase(), host, portStr)); resource.setProperty(SmartFilter.BYPASS_LOAD_BALANCER, true); return resource.get(PingResponse.class); }
/** * Resolves a path relative to the API context. The returned URI will be of the format * scheme://host[:port][/rootContext]/subPath?query. The scheme and port are pulled from the first endpoint in * the endpoints list. The host to use may be virtual (to be resolved by a load balancer) or calculated in * implementations as round-robin or single-host. Note this is not to be confused with the client-side load * balancing provided by the smart client, which overrides any host set here. * * Note that the query string must already be encoded. This is the only way too allow ampersands (&) as part * of a paremeter value */ public URI resolvePath(String subPath, String rawQuery) { String path = ""; // rootContext should be cleaned by setter if (rootContext != null && rootContext.length() > 0) path += rootContext; // add relative path to context path += subPath; if (path.isEmpty()) path = "/"; try { URI uri = RestUtil.buildUri(protocol.toString().toLowerCase(), resolveHost().getName(), port, path, rawQuery, null); log.debug("raw path & query: " + path + "?" + rawQuery); log.debug("resolved URI: " + uri); return uri; } catch (URISyntaxException e) { throw new RuntimeException("Invalid URI syntax", e); } }
/** * Single endpoint constructor (disables smart-client). */ public ObjectConfig(URI endpoint) { this(Protocol.valueOf(endpoint.getScheme().toUpperCase()), endpoint.getPort(), endpoint.getHost()); setRootContext(endpoint.getPath()); setSmartClient(false); }
hostListProvider.setProtocol(s3Config.getPropAsString(S3Config.PROPERTY_POLL_PROTOCOL)); else hostListProvider.setProtocol(s3Config.getProtocol().toString());
@Before public void setup() throws Exception { Properties syncProperties = TestConfig.getProperties(); String endpoint = syncProperties.getProperty(TestConfig.PROP_S3_ENDPOINT); final String accessKey = syncProperties.getProperty(TestConfig.PROP_S3_ACCESS_KEY_ID); final String secretKey = syncProperties.getProperty(TestConfig.PROP_S3_SECRET_KEY); final boolean useVHost = Boolean.valueOf(syncProperties.getProperty(TestConfig.PROP_S3_VHOST)); Assume.assumeNotNull(endpoint, accessKey, secretKey); final URI endpointUri = new URI(endpoint); S3Config s3Config; if (useVHost) s3Config = new S3Config(endpointUri); else s3Config = new S3Config(Protocol.valueOf(endpointUri.getScheme().toUpperCase()), endpointUri.getHost()); s3Config.withPort(endpointUri.getPort()).withUseVHost(useVHost).withIdentity(accessKey).withSecretKey(secretKey); s3 = new S3JerseyClient(s3Config); try { s3.createBucket(bucketName); } catch (S3Exception e) { if (!e.getErrorCode().equals("BucketAlreadyExists")) throw e; } targetConfig = new EcsS3Config(); targetConfig.setProtocol(com.emc.ecs.sync.config.Protocol.valueOf(endpointUri.getScheme().toLowerCase())); targetConfig.setHost(endpointUri.getHost()); targetConfig.setPort(endpointUri.getPort()); targetConfig.setEnableVHosts(useVHost); targetConfig.setAccessKey(accessKey); targetConfig.setSecretKey(secretKey); targetConfig.setBucketName(bucketName); }
else s3Config = new S3Config(Protocol.valueOf(endpointUri.getScheme().toUpperCase()), endpointUri.getHost()); s3Config.withPort(endpointUri.getPort()).withUseVHost(useVHost).withIdentity(accessKey).withSecretKey(secretKey);
s3Config = new S3Config(endpointUri); } else { s3Config = new S3Config(com.emc.object.Protocol.valueOf(endpointUri.getScheme().toUpperCase()), endpointUri.getHost());
vdcs.add(new Vdc(config.getHost())); s3Config = new S3Config(Protocol.valueOf(config.getProtocol().toString().toUpperCase()), vdcs.toArray(new Vdc[vdcs.size()])); if (config.getPort() > 0) s3Config.setPort(config.getPort()); s3Config.setSmartClient(config.isSmartClientEnabled());