Project

General

Profile

« Previous | Next » 

Revision d4e8ad57

Added by Andreas Kohlbecker almost 10 years ago

debuging resource limits

View differences:

.gitattributes
30 30
src/main/java/eu/etaxonomy/cdm/server/CommandOptions.java -text
31 31
src/main/java/eu/etaxonomy/cdm/server/DataSourcePropertyParser.java -text
32 32
src/main/java/eu/etaxonomy/cdm/server/JvmManager.java -text
33
src/main/java/eu/etaxonomy/cdm/server/OsChecker.java -text
33 34
src/main/java/eu/etaxonomy/cdm/server/jsvc/ServiceWrapper.java -text
34 35
src/main/java/eu/etaxonomy/cdm/server/win32service/CDMServerWrapperListener.java -text
35 36
src/main/java/eu/etaxonomy/cdm/server/win32service/Win32Service.java -text
src/main/java/eu/etaxonomy/cdm/server/Bootloader.java
14 14
import static eu.etaxonomy.cdm.server.CommandOptions.HELP;
15 15
import static eu.etaxonomy.cdm.server.CommandOptions.HTTP_PORT;
16 16
import static eu.etaxonomy.cdm.server.CommandOptions.JMX;
17
import static eu.etaxonomy.cdm.server.CommandOptions.LOG_DIR;
17 18
import static eu.etaxonomy.cdm.server.CommandOptions.WEBAPP;
18 19
import static eu.etaxonomy.cdm.server.CommandOptions.WIN32SERVICE;
19
import static eu.etaxonomy.cdm.server.CommandOptions.LOG_DIR;
20 20

  
21
import java.io.BufferedReader;
21 22
import java.io.File;
22 23
import java.io.FileNotFoundException;
23 24
import java.io.FileOutputStream;
24 25
import java.io.IOException;
25 26
import java.io.InputStream;
27
import java.io.InputStreamReader;
26 28
import java.io.OutputStream;
27 29
import java.lang.management.ManagementFactory;
28 30
import java.lang.reflect.InvocationTargetException;
......
31 33
import java.sql.SQLException;
32 34
import java.util.List;
33 35
import java.util.Properties;
34
import java.util.Set;
35 36

  
36 37
import javax.naming.NamingException;
37 38
import javax.sql.DataSource;
......
48 49
import org.eclipse.jetty.jmx.MBeanContainer;
49 50
import org.eclipse.jetty.security.HashLoginService;
50 51
import org.eclipse.jetty.server.Server;
51
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
52 52
import org.eclipse.jetty.server.handler.ContextHandler.Context;
53
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
53 54
import org.eclipse.jetty.util.component.LifeCycle;
54 55
import org.eclipse.jetty.util.component.LifeCycle.Listener;
55 56
import org.eclipse.jetty.util.log.Log;
......
436 437

  
437 438
        verifyMemoryRequirements();
438 439

  
440
        verifySystemResources();
441

  
439 442

  
440 443
        server = new Server(httpPort);
441 444

  
......
564 567

  
565 568
    }
566 569

  
570
    private void verifySystemResources() {
571

  
572
        OsChecker osChecker = new OsChecker();
573
        if(osChecker.isLinux()){
574
            try {
575
                Process p = Runtime.getRuntime().exec(new String[] { "bash", "-c", "ulimit -n" });
576
                BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
577
                String line;
578
                StringBuilder response = new StringBuilder();
579
                     while ((line = in.readLine()) != null) {
580
                         response.append(line);
581
                     }
582
               logger.info("OS Limit (Linux): maximum number of open files: " + response);
583
            } catch (IOException e) {
584
                // TODO Auto-generated catch block
585
                e.printStackTrace();
586
            }
587
        } else {
588
            logger.info("verifySystemResources only implemented for linux");
589
        }
590
    }
591

  
567 592
    private void verifyMemoryRequirement(String memoryName, long requiredSpaceServer, long requiredSpacePerInstance, long availableSpace) {
568 593

  
569 594

  
src/main/java/eu/etaxonomy/cdm/server/OsChecker.java
1
// $Id$
2
/**
3
 * Copyright (C) 2009 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10
package eu.etaxonomy.cdm.server;
11

  
12
/**
13
 * @author andreas
14
 * @date Jul 17, 2012
15
 *
16
 */
17
public class OsChecker {
18

  
19
    public boolean isMac() {
20
        try {
21
            Class.forName("com.apple.eawt.Application");
22
            return true;
23
        } catch (Exception e) {
24
            return false;
25
        }
26
    }
27

  
28
    // can be defeated by creating a cmd.exe in PATH
29
    public boolean isWin() {
30
        try {
31
            Runtime.getRuntime().exec(new String[] { "cmd.exe", "/C", "dir" }).waitFor();
32
            return true;
33
        } catch (Exception e) {
34
            return false;
35
        }
36
    }
37

  
38
    public boolean isLinux() {
39
        if (isMac())
40
            return false;
41
        try {
42
            Runtime.getRuntime().exec(new String[] { "sh", "-c", "ls" }).waitFor();
43
            return true;
44
        } catch (Exception e) {
45
            return false;
46
        }
47
    }
48

  
49
}

Also available in: Unified diff