Hi,
i want to develop a webpage with vaadin, where i monitor some devices. I have an API where i get the current state of each device and i want to write changes to labels with server push.
Now i just tried with 100 devices shutting down and starting up. As the startup and shut down time depends on many cicumstances all devices have different times.
When i shut down / start up all devices at once the browser (tried on chrome and on firefox both current versions) starts to freeze when there are many server push actions going on to change the text of the labels.
Heres my code (a bit simplified):
for (int i = 0; i < wall.getRows(); i++){
for (int j = 0; j < wall.getCols(); j++){
Device device = wall.getDevice(i, j);
Label label = new Label();
if (device.isSwitchedOn()){
label.setValue("ON ");
} else {
label.setValue("OFF ");
}
labelMap.put(module.toString(), label);
grid.addComponent(label);
}
}
}
The code above just creates the table with all devices in the beginning. This works pretty well. I save all the labels in a hashmap so i can access them pretty fast without reading them from the dom tree.
Heres what i do when a state changes:
public void devicePropChanged(final Device device, final String aPropertyName) {
if (!aPropertyName.equals("strOperationState")) {
return;
}
access(new Runnable() {
@Override
public void run() {
Label label = labelMap.get(device.toString());
if (device.isSwitchedOn()){
label.setValue("ON");
} else {
label.setValue("OFF");
}
}
});
Am i doing something wrong here? Any help would be appreciated.
Thanks!