polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [1/8] zest-qi4j git commit: Scheduler Library: minor code-readability edits
Date Mon, 06 Jul 2015 16:04:38 GMT
Repository: zest-qi4j
Updated Branches:
  refs/heads/develop 5bb6dbff6 -> fc96d0d8c


Scheduler Library: minor code-readability edits


Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/4b75e699
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/4b75e699
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/4b75e699

Branch: refs/heads/develop
Commit: 4b75e699f9a024f094bdc50bc52fa25fe8b9f792
Parents: 5bb6dbf
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Mon Jul 6 16:53:33 2015 +0200
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Mon Jul 6 16:53:33 2015 +0200

----------------------------------------------------------------------
 .../java/org/qi4j/library/scheduler/SchedulerMixin.java     | 9 +++++----
 .../java/org/qi4j/library/scheduler/schedule/Schedule.java  | 2 +-
 .../qi4j/library/scheduler/schedule/cron/CronSchedule.java  | 8 +++++---
 .../src/test/java/org/qi4j/library/scheduler/FooTask.java   | 6 +++---
 4 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/4b75e699/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java
b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java
index 6650573..b4fc406 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java
@@ -218,10 +218,12 @@ public class SchedulerMixin
         {
             corePoolSize = workersCount / 4;
         }
-        // Throws IllegalArgument if corePoolSize or keepAliveTime less than zero, or if
workersCount less than or equal to zero, or if corePoolSize greater than workersCount.
+        // Throws IllegalArgument if corePoolSize or keepAliveTime less than zero,
+        // or if workersCount less than or equal to zero,
+        // or if corePoolSize greater than workersCount.
         taskExecutor = new ThreadPoolExecutor( corePoolSize, workersCount,
                                                0, TimeUnit.MILLISECONDS,
-                                               new LinkedBlockingQueue<Runnable>( workQueueSize
),
+                                               new LinkedBlockingQueue<>( workQueueSize
),
                                                threadFactory, rejectionHandler );
         taskExecutor.prestartAllCoreThreads();
         managementExecutor = new ScheduledThreadPoolExecutor( 2, threadFactory, rejectionHandler
);
@@ -284,7 +286,6 @@ public class SchedulerMixin
     class ScheduleHandler
         implements Runnable
     {
-        private ScheduleRunner scheduleRunner;
         private ScheduledFuture<?> future;
 
         @Override
@@ -294,7 +295,7 @@ public class SchedulerMixin
             {
                 ScheduleTime scheduleTime = timingQueue.first();
                 timingQueue.remove( scheduleTime );
-                scheduleRunner = new ScheduleRunner( scheduleTime, SchedulerMixin.this, module
);
+                ScheduleRunner scheduleRunner = new ScheduleRunner( scheduleTime, SchedulerMixin.this,
module );
                 taskExecutor.submit( scheduleRunner );
                 if( timingQueue.size() == 0 )
                 {

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/4b75e699/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java
b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java
index 5fba485..ef2a214 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java
@@ -71,7 +71,7 @@ public interface Schedule
      *
      * @param from The starting time when to look for the next time it will run.
      *
-     * @return The exact absolute time when this Schedule is to be run next time.
+     * @return The exact absolute time when this Schedule is to be run next time, or -1 if
never
      */
     long nextRun( long from );
 

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/4b75e699/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java
b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java
index a1645bf..f9b8542 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java
@@ -78,13 +78,15 @@ public interface CronSchedule
         @Override
         public long nextRun( long from )
         {
+            long actualFrom = from;
             long firstRun = start().get().getMillis();
             if( firstRun > from )
             {
-                from = firstRun;
+                actualFrom = firstRun;
             }
-            Long nextRun = new org.codeartisans.sked.cron.CronSchedule( cronExpression().get()
).firstRunAfter( from );
-            LOGGER.info( "Schedule.firstRunAfter({}) CronSchedule result is {}", from, firstRun
);
+            Long nextRun = new org.codeartisans.sked.cron.CronSchedule( cronExpression().get()
)
+                .firstRunAfter( actualFrom );
+            LOGGER.info( "CronSchedule::nextRun({}) is {}", from, firstRun );
             return nextRun;
         }
     }

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/4b75e699/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/FooTask.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/FooTask.java b/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/FooTask.java
index f46a256..6ab61fd 100644
--- a/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/FooTask.java
+++ b/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/FooTask.java
@@ -18,7 +18,7 @@
 package org.qi4j.library.scheduler;
 
 import org.qi4j.api.common.Optional;
-import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.entity.Identity;
 import org.qi4j.api.injection.scope.This;
 import org.qi4j.api.mixin.Mixins;
 import org.qi4j.api.property.Property;
@@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory;
 
 @Mixins( FooTask.Mixin.class )
 public interface FooTask
-    extends Task, EntityComposite
+    extends Task, Identity
 {
     Property<String> input();
 
@@ -46,7 +46,7 @@ public interface FooTask
         @Override
         public void run()
         {
-            LOGGER.info( "FooTaskEntity.run({})", me.input().get() );
+            LOGGER.info( "FooTask.run({})", me.input().get() );
             if( me.input().get().equals( Constants.BAZAR ) )
             {
                 if( me.output().get() == null )


Mime
View raw message