Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,15 @@ private void run() throws Exception {
Hbase.Client client = new Hbase.Client(protocol);

byte[] t = bytes("demo_table");
ByteBuffer disabledTable = ByteBuffer.wrap(bytes("disabled_table"));

// Scan all tables, look for the demo table and delete it.
System.out.println("scanning tables...");

for (ByteBuffer name : client.getTableNames()) {
System.out.println(" found: " + ClientUtils.utf8(name.array()));

if (ClientUtils.utf8(name.array()).equals(ClientUtils.utf8(t))) {
if (ClientUtils.utf8(name.array()).equals(ClientUtils.utf8(t)) || name.equals(disabledTable)) {
if (client.isTableEnabled(name)) {
System.out.println(" disabling table: " + ClientUtils.utf8(name.array()));
client.disableTable(name);
Expand Down Expand Up @@ -159,6 +160,7 @@ private void run() throws Exception {

try {
client.createTable(ByteBuffer.wrap(t), columns);
client.createTable(disabledTable, columns);
} catch (AlreadyExists ae) {
System.out.println("WARN: " + ae.message);
}
Expand All @@ -171,6 +173,17 @@ private void run() throws Exception {
+ col2.maxVersions);
}

if (client.isTableEnabled(disabledTable)){
client.disableTable(disabledTable);
}
System.out.println("list tables with enabled statuses : ");
Map<ByteBuffer, Boolean> statusMap = client.getTableNamesWithIsTableEnabled();

for (Map.Entry<ByteBuffer, Boolean> entry : statusMap.entrySet()) {
System.out.println(" Table: " + ClientUtils.utf8(entry.getKey().array()) +
", is enabled: " + entry.getValue());
}

Map<ByteBuffer, ByteBuffer> dummyAttributes = null;
boolean writeToWal = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
Expand Down Expand Up @@ -203,6 +204,20 @@ public boolean isTableEnabled(ByteBuffer tableName) throws IOError {
}
}

@Override
public Map<ByteBuffer, Boolean> getTableNamesWithIsTableEnabled() throws IOError {
try {
HashMap<ByteBuffer, Boolean> tables = new HashMap<>();
for (ByteBuffer tableName: this.getTableNames()) {
tables.put(tableName, this.isTableEnabled(tableName));
}
return tables;
} catch (IOError e) {
LOG.warn(e.getMessage(), e);
throw getIOError(e);
}
}

// ThriftServerRunner.compact should be deprecated and replaced with methods specific to
// table and region.
@Override
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading