public Collection<User> getUsersByFirstName(final String firstName) { log.info("Finding user with firtname {}.", firstName); // retrieve interested subscriber types Collection<User> users = Collections.EMPTY_SET; try { final UserByFirstNamePredicate predicate = new UserByFirstNamePredicate( firstName); users = usersMap.getAll(usersMap.keySet(predicate)).values(); log.info("Found {} users with firstname {} .", users.size(), firstName); } catch (OperationTimeoutException ote) { log.error("Hazelcast cluster is borked, so return empty set", ote); } return users; }
@Override public int getQueriedPersonalObjects(final InetAddress remoteAddress) { Integer count = null; try { count = counterMap.get(remoteAddress); } catch (OperationTimeoutException | IllegalStateException e) { // no answer from hazelcast, expected, don't rethrow LOGGER.debug("{}: {}", e.getClass().getName(), e.getMessage()); } if (count == null) { return 0; } return count; }
@Override public void evict(final Object key) throws CacheException { try { getCache().remove(key); } catch (OperationTimeoutException e) { Logger.getLogger(AbstractGeneralRegion.class).finest(e); } }
@Override public void evictAll() throws CacheException { try { getCache().clear(); } catch (OperationTimeoutException e) { Logger.getLogger(AbstractGeneralRegion.class).finest(e); } }
@Override public Object get(final SessionImplementor session, final Object key) throws CacheException { try { return getCache().get(key, nextTimestamp()); } catch (OperationTimeoutException e) { return null; } }
@Override public void put(final SessionImplementor session, final Object key, final Object value) throws CacheException { try { getCache().put(key, value, nextTimestamp(), null); } catch (OperationTimeoutException e) { Logger.getLogger(AbstractGeneralRegion.class).finest(e); } }
@Test public void testPut_withException() { doThrow(new OperationTimeoutException("expected exception")) .when(cache).put(eq("putKey"), eq("putValue"), anyLong(), any()); region.put(null, "putKey", "putValue"); verify(cache).put(eq("putKey"), eq("putValue"), anyLong(), any()); }
@Override public Object get(final SharedSessionContractImplementor session, final Object key) throws CacheException { try { return getCache().get(key, nextTimestamp()); } catch (OperationTimeoutException e) { return null; } }
@Override public void put(final SharedSessionContractImplementor session, final Object key, final Object value) throws CacheException { try { getCache().put(key, value, nextTimestamp(), null); } catch (OperationTimeoutException e) { Logger.getLogger(AbstractGeneralRegion.class).finest(e); } }
public void evict(final Object key) throws CacheException { try { getCache().remove(key); } catch (OperationTimeoutException e) { Logger.getLogger(AbstractGeneralRegion.class).finest(e); } }
public void evictAll() throws CacheException { try { getCache().clear(); } catch (OperationTimeoutException e) { Logger.getLogger(AbstractGeneralRegion.class).finest(e); } }
public Object get(final Object key) throws CacheException { try { return getCache().get(key, nextTimestamp()); } catch (OperationTimeoutException e) { return null; } }
public void put(final Object key, final Object value) throws CacheException { try { getCache().put(key, value, nextTimestamp(), null); } catch (OperationTimeoutException e) { Logger.getLogger(AbstractGeneralRegion.class).finest(e); } }
@Test public void testPut_withException() { doThrow(new OperationTimeoutException("expected exception")) .when(cache).put(eq("putKey"), eq("putValue"), anyLong(), any()); region.put("putKey", "putValue"); verify(cache).put(eq("putKey"), eq("putValue"), anyLong(), any()); }
@Override public Object get(final Object key) throws CacheException { try { return getCache().get(key, nextTimestamp()); } catch (OperationTimeoutException e) { return null; } }
@Override public void put(final Object key, final Object value) throws CacheException { try { getCache().put(key, value, nextTimestamp(), null); } catch (OperationTimeoutException e) { Logger.getLogger(AbstractGeneralRegion.class).finest(e); } }
public Object get(final Object key) throws CacheException { try { return getCache().get(key); } catch (OperationTimeoutException e) { return null; } }
public void get(long time, TimeUnit unit) throws InterruptedException { Object result = null; boolean done = true; try { result = doGetResult((time == -1) ? -1 : unit.toMillis(time)); if (result == OBJECT_NO_RESPONSE || result == OBJECT_REDO) { done = false; innerFutureTask.innerSetException(new TimeoutException(), false); } else if (result instanceof CancellationException) { innerFutureTask.innerSetCancelled(); } else if (result == OBJECT_MEMBER_LEFT) { innerFutureTask.innerSetMemberLeft(member); } else if (result instanceof Throwable) { innerFutureTask.innerSetException((Throwable) result, true); } else { innerFutureTask.innerSet(result); } } catch (Exception e) { if (time > 0 && e instanceof OperationTimeoutException) { e = new TimeoutException(); } innerFutureTask.innerSetException(e, done); } finally { if (singleTask && done) { innerFutureTask.innerDone(); } } }
@Test public void testEvict_withException() { doThrow(new OperationTimeoutException("expected exception")).when(cache).remove(eq("evictionKey")); region.evict("evictionKey"); }
@Test public void testEvictAll_withException() { doThrow(new OperationTimeoutException("expected exception")).when(cache).clear(); region.evictAll(); }
@Test public void testGet_withException() { doThrow(new OperationTimeoutException("expected exception")).when(cache).get(eq("getKey"), anyLong()); assertNull(region.get(null, "getKey")); }
@Test public void testGet_withException() { doThrow(new OperationTimeoutException("expected exception")).when(cache).get(eq("getKey"), anyLong()); assertNull(region.get("getKey")); }
@Test public void testEvict_withException() { doThrow(new OperationTimeoutException("expected exception")).when(cache).remove(eq("evictionKey")); region.evict("evictionKey"); verify(cache).remove(eq("evictionKey")); }
@Test public void testEvictAll_withException() { doThrow(new OperationTimeoutException("expected exception")).when(cache).clear(); region.evictAll(); verify(cache).clear(); }
@Test public void testGet_withException() { doThrow(new OperationTimeoutException("expected exception")).when(cache).get(eq("getKey"), anyLong()); assertNull(region.get("getKey")); verify(cache).get(eq("getKey"), anyLong()); }
public void evict(final Object key) throws CacheException { try { getCache().remove(key); } catch (OperationTimeoutException ignored) { } }
public void evictAll() throws CacheException { try { getCache().clear(); } catch (OperationTimeoutException ignored) { } }
public void put(final Object key, final Object value) throws CacheException { try { getCache().put(key, value, null); } catch (OperationTimeoutException ignored) { } }