List of usage examples for java.util ListIterator next
E next();
From source file:com.linuxbox.enkive.docsearch.indri.IndriQueryComposer.java
/** * Iterate through all the terms in the phrase and sanitize each one in * place./*from www . j ava 2 s. c o m*/ * * @param phrase */ protected static void sanitizePhraseInPlace(Phrase phrase) { ListIterator<CharSequence> i = phrase.getTermsListIterator(); while (i.hasNext()) { CharSequence charSeq = i.next(); // convert to a StringBuffer if not one already StringBuffer buffer; if (!(charSeq instanceof StringBuffer)) { buffer = new StringBuffer(charSeq); } else { buffer = (StringBuffer) charSeq; } sanitizeStringBuffer(buffer); // replace term in phrase i.set(buffer); } }
From source file:org.apache.cxf.transport.jms.JMSOldConfigHolder.java
public static Properties getInitialContextEnv(AddressType addrType) { Properties env = new Properties(); java.util.ListIterator listIter = addrType.getJMSNamingProperty().listIterator(); while (listIter.hasNext()) { JMSNamingPropertyType propertyPair = (JMSNamingPropertyType) listIter.next(); if (null != propertyPair.getValue()) { env.setProperty(propertyPair.getName(), propertyPair.getValue()); }/*from w w w .j a v a2 s.c om*/ } if (LOG.isLoggable(Level.FINE)) { Enumeration props = env.propertyNames(); while (props.hasMoreElements()) { String name = (String) props.nextElement(); String value = env.getProperty(name); LOG.log(Level.FINE, "Context property: " + name + " | " + value); } } return env; }
From source file:com.amazonaws.hbase.kinesis.utils.EMRUtils.java
/** * Helper method to determine if HBase is installed on this cluster * @param client - The {@link AmazonElasticMapReduceClient} with read permissions * @param clusterId - unique identifier for this cluster * @return true, other throws Runtime exception *//*from ww w .jav a 2 s . c om*/ private static boolean isHBaseInstalled(AmazonElasticMapReduce client, String clusterId) { ListBootstrapActionsResult bootstrapActions = client .listBootstrapActions(new ListBootstrapActionsRequest().withClusterId(clusterId)); ListIterator<Command> iterator = bootstrapActions.getBootstrapActions().listIterator(); while (iterator.hasNext()) { Command command = iterator.next(); if (command.getName().equalsIgnoreCase("Install HBase")) return true; } throw new RuntimeException("ERROR: Apache HBase is not installed on this cluster!!"); }
From source file:com.amazonaws.hbase.kinesis.utils.EMRUtils.java
/** * Helper method to determine if an Amazon EMR cluster exists * /*from ww w .ja v a 2 s . co m*/ * @param client * The {@link AmazonElasticMapReduceClient} with read permissions * @param clusterIdentifier * The Amazon EMR cluster to check * @return true if the Amazon EMR cluster exists, otherwise false */ public static boolean clusterExists(AmazonElasticMapReduce client, String clusterIdentifier) { if (clusterIdentifier != null && !clusterIdentifier.isEmpty()) { ListClustersResult clustersList = client.listClusters(); ListIterator<ClusterSummary> iterator = clustersList.getClusters().listIterator(); ClusterSummary summary; for (summary = iterator.next(); iterator.hasNext(); summary = iterator.next()) { if (summary.getId().equals(clusterIdentifier)) { DescribeClusterRequest describeClusterRequest = new DescribeClusterRequest() .withClusterId(clusterIdentifier); DescribeClusterResult result = client.describeCluster(describeClusterRequest); if (result != null) { Cluster cluster = result.getCluster(); //check if HBase is installed on this cluster if (isHBaseInstalled(client, cluster.getId())) return false; String state = cluster.getStatus().getState(); LOG.info(clusterIdentifier + " is " + state + ". "); if (state.equalsIgnoreCase("RUNNING") || state.equalsIgnoreCase("WAITING")) { LOG.info("The cluster with id " + clusterIdentifier + " exists and is " + state); return true; } } } } } LOG.info("The cluster with id " + clusterIdentifier + " does not exist"); return false; }
From source file:be.ff.gui.web.struts.action.ActionPlugInChain.java
/** * This static method calls the <code>destroy</code> method on all <code>ActionPlugIn</code>s in the chain, * enabling them to release any referenced resources. *//* ww w . j a va 2s . c o m*/ protected static void destroy() { if (log.isDebugEnabled()) { log.debug("[ActionPlugInChain::init] Destroying the action plug-in chain ..."); } ListIterator iter = activeActionPlugInRegister.listIterator(); while (iter.hasNext()) { ActionPlugIn actionPlugIn = (ActionPlugIn) iter.next(); actionPlugIn.destroy(); } }
From source file:com.stratio.crossdata.sh.utils.ConsoleUtils.java
/** * This method save history extracted from the Crossdata console to be persisted in the disk. * * @param console Crossdata console created from a JLine console * @param file represents the file to be created of updated with the statements from the current * session/*from w w w . j a va 2 s . c o m*/ * @param sdf Simple Date Format to create dates for the history file * @throws IOException file couldn't be created or read */ public static void saveHistory(ConsoleReader console, File file, SimpleDateFormat sdf) throws IOException { boolean created = file.createNewFile(); OutputStreamWriter isr; if (created) { isr = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); } else { isr = new OutputStreamWriter(new FileOutputStream(file, true), "UTF-8"); } try (BufferedWriter bufferWriter = new BufferedWriter(isr)) { History history = console.getHistory(); ListIterator<History.Entry> histIter = history.entries(); while (histIter.hasNext()) { History.Entry entry = histIter.next(); bufferWriter.write(sdf.format(new Date())); bufferWriter.write("|"); bufferWriter.write(entry.value().toString()); bufferWriter.newLine(); } bufferWriter.flush(); } }
From source file:Alias2.java
public static void verifyAtLeast(List output, List expected) { verifyLength(output.size(), expected.size(), Test.AT_LEAST); if (!output.containsAll(expected)) { ListIterator it = expected.listIterator(); while (output.contains(it.next())) { }/*ww w .j a v a 2 s . c o m*/ throw new SimpleTestException("expected: <" + it.previous().toString() + ">"); } }
From source file:exm.stc.ic.ICUtil.java
public static void replaceVarsInList(Map<Var, Arg> replacements, List<Var> vars, boolean removeDupes, boolean removeMapped) { // Remove new duplicates ArrayList<Var> alreadySeen = null; if (removeDupes) { alreadySeen = new ArrayList<Var>(vars.size()); }/*from www. j a v a 2 s .co m*/ ListIterator<Var> it = vars.listIterator(); while (it.hasNext()) { Var v = it.next(); if (replacements.containsKey(v)) { Arg oa = replacements.get(v); if (oa.isVar()) { if (removeDupes && alreadySeen.contains(oa.getVar())) { it.remove(); } else { it.set(oa.getVar()); if (removeDupes) { alreadySeen.add(oa.getVar()); } } } } else { if (removeDupes) { if (alreadySeen.contains(v)) { it.remove(); } else { alreadySeen.add(v); } } } } }
From source file:com.twitter.hraven.etl.FileLister.java
/** * prunes the given list/array of files based on their sizes * * @param maxFileSize -max #bytes to be stored in an hbase cell * @param origList - input list of files to be processed * @param hdfs - filesystem to be looked at * @param inputPath - root dir of the path containing history files * @return - pruned array of FileStatus of files to be processed */// w ww. j a v a2 s.c o m static FileStatus[] pruneFileListBySize(long maxFileSize, FileStatus[] origList, FileSystem hdfs, Path inputPath) { LOG.info("Pruning orig list of size " + origList.length + " for source" + inputPath.toUri()); long fileSize = 0L; List<FileStatus> prunedFileList = new ArrayList<FileStatus>(); Set<String> toBeRemovedJobId = new HashSet<String>(); for (int i = 0; i < origList.length; i++) { fileSize = origList[i].getLen(); // check if hbase can store this file if yes, consider it for processing if (fileSize <= maxFileSize) { prunedFileList.add(origList[i]); } else { Path hugeFile = origList[i].getPath(); LOG.info("In getListFilesToProcess filesize " + fileSize + " has exceeded maxFileSize " + maxFileSize + " for " + hugeFile.toUri()); // note the job id so that we can remove the other file (job conf or job history) toBeRemovedJobId.add(getJobIdFromPath(hugeFile)); } } if (prunedFileList.size() == 0) { LOG.info("Found no files worth processing. Returning 0 sized array"); return new FileStatus[0]; } String jobId = null; ListIterator<FileStatus> it = prunedFileList.listIterator(); while (it.hasNext()) { if (toBeRemovedJobId.size() == 0) { // no files to remove break; } Path curFile = it.next().getPath(); jobId = getJobIdFromPath(curFile); if (toBeRemovedJobId.contains(jobId)) { LOG.info("Removing from prunedList " + curFile.toUri()); it.remove(); /* * removing the job id from the hash set since there would be only * one file with this job id in the prunedList, the other file with * this job id was huge and was already moved out */ toBeRemovedJobId.remove(jobId); } } return prunedFileList.toArray(new FileStatus[prunedFileList.size()]); }
From source file:com.ibm.soatf.config.DirectoryStructureManager.java
/** * * @throws FrameworkConfigurationException *///from w w w .j av a 2s . co m public static void checkFrameworkDirectoryStructure() throws FrameworkConfigurationException { MasterConfiguration masterConfig = ConfigurationManager.getInstance().getMasterConfig(); final ListIterator<SOATestingFrameworkMasterConfiguration.Interfaces.Interface> interfaces = masterConfig .getXmlConfig().getInterfaces().getInterface().listIterator(); while (interfaces.hasNext()) { validateIfaceStructure(interfaces.next()); } }