[ 
https://issues.apache.org/jira/browse/SOLR-3148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14060502#comment-14060502
 ] 

Thomas Mueller commented on SOLR-3148:
--------------------------------------

FYI I faced the same problem, but found a different solution. I think the 
problem is that you need to get the method on the interface 
(com.sun.management.OperatingSystemMXBean), not on the class 
(sun.management.OperatingSystemImpl). That way, setAccessible(true) is not 
needed. This works for me:

{noformat}
OperatingSystemMXBean mxBean = ManagementFactory.
    getOperatingSystemMXBean();
Method method = Class.forName(
    "com.sun.management.OperatingSystemMXBean").
    getMethod("getTotalPhysicalMemorySize");
long physicalMemorySize = (Long) method.invoke(mxBean);       
{noformat}


> SystemInfoHandler does not expose all available info
> ----------------------------------------------------
>
>                 Key: SOLR-3148
>                 URL: https://issues.apache.org/jira/browse/SOLR-3148
>             Project: Solr
>          Issue Type: Bug
>    Affects Versions: 3.6, 4.0-ALPHA
>            Reporter: Sami Siren
>            Assignee: Sami Siren
>            Priority: Minor
>             Fix For: 3.6, 4.0-ALPHA
>
>
> The following info is not returned even when they are available (on java 1.6 
> and 1.7): 
> {code}
> getSystemLoadAverage()
> getOpenFileDescriptorCount()
> getMaxFileDescriptorCount()
> getCommittedVirtualMemorySize()
> getTotalPhysicalMemorySize()
> getTotalSwapSpaceSize()
> getProcessCpuTime()
> {code}
> This is happening because the following exception is thrown: 
> {code}
> java.lang.IllegalAccessException: Class 
> org.apache.solr.handler.admin.SystemInfoHandler can not access a member of 
> class com.sun.management.UnixOperatingSystem with modifiers "public native"
> {code}
> It seems to be enough to call setAccessible(true) on the method to get rid of 
> that exception.
> Additionally I see a strange value for the ulimit key:
> "ulimit":"(error executing: ulimit -n)",



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to