Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ejercicio2-framework-back
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Josue
ejercicio2-framework-back
Commits
2425b67e
Commit
2425b67e
authored
Jan 19, 2022
by
Roberto Loayza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update ScheduleService y application.yml
parent
836b9b9c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
10 deletions
+56
-10
ScheduleService.java
...com/bytesw/bytebot/etl/batch/service/ScheduleService.java
+50
-6
application.yml
src/main/resources/application.yml
+6
-4
No files found.
src/main/java/com/bytesw/bytebot/etl/batch/service/ScheduleService.java
View file @
2425b67e
...
...
@@ -25,6 +25,7 @@ import com.bytesw.bytebot.model.enums.FrequencyType;
import
com.bytesw.bytebot.model.enums.ProcessETLEnum
;
import
com.bytesw.bytebot.repository.*
;
import
com.bytesw.bytebot.service.BusinessParameterService
;
import
com.bytesw.xdf.exception.NotFoundException
;
import
com.bytesw.xdf.multitenant.core.ThreadLocalStorage
;
import
com.google.gson.Gson
;
import
lombok.extern.log4j.Log4j2
;
...
...
@@ -83,6 +84,9 @@ public class ScheduleService implements SchedulingConfigurer {
@Value
(
"${application.byte-bot.batch.chunk:500}"
)
private
int
chunk
;
@Value
(
"${application.scheduler.cron}"
)
private
String
cronScheduler
;
@Autowired
private
JobExplorer
jobExplorer
;
...
...
@@ -209,11 +213,31 @@ public class ScheduleService implements SchedulingConfigurer {
/* Busca las listas de SchedulerTask */
List
<
SchedulerTask
>
listSchedulerTask
=
schedulerTaskRepository
.
findByEtlId
(
processDelete
.
getId
());
for
(
SchedulerTask
schedulerTask
:
listSchedulerTask
)
{
Trigger
triggerDelete
=
new
CronTrigger
(
schedulerTask
.
getCronExpression
(),
timeZone
);
String
keyScheduler
=
String
.
format
(
"%s-%s-%s"
,
tenantIdentifier
,
schedulerTask
.
getCalendarID
().
trim
(),
schedulerTask
.
getId
());
if
(!
listSchedulerTask
.
isEmpty
())
{
for
(
SchedulerTask
schedulerTask
:
listSchedulerTask
)
{
Trigger
triggerDelete
=
new
CronTrigger
(
schedulerTask
.
getCronExpression
(),
timeZone
);
String
keyScheduler
=
String
.
format
(
"%s-%s-%s"
,
tenantIdentifier
,
schedulerTask
.
getCalendarID
().
trim
(),
schedulerTask
.
getId
());
futureMap
.
put
(
keyScheduler
,
taskRegistrar
.
getScheduler
()
.
schedule
(()
->
processDeleteData
(
tenantIdentifier
,
taskRegistrar
,
schedulerTask
),
triggerDelete
));
}
}
else
{
String
keyScheduler
=
"refresh-schdeduler-task"
;
Trigger
triggerDelete
=
new
CronTrigger
(
cronScheduler
,
timeZone
);
futureMap
.
put
(
keyScheduler
,
taskRegistrar
.
getScheduler
()
.
schedule
(()
->
processDeleteData
(
tenantIdentifier
,
taskRegistrar
,
schedulerTask
.
getCalendarID
().
trim
()),
triggerDelete
));
.
schedule
(()
->
syncSchedulerTask
(),
triggerDelete
));
}
}
private
void
syncSchedulerTask
()
{
List
<
SchedulerTask
>
schedulerTasks
=
(
List
)
schedulerTaskRepository
.
findAll
();
for
(
SchedulerTask
model:
schedulerTasks
)
{
String
key
=
String
.
format
(
"%s-%s-%s"
,
tenant
,
model
.
getCalendarID
().
trim
(),
model
.
getId
());
if
(!
futureMap
.
containsKey
(
key
))
{
Trigger
trigger
=
new
CronTrigger
(
model
.
getCronExpression
(),
timeZone
);
futureMap
.
put
(
key
,
taskRegister
.
getScheduler
()
.
schedule
(()
->
processDeleteData
(
tenant
,
taskRegister
,
model
),
trigger
));
}
}
}
...
...
@@ -224,7 +248,7 @@ public class ScheduleService implements SchedulingConfigurer {
cancelTask
(
model
);
}
futureMap
.
put
(
key
,
taskRegister
.
getScheduler
()
.
schedule
(()
->
processDeleteData
(
tenant
,
taskRegister
,
model
.
getCalendarID
().
trim
()
),
trigger
));
.
schedule
(()
->
processDeleteData
(
tenant
,
taskRegister
,
model
),
trigger
));
}
public
void
cancelTaskDelete
(
Long
id
)
{
...
...
@@ -258,13 +282,24 @@ public class ScheduleService implements SchedulingConfigurer {
}
/*ETL eliminacion de data sensible*/
public
void
processDeleteData
(
String
tenantIdentifier
,
ScheduledTaskRegistrar
taskRegistrar
,
S
tring
calendarId
)
{
public
void
processDeleteData
(
String
tenantIdentifier
,
ScheduledTaskRegistrar
taskRegistrar
,
S
chedulerTask
schedulerTask
)
{
String
zone
=
businessParameterService
.
getBusinessParameterForKey
(
parameter
);
if
(
zone
!=
null
)
{
timeZone
=
TimeZone
.
getTimeZone
(
zone
);
}
else
{
timeZone
=
TimeZone
.
getTimeZone
(
zoneDefault
);
}
Optional
<
SchedulerTask
>
schedulerTaskActual
=
schedulerTaskRepository
.
findById
(
schedulerTask
.
getId
());
if
(
schedulerTaskActual
.
isPresent
())
{
schedulerTask
=
schedulerTaskActual
.
get
();
}
else
{
log
.
info
(
String
.
format
(
"No se encuentra la tarea de %s regristrado."
,
schedulerTask
.
getDescription
()));
cancelTask
(
schedulerTask
);
return
;
}
String
calendarId
=
schedulerTask
.
getCalendarID
().
trim
();
Optional
<
List
<
WeekScheduler
>>
dates
=
weekSchedulerRepository
.
findByCalendarId
(
calendarId
);
OffsetTime
actual
=
OffsetTime
.
now
();
OffsetDateTime
now
=
OffsetDateTime
.
now
();
...
...
@@ -300,6 +335,12 @@ public class ScheduleService implements SchedulingConfigurer {
.
schedule
(()
->
scheduleCron
(
createJobDataSens
(
data
),
tenantIdentifier
),
trigger
));
}
}
deleteDataSensBeans
=
deleteDataSensJDBCRepository
.
getListAgentChannel
(
AgentStatusEnum
.
DELETED
.
getName
(),
AgentParameterEnum
.
ACCESS_TWILIO
.
getName
());
if
(!
deleteDataSensBeans
.
isEmpty
())
{
for
(
DeleteDataSensBean
data
:
deleteDataSensBeans
)
{
cancelTaskDelete
(
data
.
getAgenId
());
}
}
}
else
{
keys
.
forEach
(
x
->
{
if
(
futureMap
.
containsKey
(
x
))
{
...
...
@@ -399,6 +440,9 @@ public class ScheduleService implements SchedulingConfigurer {
data
=
deleteDataSensJDBCRepository
.
getAgentChannelByAgentID
(
AgentStatusEnum
.
DEPLOYED
.
getName
(),
AgentParameterEnum
.
ACCESS_TWILIO
.
getName
(),
data
.
getAgenId
());
ThreadLocalStorage
.
setTenantName
(
tenant
);
if
(
data
==
null
)
{
return
null
;
}
return
jobBuilderFactory
.
get
(
String
.
format
(
"processDataSensible-%d"
,
data
.
getAgenId
()))
.
incrementer
(
new
RunIdIncrementer
()).
listener
(
listener
)
.
flow
(
createStepDataSens
(
tenant
,
data
)).
end
().
build
();
...
...
src/main/resources/application.yml
View file @
2425b67e
...
...
@@ -5,7 +5,7 @@ server:
port
:
${APPLICATION_PORT:9077}
web
:
#static-content-location: file:/home/mgutierrez/Documentos/Bytesw/bytebot-workspace/dist/bytebot-html/
static-content-location
:
file:/home/mgutierrez/Descargas/dist/bytebot-html/
static-content-location
:
file:/home/mgutierrez/Descargas/dist
-2022-2/dist
/bytebot-html/
security
:
...
...
@@ -30,7 +30,7 @@ application:
cron
:
0 0/1 * * * *
show-side-bar
:
false
test
:
ENC(OEchnTXpIZnCVdPNthgCZBfQjMt1AUS1)
name
:
xdf-example
name
:
AVB-HDI
license
:
applicationId
:
test
clientId
:
test
...
...
@@ -106,13 +106,15 @@ application:
version
:
"
1.0"
knowledge
:
url
:
"
http://127.0.0.1:3000/byteknowledgebaseApi"
scheduler
:
cron
:
0 0/1 * * * *
spring
:
main
:
allow-bean-definition-overriding
:
true
mbeans.exclude
:
dataSource
application
:
name
:
xdf-example
name
:
AVB-HDI
datasource
:
database-type
:
postgres
...
...
@@ -201,7 +203,7 @@ logging.level.org.springframework: ERROR
logging.level.org.apache.catalina.core
:
ERROR
logging.level.org.apache
:
ERROR
logging.level.org.quartz
:
ERROR
logging.level.com.bytesw-bfm.xdf.example.security
:
DEBUG
logging.level.com.bytesw-bfm.xdf.example.security
:
ERROR
logging.level.net.javacrumbs.shedlock
:
ERROR
logging.level.com.github.alturkovic.lock
:
ERROR
logging.level.com.ulisesbocchio.jasyptspringboot
:
ERROR
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment