Example usage for java.util.logging Level FINER

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

Introduction

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

Prototype

Level FINER

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

Click Source Link

Document

FINER indicates a fairly detailed tracing message.

Usage

From source file:org.cloudifysource.shell.installer.LocalhostGridAgentBootstrapper.java

/**
 * Shuts down the given agent, and waits until shutdown is complete or until the timeout is reached.
 * /*from   w w w. j a v a2  s  . co m*/
 * @param agent
 *            The agent to shutdown
 * @param timeout
 *            number of {@link TimeUnit}s to wait
 * @param timeunit
 *            the {@link TimeUnit} to use, to calculate the timeout
 * @throws InterruptedException
 *             Reporting the thread was interrupted while waiting
 * @throws TimeoutException
 *             Reporting the timeout was reached
 * @throws CLIException
 *             Reporting a failure to shutdown the agent
 */
private void shutdownAgentAndWait(final GridServiceAgent agent, final long timeout, final TimeUnit timeunit)
        throws InterruptedException, TimeoutException, CLIException {

    // We need to shutdown the agent after we close the admin to avoid
    // closed exception since the admin
    // still monitors
    // the deployment behind the scenes, we call the direct proxy to the gsa
    // since the admin is closed and
    // we don't
    // want to use objects it generated
    final GSA gsa = ((InternalGridServiceAgent) agent).getGSA();
    try {
        gsa.shutdown();
    } catch (final RemoteException e) {
        if (!NetworkExceptionHelper.isConnectOrCloseException(e)) {
            logger.log(Level.FINER, "Failed to shutdown GSA", e);
            throw new AdminException("Failed to shutdown GSA", e);
        }
    }

    createConditionLatch(timeout, timeunit).waitFor(new ConditionLatch.Predicate() {

        private boolean messagePublished = false;

        /**
         * Pings the agent to verify it's not available, indicating it was shut down.
         */
        @Override
        public boolean isDone() throws CLIException, InterruptedException {
            if (!messagePublished) {
                final String shuttingDownAgentMessage = ShellUtils.getMessageBundle()
                        .getString("shutting_down_cloudify_agent_teardown_localcloud");
                publishEvent(shuttingDownAgentMessage);

                final String shuttingDownManagmentMessage = ShellUtils.getMessageBundle()
                        .getString("shutting_down_cloudify_management");
                publishEvent(shuttingDownManagmentMessage);

                messagePublished = true;
            }
            logger.fine("Waiting for agent to shutdown");
            try {
                gsa.ping();
            } catch (final RemoteException e) {
                // Probably NoSuchObjectException meaning the GSA is going
                // down
                return true;
            }
            publishEvent(null);
            return false;
        }

    });
}

From source file:org.b3log.latke.repository.gae.GAERepository.java

/**
 * Gets result json object by the specified query, current page number,
 * page size, page count and cache key.//from  w w w.  j  a v a2s  .c  om
 * 
 * <p>
 * If the specified page count equals to {@code -1}, this method will calculate the page count.  
 * </p>
 *
 * @param query the specified query
 * @param currentPageNum the specified current page number
 * @param pageSize the specified page size
 * @param pageCount the specified page count
 * @param cacheKey the specified cache key of a query
 * @return for example,
 * <pre>
 * {
 *     "pagination": {
 *       "paginationPageCount": 88250
 *     },
 *     "rslts": [{
 *         "oId": "...."
 *     }, ....]
 * }
 * </pre>
 * @throws RepositoryException repository exception
 */
private JSONObject get(final Query query, final int currentPageNum, final int pageSize, final int pageCount,
        final String cacheKey) throws RepositoryException {
    final PreparedQuery preparedQuery = datastoreService.prepare(query);

    int pageCnt = pageCount;

    if (-1 == pageCnt) { // Application caller dose not specify the page count
        // Calculates the page count
        long count = -1;
        final String countCacheKey = cacheKey + REPOSITORY_CACHE_COUNT;

        if (cacheEnabled) {
            final Object o = CACHE.get(countCacheKey);

            if (null != o) {
                LOGGER.log(Level.FINER, "Got an object[cacheKey={0}] from repository cache[name={1}]",
                        new Object[] { countCacheKey, getName() });
                count = (Long) o;
            }
        }

        if (-1 == count) {
            count = preparedQuery.countEntities(FetchOptions.Builder.withDefaults());
            LOGGER.log(Level.WARNING, "Invoked countEntities() for repository[name={0}, count={1}]",
                    new Object[] { getName(), count });

            if (cacheEnabled) {
                CACHE.putAsync(countCacheKey, count);
                LOGGER.log(Level.FINER, "Added an object[cacheKey={0}] in repository cache[{1}]",
                        new Object[] { countCacheKey, getName() });
            }
        }

        pageCnt = (int) Math.ceil((double) count / (double) pageSize);
    }

    final JSONObject ret = new JSONObject();

    try {
        final JSONObject pagination = new JSONObject();

        ret.put(Pagination.PAGINATION, pagination);
        pagination.put(Pagination.PAGINATION_PAGE_COUNT, pageCnt);

        QueryResultList<Entity> queryResultList;

        if (1 != currentPageNum) {
            final Cursor startCursor = getStartCursor(currentPageNum, pageSize, preparedQuery);

            queryResultList = preparedQuery.asQueryResultList(
                    withStartCursor(startCursor).limit(pageSize).chunkSize(QUERY_CHUNK_SIZE));
        } else { // The first page
            queryResultList = preparedQuery.asQueryResultList(withLimit(pageSize).chunkSize(QUERY_CHUNK_SIZE));
        }

        // Converts entities to json objects
        final JSONArray results = new JSONArray();

        ret.put(Keys.RESULTS, results);
        for (final Entity entity : queryResultList) {
            final JSONObject jsonObject = entity2JSONObject(entity);

            results.put(jsonObject);
        }

        LOGGER.log(Level.FINER,
                "Found objects[size={0}] at page[currentPageNum={1}, pageSize={2}] in repository[{3}]",
                new Object[] { results.length(), currentPageNum, pageSize, getName() });
    } catch (final Exception e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
        throw new RepositoryException(e);
    }

    return ret;
}

From source file:edu.umass.cs.gigapaxos.PaxosInstanceStateMachine.java

private MessagingTask[] handleProposal(RequestPacket proposal) {
    assert (proposal.getEntryReplica() != IntegerMap.NULL_INT_NODE) : proposal;
    // could be multicast to all or unicast to coordinator
    MessagingTask[] mtasks = new MessagingTask[2];
    RequestInstrumenter.received(proposal, proposal.getForwarderID(), this.getMyID());
    if (PaxosCoordinator.exists(this.coordinator, this.paxosState.getBallot())) {
        // multicast ACCEPT to all
        AcceptPacket multicastAccept = null;
        proposal.addDebugInfoDeep("a");
        multicastAccept = PaxosCoordinator.propose(this.coordinator, this.groupMembers, proposal);
        if (multicastAccept != null) {
            assert (this.coordinator.getBallot().coordinatorID == getMyID()
                    && multicastAccept.sender == getMyID());
            if (proposal.isBroadcasted())
                multicastAccept = this.paxosManager.digest(multicastAccept);
            mtasks[0] = multicastAccept != null ? new MessagingTask(this.groupMembers, multicastAccept) : null; // multicast
            RequestInstrumenter.sent(multicastAccept, this.getMyID(), -1);
            log.log(Level.FINER, "{0} issuing accept {1} ",
                    new Object[] { this, multicastAccept.getSummary(log.isLoggable(Level.FINER)) });
        }/*from  w  w  w  .  j  a v a2 s.co  m*/
    } else if (!proposal.isBroadcasted()) { // else unicast to current
        // coordinator
        log.log(Level.FINER, "{0} is not the coordinator; forwarding to {1}: {2}", new Object[] { this,
                this.paxosState.getBallotCoordLog(), proposal.getSummary(log.isLoggable(Level.FINER)) });
        int coordinator = this.paxosState.getBallotCoord();

        mtasks[0] = new MessagingTask(this.paxosManager.isNodeUp(coordinator) ? coordinator
                // send to next coordinator if current seems dead
                : (coordinator = this.getNextCoordinator(this.paxosState.getBallot().ballotNumber + 1,
                        groupMembers)),
                proposal.setForwarderID(this.getMyID())); // unicast
        if ((proposal.isPingPonging() || coordinator == this.getMyID())) {
            if (proposal.isPingPonging())
                log.warning(this + " jugglinging ping-ponging proposal: " + proposal.getSummary()
                        + " forwarded by " + proposal.getForwarderID());
            Level level = Level.INFO;
            log.log(level,
                    "{0} force running for coordinator; forwardCount={1}; debugInfo = {2}; coordinator={3}",
                    new Object[] { this, proposal.getForwardCount(),
                            proposal.getDebugInfo(log.isLoggable(level)), coordinator });
            if (proposal.getForwarderID() != this.getMyID())
                mtasks[1] = new MessagingTask(getMyID(), mtasks[0].msgs);
            mtasks[0] = this.checkRunForCoordinator(true);
        } else { // forwarding
            proposal.addDebugInfo("f", coordinator);
        }
    }
    return mtasks;
}

From source file:com.ibm.jaggr.core.impl.transport.AbstractHttpTransport.java

/**
 * Returns the has conditions specified in the request as a base64 encoded
 * trit map of feature values where each trit (three state value - 0, 1 and
 * don't care) represents the state of a feature in the list of
 * deendentFeatures that was sent to the client in the featureMap JavaScript
 * resource served by/*from w ww  . j  a v  a  2s. com*/
 * {@link AbstractHttpTransport.FeatureListResourceFactory}.
 * <p>
 * Each byte from the base64 decoded byte array encodes 5 trits (3**5 = 243
 * states out of the 256 possible states).
 *
 * @param request
 *            The http request object
 * @return the decoded feature list as a string, or null
 * @throws IOException
 */
protected Features getFeaturesFromRequestEncoded(HttpServletRequest request) throws IOException {
    final String methodName = "getFeaturesFromRequestEncoded"; //$NON-NLS-1$
    boolean traceLogging = log.isLoggable(Level.FINER);
    if (traceLogging) {
        log.entering(AbstractHttpTransport.class.getName(), methodName, new Object[] { request });
    }
    if (depsInitialized == null) {
        if (traceLogging) {
            log.finer("No initialization semphore"); //$NON-NLS-1$
            log.exiting(AbstractHttpTransport.class.getName(), methodName);
        }
        return null;
    }
    String encoded = request.getParameter(ENCODED_FEATURE_MAP_REQPARAM);
    if (encoded == null) {
        if (traceLogging) {
            log.finer(ENCODED_FEATURE_MAP_REQPARAM + " param not specified in request"); //$NON-NLS-1$
            log.exiting(AbstractHttpTransport.class.getName(), methodName);
        }
        return null;
    }
    if (traceLogging) {
        log.finer(ENCODED_FEATURE_MAP_REQPARAM + " param = " + encoded); //$NON-NLS-1$
    }
    try {
        depsInitialized.await();
    } catch (InterruptedException e) {
        throw new IOException(e);
    }

    byte[] decoded = Base64.decodeBase64(encoded);
    int len = dependentFeatures.size();
    ByteArrayOutputStream bos = new ByteArrayOutputStream(len);

    // Validate the input - first two bytes specify length of feature list on the client
    if (len != (decoded[0] & 0xFF) + ((decoded[1] & 0xFF) << 8)
            || decoded.length != len / 5 + (len % 5 == 0 ? 0 : 1) + 2) {
        if (log.isLoggable(Level.FINER)) {
            log.finer("Invalid encoded feature list.  Expected feature list length = " + len); //$NON-NLS-1$
        }
        throw new BadRequestException("Invalid encoded feature list"); //$NON-NLS-1$
    }
    // Now decode the trit map
    for (int i = 2; i < decoded.length; i++) {
        int q = decoded[i] & 0xFF;
        for (int j = 0; j < 5 && (i - 2) * 5 + j < len; j++) {
            bos.write(q % 3);
            q = q / 3;
        }
    }
    Features result = new Features();
    int i = 0;
    for (byte b : bos.toByteArray()) {
        if (b < 2) {
            result.put(dependentFeatures.get(i), b == 1);
        }
        i++;
    }
    if (traceLogging) {
        log.exiting(AbstractHttpTransport.class.getName(), methodName, result);
    }
    return result;
}

From source file:org.eclipse.birt.report.engine.api.ReportRunner.java

/**
 * new a EngineConfig and config it with user's setting
 * /*from  ww w.  ja v  a 2 s . c  o  m*/
 */
protected EngineConfig createEngineConfig() {
    EngineConfig config = new EngineConfig();

    String resourcePath = (String) params.get("resourceDir");
    if (resourcePath != null)
        config.setResourcePath(resourcePath.trim());

    String tempDir = (String) params.get("tempDir");
    if (tempDir != null)
        config.setTempDir(tempDir.trim());

    String logDir = (String) params.get("logDir");
    String logLevel = (String) params.get("logLevel");
    Level level = null;
    if (logLevel != null) {
        logLevel = logLevel.trim();
        if ("all".equalsIgnoreCase(logLevel)) {
            level = Level.ALL;
        } else if ("config".equalsIgnoreCase(logLevel)) {
            level = Level.CONFIG;
        } else if ("fine".equalsIgnoreCase(logLevel)) {
            level = Level.FINE;
        } else if ("finer".equalsIgnoreCase(logLevel)) {
            level = Level.FINER;
        } else if ("finest".equalsIgnoreCase(logLevel)) {
            level = Level.FINEST;
        } else if ("info".equalsIgnoreCase(logLevel)) {
            level = Level.INFO;
        } else if ("off".equalsIgnoreCase(logLevel)) {
            level = Level.OFF;
        } else if ("severe".equalsIgnoreCase(logLevel)) {
            level = Level.SEVERE;
        } else if ("warning".equalsIgnoreCase(logLevel)) {
            level = Level.WARNING;
        }
    }
    String logD = (logDir == null) ? config.getLogDirectory() : logDir;
    Level logL = (level == null) ? config.getLogLevel() : level;
    config.setLogConfig(logD, logL);

    String logFile = (String) params.get("logFile");
    if (logFile != null)
        config.setLogFile(logFile.trim());

    String scripts = (String) params.get("scriptPath");
    HashMap map = new HashMap();
    map.put(EngineConstants.PROJECT_CLASSPATH_KEY, scripts);
    config.setAppContext(map);

    return config;
}

From source file:com.ibm.team.build.internal.hjplugin.util.HttpUtils.java

private static void closeResponse(CloseableHttpResponse formResponse) {
    if (formResponse != null) {
        try {//from  w w  w  .  ja va  2  s .c o  m
            formResponse.close();
        } catch (IOException e) {
            // we don't care we are logged in or are throwing an exception for a different problem
            LOGGER.log(Level.FINER, "Failed to close response", e);
        }
    }
}

From source file:com.ibm.team.build.internal.hjplugin.util.HttpUtils.java

/**
 * Print the HTTP request - for debugging purposes
 *///from   www.  ja va2 s.com
@SuppressWarnings("unused")
private static void printRequest(HttpRequestBase request) {
    if (LOGGER.isLoggable(Level.FINER)) {
        StringBuffer logMessage = new StringBuffer();
        logMessage.append(NEW_LINE).append("\t- Method: ").append(request.getMethod()); //$NON-NLS-1$ //
        logMessage.append(NEW_LINE).append("\t- URL: ").append(request.getURI()); //$NON-NLS-1$
        logMessage.append(NEW_LINE).append("\t- Headers: "); //$NON-NLS-1$
        Header[] headers = request.getAllHeaders();
        for (int i = 0; i < headers.length; i++) {
            logMessage.append(NEW_LINE).append("\t\t- ").append(headers[i].getName()).append(": ") //$NON-NLS-1$//$NON-NLS-2$
                    .append(headers[i].getValue());
        }
        LOGGER.finer(logMessage.toString());
    }
}

From source file:org.archive.modules.fetcher.FetchHTTP.java

/**
 * Cleanup after a failed method execute.
 * //from w ww  .  jav a  2 s  . c o  m
 * @param curi
 *            CrawlURI we failed on.
 * @param exception
 *            Exception we failed with.
 * @param message
 *            Message to log with failure. FIXME: Seems ignored
 * @param status
 *            Status to set on the fetch.
 */
protected void cleanup(final CrawlURI curi, final Exception exception, final String message, final int status) {
    if (logger.isLoggable(Level.FINER)) {
        logger.log(Level.FINER, message + ": " + exception, exception);
    } else if (logger.isLoggable(Level.FINE)) {
        logger.fine(message + ": " + exception);
    }

    curi.getNonFatalFailures().add(exception);
    curi.setFetchStatus(status);
    curi.getRecorder().close();
}

From source file:org.cloudifysource.rest.controllers.ServiceController.java

/**
 * Creates and returns a list containing all of the deployed application details.
 *
 * @return a list of all the deployed applications in the service grid.
 * @throws RestErrorException .//from w w w.ja v a2 s . c  o m
 */
@JsonResponseExample(status = "success", responseBody = "[\"petclinic\", \"travel\"]", comments = "In the example, the deployed applications in the service grid are petclinic and travel")
@PossibleResponseStatuses(responseStatuses = {
        @PossibleResponseStatus(code = HTTP_OK, description = "success") })
@RequestMapping(value = "/applications/description", method = RequestMethod.GET)
@PreAuthorize("isFullyAuthenticated()")
@PostFilter("hasPermission(filterObject, 'view')")
@ResponseBody
public Map<String, Object> getApplicationDescriptionsList() throws RestErrorException {

    if (logger.isLoggable(Level.FINER)) {
        logger.finer("received request to list application descriptions");
    }

    final Applications apps = admin.getApplications();
    final List<ApplicationDescription> appDescriptions = new ArrayList<ApplicationDescription>();
    final ApplicationDescriptionFactory applicationDescriptionFactory = new ApplicationDescriptionFactory(
            admin);
    for (final Application app : apps) {
        if (!app.getName().equals(CloudifyConstants.MANAGEMENT_APPLICATION_NAME)) {
            final ApplicationDescription applicationDescription = applicationDescriptionFactory
                    .getApplicationDescription(app);
            appDescriptions.add(applicationDescription);
        }
    }

    return successStatus(appDescriptions);
}

From source file:com.ibm.team.build.internal.hjplugin.util.HttpUtils.java

/**
 * Print out the HTTPMessage headers - for debugging purposes
 *//*from  w w w.  j av  a 2  s. c om*/
private static void printMessageHeaders(HttpMessage message) {
    if (LOGGER.isLoggable(Level.FINER)) {
        StringBuffer logMessage = new StringBuffer("Message Headers:"); //$NON-NLS-1$
        Header[] headers = message.getAllHeaders();
        for (int i = 0; i < headers.length; i++) {
            logMessage.append(NEW_LINE).append("\t- ").append(headers[i].getName()).append(": ") //$NON-NLS-1$//$NON-NLS-2$
                    .append(headers[i].getValue());
        }
        LOGGER.finer(logMessage.toString());
    }
}