public void execute(Runnable task, boolean can_block) { submitToPool(task instanceof TimeScheduler.Task? new RecurringTask(task, TaskType.dynamic, 0, ((TimeScheduler.Task)task).nextInterval(), TimeUnit.MILLISECONDS, can_block) : new Task(task, can_block)); // we'll execute the task directly }
public void setAddress(String address) { boolean changed=false; if(!Util.match(this.address, address)) changed=true; super.setAddress(address); if(changed) renameThreads(); }
protected static Buffer streamableToBuffer(byte req_or_rsp, byte type, Streamable obj) throws Exception { int expected_size=obj instanceof SizeStreamable? ((SizeStreamable)obj).serializedSize() : 100; ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(expected_size); out.writeByte(req_or_rsp); out.writeByte(type); obj.writeTo(out); return new Buffer(out.buffer(), 0, out.position()); }
protected Tuple<InputStream,Object> createStreamToProvider(final Address provider, final StateHeader hdr) { Util.close(input_stream); input_stream=new BlockingInputStream(buffer_size); return new Tuple<>(input_stream, null); }
protected static Buffer marshal(final ViewId view_id) { try { final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(Util.size(view_id)); Util.writeViewId(view_id, out); return out.getBuffer(); } catch(Exception ex) { return null; } }
public static Buffer streamableToBuffer(Streamable obj) { int expected_size=obj instanceof SizeStreamable? ((SizeStreamable)obj).serializedSize() +1 : 512; final ByteArrayDataOutputStream out=new ByteArrayDataOutputStream(expected_size); try { Util.writeStreamable(obj,out); return out.getBuffer(); } catch(Exception ex) { return null; } }
public MutableDigest set(Digest digest) { if(digest == null) return this; for(Entry entry: digest) set(entry.getMember(), entry.getHighestDeliveredSeqno(), entry.getHighestReceivedSeqno()); return this; }
/** * Creates an instance of {@link NioServer} that opens a server channel and listens for connections. * Needs to be started next. * @param bind_addr The local address to bind to. If null, the address will be picked by the OS * @param port The local port to bind to * @throws Exception Thrown if the creation failed */ public NioServer(InetAddress bind_addr, int port) throws Exception { this(new DefaultThreadFactory("nio", false), new DefaultSocketFactory(), bind_addr, port, port+50, null, 0); }
public void readFrom(DataInput in) throws Exception { attr_name=Bits.readString(in); attr_value=Util.readByteBuffer(in); } }
public Address generateAddress() { if(first) { first=false; return new UUID(0, initial_val); } return Util.createRandomAddress(); } }
public void readFrom(DataInput in) throws Exception { logical_addr=Util.readAddress(in); physical_addr=Util.readAddress(in); logical_name=Bits.readString(in); }
public void setClusterName(String cluster_name) { boolean changed=false; if(!Util.match(this.clusterName, cluster_name)) changed=true; super.setClusterName(cluster_name); if(changed) renameThreads(); }
public void readFrom(DataInput in) throws Exception { owner=new Owner(); owner.readFrom(in); name=Bits.readString(in); }
public Rsp<T> setValue(T val) { this.value=val; setReceived(); this.flags=Util.clearFlags(flags, IS_EXCEPTION); // clear the exception flag just in case it is set return this; }
public void readFrom(DataInput in) throws Exception { num_gets=Bits.readLong(in); num_puts=Bits.readLong(in); time=Bits.readLong(in); avg_gets=Util.readStreamable(AverageMinMax::new, in); avg_puts=Util.readStreamable(AverageMinMax::new, in); }
public void readFrom(DataInput in) throws Exception { attr_name=Bits.readString(in); attr_value=Util.readByteBuffer(in); } }