public static Pair<String, String> splitToDcAndCluster(String dataCenter) { if (dataCenter == null) { return new Pair<>(null, null); } if (!dataCenter.contains("/")) { //$NON-NLS-1$ return new Pair<>(dataCenter, null); } int lastSlash = dataCenter.lastIndexOf("/"); //$NON-NLS-1$ String dataCenterPart = dataCenter.substring(0, lastSlash); String clusterPart = dataCenter.substring(lastSlash + 1); return new Pair<>(dataCenterPart, clusterPart); }
public ServerCpu getCpuByName(String cpuName, Version clusterVersion) { return cpuMap.get(new Pair<>(cpuName, clusterVersion)); }
private static Pair<String, String> parseSlashSeparatedPair(String slashSeparatedString) { List<String> splitted = trimElements(slashSeparatedString.split("/")); return (splitted.size() == 2) ? new Pair<>(splitted.get(0), splitted.get(1)) : null; }
private void initCpuMapForVersion(Version version, List<ServerCpu> cpus) { for (ServerCpu cpu : cpus) { cpuMap.put(new Pair<>(cpu.getCpuName(), version), cpu); } }
private void initSize() { setBrickSize(new Pair<>(SizeUnit.BYTES, 0D)); }
public Collection<DiskInterface> getDiskHotpluggableInterfaces(Integer osId, Version version) { Set<String> diskHotpluggableInterfaces = getDiskHotpluggableInterfacesMap().get(new Pair<>(osId, version)); if (diskHotpluggableInterfaces == null) { return Collections.emptySet(); } Collection<DiskInterface> diskInterfaces = new HashSet<>(); for (String diskHotpluggableInterface : diskHotpluggableInterfaces) { diskInterfaces.add(DiskInterface.valueOf(diskHotpluggableInterface)); } return diskInterfaces; }
@Override public Map<Pair<Integer, Version>, Set<String>> getDiskHotpluggableInterfacesMap() { Set<Version> versionsWithNull = new HashSet<>(Version.ALL); versionsWithNull.add(null); Map<Pair<Integer, Version>, Set<String>> diskHotpluggableInterfacesMap = new HashMap<>(); for (Integer osId : getOsIds()) { for (Version version : versionsWithNull) { diskHotpluggableInterfacesMap.put( new Pair<>(osId, version), getDiskHotpluggableInterfaces(osId, version)); } } return diskHotpluggableInterfacesMap; }
public Boolean getNicHotplugSupport(Integer osId, Version version) { Pair<Integer, Version> pair = new Pair<>(osId, version); if (getNicHotplugSupportMap().containsKey(pair)) { return getNicHotplugSupportMap().get(pair); } return false; }
public static Stream<Pair<String, String>> mockEngineLocalConfiguration() { return Stream.of( new Pair<>("ENGINE_PKI_TRUST_STORE_TYPE", "JKS"), new Pair<>("ENGINE_PKI_TRUST_STORE", TrustStoreTestUtils.getTrustStorePath()), new Pair<>("ENGINE_PKI_TRUST_STORE_PASSWORD", "NoSoup4U"), new Pair<>("ENGINE_PKI_ENGINE_STORE_TYPE", "PKCS12"), new Pair<>("ENGINE_PKI_ENGINE_STORE", TrustStoreTestUtils.getTrustStorePath()), new Pair<>("ENGINE_PKI_ENGINE_STORE_PASSWORD", "NoSoup4U"), new Pair<>("ENGINE_PKI_ENGINE_STORE_ALIAS", "1") ); }
@Override public Map<Pair<Integer, Version>, Boolean> getNicHotplugSupportMap() { List<Version> versions = new ArrayList<>(Config.<HashSet<Version>>getValue(ConfigValues.SupportedClusterLevels)); Map<Pair<Integer, Version>, Boolean> hotplugSupportOsIdVersionMap = new HashMap<>(); for (Integer osId : getOsIds()) { for (Version version : versions) { hotplugSupportOsIdVersionMap.put( new Pair<>(osId, version), hasNicHotplugSupport(osId, version)); } } return hotplugSupportOsIdVersionMap; }
protected Pair<T, V> addGhostEntry() { T value = createGhostValue(); V widget = addEntry(value, true); return new Pair<>(value, widget); }
public Set<Pair<String, Guid>> getHostNamesForVolume(GlusterVolumeEntity volume) { Set<Pair<String, Guid>> hosts = new HashSet<>(); for(GlusterBrickEntity currentBrick : volume.getBricks()) { hosts.add(new Pair<>(currentBrick.getServerName(), currentBrick.getServerId())); } return hosts; }
public static Pair<SizeUnit, Double> autoConvert(long size, SizeUnit inUnit) { for (Pair<Long, SizeUnit> currentUnitPair : SizeUnit.weightToUnit) { if (size / Math.pow(CONVERT_FACTOR, currentUnitPair.getFirst() - inUnit.getUnitWeight()) >= 1) { return new Pair<>(currentUnitPair.getSecond(), SizeConverter.convert(size, inUnit, currentUnitPair.getSecond()).doubleValue()); } } return new Pair<>(SizeUnit.BYTES, (double) size); }
public void addFunction(PolicyUnit policyUnit) { usedFunctions.add(new Pair<>(policyUnit, 1)); for (int i = 0; i < unusedFunctions.size(); i++) { if (unusedFunctions.get(i).getId().equals(policyUnit.getId())) { unusedFunctions.remove(policyUnit); break; } } refreshCustomProperties(null, false); getFunctionsChangedEvent().raise(this, EventArgs.EMPTY); }
private List<Pair<GraphicsType, DisplayType>> parseDisplayProtocols(int osId, Version version) { List<Pair<GraphicsType, DisplayType>> graphicsAndDisplays = new ArrayList<>(); String displayAndGraphicsLine = getValueByVersion(idToUnameLookup.get(osId), "devices.display.protocols", version); // todo - use different key? for (String displayAndGraphics : displayAndGraphicsLine.split(",")) { Pair<String, String> pair = parseSlashSeparatedPair(displayAndGraphics); if (pair != null) { GraphicsType graphics = GraphicsType.fromString(pair.getFirst()); DisplayType display = DisplayType.valueOf(pair.getSecond()); graphicsAndDisplays.add(new Pair<>(graphics, display)); } } return graphicsAndDisplays; }
@Test public void testDisplayTypes() { List<Pair<GraphicsType, DisplayType>> supportedGraphicsAndDisplays = OsRepositoryImpl.INSTANCE.getGraphicsAndDisplays().get(777).get(null); boolean isSizeCorrect = supportedGraphicsAndDisplays.size() == 2; boolean containsSameElements = new HashSet<>(supportedGraphicsAndDisplays) .equals(new HashSet<>(Arrays.asList( new Pair<>(GraphicsType.SPICE, DisplayType.qxl), new Pair<>(GraphicsType.VNC, DisplayType.vga)))); assertTrue(isSizeCorrect); assertTrue(containsSameElements); }
@Override public List<Pair<Guid, String>> getAllDevicesHashes() { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource(); return getCallsHandler().executeReadList("GetAllHashesFromVmDynamic", (rs, i) -> new Pair<>(new Guid(rs.getString("vm_guid")), rs.getString("hash")), parameterSource); }
@Override public Pair<Guid, Guid> getId() { return new Pair<>(getFeature().getId(), getClusterId()); }