Example usage for java.util.logging Level FINEST

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

Introduction

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

Prototype

Level FINEST

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

Click Source Link

Document

FINEST indicates a highly detailed tracing message.

Usage

From source file:com.ibm.iotf.client.AbstractClient.java

/**
 * <p>Connects the device to IBM Watson IoT Platform and retries when there is an exception 
 * based on the value set in retry parameter. <br>
 * /*from   w w  w  .  j  a  v a2 s  .co m*/
 * This method does not retry when the following exceptions occur.</p>
 * 
 * <ul class="simple">
 *  <li> MqttSecurityException - One or more credentials are wrong
 *    <li>UnKnownHostException - Host doesn't exist. For example, a wrong organization name is used to connect.
 * </ul>
 * 
 * @param numberOfRetryAttempts - How many number of times to retry when there is a failure in connecting to Watson
 * IoT Platform.
 * @throws MqttException see above
 **/
public void connect(int numberOfRetryAttempts) throws MqttException {
    final String METHOD = "connect";
    // return if its already connected
    if (mqttAsyncClient != null && mqttAsyncClient.isConnected()) {
        LoggerUtility.log(Level.WARNING, CLASS_NAME, METHOD, "Client is already connected");
        return;
    }
    boolean tryAgain = true;
    int connectAttempts = 0;
    // clear the disconnect state when the user connects the client to Watson IoT Platform
    disconnectRequested = false;
    String userCertificate = trimedValue(options.getProperty("Use-Secure-Certificate"));

    if (getOrgId() == QUICK_START) {
        configureMqtt();
    } else if ((getOrgId() != QUICK_START)
            && (userCertificate != null && userCertificate.equalsIgnoreCase("True"))) {
        LoggerUtility.info(CLASS_NAME, METHOD, "Initiating Certificate based authentication");
        connectUsingCertificate();
        if (isAutomaticReconnect()) {
            DisconnectedBufferOptions disconnectedOpts = new DisconnectedBufferOptions();
            disconnectedOpts.setBufferEnabled(true);
            disconnectedOpts.setBufferSize(getDisconnectedBufferSize());
            mqttAsyncClient.setBufferOpts(disconnectedOpts);
        }
    } else {
        LoggerUtility.info(CLASS_NAME, METHOD, "Initiating Token based authentication");
        connectUsingToken();
        if (isAutomaticReconnect()) {
            DisconnectedBufferOptions disconnectedOpts = new DisconnectedBufferOptions();
            disconnectedOpts.setBufferEnabled(true);
            disconnectedOpts.setBufferSize(getDisconnectedBufferSize());
            mqttAsyncClient.setBufferOpts(disconnectedOpts);
        }
    }

    while (tryAgain && disconnectRequested == false) {
        connectAttempts++;

        LoggerUtility.info(CLASS_NAME, METHOD, "Connecting client " + this.clientId + " to "
                + mqttAsyncClient.getServerURI() + " (attempt #" + connectAttempts + ")...");

        try {
            mqttAsyncClient.connect(mqttClientOptions).waitForCompletion(1000 * 60);
        } catch (MqttSecurityException e) {
            System.err.println("Looks like one or more connection parameters are wrong !!!");
            LoggerUtility.log(Level.SEVERE, CLASS_NAME, METHOD, "Connecting to Watson IoT Platform failed - "
                    + "one or more connection parameters are wrong !!!", e);
            throw e;

        } catch (MqttException e) {
            if (connectAttempts > numberOfRetryAttempts) {
                LoggerUtility.log(Level.SEVERE, CLASS_NAME, METHOD, "Connecting to Watson IoT Platform failed",
                        e);
                // We must give up as the host doesn't exist.
                throw e;
            }
            e.printStackTrace();
        }

        if (mqttAsyncClient.isConnected()) {
            LoggerUtility.info(CLASS_NAME, METHOD,
                    "Successfully connected " + "to the IBM Watson IoT Platform");

            if (LoggerUtility.isLoggable(Level.FINEST)) {
                LoggerUtility.log(Level.FINEST, CLASS_NAME, METHOD,
                        " * Connection attempts: " + connectAttempts);
            }

            tryAgain = false;
        } else {
            waitBeforeNextConnectAttempt(connectAttempts);
        }
    }
}

From source file:net.sourceforge.pmd.ant.PMDTask.java

@Override
public void execute() throws BuildException {
    validate();/* www  .j ava  2  s  . co  m*/
    final Handler antLogHandler = new AntLogHandler(this);
    final ScopedLogHandlersManager logManager = new ScopedLogHandlersManager(Level.FINEST, antLogHandler);
    try {
        doTask();
    } finally {
        logManager.close();
    }
}

From source file:com.sun.grizzly.http.jk.common.ChannelSocket.java

public void accept(MsgContext ep) throws IOException {
    if (sSocket == null) {
        return;/*from   w  ww  .j a  v a 2  s.  c  o m*/
    }
    synchronized (this) {
        while (paused) {
            try {
                wait();
            } catch (InterruptedException ie) {
                //Ignore, since can't happen
            }
        }
    }
    Socket s = sSocket.accept();
    ep.setNote(socketNote, s);
    if (LoggerUtils.getLogger().isLoggable(Level.FINEST)) {
        LoggerUtils.getLogger().log(Level.FINEST, "Accepted socket " + s);
    }

    try {
        setSocketOptions(s);
    } catch (SocketException sex) {
        LoggerUtils.getLogger().log(Level.FINEST, "Error initializing Socket Options", sex);
    }

    requestCount++;

    InputStream is = new BufferedInputStream(s.getInputStream());
    OutputStream os;
    if (bufferSize > 0) {
        os = new BufferedOutputStream(s.getOutputStream(), bufferSize);
    } else {
        os = s.getOutputStream();
    }
    ep.setNote(isNote, is);
    ep.setNote(osNote, os);
    ep.setControl(tp);
}

From source file:jenkins.plugins.openstack.compute.SlaveOptionsDescriptor.java

@Restricted(DoNotUse.class)
@InjectOsAuth/*w  ww .  j  a v  a2s . com*/
public ListBoxModel doFillNetworkIdItems(@QueryParameter String networkId, @QueryParameter String endPointUrl,
        @QueryParameter String identity, @QueryParameter String credential, @QueryParameter String zone) {

    ListBoxModel m = new ListBoxModel();
    m.add("None specified", "");

    try {
        Openstack openstack = Openstack.Factory.get(endPointUrl, identity, credential, zone);
        for (org.openstack4j.model.network.Network network : openstack.getSortedNetworks()) {
            m.add(String.format("%s (%s)", network.getName(), network.getId()), network.getId());
        }
        return m;
    } catch (AuthenticationException | FormValidation | ConnectionException ex) {
        LOGGER.log(Level.FINEST, "Openstack call failed", ex);
    } catch (Exception ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
    }

    if (Util.fixEmpty(networkId) != null) {
        m.add(networkId);
    }

    return m;
}

From source file:com.clothcat.hpoolauto.model.HtmlGenerator.java

/**
 * Take a number of seconds and convert it to days, hours, minutes and seconds
 *//*from  w  ww. j ava 2 s  .  c om*/
private static String convertTimeToString(long s) {
    HLogger.log(Level.FINEST, "Converting: " + s + " seconds");
    long days = s / Constants.SECS_IN_DAY;
    s %= Constants.SECS_IN_DAY;
    long hours = s / Constants.SECS_IN_HOUR;
    s %= Constants.SECS_IN_HOUR;
    long minutes = s / Constants.SECS_IN_MINUTE;
    s %= Constants.SECS_IN_MINUTE;
    String response = "";
    if (days > 0) {
        response += "" + days + ((days == 1) ? " day " : " days ");
    }
    response += "" + hours + ((hours == 1) ? " hour " : " hours ");
    response += "" + minutes + ((minutes == 1) ? " minute " : " minutes ");
    response += "" + s + ((s == 1) ? " second" : " seconds");
    HLogger.log(Level.FINEST, "Converted to: " + response);
    return response;
}

From source file:com.sun.grizzly.http.jk.common.ChannelUn.java

/** Process a single ajp connection.
 *//*from   w ww .j  a v a2  s.  co m*/
void processConnection(MsgContext ep) {
    if (LoggerUtils.getLogger().isLoggable(Level.FINEST)) {
        LoggerUtils.getLogger().log(Level.FINEST, "New ajp connection ");
    }
    try {
        MsgAjp recv = new MsgAjp();
        while (running) {
            int res = this.receive(recv, ep);
            if (res < 0) {
                // EOS
                break;
            }
            ep.setType(0);
            LoggerUtils.getLogger().log(Level.FINEST, "Process msg ");
            int status = next.invoke(recv, ep);
        }
        if (LoggerUtils.getLogger().isLoggable(Level.FINEST)) {
            LoggerUtils.getLogger().log(Level.FINEST, "Closing un channel");
        }
        try {
            Request req = (Request) ep.getRequest();
            if (req != null) {
                ObjectName roname = (ObjectName) ep.getNote(JMXRequestNote);
                if (roname != null) {
                    Registry.getRegistry(null, null).unregisterComponent(roname);
                }
                req.getRequestProcessor().setGlobalProcessor(null);
            }
        } catch (Exception ee) {
            LoggerUtils.getLogger().log(Level.SEVERE, "Error, releasing connection", ee);
        }
        this.close(ep);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.freesundance.contacts.google.ContactsExample.java

/**
 * Run the example program.//from   w  w w. j av  a 2  s.com
 *
 * @param args Command-line arguments.
 */
public static void main(String[] args) throws ServiceException, IOException, GeneralSecurityException {

    ContactsExampleParameters parameters = new ContactsExampleParameters(args);
    if (parameters.isVerbose()) {
        httpRequestLogger.setLevel(Level.FINEST);
        ConsoleHandler handler = new ConsoleHandler();
        handler.setLevel(Level.FINEST);
        httpRequestLogger.addHandler(handler);
        httpRequestLogger.setUseParentHandlers(false);
    }

    if (parameters.numberOfParameters() == 0 || parameters.isHelp()
            || (parameters.getAction() == null && parameters.getScript() == null)) {
        displayUsage();
        return;
    }

    // Check that at most one of contactfeed and groupfeed has been provided
    if (parameters.isContactFeed() && parameters.isGroupFeed()) {
        throw new RuntimeException("Only one of contactfeed / groupfeed should" + "be specified");
    }

    ContactsExample example = new ContactsExample(parameters);

    processAction(example, parameters);
    System.out.flush();
}

From source file:com.prowidesoftware.swift.model.SwiftTagListBlock.java

/**
 * Adds a tag to this block./*from  www . j  ava  2  s  .c o m*/
 * <b>This method may be deleted after 2016</b>
 *
 * @param t the tag to add
 * @throws IllegalArgumentException if parameter t is <code>null</code>
 * @deprecated use append(tag) instead of this
 * @see #append(Tag)
 */
@Deprecated
@DeleteSchedule(2016)
public void addTag(final Tag t) {
    // sanity check
    Validate.notNull(t, "parameter 't' cannot not be null");

    if (log.isLoggable(Level.FINEST)) {
        log.finest("Adding Tag [" + t + "]");
    }
    if (this.tags == null) {
        this.tags = new ArrayList<Tag>();
    }
    this.tags.add(t);
}

From source file:io.hops.hopsworks.api.user.UserService.java

@POST
@Path("getRole")
@Produces(MediaType.APPLICATION_JSON)/*from   www.j  a va2 s.  c  o m*/
public Response getRole(@FormParam("projectId") int projectId, @Context SecurityContext sc,
        @Context HttpServletRequest req) {
    String email = sc.getUserPrincipal().getName();

    UserProjectDTO userDTO = new UserProjectDTO();
    userDTO.setEmail(email);
    userDTO.setProject(projectId);

    List<ProjectTeam> list = projectController.findProjectTeamById(projectId);

    for (ProjectTeam pt : list) {
        logger.log(Level.FINEST, "{0} ({1}) -  {2}", new Object[] { pt.getProjectTeamPK().getTeamMember(),
                pt.getProjectTeamPK().getProjectId(), pt.getTeamRole() });
        if (pt.getProjectTeamPK().getTeamMember().compareToIgnoreCase(email) == 0) {
            userDTO.setRole(pt.getTeamRole());
        }
    }

    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).entity(userDTO).build();
}

From source file:org.apache.reef.io.network.NetworkConnectionServiceTest.java

@Test
public void testMultithreadedSharedConnMessagingNetworkConnServiceRate() throws Exception {

    Assume.assumeFalse("Use log level INFO to run benchmarking", LOG.isLoggable(Level.FINEST));

    LOG.log(Level.FINEST, name.getMethodName());

    final int[] messageSizes = { 2000 }; // {1,16,32,64,512,64*1024,1024*1024};

    for (final int size : messageSizes) {
        final String message = StringUtils.repeat('1', size);
        final int numMessages = 300000 / (Math.max(1, size / 512));
        final int numThreads = 2;
        final int totalNumMessages = numMessages * numThreads;
        final Monitor monitor = new Monitor();
        final Codec<String> codec = new StringCodec();
        try (final NetworkMessagingTestService messagingTestService = new NetworkMessagingTestService(
                localAddress)) {/* w w  w. j  a v a2s.  co m*/
            messagingTestService.registerTestConnectionFactory(groupCommClientId, totalNumMessages, monitor,
                    codec);

            final ExecutorService e = Executors.newCachedThreadPool();

            try (final Connection<String> conn = messagingTestService
                    .getConnectionFromSenderToReceiver(groupCommClientId)) {

                final long start = System.currentTimeMillis();
                for (int i = 0; i < numThreads; i++) {
                    e.submit(new Runnable() {
                        @Override
                        public void run() {

                            try {
                                conn.open();
                                for (int count = 0; count < numMessages; ++count) {
                                    // send messages to the receiver.
                                    conn.write(message);
                                }
                            } catch (final Exception e) {
                                throw new RuntimeException(e);
                            }
                        }
                    });
                }

                e.shutdown();
                e.awaitTermination(30, TimeUnit.SECONDS);
                monitor.mwait();
                final long end = System.currentTimeMillis();
                final double runtime = ((double) end - start) / 1000;
                LOG.log(Level.INFO, "size: " + size + "; messages/s: " + totalNumMessages / runtime
                        + " bandwidth(bytes/s): " + ((double) totalNumMessages * 2 * size) / runtime); // x2 for unicode chars
            }
        }
    }
}