public void registerCrossPlatformClassBinaryCache( String fulLQName, byte[] binary ) { try { while (cplock.compareAndSet(false, true)) { } // spin minBinNamesBytez.put(fulLQName, binary); } finally { cplock.set(false); } }
@Override public Response<T> execute() throws IOException { if (!executed.compareAndSet(false, true)) { throw new IllegalStateException("Already executed"); } if (canceled.get()) { throw new IOException("canceled"); } if (response != null) { return response; } throw FakeCall.<Error>sneakyThrow2(error); }
@Override public void run() { long currentTimeMillis = System.currentTimeMillis(); long lastHeartbeat = getLastHeartbeat(); LOG.debug("BOLT - current time : {}, last heartbeat : {}, worker timeout (ms) : {}", currentTimeMillis, lastHeartbeat, workerTimeoutMills); if (currentTimeMillis - lastHeartbeat > workerTimeoutMills) { bolt.die(new RuntimeException("subprocess heartbeat timeout")); } sendHeartbeatFlag.compareAndSet(false, true); } }
@Override public CompletableFuture<ClusterCommunicationService> start() { if (started.compareAndSet(false, true)) { log.info("Started"); } return CompletableFuture.completedFuture(this); }
@Override public void dispose() { if (!disposed.compareAndSet(false, true)) { return; } LOG.debug("Disposing V4L4J device {}", videoFile); if (open.get()) { close(); } videoDevice.releaseControlList(); videoDevice.release(); LOG.debug("V4L4J device {} has been disposed", videoFile); }
private void processWhenOwnLeader() { if (isLeader.compareAndSet(false, true) && isOnline.get()) { LOGGER.info("[LeaderElection] 机器{}成为leader", getCurrentNode()); //leader续租任务 leaderRenewedRentFuture = startLeaderRenewedRentTask(); renewedRentFailedCount.set(ZERO); try { listener.own(); } catch (Exception e) { LOGGER.error("[LeaderElection] 执行leader own()出现异常", e); } } }
if (this.active.get() && this.closed.compareAndSet(false, true)) { if (logger.isDebugEnabled()) { logger.debug("Closing " + this); this.active.set(false);
@Override public CompletableFuture<Void> stop() { if (started.compareAndSet(true, false)) { log.info("Stopped"); } return CompletableFuture.completedFuture(null); }
@Override public void run() { long currentTimeMillis = System.currentTimeMillis(); long lastHeartbeat = getLastHeartbeat(); LOG.debug("BOLT - current time : {}, last heartbeat : {}, worker timeout (ms) : {}", currentTimeMillis, lastHeartbeat, workerTimeoutMills); if (currentTimeMillis - lastHeartbeat > workerTimeoutMills) { bolt.die(new RuntimeException("subprocess heartbeat timeout")); } sendHeartbeatFlag.compareAndSet(false, true); } }
public void run() { while (_running) { try { if (sendHeartbeatFlag.get()) { LOG.debug("BOLT - sending heartbeat request to subprocess"); String genId = Long.toString(_rand.nextLong()); _process.writeBoltMsg(createHeartbeatBoltMessage(genId)); sendHeartbeatFlag.compareAndSet(true, false); } Object write = _pendingWrites.poll(1, SECONDS); if (write instanceof BoltMsg) { _process.writeBoltMsg((BoltMsg) write); } else if (write instanceof List<?>) { _process.writeTaskIds((List<Integer>) write); } else if (write != null) { throw new RuntimeException("Unknown class type to write: " + write.getClass().getName()); } } catch (InterruptedException ignored) { } catch (Throwable t) { die(t); } } }
/** * Unregister the ShutdownHook */ public void unregister() { if (registered.get() && registered.compareAndSet(true, false)) { Runtime.getRuntime().removeShutdownHook(getDubboShutdownHook()); } }
public byte[] getCrossPlatformBinaryCache(String symbolicName) { try { while ( cplock.compareAndSet(false, true)) { } // spin return minBinNamesBytez.get(symbolicName); } finally { cplock.set(false); } }
/** * Completely disable locking mechanism. After this method is invoked, the lock will not have * any effect on the webcam runtime. */ public void disable() { if (disabled.compareAndSet(false, true)) { LOG.info("Locking mechanism has been disabled in {}", webcam); if (updater != null) { updater.interrupt(); } } }
@Override public void enableRecv() { if (throttled.compareAndSet(true, false)) { if (LOG.isDebugEnabled()) { LOG.debug("Sending unthrottle event {}", this); } channel.pipeline().fireUserEventTriggered(AutoReadEvent.ENABLE); } }
public void run() { while (_running) { try { if (sendHeartbeatFlag.get()) { LOG.debug("BOLT - sending heartbeat request to subprocess"); String genId = Long.toString(_rand.nextLong()); _process.writeBoltMsg(createHeartbeatBoltMessage(genId)); sendHeartbeatFlag.compareAndSet(true, false); } Object write = _pendingWrites.poll(1, SECONDS); if (write instanceof BoltMsg) { _process.writeBoltMsg((BoltMsg) write); } else if (write instanceof List<?>) { _process.writeTaskIds((List<Integer>) write); } else if (write != null) { throw new RuntimeException( "Unknown class type to write: " + write.getClass().getName()); } } catch (InterruptedException e) { // It's likely that Bolt is shutting down so no need to die. // just ignore and loop will be terminated eventually } catch (Throwable t) { die(t); } } }
/** * Register the ShutdownHook */ public void register() { if (!registered.get() && registered.compareAndSet(false, true)) { Runtime.getRuntime().addShutdownHook(getDubboShutdownHook()); } }
public void registerClazzFromOtherLoader( Class cl ) { while( ! classCacheLock.compareAndSet(false,true) ); classCache.put(cl.getName(),cl); classCacheLock.set(false); }
@Override public synchronized void start() { if (_running.compareAndSet(false, true)) { _thread.start(); LOG.info("{}/ConsumeService started", _name); } }
/** * Note that the netty implementation ignores the <code>waitDisableRecv</code> * parameter and is always asynchronous. * @param waitDisableRecv ignored by this implementation. */ @Override public void disableRecv(boolean waitDisableRecv) { if (throttled.compareAndSet(false, true)) { if (LOG.isDebugEnabled()) { LOG.debug("Throttling - disabling recv {}", this); } channel.pipeline().fireUserEventTriggered(AutoReadEvent.DISABLE); } }
/** * Register the ShutdownHook */ public void register() { if (!registered.get() && registered.compareAndSet(false, true)) { Runtime.getRuntime().addShutdownHook(getDubboShutdownHook()); } }