use of org.apache.hadoop.hbase.client.Put in project hbase by apache.
the class MetaTableAccessor method updateTableState.
/**
* Update state of the table in meta.
* @param connection what we use for update
* @param state new state
* @throws IOException
*/
public static void updateTableState(Connection connection, TableState state) throws IOException {
Put put = makePutFromTableState(state);
putToMetaTable(connection, put);
LOG.info("Updated table " + state.getTableName() + " state to " + state.getState() + " in META");
}
use of org.apache.hadoop.hbase.client.Put in project hbase by apache.
the class MetaTableAccessor method updateReplicationPositions.
/**
* Updates the progress of pushing entries to peer cluster. Skip entry if value is -1.
* @param connection connection we're using
* @param peerId the peerId to push
* @param positions map that saving positions for each region
* @throws IOException
*/
public static void updateReplicationPositions(Connection connection, String peerId, Map<String, Long> positions) throws IOException {
List<Put> puts = new ArrayList<>(positions.entrySet().size());
for (Map.Entry<String, Long> entry : positions.entrySet()) {
long value = Math.abs(entry.getValue());
Put put = new Put(Bytes.toBytes(entry.getKey()));
put.addImmutable(HConstants.REPLICATION_POSITION_FAMILY, Bytes.toBytes(peerId), Bytes.toBytes(value));
puts.add(put);
}
getMetaHTable(connection).put(puts);
}
use of org.apache.hadoop.hbase.client.Put in project hbase by apache.
the class MetaTableAccessor method makePutFromTableState.
/**
* Construct PUT for given state
* @param state new state
*/
public static Put makePutFromTableState(TableState state) {
long time = EnvironmentEdgeManager.currentTime();
Put put = new Put(state.getTableName().getName(), time);
put.addColumn(getTableFamily(), getStateColumn(), state.convert().toByteArray());
return put;
}
use of org.apache.hadoop.hbase.client.Put in project hbase by apache.
the class MetaTableAccessor method addDaughter.
/**
* Adds a daughter region entry to meta.
* @param regionInfo the region to put
* @param sn the location of the region
* @param openSeqNum the latest sequence number obtained when the region was open
*/
public static void addDaughter(final Connection connection, final HRegionInfo regionInfo, final ServerName sn, final long openSeqNum) throws NotAllMetaRegionsOnlineException, IOException {
long now = EnvironmentEdgeManager.currentTime();
Put put = new Put(regionInfo.getRegionName(), now);
addRegionInfo(put, regionInfo);
if (sn != null) {
addLocation(put, sn, openSeqNum, -1, regionInfo.getReplicaId());
}
putToMetaTable(connection, put);
LOG.info("Added daughter " + regionInfo.getEncodedName() + (sn == null ? ", serverName=null" : ", serverName=" + sn.toString()));
}
use of org.apache.hadoop.hbase.client.Put in project hbase by apache.
the class TestHelloHBase method testDeleteRow.
@Test
public void testDeleteRow() throws IOException {
Admin admin = TEST_UTIL.getAdmin();
admin.createNamespace(NamespaceDescriptor.create(HelloHBase.MY_NAMESPACE_NAME).build());
Table table = TEST_UTIL.createTable(HelloHBase.MY_TABLE_NAME, HelloHBase.MY_COLUMN_FAMILY_NAME);
table.put(new Put(HelloHBase.MY_ROW_ID).addColumn(HelloHBase.MY_COLUMN_FAMILY_NAME, HelloHBase.MY_FIRST_COLUMN_QUALIFIER, Bytes.toBytes("xyz")));
HelloHBase.deleteRow(table);
Result row = table.get(new Get(HelloHBase.MY_ROW_ID));
assertEquals("#deleteRow failed to delete row.", true, row.isEmpty());
TEST_UTIL.deleteTable(HelloHBase.MY_TABLE_NAME);
admin.deleteNamespace(HelloHBase.MY_NAMESPACE_NAME);
}
Aggregations