changeset 108:8f3b11eef42b

Refactor the host overview tab into separate classes Reviewed-by: vanaltj Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-March/000275.html
author Omair Majid <omajid@redhat.com>
date Thu, 08 Mar 2012 16:56:58 -0500
parents fd0aba264820
children 9e701016aeca
files client/src/main/java/com/redhat/thermostat/client/HostPanelFacade.java client/src/main/java/com/redhat/thermostat/client/HostPanelFacadeImpl.java client/src/main/java/com/redhat/thermostat/client/ui/HostOverviewController.java client/src/main/java/com/redhat/thermostat/client/ui/HostOverviewPanel.java client/src/main/java/com/redhat/thermostat/client/ui/HostOverviewView.java client/src/main/java/com/redhat/thermostat/client/ui/HostPanel.java common/src/main/java/com/redhat/thermostat/common/dao/HostInfoConverter.java common/src/main/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoConverter.java common/src/test/java/com/redhat/thermostat/common/dao/HostInfoConverterTest.java common/src/test/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoConverterTest.java
diffstat 10 files changed, 500 insertions(+), 159 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/main/java/com/redhat/thermostat/client/HostPanelFacade.java	Wed Mar 07 16:34:26 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/HostPanelFacade.java	Thu Mar 08 16:56:58 2012 -0500
@@ -38,9 +38,9 @@
 
 import java.util.List;
 
-import javax.swing.table.TableModel;
+import org.jfree.data.time.TimeSeriesCollection;
 
-import org.jfree.data.time.TimeSeriesCollection;
+import com.redhat.thermostat.client.ui.HostOverviewController;
 
 public interface HostPanelFacade extends AsyncUiFacade {
 
@@ -60,12 +60,8 @@
 
     public ChangeableText getTotalMemory();
 
-    public ChangeableText getOsName();
-
-    public ChangeableText getOsKernel();
-
-    public TableModel getNetworkTableModel();
-
     public TimeSeriesCollection getCpuLoadDataSet();
 
+    public HostOverviewController getOverviewController();
+
 }
--- a/client/src/main/java/com/redhat/thermostat/client/HostPanelFacadeImpl.java	Wed Mar 07 16:34:26 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/HostPanelFacadeImpl.java	Thu Mar 08 16:56:58 2012 -0500
@@ -36,8 +36,6 @@
 
 package com.redhat.thermostat.client;
 
-import static com.redhat.thermostat.client.locale.Translate.localize;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
@@ -45,13 +43,10 @@
 import java.util.Set;
 import java.util.Timer;
 import java.util.TimerTask;
-import java.util.Vector;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 
 import javax.swing.SwingWorker;
-import javax.swing.table.DefaultTableModel;
-import javax.swing.table.TableModel;
 
 import org.jfree.data.time.FixedMillisecond;
 import org.jfree.data.time.TimeSeries;
@@ -62,27 +57,19 @@
 import com.mongodb.DBCollection;
 import com.mongodb.DBCursor;
 import com.mongodb.DBObject;
-import com.redhat.thermostat.client.locale.LocaleResources;
-import com.redhat.thermostat.common.NetworkInfo;
-import com.redhat.thermostat.common.NetworkInterfaceInfo;
+import com.redhat.thermostat.client.ui.HostOverviewController;
 import com.redhat.thermostat.common.dao.HostRef;
 
 public class HostPanelFacadeImpl implements HostPanelFacade {
 
     private final HostRef agent;
-    private final DBCollection hostInfoCollection;
-    private final DBCollection networkInfoCollection;
     private final DBCollection cpuStatsCollection;
     private final DBCollection memoryStatsCollection;
 
     private final ChangeableText hostName = new ChangeableText("");
-    private final ChangeableText osName = new ChangeableText("");
-    private final ChangeableText osKernel = new ChangeableText("");
     private final ChangeableText cpuModel = new ChangeableText("");
     private final ChangeableText cpuCount = new ChangeableText("");
     private final ChangeableText memoryTotal = new ChangeableText("");
-    private final DefaultTableModel networkTableModel = new DefaultTableModel();
-    private final Vector<String> networkTableColumnVector;
 
     private final TimeSeriesCollection cpuLoadTimeSeriesCollection = new TimeSeriesCollection();
     private final TimeSeries cpuLoadSeries = new TimeSeries("cpu-time");
@@ -92,22 +79,19 @@
 
     private Set<MemoryType> toDisplay = new HashSet<MemoryType>();
 
+    private final HostOverviewController overviewController;
+
     public HostPanelFacadeImpl(HostRef ref, DB db) {
         this.agent = ref;
 
-        hostInfoCollection = db.getCollection("host-info");
-        networkInfoCollection = db.getCollection("network-info");
         cpuStatsCollection = db.getCollection("cpu-stats");
         memoryStatsCollection = db.getCollection("memory-stats");
 
-        networkTableColumnVector = new Vector<String>();
-        networkTableColumnVector.add(localize(LocaleResources.NETWORK_INTERFACE_COLUMN));
-        networkTableColumnVector.add(localize(LocaleResources.NETWORK_IPV4_COLUMN));
-        networkTableColumnVector.add(localize(LocaleResources.NETWORK_IPV6_COLUMN));
-
         cpuLoadTimeSeriesCollection.addSeries(cpuLoadSeries);
 
         toDisplay.addAll(Arrays.asList(MemoryType.values()));
+
+        overviewController = new HostOverviewController(ref, db);
     }
 
     @Override
@@ -115,24 +99,19 @@
         backgroundUpdateTimer.scheduleAtFixedRate(new TimerTask() {
             @Override
             public void run() {
-                DBObject hostInfo = hostInfoCollection.findOne(new BasicDBObject("agent-id", agent.getAgentId()));
-                hostName.setText((String) hostInfo.get("hostname"));
-                osName.setText((String) hostInfo.get("os_name"));
-                osKernel.setText((String) hostInfo.get("os_kernel"));
-                cpuModel.setText((String) hostInfo.get("cpu_model"));
-                cpuCount.setText(((Integer) hostInfo.get("cpu_num")).toString());
-                memoryTotal.setText(((Long) hostInfo.get("memory_total")).toString());
-
-                doNetworkTableUpdateAsync();
 
                 doCpuChartUpdateAsync();
             }
         }, 0, TimeUnit.SECONDS.toMillis(5));
+
+        overviewController.start();
     }
 
     @Override
     public void stop() {
         backgroundUpdateTimer.cancel();
+
+        overviewController.stop();
     }
 
     @Override
@@ -151,83 +130,10 @@
     }
 
     @Override
-    public ChangeableText getOsKernel() {
-        return osKernel;
-    }
-
-    @Override
-    public ChangeableText getOsName() {
-        return osName;
-    }
-
-    @Override
     public ChangeableText getTotalMemory() {
         return memoryTotal;
     }
 
-    private NetworkInfo getNetworkInfo() {
-        NetworkInfo network = new NetworkInfo();
-        DBCursor cursor = networkInfoCollection.find(new BasicDBObject("agent-id", agent.getAgentId()));
-        while (cursor.hasNext()) {
-            DBObject iface = cursor.next();
-            NetworkInterfaceInfo info = new NetworkInterfaceInfo((String) iface.get("iface"));
-            if (iface.containsField("ipv4addr")) {
-                info.setIp4Addr((String) iface.get("ipv4addr"));
-            }
-            if (iface.containsField("ipv6addr")) {
-                info.setIp6Addr((String) iface.get("ipv6addr"));
-            }
-            network.addNetworkInterfaceInfo(info);
-        }
-
-        return network;
-    }
-
-    private void doNetworkTableUpdateAsync() {
-        new NetworkTableModelUpdater(this).execute();
-    }
-
-    private static class NetworkTableModelUpdater extends SwingWorker<NetworkInfo, Void> {
-
-        private HostPanelFacadeImpl facade;
-
-        public NetworkTableModelUpdater(HostPanelFacadeImpl facade) {
-            this.facade = facade;
-        }
-
-        @Override
-        protected NetworkInfo doInBackground() throws Exception {
-            return facade.getNetworkInfo();
-        }
-
-        @Override
-        protected void done() {
-            Vector<Vector<String>> data = new Vector<Vector<String>>();
-
-            NetworkInfo networkInfo;
-            try {
-                networkInfo = get();
-                for (NetworkInterfaceInfo info : networkInfo.getInterfaces()) {
-                    String ifaceName = info.getInterfaceName();
-                    String ipv4 = info.getIp4Addr();
-                    String ipv6 = info.getIp6Addr();
-                    data.add(new Vector<String>(Arrays.asList(new String[] { ifaceName, ipv4, ipv6 })));
-                }
-                facade.networkTableModel.setDataVector(data, facade.networkTableColumnVector);
-
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            } catch (ExecutionException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    @Override
-    public TableModel getNetworkTableModel() {
-        return networkTableModel;
-    }
-
     @Override
     public List<DiscreteTimeData<Long>> getMemoryUsage(MemoryType type) {
         List<DiscreteTimeData<Long>> data = new ArrayList<DiscreteTimeData<Long>>();
@@ -275,6 +181,11 @@
         return cpuLoadTimeSeriesCollection;
     }
 
+    @Override
+    public HostOverviewController getOverviewController() {
+        return overviewController;
+    }
+
     private void doCpuChartUpdateAsync() {
         CpuLoadChartUpdater updater = new CpuLoadChartUpdater(this);
         updater.execute();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/src/main/java/com/redhat/thermostat/client/ui/HostOverviewController.java	Thu Mar 08 16:56:58 2012 -0500
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2012 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.client.ui;
+
+import static com.redhat.thermostat.client.locale.Translate.localize;
+
+import java.awt.Component;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.Vector;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.swing.SwingWorker;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.redhat.thermostat.client.AsyncUiFacade;
+import com.redhat.thermostat.client.locale.LocaleResources;
+import com.redhat.thermostat.common.HostInfo;
+import com.redhat.thermostat.common.NetworkInfo;
+import com.redhat.thermostat.common.NetworkInterfaceInfo;
+import com.redhat.thermostat.common.dao.HostInfoConverter;
+import com.redhat.thermostat.common.dao.HostRef;
+import com.redhat.thermostat.common.dao.NetworkInterfaceInfoConverter;
+import com.redhat.thermostat.common.utils.LoggingUtils;
+
+public class HostOverviewController implements AsyncUiFacade {
+
+    private static final Logger logger = LoggingUtils.getLogger(HostOverviewController.class);
+
+    private final HostRef hostRef;
+    private final DBCollection hostInfoCollection;
+    private final DBCollection networkInfoCollection;
+
+    private final Timer backgroundUpdateTimer;
+
+    private final HostOverviewView view;
+
+    public HostOverviewController(HostRef ref, DB db) {
+        this.hostRef = ref;
+        hostInfoCollection = db.getCollection("host-info");
+        networkInfoCollection = db.getCollection("network-info");
+
+        final Vector<String> networkTableColumnVector;
+        networkTableColumnVector = new Vector<String>();
+        networkTableColumnVector.add(localize(LocaleResources.NETWORK_INTERFACE_COLUMN));
+        networkTableColumnVector.add(localize(LocaleResources.NETWORK_IPV4_COLUMN));
+        networkTableColumnVector.add(localize(LocaleResources.NETWORK_IPV6_COLUMN));
+
+        backgroundUpdateTimer = new Timer();
+        view = createView();
+
+        view.setNetworkTableColumns(networkTableColumnVector.toArray());
+    }
+
+    public HostOverviewView createView() {
+        return new HostOverviewPanel();
+    }
+
+    private void doNetworkTableUpdateAsync() {
+        new NetworkTableModelUpdater().execute();
+    }
+
+    private class NetworkTableModelUpdater extends SwingWorker<NetworkInfo, Void> {
+
+        @Override
+        protected NetworkInfo doInBackground() throws Exception {
+            return getNetworkInfo();
+        }
+
+        private NetworkInfo getNetworkInfo() {
+            NetworkInfo network = new NetworkInfo();
+            DBCursor cursor = networkInfoCollection.find(new BasicDBObject("agent-id", hostRef.getAgentId()));
+            while (cursor.hasNext()) {
+                NetworkInterfaceInfo info = new NetworkInterfaceInfoConverter().fromDBObject(cursor.next());
+                network.addNetworkInterfaceInfo(info);
+            }
+
+            return network;
+        }
+
+        @Override
+        protected void done() {
+            List<Object[]> data = new ArrayList<Object[]>();
+
+            NetworkInfo networkInfo;
+            try {
+                networkInfo = get();
+                for (NetworkInterfaceInfo info: networkInfo.getInterfaces()) {
+                    String ifaceName = info.getInterfaceName();
+                    String ipv4 = info.getIp4Addr();
+                    String ipv6 = info.getIp6Addr();
+                    data.add(new String[] { ifaceName, ipv4, ipv6 });
+                }
+                view.setNetworkTableData(data.toArray(new Object[0][0]));
+
+            } catch (InterruptedException ie) {
+                logger.log(Level.WARNING, "interrupted while updating network info", ie);
+                // preserve interrupted flag
+                Thread.currentThread().interrupt();
+            } catch (ExecutionException ee) {
+                logger.log(Level.WARNING, "error updating network info", ee);
+            }
+        }
+    }
+
+    @Override
+    public void start() {
+        backgroundUpdateTimer.scheduleAtFixedRate(new TimerTask() {
+            @Override
+            public void run() {
+
+                DBObject dbObj = hostInfoCollection.findOne(new BasicDBObject("agent-id", hostRef.getAgentId()));
+                HostInfo hostInfo = new HostInfoConverter().fromDBObj(dbObj);
+                view.setHostName(hostInfo.getHostname());
+                view.setOsName(hostInfo.getOsName());
+                view.setOsKernel(hostInfo.getOsKernel());
+                view.setCpuModel(hostInfo.getCpuModel());
+                view.setCpuCount(String.valueOf(hostInfo.getCpuCount()));
+                view.setTotalMemory(String.valueOf(hostInfo.getTotalMemory()));
+
+                doNetworkTableUpdateAsync();
+            }
+        }, 0, TimeUnit.SECONDS.toMillis(5));
+
+    }
+
+    @Override
+    public void stop() {
+        backgroundUpdateTimer.cancel();
+    }
+
+    public Component getComponent() {
+        return view.getUiComponent();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/src/main/java/com/redhat/thermostat/client/ui/HostOverviewPanel.java	Thu Mar 08 16:56:58 2012 -0500
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2012 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.client.ui;
+
+import static com.redhat.thermostat.client.locale.Translate.localize;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JPanel;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableModel;
+
+import com.redhat.thermostat.client.ChangeableText;
+import com.redhat.thermostat.client.locale.LocaleResources;
+import com.redhat.thermostat.client.ui.SimpleTable.Key;
+import com.redhat.thermostat.client.ui.SimpleTable.Section;
+import com.redhat.thermostat.client.ui.SimpleTable.TableEntry;
+import com.redhat.thermostat.client.ui.SimpleTable.Value;
+
+public class HostOverviewPanel implements HostOverviewView {
+
+    private final ChangeableText hostname;
+    private final ChangeableText cpuModel;
+    private final ChangeableText cpuCount;
+    private final ChangeableText totalMemory;
+    private final ChangeableText osName;
+    private final ChangeableText osKernel;
+
+    private final DefaultTableModel networkTableModel;
+    private Object[] networkTableColumns;
+    private Object[][] networkTableData;
+
+    public HostOverviewPanel() {
+        hostname = new ChangeableText("");
+        cpuModel = new ChangeableText("");
+        cpuCount = new ChangeableText("");
+        totalMemory = new ChangeableText("");
+        osName = new ChangeableText("");
+        osKernel = new ChangeableText("");
+
+        networkTableModel = new DefaultTableModel();
+    }
+
+    @Override
+    public void setHostName(String newHostName) {
+        hostname.setText(newHostName);
+    }
+
+    @Override
+    public void setCpuModel(String newCpuModel) {
+        cpuModel.setText(newCpuModel);
+    }
+
+    @Override
+    public void setCpuCount(String newCpuCount) {
+        cpuCount.setText(newCpuCount);
+    }
+
+    @Override
+    public void setTotalMemory(String newTotalMemory) {
+        totalMemory.setText(newTotalMemory);
+    }
+
+    @Override
+    public void setOsName(String newOsName) {
+        osName.setText(newOsName);
+    }
+
+    @Override
+    public void setOsKernel(String newOsKernel) {
+        osKernel.setText(newOsKernel);
+    }
+
+    @Override
+    public void setNetworkTableColumns(Object[] columns) {
+        this.networkTableColumns = columns;
+        networkTableModel.setDataVector(this.networkTableData, this.networkTableColumns);
+    }
+
+    @Override
+    public void setNetworkTableData(Object[][] data) {
+        this.networkTableData = data;
+        networkTableModel.setDataVector(this.networkTableData, this.networkTableColumns);
+    }
+
+    @Override
+    public Component getUiComponent() {
+
+        TableEntry entry;
+        List<Section> allSections = new ArrayList<Section>();
+
+        Section basics = new Section(localize(LocaleResources.HOST_OVERVIEW_SECTION_BASICS));
+        allSections.add(basics);
+
+        entry = new TableEntry(localize(LocaleResources.HOST_INFO_HOSTNAME), hostname);
+        basics.add(entry);
+
+        Section hardware = new Section(localize(LocaleResources.HOST_OVERVIEW_SECTION_HARDWARE));
+        allSections.add(hardware);
+
+        entry = new TableEntry(localize(LocaleResources.HOST_INFO_CPU_MODEL), cpuModel);
+        hardware.add(entry);
+        entry = new TableEntry(localize(LocaleResources.HOST_INFO_CPU_COUNT), cpuCount);
+        hardware.add(entry);
+        entry = new TableEntry(localize(LocaleResources.HOST_INFO_MEMORY_TOTAL), totalMemory);
+        hardware.add(entry);
+
+        JTable networkTable = new JTable(networkTableModel);
+
+        JPanel networkPanel = new JPanel(new BorderLayout());
+        networkPanel.add(networkTable.getTableHeader(), BorderLayout.PAGE_START);
+        networkPanel.add(networkTable, BorderLayout.CENTER);
+
+        Key key = new Key(localize(LocaleResources.HOST_INFO_NETWORK));
+        hardware.add(new TableEntry(key, new Value(networkPanel)));
+
+        Section software = new Section(localize(LocaleResources.HOST_OVERVIEW_SECTION_SOFTWARE));
+        allSections.add(software);
+
+        entry = new TableEntry(localize(LocaleResources.HOST_INFO_OS_NAME), osName);
+        software.add(entry);
+        entry = new TableEntry(localize(LocaleResources.HOST_INFO_OS_KERNEL), osKernel);
+        software.add(entry);
+
+        SimpleTable simpleTable = new SimpleTable();
+        JPanel table = simpleTable.createTable(allSections);
+        table.setBorder(Components.smallBorder());
+        return table;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/client/src/main/java/com/redhat/thermostat/client/ui/HostOverviewView.java	Thu Mar 08 16:56:58 2012 -0500
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2012 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.client.ui;
+
+import java.awt.Component;
+
+public interface HostOverviewView {
+
+    void setHostName(String newHostName);
+
+    void setCpuModel(String newCpuModel);
+
+    void setCpuCount(String newCpuCount);
+
+    void setTotalMemory(String newTotalMemory);
+
+    void setOsName(String newOsName);
+
+    void setOsKernel(String newOsKernel);
+
+    void setNetworkTableColumns(Object[] columns);
+
+    void setNetworkTableData(Object[][] table);
+
+    Component getUiComponent();
+
+}
--- a/client/src/main/java/com/redhat/thermostat/client/ui/HostPanel.java	Wed Mar 07 16:34:26 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/ui/HostPanel.java	Thu Mar 08 16:56:58 2012 -0500
@@ -51,7 +51,6 @@
 import javax.swing.JCheckBox;
 import javax.swing.JPanel;
 import javax.swing.JTabbedPane;
-import javax.swing.JTable;
 
 import org.jfree.chart.ChartFactory;
 import org.jfree.chart.ChartPanel;
@@ -64,10 +63,8 @@
 import com.redhat.thermostat.client.HostPanelFacade;
 import com.redhat.thermostat.client.MemoryType;
 import com.redhat.thermostat.client.locale.LocaleResources;
-import com.redhat.thermostat.client.ui.SimpleTable.Key;
 import com.redhat.thermostat.client.ui.SimpleTable.Section;
 import com.redhat.thermostat.client.ui.SimpleTable.TableEntry;
-import com.redhat.thermostat.client.ui.SimpleTable.Value;
 
 public class HostPanel extends JPanel {
 
@@ -92,7 +89,7 @@
 
         JTabbedPane tabPane = new JTabbedPane();
 
-        tabPane.insertTab(localize(LocaleResources.HOST_INFO_TAB_OVERVIEW), null, createOverviewPanel(), null, 0);
+        tabPane.insertTab(localize(LocaleResources.HOST_INFO_TAB_OVERVIEW), null, facade.getOverviewController().getComponent(), null, 0);
         tabPane.insertTab(localize(LocaleResources.HOST_INFO_TAB_CPU), null, createCpuStatisticsPanel(), null, 1);
         tabPane.insertTab(localize(LocaleResources.HOST_INFO_TAB_MEMORY), null, createMemoryStatisticsPanel(), null, 2);
 
@@ -103,50 +100,6 @@
 
     }
 
-    private JPanel createOverviewPanel() {
-
-        TableEntry entry;
-        List<Section> allSections = new ArrayList<Section>();
-
-        Section basics = new Section(localize(LocaleResources.HOST_OVERVIEW_SECTION_BASICS));
-        allSections.add(basics);
-
-        entry = new TableEntry(localize(LocaleResources.HOST_INFO_HOSTNAME), facade.getHostName());
-        basics.add(entry);
-
-        Section hardware = new Section(localize(LocaleResources.HOST_OVERVIEW_SECTION_HARDWARE));
-        allSections.add(hardware);
-
-        entry = new TableEntry(localize(LocaleResources.HOST_INFO_CPU_MODEL), facade.getCpuModel());
-        hardware.add(entry);
-        entry = new TableEntry(localize(LocaleResources.HOST_INFO_CPU_COUNT), facade.getCpuCount());
-        hardware.add(entry);
-        entry = new TableEntry(localize(LocaleResources.HOST_INFO_MEMORY_TOTAL), facade.getTotalMemory());
-        hardware.add(entry);
-
-        JTable networkTable = new JTable(facade.getNetworkTableModel());
-
-        JPanel networkPanel = new JPanel(new BorderLayout());
-        networkPanel.add(networkTable.getTableHeader(), BorderLayout.PAGE_START);
-        networkPanel.add(networkTable, BorderLayout.CENTER);
-
-        Key key = new Key(localize(LocaleResources.HOST_INFO_NETWORK));
-        hardware.add(new TableEntry(key, new Value(networkPanel)));
-
-        Section software = new Section(localize(LocaleResources.HOST_OVERVIEW_SECTION_SOFTWARE));
-        allSections.add(software);
-
-        entry = new TableEntry(localize(LocaleResources.HOST_INFO_OS_NAME), facade.getOsName());
-        software.add(entry);
-        entry = new TableEntry(localize(LocaleResources.HOST_INFO_OS_KERNEL), facade.getOsKernel());
-        software.add(entry);
-
-        SimpleTable simpleTable = new SimpleTable();
-        JPanel table = simpleTable.createTable(allSections);
-        table.setBorder(Components.smallBorder());
-        return table;
-    }
-
     private JPanel createCpuStatisticsPanel() {
 
         JPanel contentArea = new JPanel();
--- a/common/src/main/java/com/redhat/thermostat/common/dao/HostInfoConverter.java	Wed Mar 07 16:34:26 2012 -0500
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/HostInfoConverter.java	Thu Mar 08 16:56:58 2012 -0500
@@ -36,6 +36,7 @@
 
 package com.redhat.thermostat.common.dao;
 
+import com.mongodb.DBObject;
 import com.redhat.thermostat.common.HostInfo;
 import com.redhat.thermostat.common.storage.Chunk;
 
@@ -52,4 +53,14 @@
         return chunk;
     }
 
+    public HostInfo fromDBObj(DBObject dbObj) {
+        String hostName = (String) dbObj.get("hostname");
+        String osName = (String) dbObj.get("os_name");
+        String osKernel = (String) dbObj.get("os_kernel");
+        String cpuModel = (String) dbObj.get("cpu_model");
+        Integer cpuNum = (Integer) dbObj.get("cpu_num");
+        Long totalMemory = (Long) dbObj.get("memory_total");
+        return new HostInfo(hostName, osName, osKernel, cpuModel, cpuNum, totalMemory);
+    }
+
 }
--- a/common/src/main/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoConverter.java	Wed Mar 07 16:34:26 2012 -0500
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoConverter.java	Thu Mar 08 16:56:58 2012 -0500
@@ -36,6 +36,7 @@
 
 package com.redhat.thermostat.common.dao;
 
+import com.mongodb.DBObject;
 import com.redhat.thermostat.common.NetworkInterfaceInfo;
 import com.redhat.thermostat.common.storage.Chunk;
 
@@ -55,4 +56,14 @@
         return chunk;
     }
 
+    public NetworkInterfaceInfo fromDBObject(DBObject obj) {
+        NetworkInterfaceInfo info = new NetworkInterfaceInfo((String) obj.get("iface"));
+        if (obj.containsField("ipv4addr")) {
+            info.setIp4Addr((String) obj.get("ipv4addr"));
+        }
+        if (obj.containsField("ipv6addr")) {
+            info.setIp6Addr((String) obj.get("ipv6addr"));
+        }
+        return info;
+    }
 }
--- a/common/src/test/java/com/redhat/thermostat/common/dao/HostInfoConverterTest.java	Wed Mar 07 16:34:26 2012 -0500
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/HostInfoConverterTest.java	Thu Mar 08 16:56:58 2012 -0500
@@ -37,9 +37,11 @@
 package com.redhat.thermostat.common.dao;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import org.junit.Test;
 
+import com.mongodb.BasicDBObject;
 import com.redhat.thermostat.common.HostInfo;
 import com.redhat.thermostat.common.storage.Chunk;
 import com.redhat.thermostat.common.storage.Key;
@@ -60,4 +62,33 @@
         assertEquals((Integer)9, chunk.get(new Key<Integer>("cpu_num", false)));
         assertEquals((Long) 99L, chunk.get(new Key<Long>("memory_total", false)));
     }
+
+    @Test
+    public void testDBObjecToHostInfo() {
+        final String HOST_NAME = "a host name";
+        final String OS_NAME = "some os";
+        final String OS_KERNEL = "some kernel";
+        final String CPU_MODEL = "some cpu that runs fast";
+        final int CPU_NUM = -1;
+        final long MEMORY_TOTAL = 0xCAFEBABEl;
+
+        BasicDBObject dbObj = new BasicDBObject();
+        dbObj.put("hostname", HOST_NAME);
+        dbObj.put("os_name", OS_NAME);
+        dbObj.put("os_kernel", OS_KERNEL);
+        dbObj.put("cpu_model", CPU_MODEL);
+        dbObj.put("cpu_num", CPU_NUM);
+        dbObj.put("memory_total", MEMORY_TOTAL);
+
+        HostInfo info = new HostInfoConverter().fromDBObj(dbObj);
+        assertNotNull(info);
+        assertEquals(HOST_NAME, info.getHostname());
+        assertEquals(OS_NAME, info.getOsName());
+        assertEquals(OS_KERNEL, info.getOsKernel());
+        assertEquals(CPU_MODEL, info.getCpuModel());
+        assertEquals(CPU_NUM, info.getCpuCount());
+        assertEquals(MEMORY_TOTAL, info.getTotalMemory());
+
+    }
+
 }
--- a/common/src/test/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoConverterTest.java	Wed Mar 07 16:34:26 2012 -0500
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoConverterTest.java	Thu Mar 08 16:56:58 2012 -0500
@@ -37,9 +37,11 @@
 package com.redhat.thermostat.common.dao;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import org.junit.Test;
 
+import com.mongodb.BasicDBObject;
 import com.redhat.thermostat.common.NetworkInterfaceInfo;
 import com.redhat.thermostat.common.storage.Chunk;
 import com.redhat.thermostat.common.storage.Key;
@@ -60,4 +62,23 @@
         assertEquals("6", chunk.get(new Key<String>("ipv6addr", false)));
 
     }
+
+    @Test
+    public void testDBObjectToNetworkInfo() {
+        final String INTERFACE_NAME = "some interface. maybe eth0";
+        final String IPV4_ADDR = "256.256.256.256";
+        final String IPV6_ADDR = "100:100:100::::1";
+
+        BasicDBObject dbObj = new BasicDBObject();
+        dbObj.put("iface", INTERFACE_NAME);
+        dbObj.put("ipv4addr", IPV4_ADDR);
+        dbObj.put("ipv6addr", IPV6_ADDR);
+
+        NetworkInterfaceInfo info = new NetworkInterfaceInfoConverter().fromDBObject(dbObj);
+        assertNotNull(info);
+        assertEquals(INTERFACE_NAME, info.getInterfaceName());
+        assertEquals(IPV4_ADDR, info.getIp4Addr());
+        assertEquals(IPV6_ADDR, info.getIp6Addr());
+    }
+
 }