changeset 1598:98f306902db6

Build with OpenJDK 8 Reviewed-by: jerboaa Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2014-December/012005.html
author Omair Majid <omajid@redhat.com>
date Fri, 05 Dec 2014 12:55:53 -0500
parents 0d0a64288abc
children 3570aec27794
files storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapterBuilderTest.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapterTest.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/CategoryBuilderTest.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/InvalidSampleBean.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/SampleBean.java storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/StatementUtilsTest.java vm-profiler/client-core/src/main/java/com/redhat/thermostat/vm/profiler/client/core/ProfilingResultParser.java
diffstat 7 files changed, 179 insertions(+), 225 deletions(-) [+]
line wrap: on
line diff
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapterBuilderTest.java	Thu Nov 27 18:31:17 2014 +0100
+++ b/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapterBuilderTest.java	Fri Dec 05 12:55:53 2014 -0500
@@ -37,10 +37,8 @@
 package com.redhat.thermostat.storage.core.experimental.statement;
 
 import com.redhat.thermostat.storage.core.DescriptorParsingException;
-import com.redhat.thermostat.storage.core.Persist;
 import com.redhat.thermostat.storage.core.StatementDescriptor;
 import com.redhat.thermostat.storage.internal.statement.StatementDescriptorTester;
-import com.redhat.thermostat.storage.model.TimeStampedPojo;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -54,49 +52,6 @@
 
 public class BeanAdapterBuilderTest {
 
-    @Category("testCategory")
-    private static class SampleBean implements TimeStampedPojo {
-
-        private long timeStamp;
-        private int vmId;
-        private String name;
-
-        @Indexed
-        @Persist
-        public int getVmId() {
-            return vmId;
-        }
-
-        @Indexed
-        @Persist
-        public void setVmId(int vmId) {
-            this.vmId = vmId;
-        }
-
-        @Persist
-        public String getName() {
-            return name;
-        }
-
-        @Persist
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        @Indexed
-        @Persist
-        public void setTimeStamp(long timeStamp) {
-            this.timeStamp = timeStamp;
-        }
-
-        @Indexed
-        @Persist
-        @Override
-        public long getTimeStamp() {
-            return timeStamp;
-        }
-    }
-
     private List<Query<SampleBean>> queries;
 
     @Before
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapterTest.java	Thu Nov 27 18:31:17 2014 +0100
+++ b/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/BeanAdapterTest.java	Fri Dec 05 12:55:53 2014 -0500
@@ -37,14 +37,14 @@
 package com.redhat.thermostat.storage.core.experimental.statement;
 
 import com.redhat.thermostat.storage.core.Cursor;
-import com.redhat.thermostat.storage.core.Persist;
 import com.redhat.thermostat.storage.core.PreparedStatement;
 import com.redhat.thermostat.storage.core.StatementDescriptor;
 import com.redhat.thermostat.storage.core.Storage;
-import com.redhat.thermostat.storage.model.TimeStampedPojo;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+
 import org.junit.Before;
 import org.junit.Test;
 
@@ -59,49 +59,6 @@
 
 public class BeanAdapterTest {
 
-    @Category("testCategory")
-    private static class SampleBean implements TimeStampedPojo {
-
-        private long timeStamp;
-        private int vmId;
-        private String name;
-
-        @Indexed
-        @Persist
-        public int getVmId() {
-            return vmId;
-        }
-
-        @Indexed
-        @Persist
-        public void setVmId(int vmId) {
-            this.vmId = vmId;
-        }
-
-        @Persist
-        public String getName() {
-            return name;
-        }
-
-        @Persist
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        @Indexed
-        @Persist
-        public void setTimeStamp(long timeStamp) {
-            this.timeStamp = timeStamp;
-        }
-
-        @Indexed
-        @Persist
-        @Override
-        public long getTimeStamp() {
-            return timeStamp;
-        }
-    }
-
     private Storage storage;
     private PreparedStatement<SampleBean> insert;
     private PreparedStatement<SampleBean> query;
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/CategoryBuilderTest.java	Thu Nov 27 18:31:17 2014 +0100
+++ b/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/CategoryBuilderTest.java	Fri Dec 05 12:55:53 2014 -0500
@@ -37,8 +37,6 @@
 package com.redhat.thermostat.storage.core.experimental.statement;
 
 import com.redhat.thermostat.storage.core.Key;
-import com.redhat.thermostat.storage.core.Persist;
-import com.redhat.thermostat.storage.model.TimeStampedPojo;
 import java.util.Collection;
 import java.util.List;
 import org.junit.Test;
@@ -49,54 +47,10 @@
 
 public class CategoryBuilderTest {
 
-    private static final String CATEGORY_NAME = "builder-category-test";
-
-    @Category(CATEGORY_NAME)
-    private static class SampleBean implements TimeStampedPojo {
-
-        private long timeStamp;
-        private String vmId;
-        private String name;
-
-        @Indexed
-        @Persist
-        public String getVmId() {
-            return vmId;
-        }
-
-        @Indexed
-        @Persist
-        public void setVmId(String vmId) {
-            this.vmId = vmId;
-        }
-
-        @Persist
-        public String getName() {
-            return name;
-        }
-
-        @Persist
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        @Indexed
-        @Persist
-        public void setTimeStamp(long timeStamp) {
-            this.timeStamp = timeStamp;
-        }
-
-        @Indexed
-        @Persist
-        @Override
-        public long getTimeStamp() {
-            return timeStamp;
-        }
-    }
-
+    private static final String CATEGORY_NAME = "testCategory";
     @Test
     public void testBuild() throws Exception {
-        CategoryBuilder builder =  new CategoryBuilder(SampleBean.class);
+        CategoryBuilder<SampleBean> builder =  new CategoryBuilder<>(SampleBean.class);
         com.redhat.thermostat.storage.core.Category<SampleBean> category =
                 builder.build();
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/InvalidSampleBean.java	Fri Dec 05 12:55:53 2014 -0500
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2012-2014 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.storage.core.experimental.statement;
+
+import com.redhat.thermostat.storage.core.Persist;
+import com.redhat.thermostat.storage.model.TimeStampedPojo;
+
+@Category("testCategory2")
+public class InvalidSampleBean implements TimeStampedPojo {
+
+    private long timeStamp;
+    private int vmId;
+    private String name;
+
+    public int getVmId() {
+        return vmId;
+    }
+
+    @Indexed
+    @Persist
+    public void setVmId(int vmId) {
+        this.vmId = vmId;
+    }
+
+    @Persist
+    public String getName() {
+        return name;
+    }
+
+    @Persist
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setTimeStamp(long timeStamp) {
+        this.timeStamp = timeStamp;
+    }
+
+    @Indexed
+    @Persist
+    @Override
+    public long getTimeStamp() {
+        return timeStamp;
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/SampleBean.java	Fri Dec 05 12:55:53 2014 -0500
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2012-2014 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.storage.core.experimental.statement;
+
+import com.redhat.thermostat.storage.core.Persist;
+import com.redhat.thermostat.storage.model.TimeStampedPojo;
+
+@Category("testCategory")
+public class SampleBean implements TimeStampedPojo {
+
+    private long timeStamp;
+    private int vmId;
+    private String name;
+
+    @Indexed
+    @Persist
+    public int getVmId() {
+        return vmId;
+    }
+
+    @Indexed
+    @Persist
+    public void setVmId(int vmId) {
+        this.vmId = vmId;
+    }
+
+    @Persist
+    public String getName() {
+        return name;
+    }
+
+    @Persist
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Indexed
+    @Persist
+    public void setTimeStamp(long timeStamp) {
+        this.timeStamp = timeStamp;
+    }
+
+    @Indexed
+    @Persist
+    @Override
+    public long getTimeStamp() {
+        return timeStamp;
+    }
+}
\ No newline at end of file
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/StatementUtilsTest.java	Thu Nov 27 18:31:17 2014 +0100
+++ b/storage/core/src/test/java/com/redhat/thermostat/storage/core/experimental/statement/StatementUtilsTest.java	Fri Dec 05 12:55:53 2014 -0500
@@ -36,10 +36,9 @@
 
 package com.redhat.thermostat.storage.core.experimental.statement;
 
-import com.redhat.thermostat.storage.core.Persist;
-import com.redhat.thermostat.storage.model.TimeStampedPojo;
 import java.util.List;
 import java.util.Map;
+
 import org.junit.Test;
 
 import static org.junit.Assert.assertFalse;
@@ -47,88 +46,6 @@
 
 public class StatementUtilsTest {
 
-    @Category("testCategory")
-    private static class SampleBean implements TimeStampedPojo {
-
-        private long timeStamp;
-        private int vmId;
-        private String name;
-
-        @Indexed
-        @Persist
-        public int getVmId() {
-            return vmId;
-        }
-
-        @Indexed
-        @Persist
-        public void setVmId(int vmId) {
-            this.vmId = vmId;
-        }
-
-        @Persist
-        public String getName() {
-            return name;
-        }
-
-        @Persist
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        @Indexed
-        @Persist
-        public void setTimeStamp(long timeStamp) {
-            this.timeStamp = timeStamp;
-        }
-
-        @Indexed
-        @Persist
-        @Override
-        public long getTimeStamp() {
-            return timeStamp;
-        }
-    }
-
-    @Category("testCategory2")
-    private static class InvalidSampleBean implements TimeStampedPojo {
-
-        private long timeStamp;
-        private int vmId;
-        private String name;
-
-        public int getVmId() {
-            return vmId;
-        }
-
-        @Indexed
-        @Persist
-        public void setVmId(int vmId) {
-            this.vmId = vmId;
-        }
-
-        @Persist
-        public String getName() {
-            return name;
-        }
-
-        @Persist
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        public void setTimeStamp(long timeStamp) {
-            this.timeStamp = timeStamp;
-        }
-
-        @Indexed
-        @Persist
-        @Override
-        public long getTimeStamp() {
-            return timeStamp;
-        }
-    }
-
     @Test
     public void testAnnotationSupport() {
         List<FieldDescriptor> descriptors =
--- a/vm-profiler/client-core/src/main/java/com/redhat/thermostat/vm/profiler/client/core/ProfilingResultParser.java	Thu Nov 27 18:31:17 2014 +0100
+++ b/vm-profiler/client-core/src/main/java/com/redhat/thermostat/vm/profiler/client/core/ProfilingResultParser.java	Fri Dec 05 12:55:53 2014 -0500
@@ -42,6 +42,8 @@
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -57,8 +59,8 @@
     private static final Logger logger = LoggingUtils.getLogger(ProfilingResultParser.class);
 
     public ProfilingResult parse(InputStream in) {
-        Map<String, Long> result = readData(in);
-        return processData(result);
+        Map<String, Long> methodAndTimes = readData(in);
+        return convertToResult(methodAndTimes);
     }
 
     private Map<String, Long> readData(InputStream in) {
@@ -79,7 +81,7 @@
         return result;
     }
 
-    private ProfilingResult processData(Map<String, Long> results) {
+    private ProfilingResult convertToResult(Map<String, Long> results) {
         ArrayList<MethodInfo> info = new ArrayList<>();
         long totalTime = 0;
         for (Entry<String, Long> entry : results.entrySet()) {
@@ -91,6 +93,13 @@
             info.add(method);
         }
 
+        Collections.sort(info, new Comparator<MethodInfo>() {
+            @Override
+            public int compare(MethodInfo o1, MethodInfo o2) {
+                return Long.compare(o1.totalTimeInMillis, o2.totalTimeInMillis);
+            }
+        });
+
         return new ProfilingResult(info);
     }