@Override public boolean tryAccess(String name, String key, int limitPeriod, int limitCount) throws Exception { if (StringUtils.isEmpty(name)) { throw new AquariusException("Name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Key is null or empty"); } String compositeKey = KeyUtil.getCompositeKey(prefix, name, key); return tryAccess(compositeKey, limitPeriod, limitCount); }
@Override public boolean tryAccess(String name, String key, int limitPeriod, int limitCount) throws Exception { if (StringUtils.isEmpty(name)) { throw new AquariusException("Name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Key is null or empty"); } String compositeKey = KeyUtil.getCompositeKey(prefix, name, key); return tryAccess(compositeKey, limitPeriod, limitCount); }
@Override public String nextSequenceId(String name, String key) throws Exception { if (StringUtils.isEmpty(name)) { throw new AquariusException("name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("key is null or empty"); } String compositeKey = KeyUtil.getCompositeKey(prefix, name, key); return nextSequenceId(compositeKey); }
@Override public InterProcessMutex tryLock(LockType lockType, String name, String key, long leaseTime, long waitTime, boolean async, boolean fair) throws Exception { if (StringUtils.isEmpty(name)) { throw new AquariusException("Name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Key is null or empty"); } String compositeKey = KeyUtil.getCompositeKey(prefix, name, key); return tryLock(lockType, compositeKey, leaseTime, waitTime, async, fair); }
@Override public boolean tryAccess(String name, String key, int limitPeriod, int limitCount) throws Exception { if (StringUtils.isEmpty(name)) { throw new AquariusException("Name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Key is null or empty"); } String compositeKey = KeyUtil.getCompositeKey(prefix, name, key); return tryAccess(compositeKey, limitPeriod, limitCount); }
@Override public boolean tryAccess(String name, String key, int limitPeriod, int limitCount) throws Exception { if (StringUtils.isEmpty(name)) { throw new AquariusException("Name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Key is null or empty"); } String compositeKey = KeyUtil.getCompositeKey(prefix, name, key); return tryAccess(compositeKey, limitPeriod, limitCount); }
@Override public Lock tryLock(LockType lockType, String name, String key, long leaseTime, long waitTime, boolean async, boolean fair) throws Exception { if (StringUtils.isEmpty(name)) { throw new AquariusException("Name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Key is null or empty"); } String compositeKey = KeyUtil.getCompositeKey(prefix, name, key); return tryLock(lockType, compositeKey, leaseTime, waitTime, async, fair); }
@Override public String nextUniqueId(String name, String key, int step, int length) throws Exception { if (StringUtils.isEmpty(name)) { throw new AquariusException("Name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Key is null or empty"); } String compositeKey = KeyUtil.getCompositeKey(prefix, name, key); return nextUniqueId(compositeKey, step, length); }
@Override public String nextSequenceId(String name, String key) throws Exception { if (StringUtils.isEmpty(name)) { throw new AquariusException("name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("key is null or empty"); } String compositeKey = KeyUtil.getCompositeKey(prefix, name, key); return nextSequenceId(compositeKey); }
@Override public String nextUniqueId(String name, String key, int step, int length) throws Exception { if (StringUtils.isEmpty(name)) { throw new AquariusException("Name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Key is null or empty"); } String compositeKey = KeyUtil.getCompositeKey(prefix, name, key); return nextUniqueId(compositeKey, step, length); }
@Override public RLock tryLock(LockType lockType, String name, String key, long leaseTime, long waitTime, boolean async, boolean fair) throws Exception { if (StringUtils.isEmpty(name)) { throw new AquariusException("Name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Key is null or empty"); } String compositeKey = KeyUtil.getCompositeKey(prefix, name, key); return tryLock(lockType, compositeKey, leaseTime, waitTime, async, fair); }
@Override public boolean tryAccess(String name, String key, int limitPeriod, int limitCount) throws Exception { if (StringUtils.isEmpty(name)) { throw new AquariusException("Name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Key is null or empty"); } String compositeKey = KeyUtil.getCompositeKey(prefix, name, key); return tryAccess(compositeKey, limitPeriod, limitCount); }
@Override public boolean tryAccess(String name, String key, int limitPeriod, int limitCount) throws Exception { if (StringUtils.isEmpty(name)) { throw new AquariusException("Name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Key is null or empty"); } String compositeKey = KeyUtil.getCompositeKey(prefix, name, key); return tryAccess(compositeKey, limitPeriod, limitCount); }
private Object invokeCachePut(MethodInvocation invocation, String name, String[] keys, long expire) throws Throwable { if (StringUtils.isEmpty(name)) { throw new AquariusException("Annotation [CachePut]'s name is null or empty"); } if (ArrayUtils.isEmpty(keys)) { throw new AquariusException("Annotation [CachePut]'s key is null or empty"); } List<String> compositeKeys = new ArrayList<String>(keys.length); for (int i = 0; i < keys.length; i++) { String key = keys[i]; if (StringUtils.isEmpty(key)) { throw new AquariusException("Annotation [CachePut]'s key is null or empty"); } String spelKey = null; try { spelKey = getSpelKey(invocation, key); } catch (Exception e) { spelKey = key; } String compositeKey = KeyUtil.getCompositeKey(prefix, name, spelKey); compositeKeys.add(compositeKey); } String proxyType = getProxyType(invocation); String proxiedClassName = getProxiedClassName(invocation); String methodName = getMethodName(invocation); if (frequentLogPrint) { LOG.info("Intercepted for annotation - CachePut [key={}, expire={}, proxyType={}, proxiedClass={}, method={}]", compositeKeys, expire, proxyType, proxiedClassName, methodName); } return cacheDelegate.invokeCachePut(invocation, compositeKeys, expire); }
private Object invokeCacheable(MethodInvocation invocation, String name, String[] keys, long expire) throws Throwable { if (StringUtils.isEmpty(name)) { throw new AquariusException("Annotation [Cacheable]'s name is null or empty"); } if (ArrayUtils.isEmpty(keys)) { throw new AquariusException("Annotation [Cacheable]'s key is null or empty"); } List<String> compositeKeys = new ArrayList<String>(keys.length); for (int i = 0; i < keys.length; i++) { String key = keys[i]; if (StringUtils.isEmpty(key)) { throw new AquariusException("Annotation [Cacheable]'s key is null or empty"); } String spelKey = null; try { spelKey = getSpelKey(invocation, key); } catch (Exception e) { spelKey = key; } String compositeKey = KeyUtil.getCompositeKey(prefix, name, spelKey); compositeKeys.add(compositeKey); } String proxyType = getProxyType(invocation); String proxiedClassName = getProxiedClassName(invocation); String methodName = getMethodName(invocation); if (frequentLogPrint) { LOG.info("Intercepted for annotation - Cacheable [key={}, expire={}, proxyType={}, proxiedClass={}, method={}]", compositeKeys, expire, proxyType, proxiedClassName, methodName); } return cacheDelegate.invokeCacheable(invocation, compositeKeys, expire); }
spelKey = key; String compositeKey = KeyUtil.getCompositeKey(prefix, name, spelKey); compositeKeys.add(compositeKey);
private Object invoke(MethodInvocation invocation, Annotation annotation, String name, String key, int limitPeriod, int limitCount) throws Throwable { if (StringUtils.isEmpty(name)) { throw new AquariusException("Annotation [Limit]'s name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Annotation [Limit]'s key is null or empty"); } String spelKey = null; try { spelKey = getSpelKey(invocation, key); } catch (Exception e) { spelKey = key; } String compositeKey = KeyUtil.getCompositeKey(prefix, name, spelKey); String proxyType = getProxyType(invocation); String proxiedClassName = getProxiedClassName(invocation); String methodName = getMethodName(invocation); if (frequentLogPrint) { LOG.info("Intercepted for annotation - Limit [key={}, limitPeriod={}, limitCount={}, proxyType={}, proxiedClass={}, method={}]", compositeKey, limitPeriod, limitCount, proxyType, proxiedClassName, methodName); } return limitDelegate.invoke(invocation, compositeKey, limitPeriod, limitCount); } }
private Object invoke(MethodInvocation invocation, Annotation annotation, String name, String key, int limitPeriod, int limitCount) throws Throwable { if (StringUtils.isEmpty(name)) { throw new AquariusException("Annotation [Limit]'s name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Annotation [Limit]'s key is null or empty"); } String spelKey = null; try { spelKey = getSpelKey(invocation, key); } catch (Exception e) { spelKey = key; } String compositeKey = KeyUtil.getCompositeKey(prefix, name, spelKey); String proxyType = getProxyType(invocation); String proxiedClassName = getProxiedClassName(invocation); String methodName = getMethodName(invocation); if (frequentLogPrint) { LOG.info("Intercepted for annotation - Limit [key={}, limitPeriod={}, limitCount={}, proxyType={}, proxiedClass={}, method={}]", compositeKey, limitPeriod, limitCount, proxyType, proxiedClassName, methodName); } return limitDelegate.invoke(invocation, compositeKey, limitPeriod, limitCount); } }
private Object invoke(MethodInvocation invocation, Annotation annotation, String name, String key, long leaseTime, long waitTime, boolean async, boolean fair) throws Throwable { LockType lockType = getLockType(annotation); if (lockType == null) { throw new AquariusException("Lock type is null for " + annotation); } String lockTypeValue = lockType.getValue(); if (StringUtils.isEmpty(name)) { throw new AquariusException("Annotation [" + lockTypeValue + "]'s name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Annotation [" + lockTypeValue + "]'s key is null or empty"); } String spelKey = null; try { spelKey = getSpelKey(invocation, key); } catch (Exception e) { spelKey = key; } String compositeKey = KeyUtil.getCompositeKey(prefix, name, spelKey); String proxyType = getProxyType(invocation); String proxiedClassName = getProxiedClassName(invocation); String methodName = getMethodName(invocation); if (frequentLogPrint) { LOG.info("Intercepted for annotation - {} [key={}, leaseTime={}, waitTime={}, async={}, fair={}, proxyType={}, proxiedClass={}, method={}]", lockTypeValue, compositeKey, leaseTime, waitTime, async, fair, proxyType, proxiedClassName, methodName); } return lockDelegate.invoke(invocation, lockType, compositeKey, leaseTime, waitTime, async, fair); }
private Object invoke(MethodInvocation invocation, Annotation annotation, String name, String key, long leaseTime, long waitTime, boolean async, boolean fair) throws Throwable { LockType lockType = getLockType(annotation); if (lockType == null) { throw new AquariusException("Lock type is null for " + annotation); } String lockTypeValue = lockType.getValue(); if (StringUtils.isEmpty(name)) { throw new AquariusException("Annotation [" + lockTypeValue + "]'s name is null or empty"); } if (StringUtils.isEmpty(key)) { throw new AquariusException("Annotation [" + lockTypeValue + "]'s key is null or empty"); } String spelKey = null; try { spelKey = getSpelKey(invocation, key); } catch (Exception e) { spelKey = key; } String compositeKey = KeyUtil.getCompositeKey(prefix, name, spelKey); String proxyType = getProxyType(invocation); String proxiedClassName = getProxiedClassName(invocation); String methodName = getMethodName(invocation); if (frequentLogPrint) { LOG.info("Intercepted for annotation - {} [key={}, leaseTime={}, waitTime={}, async={}, fair={}, proxyType={}, proxiedClass={}, method={}]", lockTypeValue, compositeKey, leaseTime, waitTime, async, fair, proxyType, proxiedClassName, methodName); } return lockDelegate.invoke(invocation, lockType, compositeKey, leaseTime, waitTime, async, fair); }