List of usage examples for java.util ArrayList addAll
public boolean addAll(Collection<? extends E> c)
From source file:babel.prep.extract.NutchPageExtractor.java
/** * Enumerates all segment directories.// w w w. ja v a 2s .co m */ protected List<Path> allSegmentDirs(Path segmentsDir) throws IOException { ArrayList<Path> dirs = new ArrayList<Path>(); FileStatus[] fstats = m_fs.listStatus(segmentsDir, HadoopFSUtil.getPassDirectoriesFilter(m_fs)); Path[] files = HadoopFSUtil.getPaths(fstats); if (files != null && files.length > 0) { dirs.addAll(Arrays.asList(files)); } return dirs; }
From source file:org.hammer.santamaria.mapper.dataset.CKAN2DataSetInput.java
@SuppressWarnings("unchecked") public BSONObject getDataSet(String url, String datasource, String id, BSONObject c) { BSONObject dataset = new BasicBSONObject(); dataset.put("datasource", datasource); dataset.put("id", id); String sId = EncodeURIComponent(id); LOG.info("---> id " + id + " - " + sId); HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().setParameter(ClientPNames.HANDLE_REDIRECTS, false); LOG.info(/*www.j a va2 s . c om*/ "******************************************************************************************************"); LOG.info(" "); LOG.info(url + PACKAGE_GET + sId); LOG.info(" "); LOG.info( "******************************************************************************************************"); GetMethod method = new GetMethod(url + PACKAGE_GET + sId); method.setRequestHeader("User-Agent", "Hammer Project - SantaMaria crawler"); method.getParams().setParameter(HttpMethodParams.USER_AGENT, "Hammer Project - SantaMaria crawler"); method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); try { int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new Exception("Method failed: " + method.getStatusLine()); } byte[] responseBody = method.getResponseBody(); LOG.debug(new String(responseBody)); Document result = Document.parse(new String(responseBody)); if (result != null) { dataset.put("title", result.get("title")); dataset.put("author", result.get("author")); dataset.put("author_email", result.get("author_email")); dataset.put("license_id", result.get("license")); } ArrayList<String> tags = new ArrayList<String>(); ArrayList<String> meta = new ArrayList<String>(); ArrayList<String> other_tags = new ArrayList<String>(); if (result.containsKey("author")) other_tags.add(result.get("author").toString()); if (result.containsKey("title")) other_tags.addAll(DSSUtils.GetKeyWordsFromText(result.get("title").toString())); if (result.containsKey("description")) other_tags.addAll(DSSUtils.GetKeyWordsFromText(result.get("description").toString())); ArrayList<Document> resources = new ArrayList<Document>(); if (result != null && result.containsKey("resources")) { resources = (ArrayList<Document>) result.get("resources"); for (Document resource : resources) { if (resource.getString("format").toUpperCase().equals("JSON")) { dataset.put("dataset-type", "JSON"); dataset.put("url", resource.get("url")); dataset.put("created", resource.get("created")); dataset.put("description", resource.get("description")); dataset.put("revision_timestamp", resource.get("revision_timestamp")); meta = DSSUtils.GetMetaByResource(resource.get("url").toString()); } } } if (result != null && result.containsKey("tags")) { ArrayList<Document> tagsFromCKAN = (ArrayList<Document>) result.get("tags"); for (Document tag : tagsFromCKAN) { if (tag.containsKey("state") && tag.getString("state").toUpperCase().equals("ACTIVE")) { tags.add(tag.getString("display_name").trim().toLowerCase()); } else if (tag.containsKey("display_name")) { tags.add(tag.getString("display_name").trim().toLowerCase()); } } } dataset.put("tags", tags); dataset.put("meta", meta); dataset.put("resources", resources); dataset.put("other_tags", other_tags); } catch (Exception e) { e.printStackTrace(); LOG.error(e); } finally { method.releaseConnection(); } return dataset; }
From source file:httpRequests.GetPost.java
public ArrayList<ArrayList<String>> getAllChallengerPlayers(float headersLevel, float dataLevel) { try {/*from w ww . j a va 2 s . c o m*/ String url = "https://euw.api.pvp.net/api/lol/euw/v2.5/league/challenger?type=RANKED_SOLO_5x5&api_key="; JSONObject obj = sendGet(url); ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>(); ArrayList<String> headers = new ArrayList<String>(); headers.addAll(asSortedList(getHeaders(headersLevel, obj))); result = getRows(obj, headers, dataLevel); result.add(0, headers); return result; } catch (Exception e) { System.out.println(e.getLocalizedMessage()); return null; } }
From source file:httpRequests.GetPost.java
public ArrayList<ArrayList<String>> getAllMasterPlayers(float headersLevel, float dataLevel) { try {/*from w w w .j ava 2 s .co m*/ String url = "https://euw.api.pvp.net/api/lol/euw/v2.5/league/master?type=RANKED_SOLO_5x5&api_key="; JSONObject obj = sendGet(url); ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>(); ArrayList<String> headers = new ArrayList<String>(); headers.addAll(asSortedList(getHeaders(headersLevel, obj))); result = getRows(obj, headers, dataLevel); result.add(0, headers); return result; } catch (Exception e) { System.out.println(e.getLocalizedMessage()); return null; } }
From source file:se.inera.axel.shs.broker.routing.internal.DefaultShsRouter.java
@Override synchronized public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ContextRefreshedEvent) { ListableBeanFactory beanFactory = (ListableBeanFactory) event.getSource(); Map pluginMap = BeanFactoryUtils.beansOfTypeIncludingAncestors(beanFactory, ShsPluginRegistration.class); ArrayList<ShsPluginRegistration> pluginRegistrations = new ArrayList<ShsPluginRegistration>(); pluginRegistrations.addAll(pluginMap.values()); for (ShsPluginRegistration reg : pluginRegistrations) { log.info("Registered plugin '" + reg.getName() + "' from the application context"); }/* w ww . java2 s. c o m*/ if (!pluginRegistrations.isEmpty()) { setPluginRegistrations(pluginRegistrations); } } }
From source file:com.splout.db.hadoop.StoreDeployerTool.java
/** * Deploy already generated tablespaces at a time. *//*from w w w . j a va 2 s . co m*/ @SuppressWarnings("unchecked") public void deploy(Collection<TablespaceDepSpec> deployments) throws JSONSerDeException, IOException { // We now query for the alive DNodes and build deployRequests accordingly DeployRequest[] deployRequests = new DeployRequest[deployments.size()]; log.info("Querying Splout QNode for list of DNodes..."); SploutClient client = new SploutClient(qnode); List<String> dnodes = client.dNodeList(); if (dnodes == null || dnodes.size() == 0) { throw new IOException("No available DNodes in Splout cluster."); } int tIndex = 0; for (TablespaceDepSpec tablespace : deployments) { Path tablespaceOut = new Path(tablespace.getSourcePath()); // Define a DeployRequest for this Tablespace deployRequests[tIndex] = new DeployRequest(); // Splout only accepts absolute URIs FileSystem sourceFs = tablespaceOut.getFileSystem(conf); if (!sourceFs.exists(tablespaceOut)) { throw new IllegalArgumentException("Folder doesn't exist: " + tablespaceOut); } @SuppressWarnings("deprecation") Path absoluteOutPath = tablespaceOut.makeQualified(sourceFs); Path partitionMapPath = new Path(tablespaceOut, TablespaceGenerator.OUT_PARTITION_MAP); if (!sourceFs.exists(partitionMapPath)) { throw new IllegalArgumentException( "Invalid tablespace folder: " + tablespaceOut + " doesn't contain a partition-map file."); } // Load the partition map PartitionMap partitionMap = JSONSerDe.deSer(HadoopUtils.fileToString(sourceFs, partitionMapPath), PartitionMap.class); // Load the init statements, if they exist ArrayList<String> initStatements = new ArrayList<String>(); Path initStatementsPath = new Path(tablespaceOut, TablespaceGenerator.OUT_INIT_STATEMENTS); if (sourceFs.exists(initStatementsPath)) { initStatements.addAll( JSONSerDe.deSer(HadoopUtils.fileToString(sourceFs, initStatementsPath), ArrayList.class)); } // Add the other initStatements coming in the deploy request if (tablespace.getInitStatements() != null) { initStatements.addAll(tablespace.getInitStatements()); } String engine = DefaultEngine.class.getName(); // New : load the engine id used in the generation tool, if exists ( to maintain backwards compatibility ) Path engineId = new Path(tablespaceOut, TablespaceGenerator.OUT_ENGINE); if (sourceFs.exists(engineId)) { engine = HadoopUtils.fileToString(sourceFs, engineId); log.info("Using generated engine id: " + engine); } // Finally set deployRequests[tIndex].setInitStatements(initStatements); deployRequests[tIndex].setEngine(engine); deployRequests[tIndex].setTablespace(tablespace.getTablespace()); deployRequests[tIndex].setData_uri(new Path(absoluteOutPath, "store").toUri().toString()); deployRequests[tIndex].setPartitionMap(partitionMap.getPartitionEntries()); // If rep > dnodes, impossible to reach this level of replication int repFactor = tablespace.getReplication(); if (dnodes.size() < repFactor) { log.warn( "WARNING: Replication factor " + repFactor + " for tablespace " + tablespace.getTablespace() + " is bigger than the number of serving DNodes. Adjusting replication factor to " + dnodes.size()); repFactor = dnodes.size(); } deployRequests[tIndex] .setReplicationMap(ReplicationMap.roundRobinMap(partitionMap.getPartitionEntries().size(), repFactor, dnodes.toArray(new String[0])).getReplicationEntries()); tIndex++; } // Finally we send the deploy request DeployInfo dInfo = client.deploy(deployRequests); log.info("Deploy request of [" + deployments.size() + "] tablespaces performed. Deploy on [" + qnode + "] with version [" + dInfo.getVersion() + "] in progress."); }
From source file:httpRequests.GetPost.java
public ArrayList<ArrayList<String>> getAllChampions(float headersLevel, float dataLevel) { try {//from www . j a v a 2s .co m String url = "https://global.api.pvp.net/api/lol/static-data/euw/v1.2/champion?champData=image&api_key="; JSONObject obj = sendGet(url); obj = (JSONObject) obj.get("data"); ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>(); ArrayList<String> headers = new ArrayList<String>(); headers.addAll(asSortedList(getHeaders(headersLevel, obj))); result = getRows(obj, headers, dataLevel); result.add(0, headers); return result; } catch (Exception e) { System.out.println(e.getMessage()); return null; } }
From source file:httpRequests.GetPost.java
public ArrayList<ArrayList<String>> getAllItems(float headersLevel, float dataLevel) { try {/* ww w .j av a2 s .co m*/ String url = "https://global.api.pvp.net/api/lol/static-data/euw/v1.2/item?itemListData=all&api_key="; JSONObject obj = sendGet(url); obj = (JSONObject) obj.get("data"); ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>(); ArrayList<String> headers = new ArrayList<String>(); headers.addAll(asSortedList(getHeaders(headersLevel, obj))); result = getRows(obj, headers, dataLevel); result.add(0, headers); return result; } catch (Exception e) { System.out.println(e.getMessage()); return null; } }
From source file:httpRequests.GetPost.java
public ArrayList<ArrayList<String>> getAllMatchesByPlayerID(String playerID, float headersLevel, float dataLevel) { try {/*www . j a va 2 s . c o m*/ String url = "https://euw.api.pvp.net/api/lol/euw/v2.2/matchlist/by-summoner/" + playerID + "?rankedQueues=RANKED_SOLO_5x5&seasons=SEASON2016&api_key="; JSONObject obj = sendGet(url); if (obj == null) return null; ArrayList<ArrayList<String>> result = new ArrayList<ArrayList<String>>(); ArrayList<String> headers = new ArrayList<String>(); headers.addAll(asSortedList(getHeaders(headersLevel, obj))); result = getRows(obj, headers, dataLevel); result.add(0, headers); return result; } catch (Exception e) { System.out.println(e.getLocalizedMessage()); return null; } }
From source file:jp.ac.u.tokyo.m.pig.udf.eval.sequence.PickupSequenceValues.java
private ArrayList<Tuple> composeProtoBagModeAllValueFlat(HashMap<Long, ArrayList<Tuple>> aTargetBagMap, Long aStartValue) throws ExecException { ArrayList<Tuple> tProtoBag = new ArrayList<Tuple>(); while (true) { ArrayList<Tuple> tCurrentProtoBag = aTargetBagMap.get(aStartValue++); if (tCurrentProtoBag == null) break; tProtoBag.addAll(tCurrentProtoBag); }/* www .j a va 2 s. c o m*/ return tProtoBag; }