Skip to content

Commit

Permalink
[#10131] Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Jul 21, 2023
1 parent 9025eb5 commit 6874c01
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.navercorp.pinpoint.hbase.schema.core;

import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptor;
Expand All @@ -34,7 +33,7 @@ public class HtdHbaseSchemaVerifier implements HbaseSchemaVerifier<TableDescript
/**
* Returns {@code true} if the schema definitions specified by {@code expectedSchemas} matches those
* specified by {@code actualSchemas}.
* <p>This implementation compares hbase schemas using {@link HTableDescriptor}. Note that the expected schema and
* <p>This implementation compares hbase schemas using {@link TableDescriptor}. Note that the expected schema and
* the actual schema do not have to match exactly - there may be additional tables and column families in the actual
* schema, and the method returns {@code true} as long as all tables and column families from the expected schema
* are present.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public boolean execute(HbaseAdminOperation hbaseAdminOperation) {
TableDescriptor currentHtd = hbaseAdminOperation.getTableDescriptor(tableName);

// Filter existing column families as column family modification is not supported.
// We could use modifyTable(HTableDescriptor) to add column families, but this deletes existing column families
// if they are not specified in HTableDescriptor and this may be dangerous.
// We could use modifyTable(TableDescriptor) to add column families, but this deletes existing column families
// if they are not specified in TableDescriptor and this may be dangerous.
// Instead, use addColumn.
boolean changesMade = false;
for (ColumnFamilyDescriptor cf : cfDescriptors) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@
import com.navercorp.pinpoint.common.hbase.HbaseOperations2;
import com.navercorp.pinpoint.common.hbase.ResultsExtractor;
import com.navercorp.pinpoint.common.hbase.RowMapper;
import com.navercorp.pinpoint.hbase.schema.dao.SchemaChangeLogDao;
import com.navercorp.pinpoint.hbase.schema.dao.hbase.codec.SchemaChangeLogCodec;
import com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog;
import com.navercorp.pinpoint.hbase.schema.dao.SchemaChangeLogDao;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.util.Bytes;

import java.util.ArrayList;
Expand Down Expand Up @@ -80,10 +82,11 @@ public boolean tableExists(String namespace) {
@Override
public boolean createTable(String namespace) {
TableName tableName = TableName.valueOf(namespace, TABLE_QUALIFIER);
HTableDescriptor htd = new HTableDescriptor(tableName);
HColumnDescriptor hcd = new HColumnDescriptor(COLUMN_FAMILY_NAME);
htd.addFamily(hcd);
return hbaseAdminOperation.createTableIfNotExists(htd);
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);
ColumnFamilyDescriptor cfDescriptor = ColumnFamilyDescriptorBuilder.of(COLUMN_FAMILY_NAME);
builder.setColumnFamily(cfDescriptor);
TableDescriptor tableDescriptor = builder.build();
return hbaseAdminOperation.createTableIfNotExists(tableDescriptor);
}

@Override
Expand Down

0 comments on commit 6874c01

Please sign in to comment.