提交 d42eb019 编写于 作者: P peng-yongsheng

Agent register test success by H2 storage.

上级 0c44b3a6
......@@ -39,12 +39,12 @@ public class SegmentPost {
serviceNameRegisterPost.send("json/servicename-register-consumer.json");
serviceNameRegisterPost.send("json/servicename-register-provider.json");
JsonElement provider = JsonFileReader.INSTANCE.read("json/dubbox-provider.json");
JsonElement consumer = JsonFileReader.INSTANCE.read("json/dubbox-consumer.json");
for (int i = 0; i < 1; i++) {
HttpClientTools.INSTANCE.post("http://localhost:12800/segments", provider.toString());
HttpClientTools.INSTANCE.post("http://localhost:12800/segments", consumer.toString());
}
// JsonElement provider = JsonFileReader.INSTANCE.read("json/dubbox-provider.json");
// JsonElement consumer = JsonFileReader.INSTANCE.read("json/dubbox-consumer.json");
//
// for (int i = 0; i < 1; i++) {
// HttpClientTools.INSTANCE.post("http://localhost:12800/segments", provider.toString());
// HttpClientTools.INSTANCE.post("http://localhost:12800/segments", consumer.toString());
// }
}
}
......@@ -155,81 +155,81 @@ public class StorageModule extends Module {
}
private void addPersistenceDAO(List<Class> classes) {
classes.add(ICpuSecondMetricPersistenceDAO.class);
classes.add(ICpuMinuteMetricPersistenceDAO.class);
classes.add(ICpuHourMetricPersistenceDAO.class);
classes.add(ICpuDayMetricPersistenceDAO.class);
classes.add(ICpuMonthMetricPersistenceDAO.class);
classes.add(IGCSecondMetricPersistenceDAO.class);
classes.add(IGCMinuteMetricPersistenceDAO.class);
classes.add(IGCHourMetricPersistenceDAO.class);
classes.add(IGCDayMetricPersistenceDAO.class);
classes.add(IGCMonthMetricPersistenceDAO.class);
classes.add(IMemorySecondMetricPersistenceDAO.class);
classes.add(IMemoryMinuteMetricPersistenceDAO.class);
classes.add(IMemoryHourMetricPersistenceDAO.class);
classes.add(IMemoryDayMetricPersistenceDAO.class);
classes.add(IMemoryMonthMetricPersistenceDAO.class);
classes.add(IMemoryPoolSecondMetricPersistenceDAO.class);
classes.add(IMemoryPoolMinuteMetricPersistenceDAO.class);
classes.add(IMemoryPoolHourMetricPersistenceDAO.class);
classes.add(IMemoryPoolDayMetricPersistenceDAO.class);
classes.add(IMemoryPoolMonthMetricPersistenceDAO.class);
classes.add(IApplicationComponentMinutePersistenceDAO.class);
classes.add(IApplicationComponentHourPersistenceDAO.class);
classes.add(IApplicationComponentDayPersistenceDAO.class);
classes.add(IApplicationComponentMonthPersistenceDAO.class);
classes.add(IApplicationMappingMinutePersistenceDAO.class);
classes.add(IApplicationMappingHourPersistenceDAO.class);
classes.add(IApplicationMappingDayPersistenceDAO.class);
classes.add(IApplicationMappingMonthPersistenceDAO.class);
classes.add(IInstanceMappingMinutePersistenceDAO.class);
classes.add(IInstanceMappingHourPersistenceDAO.class);
classes.add(IInstanceMappingDayPersistenceDAO.class);
classes.add(IInstanceMappingMonthPersistenceDAO.class);
classes.add(IGlobalTracePersistenceDAO.class);
classes.add(IApplicationMinuteMetricPersistenceDAO.class);
classes.add(IApplicationHourMetricPersistenceDAO.class);
classes.add(IApplicationDayMetricPersistenceDAO.class);
classes.add(IApplicationMonthMetricPersistenceDAO.class);
classes.add(IApplicationReferenceMinuteMetricPersistenceDAO.class);
classes.add(IApplicationReferenceHourMetricPersistenceDAO.class);
classes.add(IApplicationReferenceDayMetricPersistenceDAO.class);
classes.add(IApplicationReferenceMonthMetricPersistenceDAO.class);
classes.add(ISegmentCostPersistenceDAO.class);
classes.add(ISegmentPersistenceDAO.class);
classes.add(IServiceMinuteMetricPersistenceDAO.class);
classes.add(IServiceHourMetricPersistenceDAO.class);
classes.add(IServiceDayMetricPersistenceDAO.class);
classes.add(IServiceMonthMetricPersistenceDAO.class);
classes.add(IServiceReferenceMinuteMetricPersistenceDAO.class);
classes.add(IServiceReferenceHourMetricPersistenceDAO.class);
classes.add(IServiceReferenceDayMetricPersistenceDAO.class);
classes.add(IServiceReferenceMonthMetricPersistenceDAO.class);
classes.add(IInstanceMinuteMetricPersistenceDAO.class);
classes.add(IInstanceHourMetricPersistenceDAO.class);
classes.add(IInstanceDayMetricPersistenceDAO.class);
classes.add(IInstanceMonthMetricPersistenceDAO.class);
classes.add(IInstanceReferenceMinuteMetricPersistenceDAO.class);
classes.add(IInstanceReferenceHourMetricPersistenceDAO.class);
classes.add(IInstanceReferenceDayMetricPersistenceDAO.class);
classes.add(IInstanceReferenceMonthMetricPersistenceDAO.class);
classes.add(IInstanceHeartBeatPersistenceDAO.class);
// classes.add(ICpuSecondMetricPersistenceDAO.class);
// classes.add(ICpuMinuteMetricPersistenceDAO.class);
// classes.add(ICpuHourMetricPersistenceDAO.class);
// classes.add(ICpuDayMetricPersistenceDAO.class);
// classes.add(ICpuMonthMetricPersistenceDAO.class);
//
// classes.add(IGCSecondMetricPersistenceDAO.class);
// classes.add(IGCMinuteMetricPersistenceDAO.class);
// classes.add(IGCHourMetricPersistenceDAO.class);
// classes.add(IGCDayMetricPersistenceDAO.class);
// classes.add(IGCMonthMetricPersistenceDAO.class);
//
// classes.add(IMemorySecondMetricPersistenceDAO.class);
// classes.add(IMemoryMinuteMetricPersistenceDAO.class);
// classes.add(IMemoryHourMetricPersistenceDAO.class);
// classes.add(IMemoryDayMetricPersistenceDAO.class);
// classes.add(IMemoryMonthMetricPersistenceDAO.class);
//
// classes.add(IMemoryPoolSecondMetricPersistenceDAO.class);
// classes.add(IMemoryPoolMinuteMetricPersistenceDAO.class);
// classes.add(IMemoryPoolHourMetricPersistenceDAO.class);
// classes.add(IMemoryPoolDayMetricPersistenceDAO.class);
// classes.add(IMemoryPoolMonthMetricPersistenceDAO.class);
//
// classes.add(IApplicationComponentMinutePersistenceDAO.class);
// classes.add(IApplicationComponentHourPersistenceDAO.class);
// classes.add(IApplicationComponentDayPersistenceDAO.class);
// classes.add(IApplicationComponentMonthPersistenceDAO.class);
//
// classes.add(IApplicationMappingMinutePersistenceDAO.class);
// classes.add(IApplicationMappingHourPersistenceDAO.class);
// classes.add(IApplicationMappingDayPersistenceDAO.class);
// classes.add(IApplicationMappingMonthPersistenceDAO.class);
//
// classes.add(IInstanceMappingMinutePersistenceDAO.class);
// classes.add(IInstanceMappingHourPersistenceDAO.class);
// classes.add(IInstanceMappingDayPersistenceDAO.class);
// classes.add(IInstanceMappingMonthPersistenceDAO.class);
//
// classes.add(IGlobalTracePersistenceDAO.class);
//
// classes.add(IApplicationMinuteMetricPersistenceDAO.class);
// classes.add(IApplicationHourMetricPersistenceDAO.class);
// classes.add(IApplicationDayMetricPersistenceDAO.class);
// classes.add(IApplicationMonthMetricPersistenceDAO.class);
//
// classes.add(IApplicationReferenceMinuteMetricPersistenceDAO.class);
// classes.add(IApplicationReferenceHourMetricPersistenceDAO.class);
// classes.add(IApplicationReferenceDayMetricPersistenceDAO.class);
// classes.add(IApplicationReferenceMonthMetricPersistenceDAO.class);
//
// classes.add(ISegmentCostPersistenceDAO.class);
// classes.add(ISegmentPersistenceDAO.class);
//
// classes.add(IServiceMinuteMetricPersistenceDAO.class);
// classes.add(IServiceHourMetricPersistenceDAO.class);
// classes.add(IServiceDayMetricPersistenceDAO.class);
// classes.add(IServiceMonthMetricPersistenceDAO.class);
//
// classes.add(IServiceReferenceMinuteMetricPersistenceDAO.class);
// classes.add(IServiceReferenceHourMetricPersistenceDAO.class);
// classes.add(IServiceReferenceDayMetricPersistenceDAO.class);
// classes.add(IServiceReferenceMonthMetricPersistenceDAO.class);
//
// classes.add(IInstanceMinuteMetricPersistenceDAO.class);
// classes.add(IInstanceHourMetricPersistenceDAO.class);
// classes.add(IInstanceDayMetricPersistenceDAO.class);
// classes.add(IInstanceMonthMetricPersistenceDAO.class);
//
// classes.add(IInstanceReferenceMinuteMetricPersistenceDAO.class);
// classes.add(IInstanceReferenceHourMetricPersistenceDAO.class);
// classes.add(IInstanceReferenceDayMetricPersistenceDAO.class);
// classes.add(IInstanceReferenceMonthMetricPersistenceDAO.class);
//
// classes.add(IInstanceHeartBeatPersistenceDAO.class);
}
private void addUiDAO(List<Class> classes) {
......@@ -251,18 +251,18 @@ public class StorageModule extends Module {
}
private void addAlarmDAO(List<Class> classes) {
classes.add(IServiceReferenceAlarmPersistenceDAO.class);
classes.add(IServiceReferenceAlarmListPersistenceDAO.class);
classes.add(IInstanceReferenceAlarmPersistenceDAO.class);
classes.add(IInstanceReferenceAlarmListPersistenceDAO.class);
classes.add(IApplicationReferenceAlarmPersistenceDAO.class);
classes.add(IApplicationReferenceAlarmListPersistenceDAO.class);
classes.add(IServiceAlarmPersistenceDAO.class);
classes.add(IServiceAlarmListPersistenceDAO.class);
classes.add(IInstanceAlarmPersistenceDAO.class);
classes.add(IInstanceAlarmListPersistenceDAO.class);
classes.add(IApplicationAlarmPersistenceDAO.class);
classes.add(IApplicationAlarmListPersistenceDAO.class);
// classes.add(IServiceReferenceAlarmPersistenceDAO.class);
// classes.add(IServiceReferenceAlarmListPersistenceDAO.class);
// classes.add(IInstanceReferenceAlarmPersistenceDAO.class);
// classes.add(IInstanceReferenceAlarmListPersistenceDAO.class);
// classes.add(IApplicationReferenceAlarmPersistenceDAO.class);
// classes.add(IApplicationReferenceAlarmListPersistenceDAO.class);
//
// classes.add(IServiceAlarmPersistenceDAO.class);
// classes.add(IServiceAlarmListPersistenceDAO.class);
// classes.add(IInstanceAlarmPersistenceDAO.class);
// classes.add(IInstanceAlarmListPersistenceDAO.class);
// classes.add(IApplicationAlarmPersistenceDAO.class);
// classes.add(IApplicationAlarmListPersistenceDAO.class);
}
}
......@@ -207,10 +207,10 @@ import org.apache.skywalking.apm.collector.storage.es.dao.mpoolmp.MemoryPoolHour
import org.apache.skywalking.apm.collector.storage.es.dao.mpoolmp.MemoryPoolMinuteMetricEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.mpoolmp.MemoryPoolMonthMetricEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.mpoolmp.MemoryPoolSecondMetricEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.register.ApplicationEsRegisterDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.register.InstanceEsRegisterDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.register.ApplicationRegisterEsDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.register.InstanceRegisterEsDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.register.NetworkAddressRegisterEsDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.register.ServiceNameEsRegisterDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.register.ServiceNameRegisterEsDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.smp.ServiceDayMetricEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.smp.ServiceHourMetricEsPersistenceDAO;
import org.apache.skywalking.apm.collector.storage.es.dao.smp.ServiceMinuteMetricEsPersistenceDAO;
......@@ -303,9 +303,9 @@ public class StorageModuleEsProvider extends ModuleProvider {
private void registerRegisterDAO() throws ServiceNotProvidedException {
this.registerServiceImplementation(INetworkAddressRegisterDAO.class, new NetworkAddressRegisterEsDAO(elasticSearchClient));
this.registerServiceImplementation(IApplicationRegisterDAO.class, new ApplicationEsRegisterDAO(elasticSearchClient));
this.registerServiceImplementation(IInstanceRegisterDAO.class, new InstanceEsRegisterDAO(elasticSearchClient));
this.registerServiceImplementation(IServiceNameRegisterDAO.class, new ServiceNameEsRegisterDAO(elasticSearchClient));
this.registerServiceImplementation(IApplicationRegisterDAO.class, new ApplicationRegisterEsDAO(elasticSearchClient));
this.registerServiceImplementation(IInstanceRegisterDAO.class, new InstanceRegisterEsDAO(elasticSearchClient));
this.registerServiceImplementation(IServiceNameRegisterDAO.class, new ServiceNameRegisterEsDAO(elasticSearchClient));
}
private void registerPersistenceDAO() throws ServiceNotProvidedException {
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.collector.storage.es.dao.register;
import java.util.HashMap;
import java.util.Map;
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegisterDAO;
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
import org.apache.skywalking.apm.collector.storage.table.register.Application;
import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.support.WriteRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng
*/
public class ApplicationRegisterEsDAO extends EsDAO implements IApplicationRegisterDAO {
private final Logger logger = LoggerFactory.getLogger(ApplicationRegisterEsDAO.class);
public ApplicationRegisterEsDAO(ElasticSearchClient client) {
super(client);
}
@Override public int getMaxApplicationId() {
return getMaxId(ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_ID);
}
@Override public int getMinApplicationId() {
return getMinId(ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_ID);
}
@Override public void save(Application application) {
logger.debug("save application register info, application getId: {}, application code: {}", application.getId(), application.getApplicationCode());
ElasticSearchClient client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(ApplicationTable.COLUMN_APPLICATION_CODE, application.getApplicationCode());
source.put(ApplicationTable.COLUMN_APPLICATION_ID, application.getApplicationId());
source.put(ApplicationTable.COLUMN_ADDRESS_ID, application.getAddressId());
source.put(ApplicationTable.COLUMN_IS_ADDRESS, application.getIsAddress());
IndexResponse response = client.prepareIndex(ApplicationTable.TABLE, application.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
logger.debug("save application register info, application getId: {}, application code: {}, status: {}", application.getApplicationId(), application.getApplicationCode(), response.status().name());
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.collector.storage.es.dao.register;
import java.util.HashMap;
import java.util.Map;
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO;
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
import org.apache.skywalking.apm.collector.storage.table.register.Instance;
import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.action.update.UpdateRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng
*/
public class InstanceRegisterEsDAO extends EsDAO implements IInstanceRegisterDAO {
private final Logger logger = LoggerFactory.getLogger(InstanceRegisterEsDAO.class);
public InstanceRegisterEsDAO(ElasticSearchClient client) {
super(client);
}
@Override public int getMaxInstanceId() {
return getMaxId(InstanceTable.TABLE, InstanceTable.COLUMN_INSTANCE_ID);
}
@Override public int getMinInstanceId() {
return getMinId(InstanceTable.TABLE, InstanceTable.COLUMN_INSTANCE_ID);
}
@Override public void save(Instance instance) {
logger.debug("save instance register info, application getId: {}, agentUUID: {}", instance.getApplicationId(), instance.getAgentUUID());
ElasticSearchClient client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(InstanceTable.COLUMN_INSTANCE_ID, instance.getInstanceId());
source.put(InstanceTable.COLUMN_APPLICATION_ID, instance.getApplicationId());
source.put(InstanceTable.COLUMN_AGENT_UUID, instance.getAgentUUID());
source.put(InstanceTable.COLUMN_REGISTER_TIME, instance.getRegisterTime());
source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, instance.getHeartBeatTime());
source.put(InstanceTable.COLUMN_OS_INFO, instance.getOsInfo());
source.put(InstanceTable.COLUMN_ADDRESS_ID, instance.getAddressId());
source.put(InstanceTable.COLUMN_IS_ADDRESS, instance.getIsAddress());
IndexResponse response = client.prepareIndex(InstanceTable.TABLE, instance.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
logger.debug("save instance register info, application getId: {}, agentUUID: {}, status: {}", instance.getApplicationId(), instance.getAgentUUID(), response.status().name());
}
@Override public void updateHeartbeatTime(int instanceId, long heartbeatTime) {
ElasticSearchClient client = getClient();
UpdateRequest updateRequest = new UpdateRequest();
updateRequest.index(InstanceTable.TABLE);
updateRequest.type(InstanceTable.TABLE_TYPE);
updateRequest.id(String.valueOf(instanceId));
updateRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
Map<String, Object> source = new HashMap<>();
source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, heartbeatTime);
updateRequest.doc(source);
client.update(updateRequest);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.collector.storage.es.dao.register;
import java.util.HashMap;
import java.util.Map;
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.apm.collector.storage.dao.register.IServiceNameRegisterDAO;
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
import org.apache.skywalking.apm.collector.storage.table.register.ServiceName;
import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.support.WriteRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng
*/
public class ServiceNameRegisterEsDAO extends EsDAO implements IServiceNameRegisterDAO {
private final Logger logger = LoggerFactory.getLogger(ServiceNameRegisterEsDAO.class);
public ServiceNameRegisterEsDAO(ElasticSearchClient client) {
super(client);
}
@Override public int getMaxServiceId() {
return getMaxId(ServiceNameTable.TABLE, ServiceNameTable.COLUMN_SERVICE_ID);
}
@Override public int getMinServiceId() {
return getMinId(ServiceNameTable.TABLE, ServiceNameTable.COLUMN_SERVICE_ID);
}
@Override public void save(ServiceName serviceName) {
logger.debug("save service name register info, application getId: {}, service name: {}", serviceName.getId(), serviceName.getServiceName());
ElasticSearchClient client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(ServiceNameTable.COLUMN_SERVICE_ID, serviceName.getServiceId());
source.put(ServiceNameTable.COLUMN_APPLICATION_ID, serviceName.getApplicationId());
source.put(ServiceNameTable.COLUMN_SERVICE_NAME, serviceName.getServiceName());
IndexResponse response = client.prepareIndex(ServiceNameTable.TABLE, serviceName.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
logger.debug("save service name register info, application getId: {}, service name: {}, status: {}", serviceName.getId(), serviceName.getServiceName(), response.status().name());
}
}
......@@ -84,7 +84,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationAlarmListH2
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2MinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationH2CacheDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationH2RegisterDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.register.ApplicationRegisterH2DAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2MinutePersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationMinuteMetricH2PersistenceDAO;
......@@ -101,7 +101,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceAlarmH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceAlarmListH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceH2CacheDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceH2RegisterDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.register.InstanceRegisterH2DAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceHeartBeatH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMappingH2MinutePersistenceDAO;
......@@ -115,7 +115,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.MemoryPoolMetricH2UIDA
import org.apache.skywalking.apm.collector.storage.h2.dao.MemoryPoolSecondMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.MemorySecondMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.NetworkAddressH2CacheDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.NetworkAddressRegisterH2DAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.register.NetworkAddressRegisterH2DAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentCostH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentCostH2UIDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentH2PersistenceDAO;
......@@ -124,7 +124,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceAlarmH2Persiste
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceAlarmListH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceMinuteMetricH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceNameH2CacheDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceNameH2RegisterDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.register.ServiceNameRegisterH2DAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceReferenceAlarmH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceReferenceAlarmListH2PersistenceDAO;
import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceReferenceH2UIDAO;
......@@ -195,31 +195,31 @@ public class StorageModuleH2Provider extends ModuleProvider {
private void registerRegisterDAO() throws ServiceNotProvidedException {
this.registerServiceImplementation(INetworkAddressRegisterDAO.class, new NetworkAddressRegisterH2DAO(h2Client));
this.registerServiceImplementation(IApplicationRegisterDAO.class, new ApplicationH2RegisterDAO(h2Client));
this.registerServiceImplementation(IInstanceRegisterDAO.class, new InstanceH2RegisterDAO(h2Client));
this.registerServiceImplementation(IServiceNameRegisterDAO.class, new ServiceNameH2RegisterDAO(h2Client));
this.registerServiceImplementation(IApplicationRegisterDAO.class, new ApplicationRegisterH2DAO(h2Client));
this.registerServiceImplementation(IInstanceRegisterDAO.class, new InstanceRegisterH2DAO(h2Client));
this.registerServiceImplementation(IServiceNameRegisterDAO.class, new ServiceNameRegisterH2DAO(h2Client));
}
private void registerPersistenceDAO() throws ServiceNotProvidedException {
this.registerServiceImplementation(ICpuSecondMetricPersistenceDAO.class, new CpuSecondMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IGCSecondMetricPersistenceDAO.class, new GCSecondMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IMemorySecondMetricPersistenceDAO.class, new MemorySecondMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IMemoryPoolSecondMetricPersistenceDAO.class, new MemoryPoolSecondMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IGlobalTracePersistenceDAO.class, new GlobalTraceH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IApplicationComponentMinutePersistenceDAO.class, new ApplicationComponentH2MinutePersistenceDAO(h2Client));
this.registerServiceImplementation(IApplicationMappingMinutePersistenceDAO.class, new ApplicationMappingH2MinutePersistenceDAO(h2Client));
this.registerServiceImplementation(IApplicationMinuteMetricPersistenceDAO.class, new ApplicationMinuteMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IApplicationReferenceMinuteMetricPersistenceDAO.class, new ApplicationReferenceMinuteMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostH2PersistenceDAO(h2Client));
this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IServiceMinuteMetricPersistenceDAO.class, new ServiceMinuteMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IServiceReferenceMinuteMetricPersistenceDAO.class, new ServiceReferenceMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IInstanceMinuteMetricPersistenceDAO.class, new InstanceMinuteMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IInstanceReferenceMinuteMetricPersistenceDAO.class, new InstanceReferenceMetricH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IInstanceMappingMinutePersistenceDAO.class, new InstanceMappingH2MinutePersistenceDAO(h2Client));
this.registerServiceImplementation(IInstanceHeartBeatPersistenceDAO.class, new InstanceHeartBeatH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(ICpuSecondMetricPersistenceDAO.class, new CpuSecondMetricH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IGCSecondMetricPersistenceDAO.class, new GCSecondMetricH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IMemorySecondMetricPersistenceDAO.class, new MemorySecondMetricH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IMemoryPoolSecondMetricPersistenceDAO.class, new MemoryPoolSecondMetricH2PersistenceDAO(h2Client));
//
// this.registerServiceImplementation(IGlobalTracePersistenceDAO.class, new GlobalTraceH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IApplicationComponentMinutePersistenceDAO.class, new ApplicationComponentH2MinutePersistenceDAO(h2Client));
// this.registerServiceImplementation(IApplicationMappingMinutePersistenceDAO.class, new ApplicationMappingH2MinutePersistenceDAO(h2Client));
// this.registerServiceImplementation(IApplicationMinuteMetricPersistenceDAO.class, new ApplicationMinuteMetricH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IApplicationReferenceMinuteMetricPersistenceDAO.class, new ApplicationReferenceMinuteMetricH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IServiceMinuteMetricPersistenceDAO.class, new ServiceMinuteMetricH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IServiceReferenceMinuteMetricPersistenceDAO.class, new ServiceReferenceMetricH2PersistenceDAO(h2Client));
//
// this.registerServiceImplementation(IInstanceMinuteMetricPersistenceDAO.class, new InstanceMinuteMetricH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IInstanceReferenceMinuteMetricPersistenceDAO.class, new InstanceReferenceMetricH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IInstanceMappingMinutePersistenceDAO.class, new InstanceMappingH2MinutePersistenceDAO(h2Client));
// this.registerServiceImplementation(IInstanceHeartBeatPersistenceDAO.class, new InstanceHeartBeatH2PersistenceDAO(h2Client));
}
private void registerUiDAO() throws ServiceNotProvidedException {
......@@ -241,18 +241,18 @@ public class StorageModuleH2Provider extends ModuleProvider {
}
private void registerAlarmDAO() throws ServiceNotProvidedException {
this.registerServiceImplementation(IServiceReferenceAlarmPersistenceDAO.class, new ServiceReferenceAlarmH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IServiceReferenceAlarmListPersistenceDAO.class, new ServiceReferenceAlarmListH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IInstanceReferenceAlarmPersistenceDAO.class, new InstanceReferenceAlarmH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IInstanceReferenceAlarmListPersistenceDAO.class, new InstanceReferenceAlarmListH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IApplicationReferenceAlarmPersistenceDAO.class, new ApplicationReferenceAlarmH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IApplicationReferenceAlarmListPersistenceDAO.class, new ApplicationReferenceAlarmListH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IServiceAlarmPersistenceDAO.class, new ServiceAlarmH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IServiceAlarmListPersistenceDAO.class, new ServiceAlarmListH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IInstanceAlarmPersistenceDAO.class, new InstanceAlarmH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IInstanceAlarmListPersistenceDAO.class, new InstanceAlarmListH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IApplicationAlarmPersistenceDAO.class, new ApplicationAlarmH2PersistenceDAO(h2Client));
this.registerServiceImplementation(IApplicationAlarmListPersistenceDAO.class, new ApplicationAlarmListH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IServiceReferenceAlarmPersistenceDAO.class, new ServiceReferenceAlarmH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IServiceReferenceAlarmListPersistenceDAO.class, new ServiceReferenceAlarmListH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IInstanceReferenceAlarmPersistenceDAO.class, new InstanceReferenceAlarmH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IInstanceReferenceAlarmListPersistenceDAO.class, new InstanceReferenceAlarmListH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IApplicationReferenceAlarmPersistenceDAO.class, new ApplicationReferenceAlarmH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IApplicationReferenceAlarmListPersistenceDAO.class, new ApplicationReferenceAlarmListH2PersistenceDAO(h2Client));
//
// this.registerServiceImplementation(IServiceAlarmPersistenceDAO.class, new ServiceAlarmH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IServiceAlarmListPersistenceDAO.class, new ServiceAlarmListH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IInstanceAlarmPersistenceDAO.class, new InstanceAlarmH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IInstanceAlarmListPersistenceDAO.class, new InstanceAlarmListH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IApplicationAlarmPersistenceDAO.class, new ApplicationAlarmH2PersistenceDAO(h2Client));
// this.registerServiceImplementation(IApplicationAlarmListPersistenceDAO.class, new ApplicationAlarmListH2PersistenceDAO(h2Client));
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.collector.storage.h2.dao.register;
import java.util.HashMap;
import java.util.Map;
import org.apache.skywalking.apm.collector.client.h2.H2Client;
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegisterDAO;
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
import org.apache.skywalking.apm.collector.storage.table.register.Application;
import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng, clevertension
*/
public class ApplicationRegisterH2DAO extends H2DAO implements IApplicationRegisterDAO {
private final Logger logger = LoggerFactory.getLogger(ApplicationRegisterH2DAO.class);
public ApplicationRegisterH2DAO(H2Client client) {
super(client);
}
@Override
public int getMaxApplicationId() {
return getMaxId(ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_ID);
}
@Override
public int getMinApplicationId() {
return getMinId(ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_ID);
}
@Override
public void save(Application application) {
H2Client client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(ApplicationTable.COLUMN_ID, application.getId());
source.put(ApplicationTable.COLUMN_APPLICATION_CODE, application.getApplicationCode());
source.put(ApplicationTable.COLUMN_APPLICATION_ID, application.getApplicationId());
source.put(ApplicationTable.COLUMN_ADDRESS_ID, application.getAddressId());
source.put(ApplicationTable.COLUMN_IS_ADDRESS, application.getIsAddress());
String sql = SqlBuilder.buildBatchInsertSql(ApplicationTable.TABLE, source.keySet());
Object[] params = source.values().toArray(new Object[0]);
try {
client.execute(sql, params);
} catch (H2ClientException e) {
logger.error(e.getMessage(), e);
}
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.collector.storage.h2.dao.register;
import java.util.HashMap;
import java.util.Map;
import org.apache.skywalking.apm.collector.client.h2.H2Client;
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO;
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
import org.apache.skywalking.apm.collector.storage.table.register.Instance;
import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng, clevertension
*/
public class InstanceRegisterH2DAO extends H2DAO implements IInstanceRegisterDAO {
private final Logger logger = LoggerFactory.getLogger(InstanceRegisterH2DAO.class);
public InstanceRegisterH2DAO(H2Client client) {
super(client);
}
private static final String UPDATE_HEARTBEAT_TIME_SQL = "update {0} set {1} = ? where {2} = ?";
@Override public int getMaxInstanceId() {
return getMaxId(InstanceTable.TABLE, InstanceTable.COLUMN_INSTANCE_ID);
}
@Override public int getMinInstanceId() {
return getMinId(InstanceTable.TABLE, InstanceTable.COLUMN_INSTANCE_ID);
}
@Override public void save(Instance instance) {
H2Client client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(InstanceTable.COLUMN_ID, instance.getId());
source.put(InstanceTable.COLUMN_INSTANCE_ID, instance.getInstanceId());
source.put(InstanceTable.COLUMN_APPLICATION_ID, instance.getApplicationId());
source.put(InstanceTable.COLUMN_AGENT_UUID, instance.getAgentUUID());
source.put(InstanceTable.COLUMN_REGISTER_TIME, instance.getRegisterTime());
source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, instance.getHeartBeatTime());
source.put(InstanceTable.COLUMN_OS_INFO, instance.getOsInfo());
source.put(InstanceTable.COLUMN_ADDRESS_ID, instance.getAddressId());
source.put(InstanceTable.COLUMN_IS_ADDRESS, instance.getIsAddress());
String sql = SqlBuilder.buildBatchInsertSql(InstanceTable.TABLE, source.keySet());
Object[] params = source.values().toArray(new Object[0]);
try {
client.execute(sql, params);
} catch (H2ClientException e) {
logger.error(e.getMessage(), e);
}
}
@Override public void updateHeartbeatTime(int instanceId, long heartbeatTime) {
H2Client client = getClient();
String sql = SqlBuilder.buildSql(UPDATE_HEARTBEAT_TIME_SQL, InstanceTable.TABLE, InstanceTable.COLUMN_HEARTBEAT_TIME,
InstanceTable.COLUMN_ID);
Object[] params = new Object[] {heartbeatTime, instanceId};
try {
client.execute(sql, params);
} catch (H2ClientException e) {
logger.error(e.getMessage(), e);
}
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.collector.storage.h2.dao.register;
import java.util.HashMap;
import java.util.Map;
import org.apache.skywalking.apm.collector.client.h2.H2Client;
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
import org.apache.skywalking.apm.collector.storage.dao.register.INetworkAddressRegisterDAO;
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddress;
import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddressTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng, clevertension
*/
public class NetworkAddressRegisterH2DAO extends H2DAO implements INetworkAddressRegisterDAO {
private final Logger logger = LoggerFactory.getLogger(NetworkAddressRegisterH2DAO.class);
public NetworkAddressRegisterH2DAO(H2Client client) {
super(client);
}
@Override
public int getMaxNetworkAddressId() {
return getMaxId(NetworkAddressTable.TABLE, NetworkAddressTable.COLUMN_ADDRESS_ID);
}
@Override
public int getMinNetworkAddressId() {
return getMinId(NetworkAddressTable.TABLE, NetworkAddressTable.COLUMN_ADDRESS_ID);
}
@Override
public void save(NetworkAddress networkAddress) {
H2Client client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(NetworkAddressTable.COLUMN_ID, networkAddress.getId());
source.put(NetworkAddressTable.COLUMN_NETWORK_ADDRESS, networkAddress.getNetworkAddress());
source.put(NetworkAddressTable.COLUMN_ADDRESS_ID, networkAddress.getAddressId());
String sql = SqlBuilder.buildBatchInsertSql(NetworkAddressTable.TABLE, source.keySet());
Object[] params = source.values().toArray(new Object[0]);
try {
client.execute(sql, params);
} catch (H2ClientException e) {
logger.error(e.getMessage(), e);
}
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.collector.storage.h2.dao.register;
import java.util.HashMap;
import java.util.Map;
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
import org.apache.skywalking.apm.collector.storage.dao.register.IServiceNameRegisterDAO;
import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable;
import org.apache.skywalking.apm.collector.client.h2.H2Client;
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
import org.apache.skywalking.apm.collector.storage.table.register.ServiceName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author peng-yongsheng, clevertension
*/
public class ServiceNameRegisterH2DAO extends H2DAO implements IServiceNameRegisterDAO {
private final Logger logger = LoggerFactory.getLogger(ServiceNameRegisterH2DAO.class);
public ServiceNameRegisterH2DAO(H2Client client) {
super(client);
}
@Override
public int getMaxServiceId() {
return getMaxId(ServiceNameTable.TABLE, ServiceNameTable.COLUMN_SERVICE_ID);
}
@Override
public int getMinServiceId() {
return getMinId(ServiceNameTable.TABLE, ServiceNameTable.COLUMN_SERVICE_ID);
}
@Override
public void save(ServiceName serviceName) {
logger.debug("save service name register info, application getId: {}, service name: {}", serviceName.getId(), serviceName.getServiceName());
H2Client client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(ServiceNameTable.COLUMN_ID, serviceName.getId());
source.put(ServiceNameTable.COLUMN_SERVICE_ID, serviceName.getServiceId());
source.put(ServiceNameTable.COLUMN_APPLICATION_ID, serviceName.getApplicationId());
source.put(ServiceNameTable.COLUMN_SERVICE_NAME, serviceName.getServiceName());
String sql = SqlBuilder.buildBatchInsertSql(ServiceNameTable.TABLE, source.keySet());
Object[] params = source.values().toArray(new Object[0]);
try {
client.execute(sql, params);
} catch (H2ClientException e) {
logger.error(e.getMessage(), e);
}
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.collector.storage.h2.define.register;
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine;
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine;
import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable;
/**
* @author peng-yongsheng
*/
public class ApplicationH2TableDefine extends H2TableDefine {
public ApplicationH2TableDefine() {
super(ApplicationTable.TABLE);
}
@Override public void initialize() {
addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name()));
addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_APPLICATION_CODE, H2ColumnDefine.Type.Varchar.name()));
addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_ADDRESS_ID, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_IS_ADDRESS, H2ColumnDefine.Type.Boolean.name()));
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.collector.storage.h2.define.register;
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine;
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine;
import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable;
/**
* @author peng-yongsheng
*/
public class InstanceH2TableDefine extends H2TableDefine {
public InstanceH2TableDefine() {
super(InstanceTable.TABLE);
}
@Override public void initialize() {
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name()));
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_AGENT_UUID, H2ColumnDefine.Type.Varchar.name()));
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_REGISTER_TIME, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_INSTANCE_ID, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_HEARTBEAT_TIME, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_OS_INFO, H2ColumnDefine.Type.Varchar.name()));
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_ADDRESS_ID, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_IS_ADDRESS, H2ColumnDefine.Type.Boolean.name()));
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.collector.storage.h2.define.register;
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine;
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine;
import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddressTable;
/**
* @author peng-yongsheng
*/
public class NetworkAddressH2TableDefine extends H2TableDefine {
public NetworkAddressH2TableDefine() {
super(NetworkAddressTable.TABLE);
}
@Override public void initialize() {
addColumn(new H2ColumnDefine(NetworkAddressTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name()));
addColumn(new H2ColumnDefine(NetworkAddressTable.COLUMN_NETWORK_ADDRESS, H2ColumnDefine.Type.Varchar.name()));
addColumn(new H2ColumnDefine(NetworkAddressTable.COLUMN_ADDRESS_ID, H2ColumnDefine.Type.Int.name()));
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.skywalking.apm.collector.storage.h2.define.register;
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine;
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine;
import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable;
/**
* @author peng-yongsheng
*/
public class ServiceNameH2TableDefine extends H2TableDefine {
public ServiceNameH2TableDefine() {
super(ServiceNameTable.TABLE);
}
@Override public void initialize() {
addColumn(new H2ColumnDefine(ServiceNameTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name()));
addColumn(new H2ColumnDefine(ServiceNameTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ServiceNameTable.COLUMN_SERVICE_NAME, H2ColumnDefine.Type.Varchar.name()));
addColumn(new H2ColumnDefine(ServiceNameTable.COLUMN_SERVICE_ID, H2ColumnDefine.Type.Int.name()));
}
}
org.apache.skywalking.apm.collector.storage.h2.define.NetworkAddressH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.ApplicationH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.InstanceH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.ServiceNameH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.CpuMetricH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.GCMetricH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.MemoryMetricH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.MemoryPoolMetricH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.GlobalTraceH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.InstanceMetricH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.InstanceReferenceMetricH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.ApplicationComponentH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.ApplicationMappingH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.InstanceMappingH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.ApplicationReferenceMetricH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.SegmentCostH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.SegmentH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.ServiceMetricH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.ServiceReferenceMetricH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.register.NetworkAddressH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.register.ApplicationH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.register.InstanceH2TableDefine
org.apache.skywalking.apm.collector.storage.h2.define.register.ServiceNameH2TableDefine
......@@ -16,5 +16,4 @@
#
#
org.apache.skywalking.apm.collector.storage.h2.StorageModuleH2Provider
org.apache.skywalking.apm.collector.storage.h2.StorageModuleH2Provider
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册