Java Code Examples for org.redisson.api.RList#size()

The following examples show how to use org.redisson.api.RList#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisJobRepositoryImpl.java    From earth-frost with Apache License 2.0 6 votes vote down vote up
@Override
public JobInfo findJobInfoById(String id) {
  RMap<String, JobInfo> map = redissonClient.getMap(Container.JOB_INFO);
  JobInfo jobInfo = map.get(id);
  if (jobInfo == null) {
    return null;
  }
  RListMultimap<String, JobScript> scriptList = redissonClient
      .getListMultimap(Container.JOB_INFO_SCRIPT);
  RList<JobScript> list = scriptList.get(id);
  int size = list.size();
  if (size > 0) {
    JobScript script = list.get(size - 1);
    jobInfo.setScript(script.getScript());
  }
  return jobInfo;
}
 
Example 2
Source File: RedisJobRepositoryImpl.java    From earth-frost with Apache License 2.0 5 votes vote down vote up
private void fill(RList<String> list, List<JobExecuteRecord> records, int from, int to) {
  if (list.size() <= from) {
    return;
  }
  for (String id : list.subList(from, Math.min(to, list.size()))) {
    JobExecuteRecord record = findJobExecuteRecordById(id);
    if (record != null) {
      records.add(record);
    }
  }
}
 
Example 3
Source File: RedisStorage.java    From Panako with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public long[] put(int hashtableIndex, int key, long[] newArray) {
	RList<Long> currentList = hashtables.get(hashtableIndex).get(key);
	//append the current list with the new values
	for(int i = currentList.size(); i <newArray.length ; i++){
		hashtables.get(hashtableIndex).put(key,newArray[i]);
	}		
	return newArray;
}
 
Example 4
Source File: RedisStorage.java    From Panako with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public long[] get(int hashtableIndex, int key) {
	RList<Long> values = hashtables.get(hashtableIndex).get(key);
	long[] asLongArray = new long[values.size()];
	for(int i = 0 ; i<asLongArray.length ; i++){
		asLongArray[i] = values.get(i);
	}
	return asLongArray;
}
 
Example 5
Source File: RedisJobLoggerImpl.java    From earth-frost with Apache License 2.0 4 votes vote down vote up
private void removeOldestLogger(String loggerId) {
  long maxLogSize = Container.get().getJobExecutorProperties().getMaxLogSize();
  if (maxLogSize < 0) {
    return;
  }

  RMap<String, String> logMap = redissonClient.getMap(Container.LOG_BIND);
  String jobId = logMap.get(loggerId);
  if (jobId == null) {
    return;
  }

  RListMultimap<String, String> sortmap = redissonClient.getListMultimap(Container.RECORD_SORT);
  RList<String> list = sortmap.get(jobId);
  long size = list.size() - maxLogSize;
  if (size <= 0) {
    return;
  }

  JobInfo job = jobRepository.findJobInfoById(jobId);
  if (job == null) {
    return;
  }

  RListMultimap<String, JobRecordStatus> statusMultimap = redissonClient
      .getListMultimap(Container.RECORD_STATUS);
  RMap<String, JobExecuteRecord> map = redissonClient.getMap(Container.RECORD);
  RList<String> logIds = redissonClient.<String, String>getListMultimap(Container.LOG_REL)
      .get(jobId);

  JobGroup group = job.getGroup();
  for (String key : list.subList(0, (int) size).readAll()) {
    sortmap.get(Strings.EMPTY).remove(key);
    if (group != null) {
      sortmap.get(String.join(Strings.COLON, group.getGroupKey(), group.getJobKey())).remove(key);
      sortmap.get(group.getGroupKey()).remove(key);
    }
    statusMultimap.removeAll(key);
    list.remove(key);
    map.remove(key);
    logMap.remove(key);
    logIds.remove(key);
    redissonClient.getKeys().delete(String.format(Container.EVENT_SHARDING, jobId, loggerId));
  }

}