-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHE-1361 Artik: Resources monitor (CPU, memory and storage)
Signed-off-by: Vitaliy Guliy <[email protected]>
- Loading branch information
Vitaliy Guliy
committed
Jul 25, 2016
1 parent
ff31a1e
commit 8c977b5
Showing
13 changed files
with
510 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
...va/org/eclipse/che/ide/extension/machine/client/processes/monitoring/MachineMonitors.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2016 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.ide.extension.machine.client.processes.monitoring; | ||
|
||
import com.google.inject.Singleton; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Manages and provides widgets for displaying CPU, memory and disk usages for the machines. | ||
* | ||
* @author Vitaliy Guliy | ||
*/ | ||
@Singleton | ||
public class MachineMonitors { | ||
|
||
private Map<String, Map<Object, MonitorWidget>> monitorWidgets = new HashMap<>(); | ||
|
||
/** | ||
* Creates new or returns existed widget for the given machine and referrer. | ||
* Referrer is an UI object containing monitor widgets attached as children. | ||
* | ||
* @param machineID | ||
* machines ID | ||
* @param referrer | ||
* referrer object | ||
* @return | ||
* monitor widget | ||
*/ | ||
public MonitorWidget getMonitorWidget(String machineID, Object referrer) { | ||
Map<Object, MonitorWidget> widgets = monitorWidgets.get(machineID); | ||
if (widgets == null) { | ||
widgets = new HashMap<>(); | ||
monitorWidgets.put(machineID, widgets); | ||
} | ||
|
||
MonitorWidget widget = widgets.get(referrer); | ||
if (widget == null) { | ||
widget = new MonitorWidget(); | ||
widgets.put(referrer, widget); | ||
} | ||
|
||
return widget; | ||
} | ||
|
||
/** | ||
* Sets new CPU usage value for machine with given ID. | ||
* | ||
* @param machineID | ||
* machine ID | ||
* @param cpuUsage | ||
* new cpu usage | ||
*/ | ||
public void setCpuUsage(String machineID, int cpuUsage) { | ||
Map<Object, MonitorWidget> widgets = monitorWidgets.get(machineID); | ||
if (widgets != null) { | ||
for (MonitorWidget widget : widgets.values()) { | ||
widget.setCpuUsage(cpuUsage); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Sets new memory usage value for machine with given ID. | ||
* | ||
* @param machineID | ||
* machine ID | ||
* @param mem | ||
* new memory usage | ||
* @param max | ||
* maximum amount of memory | ||
*/ | ||
public void setMemoryUsage(String machineID, int mem, int max) { | ||
Map<Object, MonitorWidget> widgets = monitorWidgets.get(machineID); | ||
if (widgets != null) { | ||
for (MonitorWidget widget : widgets.values()) { | ||
widget.setMemoryUsage(mem, max); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Sets new disk usage value for machine with given ID. | ||
* | ||
* @param machineID | ||
* machine ID | ||
* @param disk | ||
* new disk usage | ||
* @param max | ||
* maximum amount of disk space | ||
*/ | ||
public void setDiskUsage(String machineID, int disk, int max) { | ||
Map<Object, MonitorWidget> widgets = monitorWidgets.get(machineID); | ||
if (widgets != null) { | ||
for (MonitorWidget widget : widgets.values()) { | ||
widget.setDiskUsage(disk, max); | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.