Skip to content

Commit

Permalink
Added environment variables to the server api page (#3065) (#3073)
Browse files Browse the repository at this point in the history
* Do not render useless hibernate (empty, zero-value) stats if disabled

* Re-order priorities to move thread and hibernate stats at the bottom and other information to the top

* Added environment variables to the server api page (#3065)
  • Loading branch information
ketan committed Jan 4, 2017
1 parent 73595c1 commit c094e90
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 52 deletions.
@@ -1,11 +1,11 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* 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,
Expand All @@ -19,15 +19,12 @@
import com.thoughtworks.go.server.cache.GoCache;
import net.sf.ehcache.config.CacheConfiguration;
import net.sf.ehcache.statistics.LiveCacheStatistics;
import org.apache.commons.lang.builder.ToStringStyle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.LinkedHashMap;
import java.util.Map;

import static org.apache.commons.lang.builder.ToStringBuilder.reflectionToString;

@Component
public class CacheInformationProvider implements ServerInfoProvider {
private GoCache goCache;
Expand All @@ -39,7 +36,7 @@ public CacheInformationProvider(GoCache goCache) {

@Override
public double priority() {
return 5.0;
return 7.0;
}

@Override
Expand Down
@@ -1,11 +1,11 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* 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,
Expand All @@ -17,7 +17,6 @@
package com.thoughtworks.go.server.service.support;

import com.thoughtworks.go.config.CruiseConfig;
import com.thoughtworks.go.config.validation.GoConfigValidity;
import com.thoughtworks.go.server.service.GoConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
Expand All @@ -37,7 +36,7 @@ public ConfigInfoProvider(GoConfigService service) {

@Override
public double priority() {
return 1.0;
return 2.0;
}

@Override
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,7 +38,7 @@ public ConfigRepositoryProvider(ConfigRepository configRepository) {

@Override
public double priority() {
return 6.5;
return 8.0;
}

@Override
Expand Down
@@ -1,11 +1,11 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* 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,
Expand All @@ -16,16 +16,16 @@

package com.thoughtworks.go.server.service.support;

import java.io.File;
import java.util.*;

import com.thoughtworks.go.util.SystemEnvironment;
import org.apache.log4j.Appender;
import org.apache.log4j.FileAppender;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.File;
import java.util.*;

@Component
public class FileLocationProvider implements ServerInfoProvider {

Expand All @@ -38,7 +38,7 @@ public FileLocationProvider(SystemEnvironment systemEnvironment) {

@Override
public double priority() {
return 2.0;
return 3.0;
}

@Override
Expand Down
@@ -1,11 +1,11 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* 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,
Expand All @@ -29,7 +29,7 @@
public class GCInformationProvider implements ServerInfoProvider {
@Override
public double priority() {
return 8.0;
return 9.0;
}

@Override
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,9 +21,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.*;
import java.util.LinkedHashMap;
import java.util.Map;

@Component
public class HibernateInformationProvider implements ServerInfoProvider {
Expand All @@ -37,13 +36,16 @@ public HibernateInformationProvider(SessionFactory sessionFactory) {

@Override
public double priority() {
return 7.0;
return 12.0;
}

@Override
public Map<String, Object> asJson() {
LinkedHashMap<String, Object> json = new LinkedHashMap<>();
Statistics statistics = sessionFactory.getStatistics();
if (!statistics.isStatisticsEnabled()){
return json;
}
json.put("EntityDeleteCount", statistics.getEntityDeleteCount());
json.put("EntityInsertCount", statistics.getEntityInsertCount());
json.put("EntityLoadCount", statistics.getEntityLoadCount());
Expand Down
@@ -1,11 +1,11 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* 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,
Expand All @@ -27,7 +27,7 @@
public class MemoryInformationProvider extends AbstractMemoryInformationProvider implements ServerInfoProvider {
@Override
public double priority() {
return 9.0;
return 10.0;
}

@Override
Expand Down
@@ -1,11 +1,11 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* 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,
Expand All @@ -28,7 +28,7 @@
public class MemoryPoolInformationProvider extends AbstractMemoryInformationProvider implements ServerInfoProvider {
@Override
public double priority() {
return 10.0;
return 11.0;
}

@Override
Expand Down
@@ -1,11 +1,11 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* 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,
Expand All @@ -27,7 +27,7 @@
public class OSInformationProvider implements ServerInfoProvider {
@Override
public double priority() {
return 6.0;
return 4.0;
}

@Override
Expand Down
@@ -1,11 +1,11 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* 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,
Expand All @@ -26,7 +26,7 @@
public class RuntimeInformationProvider implements ServerInfoProvider {
@Override
public double priority() {
return 7.0;
return 5.0;
}

private Map<String, Object> asIndentedMultilineValuesAsJson(Map<String, String> inputArguments) {
Expand Down Expand Up @@ -56,6 +56,7 @@ public Map<String, Object> asJson() {

json.put("Input Arguments", runtimeMXBean.getInputArguments());
json.put("System Properties", new TreeMap<>(asIndentedMultilineValuesAsJson(runtimeMXBean.getSystemProperties())));
json.put("Environment Variables", new TreeMap<>(asIndentedMultilineValuesAsJson(System.getenv())));

return json;
}
Expand Down
@@ -1,11 +1,11 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* 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,
Expand Down Expand Up @@ -34,7 +34,7 @@ public ServerBasicInfoProvider(ServerVersion serverVersion){

@Override
public double priority() {
return 3.0;
return 1.0;
}

@Override
Expand Down
@@ -1,11 +1,11 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* 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,
Expand All @@ -26,8 +26,6 @@
import java.util.LinkedHashMap;
import java.util.Map;

import static com.thoughtworks.go.server.web.JsonRenderer.render;

/**
* @understands Dumping all the server health messages
*/
Expand All @@ -38,7 +36,7 @@ public class ServerHealthInformationProvider implements ServerInfoProvider {

@Override
public double priority() {
return 4.0;
return 6.0;
}

@Autowired
Expand Down
@@ -1,11 +1,11 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* 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,
Expand All @@ -16,7 +16,6 @@

package com.thoughtworks.go.server.service.support;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.thoughtworks.go.i18n.LocalizedMessage;
import com.thoughtworks.go.server.domain.Username;
Expand Down
@@ -1,11 +1,11 @@
/*
* Copyright 2016 ThoughtWorks, Inc.
* Copyright 2017 ThoughtWorks, Inc.
*
* 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,
Expand Down Expand Up @@ -38,7 +38,7 @@ public ThreadInformationProvider(DaemonThreadStatsCollector daemonThreadStatsCol

@Override
public double priority() {
return 11.0;
return 13.0;
}

private Map<String, Object> getThreadCount(ThreadMXBean threadMXBean) {
Expand Down

0 comments on commit c094e90

Please sign in to comment.