GutoVeronezi commented on a change in pull request #5588:
URL: https://github.com/apache/cloudstack/pull/5588#discussion_r732980376



##########
File path: server/pom.xml
##########
@@ -170,6 +170,37 @@
             <groupId>org.influxdb</groupId>
             <artifactId>influxdb-java</artifactId>
         </dependency>
+<!--        <dependency>-->
+<!--            <groupId>io.dropwizard.metrics</groupId>-->
+<!--            <artifactId>metrics-core</artifactId>-->
+<!--            <version>3.0.2</version>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>io.dropwizard.metrics</groupId>-->
+<!--            <artifactId>metrics-jvm</artifactId>-->
+<!--            <version>3.0.2</version>-->
+<!--        </dependency>-->

Review comment:
       Will these commented dependencies be needed?

##########
File path: 
framework/cluster/src/main/java/com/cloud/cluster/ManagementServerStatusVO.java
##########
@@ -0,0 +1,215 @@
+// 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 com.cloud.cluster;
+
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.management.ManagementServerStatus;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import java.util.Date;
+
+@Entity
+@Table(name = "mshost_status")
+public class ManagementServerStatusVO implements ManagementServerStatus {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+
+    @Column(name = "ms_id", updatable = true, nullable = false)
+    private long msId;
+
+    @Column(name="last_start")
+    private Date lastStart;
+
+    @Column(name="last_stop")
+    private Date lastStop;
+
+    @Column(name="last_boot")
+    private Date lastBoot;
+
+    @Column(name="last_down")
+    private Date lastDown;
+
+    @Column(name="os_name")
+    private String osName;
+
+    @Column(name="os_version")
+    private String osVersion;
+
+    @Column(name="java_name")
+    private String javaName;
+
+    @Column(name="java_version")
+    private String javaVersion;
+
+    @Temporal(TemporalType.TIMESTAMP)
+    @Column(name = "updated")
+    private Date updated;
+
+    @Column(name = GenericDao.CREATED_COLUMN)
+    private Date created;
+
+    @Column(name = GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+
+    public ManagementServerStatusVO() {
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    @Override
+    public long getMsId() {
+        return msId;
+    }
+
+    public void setMsId(long msId) {
+        this.msId = msId;
+    }
+
+    @Override
+    public Date getLastStart() {
+        return lastStart;
+    }
+
+    public void setLastStart(Date lastStart) {
+        this.lastStart = lastStart;
+    }
+
+    @Override
+    public Date getLastStop() {
+        return lastStop;
+    }
+
+    public void setLastStop(Date lastStop) {
+        this.lastStop = lastStop;
+    }
+
+    @Override
+    public Date getLastBoot() {
+        return lastBoot;
+    }
+
+    public void setLastBoot(Date lastBoot) {
+        this.lastBoot = lastBoot;
+    }
+
+    @Override
+    public Date getLastDown() {
+        return lastDown;
+    }
+
+    public void setLastDown(Date lastDown) {
+        this.lastDown = lastDown;
+    }
+
+    @Override
+    public String getOsName() {
+        return osName;
+    }
+
+    public void setOsName(String osName) {
+        this.osName = osName;
+    }
+
+    @Override
+    public String getOsVersion() {
+        return osVersion;
+    }
+
+    public void setOsVersion(String osVersion) {
+        this.osVersion = osVersion;
+    }
+
+    @Override
+    public String getJavaName() {
+        return javaName;
+    }
+
+    public void setJavaName(String javaName) {
+        this.javaName = javaName;
+    }
+
+    @Override
+    public String getJavaVersion() {
+        return javaVersion;
+    }
+
+    public void setJavaVersion(String javaVersion) {
+        this.javaVersion = javaVersion;
+    }
+
+    @Override
+    public Date getUpdated() {
+        return updated;
+    }
+
+    public void setUpdated(Date updated) {
+        this.updated = updated;
+    }
+
+    @Override
+    public Date getCreated() {
+        return created;
+    }
+
+    public void setCreated(Date created) {
+        this.created = created;
+    }
+
+    @Override
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public void setRemoved(Date removedTime) {
+        removed = removedTime;
+    }
+
+    @Override
+    public String toString() {
+        return String.join("-",

Review comment:
       We could use `ReflectionToStringBuilder` or `ReflectionToStringBuilder` 
here.

##########
File path: server/src/main/java/com/cloud/server/StatsCollector.java
##########
@@ -334,9 +363,39 @@ public StatsCollector() {
     @Override
     public boolean start() {
         init(_configDao.getConfiguration());
+        registerAll("gc", new GarbageCollectorMetricSet(), registry);
+        registerAll("buffers", new 
BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()), registry);
+        registerAll("memory", new MemoryUsageGaugeSet(), registry);
+        registerAll("threads", new ThreadStatesGaugeSet(), registry);
+        //registerAll("threads", new CpuMetricSet(), registry);
+        //registerAll("files", new FileDescriptorRatioGauge(), registry);
+        //registerAll("threads", new RuntimeMetricSet(), registry);
+        //registerAll("threads", new StandardSystemMetricSet(), registry);

Review comment:
       Will these commented lines be needed?

##########
File path: server/src/main/java/com/cloud/server/StatsCollector.java
##########
@@ -148,6 +154,18 @@
 
 import static com.cloud.utils.NumbersUtil.toHumanReadableSize;
 import org.apache.commons.io.FileUtils;
+import com.codahale.metrics.Metric;
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.MetricSet;
+import com.codahale.metrics.jvm.BufferPoolMetricSet;
+import com.codahale.metrics.jvm.GarbageCollectorMetricSet;
+import com.codahale.metrics.jvm.MemoryUsageGaugeSet;
+import com.codahale.metrics.jvm.ThreadStatesGaugeSet;
+
+//import com.codahale.metrics.jvm.CpuMetricSet;
+//import com.codahale.metrics.jvm.FileDescriptorRatioGauge;
+//import com.codahale.metrics.jvm.RuntimeMetricSet;
+//import com.codahale.metrics.jvm.StandardSystemMetricSet;

Review comment:
       Will these commented imports be needed?

##########
File path: server/pom.xml
##########
@@ -170,6 +170,37 @@
             <groupId>org.influxdb</groupId>
             <artifactId>influxdb-java</artifactId>
         </dependency>
+<!--        <dependency>-->
+<!--            <groupId>io.dropwizard.metrics</groupId>-->
+<!--            <artifactId>metrics-core</artifactId>-->
+<!--            <version>3.0.2</version>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>io.dropwizard.metrics</groupId>-->
+<!--            <artifactId>metrics-jvm</artifactId>-->
+<!--            <version>3.0.2</version>-->
+<!--        </dependency>-->
+        <dependency>
+            <groupId>com.codahale.metrics</groupId>
+            <artifactId>metrics-core</artifactId>
+            <version>3.0.2</version>
+        </dependency>
+        <dependency>
+            <groupId>com.codahale.metrics</groupId>
+            <artifactId>metrics-jvm</artifactId>
+            <version>3.0.2</version>
+        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.apache.cloudstack</groupId>-->
+<!--            <artifactId>cloud-framework-spring-module</artifactId>-->
+<!--            <version>4.14.0.0</version>-->
+<!--            <scope>compile</scope>-->
+<!--        </dependency>-->
+        <!--        <dependency>-->
+<!--            <groupId>com.codahale.metrics</groupId>-->
+<!--            <artifactId>metrics-parent</artifactId>-->
+<!--            <version>3.0.2</version>-->
+<!--        </dependency>-->

Review comment:
       Will these commented dependencies be needed?

##########
File path: 
framework/cluster/src/main/java/com/cloud/cluster/dao/ManagementServerStatusDaoImpl.java
##########
@@ -0,0 +1,50 @@
+// 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 com.cloud.cluster.dao;
+
+import com.cloud.cluster.ManagementServerStatusVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import org.apache.log4j.Logger;
+
+import java.util.List;
+
+public class ManagementServerStatusDaoImpl extends 
GenericDaoBase<ManagementServerStatusVO, Long> implements 
ManagementServerStatusDao {
+    private static final Logger s_logger = 
Logger.getLogger(ManagementServerHostDaoImpl.class);
+
+    private final SearchBuilder<ManagementServerStatusVO> MsIdSearch;
+
+    public ManagementServerStatusDaoImpl() {
+        MsIdSearch = createSearchBuilder();
+        MsIdSearch.and("msid", MsIdSearch.entity().getMsId(), 
SearchCriteria.Op.EQ);
+        MsIdSearch.done();
+    }
+
+    @Override
+    public ManagementServerStatusVO findByMsId(String msId) {
+        SearchCriteria<ManagementServerStatusVO> sc = MsIdSearch.create();
+        sc.setParameters("msid", msId);
+
+        List<ManagementServerStatusVO> l = listIncludingRemovedBy(sc);
+        if (l != null && l.size() > 0) {

Review comment:
       We could use `org.apache.commons.collections.CollectionUtils` here:
   
   ```suggestion
           if (CollectionUtils.isNotEmpty(l)) {
   ```
   
   Also, could we rename the var to a name more intuitive?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to