1111
111
/** * Starts management processes (LUS, GSM, ESM), and waits until the requested service installations complete (space, * webui, REST), or until the timeout is reached. * * @param gsAgentArgs * GS agent start-up switches * @param securityProfile * set security profile (nonsecure/secure/ssl) * @param securityFilePath * path to the security configuration file * @param username * The username for a secure connection to the server * @param password * The password for a secure connection to the server * @param keystoreFilePath * path to the keystore file * @param keystorePassword * The password to the keystore set on the rest server * @param timeout * number of {@link TimeUnit}s to wait * @param timeunit * the {@link TimeUnit} to use, to calculate the timeout * @param isLocalCloud * Is this a local cloud (true - yes, false - no) * @throws CLIException * Reporting a failure to start the processes and services * @throws InterruptedException * Reporting the thread was interrupted while waiting * @throws TimeoutException * Reporting the timeout was reached */ private void startManagementOnLocalhostAndWaitInternal(final String[] gsAgentArgs, final String securityProfile, final String securityFilePath, final String username, final String password, final String keystoreFilePath, final String keystorePassword, final int timeout, final TimeUnit timeunit, final boolean isLocalCloud) throws CLIException, InterruptedException, TimeoutException { setIsLocalCloud(isLocalCloud); final long end = System.currentTimeMillis() + timeunit.toMillis(timeout); final ConnectionLogsFilter connectionLogs = new ConnectionLogsFilter(); connectionLogs.supressConnectionErrors(); final Admin admin = createAdmin(); try { setLookupDefaults(admin); GridServiceAgent agent; try { try { if (!isLocalCloud || fastExistingAgentCheck()) { waitForExistingAgent(admin, progressInSeconds, TimeUnit.SECONDS); throw new CLIException("Agent already running on local machine."); } } catch (final TimeoutException e) { // no existing agent running on local machine } runGsAgentOnLocalHost("agent and management processes", gsAgentArgs, securityProfile, securityFilePath, keystoreFilePath, keystorePassword); agent = waitForNewAgent(admin, ShellUtils.millisUntil(TIMEOUT_ERROR_MESSAGE, end), TimeUnit.MILLISECONDS); } finally { connectionLogs.restoreConnectionErrors(); } // waiting for LUS, GSM and ESM services to start waitForManagementProcesses(agent, ShellUtils.millisUntil(TIMEOUT_ERROR_MESSAGE, end), TimeUnit.MILLISECONDS); final List<AbstractManagementServiceInstaller> waitForManagementServices = new LinkedList<AbstractManagementServiceInstaller>(); if (isLocalCloud) { startLocalCloudManagementServicesContainer(agent); } connectionLogs.supressConnectionErrors(); try { ManagementSpaceServiceInstaller managementSpaceInstaller = null; if (!noManagementSpace) { final boolean highlyAvailable = !isLocalCloud && !notHighlyAvailableManagementSpace; final String gscLrmiCommandLineArg = getGscLrmiCommandLineArg(); managementSpaceInstaller = new ManagementSpaceServiceInstaller(); managementSpaceInstaller.setAdmin(agent.getAdmin()); managementSpaceInstaller.setVerbose(verbose); managementSpaceInstaller.setProgress(progressInSeconds, TimeUnit.SECONDS); managementSpaceInstaller.setMemory(CloudifyConstants.MANAGEMENT_SPACE_MEMORY_IN_MB, MemoryUnit.MEGABYTES); managementSpaceInstaller.setServiceName(MANAGEMENT_SPACE_NAME); managementSpaceInstaller.setManagementZone(MANAGEMENT_ZONE); managementSpaceInstaller.setHighlyAvailable(highlyAvailable); managementSpaceInstaller.addListeners(this.eventsListenersList); managementSpaceInstaller.setIsLocalCloud(isLocalCloud); managementSpaceInstaller.setLrmiCommandLineArgument(gscLrmiCommandLineArg); if (!this.isLocalCloud) { final String persistentStoragePath = this.cloud.getConfiguration().getPersistentStoragePath(); if (persistentStoragePath != null) { final String spaceStoragePath = persistentStoragePath + "/management-space/db.h2"; managementSpaceInstaller.setPersistentStoragePath(spaceStoragePath); } } try { managementSpaceInstaller.installSpace(); waitForManagementServices.add(managementSpaceInstaller); } catch (final ProcessingUnitAlreadyDeployedException e) { if (verbose) { logger.fine("Service " + MANAGEMENT_SPACE_NAME + " already installed"); publishEvent("Service " + MANAGEMENT_SPACE_NAME + " already installed"); } } } if (!noWebServices) { installWebServices(username, password, isLocalCloud, ShellUtils.isSecureConnection(securityProfile), agent, waitForManagementServices); } for (final AbstractManagementServiceInstaller managementServiceInstaller : waitForManagementServices) { managementServiceInstaller.waitForInstallation(adminFacade, agent, ShellUtils.millisUntil(TIMEOUT_ERROR_MESSAGE, end), TimeUnit.MILLISECONDS); if (managementServiceInstaller instanceof ManagementSpaceServiceInstaller) { logger.fine("Writing cloud configuration to space."); if (verbose) { publishEvent("Writing cloud configuration to space."); } final GigaSpace gigaspace = managementSpaceInstaller.getGigaSpace(); final CloudConfigurationHolder holder = new CloudConfigurationHolder(null, getCloudFilePath()); logger.fine("Writing cloud Configuration to space: " + holder); gigaspace.write(holder); // Shut down the space proxy so that if the cloud is // turned down later, there will not // be any discovery errors. // Note: in a spring environment, the bean shutdown // would clean this up. // TODO - Move the space writing part into the // management space // installer and do the clean up there. ((ISpaceProxy) gigaspace.getSpace()).close(); } } } finally { connectionLogs.restoreConnectionErrors(); } } finally { admin.close(); } }
111