Skip to content

Commit

Permalink
Merge pull request #758 from nitram509/feature/formatting
Browse files Browse the repository at this point in the history
reformat code and add hint for formatter
  • Loading branch information
nitram509 authored Dec 27, 2024
2 parents b28deec + 0e9ab84 commit 8cbb51c
Show file tree
Hide file tree
Showing 67 changed files with 530 additions and 408 deletions.
14 changes: 14 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

### PR Description

*please, provide some context about the PR - e.g. try to answer these questions...*
- what problem you try to solve?
- what reasoning you had with this implementation? what alternative approaches exists? what are possible downsides?
- how have you tested your implementation?

### Before creating a PR, please ensure...

- [ ] the code is proper formatted (e.g. running `mvn com.spotify.fmt:fmt-maven-plugin:2.25:format`)
- [ ] your code contribution contains new unit tests (if applicable)
- [ ] the tests are alle 'green'
- [ ] the documentation is updated (if applicable)
12 changes: 9 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,18 @@ Build the JAR files with
mvn clean install
```

## Styleguides
## Styleguide

### Source Code

The Java code should be formatted using [Google's Java Format](https://github.com/google/google-java-format).

For re-formatting, you can use plugins in your code editor, or just run

```shell
mvn com.spotify.fmt:fmt-maven-plugin:2.25:format
```

### Git Commit Messages

Commit messages should follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) format.
Expand Down Expand Up @@ -86,8 +92,8 @@ Available commit types:

There's a file [docker-compose.yml](docker/docker-compose.yml) prepared in this repo, which can be used with recent Docker version to
provide a backend. You just need to choose some profiles and specify them in a file [.env](docker/.env) using pattern `COMPOSE_PROFILES=profile1,profile2`:
* ```hazelcast``` runs Zeebe broker with Hazelcast exporter
* ```kafka``` runs Zeebe broker with Kafka exporter
* ```hazelcast``` runs Zeebe broker with Hazelcast exporter
* ```kafka``` runs Zeebe broker with Kafka exporter
* ```postgres``` runs PostgreSQL database
* ```mysql``` runs MySQL database

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/zeebe/monitor/config/KafkaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public <M> ConcurrentKafkaListenerContainerFactory<String, M> kafkaListenerConta
factory.setBatchListener(true);
factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.BATCH);

// Any exception thrown from record of the batch will skip(NotRetryableExceptions) or retry the entire batch
// Any exception thrown from record of the batch will skip(NotRetryableExceptions) or retry the
// entire batch
var errorHandler =
new DefaultErrorHandler(
(record, e) ->
Expand Down
60 changes: 30 additions & 30 deletions src/main/java/io/zeebe/monitor/config/RedisConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,45 @@
@Configuration
public class RedisConfig {

@Value("${zeebe.client.worker.redis.connection}")
private String redisConnection;
@Value("${zeebe.client.worker.redis.connection}")
private String redisConnection;

@Value("${zeebe.client.worker.redis.useClusterClient:false}")
private boolean useClusterClient;
@Value("${zeebe.client.worker.redis.useClusterClient:false}")
private boolean useClusterClient;

@Value("${zeebe.client.worker.redis.consumer-group:simple-monitor}")
private String redisConumerGroup;
@Value("${zeebe.client.worker.redis.consumer-group:simple-monitor}")
private String redisConumerGroup;

@Value("${zeebe.client.worker.redis.xread-count:500}")
private int redisXreadCount;
@Value("${zeebe.client.worker.redis.xread-count:500}")
private int redisXreadCount;

@Value("${zeebe.client.worker.redis.xread-block-millis:2000}")
private int redisXreadBlockMillis;
@Value("${zeebe.client.worker.redis.xread-block-millis:2000}")
private int redisXreadBlockMillis;

@Value("${zeebe.client.worker.redis.prefix:zeebe}")
private String redisPrefix;
@Value("${zeebe.client.worker.redis.prefix:zeebe}")
private String redisPrefix;

public String getRedisConnection() {
return redisConnection;
}
public String getRedisConnection() {
return redisConnection;
}

public boolean isUseClusterClient() {
return useClusterClient;
}
public boolean isUseClusterClient() {
return useClusterClient;
}

public String getRedisConumerGroup() {
return redisConumerGroup;
}
public String getRedisConumerGroup() {
return redisConumerGroup;
}

public int getRedisXreadCount() {
return redisXreadCount;
}
public int getRedisXreadCount() {
return redisXreadCount;
}

public int getRedisXreadBlockMillis() {
return redisXreadBlockMillis;
}
public int getRedisXreadBlockMillis() {
return redisXreadBlockMillis;
}

public String getRedisPrefix() {
return redisPrefix;
}
public String getRedisPrefix() {
return redisPrefix;
}
}
17 changes: 11 additions & 6 deletions src/main/java/io/zeebe/monitor/entity/ElementInstanceEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
import jakarta.persistence.*;

@Entity(name = "ELEMENT_INSTANCE")
@Table(indexes = {
@Index(name = "element_instance_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"),
@Index(name = "element_instance_processDefinitionKeyIndex", columnList = "PROCESS_DEFINITION_KEY_"),
@Index(name = "element_instance_intentIndex", columnList = "INTENT_"),
@Index(name = "element_instance_bpmnElementTypeIndex", columnList = "BPMN_ELEMENT_TYPE_"),
})
@Table(
indexes = {
@Index(
name = "element_instance_processInstanceKeyIndex",
columnList = "PROCESS_INSTANCE_KEY_"),
@Index(
name = "element_instance_processDefinitionKeyIndex",
columnList = "PROCESS_DEFINITION_KEY_"),
@Index(name = "element_instance_intentIndex", columnList = "INTENT_"),
@Index(name = "element_instance_bpmnElementTypeIndex", columnList = "BPMN_ELEMENT_TYPE_"),
})
public class ElementInstanceEntity {

@Id
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/io/zeebe/monitor/entity/ErrorEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
import org.hibernate.Length;

@Entity(name = "ERROR")
@Table(indexes = {
// performance reason, because we use it in the
// {@link io.zeebe.monitor.repository.ErrorRepository#findByProcessInstanceKey(long)}
@Index(name = "error_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"),
})
@Table(
indexes = {
// performance reason, because we use it in the
// {@link io.zeebe.monitor.repository.ErrorRepository#findByProcessInstanceKey(long)}
@Index(name = "error_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"),
})
public class ErrorEntity {

@Id
Expand All @@ -36,11 +37,11 @@ public class ErrorEntity {
@Column(name = "PROCESS_INSTANCE_KEY_")
private long processInstanceKey;

@Column(name = "EXCEPTION_MESSAGE_",length= Length.LONG16)
@Column(name = "EXCEPTION_MESSAGE_", length = Length.LONG16)
@Lob
private String exceptionMessage;

@Column(name = "STACKTRACE_",length= Length.LONG16)
@Column(name = "STACKTRACE_", length = Length.LONG16)
@Lob
private String stacktrace;

Expand Down
13 changes: 7 additions & 6 deletions src/main/java/io/zeebe/monitor/entity/IncidentEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
import org.hibernate.Length;

@Entity(name = "INCIDENT")
@Table(indexes = {
// performance reason, because we use it in the
// {@link io.zeebe.monitor.repository.IncidentRepository#findByProcessInstanceKey(long)}
@Index(name = "incident_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"),
})
@Table(
indexes = {
// performance reason, because we use it in the
// {@link io.zeebe.monitor.repository.IncidentRepository#findByProcessInstanceKey(long)}
@Index(name = "incident_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"),
})
public class IncidentEntity {

@Id
Expand All @@ -48,7 +49,7 @@ public class IncidentEntity {
@Column(name = "ERROR_TYPE_")
private String errorType;

@Column(name = "ERROR_MSG_",length= Length.LONG16)
@Column(name = "ERROR_MSG_", length = Length.LONG16)
@Lob
private String errorMessage;

Expand Down
11 changes: 6 additions & 5 deletions src/main/java/io/zeebe/monitor/entity/JobEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
import jakarta.persistence.*;

@Entity(name = "JOB")
@Table(indexes = {
// performance reason, because we use it in the
// {@link io.zeebe.monitor.repository.JobRepository#findByProcessInstanceKey(long)}
@Index(name = "job_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"),
})
@Table(
indexes = {
// performance reason, because we use it in the
// {@link io.zeebe.monitor.repository.JobRepository#findByProcessInstanceKey(long)}
@Index(name = "job_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"),
})
public class JobEntity {

@Id
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/zeebe/monitor/entity/MessageEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class MessageEntity {
@Column(name = "MESSAGE_ID_")
private String messageId;

@Column(name = "PAYLOAD_",length= Length.LONG32)
@Column(name = "PAYLOAD_", length = Length.LONG32)
@Lob
private String payload;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
import jakarta.persistence.*;

@Entity(name = "MESSAGE_SUBSCRIPTION")
@Table(indexes = {
// performance reason, because we use it in the
// {@link io.zeebe.monitor.repository.MessageSubscriptionRepository#findByProcessInstanceKey(long)}
@Index(name = "message_subscription_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"),
})
@Table(
indexes = {
// performance reason, because we use it in the
// {@link
// io.zeebe.monitor.repository.MessageSubscriptionRepository#findByProcessInstanceKey(long)}
@Index(
name = "message_subscription_processInstanceKeyIndex",
columnList = "PROCESS_INSTANCE_KEY_"),
})
public class MessageSubscriptionEntity {

@Id
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/io/zeebe/monitor/entity/ProcessEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
import org.hibernate.Length;

@Entity(name = "PROCESS")
@Table(indexes = {
@Index(name = "process_bpmnProcessId", columnList = "BPMN_PROCESS_ID_"),
})
@Table(
indexes = {
@Index(name = "process_bpmnProcessId", columnList = "BPMN_PROCESS_ID_"),
})
public class ProcessEntity {
@Id
@Column(name = "KEY_")
Expand All @@ -34,7 +35,7 @@ public class ProcessEntity {
private int version;

@Lob
@Column(name = "RESOURCE_",length= Length.LONG32)
@Column(name = "RESOURCE_", length = Length.LONG32)
private String resource;

@Column(name = "TIMESTAMP_")
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/io/zeebe/monitor/entity/TimerEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
import jakarta.persistence.*;

@Entity(name = "TIMER")
@Table(indexes = {
// performance reason, because we use it in the
// {@link io.zeebe.monitor.repository.TimerRepository#findByProcessInstanceKey(long)}
@Index(name = "timer_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"),
})
@Table(
indexes = {
// performance reason, because we use it in the
// {@link io.zeebe.monitor.repository.TimerRepository#findByProcessInstanceKey(long)}
@Index(name = "timer_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"),
})
public class TimerEntity {

@Id
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/io/zeebe/monitor/entity/VariableEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import org.hibernate.Length;

@Entity(name = "VARIABLE")
@Table(indexes = {
// performance reason, because we use it in the VariableRepository.findByProcessInstanceKey()
@Index(name = "variable_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"),
})
@Table(
indexes = {
// performance reason, because we use it in the VariableRepository.findByProcessInstanceKey()
@Index(name = "variable_processInstanceKeyIndex", columnList = "PROCESS_INSTANCE_KEY_"),
})
public class VariableEntity {

@Id
Expand All @@ -38,7 +39,7 @@ public class VariableEntity {
@Column(name = "NAME_")
private String name;

@Column(name = "VALUE_",length= Length.LONG32)
@Column(name = "VALUE_", length = Length.LONG32)
@Lob
private String value;

Expand Down Expand Up @@ -68,7 +69,7 @@ public final String getGeneratedIdentifier() {
}

@PrePersist
private void prePersistDeriveIdField(){
private void prePersistDeriveIdField() {
setId(getGeneratedIdentifier());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package io.zeebe.monitor.querydsl;

import static org.apache.commons.lang3.StringUtils.isEmpty;

import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.Expressions;
import com.querydsl.core.types.dsl.PathBuilder;
import io.zeebe.monitor.entity.QIncidentEntity;

import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
Expand All @@ -14,10 +15,9 @@
import java.util.List;
import java.util.Optional;

import static org.apache.commons.lang3.StringUtils.isEmpty;

public class IncidentEntityPredicatesBuilder {
final PathBuilder<QIncidentEntity> pathBuilder = new PathBuilder<>(QIncidentEntity.class, QIncidentEntity.incidentEntity.getMetadata());
final PathBuilder<QIncidentEntity> pathBuilder =
new PathBuilder<>(QIncidentEntity.class, QIncidentEntity.incidentEntity.getMetadata());
private final List<Predicate> predicates = new ArrayList<>();

public IncidentEntityPredicatesBuilder onlyUnresolved() {
Expand All @@ -42,15 +42,17 @@ public IncidentEntityPredicatesBuilder withErrorType(String errorType) {
public IncidentEntityPredicatesBuilder createdAfter(String timestamp) {
if (!isEmpty(timestamp)) {
final Optional<Long> created = parseIsoToUtcMillis(timestamp);
created.ifPresent(utcMillis -> predicates.add(pathBuilder.getNumber("created", Long.class).goe(utcMillis)));
created.ifPresent(
utcMillis -> predicates.add(pathBuilder.getNumber("created", Long.class).goe(utcMillis)));
}
return this;
}

public IncidentEntityPredicatesBuilder createdBefore(String timestamp) {
if (!isEmpty(timestamp)) {
final Optional<Long> created = parseIsoToUtcMillis(timestamp);
created.ifPresent(utcMillis -> predicates.add(pathBuilder.getNumber("created", Long.class).loe(utcMillis)));
created.ifPresent(
utcMillis -> predicates.add(pathBuilder.getNumber("created", Long.class).loe(utcMillis)));
}
return this;
}
Expand All @@ -65,8 +67,10 @@ public Predicate build() {

private Optional<Long> parseIsoToUtcMillis(String timestamp) {
try {
final ZonedDateTime zonedDateTime = ZonedDateTime.from(DateTimeFormatter.ISO_DATE_TIME.parse(timestamp));
final long utcMillis = zonedDateTime.withZoneSameInstant(ZoneId.of("UTC")).toInstant().toEpochMilli();
final ZonedDateTime zonedDateTime =
ZonedDateTime.from(DateTimeFormatter.ISO_DATE_TIME.parse(timestamp));
final long utcMillis =
zonedDateTime.withZoneSameInstant(ZoneId.of("UTC")).toInstant().toEpochMilli();
return Optional.of(utcMillis);
} catch (DateTimeParseException ignore) {
// ignore
Expand Down
Loading

0 comments on commit 8cbb51c

Please sign in to comment.