@Override public void heartbeat() { try { long now = System.currentTimeMillis(); @SuppressWarnings("unchecked") Map.Entry<UniqueId,MapEntry>[] entries = messages.entrySet().toArray(new Map.Entry[messages.size()]); for (int i=0; i<entries.length; i++ ) { MapEntry entry = entries[i].getValue(); if ( entry.expired(now,expire) ) { if(log.isInfoEnabled()) log.info("Message ["+entry.id+"] has expired. Removing."); messages.remove(entry.id); }//end if } } catch ( Exception x ) { log.warn("Unable to perform heartbeat on the TwoPhaseCommit interceptor.",x); } finally { super.heartbeat(); } }
@Override public void messageReceived(ChannelMessage msg) { if (okToProcess(msg.getOptions())) { if ( msg.getMessage().getLength() == (START_DATA.length+msg.getUniqueId().length+END_DATA.length) && Arrays.contains(msg.getMessage().getBytesDirect(),0,START_DATA,0,START_DATA.length) && Arrays.contains(msg.getMessage().getBytesDirect(),START_DATA.length+msg.getUniqueId().length,END_DATA,0,END_DATA.length) ) { UniqueId id = new UniqueId(msg.getMessage().getBytesDirect(),START_DATA.length,msg.getUniqueId().length); MapEntry original = messages.get(id); if ( original != null ) { super.messageReceived(original.msg); messages.remove(id); } else log.warn("Received a confirmation, but original message is missing. Id:"+Arrays.toString(id.getBytes())); } else { UniqueId id = new UniqueId(msg.getUniqueId()); MapEntry entry = new MapEntry((ChannelMessage)msg.deepclone(),id,System.currentTimeMillis()); messages.put(id,entry); } } else { super.messageReceived(msg); } }
@Override public void messageReceived(ChannelMessage msg) { if (okToProcess(msg.getOptions())) { if ( msg.getMessage().getLength() == (START_DATA.length+msg.getUniqueId().length+END_DATA.length) && Arrays.contains(msg.getMessage().getBytesDirect(),0,START_DATA,0,START_DATA.length) && Arrays.contains(msg.getMessage().getBytesDirect(),START_DATA.length+msg.getUniqueId().length,END_DATA,0,END_DATA.length) ) { UniqueId id = new UniqueId(msg.getMessage().getBytesDirect(),START_DATA.length,msg.getUniqueId().length); MapEntry original = messages.get(id); if ( original != null ) { super.messageReceived(original.msg); messages.remove(id); } else log.warn("Received a confirmation, but original message is missing. Id:"+Arrays.toString(id.getBytes())); } else { UniqueId id = new UniqueId(msg.getUniqueId()); MapEntry entry = new MapEntry((ChannelMessage)msg.deepclone(),id,System.currentTimeMillis()); messages.put(id,entry); } } else { super.messageReceived(msg); } }
@Override public void heartbeat() { try { long now = System.currentTimeMillis(); Map.Entry<UniqueId,MapEntry>[] entries = messages.entrySet().toArray(new Map.Entry[messages.size()]); for (int i=0; i<entries.length; i++ ) { MapEntry entry = entries[i].getValue(); if ( entry.expired(now,expire) ) { if(log.isInfoEnabled()) log.info("Message ["+entry.id+"] has expired. Removing."); messages.remove(entry.id); }//end if } } catch ( Exception x ) { log.warn("Unable to perform heartbeat on the TwoPhaseCommit interceptor.",x); } finally { super.heartbeat(); } }
@Override public void messageReceived(ChannelMessage msg) { if (okToProcess(msg.getOptions())) { if ( msg.getMessage().getLength() == (START_DATA.length+msg.getUniqueId().length+END_DATA.length) && Arrays.contains(msg.getMessage().getBytesDirect(),0,START_DATA,0,START_DATA.length) && Arrays.contains(msg.getMessage().getBytesDirect(),START_DATA.length+msg.getUniqueId().length,END_DATA,0,END_DATA.length) ) { UniqueId id = new UniqueId(msg.getMessage().getBytesDirect(),START_DATA.length,msg.getUniqueId().length); MapEntry original = messages.get(id); if ( original != null ) { super.messageReceived(original.msg); messages.remove(id); } else log.warn(sm.getString("twoPhaseCommitInterceptor.originalMessage.missing", Arrays.toString(id.getBytes()))); } else { UniqueId id = new UniqueId(msg.getUniqueId()); MapEntry entry = new MapEntry((ChannelMessage)msg.deepclone(),id,System.currentTimeMillis()); messages.put(id,entry); } } else { super.messageReceived(msg); } }
@Override public void heartbeat() { try { long now = System.currentTimeMillis(); @SuppressWarnings("unchecked") Map.Entry<UniqueId,MapEntry>[] entries = messages.entrySet().toArray(new Map.Entry[messages.size()]); for (int i=0; i<entries.length; i++ ) { MapEntry entry = entries[i].getValue(); if ( entry.expired(now,expire) ) { log.info(sm.getString("twoPhaseCommitInterceptor.expiredMessage", entry.id)); messages.remove(entry.id); } } } catch ( Exception x ) { log.warn(sm.getString("twoPhaseCommitInterceptor.heartbeat.failed"),x); } finally { super.heartbeat(); } }
public void messageReceived(ChannelMessage msg) { if (okToProcess(msg.getOptions())) { if ( msg.getMessage().getLength() == (START_DATA.length+msg.getUniqueId().length+END_DATA.length) && Arrays.contains(msg.getMessage().getBytesDirect(),0,START_DATA,0,START_DATA.length) && Arrays.contains(msg.getMessage().getBytesDirect(),START_DATA.length+msg.getUniqueId().length,END_DATA,0,END_DATA.length) ) { UniqueId id = new UniqueId(msg.getMessage().getBytesDirect(),START_DATA.length,msg.getUniqueId().length); MapEntry original = (MapEntry)messages.get(id); if ( original != null ) { super.messageReceived(original.msg); messages.remove(id); } else log.warn("Received a confirmation, but original message is missing. Id:"+Arrays.toString(id.getBytes())); } else { UniqueId id = new UniqueId(msg.getUniqueId()); MapEntry entry = new MapEntry((ChannelMessage)msg.deepclone(),id,System.currentTimeMillis()); messages.put(id,entry); } } else { super.messageReceived(msg); } }
public void heartbeat() { try { long now = System.currentTimeMillis(); Map.Entry[] entries = (Map.Entry[])messages.entrySet().toArray(new Map.Entry[messages.size()]); for (int i=0; i<entries.length; i++ ) { MapEntry entry = (MapEntry)entries[i].getValue(); if ( entry.expired(now,expire) ) { if(log.isInfoEnabled()) log.info("Message ["+entry.id+"] has expired. Removing."); messages.remove(entry.id); }//end if } } catch ( Exception x ) { log.warn("Unable to perform heartbeat on the TwoPhaseCommit interceptor.",x); } finally { super.heartbeat(); } }