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

Release #4

Merged
merged 7 commits into from
Dec 6, 2023
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
31 changes: 24 additions & 7 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Java CI with Maven

on:
push:
branches: [ main ]
branches: [ main, release ]
pull_request:
branches: [ main ]
branches: [ main, release ]

jobs:
build:
Expand All @@ -22,11 +22,6 @@ jobs:
java-version: '8'
distribution: 'adopt'
cache: maven
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Build with Maven
run: mvn -B install -DskipTests --file pom.xml
- name: Checkstyle with Maven
Expand All @@ -35,10 +30,32 @@ jobs:
run: mvn spotbugs:check --file pom.xml
- name: Unit Test with Maven
run: mvn test --file pom.xml

deploy:
if: github.ref == 'refs/heads/main'
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: maven
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Deploy with Maven
run: mvn -B clean deploy -DskipTests -Pci-cd

env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}


16 changes: 12 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@
<url>http://maven.apache.org</url>
<description>Workflow - A Distributed Dag Processing Library</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.7.18</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<jackson.version>2.13.4</jackson.version>
<jgrapht.version>1.3.1</jgrapht.version>
<lombok.version>1.18.24</lombok.version>
<slf4j.version>2.0.1</slf4j.version>

<!-- TEST props -->
<junit.version>4.13.2</junit.version>
<test.containers.version>1.17.3</test.containers.version>
<test.containers.version>1.19.3</test.containers.version>

<!-- PlugIns version -->
<maven-site-plugin>3.12.1</maven-site-plugin>
Expand All @@ -35,6 +38,8 @@
<spotbugs.version>4.7.0</spotbugs.version>
<checkstyle.version>9.3</checkstyle.version>
<doxia.module.apt.version>2.0.0-M3</doxia.module.apt.version>

<!-- impl dependency versions -->
</properties>

<dependencies>
Expand Down Expand Up @@ -255,5 +260,8 @@
<module>workflow-api</module>
<module>workflow-jedis</module>
<module>workflow-examples</module>
<module>workflow-jdbc</module>
<module>workflow-mongodb</module>
<module>workflow-inmemory</module>
</modules>
</project>
2 changes: 0 additions & 2 deletions workflow-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.jgrapht</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
public abstract class BaseAdapter implements Adapter {

protected final String namespace;

/**
* delay generator can have use according to type of adapter.
* eg. poll delay for queue and scheduler.
* heartbeat for persistence adapter.
*/
protected final PollDelayGenerator pollDelayGenerator;
protected final Serde serde;

}
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
package io.github.pavansharma36.workflow.api.adapter.base;

import io.github.pavansharma36.workflow.api.adapter.PersistenceAdapter;
import io.github.pavansharma36.workflow.api.adapter.WorkflowAdapter;
import io.github.pavansharma36.workflow.api.model.ManagerInfo;
import io.github.pavansharma36.workflow.api.serde.Deserializer;
import io.github.pavansharma36.workflow.api.serde.Serde;
import io.github.pavansharma36.workflow.api.serde.Serializer;
import io.github.pavansharma36.workflow.api.util.PollDelayGenerator;
import java.util.Date;
import java.util.List;
import lombok.extern.slf4j.Slf4j;

/**
* Base class for all {@link PersistenceAdapter}.
*/
@Slf4j
public abstract class BasePersistenceAdapter extends BaseAdapter implements PersistenceAdapter {

protected final Serializer serializer;
protected final Deserializer deserializer;

protected BasePersistenceAdapter(String namespace,
PollDelayGenerator pollDelayGenerator,
Serde serde) {
super(namespace, pollDelayGenerator, serde);
this.serializer = serde.serializer();
this.deserializer = serde.deserializer();
PollDelayGenerator heartbeatDelayGenerator) {
super(namespace, heartbeatDelayGenerator);
}

@Override
public void maintenance(WorkflowAdapter adapter) {
List<ManagerInfo> managerInfos = getAllManagerInfos();
long minHeartbeatTimestamp = System.currentTimeMillis()
- (heartbeatDelayGenerator().delay(false).toMillis() * 15);
managerInfos.forEach(m -> {
if (m.getHeartbeatEpoch() < minHeartbeatTimestamp) {
log.info("WorkflowManager's heartbeat is not updated since {}, purging",
new Date(m.getHeartbeatEpoch()));
removeManagerInfo(m.getManagerId());
}
});
}

@Override
public PollDelayGenerator heartbeatDelayGenerator() {
return pollDelayGenerator;
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.github.pavansharma36.workflow.api.adapter.builder;

import io.github.pavansharma36.workflow.api.adapter.PersistenceAdapter;
import io.github.pavansharma36.workflow.api.util.PollDelayGenerator;

public abstract class BasePersistenceAdapterBuilder<T extends BasePersistenceAdapterBuilder<T>>
extends BaseAdapterBuilder<T, PersistenceAdapter> {

public T withHeartbeatDelayGenerator(PollDelayGenerator heartbeatDelayGenerator) {
this.pollDelayGenerator = heartbeatDelayGenerator;
return (T) this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public abstract class BaseScheduleAdapterBuilder<S extends BaseScheduleAdapterBu
Duration.ofHours(1L));
protected Duration maxRunDuration = Duration.ofDays(7L);

public BaseScheduleAdapterBuilder<S> withMaintenanceDelayGenerator(
public S withMaintenanceDelayGenerator(
@NonNull final PollDelayGenerator maintenanceDelayGenerator) {
this.maintenanceDelayGenerator = maintenanceDelayGenerator;
return this;
return (S) this;
}

public BaseScheduleAdapterBuilder<S> maxRunDuration(@NonNull Duration maxRunDuration) {
public S maxRunDuration(@NonNull Duration maxRunDuration) {
this.maxRunDuration = maxRunDuration;
return this;
return (S) this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,66 @@
/**
* Base class for all adapter builder.
*/
public class WorkflowAdapterBuilder<S extends WorkflowAdapterBuilder<S, S1, S2, S3>,
S1 extends BaseScheduleAdapterBuilder<S1>,
S2 extends BaseAdapterBuilder<S2, PersistenceAdapter>,
S3 extends BaseAdapterBuilder<S3, QueueAdapter>> {
public class WorkflowAdapterBuilder {

protected S1 scheduleAdapterBuilder;
protected S2 persistenceAdapterBuilder;
protected S3 queueAdapterBuilder;
protected BaseScheduleAdapterBuilder<?> scheduleAdapterBuilder;
protected BasePersistenceAdapterBuilder<?> persistenceAdapterBuilder;
protected BaseAdapterBuilder<?, ? extends QueueAdapter> queueAdapterBuilder;

public WorkflowAdapterBuilder<S, S1, S2, S3> withQueuePollDelayGenerator(
public WorkflowAdapterBuilder withQueuePollDelayGenerator(
final PollDelayGenerator pollDelayGenerator) {
this.queueAdapterBuilder.withPollDelayGenerator(pollDelayGenerator);
return this;
}

public WorkflowAdapterBuilder<S, S1, S2, S3> withSchedulePollDelayGenerator(
public WorkflowAdapterBuilder withSchedulePollDelayGenerator(
final PollDelayGenerator pollDelayGenerator) {
this.scheduleAdapterBuilder.withPollDelayGenerator(pollDelayGenerator);
return this;
}

public WorkflowAdapterBuilder<S, S1, S2, S3> withMaintenancePollDelayGenerator(
public WorkflowAdapterBuilder withHeartbeatDelayGenerator(PollDelayGenerator heartbeatDelayGenerator) {
this.persistenceAdapterBuilder.withHeartbeatDelayGenerator(heartbeatDelayGenerator);
return this;
}

public WorkflowAdapterBuilder withMaintenancePollDelayGenerator(
final PollDelayGenerator pollDelayGenerator
) {
this.scheduleAdapterBuilder.withMaintenanceDelayGenerator(pollDelayGenerator);
return this;
}

public WorkflowAdapterBuilder<S, S1, S2, S3> withMaxRunDuration(Duration duration) {
public WorkflowAdapterBuilder withMaxRunDuration(Duration duration) {
this.scheduleAdapterBuilder.maxRunDuration(duration);
return this;
}

public WorkflowAdapterBuilder withScheduleAdapterBuilder(BaseScheduleAdapterBuilder<?> scheduleAdapterBuilder) {
this.scheduleAdapterBuilder = scheduleAdapterBuilder;
return this;
}

public WorkflowAdapterBuilder withPersistenceAdapterBuilder(BasePersistenceAdapterBuilder<?> persistenceAdapterBuilder) {
this.persistenceAdapterBuilder = persistenceAdapterBuilder;
return this;
}

public WorkflowAdapterBuilder withQueueAdapterBuilder(BaseAdapterBuilder<?, ? extends QueueAdapter> queueAdapterBuilder) {
this.queueAdapterBuilder = queueAdapterBuilder;
return this;
}

/**
* build {@link WorkflowAdapter}.
*
* @return - instance of workflowadaper.
*/
public WorkflowAdapter build() {
scheduleAdapterBuilder.validate();
queueAdapterBuilder.validate();
persistenceAdapterBuilder.validate();

return new WorkflowAdapterImpl(scheduleAdapterBuilder.build(),
queueAdapterBuilder.build(),
persistenceAdapterBuilder.build());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.pavansharma36.workflow.api.bean.id;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.github.pavansharma36.workflow.api.serde.IdSerializer;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -12,6 +14,7 @@
@ToString
@EqualsAndHashCode
@AllArgsConstructor
@JsonSerialize(using = IdSerializer.class)
public class Id {
/**
* string representation of this id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ public class ManagerId extends Id {
public ManagerId() {
super(Utils.random());
}

public ManagerId(String id) {
super(id);
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package io.github.pavansharma36.workflow.api.bean.task;

import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;

/**
* Task type to differentiate queue and executor for submitted tasks.
*/
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
public class TaskType {
private int version = 1;
private @NonNull String type;
Expand Down
Loading
Loading