Project

General

Profile

« Previous | Next » 

Revision 7f39ce17

Added by Andreas Kohlbecker about 11 years ago

updating system requirements

View differences:

src/main/java/eu/etaxonomy/cdm/server/Bootloader.java
175 175

  
176 176

  
177 177
    // memory requirements
178
    private static final long MB = 1024 * 1024;
179
    private static final long PERM_GEN_SPACE_PER_INSTANCE = 64 * MB;
180
    private static final long HEAP_PER_INSTANCE = 150 * MB;
181

  
182 178
    private static final int KB = 1024;
179
    private static final long MB = 1024 * KB;
180
    public static final long PERM_GEN_SPACE_PER_INSTANCE = 55 * MB;
181
    public static final long HEAP_PER_INSTANCE = 130 * MB;
182
    public static final long PERM_GEN_SPACE_CDMSERVER = 19 * MB;
183
    public static final long HEAP_CDMSERVER = 15 * MB;
184

  
183 185

  
184 186

  
185 187
    private Set<CdmInstanceProperties> configAndStatusSet = null;
......
557 559
     */
558 560
    private void verifyMemoryRequirements() {
559 561

  
560
        verifyMemoryRequirement("PermGenSpace", PERM_GEN_SPACE_PER_INSTANCE, JvmManager.getPermGenSpaceUsage().getMax());
561
        verifyMemoryRequirement("HeapSpace", HEAP_PER_INSTANCE, JvmManager.getHeapMemoryUsage().getMax());
562
        verifyMemoryRequirement("PermGenSpace", PERM_GEN_SPACE_CDMSERVER, PERM_GEN_SPACE_PER_INSTANCE, JvmManager.getPermGenSpaceUsage().getMax());
563
        verifyMemoryRequirement("HeapSpace", HEAP_CDMSERVER, HEAP_PER_INSTANCE, JvmManager.getHeapMemoryUsage().getMax());
562 564

  
563 565
    }
564 566

  
565
    private void verifyMemoryRequirement(String memoryName, long requiredSpacePerIntance, long availableSpace) {
567
    private void verifyMemoryRequirement(String memoryName, long requiredSpaceServer, long requiredSpacePerInstance, long availableSpace) {
566 568

  
567 569

  
568
        long requiredSpace = configAndStatusSet.size() * requiredSpacePerIntance;
570
        long recommendedMinimumSpace = calculateRecommendedMinimumSpace(requiredSpaceServer, requiredSpacePerInstance);
569 571

  
570
        if(requiredSpace > availableSpace){
572
        if(recommendedMinimumSpace > availableSpace){
571 573

  
572 574
            String message = memoryName + " ("
573 575
                + (availableSpace / MB)
574 576
                + "MB) insufficient for "
575 577
                + configAndStatusSet.size()
576 578
                + " instances. Increase " + memoryName + " to "
577
                + (requiredSpace / MB)
579
                + (recommendedMinimumSpace / MB)
578 580
                + "MB";
579 581
                ;
580 582
            logger.error(message + " => disabling some instances!!!");
......
583 585
            int i=0;
584 586
            for(CdmInstanceProperties instanceProps : configAndStatusSet){
585 587
                i++;
586
                if(i * requiredSpacePerIntance > availableSpace){
588
                if(i * requiredSpacePerInstance > availableSpace){
587 589
                    instanceProps.setStatus(Status.disabled);
588
                    instanceProps.getProblems().add("Disbled due to: " + message);
590
                    instanceProps.getProblems().add("Disabled due to: " + message);
589 591
                }
590 592
            }
591 593
        }
592 594
    }
593 595

  
596
    /**
597
     * @param requiredServerSpace
598
     * @param requiredSpacePerIntance
599
     * @return
600
     */
601
    public long calculateRecommendedMinimumSpace(long requiredServerSpace, long requiredSpacePerIntance) {
602
        return (configAndStatusSet.size() * requiredSpacePerIntance) + requiredServerSpace;
603
    }
604

  
594 605
    /**
595 606
     * Configures and adds a {@link RollingFileAppender} to the root logger
596 607
     *
src/main/webapp/manage/index.jsp
7 7
<%@page import="eu.etaxonomy.cdm.server.JvmManager" %>
8 8
<%@page import="java.io.IOException"%>
9 9
<%!
10
public void printMemoryUsage(java.lang.management.MemoryUsage memoryUsage, String label, String barWidth, String cssColorUsed, String cssColorMax, JspWriter writer) throws IOException{
11
	float mb = 1024 * 1024;
12
	float gb = mb * 1024;
13
    float max = memoryUsage.getMax() / mb;
14
    float used = memoryUsage.getUsed() / mb;
15
    float percent = used * 100 / max;
16
	writer.append("<span class=\"memory-usage\">").append(label + "(" + used + " of "  + max+ " MB)&nbsp;")
17
	.append("<div style=\"height: 100%; width:")
18
	.append(barWidth).append(";background-color:").append(cssColorMax).append("\">")
19
	.append("<div style=\"background-color:" + cssColorUsed + "; width:" + percent + "%\">&nbsp;</div></div></span>");
10

  
11
public void printMemoryUsage(java.lang.management.MemoryUsage memoryUsage, Long recommended, String label, String barWidth, String cssColorUsed, String cssColorMax, JspWriter writer) throws IOException{
12

  
13
  float mb = 1024 * 1024;
14
  float gb = mb * 1024;
15
  float max = memoryUsage.getMax() / mb;
16
  float used = memoryUsage.getUsed() / mb;
17
  float percent = used * 100 / max;
18
  float recommendedMB = recommended / mb;
19

  
20
  writer.append("<span class=\"memory-usage\">").append(label + "(" + used + " of "  + max+ " MB, recommended: "  + recommendedMB + " MB)&nbsp;")
21
  .append("<div style=\"height: 100%; width:")
22
  .append(barWidth).append(";background-color:").append(cssColorMax).append("\">")
23
  .append("<div style=\"background-color:" + cssColorUsed + "; width:" + percent + "%\">&nbsp;</div></div></span>");
24

  
20 25
}
21 26

  
22
// the servelt context must use the class loader of the Bootloader class otherwise 
27
// the servelt context must use the class loader of the Bootloader class otherwise
23 28
// getting the status will not work in mulithreading environments !!!
24 29
Bootloader bootloader = Bootloader.getBootloader();
25 30

  
......
28 33
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
29 34

  
30 35
<head>
31
	<title>CDM Server</title>
32
	<meta http-equiv="refresh" content="3; URL=index.jsp" />
33
	<link type="text/css" rel="stylesheet" media="all" href="/css/style.css" />
34
	<link type="text/css" rel="stylesheet" media="all" href="/css/server.css" />
35
	<script type="text/javascript" src="/js/jquery.js"></script>
36
	<script type="text/javascript" src="/js/oai-pmh-status.js"></script>
36
  <title>CDM Server</title>
37
  <meta http-equiv="refresh" content="3; URL=index.jsp" />
38
  <link type="text/css" rel="stylesheet" media="all" href="/css/style.css" />
39
  <link type="text/css" rel="stylesheet" media="all" href="/css/server.css" />
40
  <script type="text/javascript" src="/js/jquery.js"></script>
41
  <script type="text/javascript" src="/js/oai-pmh-status.js"></script>
37 42
</head>
38 43
<body class="layout-main">
39 44
    <div id="page" class="clearfix">
......
42 47
          <div id="header-first">
43 48
            <div id="logo">
44 49
              </div>
45
				<h1>CDM Server</h1>
50
        <h1>CDM Server</h1>
46 51
          </div><!-- /header-first -->
47 52
        </div><!-- /header -->
48 53
      </div><!-- /header-wrapper -->
49
      
54

  
50 55
      <div id="primary-menu-wrapper" class="clearfix">
51 56
        <div id="primary-menu">
52 57
            <div id="version"><%= bootloader.readCdmRemoteVersion() %></div>
......
55 60

  
56 61
      <div id="main-wrapper">
57 62
        <div id="main" class="clearfix">
58
        
63

  
59 64
          <div id="sidebar-first">
60 65
          </div><!-- /sidebar-first -->
61 66

  
62 67
          <div id="content-wrapper">
63 68
            <div id="content">
64
								<!-- ============================= -->
65
								<div class="block-wrapper">
66
								  <h2 class="title block-title pngfix">Server Status</h2>
67
									<div class="block" id="status">
68
									   <% 
69
									   printMemoryUsage(JvmManager.getHeapMemoryUsage(), "HeapUsage", "100%", "#F48B65", "#65B1F4", out);
70
									   printMemoryUsage(JvmManager.getPermGenSpaceUsage(), "PermGenSpaceUsage", "100%","#F48B65", "#65B1F4", out);
71
									   %> 
72
									</div>
73
								</div>
74

  
75
								
76
								<div class="block-wrapper">
77
									<div class="block" id="datasources">
78
										<h2 class="title block-title pngfix">CDM Server Instances</h2>
79
										<table>
80
											<tr><th>Path</th><th> </th><th>Database Url</th><th>Status</th><th>OAI-PMH Provider</th></tr>
69
                <!-- ============================= -->
70
                <div class="block-wrapper">
71
                  <h2 class="title block-title pngfix">Server Status</h2>
72
                  <div class="block" id="status">
73
                     <%
74
                       printMemoryUsage(JvmManager.getHeapMemoryUsage(), bootloader.calculateRecommendedMinimumSpace(Bootloader.HEAP_CDMSERVER, Bootloader.HEAP_PER_INSTANCE), "HeapUsage", "100%", "#F48B65", "#65B1F4", out);
75
                                          printMemoryUsage(JvmManager.getPermGenSpaceUsage(), bootloader.calculateRecommendedMinimumSpace(Bootloader.PERM_GEN_SPACE_CDMSERVER, Bootloader.PERM_GEN_SPACE_PER_INSTANCE), "PermGenSpaceUsage", "100%","#F48B65", "#65B1F4", out);
76
                     %>
77
                  </div>
78
                </div>
79

  
80

  
81
                <div class="block-wrapper">
82
                  <div class="block" id="datasources">
83
                    <h2 class="title block-title pngfix">CDM Server Instances</h2>
84
                    <table>
85
                      <tr><th>Path</th><th> </th><th>Database Url</th><th>Status</th><th>OAI-PMH Provider</th></tr>
81 86
                                            <%
82 87
                                           java.util.Set<CdmInstanceProperties> configAndStatus = bootloader.getConfigAndStatus();
83 88
                                           if(configAndStatus != null){
84
                                        	   int i = 0;
85
                                        	   for(CdmInstanceProperties props : configAndStatus){
86
                                        		   i++;
87
                                        		   String basePath = "/" + props.getDataSourceName();
89
                                             int i = 0;
90
                                             for(CdmInstanceProperties props : configAndStatus){
91
                                               i++;
92
                                               String basePath = "/" + props.getDataSourceName();
88 93
                                                   URL fullURL = new URL(request.getScheme(),
89 94
                                                           request.getServerName(),
90 95
                                                           request.getServerPort(),
91 96
                                                           basePath);
92
                                                   
97

  
93 98
                                                   String oddOrEven = i % 2 == 0 ? "odd" : "even";
94 99
                                                   String noBottomBorder = props.getStatus().equals(CdmInstanceProperties.Status.error) ? " style=\"border-bottom:none;\"" : "";
95
                                                   
96
	                                        	   out.append("<tr class=\"entry " + oddOrEven + "\" " +noBottomBorder+ ">");
97
	                                        	   out.append("<td class=\"base-url\"><a href=\"" + fullURL + "\">" + basePath + "</a></td>");
98
	                                        	   out.append("<td class=\"test-url\"><a href=\"" + fullURL + "/portal/classification\">Test</a></td>");
100

  
101
                                               out.append("<tr class=\"entry " + oddOrEven + "\" " +noBottomBorder+ ">");
102
                                               out.append("<td class=\"base-url\"><a href=\"" + fullURL + "\">" + basePath + "</a></td>");
103
                                               out.append("<td class=\"test-url\"><a href=\"" + fullURL + "/portal/classification\">Test</a></td>");
99 104
                                                   out.append("<td class=\"db-url\">" + props.getUrl() + "</td>");
100 105
                                                   out.append("<td class=\"status " + props.getStatus() + "\">" + props.getStatus() + "</td>");
101
                                                   
106

  
102 107
                                                   // OAI-PMH Status will be requested using javascript
103 108
                                                   out.append("<td class=\"oai-pmh\">requesting status ...</td>");
104 109
                                                   out.append("</tr>");
105 110
                                                   if(props.getStatus().equals(CdmInstanceProperties.Status.error) || !props.isEnabled()){
106
                                                	   out.append("<tr class=\"error-log " + oddOrEven + "\">");
107
                                                	   out.append("<td></td><td  class=\"error\" colspan=\"4\">");
108
                                                			   for( String problem : props.getProblems()){
109
                                                				   out.append("<div>" + problem + "</div>");
110
                                                			   }
111
                                                	   out.append("</td>");
112
                                                	   out.append("</tr>");
111
                                                     out.append("<tr class=\"error-log " + oddOrEven + "\">");
112
                                                     out.append("<td></td><td  class=\"error\" colspan=\"4\">");
113
                                                         for( String problem : props.getProblems()){
114
                                                           out.append("<div>" + problem + "</div>");
115
                                                         }
116
                                                     out.append("</td>");
117
                                                     out.append("</tr>");
113 118
                                                   }
114
	                                           }
119
                                             }
115 120
                                           }
116 121
                                           %>
117
										</table>
118
									</div>
119
								</div>
122
                    </table>
123
                  </div>
124
                </div>
120 125
<%/*
121
								<div class="block-wrapper">
122
									<div class="block" id="test">
123
										<h2 class="title block-title pngfix">Test your CDM Server (using the default data base)</h2>
124
										<form name="input" action="/default/portal/taxon/find" method="get">
125
										<input type="text" name="query"></br>
126
										<input type="submit" value="submit">
127
										</form>
128
									</div>
129
								</div><!-- test -->
126
                <div class="block-wrapper">
127
                  <div class="block" id="test">
128
                    <h2 class="title block-title pngfix">Test your CDM Server (using the default data base)</h2>
129
                    <form name="input" action="/default/portal/taxon/find" method="get">
130
                    <input type="text" name="query"></br>
131
                    <input type="submit" value="submit">
132
                    </form>
133
                  </div>
134
                </div><!-- test -->
130 135
*/
131
%>								
132
								<!-- ============================= -->
136
%>
137
                <!-- ============================= -->
133 138
            </div><!-- /content -->
134 139
          </div><!-- /content-wrapper -->
135
          
140

  
136 141
          <div id="footer" class="clearfix">
137
					The CDM Server is a component of the <a href="http://wp5.e-taxonomy.eu/">EDIT Platform for Cybertaxonomy</a>.
142
          The CDM Server is a component of the <a href="http://wp5.e-taxonomy.eu/">EDIT Platform for Cybertaxonomy</a>.
138 143
          </div><!-- /footer -->
139
        
144

  
140 145
        </div><!-- /main -->
141 146
      </div><!-- /main-wrapper -->
142 147
    </div><!-- /page -->

Also available in: Unified diff