List of usage examples for java.util TreeSet size
public int size()
From source file:org.auscope.gridtools.RegistryQueryClient.java
/** * Gets the clusters available at a site. * //from w w w. ja va 2s . c o m * @param site The name of the site * @return An array of the available clusters. */ public String[] getClusterNamesAtSite(String site) { String clusters[] = new String[0]; String xpathQuery = "//*[local-name()='Site']/child::node()[local-name()='Name']" + "[translate(text(),'abcdefghijklmnopqrstuvwxyz'," + "'ABCDEFGHIJKLMNOPQRSTUVWXYZ')=translate('" + site + "'," + "'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')]" + "/parent::node()/descendant::node()[local-name()='Cluster']"; // Query MDS file. NodeList codeAvailNodeList = turboMDSquery(xpathQuery); if (codeAvailNodeList != null) { TreeSet<String> myTreeSet = new TreeSet<String>(); for (int i = 0; i < codeAvailNodeList.getLength(); i++) { Element siteEl = (Element) codeAvailNodeList.item(i); myTreeSet.add(getTextValue(siteEl, "Name")); } clusters = myTreeSet.toArray(new String[myTreeSet.size()]); } return clusters; }
From source file:org.auscope.gridtools.RegistryQueryClient.java
/** * Gets a list of all the sites that have the specified version of a code. * //from ww w. j a v a 2 s . com * @param code The name of the code * @param version The particular version required * @return An array of sites with this exact code/version combination */ public String[] getAllSitesWithAVersionOfACode(String code, String version) { String names[] = new String[0]; String versionString = ""; if (version.length() > 0) { versionString = "/child::node()[contains(name(),Version)][text()='" + version + "']"; } String xpathQuery = "//*[local-name()='SoftwarePackage']/child::node()[contains(name(),Name)]" + "[text()='" + code + "']/parent::node()" + versionString + "/ancestor::node()[local-name()='Site']"; // Parse the document NodeList codeAvailNodeList = turboMDSquery(xpathQuery); if (codeAvailNodeList != null) { TreeSet<String> myTreeSet = new TreeSet<String>(); for (int i = 0; i < codeAvailNodeList.getLength(); i++) { Element siteEl = (Element) codeAvailNodeList.item(i); myTreeSet.add(getTextValue(siteEl, "Name")); } names = myTreeSet.toArray(new String[myTreeSet.size()]); } return names; }
From source file:org.auscope.gridtools.RegistryQueryClient.java
/** * Gets all the distinct versions of a particular code that are available * on the Grid. This method must query all the sites for their versions of * this code, and then collate the information into a list of unique * versions.// w w w.j a v a 2 s . c o m * * @return An array of all versions available */ public String[] getAllVersionsOfCodeOnGrid(String code) { String versions[] = new String[0]; String xpathQuery = "//*[local-name()='SoftwarePackage']" + "/ancestor::node()[local-name()='Site']" + "/descendant::node()[local-name()='SoftwarePackage']" + "/child::node()[contains(name(),Name)][text()='" + code + "']" + "/parent::node()"; // Query MDS file NodeList verAvailableList = turboMDSquery(xpathQuery); if (verAvailableList != null) { // Keep unique using TreeSet TreeSet<String> myTreeSet = new TreeSet<String>(); for (int i = 0; i < verAvailableList.getLength(); i++) { Element siteEl = (Element) verAvailableList.item(i); myTreeSet.add(getTextValue(siteEl, "Version")); } versions = myTreeSet.toArray(new String[myTreeSet.size()]); } return versions; }
From source file:org.auscope.gridtools.RegistryQueryClient.java
/** * Gets the compute elements in a particular cluster at the given site. * //from www. j av a 2 s .co m * @param site The site to query * @param cluster The cluster at the site to query * @return An array of the available compute elements */ public String[] getComputeElementsOfClusterAtSite(String site, String cluster) { String names[] = new String[0]; String xpathQuery = "//*[local-name()='Site']/child::node()[local-name()='Name']" + "[translate(text(),'abcdefghijklmnopqrstuvwxyz'," + "'ABCDEFGHIJKLMNOPQRSTUVWXYZ')=translate('" + site + "'," + "'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')]" + "/parent::node()/descendant::node()[local-name()='Cluster']" + "/child::node()[local-name()='Name'][translate(text()," + "'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" + "=translate('" + cluster + "','abcdefghijklmnopqrstuvwxyz'" + ",'ABCDEFGHIJKLMNOPQRSTUVWXYZ')]/parent::node()" + "/descendant::node()[local-name()='ComputingElement']"; // Parse the document NodeList computeElsNodeList = turboMDSquery(xpathQuery); if (computeElsNodeList != null) { TreeSet<String> myTreeSet = new TreeSet<String>(); for (int i = 0; i < computeElsNodeList.getLength(); i++) { Element siteEl = (Element) computeElsNodeList.item(i); myTreeSet.add(getTextValue(siteEl, "Name")); } names = myTreeSet.toArray(new String[myTreeSet.size()]); } return names; }
From source file:org.auscope.gridtools.RegistryQueryClient.java
/** * Gets a list of versions of a code available at a site. * /* w ww . jav a2s . com*/ * @param site The name of the site * @param code The name of the code * @return An array of versions of this code */ public String[] getVersionsOfCodeAtSite(String site, String code) { String[] version = new String[0]; String xpathQuery = "//*[local-name()='Site']" + "/child::node()[local-name()='Name'][text()='" + site + "']" + "/ancestor::node()[local-name()='Site']" + "/descendant::node()[local-name()='SoftwarePackage']" + "/child::node()[local-name()='Name']" + "[text()='" + code + "']/parent::node()"; // Parse the document NodeList codeVersionNodeList = turboMDSquery(xpathQuery); if (codeVersionNodeList != null) { TreeSet<String> myTreeSet = new TreeSet<String>(); for (int i = 0; i < codeVersionNodeList.getLength(); i++) { Element siteEl = (Element) codeVersionNodeList.item(i); myTreeSet.add(getTextValue(siteEl, "Version")); } version = myTreeSet.toArray(new String[myTreeSet.size()]); } return version; }
From source file:org.auscope.gridtools.RegistryQueryClient.java
/** * Gets the free job slots of compute elements of a cluster at a site. * /*from w ww . ja v a 2 s .co m*/ * @param site The site name * @param cluster The cluster name * @param computeEl The compute element * @return The free job slots */ public String[] getFreeJobSlotsOfComputeElementsOfClusterAtSite(String site, String cluster, String computeEl) { String names[] = new String[0]; String xpathQuery = "//*[local-name()='Site']" + "/child::node()[local-name()='Name']" + "[translate(text(),'abcdefghijklmnopqrstuvwxyz'," + "'ABCDEFGHIJKLMNOPQRSTUVWXYZ')=translate('" + site + "','abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')]" + "/parent::node()/descendant::node()[local-name()='Cluster']" + "/child::node()[local-name()='Name'][translate(text()," + "'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" + "=translate('" + cluster + "','abcdefghijklmnopqrstuvwxyz'" + ",'ABCDEFGHIJKLMNOPQRSTUVWXYZ')]/parent::node()" + "/descendant::node()[local-name()='ComputingElement']"; // Parse the document NodeList slotsAvailNodeList = turboMDSquery(xpathQuery); if (slotsAvailNodeList != null) { TreeSet<String> myTreeSet = new TreeSet<String>(); for (int i = 0; i < slotsAvailNodeList.getLength(); i++) { Element siteEl = (Element) slotsAvailNodeList.item(i); myTreeSet.add(getTextValue(siteEl, "Name")); } names = myTreeSet.toArray(new String[myTreeSet.size()]); } return names; }
From source file:hu.ppke.itk.nlpg.purepos.decoder.AbstractDecoder.java
protected Set<Entry<Integer, Double>> pruneGuessedTags(Map<Integer, Double> guessedTags) { TreeSet<Entry<Integer, Double>> set = new TreeSet<Map.Entry<Integer, Double>>( /* reverse comparator */ new Comparator<Entry<Integer, Double>>() { @Override/* ww w . java 2 s . c o m*/ public int compare(Entry<Integer, Double> o1, Entry<Integer, Double> o2) { if (o1.getValue() > o2.getValue()) return -1; else if (o1.getValue() < o2.getValue()) return 1; else return Double.compare(o1.getKey(), o2.getKey()); } }); int maxTag = SuffixGuesser.getMaxProbabilityTag(guessedTags); double maxVal = guessedTags.get(maxTag); double minval = maxVal - sufTheta; for (Entry<Integer, Double> entry : guessedTags.entrySet()) { if (entry.getValue() > minval) { set.add(entry); } } if (set.size() > maxGuessedTags) { Iterator<Entry<Integer, Double>> it = set.descendingIterator(); while (set.size() > maxGuessedTags) { it.next(); it.remove(); } } return set; }
From source file:org.auscope.gridtools.RegistryQueryClient.java
/** * Gets all sites' code versions./*from w ww. j a v a 2s .c om*/ * * @param requestedCode the requested code * * @return all sites' code versions */ public String[] getAllSitesCodeVersions(String requestedCode) { String versions[] = new String[0]; String xpathQuery = "//*[local-name()='SoftwarePackage']" + "/ancestor::node()[local-name()='Site']" + "/descendant::node()[local-name()='SoftwarePackage']" + "/child::node()[contains(name(),Name)][text()='" + requestedCode + "']" + "/parent::node()"; // Old Version. // "/child::node()[local-name()='Version']"; // Parse the document NodeList codeAvailNodeList = turboMDSquery(xpathQuery); if (codeAvailNodeList != null) { TreeSet<String> myTreeSet = new TreeSet<String>(); for (int i = 0; i < codeAvailNodeList.getLength(); i++) { Element siteEl = (Element) codeAvailNodeList.item(i); myTreeSet.add(getTextValue(siteEl, "Version")); } versions = myTreeSet.toArray(new String[myTreeSet.size()]); } return versions; }
From source file:dhbw.ka.mwi.businesshorizon2.ui.process.period.timeline.TimelinePresenter.java
/** * Zuknftige stochastische Perioden anlegen<br> * dabei wird bercksichtigt, dass bereits Perioden vorhanden sind.<br> * Diese werden zuerst ausgegeben und, sofern mehr ausgegeben werden sollen,<br> * neue Perioden hinzugefgt.<br>// ww w. j a v a 2s. co m * brige Perioden werden ggf gelscht * * @author Annika Weis */ private void addPastPeriods_vorhanden() { /* * Wenn bereits Perioden vorhanden sind: so viele anlegen, sonst so * viele, wie es der Benutzer vorgibt auf der Parameter-Maske */ logger.debug("past periods: " + projectProxy.getSelectedProject().getSpecifiedPastPeriods()); int i = 0; // bei Zeitreihenanalyse: ein Jahr mehr int weitere_perioden_past = 0; if (methode == "Zeitreihenanalyse") { weitere_perioden_past = -1; // Annika Weis 2014-05-03 } sumPastPeriods = 0; Period basisperiode = null; try { /* * Perioden mssen in umgekehrter Reihenfolge angegeben werden, * sonst ensteht etwas wie: 2012-2011-2010-2009-2008-2013 */ int laenge; TreeSet<Period> perioden = (TreeSet<Period>) projectProxy.getSelectedProject().getStochasticPeriods() .getPeriods(); // Lnge der vorhandenen Perioden laenge = perioden.size(); // nur so viele Perioden ausgeben, wie der Benutzer angegeben hat // bzw vorhanden sind laenge = Math.min(laenge, projectProxy.getSelectedProject().getSpecifiedPastPeriods() + weitere_perioden_past);// // wenn mehr Perioden vorhanden sind als gewnscht... if (perioden.size() > projectProxy.getSelectedProject().getSpecifiedPastPeriods() + weitere_perioden_past) { // ...dann nur die letzten gewnschten ausgeben laenge = perioden.size() - (projectProxy.getSelectedProject().getSpecifiedPastPeriods() + weitere_perioden_past) + 1; } else { // ...sonst alle ausgeben laenge = 0; } logger.debug("Lnge: " + laenge); /** * Perioden ausgeben: Anfangen bei der letzten (hchstes Jahr!) bis * zur gewnschten Lnge Ausgabe erfolgt rckwrts -2 wegen * Array-Index 0 UND Basisperiode abziehen */ for (int x = perioden.size() - 1; x >= 0; x--) { Period period = (Period) perioden.toArray()[x]; logger.debug(x + " - " + period.getYear()); if (x == perioden.size() - 1) { logger.debug("Basisperiode: " + period.getYear()); getView().addBasePeriod(period); basisperiode = period; pastPeriods.addPeriod(period); } else if (x < laenge - 2) { logger.debug("Lsche Jahr " + period.getYear()); pastPeriods.removePeriod(period); } else { logger.debug("Anlegen " + period.getYear()); getView().addPastPeriod(period); sumPastPeriods++; pastPeriods.addPeriod(period); } } projectProxy.getSelectedProject().setStochasticPeriods(pastPeriods); periodClicked(basisperiode); } catch (Exception e) { logger.debug("Fehler: " + e.getMessage()); e.printStackTrace(); } // wenn nicht genug Perioden angelegt wurden wie vom Benutzer angegeben logger.debug(sumPastPeriods + " | " + projectProxy.getSelectedProject().getSpecifiedPastPeriods()); if (sumPastPeriods == 0) { create_base(); } if (sumPastPeriods < projectProxy.getSelectedProject().getSpecifiedPastPeriods() + weitere_perioden_past) { logger.debug("Manuell Perioden anlegen"); addPastPeriods(projectProxy.getSelectedProject().getSpecifiedPastPeriods() + weitere_perioden_past - sumPastPeriods, stochasticInput); } logger.debug("Periodenanzahl: " + sumPastPeriods); return; }
From source file:org.auscope.gridtools.RegistryQueryClient.java
/** * Gets the queue (a.k.a. Compute Elements) that matches the walltime * requested and the subcluster's hostname. * /*from w w w.j a v a 2 s . c om*/ * @param subCluster The subcluster's host name * @param wallTime The walltime to request * @return A list of matching queues/computing elements */ public String[] getComputingElementForWalltimeAndSubcluster(String subCluster, String wallTime) { /* * //*[local-name()='Site']/child::node()[local-name()='Cluster'] * /child::node()[local-name()='ComputingElement'] * /child::node()[local-name()='MaxWallClockTime'][number(text())>'16']/parent::node() * /child::node()[local-name()='HostName'][text()='hydra.sapac.edu.au']/parent::node() */ String xpathQuery = "//*[local-name()='Site']/child::node()[local-name()='Cluster']" + "/child::node()[local-name()='ComputingElement']" + "/child::node()[local-name()='HostName'][text()='" + subCluster + "']/parent::node()"; if (wallTime.length() > 0) { xpathQuery += "/child::node()[local-name()='MaxWallClockTime']" + "[number(text())>'" + wallTime + "']/parent::node()"; } String names[] = new String[0]; // Parse the document NodeList elementNodeList = turboMDSquery(xpathQuery); if (elementNodeList != null) { TreeSet<String> myTreeSet = new TreeSet<String>(); for (int i = 0; i < elementNodeList.getLength(); i++) { Element siteEl = (Element) elementNodeList.item(i); myTreeSet.add(getTextValue(siteEl, "Name")); } names = myTreeSet.toArray(new String[myTreeSet.size()]); } return names; }