You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/09/20 15:52:42 UTC

[GitHub] arifcse019 edited a comment on issue #1611: Bad Security Object Error After Moving Shards

arifcse019 edited a comment on issue #1611: Bad Security Object Error After Moving Shards
URL: https://github.com/apache/couchdb/issues/1611#issuecomment-423235481
 
 
   @wohali I am using the following two ruby scripts to move shards: first to move the shards to the new node, second one to update cluster metadata to not look for those shards in the old one.
   
   `
   def http_call (uri_string, username = '', password = '', data_json = {}, verb = 'Get')
       uri = URI.parse(uri_string)
       http = Net::HTTP.new(uri.host,uri.port)
   	if verb == 'Put'
   	  request = Net::HTTP::Put.new(uri.request_uri)
   	  request.body = data_json
   	else
   	  request = Net::HTTP::Get.new(uri.request_uri)
   	end
       request.basic_auth(username, password)
       response = http.request(request)
       response_json = JSON.parse response.body
   end
   
   all_dbs_response_json = http_call "http://127.0.0.1:5984/_all_dbs", admin_username, admin_password
   
   all_dbs_response_json.each do |db|
     print "\n#{db}\n"
     info_about_db_response_json = http_call "http://127.0.0.1:5986/_dbs/#{db}", admin_username, admin_password
   
    #swap by_node information
     if info_about_db_response_json["by_node"].has_key? node_out
        info_about_db_response_json["by_node"][node_in] = info_about_db_response_json["by_node"][node_out]
     else
        next
     end
   
     #replace outgoing nodes in each shard of by_range dictionary
     info_about_db_response_json["by_range"].each do |shard, nodes|
       if nodes.include? node_out and not nodes.include? node_in
         nodes.push(node_in)
       end
     end
   
     new_changelog = ["add", node_in]
     info_about_db_response_json["changelog"].push(new_changelog)
     info_about_db_response_json_after = http_call "http://127.0.0.1:5986/_dbs/#{db}", admin_username, admin_password, info_about_db_response_json.to_json, 'Put'
   end`
   
   `all_dbs_response_json.each do |db|
     print "\n#{db}\n"
     info_about_db_response_json = http_call "http://127.0.0.1:5986/_dbs/#{db}", admin_username, admin_password
   
    #swap by_node information
     if info_about_db_response_json["by_node"].has_key? node_out
        info_about_db_response_json["by_node"].delete(node_out)
     else
        next
     end
   
     #replace outgoing nodes in each shard of by_range dictionary
     info_about_db_response_json["by_range"].each do |shard, nodes|
       if nodes.include? node_out
         nodes.delete(node_out)
       end
     end
     new_changelog = ["delete", node_out]
     info_about_db_response_json["changelog"].push(new_changelog)
     info_about_db_response_json_after = http_call "http://127.0.0.1:5986/_dbs/#{db}", admin_username, admin_password, info_about_db_response_json.to_json, 'Put'
   end`
   
   `print hello`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services