-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #580 from minwoo-jung/1.1.x-issue-572
[#572] [Backport] increase dispersion of row key for SqlMetaData table
- Loading branch information
Showing
20 changed files
with
475 additions
and
87 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
...c/main/java/com/navercorp/pinpoint/collector/dao/hbase/HbaseSqlMetaDataCompatibility.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright 2014 NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.pinpoint.collector.dao.hbase; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import com.navercorp.pinpoint.collector.dao.SqlMetaDataDao; | ||
import com.navercorp.pinpoint.common.hbase.HBaseAdminTemplate; | ||
import com.navercorp.pinpoint.common.hbase.HBaseTables; | ||
import com.navercorp.pinpoint.thrift.dto.TSqlMetaData; | ||
|
||
/** | ||
* @author minwoo.jung | ||
*/ | ||
//@Repository | ||
public class HbaseSqlMetaDataCompatibility implements SqlMetaDataDao { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
|
||
private final boolean SQL_METADATA_VER2_EXISTED; | ||
private final boolean SQL_METADATA_EXISTED; | ||
|
||
@Autowired | ||
private SqlMetaDataDao hbaseSqlMetaDataPastVersionDao; | ||
|
||
@Autowired | ||
private SqlMetaDataDao hbaseSqlMetaDataDao; | ||
|
||
@Autowired | ||
public HbaseSqlMetaDataCompatibility(HBaseAdminTemplate hBaseAdminTemplate) { | ||
SQL_METADATA_VER2_EXISTED = hBaseAdminTemplate.tableExists(HBaseTables.SQL_METADATA_VER2); | ||
|
||
if (SQL_METADATA_VER2_EXISTED == false) { | ||
logger.warn("Please create 'SqlMetaData_Ver2' table."); | ||
} | ||
|
||
SQL_METADATA_EXISTED = hBaseAdminTemplate.tableExists(HBaseTables.SQL_METADATA); | ||
|
||
if (SQL_METADATA_EXISTED == true) { | ||
logger.warn("SqlMetaData table exists. Recommend that only use SqlMetaData_Ver2 table."); | ||
} | ||
|
||
if(SQL_METADATA_EXISTED == false && SQL_METADATA_VER2_EXISTED == false) { | ||
throw new RuntimeException("Please check for sqlMetaData_ver2 table in HBase. You Should create 'SqlMetaData_Ver2' table."); | ||
} | ||
} | ||
|
||
@Override | ||
public void insert(TSqlMetaData sqlMetaData) { | ||
if (SQL_METADATA_VER2_EXISTED) { | ||
hbaseSqlMetaDataDao.insert(sqlMetaData); | ||
return; | ||
} | ||
|
||
if (SQL_METADATA_EXISTED) { | ||
hbaseSqlMetaDataPastVersionDao.insert(sqlMetaData); | ||
} | ||
} | ||
|
||
public void setHbaseSqlMetaDataPastVersionDao(SqlMetaDataDao hbaseSqlMetaDataPastVersionDao) { | ||
this.hbaseSqlMetaDataPastVersionDao = hbaseSqlMetaDataPastVersionDao; | ||
} | ||
|
||
public void setHbaseSqlMetaDataDao(SqlMetaDataDao hbaseSqlMetaDataDao) { | ||
this.hbaseSqlMetaDataDao = hbaseSqlMetaDataDao; | ||
} | ||
} |
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
75 changes: 75 additions & 0 deletions
75
.../main/java/com/navercorp/pinpoint/collector/dao/hbase/HbaseSqlMetaDataPastVersionDao.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright 2014 NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.pinpoint.collector.dao.hbase; | ||
|
||
import com.navercorp.pinpoint.collector.dao.SqlMetaDataDao; | ||
import com.navercorp.pinpoint.common.bo.SqlMetaDataBo; | ||
import com.navercorp.pinpoint.common.hbase.HBaseTables; | ||
import com.navercorp.pinpoint.common.hbase.HbaseOperations2; | ||
import com.navercorp.pinpoint.thrift.dto.TSqlMetaData; | ||
import com.sematext.hbase.wd.RowKeyDistributorByHashPrefix; | ||
|
||
import org.apache.hadoop.hbase.client.Put; | ||
import org.apache.hadoop.hbase.util.Bytes; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Repository; | ||
|
||
/** | ||
* @author emeroad | ||
*/ | ||
//@Repository | ||
public class HbaseSqlMetaDataPastVersionDao implements SqlMetaDataDao { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
|
||
@Autowired | ||
private HbaseOperations2 hbaseTemplate; | ||
|
||
@Autowired | ||
@Qualifier("metadataRowKeyDistributor") | ||
private RowKeyDistributorByHashPrefix rowKeyDistributorByHashPrefix; | ||
|
||
@Override | ||
public void insert(TSqlMetaData sqlMetaData) { | ||
if (sqlMetaData == null) { | ||
throw new NullPointerException("sqlMetaData must not be null"); | ||
} | ||
if (logger.isDebugEnabled()) { | ||
logger.debug("insert:{}", sqlMetaData); | ||
} | ||
|
||
SqlMetaDataBo sqlMetaDataBo = new SqlMetaDataBo(sqlMetaData.getAgentId(), sqlMetaData.getAgentStartTime(), sqlMetaData.getSqlId()); | ||
final byte[] rowKey = getDistributedKey(sqlMetaDataBo.toRowKey()); | ||
|
||
|
||
Put put = new Put(rowKey); | ||
String sql = sqlMetaData.getSql(); | ||
byte[] sqlBytes = Bytes.toBytes(sql); | ||
|
||
// added sqlBytes into qualifier intentionally not to conflict hashcode | ||
put.addColumn(HBaseTables.SQL_METADATA_CF_SQL, sqlBytes, null); | ||
|
||
hbaseTemplate.put(HBaseTables.SQL_METADATA, put); | ||
} | ||
|
||
private byte[] getDistributedKey(byte[] rowKey) { | ||
return rowKeyDistributorByHashPrefix.getDistributedKey(rowKey); | ||
} | ||
} |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,47 @@ | ||
|
||
disable 'AgentInfo' | ||
disable 'AgentStat' | ||
disable 'ApplicationIndex' | ||
|
||
disable 'StringMetaData' | ||
disable 'SqlMetaData' | ||
disable 'ApiMetaData' | ||
|
||
disable 'ApplicationTraceIndex' | ||
disable 'Traces' | ||
|
||
disable 'ApplicationMapStatisticsCaller' | ||
disable 'ApplicationMapStatisticsCallee' | ||
disable 'ApplicationMapStatisticsSelf' | ||
|
||
disable 'ApplicationStatistics' | ||
disable 'HostApplicationMap' | ||
disable 'HostApplicationMap_Ver2' | ||
|
||
|
||
drop 'AgentInfo' | ||
drop 'AgentStat' | ||
drop 'ApplicationIndex' | ||
|
||
drop 'StringMetaData' | ||
drop 'SqlMetaData' | ||
drop 'ApiMetaData' | ||
|
||
drop 'ApplicationTraceIndex' | ||
drop 'Traces' | ||
|
||
drop 'ApplicationMapStatisticsCaller' | ||
drop 'ApplicationMapStatisticsCallee' | ||
drop 'ApplicationMapStatisticsSelf' | ||
|
||
drop 'ApplicationStatistics' | ||
drop 'HostApplicationMap' | ||
drop 'HostApplicationMap_Ver2' | ||
|
||
list | ||
|
||
|
||
disable 'AgentInfo' | ||
disable 'AgentStat' | ||
disable 'ApplicationIndex' | ||
|
||
disable 'StringMetaData' | ||
disable 'ApiMetaData' | ||
|
||
disable 'SqlMetaData' | ||
disable 'SqlMetaData_Ver2' | ||
|
||
disable 'ApplicationTraceIndex' | ||
disable 'Traces' | ||
|
||
disable 'ApplicationMapStatisticsCaller' | ||
disable 'ApplicationMapStatisticsCallee' | ||
disable 'ApplicationMapStatisticsSelf' | ||
|
||
disable 'ApplicationStatistics' | ||
disable 'HostApplicationMap' | ||
disable 'HostApplicationMap_Ver2' | ||
|
||
|
||
drop 'AgentInfo' | ||
drop 'AgentStat' | ||
drop 'ApplicationIndex' | ||
|
||
drop 'StringMetaData' | ||
drop 'ApiMetaData' | ||
|
||
drop 'SqlMetaData' | ||
drop 'SqlMetaData_Ver2' | ||
|
||
drop 'ApplicationTraceIndex' | ||
drop 'Traces' | ||
|
||
drop 'ApplicationMapStatisticsCaller' | ||
drop 'ApplicationMapStatisticsCallee' | ||
drop 'ApplicationMapStatisticsSelf' | ||
|
||
drop 'ApplicationStatistics' | ||
drop 'HostApplicationMap' | ||
drop 'HostApplicationMap_Ver2' | ||
|
||
list | ||
|
||
exit |
Oops, something went wrong.