Skip to content
Permalink
Browse files

Added environment variables to the server api page (#3065) (#3073)

* 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 c094e900f4e097f49fc9bb87147598b9e579c104
@@ -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,
@@ -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;
@@ -39,7 +36,7 @@ public CacheInformationProvider(GoCache goCache) {

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

@Override
@@ -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,
@@ -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;
@@ -37,7 +36,7 @@ public ConfigInfoProvider(GoConfigService service) {

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

@Override
@@ -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.
@@ -38,7 +38,7 @@ public ConfigRepositoryProvider(ConfigRepository configRepository) {

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

@Override
@@ -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,
@@ -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 {

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

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

@Override
@@ -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,
@@ -29,7 +29,7 @@
public class GCInformationProvider implements ServerInfoProvider {
@Override
public double priority() {
return 8.0;
return 9.0;
}

@Override
@@ -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.
@@ -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 {
@@ -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());
@@ -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,
@@ -27,7 +27,7 @@
public class MemoryInformationProvider extends AbstractMemoryInformationProvider implements ServerInfoProvider {
@Override
public double priority() {
return 9.0;
return 10.0;
}

@Override
@@ -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,
@@ -28,7 +28,7 @@
public class MemoryPoolInformationProvider extends AbstractMemoryInformationProvider implements ServerInfoProvider {
@Override
public double priority() {
return 10.0;
return 11.0;
}

@Override
@@ -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,
@@ -27,7 +27,7 @@
public class OSInformationProvider implements ServerInfoProvider {
@Override
public double priority() {
return 6.0;
return 4.0;
}

@Override
@@ -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,
@@ -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) {
@@ -56,6 +56,7 @@ public double priority() {

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;
}
@@ -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,
@@ -34,7 +34,7 @@ public ServerBasicInfoProvider(ServerVersion serverVersion){

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

@Override
@@ -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,
@@ -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
*/
@@ -38,7 +36,7 @@

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

@Autowired
@@ -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,
@@ -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;
@@ -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,
@@ -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) {

0 comments on commit c094e90

Please sign in to comment.
You can’t perform that action at this time.