List of usage examples for java.util Collections emptyMap
@SuppressWarnings("unchecked") public static final <K, V> Map<K, V> emptyMap()
From source file:com.streamsets.pipeline.stage.destination.BaseMapReduceIT.java
public MapReduceExecutor generateExecutor(AvroConversionCommonConfig commonConfig, AvroParquetConfig avroParquetConfig, JobType jobType, Map<String, String> jobConfigs) { MapReduceConfig mapReduceConfig = new MapReduceConfig(); mapReduceConfig.mapReduceConfDir = getConfDir(); mapReduceConfig.mapreduceConfigs = Collections.emptyMap(); mapReduceConfig.mapreduceUser = ""; mapReduceConfig.kerberos = false;/*from w w w. ja v a2s. c om*/ JobConfig jobConfig = new JobConfig(); jobConfig.jobType = jobType; jobConfig.jobConfigs = jobConfigs; jobConfig.customJobCreator = SimpleJobCreator.class.getCanonicalName(); jobConfig.jobName = "SDC Test Job"; jobConfig.avroConversionCommonConfig = commonConfig; jobConfig.avroParquetConfig = avroParquetConfig; MapReduceExecutor executor = new MapReduceExecutor(mapReduceConfig, jobConfig); executor.waitForCompletition = true; return executor; }
From source file:com.eascs.app.network.volley.toolbox.BasicNetwork.java
@Override public NetworkResponse performRequest(Request<?> request) throws VolleyError { long requestStart = SystemClock.elapsedRealtime(); while (true) { HttpResponse httpResponse = null; byte[] responseContents = null; Map<String, String> responseHeaders = Collections.emptyMap(); try {//w w w . j a va 2 s . co m // Gather headers. Map<String, String> headers = new HashMap<String, String>(); addCacheHeaders(headers, request.getCacheEntry()); httpResponse = mHttpStack.performRequest(request, headers); StatusLine statusLine = httpResponse.getStatusLine(); int statusCode = statusLine.getStatusCode(); responseHeaders = convertHeaders(httpResponse.getAllHeaders()); // Handle cache validation. if (statusCode == HttpStatus.SC_NOT_MODIFIED) { Cache.Entry entry = request.getCacheEntry(); if (entry == null) { return new NetworkResponse(HttpStatus.SC_NOT_MODIFIED, null, responseHeaders, true, SystemClock.elapsedRealtime() - requestStart); } // A HTTP 304 response does not have all header fields. We // have to use the header fields from the cache entry plus // the new ones from the response. // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5 entry.responseHeaders.putAll(responseHeaders); return new NetworkResponse(HttpStatus.SC_NOT_MODIFIED, entry.data, entry.responseHeaders, true, SystemClock.elapsedRealtime() - requestStart); } // Some responses such as 204s do not have content. We must check. if (httpResponse.getEntity() != null) { responseContents = entityToBytes(httpResponse.getEntity()); } else { // Add 0 byte response as a way of honestly representing a // no-content request. responseContents = new byte[0]; } // if the request is slow, log it. long requestLifetime = SystemClock.elapsedRealtime() - requestStart; logSlowRequests(requestLifetime, request, responseContents, statusLine); if (statusCode < 200 || statusCode > 299) { throw new IOException(); } return new NetworkResponse(statusCode, responseContents, responseHeaders, false, SystemClock.elapsedRealtime() - requestStart); } catch (SocketTimeoutException e) { attemptRetryOnException("socket", request, new TimeoutError()); } catch (ConnectTimeoutException e) { attemptRetryOnException("connection", request, new TimeoutError()); } catch (MalformedURLException e) { throw new RuntimeException("Bad URL " + request.getUrl(), e); } catch (IOException e) { int statusCode; if (httpResponse != null) { statusCode = httpResponse.getStatusLine().getStatusCode(); } else { throw new NoConnectionError(e); } VolleyLog.e("Unexpected response code %d for %s", statusCode, request.getUrl()); NetworkResponse networkResponse; if (responseContents != null) { networkResponse = new NetworkResponse(statusCode, responseContents, responseHeaders, false, SystemClock.elapsedRealtime() - requestStart); if (statusCode == HttpStatus.SC_UNAUTHORIZED || statusCode == HttpStatus.SC_FORBIDDEN) { attemptRetryOnException("auth", request, new AuthFailureError(networkResponse)); } else if (statusCode >= 400 && statusCode <= 499) { // Don't retry other client errors. throw new ClientError(networkResponse); } else if (statusCode >= 500 && statusCode <= 599) { if (request.shouldRetryServerErrors()) { attemptRetryOnException("server", request, new ServerError(networkResponse)); } else { throw new ServerError(networkResponse); } } else { // 3xx? No reason to retry. throw new ServerError(networkResponse); } } else { attemptRetryOnException("network", request, new NetworkError()); } } } }
From source file:com.ikanow.aleph2.storm.samples.topology.SampleStormStreamTopology1.java
@Override public Tuple2<Object, Map<String, String>> getTopologyAndConfiguration(final DataBucketBean bucket, final IEnrichmentModuleContext context) { final TopologyBuilder builder = new TopologyBuilder(); final Collection<Tuple2<BaseRichSpout, String>> entry_points = context .getTopologyEntryPoints(BaseRichSpout.class, Optional.of(bucket)); entry_points.forEach(spout_name -> builder.setSpout(spout_name._2(), spout_name._1())); entry_points.stream().reduce(builder.setBolt("sample_conversion_bolt", new SampleConversionBolt()), (acc, v) -> acc.localOrShuffleGrouping(v._2()), (acc1, acc2) -> acc1 // (not possible in practice) );// w w w . jav a 2 s. c om builder.setBolt("sample_enrichment_bolt", new SampleEnrichmentBolt()) .localOrShuffleGrouping("sample_conversion_bolt"); builder.setBolt("default_aleph2_output_spout", context.getTopologyStorageEndpoint(BaseRichBolt.class, Optional.of(bucket))) .localOrShuffleGrouping("sample_enrichment_bolt"); return Tuples._2T(builder.createTopology(), Collections.emptyMap()); }
From source file:io.seldon.api.state.zk.ZkClientConfigHandler.java
@Override public Map<String, String> requestCacheDump(String client) { if (initalized) { return handler.getChildrenValues("/" + CLIENT_LIST_LOCATION + "/" + client); } else {/*www . jav a2 s .c om*/ return Collections.emptyMap(); } }
From source file:com.ikanow.aleph2.enrichment.utils.services.SimpleRegexFilterService.java
@Override public void onStageInitialize(IEnrichmentModuleContext context, DataBucketBean bucket, EnrichmentControlMetadataBean control, final Tuple2<ProcessingStage, ProcessingStage> previous_next, final Optional<List<String>> grouping_fields) { final SimpleRegexFilterBean config_bean = BeanTemplateUtils .from(Optional.ofNullable(control.config()).orElse(Collections.emptyMap()), SimpleRegexFilterBean.class) .get();//from ww w.j av a 2s .com final InternalRegexConfig regex_config = BeanTemplateUtils.build(InternalRegexConfig.class).with( InternalRegexConfig::elements, config_bean.elements().stream().filter(element -> element.enabled()) .map(element -> BeanTemplateUtils.build(InternalRegexConfig.InternalRegexElement.class) .with(InternalRegexConfig.InternalRegexElement::regex, buildRegex(element)) .with(InternalRegexConfig.InternalRegexElement::fields, element.fields()).done() .get()) .collect(Collectors.toList())) .done().get(); _regex_config.trySet(regex_config); _context.trySet(context); }
From source file:org.fcrepo.auth.roles.common.AccessRolesProvider.java
/** * Get the roles assigned to this Node. Optionally search up the tree for * the effective roles.//from w w w .j ava2s . c om * * @param node the subject Node * @param effective if true then search for effective roles * @return a set of roles for each principal */ public Map<String, List<String>> getRoles(Node node, final boolean effective) throws RepositoryException { final Map<String, List<String>> data = new HashMap<String, List<String>>(); final Session session = node.getSession(); Constants.registerPrefixes(session); if (node.isNodeType(JcrName.rbaclAssignable.getQualified())) { getAssignments(node, data); return data; } else { if (effective) { // look up the tree try { for (node = node.getParent(); node != null; node = node.getParent()) { if (node.isNodeType(JcrName.rbaclAssignable.getQualified())) { if (log.isDebugEnabled()) { log.debug("effective roles are assigned at node: " + node.getPath()); } getAssignments(node, data); if (log.isDebugEnabled()) { for (final String key : data.keySet()) { log.debug(key + " has role(s) " + data.get(key)); } } return data; } } } catch (final ItemNotFoundException e) { return DEFAULT_ACCESS_ROLES; } } } return Collections.emptyMap(); }
From source file:io.github.carlomicieli.footballdb.starter.pages.Table.java
public Map<String, String> valuesForRow(int n) { if (tableWithoutHeader()) return Collections.emptyMap(); return rowValues(n).map(cells -> { Map<String, String> m = IntStream.range(0, columnsCount()).mapToObj(bindHeaderWithValue(cells)) .collect(toMap(p -> p.getKey(), p -> p.getValue())); return m; }).orElse(null);//from ww w . j a v a2 s . c o m }
From source file:com.aipo.container.gadgets.uri.AipoProxyUriManager.java
public List<Uri> make(List<ProxyUri> resources, Integer forcedRefresh) { if (resources.isEmpty()) { return Collections.emptyList(); }//ww w. j a v a 2 s . c o m List<Uri> resourceUris = Lists.newArrayListWithCapacity(resources.size()); for (ProxyUri puc : resources) { resourceUris.add(puc.getResource()); } Map<Uri, String> versions; if (versioner == null) { versions = Collections.emptyMap(); } else { versions = Maps.newHashMapWithExpectedSize(resources.size()); List<String> versionList = versioner.version(resourceUris, resources.get(0).getContainer()); if (versionList != null && versionList.size() == resources.size()) { // This should always be the case. // Should we error if not, or just WARNING? Iterator<String> versionIt = versionList.iterator(); for (ProxyUri puc : resources) { versions.put(puc.getResource(), versionIt.next()); } } } List<Uri> result = Lists.newArrayListWithCapacity(resources.size()); for (ProxyUri puc : resources) { result.add(makeProxiedUri(puc, forcedRefresh, versions.get(puc.getResource()))); } return result; }
From source file:io.svectors.hbase.parser.JsonEventParser.java
/** * Parses the value./*from w ww . j a v a 2 s.c om*/ * @param topic * @param schema * @param value * @return * @throws EventParsingException */ public Map<String, byte[]> parse(final String topic, final Schema schema, final Object value, final boolean isKey) throws EventParsingException { final Map<String, byte[]> values = new LinkedHashMap<>(); try { byte[] valueBytes = null; if (isKey) { valueBytes = keyConverter.fromConnectData(topic, schema, value); } else { valueBytes = valueConverter.fromConnectData(topic, schema, value); } if (valueBytes == null || valueBytes.length == 0) { return Collections.emptyMap(); } final JsonNode valueNode = JSON_READER.readValue(valueBytes); final Map<String, Object> keyValues = OBJECT_MAPPER.convertValue(valueNode, new TypeReference<Map<String, Object>>() { }); final List<Field> fields = schema.fields(); for (Field field : fields) { final byte[] fieldValue = toValue(keyValues, field); if (fieldValue == null) { continue; } values.put(field.name(), fieldValue); } return values; } catch (Exception ex) { final String errorMsg = String.format("Failed to parse the schema [%s] , value [%s] with ex [%s]", schema, value, ex.getMessage()); throw new EventParsingException(errorMsg, ex); } }
From source file:com.github.rvesse.airline.utils.AirlineUtils.java
public static <K, V> Map<K, V> unmodifiableMapCopy(Map<K, V> map) { if (map == null) return Collections.emptyMap(); return Collections.unmodifiableMap(new LinkedHashMap<K, V>(map)); }