org.redisson.Redisson.getSemaphore()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中org.redisson.Redisson.getSemaphore方法的一些代码示例,展示了Redisson.getSemaphore的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Redisson.getSemaphore方法的具体详情如下:
包路径:org.redisson.Redisson
类名称:Redisson
方法名:getSemaphore

Redisson.getSemaphore介绍

暂无

代码示例

代码示例来源:origin: redisson/redisson

private void sendSync(boolean sync, List<Object> msg) {
  if (sync) {
    RSemaphore semaphore = redisson.getSemaphore(getSyncName(msg.get(2)));
    semaphore.release();
  }
}

代码示例来源:origin: redisson/redisson

private void sendSync(boolean sync, List<Object> msg) {
  if (sync) {
    RSemaphore semaphore = redisson.getSemaphore(getSyncName(msg.get(2)));
    semaphore.release();
  }
}

代码示例来源:origin: redisson/redisson

void waitSync(List<Object> result) {
  if (result.size() < 2) {
    return;
  }
  
  Long syncs = (Long) result.get(result.size() - 2);
  Double syncId = (Double) result.get(result.size() - 1);
  if (syncs != null && syncs > 0) {
    RSemaphore semaphore = redisson.getSemaphore(getSyncName(syncId));
    try {
      semaphore.acquire(syncs.intValue());
      semaphore.delete();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
}

代码示例来源:origin: redisson/redisson

void waitSync(List<Object> result) {
  if (result.size() < 2) {
    return;
  }
  
  Long syncs = (Long) result.get(result.size() - 2);
  Double syncId = (Double) result.get(result.size() - 1);
  if (syncs != null && syncs > 0) {
    RSemaphore semaphore = redisson.getSemaphore(getSyncName(syncId));
    try {
      semaphore.acquire(syncs.intValue());
      semaphore.delete();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
}

代码示例来源:origin: redisson/redisson

@Override
  public void onMessage(CharSequence channel, String id) {
    redisson.getAtomicLong(workersCounterName + ":" + id).getAndAdd(workers);
    redisson.getSemaphore(workersSemaphoreName + ":" + id).release();
  }
});

代码示例来源:origin: redisson/redisson

@Override
  public void onMessage(CharSequence channel, String id) {
    redisson.getAtomicLong(workersCounterName + ":" + id).getAndAdd(workers);
    redisson.getSemaphore(workersSemaphoreName + ":" + id).release();
  }
});

代码示例来源:origin: redisson/redisson

@Override
public int countActiveWorkers() {
  String id = generateRequestId();
  int subscribers = (int) workersTopic.publish(id);
  if (subscribers == 0) {
    return 0;
  }
  RSemaphore semaphore = redisson.getSemaphore(workersSemaphoreName + ":" + id);
  try {
    semaphore.tryAcquire(subscribers, 10, TimeUnit.MINUTES);
  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
  }
  RAtomicLong atomicLong = redisson.getAtomicLong(workersCounterName + ":" + id);
  long result = atomicLong.get();
  redisson.getKeys().delete(semaphore, atomicLong);
  return (int) result;
}

代码示例来源:origin: redisson/redisson

@Override
public int countActiveWorkers() {
  String id = generateRequestId();
  int subscribers = (int) workersTopic.publish(id);
  if (subscribers == 0) {
    return 0;
  }
  RSemaphore semaphore = redisson.getSemaphore(workersSemaphoreName + ":" + id);
  try {
    semaphore.tryAcquire(subscribers, 10, TimeUnit.MINUTES);
  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
  }
  RAtomicLong atomicLong = redisson.getAtomicLong(workersCounterName + ":" + id);
  long result = atomicLong.get();
  redisson.getKeys().delete(semaphore, atomicLong);
  return (int) result;
}

代码示例来源:origin: org.redisson/redisson

private void sendSync(boolean sync, List<Object> msg) {
  if (sync) {
    RSemaphore semaphore = redisson.getSemaphore(getSyncName(msg.get(2)));
    semaphore.release();
  }
}

代码示例来源:origin: org.redisson/redisson

void waitSync(List<Object> result) {
  if (result.size() < 2) {
    return;
  }
  
  Long syncs = (Long) result.get(result.size() - 2);
  Double syncId = (Double) result.get(result.size() - 1);
  if (syncs != null && syncs > 0) {
    RSemaphore semaphore = redisson.getSemaphore(getSyncName(syncId));
    try {
      semaphore.acquire(syncs.intValue());
      semaphore.delete();
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
}

代码示例来源:origin: org.redisson/redisson

@Override
  public void onMessage(CharSequence channel, String id) {
    redisson.getAtomicLong(workersCounterName + ":" + id).getAndAdd(workers);
    redisson.getSemaphore(workersSemaphoreName + ":" + id).release();
  }
});

代码示例来源:origin: org.redisson/redisson

@Override
public int countActiveWorkers() {
  String id = generateRequestId();
  int subscribers = (int) workersTopic.publish(id);
  if (subscribers == 0) {
    return 0;
  }
  RSemaphore semaphore = redisson.getSemaphore(workersSemaphoreName + ":" + id);
  try {
    semaphore.tryAcquire(subscribers, 10, TimeUnit.MINUTES);
  } catch (InterruptedException e) {
    Thread.currentThread().interrupt();
  }
  RAtomicLong atomicLong = redisson.getAtomicLong(workersCounterName + ":" + id);
  long result = atomicLong.get();
  redisson.getKeys().delete(semaphore, atomicLong);
  return (int) result;
}

相关文章