org.redisson.api.RListMultimap Java Examples
The following examples show how to use
org.redisson.api.RListMultimap.
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: ReducerTask.java From redisson with Apache License 2.0 | 6 votes |
@Override public void run() { try { this.codec = (Codec) codecClass.getConstructor().newInstance(); } catch (Exception e) { throw new IllegalArgumentException(e); } Injector.inject(reducer, redisson); RMap<KOut, VOut> map = redisson.getMap(resultMapName); RListMultimap<KOut, VOut> multimap = redisson.getListMultimap(name, codec); for (KOut key : multimap.keySet()) { if (Thread.currentThread().isInterrupted()) { break; } List<VOut> values = multimap.get(key); VOut out = reducer.reduce(key, values.iterator()); map.put(key, out); } if (timeout > 0) { map.expire(timeout, TimeUnit.MILLISECONDS); } multimap.delete(); }
Example #2
Source File: RedisJobRepositoryImpl.java From earth-frost with Apache License 2.0 | 6 votes |
@Override public void updateJob(JobInfo jobInfo) { RMap<String, JobInfo> map = redissonClient.getMap(Container.JOB_INFO); // script RListMultimap<String, JobScript> scriptList = redissonClient .getListMultimap(Container.JOB_INFO_SCRIPT); if (jobInfo.getScript() != null && JobInfo.TYPE.SCRIPT.name().equals(jobInfo.getType())) { JobInfo local = map.get(jobInfo.getId()); if (!Objects.equals(jobInfo.getType(), local.getType())) { JobScript script = build(jobInfo); scriptList.removeAll(jobInfo.getId()); scriptList.put(jobInfo.getId(), script); } } else if (JobInfo.TYPE.BEAN.name().equals(jobInfo.getType())) { scriptList.removeAll(jobInfo.getId()); } jobInfo.setScript(null); map.put(jobInfo.getId(), jobInfo); }
Example #3
Source File: RedisJobRepositoryImpl.java From earth-frost with Apache License 2.0 | 6 votes |
@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 #4
Source File: RedisJobRepositoryImpl.java From earth-frost with Apache License 2.0 | 6 votes |
@Override public String addJobRecord(JobExecuteRecord record) { RMap<String, JobExecuteRecord> map = redissonClient.getMap(Container.RECORD); map.put(record.getId(), record); // 全部 RListMultimap<String, String> sortmap = redissonClient.getListMultimap(Container.RECORD_SORT); sortmap.put(Strings.EMPTY, record.getId()); // jobId sortmap.put(record.getJobId(), record.getId()); JobInfo info = findJobInfoById(record.getJobId()); JobGroup group = info.getGroup(); if (Objects.equals(JobInfo.TYPE.BEAN.name(), info.getType())) { // groupKey sortmap.put(group.getGroupKey(), record.getId()); // jobKey sortmap .put(String.join(Strings.COLON, group.getGroupKey(), group.getJobKey()), record.getId()); } else if (group != null && group.getGroupKey() != null) { // groupKey sortmap.put(group.getGroupKey(), record.getId()); } return record.getId(); }
Example #5
Source File: Collector.java From redisson with Apache License 2.0 | 6 votes |
@Override public void emit(K key, V value) { try { ByteBuf encodedKey = codec.getValueEncoder().encode(key); long hash = Hash.hash64(encodedKey); encodedKey.release(); int part = (int) Math.abs(hash % parts); String partName = name + ":" + part; RListMultimap<K, V> multimap = client.getListMultimap(partName, codec); multimap.put(key, value); if (timeout > 0 && !expirationsBitSet.get(part)) { multimap.expire(timeout, TimeUnit.MILLISECONDS); expirationsBitSet.set(part); } } catch (IOException e) { throw new IllegalArgumentException(e); } }
Example #6
Source File: RedisJobRepositoryImpl.java From earth-frost with Apache License 2.0 | 6 votes |
@Override public void removeJobRecords(String jobId) { RMap<String, JobExecuteRecord> map = redissonClient.getMap(Container.RECORD); RListMultimap<String, String> sortmap = redissonClient.getListMultimap(Container.RECORD_SORT); List<String> list = sortmap.removeAll(jobId); RListMultimap<String, JobRecordStatus> statusMultimap = redissonClient .getListMultimap(Container.RECORD_STATUS); JobGroup group = findJobInfoById(jobId).getGroup(); for (String key : list) { sortmap.get(Strings.EMPTY).remove(key); if (group != null) { sortmap.get(group.getGroupKey()).remove(key); sortmap.get(String.join(Strings.COLON, group.getGroupKey(), group.getJobKey())).remove(key); } statusMultimap.removeAll(key); map.remove(key); redissonClient.getKeys().delete(String.format(Container.EVENT_SHARDING, jobId, key)); } }
Example #7
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testPut() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("{multi.map}.some.key"); map.put(new SimpleKey("0"), new SimpleValue("1")); map.put(new SimpleKey("0"), new SimpleValue("2")); map.put(new SimpleKey("0"), new SimpleValue("3")); map.put(new SimpleKey("0"), new SimpleValue("3")); map.put(new SimpleKey("3"), new SimpleValue("4")); assertThat(map.size()).isEqualTo(5); List<SimpleValue> s1 = map.get(new SimpleKey("0")); assertThat(s1).containsExactly(new SimpleValue("1"), new SimpleValue("2"), new SimpleValue("3"), new SimpleValue("3")); List<SimpleValue> allValues = map.getAll(new SimpleKey("0")); assertThat(allValues).containsExactly(new SimpleValue("1"), new SimpleValue("2"), new SimpleValue("3"), new SimpleValue("3")); List<SimpleValue> s2 = map.get(new SimpleKey("3")); assertThat(s2).containsExactly(new SimpleValue("4")); }
Example #8
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testFastRemove() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("test1"); assertThat(map.put(new SimpleKey("0"), new SimpleValue("1"))).isTrue(); assertThat(map.put(new SimpleKey("0"), new SimpleValue("2"))).isTrue(); assertThat(map.put(new SimpleKey("0"), new SimpleValue("2"))).isTrue(); assertThat(map.put(new SimpleKey("0"), new SimpleValue("3"))).isTrue(); long removed = map.fastRemove(new SimpleKey("0"), new SimpleKey("1")); assertThat(removed).isEqualTo(1); assertThat(map.size()).isZero(); }
Example #9
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testDelete() { RListMultimap<String, String> testList = redisson.getListMultimap( "test" ); testList.put("1", "01"); testList.put("1", "02"); testList.put("1", "03"); RList<String> list = testList.get( "1" ); list.delete(); assertThat(testList.size()).isZero(); assertThat(testList.get("1").size()).isZero(); }
Example #10
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testReadAllKeySet() { RListMultimap<String, String> map = redisson.getListMultimap("test1"); map.put("1", "4"); map.put("2", "5"); map.put("3", "6"); assertThat(map.readAllKeySet()).containsExactly("1", "2", "3"); }
Example #11
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testSize() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("test1"); map.put(new SimpleKey("0"), new SimpleValue("1")); map.put(new SimpleKey("0"), new SimpleValue("2")); map.put(new SimpleKey("1"), new SimpleValue("4")); assertThat(map.size()).isEqualTo(3); assertThat(map.fastRemove(new SimpleKey("0"))).isEqualTo(1); List<SimpleValue> s = map.get(new SimpleKey("0")); assertThat(s).isEmpty(); assertThat(map.size()).isEqualTo(1); }
Example #12
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testKeySize() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("test1"); map.put(new SimpleKey("0"), new SimpleValue("1")); map.put(new SimpleKey("0"), new SimpleValue("2")); map.put(new SimpleKey("1"), new SimpleValue("4")); assertThat(map.keySize()).isEqualTo(2); assertThat(map.fastRemove(new SimpleKey("0"))).isEqualTo(1); List<SimpleValue> s = map.get(new SimpleKey("0")); assertThat(s).isEmpty(); assertThat(map.size()).isEqualTo(1); }
Example #13
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testRemoveAllFromCollection() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("test1"); map.put(new SimpleKey("0"), new SimpleValue("1")); map.put(new SimpleKey("0"), new SimpleValue("2")); map.put(new SimpleKey("0"), new SimpleValue("3")); Collection<SimpleValue> values = Arrays.asList(new SimpleValue("1"), new SimpleValue("2")); assertThat(map.get(new SimpleKey("0")).removeAll(values)).isTrue(); assertThat(map.get(new SimpleKey("0")).size()).isEqualTo(1); assertThat(map.get(new SimpleKey("0")).removeAll(Arrays.asList(new SimpleValue("3")))).isTrue(); assertThat(map.get(new SimpleKey("0")).size()).isZero(); assertThat(map.get(new SimpleKey("0")).removeAll(Arrays.asList(new SimpleValue("3")))).isFalse(); }
Example #14
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testRemoveAll() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("test1"); map.put(new SimpleKey("0"), new SimpleValue("1")); map.put(new SimpleKey("0"), new SimpleValue("1")); map.put(new SimpleKey("0"), new SimpleValue("2")); map.put(new SimpleKey("0"), new SimpleValue("3")); List<SimpleValue> values = map.removeAll(new SimpleKey("0")); assertThat(values).containsExactly(new SimpleValue("1"), new SimpleValue("1"), new SimpleValue("2"), new SimpleValue("3")); assertThat(map.size()).isZero(); List<SimpleValue> values2 = map.removeAll(new SimpleKey("0")); assertThat(values2).isEmpty(); }
Example #15
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testRemove() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("test1"); map.put(new SimpleKey("0"), new SimpleValue("1")); map.put(new SimpleKey("0"), new SimpleValue("2")); map.put(new SimpleKey("0"), new SimpleValue("3")); assertThat(map.remove(new SimpleKey("0"), new SimpleValue("2"))).isTrue(); assertThat(map.remove(new SimpleKey("0"), new SimpleValue("5"))).isFalse(); assertThat(map.get(new SimpleKey("0")).size()).isEqualTo(2); assertThat(map.getAll(new SimpleKey("0")).size()).isEqualTo(2); }
Example #16
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testContainsKey() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("test1"); map.put(new SimpleKey("0"), new SimpleValue("1")); assertThat(map.containsKey(new SimpleKey("0"))).isTrue(); assertThat(map.containsKey(new SimpleKey("1"))).isFalse(); }
Example #17
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testContainsValue() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("{1}test1"); map.put(new SimpleKey("0"), new SimpleValue("1")); assertThat(map.containsValue(new SimpleValue("1"))).isTrue(); assertThat(map.containsValue(new SimpleValue("0"))).isFalse(); }
Example #18
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testContainsEntry() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("test1"); map.put(new SimpleKey("0"), new SimpleValue("1")); assertThat(map.containsEntry(new SimpleKey("0"), new SimpleValue("1"))).isTrue(); assertThat(map.containsEntry(new SimpleKey("0"), new SimpleValue("2"))).isFalse(); }
Example #19
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testRange() { RListMultimap<Integer, Integer> map = redisson.getListMultimap("test1"); map.put(1, 1); map.put(1, 2); map.put(1, 3); map.put(1, 4); map.put(1, 5); assertThat(map.get(1).range(1)).containsExactly(1, 2); assertThat(map.get(1).range(1, 3)).containsExactly(2, 3, 4); }
Example #20
Source File: RedisJobScheduleImpl.java From earth-frost with Apache License 2.0 | 5 votes |
@Override public void pauseJob(String jobId) { RListMultimap<String, String> listmap = redissonClient.getListMultimap(Container.TASK_ID); RScheduledExecutorService service = redissonClient.getExecutorService(Container.WORKER); Iterator<String> it = listmap.get(jobId).iterator(); while (it.hasNext()) { String id = it.next(); service.cancelTask(id); it.remove(); } }
Example #21
Source File: ListMultimapExamples.java From redisson-examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RListMultimap<String, Integer> multimap = redisson.getListMultimap("myMultimap"); multimap.put("1", 1); multimap.put("1", 2); multimap.put("1", 3); multimap.put("2", 5); multimap.put("2", 6); multimap.put("4", 7); RList<Integer> values1 = multimap.get("1"); RList<Integer> values2 = multimap.get("2"); boolean hasEntry = multimap.containsEntry("1", 3); Collection<Entry<String, Integer>> entries = multimap.entries(); Collection<Integer> values = multimap.values(); boolean isRemoved = multimap.remove("1", 3); List<Integer> removedValues = multimap.removeAll("1"); Collection<? extends Integer> newValues = Arrays.asList(5, 6, 7, 8, 9); boolean isNewKey = multimap.putAll("5", newValues); List<Integer> oldValues = multimap.replaceValues("2", newValues); List<Integer> allValues = multimap.getAll("2"); long keysRemoved = multimap.fastRemove("2", "32"); redisson.shutdown(); }
Example #22
Source File: TracingRedissonTest.java From java-redis-client with Apache License 2.0 | 5 votes |
@Test public void test_list_multi_map() { RListMultimap<String, String> map = client.getListMultimap("list_multi_map"); map.put("key", "value"); assertEquals("value", map.get("key").get(0)); List<MockSpan> spans = tracer.finishedSpans(); assertEquals(3, spans.size()); checkSpans(spans); assertNull(tracer.activeSpan()); }
Example #23
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testPutAll() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("test1"); List<SimpleValue> values = Arrays.asList(new SimpleValue("1"), new SimpleValue("2"), new SimpleValue("3"), new SimpleValue("3")); assertThat(map.putAll(new SimpleKey("0"), values)).isTrue(); assertThat(map.putAll(new SimpleKey("0"), Arrays.asList(new SimpleValue("1")))).isTrue(); List<SimpleValue> testValues = Arrays.asList(new SimpleValue("1"), new SimpleValue("2"), new SimpleValue("3"), new SimpleValue("3"), new SimpleValue("1")); assertThat(map.get(new SimpleKey("0"))).containsExactlyElementsOf(testValues); }
Example #24
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testKeySet() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("test1"); map.put(new SimpleKey("0"), new SimpleValue("1")); map.put(new SimpleKey("3"), new SimpleValue("4")); assertThat(map.keySet()).containsOnly(new SimpleKey("0"), new SimpleKey("3")); assertThat(map.keySet().size()).isEqualTo(2); }
Example #25
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testValues() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("test1"); map.put(new SimpleKey("0"), new SimpleValue("1")); map.put(new SimpleKey("0"), new SimpleValue("1")); map.put(new SimpleKey("0"), new SimpleValue("3")); map.put(new SimpleKey("2"), new SimpleValue("5")); map.put(new SimpleKey("3"), new SimpleValue("4")); assertThat(map.values().size()).isEqualTo(5); assertThat(map.values()).containsOnly(new SimpleValue("1"), new SimpleValue("1"), new SimpleValue("3"), new SimpleValue("5"), new SimpleValue("4")); }
Example #26
Source File: RedisStorage.java From Panako with GNU Affero General Public License v3.0 | 5 votes |
public RedisStorage(int numberOfTables,String name){ Config config = new Config(); config.useSingleServer().setAddress("127.0.0.1:6379"); redisson = Redisson.create(config); hashtables = new ArrayList<>(); for(int i = 0 ; i < numberOfTables ; i++){ RListMultimap<Integer, Long> map = redisson.getListMultimap("fingerprint_" + i + "" + name); hashtables.add(map); } }
Example #27
Source File: RedisJobRepositoryImpl.java From earth-frost with Apache License 2.0 | 5 votes |
@Override public void addJobScript(JobScript script) { RListMultimap<String, JobScript> scriptList = redissonClient .getListMultimap(Container.JOB_INFO_SCRIPT); script.setId(UUID.randomUUID().toString()); script.setTime(Date.from(ZonedDateTime.now().toInstant())); scriptList.put(script.getJobId(), script); if (scriptList.get(script.getJobId()).size() > Container.get().getSystemProperties() .getMaxScriptHistory()) { scriptList.get(script.getJobId()).remove(0); } }
Example #28
Source File: RedissonListMultimapTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testEntrySet() { RListMultimap<SimpleKey, SimpleValue> map = redisson.getListMultimap("test1"); map.put(new SimpleKey("0"), new SimpleValue("1")); map.put(new SimpleKey("0"), new SimpleValue("1")); map.put(new SimpleKey("3"), new SimpleValue("4")); assertThat(map.entries().size()).isEqualTo(3); List<Map.Entry<SimpleKey, SimpleValue>> testMap = new ArrayList<Map.Entry<SimpleKey, SimpleValue>>(); testMap.add(new AbstractMap.SimpleEntry(new SimpleKey("0"), new SimpleValue("1"))); testMap.add(new AbstractMap.SimpleEntry(new SimpleKey("0"), new SimpleValue("1"))); testMap.add(new AbstractMap.SimpleEntry(new SimpleKey("3"), new SimpleValue("4"))); assertThat(map.entries()).containsOnlyElementsOf(testMap); }
Example #29
Source File: RedisJobRepositoryImpl.java From earth-frost with Apache License 2.0 | 5 votes |
@Override public JobExecuteRecord findJobExecuteRecordById(String id) { RMap<String, JobExecuteRecord> map = redissonClient.getMap(Container.RECORD); JobExecuteRecord record = map.get(id); if (record == null) { return null; } RListMultimap<String, JobRecordStatus> recordStatus = redissonClient .getListMultimap(Container.RECORD_STATUS); List<JobRecordStatus> statuses = recordStatus.getAll(id); statuses.forEach(r -> r.fill(record)); record.setRecordStatuses(statuses); return record; }
Example #30
Source File: RedisJobRepositoryImpl.java From earth-frost with Apache License 2.0 | 5 votes |
@Override public int countJobRecords(String groupKey, String jobKey, String jobId) { RListMultimap<String, String> sortmap = redissonClient.getListMultimap(Container.RECORD_SORT); if (jobId != null && jobId.length() > 0) { return sortmap.get(jobId).size(); } String key = key(groupKey, jobKey); return sortmap.get(key).size(); }