Beispiel #1
0
 public static void main(String[] args) {
   CircuitBreaker atomicCircuitBreaker = new AtomicCircuitBreaker();
   IFn wrap =
       (IFn)
           atomicCircuitBreaker.wrap(
               new clojure.lang.AFn() {
                 public Object invoke(Object arg0) throws Exception {
                   if (arg0 == null) throw new IllegalArgumentException("null arg");
                   System.out.println("Invoked with: " + arg0);
                   return arg0;
                 }
               });
   succeed(atomicCircuitBreaker, wrap);
   fail(atomicCircuitBreaker, wrap);
   fail(atomicCircuitBreaker, wrap);
   fail(atomicCircuitBreaker, wrap);
   fail(atomicCircuitBreaker, wrap);
   fail(atomicCircuitBreaker, wrap);
   fail(atomicCircuitBreaker, wrap);
   sleep(1000);
   status(atomicCircuitBreaker);
   fail(atomicCircuitBreaker, wrap);
   sleep(5000);
   succeed(atomicCircuitBreaker, wrap);
 }
Beispiel #2
0
 private static void status(CircuitBreaker atomicCircuitBreaker) {
   System.out.println(RT.printString(atomicCircuitBreaker.getCurrentState()));
 }