use of org.jboss.netty.channel.Channel in project storm by apache.
the class KerberosSaslClientHandler method channelConnected.
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent event) {
// register the newly established channel
Channel channel = ctx.getChannel();
client.channelConnected(channel);
LOG.info("Connection established from {} to {}", channel.getLocalAddress(), channel.getRemoteAddress());
try {
KerberosSaslNettyClient saslNettyClient = KerberosSaslNettyClientState.getKerberosSaslNettyClient.get(channel);
if (saslNettyClient == null) {
LOG.debug("Creating saslNettyClient now for channel: {}", channel);
saslNettyClient = new KerberosSaslNettyClient(storm_conf, jaas_section, host);
KerberosSaslNettyClientState.getKerberosSaslNettyClient.set(channel, saslNettyClient);
}
LOG.debug("Going to initiate Kerberos negotiations.");
byte[] initialChallenge = saslNettyClient.saslResponse(new SaslMessageToken(new byte[0]));
LOG.debug("Sending initial challenge: {}", initialChallenge);
channel.write(new SaslMessageToken(initialChallenge));
} catch (Exception e) {
LOG.error("Failed to authenticate with server due to error: ", e);
}
return;
}
use of org.jboss.netty.channel.Channel in project zookeeper by apache.
the class NettyServerCnxnFactory method reconfigure.
public void reconfigure(InetSocketAddress addr) {
Channel oldChannel = parentChannel;
try {
LOG.info("binding to port {}", addr);
parentChannel = bootstrap.bind(addr);
localAddress = addr;
} catch (Exception e) {
LOG.error("Error while reconfiguring", e);
} finally {
oldChannel.close();
}
}
use of org.jboss.netty.channel.Channel in project storm by apache.
the class SaslStormClientHandler method channelConnected.
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent event) {
// register the newly established channel
Channel channel = ctx.getChannel();
client.channelConnected(channel);
try {
SaslNettyClient saslNettyClient = SaslNettyClientState.getSaslNettyClient.get(channel);
if (saslNettyClient == null) {
LOG.debug("Creating saslNettyClient now " + "for channel: " + channel);
saslNettyClient = new SaslNettyClient(name, token);
SaslNettyClientState.getSaslNettyClient.set(channel, saslNettyClient);
}
LOG.debug("Sending SASL_TOKEN_MESSAGE_REQUEST");
channel.write(ControlMessage.SASL_TOKEN_MESSAGE_REQUEST);
} catch (Exception e) {
LOG.error("Failed to authenticate with server " + "due to error: ", e);
}
}
use of org.jboss.netty.channel.Channel in project storm by apache.
the class SaslStormServerAuthorizeHandler method messageReceived.
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
Object msg = e.getMessage();
if (msg == null)
return;
Channel channel = ctx.getChannel();
LOG.debug("messageReceived: Checking whether the client is authorized to send messages to the server ");
// Authorize: client is allowed to doRequest() if and only if the client
// has successfully authenticated with this server.
SaslNettyServer saslNettyServer = SaslNettyServerState.getSaslNettyServer.get(channel);
if (saslNettyServer == null) {
LOG.warn("messageReceived: This client is *NOT* authorized to perform " + "this action since there's no saslNettyServer to " + "authenticate the client: " + "refusing to perform requested action: " + msg);
return;
}
if (!saslNettyServer.isComplete()) {
LOG.warn("messageReceived: This client is *NOT* authorized to perform " + "this action because SASL authentication did not complete: " + "refusing to perform requested action: " + msg);
// not authorized.
return;
}
LOG.debug("messageReceived: authenticated client: " + saslNettyServer.getUserName() + " is authorized to do request " + "on server.");
// We call fireMessageReceived since the client is allowed to perform
// this request. The client's request will now proceed to the next
// pipeline component.
Channels.fireMessageReceived(ctx, msg);
}
use of org.jboss.netty.channel.Channel in project storm by apache.
the class PacemakerClient method send.
public HBMessage send(HBMessage m) throws PacemakerConnectionException {
LOG.debug("Sending message: {}", m.toString());
try {
int next = availableMessageSlots.take();
synchronized (m) {
m.set_message_id(next);
messages[next] = m;
LOG.debug("Put message in slot: {}", Integer.toString(next));
do {
waitUntilReady();
Channel channel = channelRef.get();
if (channel != null) {
channel.write(m);
m.wait(1000);
}
} while (messages[next] == m);
}
HBMessage ret = messages[next];
if (ret == null) {
// This can happen if we lost the connection and subsequently reconnected or timed out.
send(m);
}
messages[next] = null;
LOG.debug("Got Response: {}", ret);
return ret;
} catch (InterruptedException e) {
LOG.error("PacemakerClient send interrupted: ", e);
throw new RuntimeException(e);
}
}
Aggregations