Example usage for android.database.sqlite SQLiteConnection describeCurrentOperationUnsafe

List of usage examples for android.database.sqlite SQLiteConnection describeCurrentOperationUnsafe

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteConnection describeCurrentOperationUnsafe.

Prototype

String describeCurrentOperationUnsafe() 

Source Link

Document

Describes the currently executing operation, in the case where the caller might not actually own the connection.

Usage

From source file:io.requery.android.database.sqlite.SQLiteConnectionPool.java

private void logConnectionPoolBusyLocked(long waitMillis, int connectionFlags) {
    final Thread thread = Thread.currentThread();
    StringBuilder msg = new StringBuilder();
    msg.append("The connection pool for database '").append(mConfiguration.label);
    msg.append("' has been unable to grant a connection to thread ");
    msg.append(thread.getId()).append(" (").append(thread.getName()).append(") ");
    msg.append("with flags 0x").append(Integer.toHexString(connectionFlags));
    msg.append(" for ").append(waitMillis * 0.001f).append(" seconds.\n");

    ArrayList<String> requests = new ArrayList<>();
    int activeConnections = 0;
    int idleConnections = 0;
    if (!mAcquiredConnections.isEmpty()) {
        for (SQLiteConnection connection : mAcquiredConnections.keySet()) {
            String description = connection.describeCurrentOperationUnsafe();
            if (description != null) {
                requests.add(description);
                activeConnections += 1;/*w  w  w.  ja va  2  s.  com*/
            } else {
                idleConnections += 1;
            }
        }
    }
    int availableConnections = mAvailableNonPrimaryConnections.size();
    if (mAvailablePrimaryConnection != null) {
        availableConnections += 1;
    }

    msg.append("Connections: ").append(activeConnections).append(" active, ");
    msg.append(idleConnections).append(" idle, ");
    msg.append(availableConnections).append(" available.\n");

    if (!requests.isEmpty()) {
        msg.append("\nRequests in progress:\n");
        for (String request : requests) {
            msg.append("  ").append(request).append("\n");
        }
    }

    Log.w(TAG, msg.toString());
}