Search in sources :

Example 6 with URI

use of java.net.URI in project camel by apache.

the class CouchbaseEndpoint method createClient.

private CouchbaseClient createClient() throws IOException, URISyntaxException {
    List<URI> hosts = Arrays.asList(makeBootstrapURI());
    CouchbaseConnectionFactoryBuilder cfb = new CouchbaseConnectionFactoryBuilder();
    if (opTimeOut != DEFAULT_OP_TIMEOUT) {
        cfb.setOpTimeout(opTimeOut);
    }
    if (timeoutExceptionThreshold != DEFAULT_TIMEOUT_EXCEPTION_THRESHOLD) {
        cfb.setTimeoutExceptionThreshold(timeoutExceptionThreshold);
    }
    if (readBufferSize != DEFAULT_READ_BUFFER_SIZE) {
        cfb.setReadBufferSize(readBufferSize);
    }
    if (shouldOptimize) {
        cfb.setShouldOptimize(true);
    }
    if (maxReconnectDelay != DEFAULT_MAX_RECONNECT_DELAY) {
        cfb.setMaxReconnectDelay(maxReconnectDelay);
    }
    if (opQueueMaxBlockTime != DEFAULT_OP_QUEUE_MAX_BLOCK_TIME) {
        cfb.setOpQueueMaxBlockTime(opQueueMaxBlockTime);
    }
    if (obsPollInterval != DEFAULT_OBS_POLL_INTERVAL) {
        cfb.setObsPollInterval(obsPollInterval);
    }
    if (obsTimeout != DEFAULT_OBS_TIMEOUT) {
        cfb.setObsTimeout(obsTimeout);
    }
    return new CouchbaseClient(cfb.buildCouchbaseConnection(hosts, bucket, username, password));
}
Also used : CouchbaseConnectionFactoryBuilder(com.couchbase.client.CouchbaseConnectionFactoryBuilder) URI(java.net.URI) CouchbaseClient(com.couchbase.client.CouchbaseClient)

Example 7 with URI

use of java.net.URI in project camel by apache.

the class CouchbaseComponentTest method testCouchbaseDuplicateAdditionalHosts.

@Test
public void testCouchbaseDuplicateAdditionalHosts() throws Exception {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("additionalHosts", "127.0.0.1,localhost, localhost");
    String uri = "couchbase:http://localhost/bucket?param=true";
    String remaining = "http://localhost/bucket?param=true";
    CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params);
    URI[] endpointArray = endpoint.makeBootstrapURI();
    assertEquals(2, endpointArray.length);
    assertEquals(new URI("http://localhost:8091/pools"), endpointArray[0]);
    assertEquals(new URI("http://127.0.0.1:8091/pools"), endpointArray[1]);
}
Also used : HashMap(java.util.HashMap) URI(java.net.URI) Test(org.junit.Test)

Example 8 with URI

use of java.net.URI in project camel by apache.

the class CouchbaseComponentTest method testCouchbaseAdditionalHostsWithSpaces.

@Test
public void testCouchbaseAdditionalHostsWithSpaces() throws Exception {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("additionalHosts", " 127.0.0.1, example.com, another-host ");
    String uri = "couchbase:http://localhost/bucket?param=true";
    String remaining = "http://localhost/bucket?param=true";
    CouchbaseEndpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params);
    // System.out.print(endpoint.makeBootstrapURI()[0].toString() + " " +
    // endpoint.makeBootstrapURI().length + " ");
    URI[] endpointArray = endpoint.makeBootstrapURI();
    assertEquals(new URI("http://localhost:8091/pools"), endpointArray[0]);
    assertEquals(new URI("http://127.0.0.1:8091/pools"), endpointArray[1]);
    assertEquals(new URI("http://example.com:8091/pools"), endpointArray[2]);
    assertEquals(new URI("http://another-host:8091/pools"), endpointArray[3]);
    assertEquals(4, endpointArray.length);
}
Also used : HashMap(java.util.HashMap) URI(java.net.URI) Test(org.junit.Test)

Example 9 with URI

use of java.net.URI in project camel by apache.

the class SftpComponent method buildFileEndpoint.

@Override
protected GenericFileEndpoint<ChannelSftp.LsEntry> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
    // get the base uri part before the options as they can be non URI valid such as the expression using $ chars
    // and the URI constructor will regard $ as an illegal character and we dont want to enforce end users to
    // to escape the $ for the expression (file language)
    String baseUri = uri;
    if (uri.indexOf("?") != -1) {
        baseUri = uri.substring(0, uri.indexOf("?"));
    }
    // lets make sure we create a new configuration as each endpoint can
    // customize its own version
    SftpConfiguration config = new SftpConfiguration(new URI(baseUri));
    FtpUtils.ensureRelativeFtpDirectory(this, config);
    return new SftpEndpoint(uri, this, config);
}
Also used : URI(java.net.URI)

Example 10 with URI

use of java.net.URI in project camel by apache.

the class FtpComponent method buildFileEndpoint.

@Override
protected GenericFileEndpoint<FTPFile> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
    String baseUri = getBaseUri(uri);
    // lets make sure we create a new configuration as each endpoint can customize its own version
    // must pass on baseUri to the configuration (see above)
    FtpConfiguration config = new FtpConfiguration(new URI(baseUri));
    FtpUtils.ensureRelativeFtpDirectory(this, config);
    FtpEndpoint<FTPFile> answer = new FtpEndpoint<FTPFile>(uri, this, config);
    extractAndSetFtpClientConfigParameters(parameters, answer);
    extractAndSetFtpClientParameters(parameters, answer);
    return answer;
}
Also used : FTPFile(org.apache.commons.net.ftp.FTPFile) URI(java.net.URI)

Aggregations

URI (java.net.URI)5680 Test (org.junit.Test)1852 URISyntaxException (java.net.URISyntaxException)1016 IOException (java.io.IOException)749 File (java.io.File)531 HashMap (java.util.HashMap)458 ArrayList (java.util.ArrayList)452 Test (org.testng.annotations.Test)394 Configuration (org.apache.hadoop.conf.Configuration)321 Path (org.apache.hadoop.fs.Path)267 URL (java.net.URL)266 Map (java.util.Map)262 Response (javax.ws.rs.core.Response)218 List (java.util.List)184 InputStream (java.io.InputStream)154 HashSet (java.util.HashSet)136 FileSystem (org.apache.hadoop.fs.FileSystem)135 RequestContext (com.linkedin.r2.message.RequestContext)129 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)128 RestRequest (com.linkedin.r2.message.rest.RestRequest)112