use of com.wavefront.data.ReportableEntityType in project java by wavefrontHQ.
the class QueueExporter method getValidHandlerKeys.
@VisibleForTesting
static Set<HandlerKey> getValidHandlerKeys(@Nullable List<String> files, String portList) {
if (files == null) {
return Collections.emptySet();
}
Set<String> ports = new HashSet<>(Splitter.on(",").omitEmptyStrings().trimResults().splitToList(portList));
Set<HandlerKey> out = new HashSet<>();
files.forEach(x -> {
Matcher matcher = FILENAME.matcher(x);
if (matcher.matches()) {
ReportableEntityType type = ReportableEntityType.fromString(matcher.group(2));
String handle = matcher.group(3);
if (type != null && NumberUtils.isDigits(matcher.group(4)) && !handle.startsWith("_") && (portList.equalsIgnoreCase("all") || ports.contains(handle))) {
out.add(HandlerKey.of(type, handle));
}
}
});
return out;
}
use of com.wavefront.data.ReportableEntityType in project java by wavefrontHQ.
the class SenderTaskFactoryImpl method createSenderTasks.
@SuppressWarnings("unchecked")
public Collection<SenderTask<?>> createSenderTasks(@Nonnull HandlerKey handlerKey) {
ReportableEntityType entityType = handlerKey.getEntityType();
int numThreads = entityPropsFactory.get(entityType).getFlushThreads();
List<SenderTask<?>> toReturn = new ArrayList<>(numThreads);
TaskSizeEstimator taskSizeEstimator = new TaskSizeEstimator(handlerKey.getHandle());
taskSizeEstimators.put(handlerKey, taskSizeEstimator);
ScheduledExecutorService scheduler = executors.computeIfAbsent(handlerKey, x -> Executors.newScheduledThreadPool(numThreads, new NamedThreadFactory("submitter-" + handlerKey.getEntityType() + "-" + handlerKey.getHandle())));
for (int threadNo = 0; threadNo < numThreads; threadNo++) {
SenderTask<?> senderTask;
switch(entityType) {
case POINT:
case DELTA_COUNTER:
senderTask = new LineDelimitedSenderTask(handlerKey, PUSH_FORMAT_WAVEFRONT, apiContainer.getProxyV2API(), proxyId, entityPropsFactory.get(entityType), scheduler, threadNo, taskSizeEstimator, taskQueueFactory.getTaskQueue(handlerKey, threadNo));
break;
case HISTOGRAM:
senderTask = new LineDelimitedSenderTask(handlerKey, PUSH_FORMAT_HISTOGRAM, apiContainer.getProxyV2API(), proxyId, entityPropsFactory.get(entityType), scheduler, threadNo, taskSizeEstimator, taskQueueFactory.getTaskQueue(handlerKey, threadNo));
break;
case SOURCE_TAG:
senderTask = new SourceTagSenderTask(handlerKey, apiContainer.getSourceTagAPI(), threadNo, entityPropsFactory.get(entityType), scheduler, taskQueueFactory.getTaskQueue(handlerKey, threadNo));
break;
case TRACE:
senderTask = new LineDelimitedSenderTask(handlerKey, PUSH_FORMAT_TRACING, apiContainer.getProxyV2API(), proxyId, entityPropsFactory.get(entityType), scheduler, threadNo, taskSizeEstimator, taskQueueFactory.getTaskQueue(handlerKey, threadNo));
break;
case TRACE_SPAN_LOGS:
senderTask = new LineDelimitedSenderTask(handlerKey, PUSH_FORMAT_TRACING_SPAN_LOGS, apiContainer.getProxyV2API(), proxyId, entityPropsFactory.get(entityType), scheduler, threadNo, taskSizeEstimator, taskQueueFactory.getTaskQueue(handlerKey, threadNo));
break;
case EVENT:
senderTask = new EventSenderTask(handlerKey, apiContainer.getEventAPI(), proxyId, threadNo, entityPropsFactory.get(entityType), scheduler, taskQueueFactory.getTaskQueue(handlerKey, threadNo));
break;
default:
throw new IllegalArgumentException("Unexpected entity type " + handlerKey.getEntityType().name() + " for " + handlerKey.getHandle());
}
toReturn.add(senderTask);
senderTask.start();
}
if (queueingFactory != null) {
QueueController<?> controller = queueingFactory.getQueueController(handlerKey, numThreads);
managedServices.put(handlerKey, controller);
controller.start();
}
managedTasks.put(handlerKey, toReturn);
entityTypes.computeIfAbsent(handlerKey.getHandle(), x -> new ArrayList<>()).add(handlerKey.getEntityType());
return toReturn;
}
use of com.wavefront.data.ReportableEntityType in project java by wavefrontHQ.
the class TrafficShapingRateLimitAdjuster method run.
@Override
public void run() {
for (ReportableEntityType type : ReportableEntityType.values()) {
EntityProperties props = entityProps.get(type);
long rate = props.getTotalReceivedRate();
EvictingRingBuffer<Long> stats = perEntityStats.computeIfAbsent(type, x -> new SynchronizedEvictingRingBuffer<>(windowSeconds));
if (rate > 0 || stats.size() > 0) {
stats.add(rate);
if (stats.size() >= 60) {
// need at least 1 minute worth of stats to enable the limiter
RecyclableRateLimiter rateLimiter = props.getRateLimiter();
adjustRateLimiter(type, stats, rateLimiter);
}
}
}
}
use of com.wavefront.data.ReportableEntityType in project java by wavefrontHQ.
the class PushAgent method startRelayListener.
@VisibleForTesting
protected void startRelayListener(String strPort, ReportableEntityHandlerFactory handlerFactory, SharedGraphiteHostAnnotator hostAnnotator) {
final int port = Integer.parseInt(strPort);
registerPrefixFilter(strPort);
registerTimestampFilter(strPort);
if (proxyConfig.isHttpHealthCheckAllPorts())
healthCheckManager.enableHealthcheck(port);
ReportableEntityHandlerFactory handlerFactoryDelegate = proxyConfig.isPushRelayHistogramAggregator() ? new DelegatingReportableEntityHandlerFactoryImpl(handlerFactory) {
@Override
public <T, U> ReportableEntityHandler<T, U> getHandler(HandlerKey handlerKey) {
if (handlerKey.getEntityType() == ReportableEntityType.HISTOGRAM) {
ChronicleMap<HistogramKey, AgentDigest> accumulator = ChronicleMap.of(HistogramKey.class, AgentDigest.class).keyMarshaller(HistogramKeyMarshaller.get()).valueMarshaller(AgentDigestMarshaller.get()).entries(proxyConfig.getPushRelayHistogramAggregatorAccumulatorSize()).averageKeySize(proxyConfig.getHistogramDistAvgKeyBytes()).averageValueSize(proxyConfig.getHistogramDistAvgDigestBytes()).maxBloatFactor(1000).create();
AgentDigestFactory agentDigestFactory = new AgentDigestFactory(() -> (short) Math.min(proxyConfig.getPushRelayHistogramAggregatorCompression(), entityProps.getGlobalProperties().getHistogramStorageAccuracy()), TimeUnit.SECONDS.toMillis(proxyConfig.getPushRelayHistogramAggregatorFlushSecs()), proxyConfig.getTimeProvider());
AccumulationCache cachedAccumulator = new AccumulationCache(accumulator, agentDigestFactory, 0, "histogram.accumulator.distributionRelay", null);
// noinspection unchecked
return (ReportableEntityHandler<T, U>) new HistogramAccumulationHandlerImpl(handlerKey, cachedAccumulator, proxyConfig.getPushBlockedSamples(), null, validationConfiguration, true, rate -> entityProps.get(ReportableEntityType.HISTOGRAM).reportReceivedRate(handlerKey.getHandle(), rate), blockedHistogramsLogger, VALID_HISTOGRAMS_LOGGER);
}
return delegate.getHandler(handlerKey);
}
} : handlerFactory;
Map<ReportableEntityType, ReportableEntityDecoder<?, ?>> filteredDecoders = decoderSupplier.get().entrySet().stream().filter(x -> !x.getKey().equals(ReportableEntityType.SOURCE_TAG)).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
ChannelHandler channelHandler = new RelayPortUnificationHandler(strPort, tokenAuthenticator, healthCheckManager, filteredDecoders, handlerFactoryDelegate, preprocessors.get(strPort), hostAnnotator, () -> entityProps.get(ReportableEntityType.HISTOGRAM).isFeatureDisabled(), () -> entityProps.get(ReportableEntityType.TRACE).isFeatureDisabled(), () -> entityProps.get(ReportableEntityType.TRACE_SPAN_LOGS).isFeatureDisabled());
startAsManagedThread(port, new TcpIngester(createInitializer(channelHandler, port, proxyConfig.getPushListenerMaxReceivedLength(), proxyConfig.getPushListenerHttpBufferSize(), proxyConfig.getListenerIdleConnectionTimeout(), getSslContext(strPort), getCorsConfig(strPort)), port).withChildChannelOptions(childChannelOptions), "listener-relay-" + port);
}
Aggregations