Search in sources :

Example 1 with ModuleStartException

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);
    }
}
Also used : HealthCheckMetrics(org.apache.skywalking.oap.server.telemetry.api.HealthCheckMetrics) ModuleStartException(org.apache.skywalking.oap.server.library.module.ModuleStartException) MetricsCreator(org.apache.skywalking.oap.server.telemetry.api.MetricsCreator) ModelCreator(org.apache.skywalking.oap.server.core.storage.model.ModelCreator) StorageException(org.apache.skywalking.oap.server.core.storage.StorageException)

Example 2 with ModuleStartException

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);
        }
    }
}
Also used : ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) CustomThreadFactory(org.apache.skywalking.oap.server.library.server.pool.CustomThreadFactory) ConsumerRecords(org.apache.kafka.clients.consumer.ConsumerRecords) AdminClient(org.apache.kafka.clients.admin.AdminClient) Lists(com.google.common.collect.Lists) StringDeserializer(org.apache.kafka.common.serialization.StringDeserializer) Duration(java.time.Duration) Properties(java.util.Properties) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) NewTopic(org.apache.kafka.clients.admin.NewTopic) Set(java.util.Set) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) Collectors(java.util.stream.Collectors) Bytes(org.apache.kafka.common.utils.Bytes) Objects(java.util.Objects) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) KafkaHandler(org.apache.skywalking.oap.server.analyzer.agent.kafka.provider.handler.KafkaHandler) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) ModuleStartException(org.apache.skywalking.oap.server.library.module.ModuleStartException) KafkaFetcherConfig(org.apache.skywalking.oap.server.analyzer.agent.kafka.module.KafkaFetcherConfig) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) BytesDeserializer(org.apache.kafka.common.serialization.BytesDeserializer) KafkaConsumer(org.apache.kafka.clients.consumer.KafkaConsumer) ModuleStartException(org.apache.skywalking.oap.server.library.module.ModuleStartException) NewTopic(org.apache.kafka.clients.admin.NewTopic) Properties(java.util.Properties) ExecutionException(java.util.concurrent.ExecutionException) ExecutionException(java.util.concurrent.ExecutionException) ModuleStartException(org.apache.skywalking.oap.server.library.module.ModuleStartException) AdminClient(org.apache.kafka.clients.admin.AdminClient)

Example 3 with ModuleStartException

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);
    }
}
Also used : ConfigService(org.apache.skywalking.oap.server.core.config.ConfigService) H2TableInstaller(org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TableInstaller) HealthCheckMetrics(org.apache.skywalking.oap.server.telemetry.api.HealthCheckMetrics) ModuleStartException(org.apache.skywalking.oap.server.library.module.ModuleStartException) MetricsCreator(org.apache.skywalking.oap.server.telemetry.api.MetricsCreator) ModelCreator(org.apache.skywalking.oap.server.core.storage.model.ModelCreator) StorageException(org.apache.skywalking.oap.server.core.storage.StorageException)

Example 4 with ModuleStartException

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);
    }
}
Also used : ConfigService(org.apache.skywalking.oap.server.core.config.ConfigService) HealthCheckMetrics(org.apache.skywalking.oap.server.telemetry.api.HealthCheckMetrics) ModuleStartException(org.apache.skywalking.oap.server.library.module.ModuleStartException) MetricsCreator(org.apache.skywalking.oap.server.telemetry.api.MetricsCreator) ModelCreator(org.apache.skywalking.oap.server.core.storage.model.ModelCreator) ModuleStartException(org.apache.skywalking.oap.server.library.module.ModuleStartException) ServiceNotProvidedException(org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException)

Example 5 with ModuleStartException

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());
}
Also used : ModuleStartException(org.apache.skywalking.oap.server.library.module.ModuleStartException) FileNotFoundException(java.io.FileNotFoundException) Reader(java.io.Reader) FileReader(java.io.FileReader) FileReader(java.io.FileReader) IOException(java.io.IOException) File(java.io.File) Yaml(org.yaml.snakeyaml.Yaml)

Aggregations

ModuleStartException (org.apache.skywalking.oap.server.library.module.ModuleStartException)64 ServiceNotProvidedException (org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException)28 StorageException (org.apache.skywalking.oap.server.core.storage.StorageException)18 IOException (java.io.IOException)16 ModelCreator (org.apache.skywalking.oap.server.core.storage.model.ModelCreator)16 ConfigService (org.apache.skywalking.oap.server.core.config.ConfigService)14 FileNotFoundException (java.io.FileNotFoundException)12 ModuleConfig (org.apache.skywalking.oap.server.library.module.ModuleConfig)12 ModuleDefine (org.apache.skywalking.oap.server.library.module.ModuleDefine)12 ModuleProvider (org.apache.skywalking.oap.server.library.module.ModuleProvider)12 MetricsCreator (org.apache.skywalking.oap.server.telemetry.api.MetricsCreator)12 Reader (java.io.Reader)10 Slf4j (lombok.extern.slf4j.Slf4j)10 HealthCheckMetrics (org.apache.skywalking.oap.server.telemetry.api.HealthCheckMetrics)10 Map (java.util.Map)8 ConfigChangeWatcher (org.apache.skywalking.oap.server.configuration.api.ConfigChangeWatcher)8 DynamicConfigurationService (org.apache.skywalking.oap.server.configuration.api.DynamicConfigurationService)8 MeterSystem (org.apache.skywalking.oap.server.core.analysis.meter.MeterSystem)8 File (java.io.File)6 FileReader (java.io.FileReader)6