List of usage examples for java.util Set toString
public String toString()
From source file:cs.ox.ac.uk.gsors.GroupPreferencesTestAux.java
public void testFORewriting() throws Exception { // Configuration. final DecompositionStrategy decomposition = DecompositionStrategy.DECOMPOSE; final RewritingLanguage rewLang = RewritingLanguage.UCQ; final SubCheckStrategy subchkStrategy = SubCheckStrategy.INTRADEC; final NCCheck ncCheckStrategy = NCCheck.NONE; LOGGER.info("Decomposition: " + decomposition.name()); LOGGER.info("Rewriting Language: " + rewLang.name()); LOGGER.info("Subsumption Check Strategy: " + subchkStrategy.name()); LOGGER.info("Negative Constraints Check Strategy " + ncCheckStrategy.name()); final File testSuiteFile = FileUtils.getFile(_WORKING_DIR, FilenameUtils.separatorsToSystem(_DEFAULT_INPUT_PATH), "test-cases1.txt"); final List<String> tests = IOUtils.readLines(new FileReader(testSuiteFile)); final String creationDate = dateFormat.format(new Date()); // Parse the program final Parser parser = new Parser(); parser.parse(getStringFile(_DEFAULT_INPUT_PATH + "prefDB-ontology.dtg")); // Get the rules final List<IRule> rules = parser.getRules(); // Get the queries final List<IQuery> queryHeads = parser.getQueries(); final Map<IPredicate, IRelation> conf = parser.getDirectives(); if (!conf.isEmpty()) { StorageManager.getInstance();//from w w w . ja v a2 s. c o m StorageManager.configure(conf); } // Get the TGDs from the set of rules final List<IRule> tgds = RewritingUtils.getTGDs(rules, queryHeads); final List<IRule> mSBox = RewritingUtils.getSBoxRules(rules, queryHeads); final IRuleSafetyProcessor ruleProc = new StandardRuleSafetyProcessor(); ruleProc.process(mSBox); final IQueryRewriter ndmRewriter = new NDMRewriter(mSBox); final IRelationFactory rf = new RelationFactory(); // Convert the query bodies in rules final List<IRule> bodies = new LinkedList<IRule>(rules); bodies.removeAll(tgds); final List<IRule> queries = RewritingUtils.getQueries(bodies, queryHeads); // get the constraints from the set of rules final Set<IRule> constraints = RewritingUtils.getConstraints(rules, queryHeads); final Set<Expressivity> exprs = RewritingUtils.getExpressivity(tgds); LOGGER.info("Expressivity: " + exprs.toString()); if (!exprs.contains(Expressivity.LINEAR) && !exprs.contains(Expressivity.STICKY)) { extracted(); } // compute the dependency graph LOGGER.debug("Computing position dependencies."); // long depGraphMem = MonitoringUtils.getHeapUsage(); long posDepTime = System.currentTimeMillis(); Map<Pair<IPosition, IPosition>, Set<List<IRule>>> deps = DepGraphUtils.computePositionDependencyGraph(tgds); posDepTime = System.currentTimeMillis() - posDepTime; // Setup caching CacheManager.setupCaching(); // if linear TGDs, compute the atom coverage graph. LOGGER.debug("Computing atom coverage graph."); long atomCoverGraphTime = System.currentTimeMillis(); if (exprs.contains(Expressivity.LINEAR)) { deps = DepGraphUtils.computeAtomCoverageGraph(deps); } atomCoverGraphTime = System.currentTimeMillis() - atomCoverGraphTime; // depGraphMem = MonitoringUtils.getHeapUsage() - depGraphMem; // rewriting constraints // long ncRewMem = MonitoringUtils.getHeapUsage(); final ParallelRewriter cnsRewriter = new ParallelRewriter(DecompositionStrategy.MONOLITIC, RewritingLanguage.UCQ, SubCheckStrategy.NONE, NCCheck.NONE); long ncRewTime = System.currentTimeMillis(); final Set<IRule> rewrittenConstraints = Sets.newHashSet(); if (!ncCheckStrategy.equals(NCCheck.NONE)) { for (final IRule c : constraints) { rewrittenConstraints.addAll(cnsRewriter.getRewriting(c, tgds, new HashSet<IRule>(), deps, exprs)); } } ncRewTime = System.currentTimeMillis() - ncRewTime; // ncRewMem = ncRewMem - MonitoringUtils.getHeapUsage(); LOGGER.debug("Finished rewriting constraints."); // Compute the Rewriting final ParallelRewriter rewriter = new ParallelRewriter(decomposition, rewLang, subchkStrategy, ncCheckStrategy); Map<String, Integer> cities = new HashMap<String, Integer>(); cities.put("Peoria", 142); cities.put("Gilbert", 216); cities.put("Glendale", 314); cities.put("Chandler", 466); // cities.put("Tempe", 648); // cities.put("Phoenix", 2351); List<Integer> ks = new ArrayList<Integer>(); ks.add(1); ks.add(2); ks.add(3); List<AggregateStrategy> str = new ArrayList<AggregateStrategy>(); str.add(AggregateStrategy.CSU); str.add(AggregateStrategy.Plurality); str.add(AggregateStrategy.PluralityMisery); for (AggregateStrategy strategyQA : str) { final String summaryPrefix = StringUtils.join(creationDate, "-", strategyQA.toString()); final File sizeSummaryFile = FileUtils.getFile(_WORKING_DIR, FilenameUtils.separatorsToSystem(_DEFAULT_OUTPUT_PATH + "/" + strategyQA.toString()), FilenameUtils.separatorsToSystem(_DEFAULT_SUMMARY_DIR), StringUtils.join(summaryPrefix, "-", "size-summary.csv")); final CSVWriter sizeSummaryWriter = new CSVWriter(new FileWriter(sizeSummaryFile), ','); final File timeSummaryFile = FileUtils.getFile(_WORKING_DIR, FilenameUtils.separatorsToSystem(_DEFAULT_OUTPUT_PATH + "/" + strategyQA.toString()), FilenameUtils.separatorsToSystem(_DEFAULT_SUMMARY_DIR), StringUtils.join(summaryPrefix, "-", "time-summary.csv")); final CSVWriter timeSummaryWriter = new CSVWriter(new FileWriter(timeSummaryFile), ','); final File cacheSummaryFile = FileUtils.getFile(_WORKING_DIR, FilenameUtils.separatorsToSystem(_DEFAULT_OUTPUT_PATH + "/" + strategyQA.toString()), FilenameUtils.separatorsToSystem(_DEFAULT_SUMMARY_DIR), StringUtils.join(summaryPrefix, "-", "cache-summary.csv")); final CSVWriter cacheSummaryWriter = new CSVWriter(new FileWriter(cacheSummaryFile), ','); final File memorySummaryFile = FileUtils.getFile(_WORKING_DIR, FilenameUtils.separatorsToSystem(_DEFAULT_OUTPUT_PATH + "/" + strategyQA.toString()), FilenameUtils.separatorsToSystem(_DEFAULT_SUMMARY_DIR), StringUtils.join(summaryPrefix, "-", "memory-summary.csv")); final CSVWriter memorySummaryWriter = new CSVWriter(new FileWriter(memorySummaryFile), ','); sizeSummaryWriter.writeNext(GReportingUtils.getSummaryRewritingSizeReportHeader()); timeSummaryWriter.writeNext(GReportingUtils.getSummaryRewritingTimeReportHeader()); cacheSummaryWriter.writeNext(GReportingUtils.getSummaryCachingReportHeader()); memorySummaryWriter.writeNext(GReportingUtils.getSummaryMemoryReportHeader()); for (Integer k : ks) { for (String city : cities.keySet()) { for (int con = 0; con < 10; con++) { LOGGER.info("con-city-k: " + con + "-" + city + "-" + k + "-" + strategyQA.toString()); // top k for each preferences for (final String testName : tests) { // Create a buffer for the output final IRelation result = rf.createRelation(); GPrefParameters parameters = new GPrefParameters(testName, k, city, cities.get(city)); // Create the Directory where to store the test // results // final File outTestDir = FileUtils // .getFile( // _WORKING_DIR, // FilenameUtils // .separatorsToSystem(_DEFAULT_OUTPUT_PATH // + "/" // + strategyQA // .toString() // + k + city), // testName); // if (!outTestDir.exists()) { // if (outTestDir.mkdirs()) { // LOGGER.info("Created output directory: " // + testName); // } else { // LOGGER.fatal("Error creating output directory"); // } // } LOGGER.info("Processing file: " + testName); // dump the rewritten constraints: IRule q = null; if (parameters.getScenario() == Scenario.BREAKFAST_FOOD || parameters.getScenario() == Scenario.LUNCH_FOOD || parameters.getScenario() == Scenario.DINNER_FOOD) { q = queries.get(0); } if (parameters.getScenario() == Scenario.BREAKFAST_CUSINE || parameters.getScenario() == Scenario.LUNCH_CUSINE || parameters.getScenario() == Scenario.DINNER_CUSINE) { q = queries.get(1); } if (parameters.getScenario() == Scenario.BREAKFAST_PLACE || parameters.getScenario() == Scenario.LUNCH_PLACE || parameters.getScenario() == Scenario.DINNER_PLACE) { q = queries.get(2); } CacheManager.setupCaching(); final String queryPredicate = q.getHead().iterator().next().getAtom().getPredicate() .getPredicateSymbol(); // Setup reporting final ToitReporter rep = ToitReporter.getInstance(true); ToitReporter.setupReporting(); ToitReporter.setQuery(queryPredicate); ToitReporter.setTest(testName); ToitReporter.setK(parameters.getK()); //ToitReporter.setStrategy(parameters.getStrategy()); ToitReporter.setCity(parameters.getCity()); ToitReporter.setGroupID(parameters.getGroupId()); ToitReporter.setNbUsers(parameters.getMaxNbUsers()); ToitReporter.setNbBuss(parameters.getBs()); ToitReporter.setScenario(parameters.getScenario()); rep.setValue(GRewMetric.DEPGRAPH_TIME, posDepTime); LOGGER.info("Processing query: ".concat(q.toString())); // final long rewMem = // MonitoringUtils.getHeapUsage(); final long overallTime = System.currentTimeMillis(); final Set<IRule> rewriting = rewriter.getRewriting(q, tgds, rewrittenConstraints, deps, exprs); rep.setValue(GRewMetric.REW_TIME, System.currentTimeMillis() - overallTime); // rep.setValue(RewMetric.REW_MEM, // MonitoringUtils.getHeapUsage() - rewMem); // rep.setValue(RewMetric.DEPGRAPH_MEM, // depGraphMem); rep.setValue(GRewMetric.REW_SIZE, (long) rewriting.size()); rep.setValue(GRewMetric.REW_CNS_TIME, ncRewTime); // rep.setValue(RewMetric.REW_CNS_MEM, ncRewMem); final Set<ILiteral> newHeads = new HashSet<ILiteral>(); Map<IPredicate, IRelation> results = new HashMap<IPredicate, IRelation>(); for (final IRule qr : rewriting) { newHeads.add(qr.getHead().iterator().next()); // rewFW.write(qr + "\n"); final Set<IRule> sboxRewriting = new LinkedHashSet<IRule>(); Set<IRule> rrules = ndmRewriter.getRewriting(qr); sboxRewriting.addAll(rrules); // Produce the SQL rewriting for each query in // the // program final SQLRewriter sqlRewriter = new SQLRewriter(sboxRewriting); // rewFW.write("Computing SQL Rewriting"); try { // Get the SQL rewriting as Union of // Conjunctive // Queries long duration = -System.nanoTime(); final List<String> ucqSQLRewriting = sqlRewriter.getSQLRewritings( parameters.getConstraintsSqlQuery(), parameters.getNbNodes(), parameters.getStartFromRes()); duration = ((duration + System.nanoTime()) / 1000000); IRelation resultAux = rf.createRelation(); for (final String qu : ucqSQLRewriting) { IRelation r = StorageManager.executeQuery(qu); // LOGGER.info("-Query: " + // qu+" "+r.size()+" "+c); resultAux.addAll(r); } for (IPredicate predicate : qr.getBodyPredicates()) { results.put(predicate, resultAux); } result.addAll(resultAux); // LOGGER.info("-R: " +result.size()); } catch (final SQLException e) { e.printStackTrace(); } } // write the result in the output // rewFW.write(result.toString()); // construct the graph Map<User, List<user.models.Pair<IPredicate, IPredicate>>> prefs = JsonHelper .getGPreferences(parameters.getPrefs(), tgds); final cs.ox.ac.uk.gsors2.GPreferencesGraph prefGraph = Factory.GPGRAPH .createPreferencesGraph(); long constPrefGraphTime = System.currentTimeMillis(); // final long constPrefGraphMem = // MonitoringUtils.getHeapUsage(); for (User user : prefs.keySet()) { for (user.models.Pair<IPredicate, IPredicate> pairPreference : prefs.get(user)) { IRelation morePrefs = results.get(pairPreference.getElement0()); IRelation lessPrefs = results.get(pairPreference.getElement1()); for (int j = 0; j < morePrefs.size(); j++) { ITuple el1 = morePrefs.get(j); if (!lessPrefs.contains(el1)) { for (int i = 0; i < lessPrefs.size(); i++) { ITuple el2 = lessPrefs.get(i); GPreferenceEdge edge = new GPreferenceEdge(el1, el2, user); prefGraph.addPreference(edge); } } } } } for (int i = 0; i < result.size(); i++) { ITuple v = result.get(i); prefGraph.addVertex(v); } // LOGGER.info("-----Size--Graph--: " + // result.size()+"--"+prefGraph.getVertexesSize() ); constPrefGraphTime = System.currentTimeMillis() - constPrefGraphTime; rep.setValue(GRewMetric.PREFGRAPH_CONST_TIME, constPrefGraphTime); rep.setValue(GRewMetric.PREFGRAPH_CONST_SIZE_V, (long) prefGraph.getVertexesSize()); rep.setValue(GRewMetric.PREFGRAPH_CONST_SIZE_E, (long) prefGraph.getEdgesSize()); // rep.setValue(RewMetric.PREFGRAPH_CONST__MEM, // MonitoringUtils.getHeapUsage() - // constPrefGraphMem); long mergeOperatorTime = System.currentTimeMillis(); // prefGraph // .mergeProbabilisticModel("/home/onsa/Dropbox/VGOT/toit13/resources/data_final/reviews.txt"); mergeOperatorTime = System.currentTimeMillis() - mergeOperatorTime; rep.setValue(GRewMetric.PREFGRAPH_MERGE_TIME, mergeOperatorTime); rep.setValue(GRewMetric.PREFGRAPH_MERGE_SIZE_V, (long) prefGraph.getVertexesSize()); rep.setValue(GRewMetric.PREFGRAPH_MERGE_SIZE_E, (long) prefGraph.getEdgesSize()); long topKTime = System.currentTimeMillis(); // prefGraph.getTopK(parameters.getK(), // parameters.getStrategy()); topKTime = System.currentTimeMillis() - topKTime; rep.setValue(GRewMetric.PREFGRAPH_TOPK_TIME, topKTime); rep.setValue(GRewMetric.PREFGRAPH_TOPK_SIZE_V, (long) prefGraph.getVertexesSize()); rep.setValue(GRewMetric.PREFGRAPH_TOPK_SIZE_E, (long) prefGraph.getEdgesSize()); // rewFW.write("\n"); // for (final ILiteral h : newHeads) { // rewFW.write("?- " + h + ".\n"); // } // rewFW.write("\n"); // rewFW.flush(); // rewFW.close(); // dump summary metrics. sizeSummaryWriter.writeNext(rep.getSummarySizeMetrics()); timeSummaryWriter.writeNext(rep.getSummaryTimeMetrics()); cacheSummaryWriter.writeNext(rep.getSummaryCacheMetrics()); memorySummaryWriter.writeNext(rep.getSummaryMemoryMetrics()); sizeSummaryWriter.flush(); timeSummaryWriter.flush(); cacheSummaryWriter.flush(); memorySummaryWriter.flush(); } } } } sizeSummaryWriter.close(); timeSummaryWriter.close(); cacheSummaryWriter.close(); memorySummaryWriter.close(); } }
From source file:uk.ac.cam.cl.dtg.segue.api.UsersFacade.java
/** * Get a Set of all schools reported by users in the school other field. * * @param request/* www .j a v a2 s . co m*/ * for caching purposes. * @return list of strings. */ @GET @Path("users/schools_other") @Produces(MediaType.APPLICATION_JSON) @GZIP public Response getAllSchoolOtherResponses(@Context final Request request) { Set<School> schoolOthers = schoolOtherSupplier.get(); if (null != schoolOthers) { EntityTag etag = new EntityTag(schoolOthers.toString().hashCode() + ""); Response cachedResponse = generateCachedResponse(request, etag, Constants.NEVER_CACHE_WITHOUT_ETAG_CHECK); if (cachedResponse != null) { return cachedResponse; } return Response.ok(schoolOthers).tag(etag) .cacheControl(getCacheControl(Constants.NEVER_CACHE_WITHOUT_ETAG_CHECK, false)).build(); } else { log.error("Unable to get school list"); return new SegueErrorResponse(Status.INTERNAL_SERVER_ERROR, "Error while looking up schools") .toResponse(); } }
From source file:com.orangelabs.rcs.ri.messaging.chat.single.SingleChatView.java
@Override public void initialize() { mClearUndeliveredMessageClickListener = new OnClickListener() { @Override/*from ww w. ja v a 2 s .co m*/ public void onClick(DialogInterface dialog, int which) { try { Set<String> msgIds = getUndeliveredMessages(mContact); mChatService.clearMessageDeliveryExpiration(msgIds); if (LogUtils.isActive) { Log.d(LOGTAG, "clearMessageDeliveryExpiration ".concat(msgIds.toString())); } } catch (RcsServiceException e) { showException(e); } finally { mClearUndeliveredAlertDialog = null; } } }; mClearUndeliveredFileTransferClickListener = new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Set<String> fileTransfersIds = getUndeliveredFileTransfers(mContact); mFileTransferService.clearFileTransferDeliveryExpiration(fileTransfersIds); if (LogUtils.isActive) { Log.d(LOGTAG, "clearFileTransferDeliveryExpiration ".concat(fileTransfersIds.toString())); } } catch (RcsServiceException e) { showException(e); } finally { mClearUndeliveredAlertDialog = null; } } }; mClearUndeliveredCancelListener = new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mClearUndeliveredAlertDialog = null; } }; mChatListener = new OneToOneChatListener() { /* Callback called when an Is-composing event has been received */ @Override public void onComposingEvent(ContactId contact, boolean status) { /* Discard event if not for current contact */ if (!mContact.equals(contact)) { return; } if (LogUtils.isActive) { Log.d(LOGTAG, "onComposingEvent contact=" + contact + " status=" + status); } displayComposingEvent(contact, status); } @Override public void onMessageStatusChanged(ContactId contact, String mimeType, String msgId, Content.Status status, Content.ReasonCode reasonCode) { if (LogUtils.isActive) { Log.d(LOGTAG, "onMessageStatusChanged contact=" + contact + " mime-type=" + mimeType + " msgId=" + msgId + " status=" + status); } } @Override public void onMessagesDeleted(ContactId contact, Set<String> msgIds) { if (LogUtils.isActive) { Log.d(LOGTAG, "onMessagesDeleted contact=" + contact + " for message IDs=" + Arrays.toString(msgIds.toArray())); } } }; }
From source file:gov.nih.nci.caarray.application.translation.geosoft.GeoSoftExporterBeanTest.java
@Test public void testExportArchiveTar() throws Exception { final Project p = makeGoodProject(); final List<PackagingInfo> infos = this.bean.getAvailablePackagingInfos(p); final PackagingInfo zipPi = Iterables.find(infos, new Predicate<PackagingInfo>() { @Override/*w w w . java 2 s . c o m*/ public boolean apply(PackagingInfo t) { return t.getMethod() == PackagingInfo.PackagingMethod.ZIP; } }); final File f = File.createTempFile("test", zipPi.getName()); final FileOutputStream fos = new FileOutputStream(f); this.bean.export(p, "http://example.com/my_experiemnt", PackagingInfo.PackagingMethod.TGZ, fos); fos.close(); final GZIPInputStream in = new GZIPInputStream(new FileInputStream(f)); final TarArchiveInputStream tar = new TarArchiveInputStream(in); final Set<String> entries = new HashSet<String>(); entries.addAll(java.util.Arrays.asList("test-exp-id.soft.txt", "raw_file.data", "derived_file.data", "supplimental.data", "README.txt")); TarArchiveEntry e = tar.getNextTarEntry(); while (e != null) { assertTrue(e.getName() + " unexpected", entries.remove(e.getName())); e = tar.getNextTarEntry(); } assertTrue(entries.toString() + " not found", entries.isEmpty()); }
From source file:org.apache.storm.daemon.nimbus.NimbusUtils.java
@SuppressWarnings("rawtypes") @ClojureClass(className = "backtype.storm.daemon.nimbus#update-heartbeats!") public static void updateHeartbeats(NimbusData nimbus, String stormId, Set<ExecutorInfo> allExecutors, Assignment existingAssignment) throws Exception { LOG.debug("Updating heartbeats for {}:{}", stormId, allExecutors.toString()); StormClusterState stormClusterState = nimbus.getStormClusterState(); Map<ExecutorInfo, ExecutorHeartbeat> executorBeats = stormClusterState.executorBeats(stormId, existingAssignment.getExecutorToNodeport()); Map<ExecutorInfo, ExecutorCache> cache = nimbus.getExecutorHeartbeatsCache().get(stormId); Map conf = nimbus.getConf();/*from ww w.j a v a 2s .c o m*/ int taskTimeOutSecs = CoreUtil.parseInt(conf.get(Config.NIMBUS_TASK_TIMEOUT_SECS), 30); Map<ExecutorInfo, ExecutorCache> newCache = updateHeartbeatCache(cache, executorBeats, allExecutors, taskTimeOutSecs); ConcurrentHashMap<String, Map<ExecutorInfo, ExecutorCache>> executorCache = nimbus .getExecutorHeartbeatsCache(); executorCache.put(stormId, newCache); nimbus.setExecutorHeartbeatsCache(executorCache); }
From source file:org.apache.hive.ptest.execution.conf.UnitTestPropertiesParser.java
private ModuleConfig getModuleConfig(Context context, String moduleName, int defaultBatchSize) { Set<String> excluded = getProperty(context, PROP_EXCLUDE); Set<String> isolated = getProperty(context, PROP_ISOLATE); Set<String> included = getProperty(context, PROP_INCLUDE); Set<String> skipBatching = getProperty(context, PROP_SKIP_BATCHING); if (!included.isEmpty() && !excluded.isEmpty()) { throw new IllegalArgumentException( String.format("Included and excluded mutually exclusive." + " Included = %s, excluded = %s", included.toString(), excluded.toString()) + " for module: " + moduleName); }/*from www . j a v a 2s . c o m*/ int batchSize = context.getInteger(PROP_BATCH_SIZE, defaultBatchSize); String pathPrefix = getPathPrefixFromModuleName(moduleName); return new ModuleConfig(moduleName, included, excluded, skipBatching, isolated, batchSize, pathPrefix); }
From source file:gemlite.shell.commands.admin.Monitor.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @CliCommand(value = "list services", help = "list services") public String services() { Set<ObjectInstance> names = jmxSrv.listMBeans(); List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); if (names == null) return "no services"; Object[] a = names.toArray(); //???/*w ww.j ava2s.c om*/ Arrays.sort(a, (Comparator) new Comparator<ObjectInstance>() { @Override public int compare(ObjectInstance o1, ObjectInstance o2) { return (o1.getObjectName().toString()).compareTo(o2.getObjectName().toString()); } }); if (LogUtil.getCoreLog().isDebugEnabled()) LogUtil.getCoreLog().debug("get names size:{} values:{}", names.size(), names.toString()); //?service? for (int i = 0; i < a.length; i++) { ObjectInstance oi = (ObjectInstance) a[i]; // service?,??? HashMap<String, Object> service = new HashMap<String, Object>(); service.put(oi.getObjectName().toString(), service); service.put("serviceName", service); try { Map<String, Object> map = jmxSrv.getAttributesValues(oi.getObjectName().toString()); if (map.size() <= 0) { map.put("serviceName", oi.getObjectName().toString()); LogUtil.getCoreLog().warn("jmxSrv.getAttributesValues is null ,ObjectName {}", oi.getObjectName().toString()); result.add(map); } else { result.add(map); } } catch (Exception e) { LogUtil.getCoreLog().error("jmxSrv.getAttributesValues is null ,ObjectName {},error:{}", oi.getObjectName().toString(), e); } } LinkedHashMap<String, HashMap<String, Object>> rs = (LinkedHashMap<String, HashMap<String, Object>>) get( CommandMeta.LIST_SERVICES); if (rs == null) rs = new LinkedHashMap<String, HashMap<String, Object>>(); for (Map<String, Object> map : result) { // ? HashMap<String, Object> service = rs.get(map.get("serviceName")); if (service == null) { service = new HashMap<String, Object>(); } service.putAll(map); // ? rs.put((String) map.get("serviceName"), service); } // ws?? put(CommandMeta.LIST_SERVICES, rs); if (!result.isEmpty()) return result.toString(); return "no services"; }
From source file:org.apache.oozie.service.ShareLibService.java
/** * Instruments the log service./* w w w. j a v a 2 s . co m*/ * <p> * It sets instrumentation variables indicating the location of the sharelib and launcherlib * * @param instr instrumentation to use. */ @Override public void instrument(Instrumentation instr) { instr.addVariable("libs", "sharelib.source", new Instrumentation.Variable<String>() { @Override public String getValue() { if (!StringUtils.isEmpty(sharelibMappingFile.trim())) { return SHARELIB_MAPPING_FILE; } return WorkflowAppService.SYSTEM_LIB_PATH; } }); instr.addVariable("libs", "sharelib.mapping.file", new Instrumentation.Variable<String>() { @Override public String getValue() { if (!StringUtils.isEmpty(sharelibMappingFile.trim())) { return sharelibMappingFile; } return "(none)"; } }); instr.addVariable("libs", "sharelib.system.libpath", new Instrumentation.Variable<String>() { @Override public String getValue() { String sharelibPath = "(unavailable)"; try { Path libPath = getLatestLibPath(services.get(WorkflowAppService.class).getSystemLibPath(), SHARE_LIB_PREFIX); if (libPath != null) { sharelibPath = libPath.toUri().toString(); } } catch (IOException ioe) { // ignore exception because we're just doing instrumentation } return sharelibPath; } }); instr.addVariable("libs", "sharelib.mapping.file.timestamp", new Instrumentation.Variable<String>() { @Override public String getValue() { if (!StringUtils.isEmpty(sharelibMetaFileOldTimeStamp)) { return sharelibMetaFileOldTimeStamp; } return "(none)"; } }); instr.addVariable("libs", "sharelib.keys", new Instrumentation.Variable<String>() { @Override public String getValue() { Map<String, List<Path>> shareLib = getShareLib(); if (shareLib != null && !shareLib.isEmpty()) { Set<String> keySet = shareLib.keySet(); return keySet.toString(); } return "(unavailable)"; } }); instr.addVariable("libs", "launcherlib.system.libpath", new Instrumentation.Variable<String>() { @Override public String getValue() { return getLauncherlibPath().toUri().toString(); } }); instr.addVariable("libs", "sharelib.symlink.mapping", new Instrumentation.Variable<String>() { @Override public String getValue() { Map<String, Map<Path, Path>> shareLibSymlinkMapping = getSymlinkMapping(); if (shareLibSymlinkMapping != null && !shareLibSymlinkMapping.isEmpty() && shareLibSymlinkMapping.values() != null && !shareLibSymlinkMapping.values().isEmpty()) { StringBuffer bf = new StringBuffer(); for (Entry<String, Map<Path, Path>> entry : shareLibSymlinkMapping.entrySet()) if (entry.getKey() != null && !entry.getValue().isEmpty()) { for (Path path : entry.getValue().keySet()) { bf.append(path).append("(").append(entry.getKey()).append(")").append("=>") .append(shareLibSymlinkMapping.get(entry.getKey()) != null ? shareLibSymlinkMapping.get(entry.getKey()).get(path) : "") .append(","); } } return bf.toString(); } return "(none)"; } }); instr.addVariable("libs", "sharelib.cached.config.file", new Instrumentation.Variable<String>() { @Override public String getValue() { Map<String, Map<Path, Configuration>> shareLibConfigMap = getShareLibConfigMap(); if (shareLibConfigMap != null && !shareLibConfigMap.isEmpty()) { StringBuffer bf = new StringBuffer(); for (String path : shareLibConfigMap.keySet()) { bf.append(path).append(";"); } return bf.toString(); } return "(none)"; } }); }
From source file:alliance.docs.DocumentationTest.java
@Test public void testBrokenAnchorsPresent() throws IOException, URISyntaxException { List<Path> docs = Files.list(getPath()).filter(f -> f.toString().endsWith(HTML_DIRECTORY)) .collect(Collectors.toList()); Set<String> links = new HashSet<>(); Set<String> anchors = new HashSet<>(); for (Path path : docs) { Document doc = Jsoup.parse(path.toFile(), "UTF-8", EMPTY_STRING); String thisDoc = StringUtils.substringAfterLast(path.toString(), File.separator); Elements elements = doc.body().getAllElements(); for (Element element : elements) { if (!element.toString().contains(":") && StringUtils.substringBetween(element.toString(), HREF_ANCHOR, CLOSE) != null) { links.add(thisDoc + "#" + StringUtils.substringBetween(element.toString(), HREF_ANCHOR, CLOSE)); }/*from w ww .j a v a 2s . c o m*/ anchors.add(thisDoc + "#" + StringUtils.substringBetween(element.toString(), ID, CLOSE)); } } links.removeAll(anchors); assertThat("Anchors missing section reference: " + links.toString(), links.isEmpty()); }
From source file:net.launchpad.jabref.plugins.ZentralSearch.java
private Set<String> fetchBibtexEntries(String page) { Set<String> indices = retrieveIndexIds(page); Set<String> returnBibtext = new HashSet<String>(); URL indexUrl = null;//from w w w . ja v a2 s . c o m if (indices.isEmpty()) { throw new RuntimeException("Search did not return any results."); } for (String i : indices) { try { indexUrl = new URL(getZentralblattUrl() + "?index_=" + i + "&type_=bib"); HttpURLConnection zbm = (HttpURLConnection) indexUrl.openConnection(); zbm.setRequestProperty("User-Agent", "Jabref"); returnBibtext.add(IOUtils.toString(zbm.getInputStream())); } catch (Exception e) { log.error("url: " + indexUrl + "\n" + e.getMessage(), e); } } log.debug("Found: " + returnBibtext.toString()); return returnBibtext; }