public DataSender getNewDataSender() { try { ParallelNioSender sender = new ParallelNioSender(); sender.transferProperties(this,sender); return sender; } catch ( IOException x ) { throw new RuntimeException("Unable to open NIO selector.",x); } }
@Override public synchronized void disconnect() { setConnected(false); try {close(); }catch (Exception x){/*Ignore*/} }
public void finalize() { try {disconnect(); }catch ( Exception ignore){} try {selector.close();} catch (Exception ignore) {} }
public synchronized void sendMessage(Member[] destination, ChannelMessage msg) throws ChannelException { long start = System.currentTimeMillis(); byte[] data = XByteBuffer.createDataPackage((ChannelData)msg); NioSender[] senders = setupForSend(destination); connect(senders); setData(senders,data); while ( (remaining>0) && (delta<getTimeout()) ) { try { remaining -= doLoop(selectTimeout, getMaxRetryAttempts(),waitForAck,msg); } catch (Exception x ) { int faulty = (cx == null)?0:cx.getFaultyMembers().length; ChannelException cxtimeout = new ChannelException("Operation has timed out("+getTimeout()+" ms.)."); if ( cx==null ) cx = new ChannelException("Operation has timed out("+getTimeout()+" ms.)."); for (int i=0; i<senders.length; i++ ) { if (!senders[i].isComplete() ) cx.addFaultyMember(senders[i].getDestination(),cxtimeout); try { this.disconnect(); } catch (Exception ignore) {} if ( x instanceof ChannelException ) throw (ChannelException)x; else throw new ChannelException(x);
@Override public void sendMessage(Member[] destination, ChannelMessage message) throws ChannelException { if (!isConnected()) { throw new ChannelException(sm.getString("pooledParallelSender.sender.disconnected")); } ParallelNioSender sender = (ParallelNioSender)getSender(); if (sender == null) { ChannelException cx = new ChannelException(sm.getString( "pooledParallelSender.unable.retrieveSender.timeout", Long.toString(getMaxWait()))); for (int i = 0; i < destination.length; i++) cx.addFaultyMember(destination[i], new NullPointerException(sm.getString("pooledParallelSender.unable.retrieveSender"))); throw cx; } else { try { if (!sender.isConnected()) sender.connect(); sender.sendMessage(destination, message); sender.keepalive(); } catch (ChannelException x) { sender.disconnect(); throw x; } finally { returnSender(sender); } } }
public void sendMessage(Member[] destination, ChannelMessage message) throws ChannelException { if ( !connected ) throw new ChannelException("Sender not connected."); ParallelNioSender sender = (ParallelNioSender)getSender(); if (sender == null) { ChannelException cx = new ChannelException("Unable to retrieve a data sender, time out error."); for (int i = 0; i < destination.length; i++) cx.addFaultyMember(destination[i], new NullPointerException("Unable to retrieve a sender from the sender pool")); throw cx; } else { try { sender.sendMessage(destination, message); sender.keepalive(); } catch (ChannelException x) { sender.disconnect(); throw x; } finally { returnSender(sender); if (!connected) disconnect(); } } }
if ( !isConnected() ) { log.warn("Not retrying send for:" + sender.getDestination().getName() + "; Sender is disconnected."); ChannelException cx = new ChannelException("Send failed, and sender is disconnected. Not retrying.",x);
@Override public DataSender getNewDataSender() { try { ParallelNioSender sender = new ParallelNioSender(); AbstractSender.transferProperties(this,sender); return sender; } catch ( IOException x ) { throw new RuntimeException("Unable to open NIO selector.",x); } }
@Override public synchronized void sendMessage(Member[] destination, ChannelMessage msg) throws ChannelException { long start = System.currentTimeMillis(); this.setUdpBased((msg.getOptions()&Channel.SEND_OPTIONS_UDP) == Channel.SEND_OPTIONS_UDP); byte[] data = XByteBuffer.createDataPackage((ChannelData)msg); NioSender[] senders = setupForSend(destination); connect(senders); setData(senders,data); while ( (remaining>0) && (delta<getTimeout()) ) { try { remaining -= doLoop(selectTimeout, getMaxRetryAttempts(),waitForAck,msg); } catch (Exception x ) { if (log.isTraceEnabled()) log.trace("Error sending message", x); ChannelException cxtimeout = new ChannelException("Operation has timed out("+getTimeout()+" ms.)."); if ( cx==null ) cx = new ChannelException("Operation has timed out("+getTimeout()+" ms.)."); for (int i=0; i<senders.length; i++ ) { if (!senders[i].isComplete() ) cx.addFaultyMember(senders[i].getDestination(),cxtimeout); try { this.disconnect(); } catch (Exception e) {/*Ignore*/} if ( x instanceof ChannelException ) throw (ChannelException)x; else throw new ChannelException(x);
@Override public void sendMessage(Member[] destination, ChannelMessage message) throws ChannelException { if ( !connected ) throw new ChannelException("Sender not connected."); ParallelNioSender sender = (ParallelNioSender)getSender(); if (sender == null) { ChannelException cx = new ChannelException("Unable to retrieve a data sender, time out error."); for (int i = 0; i < destination.length; i++) cx.addFaultyMember(destination[i], new NullPointerException("Unable to retrieve a sender from the sender pool")); throw cx; } else { try { sender.sendMessage(destination, message); sender.keepalive(); } catch (ChannelException x) { sender.disconnect(); throw x; } finally { returnSender(sender); if (!connected) disconnect(); } } }
if ( !isConnected() ) { log.warn("Not retrying send for:" + sender.getDestination().getName() + "; Sender is disconnected."); ChannelException cx = new ChannelException("Send failed, and sender is disconnected. Not retrying.",x);
@Override public DataSender getNewDataSender() { try { ParallelNioSender sender = new ParallelNioSender(); AbstractSender.transferProperties(this,sender); return sender; } catch ( IOException x ) { throw new RuntimeException("Unable to open NIO selector.",x); } }
throws ChannelException { long start = System.currentTimeMillis(); this.setUdpBased((msg.getOptions()&Channel.SEND_OPTIONS_UDP) == Channel.SEND_OPTIONS_UDP); byte[] data = XByteBuffer.createDataPackage((ChannelData)msg); NioSender[] senders = setupForSend(destination); connect(senders); setData(senders,data); boolean waitForAck = (Channel.SEND_OPTIONS_USE_ACK & msg.getOptions()) == Channel.SEND_OPTIONS_USE_ACK; while ( (remaining>0) && (delta<getTimeout()) ) { try { remaining -= doLoop(selectTimeout, getMaxRetryAttempts(),waitForAck,msg); } catch (Exception x ) { if (log.isTraceEnabled()) log.trace("Error sending message", x); "Operation has timed out(" + getTimeout() + " ms.)."); if ( cx==null ) cx = new ChannelException( "Operation has timed out(" + getTimeout() + " ms.)."); for (int i=0; i<senders.length; i++ ) { if (!senders[i].isComplete()) { try { this.disconnect(); } catch (Exception e) {/*Ignore*/} if ( x instanceof ChannelException ) throw (ChannelException)x; else throw new ChannelException(x);
@Override public void sendMessage(Member[] destination, ChannelMessage message) throws ChannelException { if ( !connected ) throw new ChannelException("Sender not connected."); ParallelNioSender sender = (ParallelNioSender)getSender(); if (sender == null) { ChannelException cx = new ChannelException("Unable to retrieve a data sender, time out("+getMaxWait()+" ms) error."); for (int i = 0; i < destination.length; i++) cx.addFaultyMember(destination[i], new NullPointerException("Unable to retrieve a sender from the sender pool")); throw cx; } else { try { sender.sendMessage(destination, message); sender.keepalive(); } catch (ChannelException x) { sender.disconnect(); throw x; } finally { returnSender(sender); if (!connected) disconnect(); } } }
@Override public synchronized void disconnect() { setConnected(false); try {close(); }catch (Exception x){/*Ignore*/} }
@Override public void finalize() throws Throwable { try {disconnect(); }catch ( Exception e){/*Ignore*/} try { selector.close(); }catch (Exception e) { if (log.isDebugEnabled()) { log.debug("Failed to close selector", e); } } super.finalize(); }
if ( !isConnected() ) { log.warn("Not retrying send for:" + sender.getDestination().getName() + "; Sender is disconnected.");
@Override public DataSender getNewDataSender() { try { ParallelNioSender sender = new ParallelNioSender(); AbstractSender.transferProperties(this,sender); return sender; } catch ( IOException x ) { throw new RuntimeException(sm.getString("pooledParallelSender.unable.open"),x); } } }
throws ChannelException { long start = System.currentTimeMillis(); this.setUdpBased((msg.getOptions()&Channel.SEND_OPTIONS_UDP) == Channel.SEND_OPTIONS_UDP); byte[] data = XByteBuffer.createDataPackage((ChannelData)msg); NioSender[] senders = setupForSend(destination); connect(senders); setData(senders,data); boolean waitForAck = (Channel.SEND_OPTIONS_USE_ACK & msg.getOptions()) == Channel.SEND_OPTIONS_USE_ACK; while ( (remaining>0) && (delta<getTimeout()) ) { try { SendResult result = doLoop(selectTimeout, getMaxRetryAttempts(),waitForAck,msg); remaining -= result.getCompleted(); if (result.getFailed() != null) { "parallelNioSender.operation.timedout", Long.toString(getTimeout()))); if (cx == null) { cx = new ChannelException(sm.getString("parallelNioSender.operation.timedout", Long.toString(getTimeout()))); this.disconnect(); } catch (Exception e) {
@Override public synchronized void disconnect() { setConnected(false); try { close(); } catch (Exception x) { // Ignore } }