fixed warnings

This commit is contained in:
Ziver Koc 2010-08-14 15:38:56 +00:00
parent 2693a9eb4e
commit 93b14283c2
5 changed files with 20 additions and 20 deletions

View file

@ -43,7 +43,7 @@ public class QuickSort{
* @param stop is the index to stop * @param stop is the index to stop
* @param type is the type of pivot to use * @param type is the type of pivot to use
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
public static void sort(SortableDataList list, int start, int stop, int type, boolean insertionSort){ public static void sort(SortableDataList list, int start, int stop, int type, boolean insertionSort){
if(stop-start <= 15 && insertionSort){ if(stop-start <= 15 && insertionSort){
SimpleSort.insertionSort( list, start, stop); SimpleSort.insertionSort( list, start, stop);
@ -76,7 +76,7 @@ public class QuickSort{
} }
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "rawtypes" })
private static int pivot(SortableDataList<?> list, int start, int stop,int type){ private static int pivot(SortableDataList<?> list, int start, int stop,int type){
switch(type){ switch(type){
case RANDOM_PIVOT: case RANDOM_PIVOT:

View file

@ -14,7 +14,7 @@ public class Randomizer {
* Randomizes the index of all the elements * Randomizes the index of all the elements
* @param list The list * @param list The list
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings({ "rawtypes" })
public static void sort(SortableDataList list){ public static void sort(SortableDataList list){
int size = list.size(); int size = list.size();
for(int i=0; i<size ;i++){ for(int i=0; i<size ;i++){

View file

@ -97,9 +97,8 @@ public class Converter {
* @param interf the interface to look for * @param interf the interface to look for
* @return true if the interface is implemented else false * @return true if the interface is implemented else false
*/ */
@SuppressWarnings("unchecked") public static boolean isInstanceOf(Object object, Class<?> interf){
public static boolean isInstanceOf(Object object, Class interf){ Class<?>[] objectInterf = object.getClass().getInterfaces();
Class[] objectInterf = object.getClass().getInterfaces();
for(int i=0; i<objectInterf.length ;i++){ for(int i=0; i<objectInterf.length ;i++){
if(objectInterf[i] == interf){ if(objectInterf[i] == interf){
return true; return true;

View file

@ -17,6 +17,7 @@ import zutil.network.nio.worker.WorkerDataEvent;
* *
* @author Ziver * @author Ziver
*/ */
@SuppressWarnings({ "unchecked", "rawtypes" })
public class GridClient extends ThreadedEventWorker { public class GridClient extends ThreadedEventWorker {
private static LinkedList<GridJob> jobQueue; private static LinkedList<GridJob> jobQueue;
private static GridThread thread; private static GridThread thread;
@ -43,7 +44,7 @@ public class GridClient extends ThreadedEventWorker {
*/ */
public void initiate() throws IOException{ public void initiate() throws IOException{
network.setDefaultWorker(this); network.setDefaultWorker(this);
network.send(new GridMessage<Object>(GridMessage.REGISTER)); network.send(new GridMessage(GridMessage.REGISTER));
for(int i=0; i<Runtime.getRuntime().availableProcessors() ;i++){ for(int i=0; i<Runtime.getRuntime().availableProcessors() ;i++){
Thread t = new Thread(thread); Thread t = new Thread(thread);
@ -55,14 +56,14 @@ public class GridClient extends ThreadedEventWorker {
public void messageEvent(WorkerDataEvent e) { public void messageEvent(WorkerDataEvent e) {
// ignores other messages than GridMessage // ignores other messages than GridMessage
if(e.data instanceof GridMessage){ if(e.data instanceof GridMessage){
GridMessage<?> msg = (GridMessage<?>)e.data; GridMessage msg = (GridMessage)e.data;
switch(msg.messageType()){ switch(msg.messageType()){
// Receive data from Server // Receive data from Server
case GridMessage.INIT_DATA: case GridMessage.INIT_DATA:
thread.setInitData(msg.getData()); thread.setInitData(msg.getData());
break; break;
case GridMessage.COMP_DATA: case GridMessage.COMP_DATA:
jobQueue.add(new GridJob(msg.getJobQueueID(), (Queue<?>)msg.getData())); jobQueue.add(new GridJob(msg.getJobQueueID(), (Queue)msg.getData()));
break; break;
} }
} }
@ -78,9 +79,9 @@ public class GridClient extends ThreadedEventWorker {
*/ */
public static void jobDone(int jobID, boolean correct, Object result) throws IOException{ public static void jobDone(int jobID, boolean correct, Object result) throws IOException{
if(correct) if(correct)
network.send(new GridMessage<Object>(GridMessage.COMP_SUCCESSFUL, jobID, result)); network.send(new GridMessage(GridMessage.COMP_SUCCESSFUL, jobID, result));
else else
network.send(new GridMessage<Object>(GridMessage.COMP_INCORRECT, jobID, result)); network.send(new GridMessage(GridMessage.COMP_INCORRECT, jobID, result));
} }
/** /**
@ -91,7 +92,7 @@ public class GridClient extends ThreadedEventWorker {
*/ */
public static void jobError(int jobID){ public static void jobError(int jobID){
try{ try{
network.send(new GridMessage<Object>(GridMessage.COMP_SUCCESSFUL, jobID)); network.send(new GridMessage(GridMessage.COMP_SUCCESSFUL, jobID));
}catch(Exception e){e.printStackTrace();} }catch(Exception e){e.printStackTrace();}
} }
@ -101,7 +102,7 @@ public class GridClient extends ThreadedEventWorker {
*/ */
public static synchronized GridJob getNextJob() throws IOException{ public static synchronized GridJob getNextJob() throws IOException{
if(jobQueue.isEmpty()){ if(jobQueue.isEmpty()){
network.send(new GridMessage<Object>(GridMessage.NEW_DATA)); network.send(new GridMessage(GridMessage.NEW_DATA));
while(jobQueue.isEmpty()){ while(jobQueue.isEmpty()){
try{Thread.sleep(100);}catch(Exception e){} try{Thread.sleep(100);}catch(Exception e){}
} }

View file

@ -14,18 +14,18 @@ import zutil.network.nio.worker.WorkerDataEvent;
* *
* @author Ziver * @author Ziver
*/ */
@SuppressWarnings({ "unchecked", "rawtypes" })
public class GridServerWorker extends ThreadedEventWorker{ public class GridServerWorker extends ThreadedEventWorker{
// Job timeout after 30 min // Job timeout after 30 min
public static int JOB_TIMEOUT = 1000*60*30; public static int JOB_TIMEOUT = 1000*60*30;
private HashMap<Integer, GridJob> jobs; // contains all the ongoing jobs private HashMap<Integer, GridJob> jobs; // contains all the ongoing jobs
private Queue<GridJob> reSendjobQueue; // Contains all the jobs that will be recalculated private Queue<GridJob> reSendjobQueue; // Contains all the jobs that will be recalculated
private GridJobGenerator<?> jobGenerator; // The job generator private GridJobGenerator jobGenerator; // The job generator
private GridResultHandler<Object> resHandler; private GridResultHandler resHandler;
private int nextJobID; private int nextJobID;
public GridServerWorker(GridResultHandler<Object> resHandler, GridJobGenerator<?> jobGenerator){ public GridServerWorker(GridResultHandler resHandler, GridJobGenerator jobGenerator){
this.resHandler = resHandler; this.resHandler = resHandler;
this.jobGenerator = jobGenerator; this.jobGenerator = jobGenerator;
nextJobID = 0; nextJobID = 0;
@ -41,12 +41,12 @@ public class GridServerWorker extends ThreadedEventWorker{
try { try {
// ignores other messages than GridMessage // ignores other messages than GridMessage
if(e.data instanceof GridMessage){ if(e.data instanceof GridMessage){
GridMessage<?> msg = (GridMessage<?>)e.data; GridMessage msg = (GridMessage)e.data;
GridJob job = null; GridJob job = null;
switch(msg.messageType()){ switch(msg.messageType()){
case GridMessage.REGISTER: case GridMessage.REGISTER:
e.network.send(e.socket, new GridMessage<Object>(GridMessage.INIT_DATA, 0, jobGenerator.initValues())); e.network.send(e.socket, new GridMessage(GridMessage.INIT_DATA, 0, jobGenerator.initValues()));
break; break;
// Sending new data to compute to the client // Sending new data to compute to the client
case GridMessage.NEW_DATA: case GridMessage.NEW_DATA:
@ -60,7 +60,7 @@ public class GridServerWorker extends ThreadedEventWorker{
jobs.put(job.jobID, job); jobs.put(job.jobID, job);
nextJobID++; nextJobID++;
} }
GridMessage<Object> newMsg = new GridMessage<Object>(GridMessage.COMP_DATA, job.jobID, job.job); GridMessage newMsg = new GridMessage(GridMessage.COMP_DATA, job.jobID, job.job);
e.network.send(e.socket, newMsg); e.network.send(e.socket, newMsg);
break; break;