use of org.apache.skywalking.oap.server.library.module.ModuleStartException in project skywalking by apache.
the class InfluxStorageProvider method start.
@Override
public void start() throws ServiceNotProvidedException, ModuleStartException {
MetricsCreator metricCreator = getManager().find(TelemetryModule.NAME).provider().getService(MetricsCreator.class);
HealthCheckMetrics healthChecker = metricCreator.createHealthCheckerGauge("storage_influxdb", MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE);
client.registerChecker(healthChecker);
try {
client.connect();
InfluxTableInstaller installer = new InfluxTableInstaller(client, getManager());
getManager().find(CoreModule.NAME).provider().getService(ModelCreator.class).addModelListener(installer);
} catch (StorageException e) {
throw new ModuleStartException(e.getMessage(), e);
}
}
use of org.apache.skywalking.oap.server.library.module.ModuleStartException in project incubator-skywalking by apache.
the class KafkaFetcherHandlerRegister method createTopicIfNeeded.
private void createTopicIfNeeded(Collection<String> topics, Properties properties) throws ModuleStartException {
Properties adminProps = new Properties();
adminProps.putAll(properties);
// remove 'group.id' to avoid unknown configure warning.
adminProps.remove(ConsumerConfig.GROUP_ID_CONFIG);
AdminClient adminClient = AdminClient.create(adminProps);
Set<String> missedTopics = adminClient.describeTopics(topics).values().entrySet().stream().map(entry -> {
try {
entry.getValue().get();
return null;
} catch (InterruptedException | ExecutionException ignore) {
}
return entry.getKey();
}).filter(Objects::nonNull).collect(Collectors.toSet());
if (!missedTopics.isEmpty()) {
log.info("Topics " + missedTopics + " not exist.");
List<NewTopic> newTopicList = missedTopics.stream().map(topic -> new NewTopic(topic, config.getPartitions(), (short) config.getReplicationFactor())).collect(Collectors.toList());
try {
adminClient.createTopics(newTopicList).all().get();
} catch (Exception e) {
throw new ModuleStartException("Failed to create Kafka Topics" + missedTopics + ".", e);
}
}
}
use of org.apache.skywalking.oap.server.library.module.ModuleStartException in project incubator-skywalking by apache.
the class H2StorageProvider method start.
@Override
public void start() throws ServiceNotProvidedException, ModuleStartException {
final ConfigService configService = getManager().find(CoreModule.NAME).provider().getService(ConfigService.class);
MetricsCreator metricCreator = getManager().find(TelemetryModule.NAME).provider().getService(MetricsCreator.class);
HealthCheckMetrics healthChecker = metricCreator.createHealthCheckerGauge("storage_h2", MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE);
h2Client.registerChecker(healthChecker);
try {
h2Client.connect();
H2TableInstaller installer = new H2TableInstaller(h2Client, getManager());
getManager().find(CoreModule.NAME).provider().getService(ModelCreator.class).addModelListener(installer);
} catch (StorageException e) {
throw new ModuleStartException(e.getMessage(), e);
}
}
use of org.apache.skywalking.oap.server.library.module.ModuleStartException in project incubator-skywalking by apache.
the class BanyanDBStorageProvider method start.
@Override
public void start() throws ServiceNotProvidedException, ModuleStartException {
final ConfigService configService = getManager().find(CoreModule.NAME).provider().getService(ConfigService.class);
MetricsCreator metricCreator = getManager().find(TelemetryModule.NAME).provider().getService(MetricsCreator.class);
HealthCheckMetrics healthChecker = metricCreator.createHealthCheckerGauge("storage_banyandb", MetricsTag.EMPTY_KEY, MetricsTag.EMPTY_VALUE);
this.client.registerChecker(healthChecker);
try {
this.client.connect();
BanyanDBIndexInstaller installer = new BanyanDBIndexInstaller(client, getManager(), this.config);
getManager().find(CoreModule.NAME).provider().getService(ModelCreator.class).addModelListener(installer);
} catch (Exception e) {
throw new ModuleStartException(e.getMessage(), e);
}
}
use of org.apache.skywalking.oap.server.library.module.ModuleStartException in project incubator-skywalking by apache.
the class Rules method loadRules.
public static List<Rule> loadRules(final String path, List<String> enabledRules) throws ModuleStartException {
File[] rules;
try {
rules = ResourceUtils.getPathFiles(path);
} catch (FileNotFoundException e) {
throw new ModuleStartException("Load fetcher rules failed", e);
}
return Arrays.stream(rules).filter(File::isFile).map(f -> {
try (Reader r = new FileReader(f)) {
String fileName = f.getName();
int dotIndex = fileName.lastIndexOf('.');
fileName = (dotIndex == -1) ? fileName : fileName.substring(0, dotIndex);
if (!enabledRules.contains(fileName)) {
return null;
}
Rule rule = new Yaml().loadAs(r, Rule.class);
rule.setName(fileName);
return rule;
} catch (IOException e) {
LOG.debug("Reading file {} failed", f, e);
}
return null;
}).filter(Objects::nonNull).collect(Collectors.toList());
}
Aggregations