/** @syncpriority 90 */ public void abort() { log.fatal("Mina instance ABORTING!"); ccm.prepareForShutdown(); scm.abort(); ccm.abort(); netMgr.stop(); started = false; log.fatal("Mina instance stopped"); }
public void start() throws MinaException { try { log.info(Tagline.getTagLine()); netMgr.start(); started = true; } catch (MinaException e) { SafetyNet.notifyException(e, this); log.fatal("MinaException caught on startup, stopping Mina"); stop(); throw e; } }
/** @syncpriority 200 */ public void stop() throws MinaException { log.fatal("Mina instance stopping"); ccm.prepareForShutdown(); scm.closeAllStreamConns(); streamMgr.stop(); sourceMgr.stop(); streamAdvertiser.cancel(); ccm.stop(); netMgr.stop(); badNodes.clear(); started = false; log.fatal("Mina instance stopped"); }
@Override public void setHandoverHandler(HandoverHandler handler) { netMgr.setHandoverHandler(handler); }
public void configUpdated() { netMgr.configUpdated(); }
@Override public void removeNodeFilter(NodeFilter nf) { netMgr.removeNodeFilter(nf); }
@Override public void addNodeFilter(NodeFilter nf) { netMgr.addNodeFilter(nf); }
/** * 获取虚拟机的摘要信息 * * @param url * @param username * @param password * @param vmId * @return */ public static Map<String, Object> getSummary( String url, String username, String password, String vmId) { HashMap<String, Object> resultMap = new HashMap<String, Object>(); try { VIMCache cache = VIMCache.getInstance(url, username, password); ManagedObjectReference mor = cache.getVirtualMachine(vmId); // System.out.println("vmId--:"+vmId+"===mor-是否存在---------------------------"+mor); if (mor != null) { ExtendedAppUtil ecb = getECB(url, username, password); // 配置 VirtualMachineConfigInfo config = (VirtualMachineConfigInfo) getDynamicProperty(ecb, mor, DYNAMICPROPERTY_CONFIG); // 运行 VirtualMachineRuntimeInfo runtime = (VirtualMachineRuntimeInfo) getDynamicProperty(ecb, mor, DYNAMICPROPERTY_RUNTIME); // 摘要 VirtualMachineSummary summary = (VirtualMachineSummary) getDynamicProperty(ecb, mor, DYNAMICPROPERTY_SUMMARY); // 存储列表 ManagedObjectReference[] dsList = (ManagedObjectReference[]) getDynamicProperty(ecb, mor, DYNAMICPROPERTY_DATASTORE); // 网络列表 ManagedObjectReference[] netList = (ManagedObjectReference[]) getDynamicProperty(ecb, mor, DYNAMICPROPERTY_NETWORK); // List<Object> properties = getDynamicProperties(ecb, mor, // new String[] { DYNAMICPROPERTY_CONFIG, // DYNAMICPROPERTY_SUMMARY, // DYNAMICPROPERTY_DATASTORE, // DYNAMICPROPERTY_NETWORK }); // VirtualMachineConfigInfo config = (VirtualMachineConfigInfo) // properties // .get(0); // VirtualMachineSummary summary = (VirtualMachineSummary) // properties // .get(1); // ManagedObjectReference[] dsList = (ManagedObjectReference[]) // properties // .get(2); // ManagedObjectReference[] netList = (ManagedObjectReference[]) // properties // .get(3); String hoId = ""; if ((runtime != null) && (runtime.getHost() != null)) { hoId = runtime.getHost().get_value(); } resultMap.put(SYNC_VM_HOID, hoId); resultMap.put(SYNC_COMMON_VID, mor.get_value()); resultMap.put(SYNC_COMMON_NAME, config.getName()); int numCore = config.getHardware().getNumCoresPerSocket(); resultMap.put(SYNC_VM_NUMCORE, numCore); if ((config != null) && (summary != null)) { // 常规 // 客户机操作系统 resultMap.put(SUMMARY_COMMON_GUESTFULLNAME, config.getGuestFullName()); // 虚拟机版本,样本数据vmx-08 resultMap.put(SUMMARY_COMMON_VERSION, config.getVersion()); // CPU resultMap.put(SUMMARY_COMMON_CPU, summary.getConfig().getNumCpu()); // 内存,单位为MB resultMap.put( SUMMARY_COMMON_MEMORYSIZEMB, getByteSizeStrFromMB(summary.getConfig().getMemorySizeMB())); // 内存开销,current overhead reservation,单位为字节 resultMap.put( SUMMARY_COMMON_MEMORYOVERHEAD, getByteSizeStrFromBytes(summary.getRuntime().getMemoryOverhead())); // VMware Tools: // 运行状态toolsRunningStatus // VirtualMachineToolsRunningStatus:guestToolsExecutingScripts,guestToolsNotRunning,guestToolsRunning // 状态(toolsStatus,toolsVersionStatus[Since4.0],toolsVersionStatus2[Since5.0]) // VirtualMachineToolsVersionStatus:guestToolsBlacklisted[Since5.0],guestToolsCurrent,guestToolsNeedUpgrade,guestToolsNotInstalled, // guestToolsSupportedNew[Since5.0],guestToolsSupportedOld[Since5.0],guestToolsTooNew[Since5.0],guestToolsTooOld[Since5.0],guestToolsUnmanaged // 正在运行(当前版本) // http://pubs.vmware.com/vsphere-50/topic/com.vmware.wssdk.apiref.doc_50/vim.vm.Summary.GuestSummary.html // toolsStatus // toolsVersionStatus[Since4.0] // toolsVersionStatus2[Since5.0] // 暂时只获取toolsVersionStatus resultMap.put( SUMMARY_COMMON_VMWARETOOLS, cache.getEnum(summary.getGuest().getToolsRunningStatus()) + "(" + cache.getEnum(summary.getGuest().getToolsVersionStatus()) + ")"); // IP地址 resultMap.put( SUMMARY_COMMON_IPADDRESS, Util.normalizeString(summary.getGuest().getIpAddress())); // DNS名称 resultMap.put( SUMMARY_COMMON_HOSTNAME, Util.normalizeString(summary.getGuest().getHostName())); // XXX EVC模式,暂时无法获取 // String SUMMARY_COMMON_EVCMODEL = "evcmodel"; // 状况,poweredOff,poweredOn,suspended // powerstate在alarmDesc中有翻译 // resultMap.put(SUMMARY_COMMON_POWERSTATE, cache // .getAlarmDesc(summary.getRuntime().getPowerState() // .getValue())); String powerState = ""; if (runtime != null) { powerState = runtime.getPowerState().toString(); } resultMap.put(SYNC_VM_POWERSTATE, powerState); // 主机 resultMap.put(SUMMARY_COMMON_HOST, getEntityName(ecb, summary.getRuntime().getHost())); // XXX 活动任务,暂时无法获取 // String SUMMARY_COMMON_ACTIVETASK = "activetask"; // XXX vSphere HA保护,暂时无法获取 // String SUMMARY_COMMON_VSPHEREHA = "vsphereha"; // 资源 // 已消耗的主机CPU,Basic CPU performance // statistics,单位MHz,大概是这个值此值变化比较快 resultMap.put( SUMMARY_RESOURCE_OVERALLCPUUSAGE, summary.getQuickStats().getOverallCpuUsage() + MHZ); // 已消耗的主机内存:consumed host memory,单位为MB resultMap.put( SUMMARY_RESOURCE_HOSTMEMORYUSAGE, getByteSizeStrFromMB(summary.getQuickStats().getHostMemoryUsage())); // 活动客户机内存:active guest memory,单位为MB resultMap.put( SUMMARY_RESOURCE_GUESTMEMORYUSAGE, getByteSizeStrFromMB(summary.getQuickStats().getGuestMemoryUsage())); // 未共享的存储 resultMap.put( SUMMARY_RESOURCE_STORAGE_UNSHARED, getByteSizeStrFromBytes(summary.getStorage().getUnshared())); // 已使用的存储 resultMap.put( SUMMARY_RESOURCE_STORAGE_COMMITTED, getByteSizeStrFromBytes(summary.getStorage().getCommitted())); // 置备的存储 resultMap.put( SUMMARY_RESOURCE_STORAGE_ALL, getByteSizeStrFromBytes( summary.getStorage().getCommitted() + summary.getStorage().getUncommitted())); // 存储列表 DatastoreMgr.recordResultMapDsList(resultMap, ecb, dsList); // 网络列表 NetworkMgr.recordResultMapNetList(resultMap, ecb, netList); // 记录处理正确的标识 recordResultMapSuccess(resultMap); } else { recordResultMapError( resultMap, "获取'" + DYNAMICPROPERTY_CONFIG + "'或'" + DYNAMICPROPERTY_SUMMARY + "'信息为空"); } } else { recordResultMapError(resultMap, "虚拟机'" + vmId + "'不存在"); } } catch (Exception e) { LOGGER.error("getSummary error, ", e); recordResultMapException(resultMap, e); } return resultMap; }