-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(agama): deploy flows from .gama files (#3250)
* feat: add timer for deployment/undeployment of ADS projects #3052 * feat: add data object class for an ADS deployment #3052 * chore: remove TODOs #3052
- Loading branch information
1 parent
8f72ea6
commit df14f8a
Showing
8 changed files
with
765 additions
and
1 deletion.
There are no files selected for viewing
555 changes: 555 additions & 0 deletions
555
jans-auth-server/agama/engine/src/main/java/io/jans/ads/Deployer.java
Large diffs are not rendered by default.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
jans-auth-server/agama/engine/src/main/java/io/jans/ads/timer/DeployerTimer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package io.jans.ads.timer; | ||
|
||
import io.jans.ads.Deployer; | ||
import io.jans.agama.engine.misc.FlowUtils; | ||
import io.jans.service.cdi.async.Asynchronous; | ||
import io.jans.service.cdi.event.Scheduled; | ||
import io.jans.service.timer.event.TimerEvent; | ||
import io.jans.service.timer.schedule.TimerSchedule; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.event.Event; | ||
import jakarta.enterprise.event.Observes; | ||
import jakarta.inject.Inject; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import org.slf4j.Logger; | ||
|
||
@ApplicationScoped | ||
public class DeployerTimer { | ||
|
||
@Inject | ||
private Deployer deployer; | ||
|
||
@Inject | ||
private Logger logger; | ||
|
||
@Inject | ||
private Event<TimerEvent> timerEvent; | ||
|
||
@Inject | ||
private FlowUtils futils; | ||
|
||
private AtomicBoolean isActive; | ||
|
||
private static final int DELAY = 5 + (int) (10 * Math.random()); //seconds | ||
private static final int INTERVAL = 30; // seconds | ||
|
||
public void initTimer() { | ||
|
||
logger.info("Initializing Agama transpilation Timer"); | ||
isActive = new AtomicBoolean(false); | ||
timerEvent.fire(new TimerEvent(new TimerSchedule(DELAY, INTERVAL), | ||
new DeploymentEvent(), Scheduled.Literal.INSTANCE)); | ||
|
||
} | ||
|
||
@Asynchronous | ||
public void run(@Observes @Scheduled DeploymentEvent event) { | ||
|
||
if (!futils.serviceEnabled()) return; | ||
|
||
if (isActive.get()) return; | ||
|
||
if (!isActive.compareAndSet(false, true)) return; | ||
|
||
try { | ||
deployer.process(); | ||
logger.debug("ADS deployer timer has run."); | ||
} catch (Exception e) { | ||
logger.error("An error occurred while running ADS deployer timer", e); | ||
} finally { | ||
isActive.set(false); | ||
} | ||
|
||
} | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
jans-auth-server/agama/engine/src/main/java/io/jans/ads/timer/DeploymentEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package io.jans.ads.timer; | ||
|
||
public class DeploymentEvent { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
jans-auth-server/agama/model/src/main/java/io/jans/ads/model/Deployment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package io.jans.ads.model; | ||
|
||
import io.jans.orm.annotation.AttributeName; | ||
import io.jans.orm.annotation.DataEntry; | ||
import io.jans.orm.annotation.JsonObject; | ||
import io.jans.orm.annotation.ObjectClass; | ||
import io.jans.orm.model.base.Entry; | ||
|
||
import java.util.Date; | ||
|
||
@DataEntry | ||
@ObjectClass(value = "adsPrjDeployment") | ||
public class Deployment extends Entry { | ||
|
||
public static final String ASSETS_ATTR = "adsPrjAssets"; | ||
|
||
@AttributeName(name = "jansId") | ||
private String id; | ||
|
||
@AttributeName(name = "jansStartDate") | ||
private Date createdAt; | ||
|
||
@AttributeName(name = "jansActive") | ||
private boolean taskActive; | ||
|
||
@AttributeName(name = "jansEndDate") | ||
private Date finishedAt; | ||
|
||
@AttributeName(name = Deployment.ASSETS_ATTR) | ||
private String assets; | ||
|
||
@JsonObject | ||
@AttributeName(name = "adsPrjDeplDetails") | ||
private DeploymentDetails details; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public Date getCreatedAt() { | ||
return createdAt; | ||
} | ||
|
||
public void setCreatedAt(Date createdAt) { | ||
this.createdAt = createdAt; | ||
} | ||
|
||
public boolean isTaskActive() { | ||
return taskActive; | ||
} | ||
|
||
public void setTaskActive(boolean taskActive) { | ||
this.taskActive = taskActive; | ||
} | ||
|
||
public Date getFinishedAt() { | ||
return finishedAt; | ||
} | ||
|
||
public void setFinishedAt(Date finishedAt) { | ||
this.finishedAt = finishedAt; | ||
} | ||
|
||
public String getAssets() { | ||
return assets; | ||
} | ||
|
||
public void setAssets(String assets) { | ||
this.assets = assets; | ||
} | ||
|
||
public DeploymentDetails getDetails() { | ||
return details; | ||
} | ||
|
||
public void setDetails(DeploymentDetails details) { | ||
this.details = details; | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
jans-auth-server/agama/model/src/main/java/io/jans/ads/model/DeploymentDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.jans.ads.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class DeploymentDetails { | ||
|
||
private String projectName; | ||
private List<String> folders; | ||
private Map<String, String> flowsError; | ||
private String error; | ||
|
||
public String getProjectName() { | ||
return projectName; | ||
} | ||
|
||
public void setProjectName(String projectName) { | ||
this.projectName = projectName; | ||
} | ||
|
||
public List<String> getFolders() { | ||
return folders; | ||
} | ||
|
||
public void setFolders(List<String> folders) { | ||
this.folders = folders; | ||
} | ||
|
||
public String getError() { | ||
return error; | ||
} | ||
|
||
public void setError(String error) { | ||
this.error = error; | ||
} | ||
|
||
public Map<String, String> getFlowsError() { | ||
return flowsError; | ||
} | ||
|
||
public void setFlowsError(Map<String, String> flowsError) { | ||
this.flowsError = flowsError; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
org.quartz.scheduler.instanceName=Jans AuthScheduler | ||
org.quartz.threadPool.threadCount=6 | ||
org.quartz.threadPool.threadCount=8 | ||
org.quartz.jobStore.class=org.quartz.simpl.RAMJobStore | ||
org.quartz.scheduler.skipUpdateCheck=true |