diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/base/dao/IPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/base/dao/IPersistenceDAO.java new file mode 100644 index 000000000..02b21b23d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/base/dao/IPersistenceDAO.java @@ -0,0 +1,33 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.base.dao; + +import org.skywalking.apm.collector.core.data.Data; +import org.skywalking.apm.collector.storage.base.define.DataDefine; + +/** + * @author peng-yongsheng + */ +public interface IPersistenceDAO { + Data get(String id, DataDefine dataDefine); + + I prepareBatchInsert(Data data); + + U prepareBatchUpdate(Data data); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IApplicationDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IApplicationDAO.java new file mode 100644 index 000000000..a095e43e1 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IApplicationDAO.java @@ -0,0 +1,32 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.dao; + +import org.skywalking.apm.collector.core.data.Data; + +/** + * @author peng-yongsheng + */ +public interface IApplicationDAO { + int getMaxApplicationId(); + + int getMinApplicationId(); + + void save(Data data); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ICpuMetricDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ICpuMetricDAO.java new file mode 100644 index 000000000..bba6ba444 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/ICpuMetricDAO.java @@ -0,0 +1,25 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.dao; + +/** + * @author peng-yongsheng + */ +public interface ICpuMetricDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IGCMetricDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IGCMetricDAO.java new file mode 100644 index 000000000..af3ed4c8e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IGCMetricDAO.java @@ -0,0 +1,25 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.dao; + +/** + * @author peng-yongsheng + */ +public interface IGCMetricDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstanceHeartBeatDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstanceHeartBeatDAO.java new file mode 100644 index 000000000..5909637dc --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IInstanceHeartBeatDAO.java @@ -0,0 +1,25 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.dao; + +/** + * @author peng-yongsheng + */ +public interface IInstanceHeartBeatDAO { +} \ No newline at end of file diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IMemoryMetricDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IMemoryMetricDAO.java new file mode 100644 index 000000000..70901b976 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IMemoryMetricDAO.java @@ -0,0 +1,25 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.dao; + +/** + * @author peng-yongsheng + */ +public interface IMemoryMetricDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IMemoryPoolMetricDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IMemoryPoolMetricDAO.java new file mode 100644 index 000000000..18f8277b9 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IMemoryPoolMetricDAO.java @@ -0,0 +1,25 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.dao; + +/** + * @author peng-yongsheng + */ +public interface IMemoryPoolMetricDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationEsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationEsDAO.java new file mode 100644 index 000000000..a2ef0465f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/ApplicationEsDAO.java @@ -0,0 +1,58 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.es.dao; + +import java.util.HashMap; +import java.util.Map; +import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.support.WriteRequest; +import org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.skywalking.apm.collector.core.data.Data; +import org.skywalking.apm.collector.storage.dao.IApplicationDAO; +import org.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.skywalking.apm.collector.storage.table.register.ApplicationTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ApplicationEsDAO extends EsDAO implements IApplicationDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationEsDAO.class); + + @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(Data data) { + logger.debug("save application register info, application id: {}, application code: {}", application.getApplicationId(), application.getApplicationCode()); + ElasticSearchClient client = getClient(); + Map source = new HashMap<>(); + source.put(ApplicationTable.COLUMN_APPLICATION_CODE, application.getApplicationCode()); + source.put(ApplicationTable.COLUMN_APPLICATION_ID, application.getApplicationId()); + + IndexResponse response = client.prepareIndex(ApplicationTable.TABLE, application.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get(); + logger.debug("save application register info, application id: {}, application code: {}, status: {}", application.getApplicationId(), application.getApplicationCode(), response.status().name()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/CpuMetricEsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/CpuMetricEsDAO.java new file mode 100644 index 000000000..d71574f0d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/CpuMetricEsDAO.java @@ -0,0 +1,58 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.es.dao; + +import java.util.HashMap; +import java.util.Map; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.skywalking.apm.collector.core.data.Data; +import org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.skywalking.apm.collector.storage.base.define.DataDefine; +import org.skywalking.apm.collector.storage.dao.ICpuMetricDAO; +import org.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class CpuMetricEsDAO extends EsDAO implements ICpuMetricDAO, IPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(CpuMetricEsDAO.class); + + @Override public Data get(String id, DataDefine dataDefine) { + return null; + } + + @Override public IndexRequestBuilder prepareBatchInsert(Data data) { + Map source = new HashMap<>(); + source.put(CpuMetricTable.COLUMN_INSTANCE_ID, data.getDataInteger(0)); + source.put(CpuMetricTable.COLUMN_USAGE_PERCENT, data.getDataDouble(0)); + source.put(CpuMetricTable.COLUMN_TIME_BUCKET, data.getDataLong(0)); + + logger.debug("prepare cpu metric batch insert, id: {}", data.getDataString(0)); + return getClient().prepareIndex(CpuMetricTable.TABLE, data.getDataString(0)).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(Data data) { + return null; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/GCMetricEsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/GCMetricEsDAO.java new file mode 100644 index 000000000..de15de52b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/GCMetricEsDAO.java @@ -0,0 +1,55 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.es.dao; + +import java.util.HashMap; +import java.util.Map; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.skywalking.apm.collector.core.data.Data; +import org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.skywalking.apm.collector.storage.base.define.DataDefine; +import org.skywalking.apm.collector.storage.dao.IGCMetricDAO; +import org.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.skywalking.apm.collector.storage.table.jvm.GCMetricTable; + +/** + * @author peng-yongsheng + */ +public class GCMetricEsDAO extends EsDAO implements IGCMetricDAO, IPersistenceDAO { + + @Override public Data get(String id, DataDefine dataDefine) { + return null; + } + + @Override public IndexRequestBuilder prepareBatchInsert(Data data) { + Map source = new HashMap<>(); + source.put(GCMetricTable.COLUMN_INSTANCE_ID, data.getDataInteger(0)); + source.put(GCMetricTable.COLUMN_PHRASE, data.getDataInteger(1)); + source.put(GCMetricTable.COLUMN_COUNT, data.getDataLong(0)); + source.put(GCMetricTable.COLUMN_TIME, data.getDataLong(1)); + source.put(GCMetricTable.COLUMN_TIME_BUCKET, data.getDataLong(2)); + + return getClient().prepareIndex(GCMetricTable.TABLE, data.getDataString(0)).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(Data data) { + return null; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstanceHeartBeatEsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstanceHeartBeatEsDAO.java new file mode 100644 index 000000000..a955ff9e3 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/InstanceHeartBeatEsDAO.java @@ -0,0 +1,67 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.es.dao; + +import java.util.HashMap; +import java.util.Map; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.skywalking.apm.collector.core.UnexpectedException; +import org.skywalking.apm.collector.core.data.Data; +import org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.skywalking.apm.collector.storage.base.define.DataDefine; +import org.skywalking.apm.collector.storage.dao.IInstanceHeartBeatDAO; +import org.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.skywalking.apm.collector.storage.table.register.InstanceTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceHeartBeatEsDAO extends EsDAO implements IInstanceHeartBeatDAO, IPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceHeartBeatEsDAO.class); + + @Override public Data get(String id, DataDefine dataDefine) { + GetResponse getResponse = getClient().prepareGet(InstanceTable.TABLE, id).get(); + if (getResponse.isExists()) { + Data data = dataDefine.build(id); + Map source = getResponse.getSource(); + data.setDataInteger(0, (Integer)source.get(InstanceTable.COLUMN_INSTANCE_ID)); + data.setDataLong(0, (Long)source.get(InstanceTable.COLUMN_HEARTBEAT_TIME)); + logger.debug("id: {} is exists", id); + return data; + } else { + logger.debug("id: {} is not exists", id); + return null; + } + } + + @Override public IndexRequestBuilder prepareBatchInsert(Data data) { + throw new UnexpectedException("There is no need to merge stream data with database data."); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(Data data) { + Map source = new HashMap<>(); + source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, data.getDataLong(0)); + return getClient().prepareUpdate(InstanceTable.TABLE, data.getDataString(0)).setDoc(source); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/MemoryMetricEsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/MemoryMetricEsDAO.java new file mode 100644 index 000000000..d67de6e88 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/MemoryMetricEsDAO.java @@ -0,0 +1,57 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.es.dao; + +import java.util.HashMap; +import java.util.Map; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.skywalking.apm.collector.core.data.Data; +import org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.skywalking.apm.collector.storage.base.define.DataDefine; +import org.skywalking.apm.collector.storage.dao.IMemoryMetricDAO; +import org.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; + +/** + * @author peng-yongsheng + */ +public class MemoryMetricEsDAO extends EsDAO implements IMemoryMetricDAO, IPersistenceDAO { + + @Override public Data get(String id, DataDefine dataDefine) { + return null; + } + + @Override public IndexRequestBuilder prepareBatchInsert(Data data) { + Map source = new HashMap<>(); + source.put(MemoryMetricTable.COLUMN_APPLICATION_INSTANCE_ID, data.getDataInteger(0)); + source.put(MemoryMetricTable.COLUMN_IS_HEAP, data.getDataBoolean(0)); + source.put(MemoryMetricTable.COLUMN_INIT, data.getDataLong(0)); + source.put(MemoryMetricTable.COLUMN_MAX, data.getDataLong(1)); + source.put(MemoryMetricTable.COLUMN_USED, data.getDataLong(2)); + source.put(MemoryMetricTable.COLUMN_COMMITTED, data.getDataLong(3)); + source.put(MemoryMetricTable.COLUMN_TIME_BUCKET, data.getDataLong(4)); + + return getClient().prepareIndex(MemoryMetricTable.TABLE, data.getDataString(0)).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(Data data) { + return null; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsDAO.java new file mode 100644 index 000000000..da10141c2 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsDAO.java @@ -0,0 +1,57 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.es.dao; + +import java.util.HashMap; +import java.util.Map; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.skywalking.apm.collector.core.data.Data; +import org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.skywalking.apm.collector.storage.base.define.DataDefine; +import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricDAO; +import org.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolMetricEsDAO extends EsDAO implements IMemoryPoolMetricDAO, IPersistenceDAO { + + @Override public Data get(String id, DataDefine dataDefine) { + return null; + } + + @Override public IndexRequestBuilder prepareBatchInsert(Data data) { + Map source = new HashMap<>(); + source.put(MemoryPoolMetricTable.COLUMN_INSTANCE_ID, data.getDataInteger(0)); + source.put(MemoryPoolMetricTable.COLUMN_POOL_TYPE, data.getDataInteger(1)); + source.put(MemoryPoolMetricTable.COLUMN_INIT, data.getDataLong(0)); + source.put(MemoryPoolMetricTable.COLUMN_MAX, data.getDataLong(1)); + source.put(MemoryPoolMetricTable.COLUMN_USED, data.getDataLong(2)); + source.put(MemoryPoolMetricTable.COLUMN_COMMITTED, data.getDataLong(3)); + source.put(MemoryPoolMetricTable.COLUMN_TIME_BUCKET, data.getDataLong(4)); + + return getClient().prepareIndex(MemoryPoolMetricTable.TABLE, data.getDataString(0)).setSource(source); + } + + @Override public UpdateRequestBuilder prepareBatchUpdate(Data data) { + return null; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/es_dao.define b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/es_dao.define new file mode 100644 index 000000000..3ee8777f5 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/es_dao.define @@ -0,0 +1,5 @@ +org.skywalking.apm.collector.storage.es.dao.CpuMetricEsDAO +org.skywalking.apm.collector.storage.es.dao.GCMetricEsDAO +org.skywalking.apm.collector.storage.es.dao.InstanceHeartBeatEsDAO +org.skywalking.apm.collector.storage.es.dao.MemoryMetricEsDAO +org.skywalking.apm.collector.storage.es.dao.MemoryPoolMetricEsDAO \ No newline at end of file diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationH2DAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationH2DAO.java new file mode 100644 index 000000000..c9e6aa39c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/ApplicationH2DAO.java @@ -0,0 +1,65 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.h2.dao; + +import java.util.HashMap; +import java.util.Map; +import org.skywalking.apm.collector.client.h2.H2Client; +import org.skywalking.apm.collector.client.h2.H2ClientException; +import org.skywalking.apm.collector.storage.define.register.ApplicationDataDefine; +import org.skywalking.apm.collector.storage.define.register.ApplicationTable; +import org.skywalking.apm.collector.storage.h2.SqlBuilder; +import org.skywalking.apm.collector.storage.h2.dao.H2DAO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class ApplicationH2DAO extends H2DAO implements IApplicationDAO { + private final Logger logger = LoggerFactory.getLogger(ApplicationH2DAO.class); + + @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(ApplicationDataDefine.Application application) { + H2Client client = getClient(); + + Map source = new HashMap<>(); + source.put(ApplicationTable.COLUMN_ID, application.getApplicationId()); + source.put(ApplicationTable.COLUMN_APPLICATION_CODE, application.getApplicationCode()); + source.put(ApplicationTable.COLUMN_APPLICATION_ID, application.getApplicationId()); + + 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); + } + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/CpuMetricH2DAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/CpuMetricH2DAO.java new file mode 100644 index 000000000..a5dac8e7e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/CpuMetricH2DAO.java @@ -0,0 +1,62 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.h2.dao; + +import java.util.HashMap; +import java.util.Map; +import org.skywalking.apm.collector.core.data.Data; +import org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.skywalking.apm.collector.storage.base.define.DataDefine; +import org.skywalking.apm.collector.storage.dao.ICpuMetricDAO; +import org.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.skywalking.apm.collector.storage.sql.SqlBuilder; +import org.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class CpuMetricH2DAO extends H2DAO implements ICpuMetricDAO, IPersistenceDAO { + private final Logger logger = LoggerFactory.getLogger(CpuMetricH2DAO.class); + + @Override public Data get(String id, DataDefine dataDefine) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(Data data) { + H2SqlEntity entity = new H2SqlEntity(); + Map source = new HashMap<>(); + source.put(CpuMetricTable.COLUMN_ID, data.getDataString(0)); + source.put(CpuMetricTable.COLUMN_INSTANCE_ID, data.getDataInteger(0)); + source.put(CpuMetricTable.COLUMN_USAGE_PERCENT, data.getDataDouble(0)); + source.put(CpuMetricTable.COLUMN_TIME_BUCKET, data.getDataLong(0)); + + logger.debug("prepare cpu metric batch insert, id: {}", data.getDataString(0)); + String sql = SqlBuilder.buildBatchInsertSql(CpuMetricTable.TABLE, source.keySet()); + entity.setSql(sql); + entity.setParams(source.values().toArray(new Object[0])); + return entity; + } + + @Override public H2SqlEntity prepareBatchUpdate(Data data) { + return null; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/GCMetricH2DAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/GCMetricH2DAO.java new file mode 100644 index 000000000..c4053c4b2 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/GCMetricH2DAO.java @@ -0,0 +1,59 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.h2.dao; + +import java.util.HashMap; +import java.util.Map; +import org.skywalking.apm.collector.core.data.Data; +import org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.skywalking.apm.collector.storage.base.define.DataDefine; +import org.skywalking.apm.collector.storage.dao.IGCMetricDAO; +import org.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.skywalking.apm.collector.storage.sql.SqlBuilder; +import org.skywalking.apm.collector.storage.table.jvm.GCMetricTable; + +/** + * @author peng-yongsheng, clevertension + */ +public class GCMetricH2DAO extends H2DAO implements IGCMetricDAO, IPersistenceDAO { + @Override public Data get(String id, DataDefine dataDefine) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(Data data) { + H2SqlEntity entity = new H2SqlEntity(); + Map source = new HashMap<>(); + source.put(GCMetricTable.COLUMN_ID, data.getDataString(0)); + source.put(GCMetricTable.COLUMN_INSTANCE_ID, data.getDataInteger(0)); + source.put(GCMetricTable.COLUMN_PHRASE, data.getDataInteger(1)); + source.put(GCMetricTable.COLUMN_COUNT, data.getDataLong(0)); + source.put(GCMetricTable.COLUMN_TIME, data.getDataLong(1)); + source.put(GCMetricTable.COLUMN_TIME_BUCKET, data.getDataLong(2)); + + String sql = SqlBuilder.buildBatchInsertSql(GCMetricTable.TABLE, source.keySet()); + entity.setSql(sql); + entity.setParams(source.values().toArray(new Object[0])); + return entity; + } + + @Override public H2SqlEntity prepareBatchUpdate(Data data) { + return null; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceHeartBeatH2DAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceHeartBeatH2DAO.java new file mode 100644 index 000000000..09bded4ce --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/InstanceHeartBeatH2DAO.java @@ -0,0 +1,82 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.h2.dao; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.skywalking.apm.collector.client.h2.H2Client; +import org.skywalking.apm.collector.client.h2.H2ClientException; +import org.skywalking.apm.collector.core.UnexpectedException; +import org.skywalking.apm.collector.core.data.Data; +import org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.skywalking.apm.collector.storage.base.define.DataDefine; +import org.skywalking.apm.collector.storage.dao.IInstanceHeartBeatDAO; +import org.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.skywalking.apm.collector.storage.sql.SqlBuilder; +import org.skywalking.apm.collector.storage.table.register.InstanceTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class InstanceHeartBeatH2DAO extends H2DAO implements IInstanceHeartBeatDAO, IPersistenceDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceHeartBeatH2DAO.class); + + private static final String GET_INSTANCE_HEARTBEAT_SQL = "select * from {0} where {1} = ?"; + + @Override public Data get(String id, DataDefine dataDefine) { + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_INSTANCE_HEARTBEAT_SQL, InstanceTable.TABLE, InstanceTable.COLUMN_INSTANCE_ID); + Object[] params = new Object[] {id}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + Data data = dataDefine.build(id); + data.setDataInteger(0, rs.getInt(InstanceTable.COLUMN_INSTANCE_ID)); + data.setDataLong(0, rs.getLong(InstanceTable.COLUMN_HEARTBEAT_TIME)); + return data; + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(Data data) { + throw new UnexpectedException("There is no need to merge stream data with database data."); + } + + @Override public H2SqlEntity prepareBatchUpdate(Data data) { + H2SqlEntity entity = new H2SqlEntity(); + Map source = new HashMap<>(); + source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, data.getDataLong(0)); + String sql = SqlBuilder.buildBatchUpdateSql(InstanceTable.TABLE, source.keySet(), InstanceTable.COLUMN_INSTANCE_ID); + entity.setSql(sql); + List params = new ArrayList<>(source.values()); + params.add(data.getDataString(0)); + entity.setParams(params.toArray(new Object[0])); + return entity; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2DAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2DAO.java new file mode 100644 index 000000000..1be3e1e02 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2DAO.java @@ -0,0 +1,61 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.h2.dao; + +import java.util.HashMap; +import java.util.Map; +import org.skywalking.apm.collector.core.data.Data; +import org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.skywalking.apm.collector.storage.base.define.DataDefine; +import org.skywalking.apm.collector.storage.dao.IMemoryMetricDAO; +import org.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.skywalking.apm.collector.storage.sql.SqlBuilder; +import org.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; + +/** + * @author peng-yongsheng, clevertension + */ +public class MemoryMetricH2DAO extends H2DAO implements IMemoryMetricDAO, IPersistenceDAO { + @Override public Data get(String id, DataDefine dataDefine) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(Data data) { + H2SqlEntity entity = new H2SqlEntity(); + Map source = new HashMap<>(); + source.put(MemoryMetricTable.COLUMN_ID, data.getDataString(0)); + source.put(MemoryMetricTable.COLUMN_APPLICATION_INSTANCE_ID, data.getDataInteger(0)); + source.put(MemoryMetricTable.COLUMN_IS_HEAP, data.getDataBoolean(0)); + source.put(MemoryMetricTable.COLUMN_INIT, data.getDataLong(0)); + source.put(MemoryMetricTable.COLUMN_MAX, data.getDataLong(1)); + source.put(MemoryMetricTable.COLUMN_USED, data.getDataLong(2)); + source.put(MemoryMetricTable.COLUMN_COMMITTED, data.getDataLong(3)); + source.put(MemoryMetricTable.COLUMN_TIME_BUCKET, data.getDataLong(4)); + + String sql = SqlBuilder.buildBatchInsertSql(MemoryMetricTable.TABLE, source.keySet()); + entity.setSql(sql); + entity.setParams(source.values().toArray(new Object[0])); + return entity; + } + + @Override public H2SqlEntity prepareBatchUpdate(Data data) { + return null; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2DAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2DAO.java new file mode 100644 index 000000000..cd3c72898 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2DAO.java @@ -0,0 +1,61 @@ +/* + * Copyright 2017, OpenSkywalking Organization All rights reserved. + * + * 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. + * + * Project repository: https://github.com/OpenSkywalking/skywalking + */ + +package org.skywalking.apm.collector.storage.h2.dao; + +import java.util.HashMap; +import java.util.Map; +import org.skywalking.apm.collector.core.data.Data; +import org.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.skywalking.apm.collector.storage.base.define.DataDefine; +import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricDAO; +import org.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.skywalking.apm.collector.storage.sql.SqlBuilder; +import org.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; + +/** + * @author peng-yongsheng, clevertension + */ +public class MemoryPoolMetricH2DAO extends H2DAO implements IMemoryPoolMetricDAO, IPersistenceDAO { + @Override public Data get(String id, DataDefine dataDefine) { + return null; + } + + @Override public H2SqlEntity prepareBatchInsert(Data data) { + H2SqlEntity entity = new H2SqlEntity(); + Map source = new HashMap<>(); + source.put(MemoryPoolMetricTable.COLUMN_ID, data.getDataString(0)); + source.put(MemoryPoolMetricTable.COLUMN_INSTANCE_ID, data.getDataInteger(0)); + source.put(MemoryPoolMetricTable.COLUMN_POOL_TYPE, data.getDataInteger(1)); + source.put(MemoryPoolMetricTable.COLUMN_INIT, data.getDataLong(0)); + source.put(MemoryPoolMetricTable.COLUMN_MAX, data.getDataLong(1)); + source.put(MemoryPoolMetricTable.COLUMN_USED, data.getDataLong(2)); + source.put(MemoryPoolMetricTable.COLUMN_COMMITTED, data.getDataLong(3)); + source.put(MemoryPoolMetricTable.COLUMN_TIME_BUCKET, data.getDataLong(4)); + + String sql = SqlBuilder.buildBatchInsertSql(MemoryPoolMetricTable.TABLE, source.keySet()); + entity.setSql(sql); + entity.setParams(source.values().toArray(new Object[0])); + return entity; + } + + @Override public H2SqlEntity prepareBatchUpdate(Data data) { + return null; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/h2_dao.define b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/h2_dao.define new file mode 100644 index 000000000..6753de66d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/h2_dao.define @@ -0,0 +1,5 @@ +org.skywalking.apm.collector.storage.h2.dao.CpuMetricH2DAO +org.skywalking.apm.collector.storage.h2.dao.GCMetricH2DAO +org.skywalking.apm.collector.storage.h2.dao.InstanceHeartBeatH2DAO +org.skywalking.apm.collector.storage.h2.dao.MemoryMetricH2DAO +org.skywalking.apm.collector.storage.h2.dao.MemoryPoolMetricH2DAO \ No newline at end of file