本文整理汇总了Java中com.stackify.api.common.util.Preconditions类的典型用法代码示例。如果您正苦于以下问题:Java Preconditions类的具体用法?Java Preconditions怎么用?Java Preconditions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Preconditions类属于com.stackify.api.common.util包,在下文中一共展示了Preconditions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: autoReportLast
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Auto reports any metrics that are missing a value from the current iteration
* @param autoMetrics The metrics that need to me auto reported as the last value
*/
public void autoReportLast(final Set<MetricIdentity> autoMetrics) {
Preconditions.checkNotNull(autoMetrics);
for (MetricIdentity identity : autoMetrics) {
if (!aggregateExistsForCurrentMinute(identity)) {
MetricAggregate aggregate = getAggregate(identity);
aggregate.setCount(1);
if (lastValues.containsKey(identity)) {
aggregate.setValue(lastValues.get(identity));
} else {
aggregate.setValue(0.0);
}
}
}
}
开发者ID:stackify,项目名称:stackify-metrics,代码行数:22,代码来源:MetricAggregator.java
示例2: getCookies
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Returns a Map from cookie name to masked value
* @param request The HTTP servlet request
* @return Map from cookie name to masked value
*/
private static Map<String, String> getCookies(final HttpServletRequest request) {
Preconditions.checkNotNull(request);
Cookie[] cookies = request.getCookies();
if ((cookies != null) && (0 < cookies.length)) {
Map<String, String> cookieMap = new HashMap<String, String>();
for (int i = 0; i < cookies.length; ++i) {
Cookie cookie = cookies[i];
String name = cookie.getName();
cookieMap.put(name, MASKED);
}
return cookieMap;
}
return null;
}
开发者ID:stackify,项目名称:stackify-log-servlet,代码行数:26,代码来源:HttpServletRequests.java
示例3: getSessionAttributes
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Returns a Map from session attribute name to masked value
* @param request The HTTP servlet request
* @return Map from session attribute name to masked value
*/
private static Map<String, String> getSessionAttributes(final HttpServletRequest request) {
Preconditions.checkNotNull(request);
HttpSession session = request.getSession(false);
if (session != null) {
@SuppressWarnings("unchecked")
Enumeration<String> attributeNames = session.getAttributeNames();
if ((attributeNames != null) && (attributeNames.hasMoreElements())) {
Map<String, String> attributeMap = new HashMap<String, String>();
while (attributeNames.hasMoreElements()) {
String name = attributeNames.nextElement();
attributeMap.put(name, MASKED);
}
return attributeMap;
}
}
return null;
}
开发者ID:stackify,项目名称:stackify-log-servlet,代码行数:31,代码来源:HttpServletRequests.java
示例4: MetricSender
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Constructor
* @param apiConfig API configuration
* @param objectMapper JSON object mapper
* @param monitorService Monitor service
*/
public MetricSender(final ApiConfiguration apiConfig, final ObjectMapper objectMapper, final MetricMonitorService monitorService) {
Preconditions.checkNotNull(apiConfig);
Preconditions.checkNotNull(objectMapper);
Preconditions.checkNotNull(monitorService);
this.apiConfig = apiConfig;
this.objectMapper = objectMapper;
this.monitorService = monitorService;
}
开发者ID:stackify,项目名称:stackify-metrics,代码行数:15,代码来源:MetricSender.java
示例5: MetricBackgroundService
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Constructor
* @param collector Metric collector
* @param sender Sends metrics to Stackify
*/
public MetricBackgroundService(final MetricCollector collector, final MetricSender sender) {
Preconditions.checkNotNull(collector);
Preconditions.checkNotNull(sender);
this.collector = collector;
this.sender = sender;
}
开发者ID:stackify,项目名称:stackify-metrics,代码行数:12,代码来源:MetricBackgroundService.java
示例6: MetricIdentity
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Constructor
* @param category Metric category
* @param name Metric name
* @param type Metric monitor type
*/
public MetricIdentity(final String category, final String name, final MetricMonitorType type) {
Preconditions.checkNotNull(category);
Preconditions.checkArgument(!category.isEmpty());
Preconditions.checkNotNull(name);
Preconditions.checkArgument(!name.isEmpty());
Preconditions.checkNotNull(type);
this.category = category;
this.name = name;
this.type = type;
}
开发者ID:stackify,项目名称:stackify-metrics,代码行数:18,代码来源:MetricIdentity.java
示例7: MetricMonitorService
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Constructor
* @param apiConfig API configuration
* @param objectMapper JSON object mapper
* @param appIdentityService Application identity service
*/
public MetricMonitorService(final ApiConfiguration apiConfig, final ObjectMapper objectMapper, final AppIdentityService appIdentityService) {
Preconditions.checkNotNull(apiConfig);
Preconditions.checkNotNull(objectMapper);
Preconditions.checkNotNull(appIdentityService);
this.apiConfig = apiConfig;
this.objectMapper = objectMapper;
this.appIdentityService = appIdentityService;
}
开发者ID:stackify,项目名称:stackify-metrics,代码行数:15,代码来源:MetricMonitorService.java
示例8: MetricAggregator
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Constructor
* @param currentMinute Current minute
* @param lastValues Last values for the metrics
*/
public MetricAggregator(final long currentMinute, final Map<MetricIdentity, Double> lastValues) {
Preconditions.checkArgument(0 < currentMinute);
Preconditions.checkNotNull(lastValues);
this.currentMinute = currentMinute;
this.lastValues = lastValues;
}
开发者ID:stackify,项目名称:stackify-metrics,代码行数:12,代码来源:MetricAggregator.java
示例9: add
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Aggregates a single metric into the collection of aggregates
* @param metric The metric
*/
public void add(final Metric metric) {
Preconditions.checkNotNull(metric);
// get the aggregate for this minute
MetricAggregate aggregate = getAggregate(metric.getIdentity());
// add the current metric into the aggregate
switch (metric.getIdentity().getType()) {
case COUNTER:
case TIMER:
case AVERAGE:
aggregate.setCount(aggregate.getCount() + 1);
aggregate.setValue(aggregate.getValue() + metric.getValue());
break;
case GAUGE:
aggregate.setCount(1);
if (metric.isIncrement()) {
aggregate.setValue(aggregate.getValue() + metric.getValue());
} else {
aggregate.setValue(metric.getValue());
}
break;
default:
LOGGER.info("Unable to aggregate {} metric type", metric.getIdentity().getType());
break;
}
}
开发者ID:stackify,项目名称:stackify-metrics,代码行数:34,代码来源:MetricAggregator.java
示例10: autoReportZero
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Auto reports any metrics that are missing a value from the current iteration
* @param autoMetrics The metrics that need to me auto reported as zero
*/
public void autoReportZero(final Set<MetricIdentity> autoMetrics) {
Preconditions.checkNotNull(autoMetrics);
for (MetricIdentity identity : autoMetrics) {
if (!aggregateExistsForCurrentMinute(identity)) {
MetricAggregate aggregate = getAggregate(identity);
aggregate.setCount(1);
aggregate.setValue(0.0);
}
}
}
开发者ID:stackify,项目名称:stackify-metrics,代码行数:17,代码来源:MetricAggregator.java
示例11: aggregateExistsForCurrentMinute
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Determines if the specified aggregate metric exists for the current minute
* @param identity The metric identity
* @return True if the metric exists, false otherwise
*/
private boolean aggregateExistsForCurrentMinute(final MetricIdentity identity) {
Preconditions.checkNotNull(identity);
if (aggregates.containsKey(identity)) {
if (aggregates.get(identity).containsKey(currentMinute)) {
return true;
}
}
return false;
}
开发者ID:stackify,项目名称:stackify-metrics,代码行数:17,代码来源:MetricAggregator.java
示例12: toMap
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Returns a Map from query parameter name to value
* @param request The HTTP servlet request
* @return Map from query parameter name to value
*/
public static Map<String, String> toMap(final String queryString) {
Preconditions.checkNotNull(queryString);
Map<String, String> queryMap = new HashMap<String, String>();
String decoded = queryString;
try {
decoded = URLDecoder.decode(queryString, "UTF-8");
} catch (UnsupportedEncodingException e) {
// do nothing
}
String[] params = decoded.split("[&;]");
if ((params != null) && (0 < params.length)) {
for (String param : params) {
String[] kv = param.split("=");
if ((kv != null) && (kv.length == 2)) {
String key = kv[0];
String value = kv[1];
if (queryMap.containsKey(key)) {
value = queryMap.get(key) + "," + value;
}
queryMap.put(key, value);
}
}
}
return queryMap;
}
开发者ID:stackify,项目名称:stackify-log-servlet,代码行数:43,代码来源:QueryStrings.java
示例13: addAll
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* @see java.util.Collection#addAll(java.util.Collection)
*/
@Override
public synchronized boolean addAll(Collection<? extends E> c) {
Preconditions.checkNotNull(c);
for (E e : c) {
add(e);
}
return true;
}
开发者ID:stackify,项目名称:stackify-api-java,代码行数:14,代码来源:SynchronizedEvictingQueue.java
示例14: add
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* @see java.util.Queue#add(java.lang.Object)
*/
@Override
public synchronized boolean add(E e) {
Preconditions.checkNotNull(e);
if (deque.size() == maxSize) {
deque.remove();
}
deque.add(e);
return true;
}
开发者ID:stackify,项目名称:stackify-api-java,代码行数:16,代码来源:SynchronizedEvictingQueue.java
示例15: send
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Sends a group of log messages to Stackify
* @param group The log message group
* @return The HTTP status code returned from the HTTP POST
* @throws IOException
*/
public int send(final LogMsgGroup group) throws IOException {
Preconditions.checkNotNull(group);
executeMask(group);
executeSkipJsonTag(group);
HttpClient httpClient = new HttpClient(apiConfig);
// retransmit any logs on the resend queue
resendQueue.drain(httpClient, LOG_SAVE_PATH, true);
// convert to json bytes
byte[] jsonBytes = objectMapper.writer().writeValueAsBytes(group);
// post to stackify
int statusCode = HttpURLConnection.HTTP_INTERNAL_ERROR;
try {
httpClient.post(LOG_SAVE_PATH, jsonBytes, true);
statusCode = HttpURLConnection.HTTP_OK;
} catch (IOException t) {
LOGGER.info("Queueing logs for retransmission due to IOException");
resendQueue.offer(jsonBytes, t);
throw t;
} catch (HttpException e) {
statusCode = e.getStatusCode();
LOGGER.info("Queueing logs for retransmission due to HttpException", e);
resendQueue.offer(jsonBytes, e);
}
return statusCode;
}
开发者ID:stackify,项目名称:stackify-api-java,代码行数:42,代码来源:LogSender.java
示例16: LogBackgroundService
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Constructor
* @param collector The LogMsg collector
* @param sender The LogMsgGroup HTTP sender
*/
public LogBackgroundService(final LogCollector collector, final LogSender sender) {
Preconditions.checkNotNull(collector);
Preconditions.checkNotNull(sender);
this.collector = collector;
this.sender = sender;
}
开发者ID:stackify,项目名称:stackify-api-java,代码行数:12,代码来源:LogBackgroundService.java
示例17: AppIdentityService
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Constructor
* @param apiConfig The API configuration
* @param objectMapper Jackson object mapper
*/
public AppIdentityService(final ApiConfiguration apiConfig, final ObjectMapper objectMapper) {
Preconditions.checkNotNull(apiConfig);
Preconditions.checkNotNull(objectMapper);
this.defaultApiConfig = apiConfig;
this.objectMapper = objectMapper;
this.deviceAppIdRequired = false;
}
开发者ID:stackify,项目名称:stackify-api-java,代码行数:14,代码来源:AppIdentityService.java
示例18: isCached
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
private boolean isCached(final String applicationName) {
Preconditions.checkNotNull(applicationName);
return
applicationIdentityCache.containsKey(applicationName) &&
applicationIdentityCache.get(applicationName).getAppIdentity() != null;
}
开发者ID:stackify,项目名称:stackify-api-java,代码行数:8,代码来源:AppIdentityService.java
示例19: LogEventAdapter
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Constructor
* @param envDetail Environment detail
*/
public LogEventAdapter(final EnvironmentDetail envDetail) {
Preconditions.checkNotNull(envDetail);
this.envDetail = envDetail;
}
开发者ID:stackify,项目名称:stackify-log-log4j2,代码行数:9,代码来源:LogEventAdapter.java
示例20: autoReportZero
import com.stackify.api.common.util.Preconditions; //导入依赖的package包/类
/**
* Adds this metric to the auto zero list
* @param identity The metric identity
*/
public void autoReportZero(final MetricIdentity identity) {
Preconditions.checkNotNull(identity);
autoReportZeroMetrics.add(identity);
}
开发者ID:stackify,项目名称:stackify-metrics,代码行数:9,代码来源:MetricCollector.java
注:本文中的com.stackify.api.common.util.Preconditions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论