当前位置: 首页>>代码示例>>Java>>正文


Java InstanceInfo类代码示例

本文整理汇总了Java中org.cloudfoundry.client.lib.domain.InstanceInfo的典型用法代码示例。如果您正苦于以下问题:Java InstanceInfo类的具体用法?Java InstanceInfo怎么用?Java InstanceInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InstanceInfo类属于org.cloudfoundry.client.lib.domain包,在下文中一共展示了InstanceInfo类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showInstancesStatus

import org.cloudfoundry.client.lib.domain.InstanceInfo; //导入依赖的package包/类
private void showInstancesStatus(ExecutionWrapper execution, List<InstanceInfo> instances, int runningInstances,
    int expectedInstances) {

    // Determine state counts
    Map<String, Integer> stateCounts = new HashMap<>();
    if (instances.isEmpty()) {
        stateCounts.put(InstanceState.STARTING.toString(), 0);
    } else {
        for (InstanceInfo instance : instances) {
            final String state = instance.getState().toString();
            final Integer stateCount = stateCounts.get(state);
            stateCounts.put(state, (stateCount == null) ? 1 : (stateCount + 1));
        }
    }

    // Compose state strings
    List<String> stateStrings = new ArrayList<>();
    for (Map.Entry<String, Integer> sc : stateCounts.entrySet()) {
        stateStrings.add(format("{0} {1}", sc.getValue(), sc.getKey().toLowerCase()));
    }

    // Print message
    String message = format(Messages.X_OF_Y_INSTANCES_RUNNING, runningInstances, expectedInstances,
        CommonUtil.toCommaDelimitedString(stateStrings, ""));
    execution.getStepLogger().info(message);
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:27,代码来源:PollStartAppStatusExecution.java

示例2: ensureApplicationRunning

import org.cloudfoundry.client.lib.domain.InstanceInfo; //导入依赖的package包/类
private boolean ensureApplicationRunning(String appName) {
    InstancesInfo instances;
    boolean pass = false;
    for (int i = 0; i < 50; i++) {
        try {
            instances = getInstancesWithTimeout(connectedClient, appName);
            assertNotNull(instances);

            List<InstanceInfo> infos = instances.getInstances();
            assertEquals(1, infos.size());

            int passCount = 0;
            for (InstanceInfo info : infos) {
                if (InstanceState.RUNNING.equals(info.getState())) {
                    passCount++;
                }
            }
            if (passCount == infos.size()) {
                pass = true;
                break;
            }
        } catch (CloudFoundryException ex) {
            // ignore (we may get this when staging is still ongoing)
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // ignore
        }
    }
    return pass;
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:33,代码来源:CloudFoundryClientTest.java

示例3: getStartupStatus

import org.cloudfoundry.client.lib.domain.InstanceInfo; //导入依赖的package包/类
private StartupStatus getStartupStatus(ExecutionWrapper execution, CloudFoundryOperations client, String appName) {
    CloudApplication app = client.getApplication(appName);
    List<InstanceInfo> instances = getApplicationInstances(client, app);

    // The default value here is provided for undeploy processes:
    boolean failOnCrashed = StepsUtil.getVariableOrDefault(execution.getContext(), Constants.PARAM_FAIL_ON_CRASHED, true);

    if (instances != null) {
        int expectedInstances = app.getInstances();
        int runningInstances = getInstanceCount(instances, InstanceState.RUNNING);
        int flappingInstances = getInstanceCount(instances, InstanceState.FLAPPING);
        int crashedInstances = getInstanceCount(instances, InstanceState.CRASHED);
        int startingInstances = getInstanceCount(instances, InstanceState.STARTING);

        showInstancesStatus(execution, instances, runningInstances, expectedInstances);

        if (runningInstances == expectedInstances) {
            return StartupStatus.STARTED;
        }
        if (startingInstances > 0) {
            return StartupStatus.STARTING;
        }
        if (flappingInstances > 0) {
            return StartupStatus.FLAPPING;
        }
        if (crashedInstances > 0 && failOnCrashed) {
            return StartupStatus.CRASHED;
        }
    }

    return StartupStatus.STARTING;
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:33,代码来源:PollStartAppStatusExecution.java

示例4: getInstanceCount

import org.cloudfoundry.client.lib.domain.InstanceInfo; //导入依赖的package包/类
private static int getInstanceCount(List<InstanceInfo> instances, InstanceState state) {
    int count = 0;
    for (InstanceInfo instance : instances) {
        if (instance.getState().equals(state)) {
            count++;
        }
    }
    return count;
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:10,代码来源:PollStartAppStatusExecution.java

示例5: isApplicationRunning

import org.cloudfoundry.client.lib.domain.InstanceInfo; //导入依赖的package包/类
public static boolean isApplicationRunning(CloudFoundryClient client, String appName) {
    InstancesInfo infos = client.getApplicationInstances(appName);
    if (infos != null) {
        for (InstanceInfo info :infos.getInstances()) {
            if (info.getState() != InstanceState.RUNNING) {
                return false;
            }
        }
        // All instances are running
        return true;
    }         
    
    // No instance info - app not running
    return false;
}
 
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:16,代码来源:DeployJob.java

示例6: getInstanceInfosWithTimeout

import org.cloudfoundry.client.lib.domain.InstanceInfo; //导入依赖的package包/类
private boolean getInstanceInfosWithTimeout(String appName, int count, boolean shouldBeRunning) {
    if (count > 1) {
        connectedClient.updateApplicationInstances(appName, count);
        CloudApplication app = connectedClient.getApplication(appName);
        assertEquals(count, app.getInstances());
    }

    InstancesInfo instances;
    boolean pass = false;
    for (int i = 0; i < 50; i++) {
        try {
            instances = getInstancesWithTimeout(connectedClient, appName);
            assertNotNull(instances);

            List<InstanceInfo> infos = instances.getInstances();
            assertEquals(count, infos.size());

            int passCount = 0;
            for (InstanceInfo info : infos) {
                if (shouldBeRunning) {
                    if (InstanceState.RUNNING.equals(info.getState()) || InstanceState.STARTING.equals(info.getState())) {
                        passCount++;
                    }
                } else {
                    if (InstanceState.CRASHED.equals(info.getState()) || InstanceState.FLAPPING.equals(info.getState())) {
                        passCount++;
                    }
                }
            }
            if (passCount == infos.size()) {
                pass = true;
                break;
            }
        } catch (CloudFoundryException ex) {
            // ignore (we may get this when staging is still ongoing)
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // ignore
        }
    }
    return pass;
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:45,代码来源:CloudFoundryClientTest.java

示例7: getApplicationInstances

import org.cloudfoundry.client.lib.domain.InstanceInfo; //导入依赖的package包/类
private static List<InstanceInfo> getApplicationInstances(CloudFoundryOperations client, CloudApplication app) {
    InstancesInfo instancesInfo = client.getApplicationInstances(app);
    return (instancesInfo != null) ? instancesInfo.getInstances() : null;
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:5,代码来源:PollStartAppStatusExecution.java

示例8: InstanceStatsAndInfo

import org.cloudfoundry.client.lib.domain.InstanceInfo; //导入依赖的package包/类
public InstanceStatsAndInfo(InstanceStats stats, InstanceInfo info) {
	this.stats = stats;
	this.info = info;
}
 
开发者ID:eclipse,项目名称:cft,代码行数:5,代码来源:AppStatsContentProvider.java

示例9: getInfo

import org.cloudfoundry.client.lib.domain.InstanceInfo; //导入依赖的package包/类
public InstanceInfo getInfo() {
	return info;
}
 
开发者ID:eclipse,项目名称:cft,代码行数:4,代码来源:AppStatsContentProvider.java

示例10: getInstanceInfosWithTimeout

import org.cloudfoundry.client.lib.domain.InstanceInfo; //导入依赖的package包/类
private boolean getInstanceInfosWithTimeout(String appName, int count, boolean shouldBeRunning) throws CloudFoundryException {
	if (count > 1) {
		connectedClient.updateApplicationInstances(appName, count);
		CloudApplication app = connectedClient.getApplication(appName);
		assertEquals(count, app.getInstances());
	}

	InstancesInfo instances;
	boolean pass = false;
	for (int i = 0; i < 50; i++) {
		try {
			instances = getInstancesWithTimeout(connectedClient, appName);
			assertNotNull(instances);

			List<InstanceInfo> infos = instances.getInstances();
			assertEquals(count, infos.size());

			int passCount = 0;
			for (InstanceInfo info : infos) {
				if (shouldBeRunning) {
					if (InstanceState.RUNNING.equals(info.getState()) ||
							InstanceState.STARTING.equals(info.getState())) {
						passCount++;
					}
				} else {
					if (InstanceState.CRASHED.equals(info.getState()) ||
							InstanceState.FLAPPING.equals(info.getState())) {
						passCount++;
					}
				}
			}
			if (passCount == infos.size()) {
				pass = true;
				break;
			}
		} catch (CloudFoundryException ex) {
			// ignore (we may get this when staging is still ongoing)
		}
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			// ignore
		}
	}
	return pass;
}
 
开发者ID:stephen-kruger,项目名称:cloudfoundry-liteclient-lib,代码行数:47,代码来源:CloudFoundryClientTest.java


注:本文中的org.cloudfoundry.client.lib.domain.InstanceInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。