You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2015/05/27 06:34:43 UTC
[18/50] [abbrv] incubator-kylin git commit: code cleaning
code cleaning
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/f251f8f0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/f251f8f0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/f251f8f0
Branch: refs/heads/0.8.0
Commit: f251f8f0f96122c4062f547653c8bf397ddae2e1
Parents: 0eb756f
Author: honma <ho...@ebay.com>
Authored: Tue Mar 24 15:50:31 2015 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Wed May 27 12:23:44 2015 +0800
----------------------------------------------------------------------
.../kylin/common/restclient/Broadcaster.java | 8 +++---
.../kylin/common/restclient/RestClient.java | 16 ++++++------
.../kylin/metadata/project/ProjectInstance.java | 4 +++
.../kylin/metadata/project/ProjectL2Cache.java | 16 ++++++------
.../kylin/metadata/project/ProjectManager.java | 5 +---
.../kylin/rest/controller/CacheController.java | 26 +++++++++++---------
6 files changed, 40 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/f251f8f0/common/src/main/java/org/apache/kylin/common/restclient/Broadcaster.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/kylin/common/restclient/Broadcaster.java b/common/src/main/java/org/apache/kylin/common/restclient/Broadcaster.java
index f745410..fa379dc 100644
--- a/common/src/main/java/org/apache/kylin/common/restclient/Broadcaster.java
+++ b/common/src/main/java/org/apache/kylin/common/restclient/Broadcaster.java
@@ -40,7 +40,7 @@ public class Broadcaster {
private static final Logger logger = LoggerFactory.getLogger(Broadcaster.class);
- private BlockingDeque<BroadcastEvent> broadcaseEvents = new LinkedBlockingDeque<>();
+ private BlockingDeque<BroadcastEvent> broadcastEvents = new LinkedBlockingDeque<>();
private AtomicLong counter = new AtomicLong();
@@ -54,7 +54,7 @@ public class Broadcaster {
public void run() {
final String[] nodes = KylinConfig.getInstanceFromEnv().getRestServers();
if (nodes == null || nodes.length < 1) {//TODO if the node count is greater than 1, it means it is a cluster
- logger.info("There is no available rest server; check the 'kylin.rest.servers' config");
+ logger.warn("There is no available rest server; check the 'kylin.rest.servers' config");
return;
}
final List<RestClient> restClients = Lists.newArrayList();
@@ -64,7 +64,7 @@ public class Broadcaster {
final ExecutorService wipingCachePool = Executors.newFixedThreadPool(restClients.size());
while (true) {
try {
- final BroadcastEvent broadcastEvent = broadcaseEvents.takeFirst();
+ final BroadcastEvent broadcastEvent = broadcastEvents.takeFirst();
logger.info("new broadcast event:" + broadcastEvent);
for (final RestClient restClient : restClients) {
wipingCachePool.execute(new Runnable() {
@@ -99,7 +99,7 @@ public class Broadcaster {
public void queue(String type, String action, String key) {
try {
counter.incrementAndGet();
- broadcaseEvents.putFirst(new BroadcastEvent(type, action, key));
+ broadcastEvents.putFirst(new BroadcastEvent(type, action, key));
} catch (Exception e) {
counter.decrementAndGet();
logger.error("error putting BroadcastEvent", e);
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/f251f8f0/common/src/main/java/org/apache/kylin/common/restclient/RestClient.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/kylin/common/restclient/RestClient.java b/common/src/main/java/org/apache/kylin/common/restclient/RestClient.java
index 64a8a74..743acfe 100644
--- a/common/src/main/java/org/apache/kylin/common/restclient/RestClient.java
+++ b/common/src/main/java/org/apache/kylin/common/restclient/RestClient.java
@@ -89,11 +89,11 @@ public class RestClient {
public void wipeCache(String type, String action, String name) throws IOException {
String url = baseUrl + "/cache/" + type + "/" + name + "/" + action;
- HttpMethod get = new PutMethod(url);
+ HttpMethod request = new PutMethod(url);
try {
- int code = client.executeMethod(get);
- String msg = Bytes.toString(get.getResponseBody());
+ int code = client.executeMethod(request);
+ String msg = Bytes.toString(request.getResponseBody());
if (code != 200)
throw new IOException("Invalid response " + code + " with cache wipe url " + url + "\n" + msg);
@@ -101,16 +101,16 @@ public class RestClient {
} catch (HttpException ex) {
throw new IOException(ex);
} finally {
- get.releaseConnection();
+ request.releaseConnection();
}
}
public String getKylinProperties() throws IOException {
String url = baseUrl + "/admin/config";
- HttpMethod get = new GetMethod(url);
+ HttpMethod request = new GetMethod(url);
try {
- int code = client.executeMethod(get);
- String msg = Bytes.toString(get.getResponseBody());
+ int code = client.executeMethod(request);
+ String msg = Bytes.toString(request.getResponseBody());
JSONObject obj = new JSONObject(msg);
msg = obj.getString("config");
@@ -122,7 +122,7 @@ public class RestClient {
} catch (JSONException e) {
throw new IOException("Error when parsing json response from REST");
} finally {
- get.releaseConnection();
+ request.releaseConnection();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/f251f8f0/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectInstance.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectInstance.java b/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectInstance.java
index 7575ff7..d6cbfcc 100644
--- a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectInstance.java
+++ b/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectInstance.java
@@ -25,6 +25,7 @@ import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
+import org.apache.commons.lang3.StringUtils;
import org.apache.kylin.common.persistence.ResourceStore;
import org.apache.kylin.common.persistence.RootPersistentEntity;
import org.apache.kylin.metadata.realization.RealizationType;
@@ -270,6 +271,9 @@ public class ProjectInstance extends RootPersistentEntity {
if (tables == null)
tables = new TreeSet<String>();
+
+ if (StringUtils.isBlank(this.name))
+ throw new IllegalStateException("Project name must not be blank");
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/f251f8f0/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectL2Cache.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectL2Cache.java b/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectL2Cache.java
index aa2ba30..6c153ad 100644
--- a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectL2Cache.java
+++ b/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectL2Cache.java
@@ -18,9 +18,11 @@
package org.apache.kylin.metadata.project;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.kylin.metadata.MetadataManager;
import org.apache.kylin.metadata.model.*;
import org.apache.kylin.metadata.realization.IRealization;
@@ -28,10 +30,9 @@ import org.apache.kylin.metadata.realization.RealizationRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
/**
* This is a second level cache that is built on top of first level cached objects,
@@ -89,6 +90,7 @@ class ProjectL2Cache {
if (tableCache == null)
return false;
+
for (ColumnDesc colDesc : tableCache.exposedColumns) {
if (colDesc.getName().equals(col))
return true;
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/f251f8f0/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java b/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java
index 76b1c0f..bcafcc7 100644
--- a/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java
+++ b/metadata/src/main/java/org/apache/kylin/metadata/project/ProjectManager.java
@@ -122,12 +122,9 @@ public class ProjectManager {
projectInstance.init();
- if (StringUtils.isBlank(projectInstance.getName()))
- throw new IllegalStateException("Project name must not be blank");
-
projectMap.putLocal(projectInstance.getName(), projectInstance);
-
clearL2Cache();
+
return projectInstance;
}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/f251f8f0/server/src/main/java/org/apache/kylin/rest/controller/CacheController.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/controller/CacheController.java b/server/src/main/java/org/apache/kylin/rest/controller/CacheController.java
index 42f5ad8..912d5bc 100644
--- a/server/src/main/java/org/apache/kylin/rest/controller/CacheController.java
+++ b/server/src/main/java/org/apache/kylin/rest/controller/CacheController.java
@@ -54,23 +54,25 @@ public class CacheController extends BasicController {
* @return if the action success
* @throws IOException
*/
- @RequestMapping(value = "/{type}/{name}/{event}", method = {RequestMethod.PUT})
+ @RequestMapping(value = "/{type}/{name}/{event}", method = { RequestMethod.PUT })
@ResponseBody
public void wipeCache(@PathVariable String type, @PathVariable String event, @PathVariable String name) throws IOException {
+
Broadcaster.TYPE wipeType = Broadcaster.TYPE.getType(type);
EVENT wipeEvent = Broadcaster.EVENT.getEvent(event);
- final String log = "wipe cache type: " + wipeType + " event:" + wipeEvent + " name:" + name;
- logger.info(log);
+
+ logger.info("wipe cache type: " + wipeType + " event:" + wipeEvent + " name:" + name);
+
switch (wipeEvent) {
- case CREATE:
- case UPDATE:
- cacheService.rebuildCache(wipeType, name);
- break;
- case DROP:
- cacheService.removeCache(wipeType, name);
- break;
- default:
- throw new RuntimeException("invalid type:" + wipeEvent);
+ case CREATE:
+ case UPDATE:
+ cacheService.rebuildCache(wipeType, name);
+ break;
+ case DROP:
+ cacheService.removeCache(wipeType, name);
+ break;
+ default:
+ throw new RuntimeException("invalid type:" + wipeEvent);
}
}