Skip to content
Snippets Groups Projects
Commit a8c472c1 authored by Bjoern Weissenfels's avatar Bjoern Weissenfels
Browse files

last 100 records stored in DataBean instead of RecordListBean

parent fe268692
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,10 @@ public class DataBean extends Observable{
LinkedList<Record> records;
List<Record> newRecords;
List<Record> lastRecords;
int numberOfRecords = 100;
LinkedList<CPUUtilizationRecord> cpuList;
List<CPUUtilizationRecord> newCpuEntries;
LinkedList<MemSwapUsageRecord> memSwapList;
......@@ -49,12 +53,17 @@ public class DataBean extends Observable{
this.memSwapList = new LinkedList<MemSwapUsageRecord>();
this.newMemSwapEntries = new LinkedList<MemSwapUsageRecord>();
this.newRecords = new LinkedList<Record>();
this.lastRecords = new LinkedList<Record>();
}
public void setStartingBean(StartingBean startingBean){
this.startingBean = startingBean;
}
public List<Record> getLastRecords(){
return this.lastRecords;
}
public LinkedList<Record> getOERList(){
return this.records;
}
......@@ -127,6 +136,14 @@ public class DataBean extends Observable{
// update recordList
this.records.addAll(newRecords);
// update last 100 entries
for(int i=0; i < newRecords.size(); i++){
this.lastRecords.add(0, newRecords.get(i));
}
if(this.lastRecords.size() > this.numberOfRecords){
this.lastRecords.subList(this.numberOfRecords, this.lastRecords.size()).clear();
}
// remove old records
if(!this.records.isEmpty()){
long currentTime = System.currentTimeMillis() * 1000000;
......
package livedemo.managedbeans;
import java.util.LinkedList;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
......@@ -17,10 +12,8 @@ import livedemo.entities.Record;
*/
@ManagedBean(name="recordBean", eager=true)
@SessionScoped
public class RecordListBean implements Observer{
public class RecordListBean{
int displayedRecords = 100;
List<Record> lastRecords;
boolean firstCall;
boolean freeze;
String freezeButton;
......@@ -29,18 +22,12 @@ public class RecordListBean implements Observer{
DataBean dataBean;
public RecordListBean(){
this.lastRecords = new LinkedList<Record>();
this.firstCall = true;
this.freeze = false;
this.freezeButton = "freeze";
this.updateForm = "rec";
}
@PostConstruct
public void init() {
this.dataBean.addObserver(this);
}
public String freeze(){
if(this.freeze){
this.freeze = false;
......@@ -68,35 +55,7 @@ public class RecordListBean implements Observer{
public List<Record> getRecords(){
this.dataBean.updateOERList();
return this.lastRecords;
}
@Override
public void update(Observable arg0, Object message) {
if("oer".equals(message)){
if(this.firstCall){
List<Record> tmp = this.dataBean.getOERList();
int size = tmp.size();
if(size > this.displayedRecords){
for(int i=1; i <= this.displayedRecords; i++){
this.lastRecords.add(tmp.get(size - i));
}
}else{
for(int i=1; i <= size; i++){
this.lastRecords.add(tmp.get(size - i));
}
}
this.firstCall = false;
}else{
List<Record> tmp = this.dataBean.getNewOEREntries();
for(int i=0; i < tmp.size(); i++){
this.lastRecords.add(0, tmp.get(i));
}
if(this.lastRecords.size() > this.displayedRecords){
this.lastRecords.subList(this.displayedRecords, this.lastRecords.size()).clear();
}
}
}
return this.dataBean.getLastRecords();
}
}
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment