Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. (defn prepareKS!
  2. "returns the string for cqlsh to make the keysapace based on the number of nodes"
  3. [dcs bench]
  4. (let [dropComm (str "drop KEYSPACE IF EXISTS " bench ";")
  5. dcString (reduce (fn [oldDc newDc] (str oldDc ", 'dc_" newDc "':1")) "" dcs)
  6. finalComm (str dropComm " create KEYSPACE " bench " WITH replication = {'class': 'NetworkTopologyStrategy'" dcString "};")]
  7. finalComm
  8. ))
  9.  
  10. (defn prepareDB!
  11. "creating keyspace and tables"
  12. [node test tables bench]
  13. (when (= (str node) "n1")
  14. (info ">>> creating keyspace on: " (dns-resolve node))
  15. (c/exec* (str "/home/ubuntu/cassandra/bin/cqlsh " node " -e \"" (prepareKS! (:nodes test) bench) "\"" ))
  16. (info ">>> creating tablese on: " (dns-resolve node))
  17. (c/exec* (str "/home/ubuntu/cassandra/bin/cqlsh " (dns-resolve node) " -f /home/ubuntu/resource/ddl.cql" ))
  18. (info ">>> keyspace and tables intialized")
  19. (doseq [t tables]
  20. (do ; .csv solution:
  21. ;(info (str "Loading raw data in table: " t))
  22. ;(c/exec* (str "/home/ubuntu/cassandra/bin/cqlsh " (dns-resolve node) " -f /home/ubuntu/resource/load_" t ".cql" ))
  23.  
  24. ; snapshot based solution:
  25. (info (str "Copying snapshots for: " t))
  26. (c/exec* (str "/home/ubuntu/cassandra/bin/sstableloader -d " (dns-resolve node) " /home/ubuntu/" bench "/" t))
  27. ))
  28. ;(c/exec* (str "/home/ubuntu/cassandra/bin/cqlsh " (dns-resolve node) " -f /home/ubuntu/load.cql" ))
  29. (Thread/sleep 1000)
  30. (info (str ">>> initial SSTables loaded ")
  31. (info ">>> creating a java connection pool")
  32. )))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement