Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[#637] [Backport] Change qualitifier name in metadata table #665

Merged
merged 1 commit into from
Jun 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -34,6 +34,7 @@

/**
* @author emeroad
* @author minwoo.jung
*/
@Repository
public class HbaseApiMetaDataDao implements ApiMetaDataDao {
Expand Down Expand Up @@ -68,7 +69,7 @@ public void insert(TApiMetaData apiMetaData) {
buffer.put(-1);
}
final byte[] apiMetaDataBytes = buffer.getBuffer();
put.addColumn(HBaseTables.API_METADATA_CF_API, apiMetaDataBytes, null);
put.addColumn(HBaseTables.API_METADATA_CF_API, HBaseTables.API_METADATA_CF_API_QUALI_SIGNATURE, apiMetaDataBytes);

hbaseTemplate.put(HBaseTables.API_METADATA, put);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* @author minwoo.jung
*/
//@Repository
@Deprecated
public class HbaseSqlMetaDataCompatibility implements SqlMetaDataDao {

private final Logger logger = LoggerFactory.getLogger(this.getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

/**
* @author emeroad
* @author minwoo.jung
*/
//@Repository
public class HbaseSqlMetaDataDao implements SqlMetaDataDao {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@

/**
* @author emeroad
* @author minwoo.jung
*/
//@Repository
@Deprecated
public class HbaseSqlMetaDataPastVersionDao implements SqlMetaDataDao {

private final Logger logger = LoggerFactory.getLogger(this.getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

/**
* @author emeroad
* @author minwoo.jung
*/
@Repository
public class HbaseStringMetaDataDao implements StringMetaDataDao {
Expand Down Expand Up @@ -62,8 +63,7 @@ public void insert(TStringMetaData stringMetaData) {
Put put = new Put(rowKey);
String stringValue = stringMetaData.getStringValue();
byte[] sqlBytes = Bytes.toBytes(stringValue);
// added sqlBytes into qualifier intentionally not to conflict hashcode
put.addColumn(HBaseTables.STRING_METADATA_CF_STR, sqlBytes, null);
put.addColumn(HBaseTables.STRING_METADATA_CF_STR, HBaseTables.STRING_METADATA_CF_STR_QUALI_STRING, sqlBytes);

hbaseTemplate.put(HBaseTables.STRING_METADATA, put);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ public final class HBaseTables {

public static final String STRING_METADATA = "StringMetaData";
public static final byte[] STRING_METADATA_CF_STR = Bytes.toBytes("Str");
public static final byte[] STRING_METADATA_CF_STR_QUALI_STRING = Bytes.toBytes("P_string");

public static final String API_METADATA = "ApiMetaData";
public static final byte[] API_METADATA_CF_API = Bytes.toBytes("Api");
public static final byte[] API_METADATA_CF_API_QUALI_SIGNATURE = Bytes.toBytes("P_api_signature");

public static final String MAP_STATISTICS_CALLER = "ApplicationMapStatisticsCaller";
public static final byte[] MAP_STATISTICS_CALLER_CF_COUNTER = Bytes.toBytes("C");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* 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.web.dao.hbase;

import java.util.ArrayList;
Expand All @@ -12,6 +27,10 @@
import com.navercorp.pinpoint.common.hbase.HBaseTables;
import com.navercorp.pinpoint.web.dao.SqlMetaDataDao;

/**
* @author minwoo.jung
*/
@Deprecated
public class HbaseSqlMetaDataCompatibility implements SqlMetaDataDao {

private final Logger logger = LoggerFactory.getLogger(this.getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* @author minwoo.jung
*/
//@Repository
@Deprecated
public class HbaseSqlMetaDataPastVersionDao implements SqlMetaDataDao {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
import com.navercorp.pinpoint.common.bo.ApiMetaDataBo;
import com.navercorp.pinpoint.common.buffer.Buffer;
import com.navercorp.pinpoint.common.buffer.FixedBuffer;
import com.navercorp.pinpoint.common.hbase.HBaseTables;
import com.sematext.hbase.wd.RowKeyDistributorByHashPrefix;

import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -37,6 +39,7 @@

/**
* @author emeroad
* @author minwoo.jung
*/
@Component
public class ApiMetaDataMapper implements RowMapper<List<ApiMetaDataBo>> {
Expand All @@ -46,6 +49,8 @@ public class ApiMetaDataMapper implements RowMapper<List<ApiMetaDataBo>> {
@Autowired
@Qualifier("metadataRowKeyDistributor")
private RowKeyDistributorByHashPrefix rowKeyDistributorByHashPrefix;

private final static String API_METADATA_CF_API_QUALI_SIGNATURE = Bytes.toString(HBaseTables.API_METADATA_CF_API_QUALI_SIGNATURE);

@Override
public List<ApiMetaDataBo> mapRow(Result result, int rowNum) throws Exception {
Expand All @@ -60,7 +65,15 @@ public List<ApiMetaDataBo> mapRow(Result result, int rowNum) throws Exception {
apiMetaDataBo.readRowKey(rowKey);

byte[] qualifier = CellUtil.cloneQualifier(cell);
Buffer buffer = new FixedBuffer(qualifier);
byte[] value = null;

if (API_METADATA_CF_API_QUALI_SIGNATURE.equals(Bytes.toString(qualifier))) {
value = CellUtil.cloneValue(cell);
} else {
value = qualifier;
}

Buffer buffer = new FixedBuffer(value);
String apiInfo = buffer.readPrefixedString();
int lineNumber = buffer.readInt();
apiMetaDataBo.setApiInfo(apiInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.navercorp.pinpoint.web.mapper;

import com.navercorp.pinpoint.common.bo.StringMetaDataBo;
import com.navercorp.pinpoint.common.hbase.HBaseTables;
import com.sematext.hbase.wd.RowKeyDistributorByHashPrefix;

import org.apache.hadoop.hbase.Cell;
Expand All @@ -40,7 +41,9 @@ public class StringMetaDataMapper implements RowMapper<List<StringMetaDataBo>> {
@Autowired
@Qualifier("metadataRowKeyDistributor")
private RowKeyDistributorByHashPrefix rowKeyDistributorByHashPrefix;


private final static String STRING_METADATA_CF_STR_QUALI_STRING = Bytes.toString(HBaseTables.STRING_METADATA_CF_STR_QUALI_STRING);

@Override
public List<StringMetaDataBo> mapRow(Result result, int rowNum) throws Exception {
if (result.isEmpty()) {
Expand All @@ -54,6 +57,11 @@ public List<StringMetaDataBo> mapRow(Result result, int rowNum) throws Exception
StringMetaDataBo sqlMetaDataBo = new StringMetaDataBo();
sqlMetaDataBo.readRowKey(rowKey);
String stringValue = Bytes.toString(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength());

if (STRING_METADATA_CF_STR_QUALI_STRING.equals(stringValue)) {
stringValue = Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
}

sqlMetaDataBo.setStringValue(stringValue);
stringMetaDataList.add(sqlMetaDataBo);
}
Expand Down