-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
息羽
committed
Feb 22, 2016
1 parent
d4fa6dc
commit 5eba7d1
Showing
14 changed files
with
740 additions
and
198 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* | ||
* Copyright 2015 The Darks Grid Project (Liu lihua) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package darks.grid; | ||
|
||
public class GridConstant { | ||
|
||
public static final String CFG_MACHINE_FACTORY = "machine.info.factory"; | ||
|
||
} |
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
56 changes: 56 additions & 0 deletions
56
src/main/java/darks/grid/commons/BlankMachineInfoFactory.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,56 @@ | ||
/** | ||
* | ||
* Copyright 2015 The Darks Grid Project (Liu lihua) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package darks.grid.commons; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import darks.grid.beans.MachineInfo; | ||
import darks.grid.beans.NodeHealth; | ||
|
||
public class BlankMachineInfoFactory extends MachineInfoFactory | ||
{ | ||
private static final Logger log = LoggerFactory.getLogger(BlankMachineInfoFactory.class); | ||
|
||
|
||
public BlankMachineInfoFactory() | ||
{ | ||
log.info("Create blank machine info factory"); | ||
} | ||
|
||
@Override | ||
public MachineInfo createMachineInfo() | ||
{ | ||
MachineInfo info = new MachineInfo(); | ||
return updateMachineInfo(info); | ||
} | ||
|
||
@Override | ||
public MachineInfo updateMachineInfo(MachineInfo info) | ||
{ | ||
long maxMemory = Runtime.getRuntime().maxMemory(); | ||
long totalMemory = Runtime.getRuntime().totalMemory(); | ||
long freeMemory = Runtime.getRuntime().freeMemory(); | ||
info.setUsedMaxMemoryUsage((float) ((double) (maxMemory - freeMemory) / (double) maxMemory)); | ||
info.setUsedTotalMemoryUsage((float) ((double) (totalMemory - freeMemory) / (double) totalMemory)); | ||
info.setProcessCpuUsage(-1f); | ||
info.setSystemCpuUsage(-1f); | ||
info.setHealthyScore(NodeHealth.evaluateLocal(info)); | ||
return info; | ||
} | ||
|
||
} |
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
Oops, something went wrong.