brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Couchbase rebalance timeout fix a...
Date Thu, 09 Oct 2014 13:36:15 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/234#discussion_r18644861
  
    --- Diff: software/nosql/src/main/java/brooklyn/entity/nosql/couchbase/CouchbaseNodeSshDriver.java
---
    @@ -392,33 +415,76 @@ public Boolean call() throws Exception {
             ).apply(nodesResponse);
         }
         
    -    private boolean isNodeRebalancing(String nodeHostAndPort) throws URISyntaxException
{
    -        HttpToolResponse response = getAPIResponse("http://" + nodeHostAndPort + "/pools/nodes/rebalanceProgress");
    +    private boolean isNodeRebalancing(String nodeHostAndPort) {
    +        HttpToolResponse response = getApiResponse("http://" + nodeHostAndPort + "/pools/default/rebalanceProgress");
             if (response.getResponseCode() != 200) {
    -            throw new IllegalStateException("failed to rebalance cluster: " + response);
    +            throw new IllegalStateException("failed retrieving rebalance status: " +
response);
             }
             return !"none".equals(HttpValueFunctions.jsonContents("status", String.class).apply(response));
         }
         
    -    private HttpToolResponse getAPIResponse(String uri) throws URISyntaxException {
    -        URI apiUri = new URI(uri);
    -        Credentials credentials = new UsernamePasswordCredentials(getUsername(), getPassword());
    +    private HttpToolResponse getApiResponse(String uri) {
             return HttpTool.httpGet(HttpTool.httpClientBuilder()
                     // the uri is required by the HttpClientBuilder in order to set the AuthScope
of the credentials
    -                .uri(apiUri)
    -                .credentials(credentials)
    +                .uri(uri)
    +                .credentials(new UsernamePasswordCredentials(getUsername(), getPassword()))
                     .build(), 
    -            apiUri, 
    +            URI.create(uri), 
                 ImmutableMap.<String, String>of());
         }
         
         @Override
         public void serverAdd(String serverToAdd, String username, String password) {
    +        // TODO the POST is failing with SocketException: Connection reset
    +        // removing any data makes the problem go away; i suspect it is the combo of:
    +        // credentials, an explicit port, and content.
    +        // but i do not know how to fix it...
    +////      curl -u Administrator:password\
    +////      192.168.60.101:8091/controller/addNode \
    +////       -d "hostname=192.168.60.103&user=Administrator&password=password"
    +//        String baseUrl = Preconditions.checkNotNull(getEntity().getAttribute(CouchbaseNode.COUCHBASE_WEB_ADMIN_URL),
"web admin URL not available");
    +//        String uri = Urls.mergePaths(baseUrl, "controller/addNode");
    +//        URI uriU = URI.create(uri);
    +//        
    +//        HttpClient client = HttpTool.httpClientBuilder()
    +//            // the uri is required by the HttpClientBuilder in order to set the AuthScope
of the credentials
    +//            .uri(uriU.getScheme()+"://"+uriU.getHost())
    +//            .credentials(new UsernamePasswordCredentials(getUsername(), getPassword()))
    +//            .build();
    +//        client.getParams().setParameter("http.socket.timeout", new Integer(0)); 
    +//        client.getParams().setParameter("http.connection.stalecheck", new Boolean(true));
    +//        
    +//        HttpToolResponse response = HttpTool.httpPost(client, 
    +//            URI.create(uri), 
    +////            ImmutableMap.of(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_FORM_URLENCODED.getMimeType()),
    +//            // TODO do we need the above?
    +//            ImmutableMap.<String,String>of(),
    +//            
    +//            ("hostname="+Urls.encode(serverToAdd)+
    +//                "&user"+Urls.encode(username)+
    +//                "&password"+Urls.encode(password)).getBytes()
    +//            // the following two work
    +////            "".getBytes()
    +////            ImmutableMap.<String,String>of()
    +//            );
    +//        if (response.getResponseCode()==200) {
    +//            log.debug("Completed addNode call for "+serverToAdd+" via REST to "+getEntity()+":
"+response.getContentAsString());
    +//        } else {
    +//            log.warn("Failed addNode call for "+serverToAdd+" via REST to "+getEntity()+":
"+response.getResponseCode()+" / "+response.getContentAsString());
    +//            throw new IllegalStateException("Failed addNode call for "+serverToAdd+"
via REST to "+getEntity()+": "+response.getResponseCode()+" / "+response.getContentAsString());
    +//        }
    +
    +        // TODO would like a WebTasks API such as this:
    +//        DynamicTasks.queue(WebTasks.get(baseUrl).subpath("controller/addNode").credentials(getUsername(),
getPassword())
    --- End diff --
    
    If/when this is added, can we reuse names etc already used in `HttpFeed` and `HttpPollConfig`.
Or refactor that code to have methods that match whatever improvements are desired.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message