protected void unparkIfNeeded(long size) { long acc_bytes=size > 0? accumulated_bytes.addAndGet(size) : accumulated_bytes.get(); boolean size_exceeded=acc_bytes >= transport.getMaxBundleSize() && accumulated_bytes.compareAndSet(acc_bytes, 0); boolean no_other_threads=num_threads.decrementAndGet() == 0; boolean unpark=size_exceeded || no_other_threads; // only 2 threads at a time should do this in parallel (1st cond and 2nd cond) if(unpark && unparking.compareAndSet(false, true)) { Thread thread=bundler_thread.getThread(); if(thread != null) LockSupport.unpark(thread); unparking.set(false); } }
public void init(TP transport) { this.transport=transport; log=transport.getLog(); output=new ByteArrayDataOutputStream(transport.getMaxBundleSize() + MSG_OVERHEAD); } public void start() {}
public void init() throws Exception { super.init(); int old_frag_size=frag_size; if(frag_size <=0) throw new Exception("frag_size=" + old_frag_size + ", new frag_size=" + frag_size + ": new frag_size is invalid"); TP transport=getTransport(); if(transport != null) { int max_bundle_size=transport.getMaxBundleSize(); if(frag_size >= max_bundle_size) throw new IllegalArgumentException("frag_size (" + frag_size + ") has to be < TP.max_bundle_size (" + max_bundle_size + ")"); } Map<String,Object> info=new HashMap<>(1); info.put("frag_size", frag_size); down_prot.down(new Event(Event.CONFIG, info)); }
public void init() throws Exception { super.init(); int old_frag_size=frag_size; if(frag_size <=0) throw new Exception("frag_size=" + old_frag_size + ", new frag_size=" + frag_size + ": new frag_size is invalid"); TP transport=getTransport(); if(transport != null) { int max_bundle_size=transport.getMaxBundleSize(); if(frag_size >= max_bundle_size) throw new IllegalArgumentException("frag_size (" + frag_size + ") has to be < TP.max_bundle_size (" + max_bundle_size + ")"); } Map<String,Object> info=new HashMap<>(1); info.put("frag_size", frag_size); down_prot.down(new Event(Event.CONFIG, info)); }
public void send(Message msg) throws Exception { num_senders.incrementAndGet(); long size=msg.size(); lock.lock(); try { if(count + size >= transport.getMaxBundleSize()) sendBundledMessages(); addMessage(msg, size); // at this point, we haven't sent our message yet ! if(num_senders.decrementAndGet() == 0) // no other sender threads present at this time sendBundledMessages(); // else there are other sender threads waiting, so our message will be sent by a different thread } finally { lock.unlock(); } } }
public void send(Message msg) throws Exception { if(msg == null) throw new IllegalArgumentException("message must not be null"); num_threads.incrementAndGet(); int tmp_index=getWriteIndex(); // decrements write_permits // System.out.printf("[%d] tmp_index=%d\n", Thread.currentThread().getId(), tmp_index); if(tmp_index == -1) { log.warn("buf is full (num_permits: %d, bundler: %s)\n", write_permits.get(), toString()); num_threads.decrementAndGet(); return; } buf[tmp_index]=msg; long acc_bytes=accumulated_bytes.addAndGet(msg.size()); int current_threads=num_threads.decrementAndGet(); boolean no_other_threads=current_threads == 0; boolean unpark=(acc_bytes >= transport.getMaxBundleSize() && accumulated_bytes.compareAndSet(acc_bytes, 0)) || no_other_threads; // only 2 threads at a time should do this (1st cond and 2nd cond), so we have to reduce this to // 1 thread as advanceWriteIndex() is not thread safe if(unpark && unparking.compareAndSet(false, true)) { int num_advanced=advanceWriteIndex(); size.addAndGet(num_advanced); if(num_advanced > 0) { Thread thread=bundler_thread.getThread(); if(thread != null) LockSupport.unpark(thread); } unparking.set(false); } }
public void init() throws Exception { super.init(); TP transport=getTransport(); sends_can_block=transport instanceof TCP; // UDP and TCP_NIO2 won't block time_service=transport.getTimeService(); if(time_service == null) throw new IllegalStateException("time service from transport is null"); last_sync_sent=new ExpiryCache<>(sync_min_interval); // max bundle size (minus overhead) divided by <long size> times bits per long // Example: for 8000 missing messages, SeqnoList has a serialized size of 1012 bytes, for 64000 messages, the // serialized size is 8012 bytes. Therefore, for a serialized size of 64000 bytes, we can retransmit a max of // 8 * 64000 = 512'000 seqnos // see SeqnoListTest.testSerialization3() int estimated_max_msgs_in_xmit_req=(transport.getMaxBundleSize() -50) * Global.LONG_SIZE; int old_max_xmit_size=max_xmit_req_size; if(max_xmit_req_size <= 0) max_xmit_req_size=estimated_max_msgs_in_xmit_req; else max_xmit_req_size=Math.min(max_xmit_req_size, estimated_max_msgs_in_xmit_req); if(old_max_xmit_size != max_xmit_req_size) log.trace("%s: set max_xmit_req_size from %d to %d", local_addr, old_max_xmit_size, max_xmit_req_size); boolean regular_pool_enabled=(boolean)transport.getValue("thread_pool_enabled"); if(!regular_pool_enabled) log.info("the thread pool is disabled; %s could be removed (JGRP-2069)", getClass().getSimpleName()); }
continue; long size=msg.size(); if(count + size >= transport.getMaxBundleSize()) { num_sends_because_full_queue++; fill_count.add(count); msg=remove_queue.get(i); size=msg.size(); if(count + size >= transport.getMaxBundleSize()) { num_sends_because_full_queue++; fill_count.add(count);
public void run() { while(running) { Message msg=null; try { if((msg=queue.take()) == null) // block until first message is available continue; long size=msg.size(); if(count + size >= transport.getMaxBundleSize()) { num_sends_because_full_queue++; fill_count.add(count); _sendBundledMessages(); } for(;;) { Address dest=msg.dest(); if(!Util.match(dest, target_dest) || count + size >= transport.getMaxBundleSize()) _sendBundledMessages(); _addMessage(msg, size); msg=queue.poll(); if(msg == null) break; size=msg.size(); } _sendBundledMessages(); } catch(Throwable t) { } } }
public void run() { try { int drained=rb.drainToBlocking(remove_queue); if(drained == 1) { output.position(0); sendSingleMessage(remove_queue[0]); return; } for(int i=0; i < drained; i++) { Message msg=remove_queue[i]; long size=msg.size(); if(count + size >= transport.getMaxBundleSize()) sendBundledMessages(); addMessage(msg, msg.size()); } sendBundledMessages(); } catch(Throwable t) { } }
int estimated_max_msgs_in_xmit_req=(transport.getMaxBundleSize() -50) * Global.LONG_SIZE; int old_max_xmit_size=max_xmit_req_size; if(max_xmit_req_size <= 0)
int max_bundle_size=transport.getMaxBundleSize(); byte[] cluster_name=transport.cluster_name.chars(); int start=read_index;
int max_bundle_size=transport.getMaxBundleSize(); byte[] cluster_name=transport.cluster_name.chars(); int sent_msgs=0;
int max_bundle_size=transport.getMaxBundleSize(); byte[] cluster_name=transport.cluster_name.chars(); int start=read_index;
public int getMaxBundleSize() { return tp.getMaxBundleSize(); }
protected void unparkIfNeeded(long size) { long acc_bytes=size > 0? accumulated_bytes.addAndGet(size) : accumulated_bytes.get(); boolean size_exceeded=acc_bytes >= transport.getMaxBundleSize() && accumulated_bytes.compareAndSet(acc_bytes, 0); boolean no_other_threads=num_threads.decrementAndGet() == 0; boolean unpark=size_exceeded || no_other_threads; // only 2 threads at a time should do this in parallel (1st cond and 2nd cond) if(unpark && unparking.compareAndSet(false, true)) { Thread thread=bundler_thread.getThread(); if(thread != null) LockSupport.unpark(thread); unparking.set(false); } }
public void init(TP transport) { this.transport=transport; log=transport.getLog(); output=new ByteArrayDataOutputStream(transport.getMaxBundleSize() + MSG_OVERHEAD); } public void start() {}
public void init() throws Exception { super.init(); int old_frag_size=frag_size; if(frag_size <=0) throw new Exception("frag_size=" + old_frag_size + ", new frag_size=" + frag_size + ": new frag_size is invalid"); TP transport=getTransport(); if(transport != null) { int max_bundle_size=transport.getMaxBundleSize(); if(frag_size >= max_bundle_size) throw new IllegalArgumentException("frag_size (" + frag_size + ") has to be < TP.max_bundle_size (" + max_bundle_size + ")"); } Map<String,Object> info=new HashMap<>(1); info.put("frag_size", frag_size); down_prot.down(new Event(Event.CONFIG, info)); }
public void init() throws Exception { super.init(); int old_frag_size=frag_size; if(frag_size <=0) throw new Exception("frag_size=" + old_frag_size + ", new frag_size=" + frag_size + ": new frag_size is invalid"); TP transport=getTransport(); if(transport != null) { int max_bundle_size=transport.getMaxBundleSize(); if(frag_size >= max_bundle_size) throw new IllegalArgumentException("frag_size (" + frag_size + ") has to be < TP.max_bundle_size (" + max_bundle_size + ")"); } Map<String,Object> info=new HashMap<>(1); info.put("frag_size", frag_size); down_prot.down(new Event(Event.CONFIG, info)); }
public void send(Message msg) throws Exception { num_senders.incrementAndGet(); long size=msg.size(); lock.lock(); try { if(count + size >= transport.getMaxBundleSize()) sendBundledMessages(); addMessage(msg, size); // at this point, we haven't sent our message yet ! if(num_senders.decrementAndGet() == 0) // no other sender threads present at this time sendBundledMessages(); // else there are other sender threads waiting, so our message will be sent by a different thread } finally { lock.unlock(); } } }