if ( job.isSimulation() )
{
return null;
}
CraftingCPUCluster cpuCluster = null;
if ( target instanceof CraftingCPUCluster )
{
cpuCluster = (CraftingCPUCluster) target;
}
if ( target == null )
{
List<CraftingCPUCluster> validCpusClusters = new ArrayList<CraftingCPUCluster>();
for (CraftingCPUCluster cpu : this.craftingCPUClusters)
{
if ( cpu.isActive() && !cpu.isBusy() && cpu.getAvailableStorage() >= job.getByteTotal() )
{
validCpusClusters.add( cpu );
}
}
Collections.sort( validCpusClusters, new Comparator<CraftingCPUCluster>()
{
@Override
public int compare(CraftingCPUCluster firstCluster, CraftingCPUCluster nextCluster)
{
if ( prioritizePower )
{
int comparison = ItemSorters.compareLong( nextCluster.getCoProcessors(), firstCluster.getCoProcessors() );
if ( comparison != 0 )
return comparison;
return ItemSorters.compareLong( nextCluster.getAvailableStorage(), firstCluster.getAvailableStorage() );
}
int comparison = ItemSorters.compareLong( firstCluster.getCoProcessors(), nextCluster.getCoProcessors() );
if ( comparison != 0 )
return comparison;
return ItemSorters.compareLong( firstCluster.getAvailableStorage(), nextCluster.getAvailableStorage() );
}
} );
if ( !validCpusClusters.isEmpty() )
{
cpuCluster = validCpusClusters.get( 0 );
}
}
if ( cpuCluster != null )
{
return cpuCluster.submitJob( grid, job, src, requestingMachine );
}
return null;
}