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:edu.umass.cs.gigapaxos.PaxosInstanceStateMachine.java

/**
 * For legacy reasons, this method still accepts JSONObject in addition to
 * PaxosPacket as the first argument./* w  w w.  j  a va 2s.  c om*/
 * 
 * @param obj
 * @param mode
 * @throws JSONException
 */
private void handlePaxosMessage(PaxosPacket pp, SyncMode mode) throws JSONException {
    long methodEntryTime = System.currentTimeMillis();
    assert (pp != null || !mode.equals(SyncMode.DEFAULT_SYNC));

    Level level = Level.FINEST;
    if (pp != null)
        log.log(level, "{0} received {1}", new Object[] { this, pp.getSummary(log.isLoggable(level)) });

    if (pp != null && pp.getVersion() != this.getVersion())
        return;

    /* Note: Because incoming messages may be handled concurrently, some
     * messages may continue to get processed for a little while after a
     * stop has been executed and even after isStopped() is true (because
     * isStopped() was false when those messages came in here). But that is
     * okay coz these messages can not spawn unsafe outgoing messages (as
     * messaging is turned off for all but DECISION or CHECKPOINT_STATE
     * packets) and can not change any disk state. */
    if (this.paxosState.isStopped()) {
        log.log(Level.INFO, "{0} stopped; dropping {1}", new Object[] { this, pp.getSummary() });
        return;
    }

    // recovery means we won't send any replies
    boolean recovery = pp != null ? PaxosPacket.isRecovery(pp) : false;
    /* The reason we should not process regular messages until this instance
     * has rolled forward is that it might respond to a prepare with a list
     * of accepts fetched from disk that may be inconsistent with its
     * acceptor state. */
    if (!this.paxosManager.hasRecovered(this) && !recovery)
        return; // only process recovery message during rollForward

    PaxosPacket.PaxosPacketType msgType = pp != null ? pp.getType() : PaxosPacket.PaxosPacketType.NO_TYPE;
    log.log(Level.FINEST, "{0} received {1}:{2}",
            new Object[] { this, msgType, pp != null ? pp.getSummary(log.isLoggable(Level.FINEST)) : pp });

    boolean isPoke = msgType.equals(PaxosPacketType.NO_TYPE);
    if (!isPoke)
        this.markActive();
    else
        log.log(Level.FINER, "{0} received NO_TYPE poke {1};", new Object[] { this, mode });

    MessagingTask[] mtasks = new MessagingTask[3];
    /* Check for coordinator'ing upon *every* message except poke messages.
     * Pokes are primarily for sync'ing decisions and could be also used to
     * resend accepts. There is little reason to send prepares proactively
     * if no new activity is happening. */
    mtasks[0] = (!recovery ?
    // check run for coordinator if not active
            (!PaxosCoordinator.isActive(this.coordinator)
                    // ignore pokes unless not caught up
                    && (!isPoke || !PaxosCoordinator.caughtUp(this.coordinator))) ? checkRunForCoordinator()
                            // else reissue long waiting accepts
                            : this.pokeLocalCoordinator()
            // neither during recovery
            : null);

    log.log(level, "{0} about to switch on packet type {1}",
            new Object[] { this, pp != null ? pp.getSummary(log.isLoggable(level)) : null });

    MessagingTask mtask = null;
    MessagingTask[] batchedTasks = null;

    switch (msgType) {
    case REQUEST:
        batchedTasks = handleRequest((RequestPacket) pp);
        // send RequestPacket to current coordinator
        break;
    // replica --> coordinator
    case PROPOSAL:
        batchedTasks = handleProposal((ProposalPacket) pp);
        // unicast ProposalPacket to coordinator or multicast AcceptPacket
        break;
    // coordinator --> replica
    case DECISION:
        mtask = handleCommittedRequest((PValuePacket) pp);
        // send nothing, but log decision
        break;
    case BATCHED_COMMIT:
        mtask = handleBatchedCommit((BatchedCommit) pp);
        // send nothing, but log decision
        break;
    // coordinator --> replica
    case PREPARE:
        mtask = handlePrepare((PreparePacket) pp);
        // send PreparePacket prepare reply to coordinator
        break;
    // replica --> coordinator
    case PREPARE_REPLY:
        mtask = handlePrepareReply((PrepareReplyPacket) pp);
        // send AcceptPacket[] to all
        break;
    // coordinator --> replica
    case ACCEPT:
        batchedTasks = handleAccept((AcceptPacket) pp);
        // send AcceptReplyPacket to coordinator
        break;
    // replica --> coordinator
    case ACCEPT_REPLY:
        mtask = handleAcceptReply((AcceptReplyPacket) pp);
        // send PValuePacket decision to all
        break;
    case BATCHED_ACCEPT_REPLY:
        batchedTasks = handleBatchedAcceptReply((BatchedAcceptReply) pp);
        // send PValuePacket decisions to all
        break;
    case BATCHED_ACCEPT:
        batchedTasks = handleBatchedAccept((BatchedAccept) pp);
        break;
    case SYNC_DECISIONS_REQUEST:
        mtask = handleSyncDecisionsPacket((SyncDecisionsPacket) pp);
        // send SynchronizeReplyPacket to sender
        break;
    case CHECKPOINT_STATE:
        mtask = handleCheckpoint((StatePacket) pp);
        break;
    case NO_TYPE: // not a real packet
        // sync if needed on poke
        mtasks[0] = (mtasks[0] != null) ? mtasks[0] : this.syncLongDecisionGaps(null, mode);
        break;
    default:
        assert (false) : "Paxos instance received an unrecognizable packet: " + (pp.getSummary());
    }
    mtasks[1] = mtask;

    // special case for method returning array of messaging tasks
    if (batchedTasks != null) {
        // mtasks[1] = batchedTasks[0];
        // mtasks[2] = batchedTasks[1];
        mtasks = MessagingTask.combine(mtasks, batchedTasks);
    }

    instrumentDelay(toLog.handlePaxosMessage, methodEntryTime);

    this.checkIfTrapped(pp, mtasks[1]); // just to print a warning
    if (!recovery) {
        this.sendMessagingTask(mtasks);
    }
}

From source file:edu.emory.cci.aiw.i2b2etl.dest.I2b2QueryResultsHandler.java

@Override
public void handleQueryResult(String keyId, List<Proposition> propositions,
        Map<Proposition, List<Proposition>> forwardDerivations,
        Map<Proposition, List<Proposition>> backwardDerivations, Map<UniqueId, Proposition> references)
        throws QueryResultsHandlerProcessingException {
    Logger logger = I2b2ETLUtil.logger();
    logger.log(Level.FINER, "Loading patient into i2b2");
    try {/*from  ww  w .java  2s .  co  m*/
        Set<Proposition> derivedPropositions = new HashSet<>();
        PatientDimension pd = null;
        for (Proposition prop : propositions) {
            if (prop.getId().equals(this.visitPropId)) {
                pd = handlePatient(pd, keyId, prop, references, forwardDerivations, backwardDerivations,
                        derivedPropositions);
            }
        }
    } catch (InvalidConceptCodeException | InvalidFactException | InvalidPatientRecordException
            | SQLException ex) {
        throw new QueryResultsHandlerProcessingException(
                "Load into i2b2 failed for query " + this.query.getName(), ex);
    }
    logger.log(Level.FINER, "Done loading patient into i2b2");
}

From source file:tigase.muc.modules.PresenceModule.java

/**
* Method description//from  w  w w.  j  ava2s  .  co m
* 
* 
* @param element
* 
* @throws MUCException
* @throws TigaseStringprepException
*/
@Override
public void process(Packet element) throws MUCException, TigaseStringprepException {
    final JID senderJID = JID.jidInstance(element.getAttributeStaticStr(Packet.FROM_ATT));
    final BareJID roomJID = BareJID.bareJIDInstance(element.getAttributeStaticStr(Packet.TO_ATT));
    final String nickName = getNicknameFromJid(JID.jidInstance(element.getAttributeStaticStr(Packet.TO_ATT)));
    final String presenceType = element.getAttributeStaticStr(Packet.TYPE_ATT);

    // final String id = element.getAttribute("id");
    if ((presenceType != null) && "error".equals(presenceType)) {
        if (log.isLoggable(Level.FINER)) {
            log.finer("Ignoring presence with type='" + presenceType + "' from " + senderJID);
        }

        return;
    }
    if (nickName == null) {
        throw new MUCException(Authorization.JID_MALFORMED);
    }
    try {
        Room room = repository.getRoom(roomJID);

        if ((presenceType != null) && "unavailable".equals(presenceType)) {
            processExit(room, element.getElement(), senderJID);

            return;
        }

        final String knownNickname;
        final boolean roomCreated;

        int roomStauts = internalValidRoom(roomJID.toString(), senderJID.toString());

        if ((roomStauts == -1) || (roomStauts != 0 && room == null)) {
            throw new MUCException(Authorization.NOT_ALLOWED, "you are not allowed to enter this room");
        }

        if (room == null) {
            if (log.isLoggable(Level.INFO)) {
                log.info("Creating new room '" + roomJID + "' by user " + nickName + "' <"
                        + senderJID.toString() + ">");
            }
            room = repository.createNewRoom(roomJID, senderJID);
            room.addAffiliationByJid(senderJID.getBareJID(), Affiliation.owner);
            room.setRoomLocked(this.lockNewRoom);
            room.setRoomLocked(false);
            roomCreated = true;
            knownNickname = null;
            room.getConfig().notifyConfigUpdate();
        } else {
            roomCreated = false;
            knownNickname = room.getOccupantsNickname(senderJID);
        }

        final boolean probablyReEnter = element.getElement().getChild("x",
                "http://jabber.org/protocol/muc") != null;

        if ((knownNickname != null) && !knownNickname.equals(nickName)) {
            processChangeNickname(room, element.getElement(), senderJID, knownNickname, nickName);
        } else if (probablyReEnter || (knownNickname == null)) {
            processEntering(room, roomCreated, element.getElement(), senderJID, nickName);
        } else if (knownNickname.equals(nickName)) {
            processChangeAvailabilityStatus(room, element.getElement(), senderJID, knownNickname);
        }
    } catch (MUCException e) {
        throw e;
    } catch (TigaseStringprepException e) {
        throw e;
    } catch (RepositoryException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.b3log.latke.servlet.RequestProcessors.java

/**
 * Scans classpath (from classloader) to discover request processor classes.
 * @param scanPath scanPah using ',' as split.
 * @throws IOException  IOException//ww  w .j a va  2  s .  com
 */
private static void discoverFromClassPath(final String scanPath) throws IOException {

    final String[] paths = scanPath.split(",");
    final Set<URL> urls = new LinkedHashSet<URL>();

    /** using static ??  */
    final ClassPathResolver classPathResolver = new ClassPathResolver();

    for (String path : paths) {

        /**
         * the being two types of the scanPath.
         *  1 package: org.b3log.process
         *  2 ant-style classpath: org/b3log/** /*process.class
         */
        if (!AntPathMatcher.isPattern(path)) {
            path = path.replaceAll("\\.", "/") + "/**/*.class";
        }

        urls.addAll(classPathResolver.getResources(path));
    }

    for (URL url : urls) {
        final DataInputStream classInputStream = new DataInputStream(url.openStream());

        final ClassFile classFile = new ClassFile(classInputStream);
        final AnnotationsAttribute annotationsAttribute = (AnnotationsAttribute) classFile
                .getAttribute(AnnotationsAttribute.visibleTag);

        if (null == annotationsAttribute) {
            continue;
        }

        for (Annotation annotation : annotationsAttribute.getAnnotations()) {
            if ((annotation.getTypeName()).equals(RequestProcessor.class.getName())) {
                // Found a request processor class, loads it
                final String className = classFile.getName();

                Class<?> clz;

                try {
                    clz = Thread.currentThread().getContextClassLoader().loadClass(className);
                } catch (final ClassNotFoundException e) {
                    LOGGER.log(Level.SEVERE, "some error to load the class[" + className + "]", e);
                    break;
                }

                LOGGER.log(Level.FINER, "Found a request processor[className={0}]", className);
                final Method[] declaredMethods = clz.getDeclaredMethods();

                for (int i = 0; i < declaredMethods.length; i++) {
                    final Method mthd = declaredMethods[i];
                    final RequestProcessing requestProcessingMethodAnn = mthd
                            .getAnnotation(RequestProcessing.class);

                    if (null == requestProcessingMethodAnn) {
                        continue;
                    }
                    LOGGER.log(Level.INFO, "get the matched processing Class[{0}], method[{1}]",
                            new Object[] { clz.getCanonicalName(), mthd.getName() });
                    addProcessorMethod(requestProcessingMethodAnn, clz, mthd);
                }
            }
        }
    }

}

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

@Override
public void modifyConfig(IAggregator aggregator, Object configObj) {
    final String sourceMethod = "modifyConfig"; //$NON-NLS-1$
    boolean isTraceLogging = log.isLoggable(Level.FINER);
    // The server-side AMD config has been updated.  Add an entry to the
    // {@code paths} property to map the resource (combo) path to the
    // location of the combo resources on the server.
    Context context = Context.enter();
    Scriptable config = (Scriptable) configObj;
    try {/*from   w ww  . j  a  v  a 2s.com*/
        if (isTraceLogging) {
            log.entering(AbstractHttpTransport.class.getName(), sourceMethod,
                    new Object[] { aggregator, Context.toString(config) });
        }
        Object pathsObj = config.get(PATHS_PROPNAME, config);
        if (pathsObj == Scriptable.NOT_FOUND) {
            // If not present, add it.
            config.put("paths", config, context.newObject(config)); //$NON-NLS-1$
            pathsObj = (Scriptable) config.get(PATHS_PROPNAME, config);
        }
        ((Scriptable) pathsObj).put(getResourcePathId(), (Scriptable) pathsObj, getComboUri().toString());
        if (isTraceLogging) {
            log.finer("modified config = " + Context.toString(config)); //$NON-NLS-1$
            log.exiting(AbstractHttpTransport.class.getName(), sourceMethod);
        }
    } finally {
        Context.exit();
    }
}

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

@Override
public JSONObject get(final org.b3log.latke.repository.Query query) throws RepositoryException {
    JSONObject ret;//from w ww  . j  a va  2s  .  c o  m

    final String cacheKey = CACHE_KEY_PREFIX + query.getCacheKey() + "_" + getName();

    LOGGER.log(Level.FINEST, "Executing a query[cacheKey={0}, query=[{1}]]",
            new Object[] { cacheKey, query.toString() });

    if (cacheEnabled) {
        ret = (JSONObject) CACHE.get(cacheKey);
        if (null != ret) {
            LOGGER.log(Level.FINER, "Got query result[cacheKey={0}] from repository cache[name={1}]",
                    new Object[] { cacheKey, getName() });
            return ret;
        }
    }

    final int currentPageNum = query.getCurrentPageNum();
    final Set<Projection> projections = query.getProjections();
    final Filter filter = query.getFilter();
    final int pageSize = query.getPageSize();
    final Map<String, SortDirection> sorts = query.getSorts();
    // Asssumes the application call need to count page
    int pageCount = -1;

    // If the application caller need not to count page, gets the page count the caller specified 
    if (null != query.getPageCount()) {
        pageCount = query.getPageCount();
    }

    ret = get(currentPageNum, pageSize, pageCount, projections, sorts, filter, cacheKey);

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

        try {
            cacheQueryResults(ret.optJSONArray(Keys.RESULTS), query);
        } catch (final JSONException e) {
            LOGGER.log(Level.WARNING, "Caches query results failed", e);
        }
    }

    return ret;
}

From source file:org.aselect.server.request.handler.IDPFHandler.java

/**
 * @param request// www  . j a  v a2s.  c o  m
 * @param extracted_credentials
 * @param sMethod
 * @param extractedAselect_credentials
 * @return 
 * @throws ASelectCommunicationException
 */
private String verify_credentials(HttpServletRequest request, String extracted_credentials)
        throws ASelectCommunicationException {
    String sMethod = "verify_credentials";
    // This could be done by getting request parametermap
    String queryData = request.getQueryString();
    String extractedRid = queryData.replaceFirst(".*rid=([^&]*).*$", "$1");
    String finalReqURL = aselectServerURL;
    String finalReqSharedSecret = sharedSecret;
    String finalReqAselectServer = _sMyServerID;
    String finalReqrequest = "verify_credentials";

    //Construct request data
    String finalRequestURL = null;
    try {
        finalRequestURL = finalReqURL + "?" + "shared_secret="
                + URLEncoder.encode(finalReqSharedSecret, "UTF-8") + "&a-select-server="
                + URLEncoder.encode(finalReqAselectServer, "UTF-8") + "&request="
                + URLEncoder.encode(finalReqrequest, "UTF-8") + "&aselect_credentials=" + extracted_credentials
                +
                //                        "&check-signature=" + URLEncoder.encode(ridCheckSignature, "UTF-8") +
                "&rid=" + extractedRid;
    } catch (UnsupportedEncodingException e3) {
        _systemLogger.log(Level.SEVERE, MODULE, sMethod,
                "Could not URLEncode to UTF-8, this should not happen!");
        throw new ASelectCommunicationException(Errors.ERROR_ASELECT_INTERNAL_ERROR, e3);
    }
    String finalResult = "";

    //Send data
    _systemLogger.log(Level.INFO, MODULE, sMethod, "Retrieving attributes through: " + finalRequestURL);

    BufferedReader in = null;
    try {
        URL url = new URL(finalRequestURL);

        in = new BufferedReader(new InputStreamReader(url.openStream()));

        String inputLine = null;
        while ((inputLine = in.readLine()) != null) {
            finalResult += inputLine;
        }
        _systemLogger.log(Level.FINER, MODULE, sMethod, "Retrieved attributes in: " + finalResult);

    } catch (Exception e) {
        _systemLogger.log(Level.SEVERE, MODULE, sMethod,
                "Could not retrieve attributes from aselectserver: " + finalReqAselectServer);
        throw new ASelectCommunicationException(Errors.ERROR_ASELECT_IO, e);
    } finally {
        if (in != null)
            try {
                in.close();
            } catch (IOException e) {
                _systemLogger.log(Level.WARNING, MODULE, sMethod,
                        "Could not close stream to aselectserver : " + finalReqAselectServer);
            }
    }
    return finalResult;
}

From source file:com.granule.json.utils.internal.JSONObject.java

/**
 * Method to write aa standard attribute/subtag containing object
 * @param writer The writer object to render the XML to.
 * @param indentDepth How far to indent.
 * @param contentOnly Whether or not to write the object name as part of the output
 * @param compact Flag to denote whether or not to write the object in compact form.
 * @throws IOException Trhown if an error occurs on write.
 */// ww  w  . j av  a2 s.  c o m
private void writeComplexObject(Writer writer, int indentDepth, boolean contentOnly, boolean compact)
        throws IOException {
    if (logger.isLoggable(Level.FINER))
        logger.entering(className, "writeComplexObject(Writer, int, boolean, boolean)");

    boolean wroteTagText = false;

    if (!contentOnly) {
        if (logger.isLoggable(Level.FINEST))
            logger.logp(Level.FINEST, className, "writeComplexObject(Writer, int, boolean, boolean)",
                    "Writing object: [" + this.objectName + "]");

        if (!compact) {
            writeIndention(writer, indentDepth);
        }

        writer.write("\"" + this.objectName + "\"");

        if (!compact) {
            writer.write(" : {\n");
        } else {
            writer.write(":{");
        }
    } else {
        if (logger.isLoggable(Level.FINEST))
            logger.logp(Level.FINEST, className, "writeObject(Writer, int, boolean, boolean)",
                    "Writing object contents as an anonymous object (usually an array entry)");

        if (!compact) {
            writeIndention(writer, indentDepth);
            writer.write("{\n");
        } else {
            writer.write("{");
        }
    }

    if (this.tagText != null && !this.tagText.equals("") && !this.tagText.trim().equals("")) {
        writeAttribute(writer, "content", this.tagText.trim(), indentDepth + 1, compact);
        wroteTagText = true;
    }

    if (this.attrs != null && !this.attrs.isEmpty() && wroteTagText) {
        if (!compact) {
            writer.write(",\n");
        } else {
            writer.write(",");
        }
    }

    writeAttributes(writer, this.attrs, indentDepth, compact);
    if (!this.jsonObjects.isEmpty()) {
        if (this.attrs != null && (!this.attrs.isEmpty() || wroteTagText)) {
            if (!compact) {
                writer.write(",\n");
            } else {
                writer.write(",");
            }

        } else {
            if (!compact) {
                writer.write("\n");
            }
        }
        writeChildren(writer, indentDepth, compact);
    } else {
        if (!compact) {
            writer.write("\n");
        }
    }

    if (!compact) {
        writeIndention(writer, indentDepth);
        writer.write("}\n");
        //writer.write("\n");
    } else {
        writer.write("}");
    }

    if (logger.isLoggable(Level.FINER))
        logger.exiting(className, "writeComplexObject(Writer, int, boolean, boolean)");
}

From source file:org.eclipse.birt.data.oda.mongodb.impl.MDbResultSet.java

private static void logFetchedFirstElementFromArray(String columnName, int arraySize) {
    // log that only first value in set is returned
    if (arraySize > 1 && getLogger().isLoggable(Level.FINER))
        getLogger().finer(Messages.bind("Fetching only the first value out of {0} for the field {1}.", //$NON-NLS-1$
                Integer.valueOf(arraySize), columnName));
}

From source file:org.cloudifysource.esc.driver.provisioning.byon.ByonProvisioningDriver.java

private void stopAgentAndWait(final int expectedGsmCount, final String ipAddress)
        throws TimeoutException, InterruptedException {

    if (admin == null) {
        final Integer discoveryPort = getLusPort();
        admin = Utils.getAdminObject(ipAddress, expectedGsmCount, discoveryPort);
    }/*from w w w  .  j av  a 2  s.  c  o m*/

    final Map<String, GridServiceAgent> agentsMap = admin.getGridServiceAgents().getHostAddress();
    // GridServiceAgent agent = agentsMap.get(ipAddress);
    GSA agent = null;
    for (final Entry<String, GridServiceAgent> agentEntry : agentsMap.entrySet()) {
        if (IPUtils.isSameIpAddress(agentEntry.getKey(), ipAddress)
                || agentEntry.getKey().equalsIgnoreCase(ipAddress)) {
            agent = ((InternalGridServiceAgent) agentEntry.getValue()).getGSA();
        }
    }

    if (agent != null) {
        logger.info("ByonProvisioningDriver: shutting down agent on server: " + ipAddress);
        try {
            admin.close();
            agent.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);
            }
        }

        final long end = System.currentTimeMillis()
                + TimeUnit.MINUTES.toMillis(AGENT_SHUTDOWN_TIMEOUT_IN_MINUTES);
        boolean agentUp = isAgentUp(agent);
        while (agentUp && System.currentTimeMillis() < end) {
            logger.fine("next check in " + TimeUnit.MILLISECONDS.toSeconds(THREAD_WAITING_IDLE_TIME_IN_SECS)
                    + " seconds");
            Thread.sleep(TimeUnit.SECONDS.toMillis(THREAD_WAITING_IDLE_TIME_IN_SECS));
            agentUp = isAgentUp(agent);
        }

        if (!agentUp && System.currentTimeMillis() >= end) {
            throw new TimeoutException("Agent shutdown timed out (agent IP: " + ipAddress + ")");
        }
    }
}