本文整理了Java中io.cattle.platform.core.model.Instance.getId()
方法的一些代码示例,展示了Instance.getId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instance.getId()
方法的具体详情如下:
包路径:io.cattle.platform.core.model.Instance
类名称:Instance
方法名:getId
[英]Getter for cattle.instance.id
.
[中]cattle.instance.id
的Getter。
代码示例来源:origin: rancher/cattle
@Override
protected Long getId(Object obj) {
if (obj instanceof Instance) {
return ((Instance) obj).getId();
}
return null;
}
}
代码示例来源:origin: rancher/cattle
@Override
public void instanceAllocate(final Instance instance) {
log.info("Allocating instance [{}]", instance.getId());
lockManager.lock(new AllocateResourceLock(instance.getId()), new LockCallbackNoReturn() {
@Override
public void doWithLockNoResult() {
allocateInstance(instance);
}
});
log.info("Handled request for instance [{}]", instance.getId());
}
代码示例来源:origin: rancher/cattle
protected void reregisterInstancesForHealtchecks(List<? extends Instance> instances) {
for (Instance instance : instances) {
healthcheckService.registerForHealtcheck(HealthcheckInstanceType.INSTANCE, instance.getId());
}
}
代码示例来源:origin: rancher/cattle
@Override
public void doWithLockNoResult() {
objectProcessManager.scheduleStandardProcessAsync(StandardProcess.REMOVE, currentMappedInstances.get(instance.getId()),
null);
}
});
代码示例来源:origin: rancher/cattle
private EventVO<Map<String, Object>> buildEvent(String eventName, String phase, List<Instance> instances, Set<Volume> volumes, Long agentId) {
List<ResourceRequest> resourceRequests = gatherResourceRequests(instances, volumes, agentId);
if (resourceRequests.isEmpty()) {
return null;
}
return newEvent(eventName, resourceRequests, "instance", phase, instances.get(0).getId(), instances);
}
代码示例来源:origin: rancher/cattle
private EventVO<Map<String, Object>> buildEventForPort(String eventName, String phase, List<Instance> instances,
Long agentId, List<Port> newPorts) {
List<ResourceRequest> resourceRequests = gatherResourceRequestsForPort(instances, agentId, newPorts);
if (resourceRequests.isEmpty()) {
return null;
}
return newEvent(eventName, resourceRequests, "instance", phase, instances.get(0).getId(), instances);
}
代码示例来源:origin: rancher/cattle
protected boolean isStartedOnce() {
List<String> validStates = Arrays.asList(InstanceConstants.STATE_STOPPED, InstanceConstants.STATE_STOPPING,
InstanceConstants.STATE_RUNNING);
return validStates.contains(context.objectManager.reload(this.instance).getState())
&& context.objectManager.find(InstanceHostMap.class, INSTANCE_HOST_MAP.INSTANCE_ID,
instance.getId()).size() > 0;
}
代码示例来源:origin: rancher/cattle
@Override
public ServiceExposeMap getServiceInstanceMap(Service service, final Instance instance) {
return objectManager.findAny(ServiceExposeMap.class, SERVICE_EXPOSE_MAP.INSTANCE_ID, instance.getId(),
SERVICE_EXPOSE_MAP.SERVICE_ID, service.getId(), SERVICE_EXPOSE_MAP.REMOVED, null);
}
代码示例来源:origin: rancher/cattle
protected void releaseAllocation(Instance instance) {
// This is kind of strange logic to remove deallocate for every instance host map, but in truth there will be only one ihm
Map<String, List<InstanceHostMap>> maps = allocatorDao.getInstanceHostMapsWithHostUuid(instance.getId());
for (Map.Entry<String, List<InstanceHostMap>> entry : maps.entrySet()) {
for (InstanceHostMap map : entry.getValue()) {
if (!allocatorDao.isAllocationReleased(map)) {
allocatorDao.releaseAllocation(instance, map);
releaseResources(instance, entry.getKey(), InstanceConstants.PROCESS_DEALLOCATE);
}
}
}
}
代码示例来源:origin: rancher/cattle
protected String key(Instance instance) {
Object resourceId = context.idFormatter.formatId(instance.getKind(), instance.getId());
return String.format("%s:%s", instance.getKind(), resourceId);
}
代码示例来源:origin: rancher/cattle
@Override
public HandlerResult handle(ProcessState state, ProcessInstance process) {
Instance instance = (Instance)state.getResource();
if (mapDao.findNonRemoved(InstanceHostMap.class, Instance.class, instance.getId()).size() == 0) {
allocatorService.instanceAllocate(instance);
}
return afterAllocate(state, process, new HashMap<Object, Object>());
}
代码示例来源:origin: rancher/cattle
private void createLabels(Instance instance) {
@SuppressWarnings("unchecked")
Map<String, String> labels = DataAccessor.fields(instance).withKey(InstanceConstants.FIELD_LABELS).as(Map.class);
if (labels == null) {
return;
}
for (Map.Entry<String, String> labelEntry : labels.entrySet()) {
String labelKey = labelEntry.getKey();
String labelValue = labelEntry.getValue();
labelsService.createContainerLabel(instance.getAccountId(), instance.getId(), labelKey, labelValue);
}
}
代码示例来源:origin: rancher/cattle
public Condition getInstanceHostConstraint(Instance instance) {
if (StringUtils.isEmpty(instance.getDeploymentUnitUuid())) {
return INSTANCE_HOST_MAP.INSTANCE_ID.eq(instance.getId());
} else {
return INSTANCE.DEPLOYMENT_UNIT_UUID.eq(instance.getDeploymentUnitUuid());
}
}
代码示例来源:origin: rancher/cattle
private void deleteServiceMappings(Instance instance) {
List<? extends ServiceExposeMap> maps = objectManager.mappedChildren(
objectManager.loadResource(Instance.class, instance.getId()),
ServiceExposeMap.class);
for (ServiceExposeMap map : maps) {
if (!(map.getState().equals(CommonStatesConstants.REMOVED) || map.getState().equals(
CommonStatesConstants.REMOVING))) {
objectProcessManager.scheduleStandardProcessAsync(StandardProcess.REMOVE, map, null);
}
}
}
代码示例来源:origin: rancher/cattle
protected void compute(Instance instance, ProcessState state) {
for (InstanceHostMap map : mapDao.findNonRemoved(InstanceHostMap.class, Instance.class, instance.getId())) {
activate(map, state.getData());
}
}
代码示例来源:origin: rancher/cattle
protected Volume getRoot(Instance instance, List<Volume> volumes) {
if (instance.getImageId() == null) {
return null;
}
for (Volume volume : volumes) {
if (volume.getDeviceNumber() != null && volume.getDeviceNumber().intValue() == 0) {
return volume;
}
}
return objectManager.create(Volume.class, VOLUME.ACCOUNT_ID, instance.getAccountId(), VOLUME.INSTANCE_ID, instance.getId(), VOLUME.IMAGE_ID, instance
.getImageId(), VOLUME.DEVICE_NUMBER, 0, VOLUME.ATTACHED_STATE, CommonStatesConstants.ACTIVE);
}
代码示例来源:origin: rancher/cattle
protected HandlerResult afterDeallocate(ProcessState state, ProcessInstance process, Map<Object, Object> result) {
Instance instance = (Instance) state.getResource();
for (InstanceHostMap map : mapDao.findToRemove(InstanceHostMap.class, Instance.class, instance.getId())) {
if (CommonStatesConstants.ACTIVATING.equals(map.getState()) || CommonStatesConstants.ACTIVE.equals(map.getState())) {
deactivate(map, state.getData());
}
remove(map, state.getData());
}
return new HandlerResult(result);
}
}
代码示例来源:origin: rancher/cattle
@Override
public Nic getPrimaryNic(Instance instance) {
if ( instance == null ) {
return null;
}
return create()
.selectFrom(NIC)
.where(NIC.INSTANCE_ID.eq(instance.getId())
.and(NIC.DEVICE_NUMBER.eq(0)))
.fetchOne();
}
代码示例来源:origin: rancher/cattle
@Override
public List<? extends Service> findServicesFor(Instance instance) {
return create().select(SERVICE.fields())
.from(SERVICE)
.join(SERVICE_EXPOSE_MAP)
.on(SERVICE_EXPOSE_MAP.SERVICE_ID.eq(SERVICE.ID))
.where(SERVICE_EXPOSE_MAP.INSTANCE_ID.eq(instance.getId()))
.fetchInto(ServiceRecord.class);
}
代码示例来源:origin: rancher/cattle
@Override
public List<? extends Service> findServicesNonRemovedLinksOnly(Instance instance) {
return create().select(SERVICE.fields())
.from(SERVICE)
.join(SERVICE_EXPOSE_MAP)
.on(SERVICE_EXPOSE_MAP.SERVICE_ID.eq(SERVICE.ID))
.where(SERVICE_EXPOSE_MAP.INSTANCE_ID.eq(instance.getId())
.and(SERVICE_EXPOSE_MAP.REMOVED.isNull()))
.fetchInto(ServiceRecord.class);
}
内容来源于网络,如有侵权,请联系作者删除!