List of usage examples for java.util Collections unmodifiableMap
public static <K, V> Map<K, V> unmodifiableMap(Map<? extends K, ? extends V> m)
From source file:com.mgmtp.perfload.core.console.status.StatusHandler.java
public Map<StatusInfoKey, Deque<ThreadActivity>> getThreadActivitiesMap() { return Collections.unmodifiableMap(threadActivities); }
From source file:com.twitter.heron.ckptmgr.CheckpointManager.java
public CheckpointManager(String topologyName, String topologyId, String checkpointMgrId, String serverHost, int serverPort, SystemConfig systemConfig, CheckpointManagerConfig checkpointManagerConfig) throws IOException, CheckpointManagerException { this.checkpointManagerServerLoop = new NIOLooper(); HeronSocketOptions serverSocketOptions = new HeronSocketOptions(checkpointManagerConfig.getWriteBatchSize(), checkpointManagerConfig.getWriteBatchTime(), checkpointManagerConfig.getReadBatchSize(), checkpointManagerConfig.getReadBatchTime(), checkpointManagerConfig.getSocketSendSize(), checkpointManagerConfig.getSocketReceiveSize(), checkpointManagerConfig.getMaximumPacketSize()); // Setup the IStatefulStorage // TODO(mfu): This should be done in an executor driven by another thread, kind of async IStatefulStorage statefulStorage;/* www . j ava 2 s. com*/ String classname = checkpointManagerConfig.getStorageClassname(); try { statefulStorage = (IStatefulStorage) Class.forName(classname).newInstance(); } catch (InstantiationException e) { throw new CheckpointManagerException(classname + " class must have a no-arg constructor.", e); } catch (IllegalAccessException e) { throw new CheckpointManagerException(classname + " class must be concrete.", e); } catch (ClassNotFoundException e) { throw new CheckpointManagerException(classname + " class must be a class path.", e); } try { statefulStorage.init(Collections.unmodifiableMap(checkpointManagerConfig.getStatefulStorageConfig())); } catch (StatefulStorageException e) { throw new CheckpointManagerException(classname + " init threw exception", e); } // Start the server this.checkpointManagerServer = new CheckpointManagerServer(topologyName, topologyId, checkpointMgrId, statefulStorage, checkpointManagerServerLoop, serverHost, serverPort, serverSocketOptions); }
From source file:channellistmaker.dataextractor.AbstractEPGFileExtractor.java
/** * ?????????1?????dump()??????// w ww .j a v a 2s. c om * * @author dosdiaopfhj * @return ??? * */ public final synchronized Map<MultiKey<Integer>, T> makeMap() { Map<MultiKey<Integer>, T> records = new ConcurrentHashMap<>(); Element root; root = this.doc.getDocumentElement(); NodeList nl = doc.getElementsByTagName(this.nodeName); int Nodes = nl.getLength(); for (int i = 0; i < Nodes; i++) { Node N = nl.item(i); try { T record_val = dump(N); T ret = records.put(record_val.getKeyfields().getMuiltiKey(), record_val); if (ret != null) { LOG.info("????????\n" + ret); } } catch (IllegalArgumentException ex) { LOG.warn("??????????", ex); } } return Collections.unmodifiableMap(records); }
From source file:com.mgmtp.jfunk.data.DefaultDataSet.java
@Override public Map<String, String> getDataView() { return Collections.unmodifiableMap(data); }
From source file:com.spotify.helios.client.DefaultRequestDispatcher.java
@Override public ListenableFuture<Response> request(final URI uri, final String method, final byte[] entityBytes, final Map<String, List<String>> headers) { return executorService.submit(new Callable<Response>() { @Override/* ww w . j a v a2 s. com*/ public Response call() throws Exception { final HttpURLConnection connection = connect(uri, method, entityBytes, headers); final int status = connection.getResponseCode(); final InputStream rawStream; if (status / 100 != 2) { rawStream = connection.getErrorStream(); } else { rawStream = connection.getInputStream(); } final boolean gzip = isGzipCompressed(connection); final InputStream stream = gzip ? new GZIPInputStream(rawStream) : rawStream; final ByteArrayOutputStream payload = new ByteArrayOutputStream(); if (stream != null) { int n; byte[] buffer = new byte[4096]; while ((n = stream.read(buffer, 0, buffer.length)) != -1) { payload.write(buffer, 0, n); } } URI realUri = connection.getURL().toURI(); if (log.isTraceEnabled()) { log.trace("rep: {} {} {} {} {} gzip:{}", method, realUri, status, payload.size(), decode(payload), gzip); } else { log.debug("rep: {} {} {} {} gzip:{}", method, realUri, status, payload.size(), gzip); } return new Response(method, uri, status, payload.toByteArray(), Collections.unmodifiableMap(Maps.newHashMap(connection.getHeaderFields()))); } private boolean isGzipCompressed(final HttpURLConnection connection) { final List<String> encodings = connection.getHeaderFields().get("Content-Encoding"); if (encodings == null) { return false; } for (String encoding : encodings) { if ("gzip".equals(encoding)) { return true; } } return false; } }); }
From source file:edu.cornell.mannlib.vitro.webapp.modelaccess.impl.ContextModelAccessImpl.java
private Map<WhichService, RDFService> populateRdfServiceMap() { Map<WhichService, RDFService> map = new EnumMap<>(WhichService.class); map.put(CONTENT, factory.getRDFService(CONTENT)); map.put(CONFIGURATION, factory.getRDFService(CONFIGURATION)); log.debug("RdfServiceMap: " + map); return Collections.unmodifiableMap(map); }
From source file:com.handu.open.dubbo.monitor.RegistryContainer.java
public Map<String, List<URL>> getServiceConsumers() { return Collections.unmodifiableMap(serviceConsumers); }
From source file:net.formio.upload.MultipartRequestPreprocessor.java
/** * Return a {@code Map<String, String[]>} for all regular parameters. Does * not return any file upload parameters at all. *///from w ww .j a v a2 s . c om public Map<String, String[]> getParameterMap() { Map<String, String[]> res = new LinkedHashMap<String, String[]>(); for (Map.Entry<String, List<String>> entry : regularParams.entrySet()) { res.put(entry.getKey(), entry.getValue().toArray(new String[0])); } return Collections.unmodifiableMap(res); }
From source file:org.ihtsdo.otf.snomed.service.ConceptLookUpServiceImplv1_0.java
@Override @Cacheable(value = { "concepts" }) public Map<String, Concept> getConcepts(Set<String> conceptIds) throws ConceptServiceException { LOGGER.debug("getting concepts details for {}", conceptIds); Map<String, Concept> concepts = new HashMap<String, Concept>(); TitanGraph g = null;/*from w w w . ja v a 2 s. com*/ try { g = factory.getReadOnlyGraph(); /**/ List<String> idLst = new ArrayList<String>(); idLst.addAll(conceptIds); int length = idLst.size() / 1024; int to = idLst.size() > 1024 ? 1024 : conceptIds.size(); int from = 0; for (int i = 0; i < length + 1; i++) { LOGGER.debug("getting concept description from {} to {} ", from, to); List<String> subList = idLst.subList(from, to); String ids = org.apache.commons.lang.StringUtils.join(subList, " OR "); Iterable<Result<Vertex>> vs = g.indexQuery("concept", "v.sctid:" + ids).vertices(); for (Result<Vertex> r : vs) { Vertex v = r.getElement(); Object sctid = v.getProperty(Properties.sctid.toString()); Object label = v.getProperty(Properties.title.toString()); if (sctid != null && label != null && idLst.contains(sctid.toString())) { Concept c = new Concept(); c.setId(sctid.toString()); Long effectiveTime = v.getProperty(Properties.effectiveTime.toString()); if (effectiveTime != null) { c.setEffectiveTime(new DateTime(effectiveTime)); } String status = v.getProperty(Properties.status.toString()); boolean active = "1".equals(status) ? true : false; c.setActive(active); c.setLabel(label.toString()); Iterable<Edge> es = v.getEdges(Direction.OUT, Relationship.hasModule.toString()); for (Edge edge : es) { Vertex vE = edge.getVertex(Direction.IN); if (vE != null) { String moduleId = vE.getProperty(Properties.sctid.toString()); c.setModuleId(moduleId); break; } } concepts.put(sctid.toString(), c); } } //to run next loop if required from = to > idLst.size() ? idLst.size() : to; to = (to + 1024) > idLst.size() ? idLst.size() : to + 1024; } RefsetGraphFactory.commit(g); } catch (Exception e) { LOGGER.error("Error duing concept details for concept map fetch", e); RefsetGraphFactory.rollback(g); throw new ConceptServiceException(e); } finally { RefsetGraphFactory.shutdown(g); } LOGGER.debug("returning total {} concepts ", concepts.size()); return Collections.unmodifiableMap(concepts); }
From source file:com.erudika.para.core.ParaObjectUtils.java
/** * Returns a map of the core data types. * @return a map of type plural - type singular form *//*from w w w . jav a2 s .c o m*/ public static Map<String, String> getCoreTypes() { if (coreTypes.isEmpty()) { try { for (Class<? extends ParaObject> clazz : ParaObjectUtils.getCoreClassesMap().values()) { ParaObject p = clazz.newInstance(); coreTypes.put(p.getPlural(), p.getType()); } } catch (Exception ex) { logger.error(null, ex); } } return Collections.unmodifiableMap(coreTypes); }