Examples of ProcessInfo


Examples of org.rhq.core.system.ProcessInfo

        return stopNode();
    }

    protected OperationResult stopNode() {
        ProcessInfo process = getResourceContext().getNativeProcess();

        if (process == null) {
            log.warn("Failed to obtain process info. It appears Cassandra is already shutdown.");
            return new OperationResult("Failed to obtain process info. It appears Cassandra is already shutdown.");
        }

        long pid = process.getPid();
        try {
            process.kill("KILL");

            Configuration pluginConfig = getResourceContext().getPluginConfiguration();
            File basedir = new File(pluginConfig.getSimpleValue("baseDir"));
            File binDir = new File(basedir, "bin");
            File pidFile = new File(binDir, "cassandra.pid");
View Full Code Here

Examples of org.rhq.core.system.ProcessInfo

        String jmxPort = null;
        StringBuilder commandLineBuilder = new StringBuilder(400);
        int classpathIndex = -1;

        ProcessInfo processInfo = processScanResult.getProcessInfo();
        String[] arguments = processInfo.getCommandLine();
        for (int i = 0; i < arguments.length; i++) {
            String arg = arguments[i];

            if (arg.startsWith("-Dcom.sun.management.jmxremote.port")) {
                String[] jmxPortArg = arg.split("=");
                jmxPort = jmxPortArg[1];
            }
            if (arg.startsWith("-cp") || (arg.startsWith("-classpath"))) {
                classpathIndex = i;
            }

            commandLineBuilder.append(arg);
            commandLineBuilder.append(' ');
        }

        pluginConfig.put(new PropertySimple(COMMAND_LINE_CONFIG_PROPERTY, commandLineBuilder.toString()));

        if (classpathIndex != -1 && classpathIndex + 1 < arguments.length) {
            String[] classpathEntries = arguments[classpathIndex + 1].split(File.pathSeparator);

            File yamlConfigurationPath = null;
            for (String classpathEntry : classpathEntries) {
                if (classpathEntry.endsWith("conf")) {
                    yamlConfigurationPath = new File(classpathEntry);
                    if (!yamlConfigurationPath.isAbsolute()) {
                        try {
                            //relative path, use process CWD to find absolute path of the conf directory
                            yamlConfigurationPath = new File(processInfo.getExecutable().getCwd(), classpathEntry);
                        } catch (Exception e) {
                            log.error("Error creating path for yaml file.", e);
                        }
                    }
                }
            }

            if (yamlConfigurationPath != null) {
                File yamlConfigurationFile = new File(yamlConfigurationPath, "cassandra.yaml");
                ConfigEditor yamlEditor = new ConfigEditor(yamlConfigurationFile);
                yamlEditor.load();

                pluginConfig.put(new PropertySimple(YAML_PROPERTY, yamlConfigurationFile.getAbsolutePath()));
                pluginConfig.put(new PropertySimple(CLUSTER_NAME_PROPERTY, yamlEditor.getClusterName()));
                pluginConfig.put(new PropertySimple(HOST_PROPERTY, yamlEditor.getListenAddress()));
                pluginConfig.put(new PropertySimple(AUTHENTICATOR_PROPERTY, yamlEditor.getAuthenticator()));
            }
        }

        if (jmxPort != null) {
            pluginConfig.put(new PropertySimple(JMX_PORT_PROPERTY, jmxPort));

            pluginConfig.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
                J2SE5ConnectionTypeDescriptor.class.getName()));
            pluginConfig.put(new PropertySimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY,
                "service:jmx:rmi:///jndi/rmi://" + pluginConfig.getSimpleValue(HOST_PROPERTY) + ":" + jmxPort
                    + "/jmxrmi"));
        }

        String resourceKey = "Cassandra (" + pluginConfig.getSimpleValue(HOST_PROPERTY) + ") " + jmxPort;
        String resourceName = RESOURCE_NAME;

        String path = processInfo.getExecutable().getCwd();
        pluginConfig.put(new PropertySimple(BASEDIR_PROPERTY, new File(path).getParentFile().getAbsolutePath()));

        return new DiscoveredResourceDetails(context.getResourceType(), resourceKey, resourceName, null, null,
            pluginConfig, processInfo);
    }
View Full Code Here

Examples of org.rhq.core.system.ProcessInfo

            long now = new Date().getTime();

            if (now - lastManagementInterfaceReply > MAX_TIMEOUT_FAILURE_WAIT) {
                availabilityType = DOWN;
            } else {
                ProcessInfo processInfo = context.getNativeProcess();
                if (processInfo != null && processInfo.priorSnaphot().isRunning()) {
                    availabilityType = previousAvailabilityType;
                } else {
                    availabilityType = DOWN;
                }
            }
View Full Code Here

Examples of org.rhq.core.system.ProcessInfo

    public DiscoveredResourceDetails discoverResource(Configuration pluginConfig, ResourceDiscoveryContext context)
        throws InvalidPluginConfigurationException {

        ProcessComponentConfig processComponentConfig = createProcessComponentConfig(pluginConfig);

        ProcessInfo processInfo;
        try {
            processInfo = findProcess(processComponentConfig, context.getSystemInformation());
        } catch (Exception e) {
            throw new RuntimeException("Failed to manually add process Resource based on plugin config: "
                + pluginConfig.toString(true), e);
        }

        String resourceKey, resourceDescription;
        switch (processComponentConfig.getType()) {
        case pidFile:
            resourceKey = processComponentConfig.getPidFile();
            resourceDescription = processInfo.getBaseName() + " process with PID file [" + resourceKey + "]";
            break;
        case piql:
            resourceKey = processComponentConfig.getPiql();
            resourceDescription = processInfo.getBaseName() + " process with PIQL expression [" + resourceKey + "]";
            break;
        default:
            throw new InvalidPluginConfigurationException("Unknown type: " + processComponentConfig.getType());
        }

        return new DiscoveredResourceDetails(context.getResourceType(), resourceKey, processInfo.getBaseName(),
            null /*version*/, resourceDescription, pluginConfig, processInfo);
    }
View Full Code Here

Examples of org.rhq.core.system.ProcessInfo

     * Return availability of this resource
     *  @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
     */
    @Override
    public AvailabilityType getAvailability() {
        ProcessInfo process = getResourceContext().getNativeProcess();

        // It is safe to read prior snapshot as getNativeProcess always return a fresh instance
        AvailabilityType ret = process == null ? AvailabilityType.DOWN
            : (process.priorSnaphot().isRunning() ? AvailabilityType.UP : AvailabilityType.DOWN);

        EventContext events = getResourceContext().getEventContext();
        if (events != null) {
            if (ret == AvailabilityType.UP) {
                if (!eventsRegistered) {
View Full Code Here

Examples of org.rhq.core.system.ProcessInfo

        }

        if (processComponentConfig.isFullProcessTree()) {
            return new AggregateProcessInfo(pid);
        } else {
            return new ProcessInfo(pid);
        }
    }
View Full Code Here

Examples of org.rhq.core.system.ProcessInfo

                    throw new InvalidPluginConfigurationException("Invalid password");
                }
            }
            throw new InvalidPluginConfigurationException("Cannot open database connection", e);
        }
        ProcessInfo processInfo = resourceContext.getNativeProcess();
        if (processInfo != null) {
            aggregateProcessInfo = processInfo.getAggregateProcessTree();
        } else {
            findProcessInfo();
        }
        File configFile = getConfigurationFileObject();
        if (!configFile.exists()) {
View Full Code Here

Examples of org.rhq.core.system.ProcessInfo

            JBossConnectionTypeDescriptor.class.getName()));

        // Set default values on any props that are not set.
        setPluginConfigurationDefaults(pluginConfiguration);

        ProcessInfo processInfo = null;
        String jbossHomeDir = pluginConfiguration.getSimpleValue(JBossASServerComponent.JBOSS_HOME_DIR_CONFIG_PROP,
            null);// this will never be null
        JBossInstallationInfo installInfo;
        try {
            installInfo = new JBossInstallationInfo(new File(jbossHomeDir));
View Full Code Here

Examples of org.rhq.core.system.ProcessInfo

    private void processAutoDiscoveredProcesses(ResourceDiscoveryContext context,
        Set<DiscoveredResourceDetails> resources, DiscoveredResourceDetails jbossPcIsEmbeddedIn) {
        List<ProcessScanResult> autoDiscoveryResults = context.getAutoDiscoveredProcesses();
        for (ProcessScanResult autoDiscoveryResult : autoDiscoveryResults) {
            ProcessInfo processInfo = autoDiscoveryResult.getProcessInfo();
            if (log.isDebugEnabled())
                log.debug("Discovered JBoss AS process: " + processInfo);

            JBossInstanceInfo cmdLine;
            try {
                cmdLine = new JBossInstanceInfo(processInfo);
            } catch (Exception e) {
                log.error("Failed to process JBoss AS command line: " + Arrays.asList(processInfo.getCommandLine()), e);
                continue;
            }

            // See if we have an AS 5 or AS 6 - if so, skip it.
            JBossInstallationInfo installInfo = cmdLine.getInstallInfo();
            String version = installInfo.getVersion();
            if (version.startsWith("5") || version.startsWith("6")) {
                if (log.isDebugEnabled())
                    log.debug("Found JBoss AS 5.0 or later, which is not supported by this plugin - skipping...");
                continue;
            }

            File installHome = new File(cmdLine.getSystemProperties().getProperty(JBossProperties.HOME_DIR));
            File configDir = new File(cmdLine.getSystemProperties().getProperty(JBossProperties.SERVER_HOME_DIR));

            if ((jbossPcIsEmbeddedIn != null)
                && jbossPcIsEmbeddedIn.getPluginConfiguration()
                    .getSimple(JBossASServerComponent.CONFIGURATION_PATH_CONFIG_PROP).getStringValue()
                    .equals(configDir.getAbsolutePath())) {
                // We're running embedded, and the JBossAS server we're embedded in has already been found.
                continue;
            }

            // The config dir might be a symlink - call getCanonicalFile() to resolve it if so, before
            // calling isDirectory() (isDirectory() returns false for a symlink, even if it points at
            // a directory).
            try {
                if (!configDir.getCanonicalFile().isDirectory()) {
                    log.warn("Skipping discovery for JBoss AS process " + processInfo + ", because configuration dir '"
                        + configDir + "' does not exist or is not a directory.");
                    continue;
                }
            } catch (IOException e) {
                log.error("Skipping discovery for JBoss AS process " + processInfo + ", because configuration dir '"
                    + configDir + "' could not be canonicalized.", e);
                continue;
            }

            Configuration pluginConfiguration = context.getDefaultPluginConfiguration();

            String jnpURL = getJnpURL(cmdLine, installHome, configDir);

            // Set the connection type (used by JMX plugin to connect to the MBean server).
            pluginConfiguration.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
                JBossConnectionTypeDescriptor.class.getName()));

            // Set the required props...
            pluginConfiguration.put(new PropertySimple(JBossASServerComponent.NAMING_URL_CONFIG_PROP, jnpURL));
            pluginConfiguration.put(new PropertySimple(JBossASServerComponent.JBOSS_HOME_DIR_CONFIG_PROP, installHome
                .getAbsolutePath()));
            pluginConfiguration
                .put(new PropertySimple(JBossASServerComponent.CONFIGURATION_PATH_CONFIG_PROP, configDir));

            // Set the optional props...
            pluginConfiguration.put(new PropertySimple(JBossASServerComponent.CONFIGURATION_SET_CONFIG_PROP, cmdLine
                .getSystemProperties().getProperty(JBossProperties.SERVER_NAME)));
            pluginConfiguration.put(new PropertySimple(JBossASServerComponent.BINDING_ADDRESS_CONFIG_PROP, cmdLine
                .getSystemProperties().getProperty(JBossProperties.BIND_ADDRESS)));

            JBossASDiscoveryUtils.UserInfo userInfo = JBossASDiscoveryUtils.getJmxInvokerUserInfo(configDir);
            if (userInfo != null) {
                pluginConfiguration.put(new PropertySimple(JBossASServerComponent.PRINCIPAL_CONFIG_PROP, userInfo
                    .getUsername()));
                pluginConfiguration.put(new PropertySimple(JBossASServerComponent.CREDENTIALS_CONFIG_PROP, userInfo
                    .getPassword()));
            }

            String javaHome = processInfo.getEnvironmentVariable(JAVA_HOME_ENV_VAR);
            if (javaHome == null && log.isDebugEnabled()) {
                log.debug("JAVA_HOME environment variable not set in JBoss AS process - defaulting "
                    + JBossASServerComponent.JAVA_HOME_PATH_CONFIG_PROP
                    + " connection property to the plugin container JRE dir.");
            }
View Full Code Here

Examples of org.rhq.core.system.ProcessInfo

        @SuppressWarnings("unchecked")
        List<ProcessScanResult> autoDiscoveryResults = context.getAutoDiscoveredProcesses();
        for (ProcessScanResult result : autoDiscoveryResults) {
            LOG.info("Discovered a postgres process: " + result);

            ProcessInfo procInfo = result.getProcessInfo();

            String pgDataPath = getDataDirPath(procInfo);
            if (pgDataPath == null) {
                LOG.error("Unable to obtain data directory for postgres process with pid " + procInfo.getPid()
                    + " (tried checking both -D command line argument, as well as " + PGDATA_ENV_VAR
                    + " environment variable).");
                continue;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.