Example usage for java.util.logging Level INFO

List of usage examples for java.util.logging Level INFO

Introduction

In this page you can find the example usage for java.util.logging Level INFO.

Prototype

Level INFO

To view the source code for java.util.logging Level INFO.

Click Source Link

Document

INFO is a message level for informational messages.

Usage

From source file:gov.nih.nci.queue.servlet.FileUploadServlet.java

/**
 * *************************************************
 * URL: /upload doPost(): upload the files and other parameters
 *
 * @param request/*from w w  w  . j  a  v a 2 s  . c om*/
 * @param response
 * @throws javax.servlet.ServletException
 * @throws java.io.IOException
 * **************************************************
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    // Create an object for JSON response.
    ResponseModel rm = new ResponseModel();
    // Set response type to json
    response.setContentType("application/json");
    PrintWriter writer = response.getWriter();

    // Get property values.
    // SOCcer related.
    final Double estimatedThreshhold = Double
            .valueOf(PropertiesUtil.getProperty("gov.nih.nci.soccer.computing.time.threshhold").trim());
    // FileUpload Settings.
    final String repositoryPath = PropertiesUtil.getProperty("gov.nih.nci.queue.repository.dir");
    final String strOutputDir = PropertiesUtil.getProperty("gov.nih.cit.soccer.output.dir").trim();
    final long fileSizeMax = 10000000000L; // 10G
    LOGGER.log(Level.INFO, "repository.dir: {0}, filesize.max: {1}, time.threshhold: {2}",
            new Object[] { repositoryPath, fileSizeMax, estimatedThreshhold });

    // Check that we have a file upload request
    // Check that we have a file upload request
    boolean isMultipart = ServletFileUpload.isMultipartContent(request);

    // Ensuring that the request is actually a file upload request.
    if (isMultipart) {
        // Create a factory for disk-based file items
        DiskFileItemFactory factory = new DiskFileItemFactory();

        //upload file dirctory. If it does not exist, create one.
        File f = new File(repositoryPath);
        if (!f.exists()) {
            f.mkdir();
        }
        // Set factory constraints
        // factory.setSizeThreshold(yourMaxMemorySize);
        // Configure a repository
        factory.setRepository(new File(repositoryPath));

        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);
        upload.setFileSizeMax(fileSizeMax);

        try {
            // Parse the request
            List<FileItem> items = upload.parseRequest(request);

            // Process the uploaded items
            Iterator<FileItem> iter = items.iterator();
            while (iter.hasNext()) {
                FileItem item = iter.next();

                if (!item.isFormField()) { // Handle file field.
                    String fileName = item.getName();
                    rm.setFileName(fileName);
                    String contentType = item.getContentType();
                    rm.setFileType(contentType);
                    long sizeInBytes = item.getSize();
                    rm.setFileSize(String.valueOf(sizeInBytes));

                    String inputFileId = new UniqueIdUtil(fileName).getInputUniqueID();
                    rm.setInputFileId(inputFileId);
                    String absoluteInputFileName = repositoryPath + File.separator + inputFileId;
                    rm.setRepositoryPath(repositoryPath);

                    // Write file to the destination folder.
                    File inputFile = new File(absoluteInputFileName);
                    item.write(inputFile);

                    // Validation.
                    InputFileValidator validator = new InputFileValidator();
                    List<String> validationErrors = validator.validateFile(inputFile);

                    if (validationErrors == null) { // Pass validation
                        // check estimatedProcessingTime.
                        SoccerServiceHelper soccerHelper = new SoccerServiceHelper(strOutputDir);
                        Double estimatedTime = soccerHelper.getEstimatedTime(absoluteInputFileName);
                        rm.setEstimatedTime(String.valueOf(estimatedTime));
                        if (estimatedTime > estimatedThreshhold) { // STATUS: QUEUE (Ask client for email)
                            // Construct Response String in JSON format.
                            rm.setStatus("queue");
                        } else { // STATUS: PASS (Ask client to confirm calculate)
                            // all good. Process the output and Go to result page directly.
                            rm.setStatus("pass");
                        }
                    } else { // STATUS: FAIL // Did not pass validation.
                        // Construct Response String in JSON format.
                        rm.setStatus("invalid");
                        rm.setDetails(validationErrors);
                    }
                } else {
                    // TODO: Handle Form Fields such as SOC_SYSTEM.
                } // End of isFormField
            }
        } catch (Exception e) {
            LOGGER.log(Level.SEVERE, "FileUploadException or FileNotFoundException. Error Message: {0}",
                    new Object[] { e.getMessage() });
            rm.setStatus("fail");
            rm.setErrorMessage(
                    "Oops! We met with problems when uploading your file. Error Message: " + e.getMessage());
        }

        // Send the response.
        ObjectMapper jsonMapper = new ObjectMapper();
        LOGGER.log(Level.INFO, "Response: {0}", new Object[] { jsonMapper.writeValueAsString(rm) });
        // Generate metadata file
        new MetadataFileUtil(rm.getInputFileId(), repositoryPath)
                .generateMetadataFile(jsonMapper.writeValueAsString(rm));
        // Responde to the client.
        writer.print(jsonMapper.writeValueAsString(rm));

    } else { // The request is NOT actually a file upload request
        writer.print("You hit the wrong file upload page. The request is NOT actually a file upload request.");
    }
}

From source file:de.static_interface.sinklibrary.util.Debug.java

public static void log(@Nonnull String message) {
    logInternal(Level.INFO, message, null);
}

From source file:eu.ascetic.zabbixdatalogger.datasource.hostvmfilter.NamedList.java

/**
 * This creates a name filter that checks to see if the start of a host name
 * matches particular criteria or not. if it does then it will indicate
 * accordingly that the "Zabbix JSON API host" is a host or VM.
 *///from   w w  w .  java 2  s . co m
public NamedList() {
    try {
        PropertiesConfiguration config;
        if (new File(CONFIG_FILE).exists()) {
            config = new PropertiesConfiguration(CONFIG_FILE);
        } else {
            config = new PropertiesConfiguration();
            config.setFile(new File(CONFIG_FILE));
        }
        config.setAutoSave(true); //This will save the configuration file back to disk. In case the defaults need setting.
        namedSet = config.getString("data.logger.filter.names", namedSet);
        config.setProperty("data.logger.filter.names", namedSet);
        hostNames.addAll(Arrays.asList(namedSet.split(",")));
    } catch (ConfigurationException ex) {
        Logger.getLogger(NameBeginsFilter.class.getName()).log(Level.INFO,
                "Error loading the configuration of the named list filter");
    }
}

From source file:ke.co.pixie.daemon.JavaDaemon.java

/**
 * Used to configuration files, create a trace file, create ServerSockets,
 * Threads, etc./*ww w.  j a v a 2 s.co  m*/
 *
 * @param context the DaemonContext
 *
 * @throws DaemonInitException on error
 */
@Override
public void init(final DaemonContext context) throws DaemonInitException {
    worker = new Thread(this);
    DaemonLogger.log(Level.INFO, "Initializing daemon...");
}

From source file:onl.area51.httpd.HttpRequestHandlerBuilder.java

default HttpRequestHandlerBuilder log() {
    return log(Logger.getGlobal(), Level.INFO);
}

From source file:ws.util.AbstractJSONCoder.java

@Override
public String encode(T pojo) throws EncodeException {
    StringBuilder log = new StringBuilder().append(type).append("| [coder] encoding..").append(pojo);
    String json = null;//from w w w .  j ava2s  . c  o m
    try {
        ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
        // Jackson jr ??@JsonManagedReference, @JsonBackReference????
        //                  json = JSON.std.asString(pojo);
        json = ow.writeValueAsString(pojo);
        log.append(" DONE.");
    } catch (IOException e) {
        log.append(" **NG**.");
        logger.log(Level.SEVERE, e.toString());
        e.printStackTrace();
        throw new EncodeException(json, e.getMessage());
    } catch (Exception e) {
        log.append(" **NG**.");
        logger.log(Level.SEVERE, e.toString());
        e.printStackTrace();
        throw new EncodeException(json, e.getMessage());
    } finally {
        logger.log(Level.INFO, log.toString());
    }
    //            logger.log(Level.INFO, new StringBuilder()
    //                  .append("[coder] done: ")
    //                  .append(json)
    //                  .toString());
    return json;
}

From source file:org.hydroponics.web.controller.HydroponicsController.java

@RequestMapping(value = "/main.htm")
public ModelAndView overviewHandler() {

    logger.info("/main.htm");

    ModelAndView mav = new ModelAndView();
    Map<String, Object> grow = hydroponicsDao.getCurrentGrow();
    mav.addObject(Constants.GROW, grow);
    mav.addObject(Constants.CALIBRE, hydroponicsDao.getCalibre());

    List<Map<String, Object>> switches = hydroponicsClientHandler.getStatus();
    if (switches != null) {
        for (Map<String, Object> s : switches) {
            Integer id = (Integer) s.get(Constants.NUMBER);
            String name = hydroponicsDao.getSwitchName(id);
            s.put(Constants.NAME, (name == null || name.isEmpty() ? "Switch " + id : name));
        }/*w  w w. j a va2  s.  co  m*/
    } else {
        switches = new ArrayList<Map<String, Object>>();
    }
    logger.log(Level.INFO, new StringBuffer("switches:").append(switches).toString());

    mav.addObject(Constants.SWITCHES, switches);
    if (grow != null && grow.containsKey(Constants.ID)) {
        mav.addObject(Constants.IMAGES, hydroponicsDao.getImages((Integer) grow.get(Constants.ID)));
    }
    return mav;
}

From source file:fr.ortolang.diffusion.statistics.PiwikGenericCollector.java

@Override
public void run() {
    PiwikTracker tracker = new PiwikTracker(host + "index.php");

    for (String alias : workspaces) {
        try {//from w ww .  ja  v a2  s  .com
            LOGGER.log(Level.INFO,
                    "Collect stats for workspace with alias [" + alias + "] (range: " + range + ")");
            // Views
            PiwikRequest request = makePiwikRequestForViews(siteId, authToken, alias, range);
            HttpResponse viewsResponse = tracker.sendRequest(request);
            // Downloads
            request = makePiwikRequestForDownloads(siteId, authToken, alias, range);
            HttpResponse downloadsResponse = tracker.sendRequest(request);
            // Single Downloads
            request = makePiwikRequestForSingleDownloads(siteId, authToken, alias, range);
            HttpResponse singleDownloadsResponse = tracker.sendRequest(request);
            compileResults(alias, timestamp, viewsResponse, downloadsResponse, singleDownloadsResponse);
        } catch (IOException e) {
            LOGGER.log(Level.SEVERE,
                    "Could not probe Piwik stats for workspace with alias [" + alias + "]: " + e.getMessage(),
                    e);
        }
    }
}

From source file:ComputeNode.java

public ComputeNode(String servername, Double _underLoadThreshold, Double _overLoadThreshold,
        Double _failProbability, Double _loadConstant, Pair<Double, Double> _loadGaussian, String configFile)
        throws Exception {

    server = (ServerInterface) Naming.lookup("//" + servername + "/Server");

    id = server.registerNode();/*from  w  w  w  .j a  va  2  s  .  com*/

    lg = new Logger("Compute Node:" + id);
    lg.log(Level.INFO, "ComputeNode " + id + " started.");

    // If a config file was specified
    if (configFile == null) {
        configFile = defaultconf;
    }

    try {
        // TODO: Only load if we need to.
        Properties properties = new Properties();
        properties.load(new FileInputStream(configFile));

        if (_overLoadThreshold == null)
            _overLoadThreshold = new Double(properties.getProperty("computenode.overload_threshhold"));
        overLoadThreshold = _overLoadThreshold;

        if (_underLoadThreshold == null)
            _underLoadThreshold = new Double(properties.getProperty("computenode.underload_threshhold"));
        underLoadThreshold = _underLoadThreshold;

        if (_failProbability == null)
            _failProbability = new Double(properties.getProperty("computenode.fail_probability"));
        failProbability = _failProbability;

        lg.log(Level.FINER, "ComputeNode " + id + ": under load threshhold = " + underLoadThreshold);
        lg.log(Level.FINER, "ComputeNode " + id + ": over load threshhold = " + overLoadThreshold);
        lg.log(Level.FINER, "ComputeNode " + id + ": fail probability = " + failProbability);

        loadConstant = _loadConstant;
        if (loadConstant != null)
            lg.log(Level.FINER, "ComputeNode " + id + ": load constant = " + loadConstant);

        loadGaussian = _loadGaussian;
        if (loadGaussian != null)
            lg.log(Level.FINER,
                    "ComputeNode " + id + ": load gaussian = " + loadGaussian.fst() + "," + loadGaussian.snd());

    } catch (Exception e) {
        lg.log(Level.SEVERE, "ComputeNode " + id + ": Constructor failure! " + underLoadThreshold);
        e.printStackTrace();
        System.exit(1);
    }

    myNodeStats = new NodeStats();
    myNodeStats.setCurrentLoad(getCurrentLoad());
}

From source file:cz.incad.kramerius.k5indexer.IndexDocs.java

private void getDocs(int start) throws Exception {

    _init = true;//from  w  ww .j  a v a 2  s  . c o m
    docs.clear();

    String urlStr = host + "/select?wt=" + wt + "&q=" + URLEncoder.encode(query, "UTF-8") + "&rows=" + rows
            + "&start=" + (start + initStart);
    if (fl != null) {
        urlStr += "&fl=" + fl;
    }
    logger.log(Level.INFO, "urlStr: {0}", urlStr);

    java.net.URL url = new java.net.URL(urlStr);
    InputStream is;
    StringWriter resp = new StringWriter();
    try {
        is = url.openStream();
    } catch (Exception ex) {
        logger.log(Level.WARNING, "", ex);
        is = url.openStream();
    }

    if (wt.equals("json")) {
        org.apache.commons.io.IOUtils.copy(is, resp, "UTF-8");
        JSONObject json = new JSONObject(resp.toString());
        JSONObject response = json.getJSONObject("response");
        numFound = response.getInt("numFound");
        JSONArray jdocs = response.getJSONArray("docs");
        numDocs = jdocs.length();
        for (int i = 0; i < jdocs.length(); i++) {
            docs.add(jdocs.getJSONObject(i));
        }
    } else {

        Document respDoc = builder.parse(is);
        numFound = Integer.parseInt(respDoc.getElementsByTagName("result").item(0).getAttributes()
                .getNamedItem("numFound").getNodeValue());
        numDocs = respDoc.getElementsByTagName("doc").getLength();
        docs.add(respDoc);
    }

}