-
-
Save vessi/7585893 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
@path = '/opt/tmp_tables_list' | |
@remove_except_table = 'localPreferences' | |
@tables = [] | |
def fix_base | |
`echo "list" | hbase shell | grep -v #{@remove_except_table} > #{@path}` | |
sanitize_file @path | |
`cat #{@path} | awk '{print "disable \\"" $1 "\\""}' | hbase shell` | |
`cat #{@path} | awk '{print "drop \\"" $1 "\\""}' | hbase shell` | |
end | |
def sanitize_file(path) | |
File.open(path).each do |line| | |
tables_found = line.include? 'TABLE' | |
if tables_found and !line.include? ' seconds' and !line.include? 'TABLE' | |
@tables << line | |
end | |
end | |
write_tables | |
end | |
def write_tables | |
File.open(@path, 'w') do |file| | |
@tables.each do |string| | |
file.write(string) | |
end | |
end | |
end | |
fix_base |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment