gpt4 book ai didi

org.zstack.header.zone.ZoneInventory.valueOf()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 23:03:31 28 4
gpt4 key购买 nike

本文整理了Java中org.zstack.header.zone.ZoneInventory.valueOf()方法的一些代码示例,展示了ZoneInventory.valueOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneInventory.valueOf()方法的具体详情如下:
包路径:org.zstack.header.zone.ZoneInventory
类名称:ZoneInventory
方法名:valueOf

ZoneInventory.valueOf介绍

暂无

代码示例

代码示例来源:origin: zstackio/zstack

public static List<ZoneInventory> valueOf(Collection<ZoneVO> vos) {
  List<ZoneInventory> invs = new ArrayList<ZoneInventory>(vos.size());
  for (ZoneVO vo : vos) {
    invs.add(ZoneInventory.valueOf(vo));
  }
  return invs;
}

代码示例来源:origin: zstackio/zstack

void afterChange(ZoneVO vo, final ZoneStateEvent event, final ZoneState previousState) {
  final ZoneInventory zinv = ZoneInventory.valueOf(vo);
  CollectionUtils.safeForEach(changeExts, new ForEachFunction<ZoneChangeStateExtensionPoint>() {
    @Override
    public void run(ZoneChangeStateExtensionPoint arg) {
      arg.afterChangeZoneState(zinv, event, previousState);
    }
  });
}

代码示例来源:origin: zstackio/zstack

void beforeChange(ZoneVO vo, final ZoneStateEvent event) {
  final ZoneInventory zinv = ZoneInventory.valueOf(vo);
  final ZoneState next = AbstractZone.getNextState(vo.getState(), event);
  CollectionUtils.safeForEach(changeExts, new ForEachFunction<ZoneChangeStateExtensionPoint>() {
    @Override
    public void run(ZoneChangeStateExtensionPoint arg) {
      arg.beforeChangeZoneState(zinv, event, next);
    }
  });
}

代码示例来源:origin: zstackio/zstack

private void handle(APIGetZoneMsg msg) {
  APIGetZoneReply reply = new APIGetZoneReply();
  if (msg.getUuid() != null) {
    ZoneVO vo = dbf.findByUuid(msg.getUuid(), ZoneVO.class);
    reply.setInventories(asList(ZoneInventory.valueOf(vo)));
  } else {
    reply.setInventories(ZoneInventory.valueOf(dbf.listAll(ZoneVO.class)));
  }
  bus.reply(msg, reply);
}

代码示例来源:origin: zstackio/zstack

void preChange(ZoneVO vo, ZoneStateEvent event) throws ZoneException {
  ZoneInventory zinv = ZoneInventory.valueOf(vo);
  ZoneState next = AbstractZone.getNextState(vo.getState(), event);
  for (ZoneChangeStateExtensionPoint extp : changeExts) {
    try {
      extp.preChangeZoneState(zinv, event, next);
    } catch (ZoneException ze) {
      logger.debug(String.format("Extension: %s refused zone change state operation[ZoneStateEvent:%s] because %s", extp.getClass()
          .getCanonicalName(), event, ze.getMessage()));
      throw ze;
    } catch (Exception e) {
      logger.warn("Exception happened while calling " + extp.getClass().getCanonicalName() + ".preChangeZoneState(), " + "zone name: " + zinv.getName()
          + " uuid: " + zinv.getUuid(), e);
    }
  }
}

代码示例来源:origin: zstackio/zstack

private void handle(APIListZonesMsg msg) {
  APIListZonesReply reply = new APIListZonesReply();
  List<ZoneVO> vos = dl.listByApiMessage(msg, ZoneVO.class);
  List<ZoneInventory> invs = ZoneInventory.valueOf(vos);
  reply.setInventories(invs);
  bus.reply(msg, reply);
}

代码示例来源:origin: zstackio/zstack

@Override
  public void run(MessageReply reply) {
    if (!reply.isSuccess()) {
      areply.setError(reply.getError());
    } else {
      AllocateHostDryRunReply re = reply.castReply();
      if (!re.getHosts().isEmpty()) {
        areply.setHosts(re.getHosts());
        List<String> clusterUuids = re.getHosts().stream().
            map(HostInventory::getClusterUuid).collect(Collectors.toList());
        areply.setClusters(ClusterInventory.valueOf(dbf.listByPrimaryKeys(clusterUuids, ClusterVO.class)));
        List<String> zoneUuids = re.getHosts().stream().
            map(HostInventory::getZoneUuid).collect(Collectors.toList());
        areply.setZones(ZoneInventory.valueOf(dbf.listByPrimaryKeys(zoneUuids, ZoneVO.class)));
      } else {
        areply.setHosts(new ArrayList<>());
        areply.setClusters(new ArrayList<>());
        areply.setZones(new ArrayList<>());
      }
    }
    bus.reply(msg, areply);
  }
});

代码示例来源:origin: zstackio/zstack

private void handle(ZoneDeletionMsg msg) {
  ZoneInventory inv = ZoneInventory.valueOf(self);
  extpEmitter.beforeDelete(inv);
  deleteHook();
  extpEmitter.afterDelete(inv);
  ZoneDeletionReply reply = new ZoneDeletionReply();
  bus.reply(msg, reply);
}

代码示例来源:origin: zstackio/zstack

protected void handle(APIDeleteZoneMsg msg) {
  final APIDeleteZoneEvent evt = new APIDeleteZoneEvent(msg.getId());
  final String issuer = ZoneVO.class.getSimpleName();
  ZoneInventory zinv = ZoneInventory.valueOf(self);
  final List<ZoneInventory> ctx = Arrays.asList(zinv);
  FlowChain chain = FlowChainBuilder.newSimpleFlowChain();

代码示例来源:origin: zstackio/zstack

private void handle(APIUpdateZoneMsg msg) {
  boolean update = false;
  if (msg.getName() != null) {
    self.setName(msg.getName());
    update = true;
  }
  if (msg.getDescription() != null) {
    self.setDescription(msg.getDescription());
    update = true;
  }
  if (update) {
    self = dbf.updateAndRefresh(self);
  }
  APIUpdateZoneEvent evt = new APIUpdateZoneEvent(msg.getId());
  evt.setInventory(ZoneInventory.valueOf(self));
  bus.publish(evt);
}

代码示例来源:origin: zstackio/zstack

protected void handle(APIChangeZoneStateMsg msg) {
  APIChangeZoneStateEvent evt = new APIChangeZoneStateEvent(msg.getId());
  ZoneStateEvent stateEvt = ZoneStateEvent.valueOf(msg.getStateEvent());
  try {
    extpEmitter.preChange(self, stateEvt);
  } catch (ZoneException e) {
    evt.setError(err(SysErrors.CHANGE_RESOURCE_STATE_ERROR, e.getMessage()));
    bus.publish(evt);
    return;
  }
  ZoneState formerState = self.getState();
  extpEmitter.beforeChange(self, stateEvt);
  ZoneState next = AbstractZone.getNextState(self.getState(), stateEvt);
  self.setState(next);
  self = dbf.updateAndRefresh(self);
  extpEmitter.afterChange(self, stateEvt, formerState);
  evt.setInventory(ZoneInventory.valueOf(self));
  logger.debug(String.format("Changed state of zone[uuid:%s] from %s to %s by event %s", self.getUuid(), formerState, self.getState(), stateEvt));
  bus.publish(evt);
}

代码示例来源:origin: zstackio/zstack

private void handle(APICreateZoneMsg msg) {
  String zoneType = msg.getType();
  if (zoneType == null) {
    zoneType = BaseZoneFactory.type.toString();
  }
  ZoneFactory factory = this.getZoneFactory(ZoneType.valueOf(zoneType));
  APICreateZoneEvent evt = new APICreateZoneEvent(msg.getId());
  ZoneVO vo = new ZoneVO();
  if (msg.getResourceUuid() != null) {
    vo.setUuid(msg.getResourceUuid());
  } else {
    vo.setUuid(Platform.getUuid());
  }
  vo.setName(msg.getName());
  vo.setDescription(msg.getDescription());
  vo = factory.createZone(vo, msg);
  tagMgr.createTagsFromAPICreateMessage(msg, vo.getUuid(), ZoneVO.class.getSimpleName());
  evt.setInventory(ZoneInventory.valueOf(vo));
  logger.debug("Created zone: " + vo.getName() + " uuid:" + vo.getUuid());
  bus.publish(evt);
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com