congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
SystemInfoFactory
Code IndexAdd Tabnine to your IDE (free)

How to use
SystemInfoFactory
in
org.rhq.core.system

Best Java code snippets using org.rhq.core.system.SystemInfoFactory (Showing top 20 results out of 315)

origin: org.rhq/rhq-core-plugin-container

private List<ProcessInfo> getProcessInfos() {
  SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();
  log.debug("Retrieving process table...");
  long startTime = System.currentTimeMillis();
  List<ProcessInfo> processInfos = null;
  try {
    processInfos = systemInfo.getAllProcesses();
  } catch (UnsupportedOperationException uoe) {
    log.debug("Cannot perform process scan - not supported on this platform. (" + systemInfo.getClass() + ")");
  }
  long elapsedTime = System.currentTimeMillis() - startTime;
  if (log.isDebugEnabled()) {
    log.debug("Retrieval of process table took " + elapsedTime + " ms.");
  }
  return processInfos;
}
origin: org.rhq/rhq-core-plugin-container

/**
 * Enables or disables the native layer.
 * @param tokens tokenized command line tokens[0] is the command itself
 */
private void doNative(String[] tokens) {
  String what = tokens[1];
  if (what.startsWith("e")) {
    SystemInfoFactory.enableNativeSystemInfo();
    System.out.println("Native layer enabled.");
  } else if (what.startsWith("d")) {
    SystemInfoFactory.disableNativeSystemInfo();
    System.out.println("Native layer disabled.");
  } else if (what.startsWith("s")) {
    System.out.println("Native layer is:");
    System.out.println(SystemInfoFactory.isNativeSystemInfoDisabled() ? "Disabled" : "Enabled");
    if (!SystemInfoFactory.isNativeSystemInfoDisabled()) {
      System.out.println(SystemInfoFactory.isNativeSystemInfoAvailable() ? "Available" : "Not Available");
      System.out.println(SystemInfoFactory.isNativeSystemInfoInitialized() ? "Initialized" : "Not initialized");
    }
  } else {
    System.err.println("Unknown option. Only 'e', 'd' and 's' are applicable (enable/disable/status)");
    return;
  }
}
origin: org.rhq/rhq-core-native-system

public ProcessExecutionResults executeProcess(ProcessExecution processExecution) {
  // TODO: doesn't look like SIGAR has an API to fork/execute processes? fallback to using the Java way
  return SystemInfoFactory.createJavaSystemInfo().executeProcess(processExecution);
}
origin: org.rhq/rhq-core-native-system

public static boolean isSigarAvailable() {
  if (!SystemInfoFactory.isNativeSystemInfoDisabled() && SystemInfoFactory.isNativeSystemInfoAvailable()) {
    // its available, but it may not yet have been initialized. If it has not been initialized,
    // make a call that forces it to be initialized and loaded. 99% of the time, the native layer
    // will already be initialized and this check will be very fast.
    if (!SystemInfoFactory.isNativeSystemInfoInitialized()) {
      SystemInfoFactory.getNativeSystemInfoVersion();
    }
    return true;
  } else {
    return false;
  }
}
origin: rhq-project/rhq

/**
 * If the native system is both {@link #isNativeSystemInfoAvailable() available} and
 * {@link #isNativeSystemInfoDisabled() enabled}, this will return the native system's version string. Otherwise, a
 * generic Java version message is returned.
 *
 * @return native system version string
 */
public static synchronized String getNativeSystemInfoVersion() {
  String version = null;
  Throwable error = null;
  initialize(); // make sure we've loaded the native libraries, if appropriate
  if (!isNativeSystemInfoDisabled() && isNativeSystemInfoAvailable()) {
    try {
      version = "Version=" + invokeApi(NativeApi.VERSION_STRING) + " (" + invokeApi(NativeApi.BUILD_DATE)
        + "); Native version=" + invokeApi(NativeApi.NATIVE_VERSION_STRING) + " ("
        + invokeApi(NativeApi.NATIVE_BUILD_DATE) + ")";
    } catch (Throwable t) {
      error = t;
    }
  }
  if (version == null) {
    version = "Native system not supported - Java version is " + System.getProperty("java.version");
    if (error != null) {
      version += " : " + error;
    }
  }
  return version;
}
origin: rhq-project/rhq

/**
 * Returns the appropriate {@link SystemInfo} implementation based on the platform/operating system the JVM is
 * running on.
 *
 * @return a {@link NativeSystemInfo} implementation or a {@link JavaSystemInfo} if the native libraries are
 *         {@link #isNativeSystemInfoAvailable() not available for the platform} or have been
 *         {@link #disableNativeSystemInfo() disabled}.
 */
public static synchronized SystemInfo createSystemInfo() {
  if (cachedSystemInfo == null) {
    initialize(); // make sure we've loaded the native libraries, if appropriate
    SystemInfo nativePlatform = null;
    if (!isNativeSystemInfoDisabled() && isNativeSystemInfoAvailable()) {
      // we could use SIGAR here, but this should be enough
      if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
        nativePlatform = new WindowsNativeSystemInfo();
      } else {
        // we either don't know what OS it is or we don't have a specific native subclass for it;
        // but we know we have a native library for it! so just create the generic NativePlatform to represent it.
        nativePlatform = new NativeSystemInfo();
      }
    }
    if (nativePlatform == null) {
      nativePlatform = javaSystemInfo;
    }
    cachedSystemInfo = nativePlatform;
  }
  return cachedSystemInfo;
}
origin: rhq-project/rhq

if (!isNativeSystemInfoDisabled()) {
  try {
    Class<?> clazz = Class.forName(NATIVE_LIBRARY_CLASS_NAME);
    nativeApis.put(NativeApi.NATIVE_BUILD_DATE, clazz.getField(NativeApi.NATIVE_BUILD_DATE.name()));
    invokeApi(NativeApi.load);
origin: org.rhq/rhq-core-native-system

public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  if (SystemInfoFactory.isNativeSystemInfoDisabled()) {
    throw new SystemInfoException("Native system has been disabled");
origin: rhq-project/rhq

URL jarLocation;
if (isNativeSystemInfoAvailable()) {
  rootDir = System.getProperty("rhq.native-libraries-root-directory");
  if (rootDir == null) {
origin: org.rhq/rhq-cassandra-ccm-core

public CassandraClusterManager(DeploymentOptions deploymentOptions) {
  // Disabling native layer because according to
  // https://docs.jboss.org/author/display/MODULES/Native+Libraries more work than I
  // prefer is needed in order to properly deploy sigar's native libraries. We do not
  // need the native layer as we are only using the rhq-core-native-system apis for
  // starting cassandra nodes.
  //
  // jsanda
  SystemInfoFactory.disableNativeSystemInfo();
  this.deploymentOptions = deploymentOptions;
  try {
    this.deploymentOptions.load();
  } catch (IOException e) {
    log.error("Failed to load deployment options", e);
    throw new IllegalStateException("An initialization error occurred.", e);
  }
}
origin: rhq-project/rhq

public static boolean isSigarAvailable() {
  if (!SystemInfoFactory.isNativeSystemInfoDisabled() && SystemInfoFactory.isNativeSystemInfoAvailable()) {
    // its available, but it may not yet have been initialized. If it has not been initialized,
    // make a call that forces it to be initialized and loaded. 99% of the time, the native layer
    // will already be initialized and this check will be very fast.
    if (!SystemInfoFactory.isNativeSystemInfoInitialized()) {
      SystemInfoFactory.getNativeSystemInfoVersion();
    }
    return true;
  } else {
    return false;
  }
}
origin: org.rhq/rhq-core-native-system

/**
 * If the native system is both {@link #isNativeSystemInfoAvailable() available} and
 * {@link #isNativeSystemInfoDisabled() enabled}, this will return the native system's version string. Otherwise, a
 * generic Java version message is returned.
 *
 * @return native system version string
 */
public static synchronized String getNativeSystemInfoVersion() {
  String version = null;
  Throwable error = null;
  initialize(); // make sure we've loaded the native libraries, if appropriate
  if (!isNativeSystemInfoDisabled() && isNativeSystemInfoAvailable()) {
    try {
      version = "Version=" + invokeApi(NativeApi.VERSION_STRING) + " (" + invokeApi(NativeApi.BUILD_DATE)
        + "); Native version=" + invokeApi(NativeApi.NATIVE_VERSION_STRING) + " ("
        + invokeApi(NativeApi.NATIVE_BUILD_DATE) + ")";
    } catch (Throwable t) {
      error = t;
    }
  }
  if (version == null) {
    version = "Native system not supported - Java version is " + System.getProperty("java.version");
    if (error != null) {
      version += " : " + error;
    }
  }
  return version;
}
origin: org.rhq/rhq-core-native-system

/**
 * Returns the appropriate {@link SystemInfo} implementation based on the platform/operating system the JVM is
 * running on.
 *
 * @return a {@link NativeSystemInfo} implementation or a {@link JavaSystemInfo} if the native libraries are
 *         {@link #isNativeSystemInfoAvailable() not available for the platform} or have been
 *         {@link #disableNativeSystemInfo() disabled}.
 */
public static synchronized SystemInfo createSystemInfo() {
  if (cachedSystemInfo == null) {
    initialize(); // make sure we've loaded the native libraries, if appropriate
    SystemInfo nativePlatform = null;
    if (!isNativeSystemInfoDisabled() && isNativeSystemInfoAvailable()) {
      // we could use SIGAR here, but this should be enough
      if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
        nativePlatform = new WindowsNativeSystemInfo();
      } else {
        // we either don't know what OS it is or we don't have a specific native subclass for it;
        // but we know we have a native library for it! so just create the generic NativePlatform to represent it.
        nativePlatform = new NativeSystemInfo();
      }
    }
    if (nativePlatform == null) {
      nativePlatform = javaSystemInfo;
    }
    cachedSystemInfo = nativePlatform;
  }
  return cachedSystemInfo;
}
origin: org.rhq/rhq-core-native-system

if (!isNativeSystemInfoDisabled()) {
  try {
    Class<?> clazz = Class.forName(NATIVE_LIBRARY_CLASS_NAME);
    nativeApis.put(NativeApi.NATIVE_BUILD_DATE, clazz.getField(NativeApi.NATIVE_BUILD_DATE.name()));
    invokeApi(NativeApi.load);
origin: rhq-project/rhq

public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  if (SystemInfoFactory.isNativeSystemInfoDisabled()) {
    throw new SystemInfoException("Native system has been disabled");
origin: org.rhq/rhq-core-native-system

URL jarLocation;
if (isNativeSystemInfoAvailable()) {
  rootDir = System.getProperty("rhq.native-libraries-root-directory");
  if (rootDir == null) {
origin: org.rhq/rhq-core-plugin-container

private PluginContext createPluginContext(String pluginName) {
  SystemInfo sysInfo = SystemInfoFactory.createSystemInfo();
  File dataDir = new File(pluginContainerConfiguration.getDataDirectory(), pluginName);
  File tmpDir = pluginContainerConfiguration.getTemporaryDirectory();
  String pcName = pluginContainerConfiguration.getContainerName();
  PluginContext context = new PluginContext(pluginName, sysInfo, tmpDir, dataDir, pcName);
  return context;
}
origin: org.rhq/rhq-core-plugin-api

boolean nativeSystemInfoDisabled = SystemInfoFactory.isNativeSystemInfoDisabled();
ResourceType resourceType = this.resourceContext.getResourceType();
List<String> logFilePaths = getLogFilePaths(enabledEventSources);
origin: rhq-project/rhq

public ProcessExecutionResults executeProcess(ProcessExecution processExecution) {
  // TODO: doesn't look like SIGAR has an API to fork/execute processes? fallback to using the Java way
  return SystemInfoFactory.createJavaSystemInfo().executeProcess(processExecution);
}
origin: org.rhq/rhq-cassandra-ccm-core

private ProcessExecutionResults startNode(File basedir) {
  if (log.isDebugEnabled()) {
    log.debug("Starting node at " + basedir);
  }
  File binDir = new File(basedir, "bin");
  File startScript;
  SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();
  ProcessExecution startScriptExe;
  if (systemInfo.getOperatingSystemType() == OperatingSystemType.WINDOWS) {
    startScript = new File(binDir, "cassandra.bat");
    startScriptExe = createProcessExecution(null, startScript);
  } else {
    startScript = new File(binDir, "cassandra");
    startScriptExe = createProcessExecution(null, startScript);
    startScriptExe.addArguments(Arrays.asList("-p", "cassandra.pid"));
  }
  startScriptExe.setWaitForCompletion(0);
  ProcessExecutionResults results = systemInfo.executeProcess(startScriptExe);
  if (log.isDebugEnabled()) {
    log.debug(startScript + " returned with exit code [" + results.getExitCode() + "]");
  }
  return results;
}
org.rhq.core.systemSystemInfoFactory

Javadoc

Builds SystemInfo objects based on the native operating system the VM is running on.

Most used methods

  • createSystemInfo
    Returns the appropriate SystemInfo implementation based on the platform/operating system the JVM is
  • isNativeSystemInfoDisabled
    Returns true if this factory was told to #disableNativeSystemInfo() the native layer. This only indi
  • disableNativeSystemInfo
    This will tell the factory to not #createSystemInfo() any native objects and to not load the native
  • isNativeSystemInfoAvailable
    If there is a native library available for the JVM's platform/operating system, true is returned. I
  • isNativeSystemInfoInitialized
    This returns true iff the native libraries have actually been initialized. This will return false if
  • createJavaSystemInfo
    Under some circumstances, you may want to force this factory to provide a Java-only SystemInfoimplem
  • enableNativeSystemInfo
    This will allow the factory to load the native libraries and #createSystemInfo() native objects. Not
  • getNativeSystemInfoVersion
    If the native system is both #isNativeSystemInfoAvailable() and #isNativeSystemInfoDisabled(), this
  • initialize
    This will initialize the native layer, if applicable. If the native layer was already initialized, t
  • invokeApi
    In order for this class to not have any compile or load time dependencies on the SIGAR jar, use this

Popular in Java

  • Start an intent from android
  • setScale (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • getContentResolver (Context)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Reference (javax.naming)
  • JCheckBox (javax.swing)
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now