Skip to content

Commit

Permalink
Modify the fields from float to int & format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhiguo.Chen committed Aug 31, 2015
1 parent 803d402 commit ed52091
Show file tree
Hide file tree
Showing 33 changed files with 284 additions and 271 deletions.
22 changes: 11 additions & 11 deletions src/main/java/com/handu/open/dubbo/monitor/CountUtils.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2006-2015 handu.com
*
* <p/>
* 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
*
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
Expand Down Expand Up @@ -34,13 +34,13 @@ public final class CountUtils {
private static final Logger logger = LoggerFactory.getLogger(CountUtils.class);

private static final Pattern NUMBER_PATTERN = Pattern.compile("\\d+");

private static final int SUM = 0;

private static final int MAX = 1;

private static final int AVG = 2;

public static long sum(File file) {
return calc(file, SUM);
}
Expand All @@ -52,7 +52,7 @@ public static long max(File file) {
public static long avg(File file) {
return calc(file, SUM);
}

private static long calc(File file, int op) {
if (file.exists()) {
try {
Expand All @@ -67,7 +67,7 @@ private static long calc(File file, int op) {
line = line.substring(i + 1).trim();
if (NUMBER_PATTERN.matcher(line).matches()) {
int value = Integer.parseInt(line);
times ++;
times++;
if (op == MAX) {
count = Math.max(count, value);
} else {
Expand All @@ -89,5 +89,5 @@ private static long calc(File file, int op) {
}
return 0;
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2006-2015 handu.com
*
* <p/>
* 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
*
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
Expand Down Expand Up @@ -202,7 +202,7 @@ public List<DubboInvoke> countDubboInvokeInfo(DubboInvoke dubboInvoke) {
* @param dubboInvoke
* @return
*/
public Map<String,List> countDubboInvokeTopTen(DubboInvoke dubboInvoke){
public Map<String, List> countDubboInvokeTopTen(DubboInvoke dubboInvoke) {
Map<String, List> result = Maps.newHashMap();
result.put("success", dao.getList(CLASSNAME, "countDubboInvokeSuccessTopTen", dubboInvoke));
result.put("failure", dao.getList(CLASSNAME, "countDubboInvokeFailureTopTen", dubboInvoke));
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/com/handu/open/dubbo/monitor/RegistryContainer.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2006-2015 handu.com
*
* <p/>
* 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
*
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
Expand Down Expand Up @@ -65,7 +65,7 @@ public RegistryService getRegistry() {
public Set<String> getApplications() {
return Collections.unmodifiableSet(applications);
}

public Set<String> getDependencies(String application, boolean reverse) {
if (reverse) {
Set<String> dependencies = new HashSet<String>();
Expand Down Expand Up @@ -190,13 +190,13 @@ public List<URL> getConsumersByApplication(String application) {
@PostConstruct
public void start() {
URL subscribeUrl = new URL(Constants.ADMIN_PROTOCOL, NetUtils.getLocalHost(), 0, "",
Constants.INTERFACE_KEY, Constants.ANY_VALUE,
Constants.GROUP_KEY, Constants.ANY_VALUE,
Constants.VERSION_KEY, Constants.ANY_VALUE,
Constants.CLASSIFIER_KEY, Constants.ANY_VALUE,
Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY + ","
+ Constants.CONSUMERS_CATEGORY,
Constants.CHECK_KEY, String.valueOf(false));
Constants.INTERFACE_KEY, Constants.ANY_VALUE,
Constants.GROUP_KEY, Constants.ANY_VALUE,
Constants.VERSION_KEY, Constants.ANY_VALUE,
Constants.CLASSIFIER_KEY, Constants.ANY_VALUE,
Constants.CATEGORY_KEY, Constants.PROVIDERS_CATEGORY + ","
+ Constants.CONSUMERS_CATEGORY,
Constants.CHECK_KEY, String.valueOf(false));
registry.subscribe(subscribeUrl, new NotifyListener() {
public void notify(List<URL> urls) {
if (urls == null || urls.size() == 0) {
Expand Down Expand Up @@ -229,7 +229,7 @@ public void notify(List<URL> urls) {
serviceApplications = providerServiceApplications.get(service);
}
serviceApplications.add(application);

Set<String> applicationServices = providerApplicationServices.get(application);
if (applicationServices == null) {
providerApplicationServices.put(application, new ConcurrentHashSet<String>());
Expand All @@ -255,15 +255,15 @@ public void notify(List<URL> urls) {
serviceApplications = consumerServiceApplications.get(service);
}
serviceApplications.add(application);

Set<String> applicationServices = consumerApplicationServices.get(application);
if (applicationServices == null) {
consumerApplicationServices.put(application, new ConcurrentHashSet<String>());
applicationServices = consumerApplicationServices.get(application);
}
applicationServices.add(service);
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2006-2015 handu.com
*
* <p/>
* 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
*
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2006-2015 handu.com
*
* <p/>
* 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
*
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2006-2015 handu.com
*
* <p/>
* 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
*
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2006-2015 handu.com
*
* <p/>
* 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
*
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/handu/open/dubbo/monitor/config/WebConfig.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2006-2015 handu.com
*
* <p/>
* 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
*
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
Expand Down Expand Up @@ -35,7 +35,7 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
}

@Bean
public JetTemplateViewResolver viewResolver(){
public JetTemplateViewResolver viewResolver() {
JetTemplateViewResolver jetTemplateViewResolver = new JetTemplateViewResolver();
jetTemplateViewResolver.setOrder(1);
jetTemplateViewResolver.setContentType("text/html; charset=utf-8");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2006-2015 handu.com
*
* <p/>
* 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
*
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
Expand Down Expand Up @@ -126,7 +126,7 @@ public String dependencies(@RequestParam String application, @RequestParam(requi
private void appendDependency(List<String> rows, boolean reverse, String application, int level, Set<String> appended, Set<String> indirectly) {
StringBuilder buf = new StringBuilder();
if (level > 0) {
for (int i = 0; i < level; i ++) {
for (int i = 0; i < level; i++) {
buf.append("<span style=\"margin-left:" + (level * 30) + "px;\"></span>");
}
buf.append(reverse ? "<i class=\"fa fa-level-down\" style=\"-webkit-transform: rotate(180deg);margin-right:5px;\"></i> " : "<i class=\"fa fa-level-up\" style=\"-webkit-transform: rotate(90deg);margin-right:5px;\"></i> ");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2006-2015 handu.com
*
* <p/>
* 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
*
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
Expand Down Expand Up @@ -86,7 +86,7 @@ public CommonResponse loadChartsData(@ModelAttribute DubboInvoke dubboInvoke) {
double[] qpsProviderSeriesData;
double[] artProviderSeriesData;
for (DubboInvoke dubboInvokeDetail : providerDubboInvokeDetails) {
qpsProviderSeriesData = new double[]{dubboInvokeDetail.getInvokeTime(), Double.valueOf(String.format("%.4f", dubboInvokeDetail.getSuccess()/ timeParticle))};
qpsProviderSeriesData = new double[]{dubboInvokeDetail.getInvokeTime(), Double.valueOf(String.format("%.4f", dubboInvokeDetail.getSuccess() / timeParticle))};
qpsSeriesDatas.add(qpsProviderSeriesData);
artProviderSeriesData = new double[]{dubboInvokeDetail.getInvokeTime(), Double.valueOf(String.format("%.4f", dubboInvokeDetail.getElapsed()))};
artSeriesDatas.add(artProviderSeriesData);
Expand All @@ -107,7 +107,7 @@ public CommonResponse loadChartsData(@ModelAttribute DubboInvoke dubboInvoke) {
double[] qpsConsumerSeriesData;
double[] artConsumerSeriesData;
for (DubboInvoke dubboInvokeDetail : consumerDubboInvokeDetails) {
qpsConsumerSeriesData = new double[]{dubboInvokeDetail.getInvokeTime(), Double.valueOf(String.format("%.4f", dubboInvokeDetail.getSuccess()/ timeParticle))};
qpsConsumerSeriesData = new double[]{dubboInvokeDetail.getInvokeTime(), Double.valueOf(String.format("%.4f", dubboInvokeDetail.getSuccess() / timeParticle))};
qpsSeriesDatas.add(qpsConsumerSeriesData);
artConsumerSeriesData = new double[]{dubboInvokeDetail.getInvokeTime(), Double.valueOf(String.format("%.4f", dubboInvokeDetail.getElapsed()))};
artSeriesDatas.add(artConsumerSeriesData);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2006-2015 handu.com
*
* <p/>
* 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
*
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
Expand Down Expand Up @@ -63,7 +63,7 @@ public String hosts(Model model) {
URL url = (providers != null && providers.size() > 0) ? providers.iterator().next() : consumers.iterator().next();
dubboHost.setApplication(url.getParameter(Constants.APPLICATION_KEY, ""));
dubboHost.setOwner(url.getParameter("owner", ""));
dubboHost.setOrganization((url.hasParameter("organization") ? url.getParameter("organization") : ""));
dubboHost.setOrganization((url.hasParameter("organization") ? url.getParameter("organization") : ""));
}

int providerSize = providers == null ? 0 : providers.size();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2006-2015 handu.com
*
* <p/>
* 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
*
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
Expand All @@ -23,7 +23,6 @@
import com.handu.open.dubbo.monitor.support.CommonResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2006-2015 handu.com
*
* <p/>
* 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
*
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
Expand Down
Loading

0 comments on commit ed52091

Please sign in to comment.