use of io.quarkus.deployment.console.StartupLogCompressor in project quarkus by quarkusio.
the class DevServicesApicurioRegistryProcessor method startApicurioRegistryDevService.
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class)
public DevServicesResultBuildItem startApicurioRegistryDevService(LaunchModeBuildItem launchMode, DockerStatusBuildItem dockerStatusBuildItem, ApicurioRegistryDevServicesBuildTimeConfig apicurioRegistryDevServices, List<DevServicesSharedNetworkBuildItem> devServicesSharedNetworkBuildItem, Optional<ConsoleInstalledBuildItem> consoleInstalledBuildItem, CuratedApplicationShutdownBuildItem closeBuildItem, LoggingSetupBuildItem loggingSetupBuildItem, GlobalDevServicesConfig devServicesConfig) {
ApicurioRegistryDevServiceCfg configuration = getConfiguration(apicurioRegistryDevServices);
if (devService != null) {
boolean restartRequired = !configuration.equals(cfg);
if (!restartRequired) {
return devService.toBuildItem();
}
shutdownApicurioRegistry();
cfg = null;
}
StartupLogCompressor compressor = new StartupLogCompressor((launchMode.isTest() ? "(test) " : "") + "Apicurio Registry Dev Services Starting:", consoleInstalledBuildItem, loggingSetupBuildItem);
try {
devService = startApicurioRegistry(dockerStatusBuildItem, configuration, launchMode, !devServicesSharedNetworkBuildItem.isEmpty(), devServicesConfig.timeout);
compressor.close();
} catch (Throwable t) {
compressor.closeAndDumpCaptured();
throw new RuntimeException(t);
}
if (devService == null) {
return null;
}
cfg = configuration;
if (devService.isOwner()) {
log.infof("Dev Services for Apicurio Registry started. The registry is available at %s", devService.getConfig().get(APLICURIO_REGISTRY_URL_CONFIG));
}
// Configure the watch dog
if (first) {
first = false;
Runnable closeTask = new Runnable() {
@Override
public void run() {
if (devService != null) {
shutdownApicurioRegistry();
}
first = true;
devService = null;
cfg = null;
}
};
closeBuildItem.addCloseTask(closeTask, true);
}
return devService.toBuildItem();
}
use of io.quarkus.deployment.console.StartupLogCompressor in project quarkus by quarkusio.
the class RabbitMQDevServicesProcessor method startRabbitMQDevService.
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class)
public DevServicesResultBuildItem startRabbitMQDevService(DockerStatusBuildItem dockerStatusBuildItem, LaunchModeBuildItem launchMode, RabbitMQBuildTimeConfig rabbitmqClientBuildTimeConfig, Optional<ConsoleInstalledBuildItem> consoleInstalledBuildItem, LoggingSetupBuildItem loggingSetupBuildItem, GlobalDevServicesConfig devServicesConfig) {
RabbitMQDevServiceCfg configuration = getConfiguration(rabbitmqClientBuildTimeConfig);
if (devService != null) {
boolean shouldShutdownTheBroker = !configuration.equals(cfg);
if (!shouldShutdownTheBroker) {
return devService.toBuildItem();
}
shutdownBroker();
cfg = null;
}
StartupLogCompressor compressor = new StartupLogCompressor((launchMode.isTest() ? "(test) " : "") + "RabbitMQ Dev Services Starting:", consoleInstalledBuildItem, loggingSetupBuildItem);
try {
RunningDevService newDevService = startRabbitMQBroker(dockerStatusBuildItem, configuration, launchMode, devServicesConfig.timeout);
if (newDevService != null) {
devService = newDevService;
Map<String, String> config = devService.getConfig();
if (devService.isOwner()) {
log.info("Dev Services for RabbitMQ started.");
log.infof("Other Quarkus applications in dev mode will find the " + "broker automatically. For Quarkus applications in production mode, you can connect to" + " this by starting your application with -Drabbitmq-host=%s -Drabbitmq-port=%s -Drabbitmq-username=%s -Drabbitmq-password=%s", config.get(RABBITMQ_HOST_PROP), config.get(RABBITMQ_PORT_PROP), config.get(RABBITMQ_USERNAME_PROP), config.get(RABBITMQ_PASSWORD_PROP));
}
}
if (devService == null) {
compressor.closeAndDumpCaptured();
} else {
compressor.close();
}
} catch (Throwable t) {
compressor.closeAndDumpCaptured();
throw new RuntimeException(t);
}
if (devService == null) {
return null;
}
// Configure the watch dog
if (first) {
first = false;
Runnable closeTask = () -> {
if (devService != null) {
shutdownBroker();
log.info("Dev Services for RabbitMQ shut down.");
}
first = true;
devService = null;
cfg = null;
};
QuarkusClassLoader cl = (QuarkusClassLoader) Thread.currentThread().getContextClassLoader();
((QuarkusClassLoader) cl.parent()).addCloseTask(closeTask);
}
cfg = configuration;
return devService.toBuildItem();
}
use of io.quarkus.deployment.console.StartupLogCompressor in project quarkus by quarkusio.
the class InfinispanDevServiceProcessor method startInfinispanContainers.
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = { GlobalDevServicesConfig.Enabled.class })
public List<DevServicesResultBuildItem> startInfinispanContainers(LaunchModeBuildItem launchMode, DockerStatusBuildItem dockerStatusBuildItem, List<DevServicesSharedNetworkBuildItem> devServicesSharedNetworkBuildItem, InfinispanClientDevServiceBuildTimeConfig config, Optional<ConsoleInstalledBuildItem> consoleInstalledBuildItem, CuratedApplicationShutdownBuildItem closeBuildItem, LoggingSetupBuildItem loggingSetupBuildItem, GlobalDevServicesConfig devServicesConfig) {
// if not and the Infinispan containers have already started we just return
if (devServices != null) {
boolean restartRequired = !config.devService.equals(capturedDevServicesConfiguration);
if (!restartRequired) {
return devServices.stream().map(RunningDevService::toBuildItem).collect(Collectors.toList());
}
for (Closeable closeable : devServices) {
try {
closeable.close();
} catch (Throwable e) {
log.error("Failed to stop infinispan container", e);
}
}
devServices = null;
capturedDevServicesConfiguration = null;
}
capturedDevServicesConfiguration = config.devService;
List<RunningDevService> newDevServices = new ArrayList<>();
StartupLogCompressor compressor = new StartupLogCompressor((launchMode.isTest() ? "(test) " : "") + "Infinispan Dev Services Starting:", consoleInstalledBuildItem, loggingSetupBuildItem);
try {
RunningDevService devService = startContainer(dockerStatusBuildItem, config.devService.devservices, launchMode.getLaunchMode(), !devServicesSharedNetworkBuildItem.isEmpty(), devServicesConfig.timeout);
if (devService == null) {
compressor.closeAndDumpCaptured();
return null;
}
newDevServices.add(devService);
log.infof("The infinispan server is ready to accept connections on %s", devService.getConfig().get(getConfigPrefix() + "server-list"));
compressor.close();
} catch (Throwable t) {
compressor.closeAndDumpCaptured();
throw new RuntimeException(t);
}
devServices = newDevServices;
if (first) {
first = false;
Runnable closeTask = () -> {
if (devServices != null) {
for (Closeable closeable : devServices) {
try {
closeable.close();
} catch (Throwable t) {
log.error("Failed to stop infinispan", t);
}
}
}
first = true;
devServices = null;
capturedDevServicesConfiguration = null;
};
closeBuildItem.addCloseTask(closeTask, true);
}
return devServices.stream().map(RunningDevService::toBuildItem).collect(Collectors.toList());
}
use of io.quarkus.deployment.console.StartupLogCompressor in project quarkus by quarkusio.
the class DevServicesKafkaProcessor method startKafkaDevService.
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class)
public DevServicesResultBuildItem startKafkaDevService(DockerStatusBuildItem dockerStatusBuildItem, LaunchModeBuildItem launchMode, KafkaBuildTimeConfig kafkaClientBuildTimeConfig, List<DevServicesSharedNetworkBuildItem> devServicesSharedNetworkBuildItem, Optional<ConsoleInstalledBuildItem> consoleInstalledBuildItem, CuratedApplicationShutdownBuildItem closeBuildItem, LoggingSetupBuildItem loggingSetupBuildItem, GlobalDevServicesConfig devServicesConfig) {
KafkaDevServiceCfg configuration = getConfiguration(kafkaClientBuildTimeConfig);
if (devService != null) {
boolean shouldShutdownTheBroker = !configuration.equals(cfg);
if (!shouldShutdownTheBroker) {
return devService.toBuildItem();
}
shutdownBroker();
cfg = null;
}
StartupLogCompressor compressor = new StartupLogCompressor((launchMode.isTest() ? "(test) " : "") + "Kafka Dev Services Starting:", consoleInstalledBuildItem, loggingSetupBuildItem);
try {
devService = startKafka(dockerStatusBuildItem, configuration, launchMode, !devServicesSharedNetworkBuildItem.isEmpty(), devServicesConfig.timeout);
if (devService == null) {
compressor.closeAndDumpCaptured();
} else {
compressor.close();
}
} catch (Throwable t) {
compressor.closeAndDumpCaptured();
throw new RuntimeException(t);
}
if (devService == null) {
return null;
}
// Configure the watch dog
if (first) {
first = false;
Runnable closeTask = () -> {
if (devService != null) {
shutdownBroker();
}
first = true;
devService = null;
cfg = null;
};
closeBuildItem.addCloseTask(closeTask, true);
}
cfg = configuration;
if (devService.isOwner()) {
log.infof("Dev Services for Kafka started. Other Quarkus applications in dev mode will find the " + "broker automatically. For Quarkus applications in production mode, you can connect to" + " this by starting your application with -Dkafka.bootstrap.servers=%s", getKafkaBootstrapServers());
}
createTopicPartitions(getKafkaBootstrapServers(), configuration);
return devService.toBuildItem();
}
use of io.quarkus.deployment.console.StartupLogCompressor in project quarkus by quarkusio.
the class DevServicesMongoProcessor method startMongo.
@BuildStep(onlyIfNot = IsNormal.class, onlyIf = GlobalDevServicesConfig.Enabled.class)
public List<DevServicesResultBuildItem> startMongo(List<MongoConnectionNameBuildItem> mongoConnections, DockerStatusBuildItem dockerStatusBuildItem, MongoClientBuildTimeConfig mongoClientBuildTimeConfig, List<DevServicesSharedNetworkBuildItem> devServicesSharedNetworkBuildItem, Optional<ConsoleInstalledBuildItem> consoleInstalledBuildItem, CuratedApplicationShutdownBuildItem closeBuildItem, LaunchModeBuildItem launchMode, LoggingSetupBuildItem loggingSetupBuildItem, GlobalDevServicesConfig globalDevServicesConfig) {
List<String> connectionNames = new ArrayList<>(mongoConnections.size());
for (MongoConnectionNameBuildItem mongoConnection : mongoConnections) {
connectionNames.add(mongoConnection.getName());
}
// TODO: handle named connections as well
if (connectionNames.size() != 1) {
return null;
}
if (!isDefault(connectionNames.get(0))) {
return null;
}
Map<String, CapturedProperties> currentCapturedProperties = captureProperties(connectionNames, mongoClientBuildTimeConfig);
// if not and the DB's have already started we just return
if (devServices != null) {
boolean restartRequired = !currentCapturedProperties.equals(capturedProperties);
if (!restartRequired) {
return devServices.stream().map(RunningDevService::toBuildItem).collect(Collectors.toList());
}
for (Closeable i : devServices) {
try {
i.close();
} catch (Throwable e) {
log.error("Failed to stop database", e);
}
}
devServices = null;
capturedProperties = null;
}
List<RunningDevService> newDevServices = new ArrayList<>(mongoConnections.size());
// TODO: we need to go through each connection
String connectionName = connectionNames.get(0);
RunningDevService devService;
StartupLogCompressor compressor = new StartupLogCompressor((launchMode.isTest() ? "(test) " : "") + "Mongo Dev Services Starting:", consoleInstalledBuildItem, loggingSetupBuildItem);
try {
devService = startMongo(dockerStatusBuildItem, connectionName, currentCapturedProperties.get(connectionName), !devServicesSharedNetworkBuildItem.isEmpty(), globalDevServicesConfig.timeout);
if (devService == null) {
compressor.closeAndDumpCaptured();
} else {
compressor.close();
}
} catch (Throwable t) {
compressor.closeAndDumpCaptured();
throw new RuntimeException(t);
}
if (devService != null) {
newDevServices.add(devService);
}
if (first) {
first = false;
Runnable closeTask = new Runnable() {
@Override
public void run() {
if (devServices != null) {
for (Closeable i : devServices) {
try {
i.close();
} catch (Throwable t) {
log.error("Failed to stop database", t);
}
}
}
first = true;
devServices = null;
capturedProperties = null;
}
};
closeBuildItem.addCloseTask(closeTask, true);
}
devServices = newDevServices;
capturedProperties = currentCapturedProperties;
return devServices.stream().map(RunningDevService::toBuildItem).collect(Collectors.toList());
}
Aggregations