Package org.jgroups.tests.perf
Class ProgrammaticUPerf
- java.lang.Object
-
- org.jgroups.tests.perf.ProgrammaticUPerf
-
- All Implemented Interfaces:
MethodInvoker,Receiver
public class ProgrammaticUPerf extends java.lang.Object implements Receiver, MethodInvoker
Tests the UNICAST by invoking unicast RPCs between a sender and a receiver. Mimicks the DIST mode in Infinispan
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classProgrammaticUPerf.Invoker
-
Field Summary
Fields Modifier and Type Field Description protected booleanallow_local_getsprivate static shortALLOW_LOCAL_GETSprotected intanycast_countprivate byte[]BUFFERprivate JChannelchannelprivate java.util.concurrent.atomic.AtomicIntegerCOUNTERprivate RpcDispatcherdispprotected java.lang.Threadevent_loop_threadprotected static java.lang.Stringformatprivate static shortGETprivate static shortGET_CONFIG(package private) static java.lang.Stringgroupnameprivate Addresslocal_addrprotected booleanloopingprotected java.util.List<Address>membersprotected intmsg_sizeprotected java.util.concurrent.atomic.LongAddernum_readsprotected intnum_threadsprotected java.util.concurrent.atomic.LongAddernum_writesprotected booleanoobprotected booleanprint_detailsprivate static shortPRINT_DETAILSprotected booleanprint_invokersprivate static shortPRINT_INVOKERSprivate static shortPUTprivate static shortQUIT_ALLprotected doubleread_percentageprivate static shortSET_ANYCAST_COUNTprivate static shortSET_MSG_SIZEprivate static shortSET_NUM_THREADSprivate static shortSET_OOBprivate static shortSET_READ_PERCENTAGEprivate static shortSET_SYNCprivate static shortSET_TIMEprivate static shortSTARTprotected booleansyncprotected inttimeprotected Viewview
-
Constructor Summary
Constructors Constructor Description ProgrammaticUPerf()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowLocalGets()voidallowLocalGets(boolean a)protected voidapplyConfig(PerfUtil.Config config)voideventLoop()byte[]get(int key)intgetAnycastCount()PerfUtil.ConfiggetConfig()intgetMsgSize()intgetNumThreads()booleangetOOB()doublegetReadPercentage()booleangetSync()intgetTime()(package private) static voidhelp()voidinit(java.lang.String name, AddressGenerator generator, java.lang.String bind_addr, int bind_port, boolean udp, java.lang.String mcast_addr, int mcast_port, java.lang.String initial_hosts)(package private) voidinvoke(short method_id, java.lang.Object... args)java.lang.Objectinvoke(java.lang.Object target, short method_id, java.lang.Object[] args)An implementation invokes a method associated with a given ID and the given args against a target objectstatic voidmain(java.lang.String[] args)(package private) intparseAnycastCount()(package private) static doubleparseReadPercentage()protected static java.lang.Stringprint(AverageMinMax avg, boolean details)protected java.lang.StringprintAverage(long start_time)booleanprintDetails()voidprintDetails(boolean p)booleanprintInvokers()voidprintInvokers(boolean p)protected voidprintView()voidput(int key, byte[] val)voidquitAll()voidsetAnycastCount(int t)voidsetMsgSize(int t)voidsetNumThreads(int t)voidsetOOB(boolean oob)voidsetReadPercentage(double r)voidsetSync(boolean s)voidsetTime(int t)(package private) voidstartBenchmark()Kicks off the benchmark on all cluster nodesprotected voidstartEventThread()PerfUtil.ResultsstartTest()(package private) voidstop()protected voidstopEventThread()voidviewAccepted(View new_view)Called when a change in membership has occurred.
-
-
-
Field Detail
-
channel
private JChannel channel
-
local_addr
private Address local_addr
-
disp
private RpcDispatcher disp
-
groupname
static final java.lang.String groupname
- See Also:
- Constant Field Values
-
members
protected final java.util.List<Address> members
-
view
protected volatile View view
-
looping
protected volatile boolean looping
-
event_loop_thread
protected java.lang.Thread event_loop_thread
-
num_reads
protected final java.util.concurrent.atomic.LongAdder num_reads
-
num_writes
protected final java.util.concurrent.atomic.LongAdder num_writes
-
sync
protected boolean sync
-
oob
protected boolean oob
-
num_threads
protected int num_threads
-
time
protected int time
-
msg_size
protected int msg_size
-
anycast_count
protected int anycast_count
-
read_percentage
protected double read_percentage
-
allow_local_gets
protected boolean allow_local_gets
-
print_invokers
protected boolean print_invokers
-
print_details
protected boolean print_details
-
START
private static final short START
- See Also:
- Constant Field Values
-
GET
private static final short GET
- See Also:
- Constant Field Values
-
PUT
private static final short PUT
- See Also:
- Constant Field Values
-
GET_CONFIG
private static final short GET_CONFIG
- See Also:
- Constant Field Values
-
SET_SYNC
private static final short SET_SYNC
- See Also:
- Constant Field Values
-
SET_OOB
private static final short SET_OOB
- See Also:
- Constant Field Values
-
SET_NUM_THREADS
private static final short SET_NUM_THREADS
- See Also:
- Constant Field Values
-
SET_TIME
private static final short SET_TIME
- See Also:
- Constant Field Values
-
SET_MSG_SIZE
private static final short SET_MSG_SIZE
- See Also:
- Constant Field Values
-
SET_ANYCAST_COUNT
private static final short SET_ANYCAST_COUNT
- See Also:
- Constant Field Values
-
SET_READ_PERCENTAGE
private static final short SET_READ_PERCENTAGE
- See Also:
- Constant Field Values
-
ALLOW_LOCAL_GETS
private static final short ALLOW_LOCAL_GETS
- See Also:
- Constant Field Values
-
PRINT_INVOKERS
private static final short PRINT_INVOKERS
- See Also:
- Constant Field Values
-
PRINT_DETAILS
private static final short PRINT_DETAILS
- See Also:
- Constant Field Values
-
QUIT_ALL
private static final short QUIT_ALL
- See Also:
- Constant Field Values
-
COUNTER
private final java.util.concurrent.atomic.AtomicInteger COUNTER
-
BUFFER
private byte[] BUFFER
-
format
protected static final java.lang.String format
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSync
public boolean getSync()
-
setSync
public void setSync(boolean s)
-
getOOB
public boolean getOOB()
-
setOOB
public void setOOB(boolean oob)
-
getNumThreads
public int getNumThreads()
-
setNumThreads
public void setNumThreads(int t)
-
getTime
public int getTime()
-
setTime
public void setTime(int t)
-
getMsgSize
public int getMsgSize()
-
setMsgSize
public void setMsgSize(int t)
-
getAnycastCount
public int getAnycastCount()
-
setAnycastCount
public void setAnycastCount(int t)
-
getReadPercentage
public double getReadPercentage()
-
setReadPercentage
public void setReadPercentage(double r)
-
allowLocalGets
public boolean allowLocalGets()
-
allowLocalGets
public void allowLocalGets(boolean a)
-
printInvokers
public boolean printInvokers()
-
printInvokers
public void printInvokers(boolean p)
-
printDetails
public boolean printDetails()
-
printDetails
public void printDetails(boolean p)
-
init
public void init(java.lang.String name, AddressGenerator generator, java.lang.String bind_addr, int bind_port, boolean udp, java.lang.String mcast_addr, int mcast_port, java.lang.String initial_hosts) throws java.lang.Throwable- Throws:
java.lang.Throwable
-
stop
void stop()
-
startEventThread
protected void startEventThread()
-
stopEventThread
protected void stopEventThread()
-
viewAccepted
public void viewAccepted(View new_view)
Description copied from interface:ReceiverCalled when a change in membership has occurred. No long running actions, sending of messages or anything that could block should be done in this callback. If some long running action needs to be performed, it should be done in a separate thread.
Note that on reception of the first view (a new member just joined), the channel will not yet be in the connected state. This only happens whenJChannel.connect(String)returns.- Specified by:
viewAcceptedin interfaceReceiver
-
invoke
public java.lang.Object invoke(java.lang.Object target, short method_id, java.lang.Object[] args) throws java.lang.ExceptionDescription copied from interface:MethodInvokerAn implementation invokes a method associated with a given ID and the given args against a target object- Specified by:
invokein interfaceMethodInvoker- Parameters:
target- The object against which to invoke the methodmethod_id- The ID of the method. The implementation must assign unique IDs and associate them somehow with a method to invokeargs- The arguments of the invocation- Returns:
- The result. It may be null if a method returns void
- Throws:
java.lang.Exception- Thrown if the invocation threw an exception. The real exception may be wrapped in anInvocationTargetException.
-
startTest
public PerfUtil.Results startTest() throws java.lang.Exception
- Throws:
java.lang.Exception
-
quitAll
public void quitAll()
-
printAverage
protected java.lang.String printAverage(long start_time)
-
get
public byte[] get(int key)
-
put
public void put(int key, byte[] val)
-
getConfig
public PerfUtil.Config getConfig()
-
applyConfig
protected void applyConfig(PerfUtil.Config config)
-
eventLoop
public void eventLoop()
-
invoke
void invoke(short method_id, java.lang.Object... args) throws java.lang.Exception- Throws:
java.lang.Exception
-
startBenchmark
void startBenchmark()
Kicks off the benchmark on all cluster nodes
-
parseReadPercentage
static double parseReadPercentage() throws java.lang.Exception- Throws:
java.lang.Exception
-
parseAnycastCount
int parseAnycastCount() throws java.lang.Exception- Throws:
java.lang.Exception
-
printView
protected void printView()
-
print
protected static java.lang.String print(AverageMinMax avg, boolean details)
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception- Throws:
java.lang.Exception
-
help
static void help()
-
-