Skip to content
Permalink
Browse files
Reformatting code
  • Loading branch information
effrafax committed Nov 21, 2019
1 parent 5a26d3c commit 8a5dc50f9db022d0d3b0724143561264a2644ba0
Showing 24 changed files with 183 additions and 203 deletions.
@@ -35,21 +35,20 @@
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*
*/
public class DefaultTaskQueue
implements TaskQueue
{

private Logger logger = LoggerFactory.getLogger( getClass() );
private Logger logger = LoggerFactory.getLogger( getClass( ) );

private List<TaskEntryEvaluator> taskEntryEvaluators = new ArrayList<>();
private List<TaskEntryEvaluator> taskEntryEvaluators = new ArrayList<>( );

private List<TaskExitEvaluator> taskExitEvaluators = new ArrayList<>();
private List<TaskExitEvaluator> taskExitEvaluators = new ArrayList<>( );

private List<TaskViabilityEvaluator> taskViabilityEvaluators = new ArrayList<>();
private List<TaskViabilityEvaluator> taskViabilityEvaluators = new ArrayList<>( );

private BlockingQueue<Task> queue = new LinkedBlockingQueue<>();
private BlockingQueue<Task> queue = new LinkedBlockingQueue<>( );

// ----------------------------------------------------------------------
// Component Lifecycle
@@ -95,9 +94,9 @@ public boolean put( Task task )
Collection<Task> toBeRemoved =
taskViabilityEvaluator.evaluate( Collections.unmodifiableCollection( queue ) );

for ( Iterator<Task> it = toBeRemoved.iterator(); it.hasNext(); )
for ( Iterator<Task> it = toBeRemoved.iterator( ); it.hasNext( ); )
{
Task t = it.next();
Task t = it.next( );

queue.remove( t );
}
@@ -106,13 +105,13 @@ public boolean put( Task task )
return true;
}

public Task take()
public Task take( )
throws TaskQueueException
{
logger.debug( "take" );
while ( true )
{
Task task = dequeue();
Task task = dequeue( );

if ( task == null )
{
@@ -163,7 +162,7 @@ public boolean removeAll( List tasks )
// Queue Inspection
// ----------------------------------------------------------------------

public List<Task> getQueueSnapshot()
public List<Task> getQueueSnapshot( )
throws TaskQueueException
{
return Collections.unmodifiableList( new ArrayList( queue ) );
@@ -179,13 +178,13 @@ private void enqueue( Task task )
logger.debug( "enqueue success {}", success );
}

private Task dequeue()
private Task dequeue( )
{
logger.debug( "dequeue" );
return queue.poll();
return queue.poll( );
}

public List<TaskEntryEvaluator> getTaskEntryEvaluators()
public List<TaskEntryEvaluator> getTaskEntryEvaluators( )
{
return taskEntryEvaluators;
}
@@ -195,7 +194,7 @@ public void setTaskEntryEvaluators( List<TaskEntryEvaluator> taskEntryEvaluators
this.taskEntryEvaluators = taskEntryEvaluators;
}

public List<TaskExitEvaluator> getTaskExitEvaluators()
public List<TaskExitEvaluator> getTaskExitEvaluators( )
{
return taskExitEvaluators;
}
@@ -205,7 +204,7 @@ public void setTaskExitEvaluators( List<TaskExitEvaluator> taskExitEvaluators )
this.taskExitEvaluators = taskExitEvaluators;
}

public List<TaskViabilityEvaluator> getTaskViabilityEvaluators()
public List<TaskViabilityEvaluator> getTaskViabilityEvaluators( )
{
return taskViabilityEvaluators;
}
@@ -22,12 +22,11 @@
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*
*/
public interface Task
{
/**
* @return the maximum time in milliseconds this task may run before it's cancelled.
*/
long getMaxExecutionTime();
long getMaxExecutionTime( );
}
@@ -22,7 +22,6 @@
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*
*/
public interface TaskEntryEvaluator<T extends Task>
{
@@ -22,7 +22,6 @@
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*
*/
public interface TaskExitEvaluator<T extends Task>
{
@@ -27,7 +27,6 @@
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*
*/
public interface TaskQueue<T extends Task>
{
@@ -43,7 +42,7 @@
boolean put( T task )
throws TaskQueueException;

T take()
T take( )
throws TaskQueueException;

boolean remove( T task )
@@ -56,7 +55,7 @@ boolean removeAll( List<T> tasks )
// Queue Inspection
// ----------------------------------------------------------------------

List<T> getQueueSnapshot()
List<T> getQueueSnapshot( )
throws TaskQueueException;

/**
@@ -21,7 +21,6 @@

/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*
*/
public class TaskQueueException
extends Exception
@@ -24,7 +24,6 @@
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*
*/
public interface TaskViabilityEvaluator<T extends Task>
{
@@ -21,7 +21,6 @@

/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*
*/
public class TaskExecutionException
extends Exception
@@ -23,7 +23,6 @@

/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*
*/
public interface TaskExecutor<T extends Task>
{
@@ -24,7 +24,6 @@

/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*
*/
public interface TaskQueueExecutor<T extends Task>
{
@@ -34,7 +33,7 @@
*
* @return the currently executing task.
*/
T getCurrentTask();
T getCurrentTask( );

/**
* Cancels execution of this task, if it's currently running.

0 comments on commit 8a5dc50

Please sign in to comment.