public static CloudFoundryApplicationModule getCloudFoundryApplicationModule( IModule module, IServer server) throws CoreException { CloudFoundryServer cloudServer = CloudServerUtil.getCloudServer(server); CloudFoundryApplicationModule appModule = cloudServer.getExistingCloudModule(module); if (appModule == null) { throw CloudErrorUtil.toCoreException( NLS.bind( Messages.ApplicationDelegate_NO_CLOUD_MODULE_FOUND, module.getName(), cloudServer.getServer().getId())); } return appModule; }
/** * @param serverID unique ID of the server. This should not just be the name of the server, but * the full id (e.g. for V2, it should include the space name) * @return CloudFoundry server that corresponds to the given ID, or null if not found */ public static CloudFoundryServer getCloudServer(String serverID) { IServer[] servers = ServerCore.getServers(); if (servers == null) { return null; } CloudFoundryServer cfServer = null; for (IServer server : servers) { cfServer = (CloudFoundryServer) server.loadAdapter(CloudFoundryServer.class, null); if (cfServer != null && cfServer.getServerId().equals(serverID)) { break; } } return cfServer; }
public InstanceState track(IProgressMonitor monitor) throws CoreException { InstanceState runState = null; long currentTime = System.currentTimeMillis(); long totalTime = currentTime + timeout; CloudFoundryApplicationModule appModule = cloudServer.getBehaviour().updateCloudModuleWithInstances(appName, monitor); ApplicationStats stats = getStats(monitor); printlnToConsole( NLS.bind(Messages.ApplicationInstanceStartingTracker_STARTING_TRACKING, appName), appModule); while (runState != InstanceState.RUNNING && runState != InstanceState.FLAPPING && runState != InstanceState.CRASHED && currentTime < totalTime) { runState = getRunState(stats, appModule.getApplication()); try { Thread.sleep(WAIT_TIME); } catch (InterruptedException e) { } stats = getStats(monitor); currentTime = System.currentTimeMillis(); } String runningStateMessage = runState == InstanceState.RUNNING ? NLS.bind(Messages.ApplicationInstanceStartingTracker_APPLICATION_IS_RUNNING, appName) : NLS.bind( Messages.ApplicationInstanceStartingTracker_APPLICATION_IS_NOT_RUNNING, appName); printlnToConsole(runningStateMessage, appModule); return runState; }
protected ApplicationStats getStats(IProgressMonitor monitor) throws CoreException { return cloudServer.getBehaviour().getApplicationStats(appName, monitor); }