Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checkstyle configuration for four more modules #874

Merged
merged 5 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion streampipes-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
~
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.streampipes</groupId>
Expand Down Expand Up @@ -134,6 +135,10 @@
</environmentVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
</plugins>
<finalName>streampipes-backend</finalName>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.streampipes.svcdiscovery.api.model.DefaultSpServiceGroups;
import org.apache.streampipes.svcdiscovery.api.model.DefaultSpServiceTags;
import org.apache.streampipes.svcdiscovery.api.model.SpServiceTag;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
Expand All @@ -43,6 +44,7 @@

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -56,10 +58,10 @@
@Configuration
@EnableAutoConfiguration
@Import({StreamPipesResourceConfig.class,
WelcomePageController.class,
StreamPipesPasswordEncoder.class,
WebSecurityConfig.class,
SpPermissionEvaluator.class
WelcomePageController.class,
StreamPipesPasswordEncoder.class,
WebSecurityConfig.class,
SpPermissionEvaluator.class
})
@ComponentScan({"org.apache.streampipes.rest.*"})
public class StreamPipesBackendApplication extends StreamPipesServiceBase {
Expand All @@ -82,16 +84,18 @@ public class StreamPipesBackendApplication extends StreamPipesServiceBase {
private Map<String, Integer> failedPipelines = new HashMap<>();

public static void main(String[] args) {
StreamPipesBackendApplication application = new StreamPipesBackendApplication();
try {
BaseNetworkingConfig networkingConfig = BaseNetworkingConfig.defaultResolution(8030);
application.startStreamPipesService(StreamPipesBackendApplication.class,
DefaultSpServiceGroups.CORE,
application.serviceId(),
networkingConfig);
} catch (UnknownHostException e) {
LOG.error("Could not auto-resolve host address - please manually provide the hostname using the SP_HOST environment variable");
}
StreamPipesBackendApplication application = new StreamPipesBackendApplication();
try {
BaseNetworkingConfig networkingConfig = BaseNetworkingConfig.defaultResolution(8030);
application.startStreamPipesService(StreamPipesBackendApplication.class,
DefaultSpServiceGroups.CORE,
application.serviceId(),
networkingConfig);
} catch (UnknownHostException e) {
LOG.error(
"Could not auto-resolve host address - please manually provide the hostname"
+ " using the `SP_HOST` environment variable");
}
}

private String serviceId() {
Expand All @@ -116,9 +120,9 @@ public void init() {
executorService.schedule(this::startAllPreviouslyStoppedPipelines, 5, TimeUnit.SECONDS);
LOG.info("Pipeline health check will run every {} seconds", HEALTH_CHECK_INTERVAL);
healthCheckExecutorService.scheduleAtFixedRate(new PipelineHealthCheck(),
HEALTH_CHECK_INTERVAL,
HEALTH_CHECK_INTERVAL,
HEALTH_CHECK_UNIT);
HEALTH_CHECK_INTERVAL,
HEALTH_CHECK_INTERVAL,
HEALTH_CHECK_UNIT);

LOG.info("Extensions logs will be fetched every {} seconds", LOG_FETCH_INTERVAL);
logCheckExecutorService.scheduleAtFixedRate(new ExtensionsServiceLogExecutor(),
Expand Down Expand Up @@ -160,9 +164,9 @@ public void onExit() {
LOG.info("Shutting down StreamPipes...");
LOG.info("Flagging currently running pipelines for restart...");
List<Pipeline> pipelinesToStop = getAllPipelines()
.stream()
.filter(Pipeline::isRunning)
.collect(Collectors.toList());
.stream()
.filter(Pipeline::isRunning)
.collect(Collectors.toList());

LOG.info("Found {} running pipelines which will be stopped...", pipelinesToStop.size());

Expand All @@ -189,9 +193,9 @@ public void onExit() {
private void startAllPreviouslyStoppedPipelines() {
LOG.info("Checking for orphaned pipelines...");
List<Pipeline> orphanedPipelines = getAllPipelines()
.stream()
.filter(Pipeline::isRunning)
.collect(Collectors.toList());
.stream()
.filter(Pipeline::isRunning)
.collect(Collectors.toList());

LOG.info("Found {} orphaned pipelines", orphanedPipelines.size());

Expand All @@ -203,10 +207,10 @@ private void startAllPreviouslyStoppedPipelines() {
LOG.info("Checking for gracefully shut down pipelines to be restarted...");

List<Pipeline> pipelinesToRestart = getAllPipelines()
.stream()
.filter(p -> !(p.isRunning()))
.filter(Pipeline::isRestartOnSystemReboot)
.collect(Collectors.toList());
.stream()
.filter(p -> !(p.isRunning()))
.filter(Pipeline::isRestartOnSystemReboot)
.collect(Collectors.toList());

LOG.info("Found {} pipelines that we are attempting to restart...", pipelinesToRestart.size());

Expand All @@ -229,15 +233,15 @@ private void startPipeline(Pipeline pipeline, boolean restartOnReboot) {
int failedAttemptCount = failedPipelines.get(pipeline.getPipelineId());
if (failedAttemptCount <= MAX_PIPELINE_START_RETRIES) {
LOG.error("Pipeline {} could not be restarted - I'll try again in {} seconds ({}/{} failed attempts)",
pipeline.getName(),
WAIT_TIME_AFTER_FAILURE_IN_SECONDS,
failedAttemptCount,
MAX_PIPELINE_START_RETRIES);
pipeline.getName(),
WAIT_TIME_AFTER_FAILURE_IN_SECONDS,
failedAttemptCount,
MAX_PIPELINE_START_RETRIES);

schedulePipelineStart(pipeline, restartOnReboot);
} else {
LOG.error("Pipeline {} could not be restarted - are all pipeline element containers running?",
status.getPipelineName());
status.getPipelineName());
}
}
}
Expand All @@ -254,23 +258,23 @@ private void storeFailedRestartAttempt(Pipeline pipeline) {

private List<Pipeline> getAllPipelines() {
return getPipelineStorage()
.getAllPipelines();
.getAllPipelines();
}

private IPipelineStorage getPipelineStorage() {
return StorageDispatcher
.INSTANCE
.getNoSqlStore()
.getPipelineStorageAPI();
.INSTANCE
.getNoSqlStore()
.getPipelineStorageAPI();
}


@Override
protected List<SpServiceTag> getServiceTags() {
return Arrays.asList(
DefaultSpServiceTags.CORE,
DefaultSpServiceTags.CONNECT_MASTER,
DefaultSpServiceTags.STREAMPIPES_CLIENT
DefaultSpServiceTags.CORE,
DefaultSpServiceTags.CONNECT_MASTER,
DefaultSpServiceTags.STREAMPIPES_CLIENT
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.streampipes.config.backend.BackendConfig;
import org.apache.streampipes.config.backend.model.JwtSigningMode;
import org.apache.streampipes.config.backend.model.LocalAuthConfig;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -61,15 +62,21 @@ private void updateJwtSettings() {
}

if (!Envs.SP_JWT_SIGNING_MODE.exists()) {
LOG.info("No JWT signing mode provided (using default settings), consult the docs to learn how to provide JWT settings");
LOG.info(
"No JWT signing mode provided (using default settings), "
+ "consult the docs to learn how to provide JWT settings");
} else if (localAuthConfig.getJwtSigningMode() == JwtSigningMode.HMAC && !Envs.SP_JWT_SECRET.exists()) {
LOG.warn("JWT signing mode set to HMAC but no secret provided (falling back to auto-generated secret), provide a {} variable",
Envs.SP_JWT_SECRET.getEnvVariableName());
} else if (localAuthConfig.getJwtSigningMode() == JwtSigningMode.RSA &&
((!Envs.SP_JWT_PUBLIC_KEY_LOC.exists() || !Envs.SP_JWT_PRIVATE_KEY_LOC.exists()) || incompleteConfig)) {
LOG.warn("JWT signing mode set to RSA but no public or private key location provided, do you provide {} and {} variables?",
Envs.SP_JWT_PRIVATE_KEY_LOC.getEnvVariableName(),
Envs.SP_JWT_PUBLIC_KEY_LOC.getEnvVariableName());
LOG.warn(
"JWT signing mode set to HMAC but no secret provided (falling back to auto-generated secret), "
+ "provide a {} variable",
Envs.SP_JWT_SECRET.getEnvVariableName());
} else if (localAuthConfig.getJwtSigningMode() == JwtSigningMode.RSA
&& ((!Envs.SP_JWT_PUBLIC_KEY_LOC.exists() || !Envs.SP_JWT_PRIVATE_KEY_LOC.exists()) || incompleteConfig)) {
LOG.warn(
"JWT signing mode set to RSA but no public or private key location provided, "
+ "do you provide {} and {} variables?",
Envs.SP_JWT_PRIVATE_KEY_LOC.getEnvVariableName(),
Envs.SP_JWT_PUBLIC_KEY_LOC.getEnvVariableName());
}
if (!incompleteConfig) {
LOG.info("Updating local auth config with signing mode {}", localAuthConfig.getJwtSigningMode().name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
package org.apache.streampipes.backend;

import org.apache.streampipes.user.management.authentication.StreamPipesCredentialsMatcher;

import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
public class StreamPipesPasswordEncoder {

@Bean
public PasswordEncoder passwordEncoder() {
return new StreamPipesCredentialsMatcher();
}
@Bean
public PasswordEncoder passwordEncoder() {
return new StreamPipesCredentialsMatcher();
}
}
Loading