amitjoy commented on a change in pull request #29:
URL: https://github.com/apache/felix-dev/pull/29#discussion_r447606629



##########
File path: 
healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/executor/async/cron/CronSchedulerTask.java
##########
@@ -0,0 +1,53 @@
+package org.apache.felix.hc.core.impl.executor.async.cron;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class CronSchedulerTask implements Runnable {
+
+    private final Logger logger = LoggerFactory.getLogger(getClass());
+
+    public final CronJob cronJob;
+    public final CronScheduler scheduler;
+    public final CronParser sequenceGenerator;
+
+    volatile boolean executing;
+    volatile long lastExecutingTime = 0;
+    volatile long nextExecutingTime = 0;
+
+    public CronSchedulerTask(final CronScheduler scheduler, final CronJob 
cronJob,
+            final CronParser sequenceGenerator) {
+        this.scheduler = scheduler;
+        this.cronJob = cronJob;
+        this.sequenceGenerator = sequenceGenerator;
+    }
+
+    @Override
+    public void run() {
+        try {
+               cronJob.run();

Review comment:
        In Eclipse, this looks good but due to formatting standard in GitHub, 
it looks different here.

##########
File path: 
healthcheck/core/src/main/java/org/apache/felix/hc/core/impl/scheduling/AsyncCronJob.java
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The SF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.apache.felix.hc.core.impl.scheduling;
+
+import org.apache.felix.hc.core.impl.executor.async.cron.CronJob;
+import org.apache.felix.hc.core.impl.executor.async.cron.CronScheduler;
+import 
org.apache.felix.hc.core.impl.executor.async.cron.HealthCheckCronScheduler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *  Runs health checks that are configured with a cron expression for 
asynchronous execution. 
+ */
+public class AsyncCronJob extends AsyncJob {
+       private final Logger logger = LoggerFactory.getLogger(getClass());
+
+    private final CronJob cronJob;
+    protected final HealthCheckCronScheduler healtchCheckScheduler;
+
+    public AsyncCronJob(Runnable runnable, HealthCheckCronScheduler 
healtchCheckScheduler, String id, String cronExpression) throws 
ClassNotFoundException {
+        super(runnable);
+        this.healtchCheckScheduler = healtchCheckScheduler;
+        this.cronJob = new HealthCheckJob(cronExpression, id);
+    }
+
+    public boolean schedule() {
+        try {
+            CronScheduler scheduler = healtchCheckScheduler.getScheduler();
+            scheduler.schedule(cronJob);
+            logger.info("Scheduled job {} with trigger {}", cronJob.name(), 
cronJob.cron());
+            return true;
+        } catch (Exception e) {
+            logger.error("Could not schedule job for " + runnable + ": " + e, 
e);
+            return false;
+        }
+

Review comment:
       fixed




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to