本文整理汇总了Java中io.vertx.core.shareddata.Counter类的典型用法代码示例。如果您正苦于以下问题:Java Counter类的具体用法?Java Counter怎么用?Java Counter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Counter类属于io.vertx.core.shareddata包,在下文中一共展示了Counter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: openCircuitBreakerAndHandleError
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T> void openCircuitBreakerAndHandleError(
Consumer<Throwable> errorHandler,
ThrowableErrorConsumer<Throwable, T> onFailureRespond,
Consumer<Throwable> errorMethodHandler,
Consumer<ExecutionResult<T>> resultConsumer,
AsyncResult<T> event,
Lock lock,
Counter counter) {
counter.addAndGet(
LOCK_VALUE,
val -> {
lock.release();
errorHandling(
errorHandler,
onFailureRespond,
errorMethodHandler,
resultConsumer,
Future.failedFuture(event.cause()));
});
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:21,代码来源:ResponseExecution.java
示例2: openCircuitBreakerAndHandleError
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T> void openCircuitBreakerAndHandleError(
Future<ExecutionResult<T>> _blockingHandler,
Consumer<Throwable> _errorHandler,
ThrowableFunction<Throwable, T> _onFailureRespond,
Consumer<Throwable> _errorMethodHandler,
VxmsShared vxmsShared,
Throwable e,
Lock lck,
Counter counter) {
counter.addAndGet(
LOCK_VALUE,
val -> {
lck.release();
final Vertx vertx = vxmsShared.getVertx();
vertx.executeBlocking(
bhandler -> {
T result = handleError(_errorHandler, _onFailureRespond, _errorMethodHandler, e);
if (!_blockingHandler.isComplete()) {
_blockingHandler.complete(new ExecutionResult<>(result, true, true, null));
}
},
false,
res -> {});
});
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:26,代码来源:ResponseBlockingExecution.java
示例3: openCircuitBreakerAndHandleError
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T> void openCircuitBreakerAndHandleError(
Future<ExecutionResult<T>> _resultHandler,
Consumer<Throwable> _errorHandler,
ThrowableFunction<Throwable, T> _onFailureRespond,
Consumer<Throwable> _errorMethodHandler,
VxmsShared vxmsShared,
Throwable e,
Lock lck,
Counter counter) {
counter.addAndGet(
LOCK_VALUE,
val -> {
lck.release();
final Vertx vertx = vxmsShared.getVertx();
vertx.executeBlocking(
bhandler -> {
T result = handleError(_errorHandler, _onFailureRespond, _errorMethodHandler, e);
if (!_resultHandler.isComplete()) {
_resultHandler.complete(new ExecutionResult<>(result, true, true, null));
}
},
false,
res -> {});
});
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:26,代码来源:StepExecution.java
示例4: testAtomicSyncCounter3
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
@Test
public void testAtomicSyncCounter3() {
long max = 3;
vertx
.sharedData()
.getCounter(
"counter1",
resultHandler -> {
final Counter counter = resultHandler.result();
counter.get(
handler -> {
long val = handler.result();
if (val == 0) {
counter.addAndGet(
max,
hhh -> {
System.out.println("::::" + hhh.result());
});
} else {
}
});
});
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:25,代码来源:AtomicCounterTest.java
示例5: getCounter
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
@Override
public void getCounter(final String name, final Handler<AsyncResult<Counter>> resultHandler) {
AtomicLong counter = new AtomicLong();
final AtomicLong prev = counters.putIfAbsent(name, counter);
if (prev != null) {
counter = prev;
}
final AtomicLong theCounter = counter;
final Context context = this.vertx.getOrCreateContext();
context.runOnContext(v -> resultHandler.handle(Future.succeededFuture(new AsynchronousCounter(this.vertx, theCounter))));
}
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:12,代码来源:FakeClusterManager.java
示例6: getCounter
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
@Override
public void getCounter(String name, Handler<AsyncResult<Counter>> resultHandler) {
vertx.executeBlocking(future -> {
try {
Objects.requireNonNull(name);
future.complete(new ZKCounter(name, retryPolicy));
} catch (Exception e) {
future.fail(new VertxException(e));
}
}, resultHandler);
}
开发者ID:IBYoung,项目名称:vert.3x-gateway,代码行数:12,代码来源:ZookeeperClusterManager.java
示例7: executeInitialState
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T> void executeInitialState(
int _retry,
long _timeout,
ThrowableFutureConsumer<T> _userOperation,
VxmsShared vxmsShared,
Future<T> operationResult,
Lock lock,
Counter counter) {
final long initialRetryCounterValue = (long) (_retry + 1);
counter.addAndGet(
initialRetryCounterValue,
rHandler ->
executeDefaultState(_timeout, _userOperation, vxmsShared, operationResult, lock));
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:15,代码来源:ResponseExecution.java
示例8: handleStatefulError
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T> void handleStatefulError(
String _methodId,
int _retry,
long _timeout,
long _circuitBreakerTimeout,
ThrowableFutureConsumer<T> _userOperation,
Consumer<Throwable> errorHandler,
ThrowableErrorConsumer<Throwable, T> onFailureRespond,
Consumer<Throwable> errorMethodHandler,
VxmsShared vxmsShared,
Consumer<ExecutionResult<T>> resultConsumer,
AsyncResult<T> event,
Lock lock,
Counter counter,
AsyncResult<Long> valHandler) {
long count = valHandler.result();
if (count <= DEFAULT_LONG_VALUE) {
setCircuitBreakerReleaseTimer(_retry, _circuitBreakerTimeout, vxmsShared, counter);
openCircuitBreakerAndHandleError(
errorHandler, onFailureRespond, errorMethodHandler, resultConsumer, event, lock, counter);
} else {
lock.release();
retry(
_methodId,
_retry,
_timeout,
_circuitBreakerTimeout,
_userOperation,
errorHandler,
onFailureRespond,
errorMethodHandler,
vxmsShared,
resultConsumer,
event);
}
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:37,代码来源:ResponseExecution.java
示例9: executeInitialState
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T, V> void executeInitialState(
int _retry,
long _timeout,
ThrowableFutureBiConsumer<T, V> step,
T inputValue,
VxmsShared vxmsShared,
Future<V> operationResult,
Lock lock,
Counter counter) {
final long initialRetryCounterValue = (long) (_retry + 1);
counter.addAndGet(
initialRetryCounterValue,
rHandler ->
executeDefaultState(_timeout, step, inputValue, vxmsShared, operationResult, lock));
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:16,代码来源:StepExecution.java
示例10: handleStatefulError
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T, V> void handleStatefulError(
String _methodId,
int _retry,
long _timeout,
long _circuitBreakerTimeout,
ThrowableFutureBiConsumer<T, V> step,
T inputValue,
Consumer<Throwable> errorHandler,
ThrowableErrorConsumer<Throwable, V> onFailureRespond,
Consumer<Throwable> errorMethodHandler,
VxmsShared vxmsShared,
Consumer<ExecutionResult<V>> resultConsumer,
AsyncResult<V> event,
Lock lock,
Counter counter,
AsyncResult<Long> valHandler) {
long count = valHandler.result();
if (count <= DEFAULT_LONG_VALUE) {
setCircuitBreakerReleaseTimer(_retry, _circuitBreakerTimeout, vxmsShared, counter);
openCircuitBreakerAndHandleError(
errorHandler, onFailureRespond, errorMethodHandler, resultConsumer, event, lock, counter);
} else {
lock.release();
retry(
_methodId,
_retry,
_timeout,
_circuitBreakerTimeout,
step,
inputValue,
errorHandler,
onFailureRespond,
errorMethodHandler,
vxmsShared,
resultConsumer,
event);
}
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:39,代码来源:StepExecution.java
示例11: executeInitialState
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T> void executeInitialState(
String _methodId,
ThrowableSupplier<T> _supplier,
Future<ExecutionResult<T>> _blockingHandler,
Consumer<Throwable> _errorHandler,
ThrowableFunction<Throwable, T> _onFailureRespond,
Consumer<Throwable> _errorMethodHandler,
VxmsShared vxmsShared,
Throwable _t,
int _retry,
long _timeout,
long _circuitBreakerTimeout,
long _delay,
Lock lock,
Counter counter) {
final long initialRetryCounterValue = (long) (_retry + 1);
counter.addAndGet(
initialRetryCounterValue,
rHandler ->
executeDefault(
_methodId,
_supplier,
_blockingHandler,
_errorHandler,
_onFailureRespond,
_errorMethodHandler,
vxmsShared,
_t,
_retry,
_timeout,
_circuitBreakerTimeout,
_delay,
lock));
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:35,代码来源:ResponseBlockingExecution.java
示例12: setCircuitBreakerReleaseTimer
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static void setCircuitBreakerReleaseTimer(
VxmsShared vxmsShared, int _retry, long _circuitBreakerTimeout, Counter counter) {
final long initialRetryCounterValue = (long) (_retry + 1);
final Vertx vertx = vxmsShared.getVertx();
vertx.setTimer(
_circuitBreakerTimeout, timer -> counter.addAndGet(initialRetryCounterValue, val -> {}));
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:8,代码来源:ResponseBlockingExecution.java
示例13: executeInitialState
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T, V> void executeInitialState(
String _methodId,
ThrowableFunction<T, V> step,
T value,
Future<ExecutionResult<V>> _resultHandler,
Consumer<Throwable> _errorHandler,
ThrowableFunction<Throwable, V> _onFailureRespond,
Consumer<Throwable> _errorMethodHandler,
VxmsShared vxmsShared,
Throwable _t,
int _retry,
long _timeout,
long _circuitBreakerTimeout,
long _delay,
Lock lock,
Counter counter) {
final long initialRetryCounterValue = (long) (_retry + 1);
counter.addAndGet(
initialRetryCounterValue,
rHandler ->
executeDefault(
_methodId,
step,
value,
_resultHandler,
_errorHandler,
_onFailureRespond,
_errorMethodHandler,
vxmsShared,
_t,
_retry,
_timeout,
_circuitBreakerTimeout,
_delay,
lock));
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:37,代码来源:StepExecution.java
示例14: openCircuitAndHandleError
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T> void openCircuitAndHandleError(
String methodId,
VxmsShared vxmsShared,
Consumer<Throwable> errorMethodHandler,
Message<Object> requestMessage,
Encoder encoder,
Consumer<Throwable> errorHandler,
ThrowableErrorConsumer<Throwable, T> onFailureRespond,
DeliveryOptions responseDeliveryOptions,
int retryCount,
long timeout,
long circuitBreakerTimeout,
RecursiveExecutor<T> executor,
AsyncResult<Message<Object>> event,
Lock lock,
Counter counter) {
resetLockTimer(vxmsShared, retryCount, circuitBreakerTimeout, counter);
lockAndHandle(
counter,
val -> {
final Throwable cause = event.cause();
handleError(
methodId,
vxmsShared,
errorMethodHandler,
requestMessage,
encoder,
errorHandler,
onFailureRespond,
responseDeliveryOptions,
retryCount,
timeout,
circuitBreakerTimeout,
executor,
lock,
cause);
});
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:39,代码来源:EventbusBridgeExecution.java
示例15: resetLockTimer
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static void resetLockTimer(
VxmsShared vxmsShared, int retryCount, long circuitBreakerTimeout, Counter counter) {
final Vertx vertx = vxmsShared.getVertx();
vertx.setTimer(
circuitBreakerTimeout,
timer -> counter.addAndGet(Integer.valueOf(retryCount + 1).longValue(), val -> {}));
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:8,代码来源:EventbusBridgeExecution.java
示例16: openCircuitAndHandleError
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T> void openCircuitAndHandleError(
String methodId,
VxmsShared vxmsShared,
Consumer<Throwable> errorMethodHandler,
Message<Object> requestMessage,
Encoder encoder,
Consumer<Throwable> errorHandler,
ThrowableFunction<Throwable, T> onFailureRespond,
DeliveryOptions responseDeliveryOptions,
int retryCount,
long timeout,
long delay,
long circuitBreakerTimeout,
RecursiveExecutor<T> executor,
AsyncResult<Message<Object>> event,
Lock lock,
Counter counter) {
resetLockTimer(vxmsShared, retryCount, circuitBreakerTimeout, counter);
lockAndHandle(
counter,
val -> {
final Throwable cause = event.cause();
handleError(
methodId,
vxmsShared,
errorMethodHandler,
requestMessage,
encoder,
errorHandler,
onFailureRespond,
responseDeliveryOptions,
retryCount,
timeout,
delay,
circuitBreakerTimeout,
executor,
lock,
cause);
});
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:41,代码来源:EventbusBridgeExecution.java
示例17: getCounter
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
/**
* Get a local counter. The counter will be passed to the handler.
*
* @param name the name of the counter.
* @param resultHandler the handler
*/
public void getCounter(String name, Handler<AsyncResult<Counter>> resultHandler) {
Objects.requireNonNull(name, "name");
Objects.requireNonNull(resultHandler, "resultHandler");
Counter counter = this.localCounters
.computeIfAbsent(name, (n) -> new AsynchronousCounter((VertxInternal) this.vertx));
Context context = this.vertx.getOrCreateContext();
context.runOnContext((v) -> resultHandler.handle(Future.succeededFuture(counter)));
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:15,代码来源:LocalData.java
示例18: executeInitialState
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T> void executeInitialState(
int retry,
long timeout,
ThrowableFutureConsumer<T> _userOperation,
VxmsShared vxmsShared,
Future<T> operationResult,
Lock lock,
Counter counter) {
final long initialRetryCounterValue = (long) (retry + 1);
counter.addAndGet(
initialRetryCounterValue,
rHandler ->
executeDefaultState(timeout, _userOperation, vxmsShared, operationResult, lock));
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:15,代码来源:ResponseExecution.java
示例19: handleStatefulError
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T> void handleStatefulError(
String methodId,
int retry,
long timeout,
long circuitBreakerTimeout,
ThrowableFutureConsumer<T> _userOperation,
Consumer<Throwable> errorHandler,
ThrowableErrorConsumer<Throwable, T> onFailureRespond,
Consumer<Throwable> errorMethodHandler,
VxmsShared vxmsShared,
Consumer<ExecutionResult<T>> resultConsumer,
AsyncResult<T> event,
Lock lock,
Counter counter,
AsyncResult<Long> valHandler) {
long count = valHandler.result();
if (count <= DEFAULT_LONG_VALUE) {
setCircuitBreakerReleaseTimer(retry, circuitBreakerTimeout, vxmsShared.getVertx(), counter);
openCircuitBreakerAndHandleError(
errorHandler, onFailureRespond, errorMethodHandler, resultConsumer, event, lock, counter);
} else {
lock.release();
retry(
methodId,
retry,
timeout,
circuitBreakerTimeout,
_userOperation,
errorHandler,
onFailureRespond,
errorMethodHandler,
vxmsShared,
resultConsumer,
event);
}
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:37,代码来源:ResponseExecution.java
示例20: executeInitialState
import io.vertx.core.shareddata.Counter; //导入依赖的package包/类
private static <T, V> void executeInitialState(
int retry,
long timeout,
ThrowableFutureBiConsumer<T, V> _step,
T _inputValue,
VxmsShared vxmsShared,
Future<V> operationResult,
Lock lock,
Counter counter) {
final long initialRetryCounterValue = (long) (retry + 1);
counter.addAndGet(
initialRetryCounterValue,
rHandler ->
executeDefaultState(timeout, _step, _inputValue, vxmsShared, operationResult, lock));
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:16,代码来源:StepExecution.java
注:本文中的io.vertx.core.shareddata.Counter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论