public static void main ( String [ ] args ) throws Exception { if ( args . length < 1 ) throw new IllegalArgumentException ( "must supply a set of host:port tuples" ) ; // Build a list of all member addresses to which to connect. List < Address > members = new ArrayList <> ( ) ; for ( String arg : args ) { String [ ] parts = arg . split ( ":" ) ; members . add ( new Address ( parts [ 0 ] , Integer . valueOf ( parts [ 1 ] ) ) ) ; } CopycatClient client = CopycatClient . builder ( ) . withTransport ( new NettyTransport ( ) ) . withConnectionStrategy ( ConnectionStrategies . FIBONACCI_BACKOFF ) . withRecoveryStrategy ( RecoveryStrategies . RECOVER ) . withServerSelectionStrategy ( ServerSelectionStrategies . LEADER ) . withSessionTimeout ( Duration . ofSeconds ( 15 ) ) . build ( ) ; client . serializer ( ) . register ( SetCommand . class , 1 ) ; client . serializer ( ) . register ( GetQuery . class , 2 ) ; client . serializer ( ) . register ( DeleteCommand . class , 3 ) ; client . connect ( members ) . join ( ) ; recursiveSet ( client ) ; while ( client . state ( ) != CopycatClient . State . CLOSED ) { try { Thread . sleep ( 1000 ) ; } catch ( InterruptedException e ) { break ; } } }
Starts the client .