在S个服务器之间均匀分配N个查询

时间:2017-05-20 16:01:25

标签: java

问题在于:需要在S个服务器之间分配N个查询。已经提出了这个问题。解决方案是向服务器分配查询,但删除服务器先前查询的查询次数。可以建议我做错了什么?

public class Servers<T> {
    public int serverId;

    public ArrayList<Queries> queryList;
    public Servers()
    {

    }

    public int getServerId() {
        return serverId;
    }
    public ArrayList<Queries> getqueryList() {
        return queryList;
    }
    public void setqueryList(ArrayList<Queries> queryList) {
        this.queryList = queryList;
    }
    public void setServerId(int serverId) {
        this.serverId = serverId;
    }


}

查询类:

public class Queries {
    private static final int noOfServers=10; 
    private String query;
    private int queryId;
    private int size=0;
    private Servers[] ser=new Servers[noOfServers];
//getters and setters for instance variables for Queries class <not included>
public int allocateM(Queries query)
    {
        ArrayList<Queries> queryList=new ArrayList<Queries>();
        int i=size;
        if(i < ser.length)
        {
            qList.add(query);
            ser[i].setqueryList(qList);
            System.out.println("size" + ser[i].getqueryList());
            size++;
        }
        else    if(i==ser.length)
        {
            size=0;
            i=0;


        }



        return ser[i].serverId;
    }

0 个答案:

没有答案