Fix compilation errors in ChannelGroup and its related types
- Also removed the operations not valid anymore
This commit is contained in:
parent
825d7964c9
commit
c34d63d159
@ -23,7 +23,6 @@ import io.netty.channel.ChannelHandlerContext;
|
|||||||
import io.netty.channel.ServerChannel;
|
import io.netty.channel.ServerChannel;
|
||||||
import io.netty.util.CharsetUtil;
|
import io.netty.util.CharsetUtil;
|
||||||
|
|
||||||
import java.net.SocketAddress;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,19 +115,6 @@ public interface ChannelGroup extends Set<Channel>, Comparable<ChannelGroup> {
|
|||||||
*/
|
*/
|
||||||
ChannelGroupFuture write(Object message);
|
ChannelGroupFuture write(Object message);
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes the specified {@code message} with the specified
|
|
||||||
* {@code remoteAddress} to all {@link Channel}s in this group. If the
|
|
||||||
* specified {@code message} is an instance of {@link ChannelBuffer}, it is
|
|
||||||
* automatically {@linkplain ChannelBuffer#duplicate() duplicated} to avoid
|
|
||||||
* a race condition. Please note that this operation is asynchronous as
|
|
||||||
* {@link Channel#write(Object, SocketAddress)} is.
|
|
||||||
*
|
|
||||||
* @return the {@link ChannelGroupFuture} instance that notifies when
|
|
||||||
* the operation is done for all channels
|
|
||||||
*/
|
|
||||||
ChannelGroupFuture write(Object message, SocketAddress remoteAddress);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects all {@link Channel}s in this group from their remote peers.
|
* Disconnects all {@link Channel}s in this group from their remote peers.
|
||||||
*
|
*
|
||||||
|
@ -15,14 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.channel.group;
|
package io.netty.channel.group;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelFuture;
|
import io.netty.channel.ChannelFuture;
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.MessageEvent;
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The result of an asynchronous {@link ChannelGroup} operation.
|
* The result of an asynchronous {@link ChannelGroup} operation.
|
||||||
|
@ -22,7 +22,6 @@ import io.netty.channel.ChannelFutureListener;
|
|||||||
import io.netty.channel.ServerChannel;
|
import io.netty.channel.ServerChannel;
|
||||||
import io.netty.util.internal.ConcurrentHashMap;
|
import io.netty.util.internal.ConcurrentHashMap;
|
||||||
|
|
||||||
import java.net.SocketAddress;
|
|
||||||
import java.util.AbstractSet;
|
import java.util.AbstractSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -117,7 +116,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
|||||||
|
|
||||||
boolean added = map.putIfAbsent(channel.id(), channel) == null;
|
boolean added = map.putIfAbsent(channel.id(), channel) == null;
|
||||||
if (added) {
|
if (added) {
|
||||||
channel.getCloseFuture().addListener(remover);
|
channel.addClosureListener(remover);
|
||||||
}
|
}
|
||||||
return added;
|
return added;
|
||||||
}
|
}
|
||||||
@ -133,9 +132,9 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
|||||||
} else if (o instanceof Channel) {
|
} else if (o instanceof Channel) {
|
||||||
c = (Channel) o;
|
c = (Channel) o;
|
||||||
if (c instanceof ServerChannel) {
|
if (c instanceof ServerChannel) {
|
||||||
c = serverChannels.remove(c.getId());
|
c = serverChannels.remove(c.id());
|
||||||
} else {
|
} else {
|
||||||
c = nonServerChannels.remove(c.getId());
|
c = nonServerChannels.remove(c.id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +142,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.getCloseFuture().removeListener(remover);
|
c.removeClosureListener(remover);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,10 +181,14 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
|||||||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
new LinkedHashMap<Integer, ChannelFuture>(size());
|
||||||
|
|
||||||
for (Channel c: serverChannels.values()) {
|
for (Channel c: serverChannels.values()) {
|
||||||
futures.put(c.getId(), c.close().awaitUninterruptibly());
|
ChannelFuture f = c.newFuture();
|
||||||
|
c.close(f);
|
||||||
|
futures.put(c.id(), f.awaitUninterruptibly());
|
||||||
}
|
}
|
||||||
for (Channel c: nonServerChannels.values()) {
|
for (Channel c: nonServerChannels.values()) {
|
||||||
futures.put(c.getId(), c.close());
|
ChannelFuture f = c.newFuture();
|
||||||
|
c.close(f);
|
||||||
|
futures.put(c.id(), f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DefaultChannelGroupFuture(this, futures);
|
return new DefaultChannelGroupFuture(this, futures);
|
||||||
@ -197,55 +200,14 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
|||||||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
new LinkedHashMap<Integer, ChannelFuture>(size());
|
||||||
|
|
||||||
for (Channel c: serverChannels.values()) {
|
for (Channel c: serverChannels.values()) {
|
||||||
futures.put(c.getId(), c.disconnect().awaitUninterruptibly());
|
ChannelFuture f = c.newFuture();
|
||||||
|
c.disconnect(f);
|
||||||
|
futures.put(c.id(), f.awaitUninterruptibly());
|
||||||
}
|
}
|
||||||
for (Channel c: nonServerChannels.values()) {
|
for (Channel c: nonServerChannels.values()) {
|
||||||
futures.put(c.getId(), c.disconnect());
|
ChannelFuture f = c.newFuture();
|
||||||
}
|
c.disconnect(f);
|
||||||
|
futures.put(c.id(), f);
|
||||||
return new DefaultChannelGroupFuture(this, futures);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelGroupFuture setInterestOps(int interestOps) {
|
|
||||||
Map<Integer, ChannelFuture> futures =
|
|
||||||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
|
||||||
|
|
||||||
for (Channel c: serverChannels.values()) {
|
|
||||||
futures.put(c.getId(), c.setInterestOps(interestOps).awaitUninterruptibly());
|
|
||||||
}
|
|
||||||
for (Channel c: nonServerChannels.values()) {
|
|
||||||
futures.put(c.getId(), c.setInterestOps(interestOps));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new DefaultChannelGroupFuture(this, futures);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelGroupFuture setReadable(boolean readable) {
|
|
||||||
Map<Integer, ChannelFuture> futures =
|
|
||||||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
|
||||||
|
|
||||||
for (Channel c: serverChannels.values()) {
|
|
||||||
futures.put(c.getId(), c.setReadable(readable).awaitUninterruptibly());
|
|
||||||
}
|
|
||||||
for (Channel c: nonServerChannels.values()) {
|
|
||||||
futures.put(c.getId(), c.setReadable(readable));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new DefaultChannelGroupFuture(this, futures);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelGroupFuture unbind() {
|
|
||||||
Map<Integer, ChannelFuture> futures =
|
|
||||||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
|
||||||
|
|
||||||
for (Channel c: serverChannels.values()) {
|
|
||||||
futures.put(c.getId(), c.unbind().awaitUninterruptibly());
|
|
||||||
}
|
|
||||||
for (Channel c: nonServerChannels.values()) {
|
|
||||||
futures.put(c.getId(), c.unbind());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DefaultChannelGroupFuture(this, futures);
|
return new DefaultChannelGroupFuture(this, futures);
|
||||||
@ -258,28 +220,15 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
|
|||||||
if (message instanceof ChannelBuffer) {
|
if (message instanceof ChannelBuffer) {
|
||||||
ChannelBuffer buf = (ChannelBuffer) message;
|
ChannelBuffer buf = (ChannelBuffer) message;
|
||||||
for (Channel c: nonServerChannels.values()) {
|
for (Channel c: nonServerChannels.values()) {
|
||||||
futures.put(c.getId(), c.write(buf.duplicate()));
|
ChannelFuture f = c.newFuture();
|
||||||
|
c.write(buf.duplicate(), f);
|
||||||
|
futures.put(c.id(), f);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Channel c: nonServerChannels.values()) {
|
for (Channel c: nonServerChannels.values()) {
|
||||||
futures.put(c.getId(), c.write(message));
|
ChannelFuture f = c.newFuture();
|
||||||
}
|
c.write(message, f);
|
||||||
}
|
futures.put(c.id(), f);
|
||||||
return new DefaultChannelGroupFuture(this, futures);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelGroupFuture write(Object message, SocketAddress remoteAddress) {
|
|
||||||
Map<Integer, ChannelFuture> futures =
|
|
||||||
new LinkedHashMap<Integer, ChannelFuture>(size());
|
|
||||||
if (message instanceof ChannelBuffer) {
|
|
||||||
ChannelBuffer buf = (ChannelBuffer) message;
|
|
||||||
for (Channel c: nonServerChannels.values()) {
|
|
||||||
futures.put(c.getId(), c.write(buf.duplicate(), remoteAddress));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (Channel c: nonServerChannels.values()) {
|
|
||||||
futures.put(c.getId(), c.write(message, remoteAddress));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new DefaultChannelGroupFuture(this, futures);
|
return new DefaultChannelGroupFuture(this, futures);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user