use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class HbaseSchemaServiceImpl method getSchemaStatus.
/**
* This implementation uses the executed schema change logs to compare against the specified {@code changeSets} to
* check the current schema status, regardless of how the actual schema looks like.
*/
// TODO May be a good idea to compare the actual tables against each of the change sets in the future.
@Override
public HbaseSchemaStatus getSchemaStatus(String namespace, List<ChangeSet> changeSets) {
if (CollectionUtils.isEmpty(changeSets)) {
throw new IllegalArgumentException("changeSets must not be empty");
}
if (!schemaChangeLogService.isAvailable(namespace)) {
return HbaseSchemaStatus.NONE;
}
List<SchemaChangeLog> schemaChangeLogs = schemaChangeLogService.getSchemaChangeLogs(namespace);
if (CollectionUtils.isEmpty(schemaChangeLogs)) {
return HbaseSchemaStatus.NONE;
}
List<ChangeSet> unexecutedChangeSets;
ChangeSetManager changeSetManager = new ChangeSetManager(changeSets);
try {
unexecutedChangeSets = changeSetManager.filterExecutedChangeSets(schemaChangeLogs);
} catch (IllegalArgumentException e) {
logger.error("[{}] Invalid hbase schema, cause : {}", namespace, e.getMessage());
return HbaseSchemaStatus.INVALID;
}
if (CollectionUtils.isEmpty(unexecutedChangeSets)) {
return HbaseSchemaStatus.VALID;
}
return HbaseSchemaStatus.VALID_OUT_OF_DATE;
}
use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class SchemaChangeLogServiceImpl method recordChangeSet.
private SchemaChangeLog recordChangeSet(String namespace, long executionTimestamp, int executionOrder, ChangeSet changeSet) {
CheckSum checkSum = CheckSum.compute(CheckSum.getCurrentVersion(), changeSet.getValue());
SchemaChangeLog schemaChangeLog = new SchemaChangeLog.Builder().id(changeSet.getId()).execTimestamp(executionTimestamp).execOrder(executionOrder).checkSum(checkSum).value(changeSet.getValue()).build();
schemaChangeLogDao.insertChangeLog(namespace, schemaChangeLog);
return schemaChangeLog;
}
use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class SchemaChangeLogServiceImpl method recordChangeSets.
@Override
public List<SchemaChangeLog> recordChangeSets(String namespace, int executionOrder, List<ChangeSet> changeSets) {
if (CollectionUtils.isEmpty(changeSets)) {
return Collections.emptyList();
}
int startingOrder = executionOrder;
long executionTimestamp = System.currentTimeMillis();
List<SchemaChangeLog> schemaChangeLogs = new ArrayList<>();
for (ChangeSet changeSet : changeSets) {
SchemaChangeLog schemaChangeLog = recordChangeSet(namespace, executionTimestamp, startingOrder, changeSet);
schemaChangeLogs.add(schemaChangeLog);
startingOrder++;
}
return schemaChangeLogs;
}
use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class PrintSchemaChangeLogTask method run.
@Override
public void run(List<String> arguments) {
if (CollectionUtils.isEmpty(arguments)) {
List<SchemaChangeLog> schemaChangeLogs = hbaseSchemaService.getChangeLogs(namespace);
if (CollectionUtils.isEmpty(schemaChangeLogs)) {
logger.info("No schema change logs found.");
} else {
for (SchemaChangeLog schemaChangeLog : schemaChangeLogs) {
printDetailedSchemaChangeLog(schemaChangeLog);
}
}
} else {
String changeSetId = arguments.get(0);
SchemaChangeLog schemaChangeLog = hbaseSchemaService.getChangeLog(namespace, changeSetId);
if (schemaChangeLog == null) {
logger.info("No schema change log found with id : {}", changeSetId);
} else {
printDetailedSchemaChangeLog(schemaChangeLog);
}
}
}
Aggregations