this.sessions = Collections.emptyList();
return;
}
Collection<Session> copySessions = list;
List<List<Session>> tmpList = new ArrayList<List<Session>>();
Session target = null;
List<Session> subList = null;
for (Session session : copySessions) {
if (target == null) {
target = session;
subList = new ArrayList<Session>();
subList.add(target);
} else {
if (session.getRemoteSocketAddress().equals(
target.getRemoteSocketAddress())) {
subList.add(session);
} else {
tmpList.add(subList);
target = session;
subList = new ArrayList<Session>();
subList.add(target);
}
}
}
// The last one
if (subList != null) {
tmpList.add(subList);
}
List<List<Session>> newSessions = new ArrayList<List<Session>>(
tmpList.size() * 2);
for (List<Session> sessions : tmpList) {
if (sessions != null && !sessions.isEmpty()) {
Session session = sessions.get(0);
if (session instanceof MemcachedTCPSession) {
int weight = ((MemcachedSession) session).getWeight();
for (int i = 0; i < weight; i++) {
newSessions.add(sessions);
}