Fix mapping update bug in H2, MySQL, TiDB storage (#1999)

* Service inventory mapping  doesn't update right.

* Remove codes.
This commit is contained in:
吴晟 Wu Sheng 2018-12-04 16:52:46 +08:00 committed by GitHub
parent fc79182c31
commit bd879fd2d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -74,7 +74,7 @@ public class H2SQLExecutor {
protected StorageData toStorageData(ResultSet rs, String modelName,
StorageBuilder storageBuilder) throws SQLException {
while (rs.next()) {
if (rs.next()) {
Map data = new HashMap();
List<ModelColumn> columns = TableMetaInfo.get(modelName).getColumns();
for (ModelColumn column : columns) {

View File

@ -19,13 +19,17 @@
package org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao;
import java.io.IOException;
import java.sql.*;
import java.util.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.skywalking.oap.server.core.register.ServiceInventory;
import org.apache.skywalking.oap.server.core.storage.cache.IServiceInventoryCacheDAO;
import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
import org.apache.skywalking.oap.server.library.util.BooleanUtils;
import org.slf4j.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author wusheng
@ -68,12 +72,14 @@ public class H2ServiceInventoryCacheDAO extends H2SQLExecutor implements IServic
try (Connection connection = h2Client.getConnection()) {
try (ResultSet resultSet = h2Client.executeQuery(connection, sql.toString(), BooleanUtils.TRUE, System.currentTimeMillis() - 30 * 60 * 1000)) {
while (resultSet.next()) {
ServiceInventory serviceInventory = (ServiceInventory)toStorageData(resultSet, ServiceInventory.MODEL_NAME, new ServiceInventory.Builder());
ServiceInventory serviceInventory;
do {
serviceInventory = (ServiceInventory)toStorageData(resultSet, ServiceInventory.MODEL_NAME, new ServiceInventory.Builder());
if (serviceInventory != null) {
serviceInventories.add(serviceInventory);
}
}
while (serviceInventory != null);
}
} catch (SQLException e) {
throw new IOException(e);