From e75a8ef2372722c0b22669fb427d47bacc5b8d5e Mon Sep 17 00:00:00 2001 From: HuabingZhao Date: Thu, 7 Sep 2017 14:33:18 +0800 Subject: Fix java check style warning Change-Id: I98a6d7237a213d007ad4d954989cb0b0fa150a10 Issue-Id: MSB-67 Signed-off-by: HuabingZhao --- .../apiroute/wrapper/dao/RedisAccessWrapper.java | 58 +++++++++++----------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/RedisAccessWrapper.java') diff --git a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/RedisAccessWrapper.java b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/RedisAccessWrapper.java index a789c0a..db74a42 100644 --- a/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/RedisAccessWrapper.java +++ b/apiroute/apiroute-service/src/main/java/org/onap/msb/apiroute/wrapper/dao/RedisAccessWrapper.java @@ -1,46 +1,45 @@ /******************************************************************************* * Copyright 2016-2017 ZTE, Inc. and others. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. ******************************************************************************/ package org.onap.msb.apiroute.wrapper.dao; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + import org.onap.msb.apiroute.wrapper.util.JedisUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import redis.clients.jedis.Jedis; import redis.clients.jedis.ScanParams; import redis.clients.jedis.ScanResult; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - public class RedisAccessWrapper { private static final Logger LOGGER = LoggerFactory.getLogger(RedisAccessWrapper.class); - //An iteration starts when the cursor is set to 0 + // An iteration starts when the cursor is set to 0 private static final String REDIS_SCAN_POINTER_NEW_ITERATION = "0"; - //An iteration terminated when the cursor returned by the server is 0 + // An iteration terminated when the cursor returned by the server is 0 private static final String REDIS_SCAN_POINTER_ITERATION_END = "0"; private static final int REDIS_SCAN_COUNT = 50; - public static void save(String key,String value) throws Exception { + public static void save(String key, String value) throws Exception { Jedis jedis = null; try { jedis = JedisUtil.borrowJedisInstance(); - jedis.set(key,value); + jedis.set(key, value); } finally { JedisUtil.returnJedisInstance(jedis); } @@ -52,7 +51,7 @@ public class RedisAccessWrapper { try { jedis = JedisUtil.borrowJedisInstance(); value = jedis.get(key); - }finally { + } finally { JedisUtil.returnJedisInstance(jedis); } return value; @@ -88,9 +87,9 @@ public class RedisAccessWrapper { Jedis jedis = null; try { jedis = JedisUtil.borrowJedisInstance(); - for(String key : keySet){ + for (String key : keySet) { String value = jedis.get(key); - if(value !=null && !"".equals(value)){ + if (value != null && !"".equals(value)) { valueList.add(value); } } @@ -106,7 +105,7 @@ public class RedisAccessWrapper { Jedis jedis = null; try { jedis = JedisUtil.borrowJedisInstance(); - for(String key : keySet){ + for (String key : keySet) { long reply = jedis.del(key); replySum = replySum + reply; } @@ -117,12 +116,13 @@ public class RedisAccessWrapper { } /** - * filter the keys according to the given pattern - * using "scan" instead of using "keys", incrementally iterate the keys space + * filter the keys according to the given pattern using "scan" instead of using "keys", + * incrementally iterate the keys space + * * @param pattern the input filter pattern * @return the matched keys set */ - public static Set filterKeys(String pattern) throws Exception{ + public static Set filterKeys(String pattern) throws Exception { long start = System.currentTimeMillis(); Jedis jedis = null; Set filteredKeys = new HashSet<>(); @@ -131,17 +131,17 @@ public class RedisAccessWrapper { scanParams.count(REDIS_SCAN_COUNT); try { jedis = JedisUtil.borrowJedisInstance(); - ScanResult scanResult = jedis.scan(REDIS_SCAN_POINTER_NEW_ITERATION,scanParams); + ScanResult scanResult = jedis.scan(REDIS_SCAN_POINTER_NEW_ITERATION, scanParams); filteredKeys.addAll(scanResult.getResult()); - while(!scanResult.getStringCursor().equals(REDIS_SCAN_POINTER_ITERATION_END)){ - scanResult = jedis.scan(scanResult.getStringCursor(),scanParams); + while (!scanResult.getStringCursor().equals(REDIS_SCAN_POINTER_ITERATION_END)) { + scanResult = jedis.scan(scanResult.getStringCursor(), scanParams); filteredKeys.addAll(scanResult.getResult()); } } finally { JedisUtil.returnJedisInstance(jedis); } long end = System.currentTimeMillis(); - long costTime = end-start; + long costTime = end - start; LOGGER.info("filterKeys " + pattern + " count:" + filteredKeys.size() + " cost: " + costTime); return filteredKeys; } -- cgit 1.2.3-korg